|
@@ -1,10 +1,12 @@
|
|
|
package com.rongwei.sfcommon.sys.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.rongwe.scentity.domian.CheckItemsDo;
|
|
|
import com.rongwe.scentity.domian.PointCheckDo;
|
|
|
+import com.rongwe.scentity.vo.CheckItemsTypeVo;
|
|
|
import com.rongwei.safecommon.utils.CXCommonUtils;
|
|
|
import com.rongwei.sfcommon.sys.dao.CheckItemsDao;
|
|
|
import com.rongwei.sfcommon.sys.service.CheckItemsService;
|
|
@@ -23,37 +25,39 @@ public class CheckItemsServiceImpl extends ServiceImpl<CheckItemsDao, CheckItems
|
|
|
private PointCheckService pointCheckService;
|
|
|
|
|
|
@Autowired
|
|
|
- private CheckItemsDao checkItemsDao;
|
|
|
+ private CheckItemsDao checkItemsDao;
|
|
|
|
|
|
/**
|
|
|
* 设备列表删除验证是否存在点检记录
|
|
|
+ *
|
|
|
* @param ids
|
|
|
*/
|
|
|
- public String deleteValidate(List<String> ids){
|
|
|
+ public String deleteValidate(List<String> ids) {
|
|
|
String warnMes = null;
|
|
|
List<String> retWarn = new ArrayList<>();
|
|
|
- if(ids != null && ids.size()>0){
|
|
|
- for(String id:ids){
|
|
|
+ if (ids != null && ids.size() > 0) {
|
|
|
+ for (String id : ids) {
|
|
|
CheckItemsDo checkItemsDo = this.getById(id);
|
|
|
- Map<String,Object> pcMap = new HashMap<>();
|
|
|
- pcMap.put("CHECKITEMID",id);
|
|
|
- List<PointCheckDo> pointCheckDos = (List<PointCheckDo>)pointCheckService.listByMap(pcMap);
|
|
|
- if(pointCheckDos != null && pointCheckDos.size()>0){
|
|
|
- retWarn.add("设备编号:"+checkItemsDo.getCheckitemcode()+";设备名称:"+checkItemsDo.getCheckitemname());
|
|
|
- }else{
|
|
|
+ Map<String, Object> pcMap = new HashMap<>();
|
|
|
+ pcMap.put("CHECKITEMID", id);
|
|
|
+ List<PointCheckDo> pointCheckDos = (List<PointCheckDo>) pointCheckService.listByMap(pcMap);
|
|
|
+ if (pointCheckDos != null && pointCheckDos.size() > 0) {
|
|
|
+ retWarn.add("设备编号:" + checkItemsDo.getCheckitemcode() + ";设备名称:" + checkItemsDo.getCheckitemname());
|
|
|
+ } else {
|
|
|
this.removeById(id);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if(retWarn != null && retWarn.size()>0){
|
|
|
- warnMes = String.join("\n",retWarn);
|
|
|
- warnMes = warnMes + "\n"+"以上设备已存在点检记录不可删除;";
|
|
|
+ if (retWarn != null && retWarn.size() > 0) {
|
|
|
+ warnMes = String.join("\n", retWarn);
|
|
|
+ warnMes = warnMes + "\n" + "以上设备已存在点检记录不可删除;";
|
|
|
}
|
|
|
return warnMes;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 备用设备列表
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
@@ -65,21 +69,22 @@ public class CheckItemsServiceImpl extends ServiceImpl<CheckItemsDao, CheckItems
|
|
|
@Override
|
|
|
public void reportEquMessage() {
|
|
|
//查询所有需要提醒的设备
|
|
|
- List<CheckItemsDo> list = this.baseMapper.selectNeedReportEqu();
|
|
|
+ List<CheckItemsTypeVo> list = this.baseMapper.selectNeedReportEqu();
|
|
|
//查询设备的工厂,三个工厂的设备管理员角色下的员工ID
|
|
|
Set<String> tenantIds = list.stream().map(CheckItemsDo::getTenantid).collect(Collectors.toSet());
|
|
|
Map<String, List<String>> equManager = new HashMap<>();
|
|
|
- tenantIds.forEach(tenantId ->{
|
|
|
+ tenantIds.forEach(tenantId -> {
|
|
|
List<String> userIdList = this.baseMapper.selectUserByTenantId(tenantId);
|
|
|
equManager.put(tenantId, userIdList);
|
|
|
});
|
|
|
|
|
|
//根据设备的所属工厂给自己工厂的设备管理员发送消息
|
|
|
- list.forEach(item->{
|
|
|
- if(ObjectUtil.isNotEmpty(item.getTenantid())) {
|
|
|
+ list.forEach(item -> {
|
|
|
+ if (ObjectUtil.isNotEmpty(item.getTenantid())) {
|
|
|
//发送消息
|
|
|
CXCommonUtils.sendNotify("特种设备提醒",
|
|
|
- "特种设备【" + item.getCheckitemname() + "】预计提醒时间已到",
|
|
|
+ "【设备年检提醒】,您好,有如下设备即将年检到期,请及时处理:" +
|
|
|
+ "设备类型:【" + item.getTypeName() + "】,设备编号:【" + item.getCheckitemcode() + "】,设备名称:【" + item.getCheckitemname() + "】,年检日期:【" + DateUtil.format(item.getNextcheckdate(), "yyy-MM-dd") + "】",
|
|
|
null,
|
|
|
equManager.get(item.getTenantid()),
|
|
|
item.getId(),
|