|
@@ -9,11 +9,12 @@ import com.rongwe.scentity.vo.CheckTemplateVo;
|
|
|
import com.rongwei.commonservice.serial.service.CommonDictService;
|
|
|
import com.rongwei.commonservice.serial.service.SysSerialNumberService;
|
|
|
import com.rongwei.rwadmincommon.system.dao.SysUserDao;
|
|
|
+import com.rongwei.rwadmincommon.system.domain.SysDictDo;
|
|
|
import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
import com.rongwei.rwcommon.utils.StringUtils;
|
|
|
import com.rongwei.rwcommon.vo.generalsql.GeneralApiParameter;
|
|
|
import com.rongwei.rwcommon.vo.generalsql.SlaveDMLVo;
|
|
|
-import com.rongwei.rwcommonentity.commonservers.vo.SysSerialVo;
|
|
|
+import com.rongwei.safecommon.utils.CXCommonUtils;
|
|
|
import com.rongwei.sfcommon.sys.dao.CheckTemplateDao;
|
|
|
import com.rongwei.sfcommon.sys.service.*;
|
|
|
import com.rongwei.sfcommon.utils.MlConstants;
|
|
@@ -23,7 +24,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
+import static com.rongwei.safecommon.utils.CXCommonUtils.DEFAULT_NOTIFY_STATUS;
|
|
|
+import static com.rongwei.safecommon.utils.SaveConstans.NotifyTitle.*;
|
|
|
+import static com.rongwei.safecommon.utils.SaveConstans.NotifyType.INSPECTION;
|
|
|
import static com.rongwei.sfcommon.utils.CommonUtil.streamCodeGeneration;
|
|
|
|
|
|
@Service("checkTemplateService")
|
|
@@ -161,6 +166,8 @@ public class CheckTemplateServiceImpl extends ServiceImpl<CheckTemplateDao, Chec
|
|
|
List<List<CheckTemplateItemsDo>> middleItems = new ArrayList<>();
|
|
|
// 夜班检查项
|
|
|
List<List<CheckTemplateItemsDo>> nightItems = new ArrayList<>();
|
|
|
+ // 长白班检查项
|
|
|
+ List<List<CheckTemplateItemsDo>> changbaiClassItems = new ArrayList<>();
|
|
|
if (items == null || items.size() == 0) {
|
|
|
return;
|
|
|
}
|
|
@@ -179,6 +186,7 @@ public class CheckTemplateServiceImpl extends ServiceImpl<CheckTemplateDao, Chec
|
|
|
if (runTask && (StringUtils.isBlank(frequency) || !isNowCreateByFrequency(frequency))) {
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
// 白班
|
|
|
if (MlConstants.CHECK_SHIFT_EVERY_SHIFT.equals(shift) || MlConstants.CHECK_SHIFT_EVERY_DAY_SHIFT.equals(shift)) {
|
|
|
addCheckItems(dayItems, shiftcount, checkTemplateItem);
|
|
@@ -191,6 +199,10 @@ public class CheckTemplateServiceImpl extends ServiceImpl<CheckTemplateDao, Chec
|
|
|
if (MlConstants.CHECK_SHIFT_EVERY_SHIFT.equals(shift) || MlConstants.CHECK_SHIFT_EVERY_MIDDLE_SHIFT.equals(shift)) {
|
|
|
addCheckItems(middleItems, shiftcount, checkTemplateItem);
|
|
|
}
|
|
|
+ // 长白班
|
|
|
+ if (MlConstants.CHECK_SHIFT_EVERY_SHIFT.equals(shift) || MlConstants.CHECK_SHIFT_EVERY_CHANGBAI_CLASS_SHIFT.equals(shift)) {
|
|
|
+ addCheckItems(changbaiClassItems, shiftcount, checkTemplateItem);
|
|
|
+ }
|
|
|
}
|
|
|
// 生成点检任务
|
|
|
System.out.println("dayItems:" + dayItems.size() + "***" + "middleItems:" + middleItems.size() + "***" + "nightItems:" + nightItems.size());
|
|
@@ -200,6 +212,8 @@ public class CheckTemplateServiceImpl extends ServiceImpl<CheckTemplateDao, Chec
|
|
|
createPointCheckByTemplate(checkTemplate, middleItems, MlConstants.CHECK_SHIFT_EVERY_MIDDLE_SHIFT);
|
|
|
// 夜班任务
|
|
|
createPointCheckByTemplate(checkTemplate, nightItems, MlConstants.CHECK_SHIFT_EVERY_NIGHT_SHIFT);
|
|
|
+ // 夜班任务
|
|
|
+ createPointCheckByTemplate(checkTemplate, changbaiClassItems, MlConstants.CHECK_SHIFT_EVERY_CHANGBAI_CLASS_SHIFT);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -275,70 +289,79 @@ public class CheckTemplateServiceImpl extends ServiceImpl<CheckTemplateDao, Chec
|
|
|
* @param items 检查模板明细(检查内容)
|
|
|
* @param shift 班次
|
|
|
*/
|
|
|
- private void createPointCheckByTemplate(CheckTemplateDo checkTemplate,List<List<CheckTemplateItemsDo>> items,String shift){
|
|
|
- if(items != null && items.size()>0){
|
|
|
- List<PointCheckDo> pointChecks = new ArrayList<>();
|
|
|
- List<PointCheckItemDo> pointCheckItems = new ArrayList<>();
|
|
|
- // 每班几次就生成几个任务
|
|
|
- for(List<CheckTemplateItemsDo> checkItems:items){
|
|
|
- // 点检名称 班次+模板名称+当前日期
|
|
|
- String poName = commonDictService.getDictNameByValue("check-shift",shift)+"-"+checkTemplate.getTemplatename()+"-"+DateUtil.format(new Date(),"yyyy-MM-dd");
|
|
|
- // 设备表IDS
|
|
|
- String checkitemsids = checkTemplate.getCheckitemids();
|
|
|
- if(StringUtils.isNotEmpty(checkitemsids)){
|
|
|
- String[] checkitemsidArray = checkitemsids.split(",");
|
|
|
- for (String checkitemsid : checkitemsidArray) {
|
|
|
- // 每个设备生成一条点检任务
|
|
|
- CheckItemsDo checkItemsdo = checkItemsService.getById(checkitemsid);
|
|
|
- // 如当前设备未禁用状态则不生成点检任务
|
|
|
- if (checkItemsdo != null && MlConstants.CHECKITEM_STATUS_DISABLE.equals(checkItemsdo.getEnabled())) {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- // 点检编号
|
|
|
-
|
|
|
- String pointcheckcode = streamCodeGeneration("asp_point_check_POINTCHECKCODE",
|
|
|
- "@{date:yyyyMMdd}@{serialNumber:#0000000}","date:yyyy", checkTemplate.getTenantid());
|
|
|
- // 点检生成
|
|
|
- PointCheckDo pointCheckDo = new PointCheckDo();
|
|
|
- pointCheckDo.setId(SecurityUtil.getUUID());
|
|
|
- pointCheckDo.setPointcheckname(poName);
|
|
|
- pointCheckDo.setPointcheckcode(pointcheckcode);
|
|
|
- pointCheckDo.setWorkshopid(checkTemplate.getYjorgid());
|
|
|
- pointCheckDo.setWorkshopname(checkTemplate.getYjorgname());
|
|
|
- //设备ID
|
|
|
- pointCheckDo.setCheckitemid(checkItemsdo.getId());
|
|
|
- //班次
|
|
|
- pointCheckDo.setShift(shift);
|
|
|
- //点检状态默认待点检
|
|
|
- pointCheckDo.setCheckstatus(MlConstants.POINT_CHECK_STATUS_WAIT);
|
|
|
- // 点检预警状态默认正常
|
|
|
- pointCheckDo.setCheckwarnstatus(MlConstants.POINTCEHCK_WARNSTATUS_NORMAL);
|
|
|
- pointCheckDo.setTenantid(checkTemplate.getTenantid());
|
|
|
- pointCheckDo.setSource("1");
|
|
|
- pointCheckDo.setTemplatetype(checkTemplate.getTemplatetype());
|
|
|
- //设备负责人
|
|
|
- Map<String, Object> duMap = new HashMap<>();
|
|
|
- duMap.put("CHECKITEMID", checkItemsdo.getId());
|
|
|
- List<CheckItemsDutyuserDo> checkItemsDutyusers = (List<CheckItemsDutyuserDo>) checkItemsDutyuserService.listByMap(duMap);
|
|
|
- //设置点检人
|
|
|
- String pcids = null;
|
|
|
- String pcnames = null;
|
|
|
- if (checkItemsDutyusers != null && checkItemsDutyusers.size() > 0) {
|
|
|
- for (CheckItemsDutyuserDo checkItemsDutyuser : checkItemsDutyusers) {
|
|
|
- // 生产属性的员工为点检人
|
|
|
- if (MlConstants.USER_ATTR_PRODUCTION.equals(checkItemsDutyuser.getDutyuserattribute())) {
|
|
|
- if (pcids == null) {
|
|
|
- pcids = checkItemsDutyuser.getDutyuserid();
|
|
|
- pcnames = checkItemsDutyuser.getDutyusername();
|
|
|
- } else {
|
|
|
- pcids = pcids + "," + checkItemsDutyuser.getDutyuserid();
|
|
|
- pcnames = pcnames + "," + checkItemsDutyuser.getDutyusername();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //有设备负责人则设置点检人为设备负责人
|
|
|
+ private void createPointCheckByTemplate(CheckTemplateDo checkTemplate,List<List<CheckTemplateItemsDo>> items,String shift) {
|
|
|
+ if (items.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<PointCheckDo> pointChecks = new ArrayList<>();
|
|
|
+ List<PointCheckItemDo> pointCheckItems = new ArrayList<>();
|
|
|
+ Map<PointCheckDo,List<String>> notifyType = new HashMap<>();
|
|
|
+ // 每班几次就生成几个任务
|
|
|
+ for(List<CheckTemplateItemsDo> checkItems:items){
|
|
|
+ // 点检名称 班次+模板名称+当前日期
|
|
|
+ String poName = commonDictService.getDictNameByValue("check-shift",shift)+"-"+checkTemplate.getTemplatename()+"-"+DateUtil.format(new Date(),"yyyy-MM-dd");
|
|
|
+ // 设备表IDS
|
|
|
+ String checkitemsids = checkTemplate.getCheckitemids();
|
|
|
+ // 获取模板的检查分类
|
|
|
+ String templatetype = checkTemplate.getTemplatetype();
|
|
|
+ if(StringUtils.isNotEmpty(checkitemsids)){
|
|
|
+ String[] checkitemsidArray = checkitemsids.split(",");
|
|
|
+ for (String checkitemsid : checkitemsidArray) {
|
|
|
+ // 每个设备生成一条点检任务
|
|
|
+ CheckItemsDo checkItemsdo = checkItemsService.getById(checkitemsid);
|
|
|
+ // 如当前设备未禁用状态则不生成点检任务
|
|
|
+ if (checkItemsdo != null && MlConstants.CHECKITEM_STATUS_DISABLE.equals(checkItemsdo.getEnabled())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 点检编号
|
|
|
+ String pointcheckcode = streamCodeGeneration("asp_point_check_POINTCHECKCODE",
|
|
|
+ "@{date:yyyyMMdd}@{serialNumber:#0000000}","date:yyyy", checkTemplate.getTenantid());
|
|
|
+ // 点检生成
|
|
|
+ PointCheckDo pointCheckDo = new PointCheckDo();
|
|
|
+ pointCheckDo.setId(SecurityUtil.getUUID());
|
|
|
+ pointCheckDo.setPointcheckname(poName);
|
|
|
+ pointCheckDo.setPointcheckcode(pointcheckcode);
|
|
|
+ pointCheckDo.setWorkshopid(checkTemplate.getYjorgid());
|
|
|
+ pointCheckDo.setWorkshopname(checkTemplate.getYjorgname());
|
|
|
+ //设备ID
|
|
|
+ pointCheckDo.setCheckitemid(checkItemsdo.getId());
|
|
|
+ //班次
|
|
|
+ pointCheckDo.setShift(shift);
|
|
|
+ //点检状态默认待点检
|
|
|
+ pointCheckDo.setCheckstatus(MlConstants.POINT_CHECK_STATUS_WAIT);
|
|
|
+ // 点检预警状态默认正常
|
|
|
+ pointCheckDo.setCheckwarnstatus(MlConstants.POINTCEHCK_WARNSTATUS_NORMAL);
|
|
|
+ pointCheckDo.setTenantid(checkTemplate.getTenantid());
|
|
|
+ pointCheckDo.setSource("1");
|
|
|
+ pointCheckDo.setTemplatetype(templatetype);
|
|
|
+ //设备负责人
|
|
|
+ Map<String, Object> duMap = new HashMap<>();
|
|
|
+ duMap.put("CHECKITEMID", checkItemsdo.getId());
|
|
|
+ duMap.put("DUTYUSERATTRIBUTE",templatetype);
|
|
|
+ List<CheckItemsDutyuserDo> checkItemsDutyusers = (List<CheckItemsDutyuserDo>) checkItemsDutyuserService.
|
|
|
+ listByMap(duMap);
|
|
|
+ // 组织需要发送德消息
|
|
|
+ if (!checkItemsDutyusers.isEmpty()){
|
|
|
+ notifyType.put(pointCheckDo,checkItemsDutyusers.stream().map(CheckItemsDutyuserDo::getDutyuserid).distinct().collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ //设置点检人
|
|
|
+// String pcids = null;
|
|
|
+// String pcnames = null;
|
|
|
+// if (checkItemsDutyusers != null && checkItemsDutyusers.size() > 0) {
|
|
|
+// for (CheckItemsDutyuserDo checkItemsDutyuser : checkItemsDutyusers) {
|
|
|
+// // 生产属性的员工为点检人
|
|
|
+// if (MlConstants.USER_ATTR_PRODUCTION.equals(checkItemsDutyuser.getDutyuserattribute())) {
|
|
|
+// if (pcids == null) {
|
|
|
+// pcids = checkItemsDutyuser.getDutyuserid();
|
|
|
+// pcnames = checkItemsDutyuser.getDutyusername();
|
|
|
+// } else {
|
|
|
+// pcids = pcids + "," + checkItemsDutyuser.getDutyuserid();
|
|
|
+// pcnames = pcnames + "," + checkItemsDutyuser.getDutyusername();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+ //有设备负责人则设置点检人为设备负责人
|
|
|
/*if(pcids != null){
|
|
|
pointCheckDo.setCheckuserid(pcids);
|
|
|
pointCheckDo.setCheckusername(pcnames);
|
|
@@ -370,43 +393,53 @@ public class CheckTemplateServiceImpl extends ServiceImpl<CheckTemplateDao, Chec
|
|
|
}
|
|
|
}*/
|
|
|
|
|
|
- //点检明细生成
|
|
|
- if(checkItems != null && checkItems.size()>0){
|
|
|
- checkItems.forEach(v -> {
|
|
|
- PointCheckItemDo pointCheckItemDo = new PointCheckItemDo();
|
|
|
- pointCheckItemDo.setId(SecurityUtil.getUUID());
|
|
|
- pointCheckItemDo.setPointcheckid(pointCheckDo.getId());
|
|
|
- pointCheckItemDo.setTenantid(checkTemplate.getTenantid());
|
|
|
- // 检查内容模板
|
|
|
- CheckItemContentDo checkItemContent = checkItemContentService.getById(v.getCheckitemcontentid());
|
|
|
- pointCheckItemDo.setCheckitemcontentid(v.getCheckitemcontentid());
|
|
|
- if(checkItemContent != null){
|
|
|
- pointCheckItemDo.setCheckitemcontentman(checkItemContent.getManagement());
|
|
|
- }
|
|
|
- pointCheckItemDo.setCheckposition(v.getCheckposition());
|
|
|
- pointCheckItemDo.setCheckcontent(v.getCheckcontent());
|
|
|
- pointCheckItemDo.setChecktype(v.getChecktype());
|
|
|
- pointCheckItemDo.setCheckstandard(v.getCheckstandard());
|
|
|
- pointCheckItemDo.setFrequencyids(v.getFrequencyids());
|
|
|
- pointCheckItemDo.setFrequency(v.getFrequency());
|
|
|
- pointCheckItemDo.setShift(v.getShift());
|
|
|
- pointCheckItemDo.setShiftcount(v.getShiftcount());
|
|
|
- // 排序字段
|
|
|
- pointCheckItemDo.setItemsort(v.getItemsort());
|
|
|
- pointCheckItemDo.setSource("1");
|
|
|
- pointCheckItems.add(pointCheckItemDo);
|
|
|
- });
|
|
|
- }
|
|
|
- pointChecks.add(pointCheckDo);
|
|
|
+ //点检明细生成
|
|
|
+ if(checkItems != null && checkItems.size()>0){
|
|
|
+ checkItems.forEach(v -> {
|
|
|
+ PointCheckItemDo pointCheckItemDo = new PointCheckItemDo();
|
|
|
+ pointCheckItemDo.setId(SecurityUtil.getUUID());
|
|
|
+ pointCheckItemDo.setPointcheckid(pointCheckDo.getId());
|
|
|
+ pointCheckItemDo.setTenantid(checkTemplate.getTenantid());
|
|
|
+ // 检查内容模板
|
|
|
+ CheckItemContentDo checkItemContent = checkItemContentService.getById(v.getCheckitemcontentid());
|
|
|
+ pointCheckItemDo.setCheckitemcontentid(v.getCheckitemcontentid());
|
|
|
+ if(checkItemContent != null){
|
|
|
+ pointCheckItemDo.setCheckitemcontentman(checkItemContent.getManagement());
|
|
|
+ }
|
|
|
+ pointCheckItemDo.setCheckposition(v.getCheckposition());
|
|
|
+ pointCheckItemDo.setCheckcontent(v.getCheckcontent());
|
|
|
+ pointCheckItemDo.setChecktype(v.getChecktype());
|
|
|
+ pointCheckItemDo.setCheckstandard(v.getCheckstandard());
|
|
|
+ pointCheckItemDo.setFrequencyids(v.getFrequencyids());
|
|
|
+ pointCheckItemDo.setFrequency(v.getFrequency());
|
|
|
+ pointCheckItemDo.setShift(v.getShift());
|
|
|
+ pointCheckItemDo.setShiftcount(v.getShiftcount());
|
|
|
+ // 排序字段
|
|
|
+ pointCheckItemDo.setItemsort(v.getItemsort());
|
|
|
+ pointCheckItemDo.setSource("1");
|
|
|
+ pointCheckItems.add(pointCheckItemDo);
|
|
|
+ });
|
|
|
}
|
|
|
- }else{
|
|
|
- logger.error("点检定时任务生成时,检查模板(ID:"+checkTemplate.getId()+")没有设备");
|
|
|
+ pointChecks.add(pointCheckDo);
|
|
|
}
|
|
|
+ }else{
|
|
|
+ logger.error("点检定时任务生成时,检查模板(ID:"+checkTemplate.getId()+")没有设备");
|
|
|
}
|
|
|
- // 批量保存点检任务
|
|
|
- pointCheckService.saveBatch(pointChecks);
|
|
|
- pointCheckItemService.saveBatch(pointCheckItems);
|
|
|
}
|
|
|
+
|
|
|
+ if(!notifyType.isEmpty()){
|
|
|
+ List<SysDictDo> dictsByType = commonDictService.getDictsByType("template-type");
|
|
|
+ notifyType.forEach((k,v)->{
|
|
|
+ String pointcheckname = k.getPointcheckname();
|
|
|
+ String templatetype = k.getTemplatetype();
|
|
|
+ SysDictDo sysDictDo = dictsByType.stream().filter(info -> info.getValue().equals(templatetype)).findFirst().orElse(null);
|
|
|
+ CXCommonUtils.sendNotify(INSPECTION_TITLE, String.format(INSPECTION_TITLE,pointcheckname,sysDictDo==null?"":sysDictDo.getName()),
|
|
|
+ null,v,k.getId(),INSPECTION,false);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 批量保存点检任务
|
|
|
+ pointCheckService.saveBatch(pointChecks);
|
|
|
+ pointCheckItemService.saveBatch(pointCheckItems);
|
|
|
}
|
|
|
|
|
|
/**
|