|
@@ -9,7 +9,6 @@ import com.rongwe.scentity.vo.CheckTemplateItemsVo;
|
|
|
import com.rongwe.scentity.vo.CheckTemplateVo;
|
|
|
import com.rongwei.commonservice.serial.service.CommonDictService;
|
|
|
import com.rongwei.rwadmincommon.system.domain.SysDictDo;
|
|
|
-import com.rongwei.rwadmincommon.system.service.impl.WidgetInstServiceImpl;
|
|
|
import com.rongwei.rwadmincommon.system.vo.SysUserVo;
|
|
|
import com.rongwei.rwcommon.base.BaseDo;
|
|
|
import com.rongwei.rwcommon.base.R;
|
|
@@ -25,12 +24,12 @@ import com.rongwei.sfcommon.utils.MlConstants;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
import static com.rongwei.safecommon.utils.JSCommonUtils.parameterCheck;
|
|
|
import static com.rongwei.safecommon.utils.JSCommonUtils.streamCodeGeneration;
|
|
@@ -81,7 +80,7 @@ public class CheckTemplateServiceImpl extends ServiceImpl<CheckTemplateDao, Chec
|
|
|
@Autowired
|
|
|
private ThemeCheckContentService themeCheckContentService;
|
|
|
@Autowired
|
|
|
- private WidgetInstServiceImpl widgetInstService;
|
|
|
+ private AspRiskUnitServiceImpl aspRiskUnitService;
|
|
|
|
|
|
/**
|
|
|
* 通用Map转自定义业务实体类
|
|
@@ -524,7 +523,18 @@ public class CheckTemplateServiceImpl extends ServiceImpl<CheckTemplateDao, Chec
|
|
|
Map<String, List<CheckTemplateItemsDo>> shiftTypeAndTempMap = new HashMap<>();
|
|
|
// 获取工作时间信息
|
|
|
List<AspShiftTimeDo> aspShiftTimeDos = aspShiftTimeDao.selectByMap(SHIFT_TIME_QUERY);
|
|
|
-
|
|
|
+ // 风险单元ID
|
|
|
+ String riskunitid = checkTemplateDo.getRiskunitid();
|
|
|
+ JSCommonUtils.parameterCheck(() -> StringUtils.isBlank(riskunitid), "风险单元为空", "风险单元为空");
|
|
|
+ List<AspRiskUnitDo> aspRiskUnitDos = aspRiskUnitService.getBaseMapper().selectBatchIds(Arrays.asList(riskunitid.split(",")));
|
|
|
+ Map<String, String> checkUserMap = new HashMap<>();
|
|
|
+ if (StringUtils.isNotBlank(checkTemplateDo.getInspectorsid())) {
|
|
|
+ String[] ids = checkTemplateDo.getInspectorsid().split(",");
|
|
|
+ String[] names = checkTemplateDo.getInspectors().split(",");
|
|
|
+ for (int i = 0; i < ids.length; i++) {
|
|
|
+ checkUserMap.put(ids[i], names[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
// 获取模板对应的检查项
|
|
|
List<CheckTemplateItemsDo> templateItemsDos = checkTemplateItemsService.list(new LambdaQueryWrapper<CheckTemplateItemsDo>()
|
|
|
.in(CheckTemplateItemsDo::getChecktemplateid, checkTemplateDo.getId())
|
|
@@ -590,67 +600,65 @@ public class CheckTemplateServiceImpl extends ServiceImpl<CheckTemplateDao, Chec
|
|
|
|
|
|
// 模板对应的检查项
|
|
|
List<CheckTemplateItemsDo> items;
|
|
|
-
|
|
|
- for (Map.Entry<String, List<CheckTemplateItemsDo>> entry : shiftTypeAndTempMap.entrySet()) {
|
|
|
- String k = entry.getKey();
|
|
|
- AspShiftTimeDo aspShiftTimeDo = aspShiftTimeDos.stream().filter(info -> k.equals(info.getShift())).findFirst().orElse(null);
|
|
|
-
|
|
|
- //当前班次最大的任务数量
|
|
|
-// int maxFrequency = entry.getValue().stream().mapToInt(CheckTemplateItemsDo::getShiftcount).max().orElse(1);
|
|
|
- int maxFrequency = entry.getValue().stream()
|
|
|
- .mapToInt(item -> Optional.ofNullable(item.getShiftcount()).orElse(1))
|
|
|
- .max()
|
|
|
- .orElse(1);
|
|
|
- for (int i = 1; i <= maxFrequency; i++) {
|
|
|
- checkItemDo = new ThemeCheckItemDo();
|
|
|
- checkItemDo.setId(SecurityUtil.getUUID());
|
|
|
- JSCommonUtils.setBaseDetail(checkItemDo, currentUser);
|
|
|
- checkItemDo.setThemechecknum(JSCommonUtils.streamCodeGeneration("asp_theme_check_item_number",
|
|
|
- "SC@{date:yyyyMM}@{serialNumber:#000000}", "date:yyyyMM", ""));
|
|
|
- checkItemDo.setThemecheckid(checkTemplateDo.getId());
|
|
|
- checkItemDo.setThemecheckname(checkTemplateDo.getTemplatename());
|
|
|
- if (aspShiftTimeDo != null) {
|
|
|
- checkItemDo.setPlanstarttime(basedOnShiftGenerateTime(aspShiftTimeDo, AspShiftTimeDo::getStarttime));
|
|
|
- checkItemDo.setPlanendtime(basedOnShiftGenerateTime(aspShiftTimeDo, AspShiftTimeDo::getEndtime));
|
|
|
- } else {
|
|
|
- checkItemDo.setPlanstarttime(startTime);
|
|
|
- checkItemDo.setPlanendtime(endTime);
|
|
|
- }
|
|
|
- checkItemDo.setChecktype(checkTemplateDo.getTemplatetype());
|
|
|
- checkItemDo.setTenantid(checkTemplateDo.getTenantid());
|
|
|
- // TODO:XH add 2024/8/16 暂不止如何处理
|
|
|
-// checkItemDo.setChecker();
|
|
|
-// checkItemDo.setCheckerid();
|
|
|
- // TODO:XH add 2024/8/16 检查区域暂不处理
|
|
|
-// checkItemDo.setThemecheckworkspartid();a
|
|
|
-// checkItemDo.setCheckworkspart();
|
|
|
- checkItemDo.setCheckresult("20");
|
|
|
- checkItemDo.setCheckstatus(THEME_CHECK_STATUS_WAIT);
|
|
|
- themeCheckItemSaveDos.add(checkItemDo);
|
|
|
- int finalI = i;
|
|
|
-// items = entry.getValue().stream().filter(info -> info.getShiftcount() >= finalI).collect(Collectors.toList());
|
|
|
- items = entry.getValue().stream()
|
|
|
- .map(info -> {
|
|
|
- Integer shiftcount = Optional.ofNullable(info.getShiftcount()).orElse(1);
|
|
|
- info.setShiftcount(shiftcount);
|
|
|
- return info;
|
|
|
- })
|
|
|
- .filter(info -> info.getShiftcount() >= finalI)
|
|
|
- .collect(Collectors.toList());
|
|
|
- for (int j = 0; j < items.size(); j++) {
|
|
|
- themeCheckContentDo = new ThemeCheckContentDo();
|
|
|
- themeCheckContentDo.setItemsort(j + 1);
|
|
|
- themeCheckContentDo.setTenantid(checkTemplateDo.getTenantid());
|
|
|
- themeCheckContentDo.setId(SecurityUtil.getUUID());
|
|
|
- themeCheckContentDo.setThemecheckitemid(checkItemDo.getId());
|
|
|
- JSCommonUtils.setBaseDetail(themeCheckContentDo, currentUser);
|
|
|
- themeCheckContentDo.setCheckposition(items.get(j).getCheckposition());
|
|
|
- themeCheckContentDo.setCheckmethod(items.get(j).getChecktype());
|
|
|
- themeCheckContentDo.setCheckcontent(items.get(j).getCheckcontent());
|
|
|
- themeCheckContentDo.setManagement(items.get(j).getManagement());
|
|
|
- themeCheckContentDos.add(themeCheckContentDo);
|
|
|
+ for (AspRiskUnitDo aspRiskUnitDo : aspRiskUnitDos) {
|
|
|
+ checkUserMap.put(aspRiskUnitDo.getDutyofficerid(), aspRiskUnitDo.getDutyofficername());
|
|
|
+ for (Map.Entry<String, String> nameAndId : checkUserMap.entrySet()) {
|
|
|
+ for (Map.Entry<String, List<CheckTemplateItemsDo>> entry : shiftTypeAndTempMap.entrySet()) {
|
|
|
+ String k = entry.getKey();
|
|
|
+ AspShiftTimeDo aspShiftTimeDo = aspShiftTimeDos.stream().filter(info -> k.equals(info.getShift())).findFirst().orElse(null);
|
|
|
+ int maxFrequency = entry.getValue().stream()
|
|
|
+ .mapToInt(item -> Optional.ofNullable(item.getShiftcount()).orElse(1))
|
|
|
+ .max()
|
|
|
+ .orElse(1);
|
|
|
+ for (int i = 1; i <= maxFrequency; i++) {
|
|
|
+ checkItemDo = new ThemeCheckItemDo();
|
|
|
+ checkItemDo.setId(SecurityUtil.getUUID());
|
|
|
+ JSCommonUtils.setBaseDetail(checkItemDo, currentUser);
|
|
|
+ checkItemDo.setThemechecknum(JSCommonUtils.streamCodeGeneration("asp_theme_check_item_number",
|
|
|
+ "SC@{date:yyyyMM}@{serialNumber:#000000}", "date:yyyyMM", ""));
|
|
|
+ checkItemDo.setThemecheckid(checkTemplateDo.getId());
|
|
|
+ checkItemDo.setThemecheckname(checkTemplateDo.getTemplatename());
|
|
|
+ if (aspShiftTimeDo != null) {
|
|
|
+ checkItemDo.setPlanstarttime(basedOnShiftGenerateTime(aspShiftTimeDo, AspShiftTimeDo::getStarttime));
|
|
|
+ checkItemDo.setPlanendtime(basedOnShiftGenerateTime(aspShiftTimeDo, AspShiftTimeDo::getEndtime));
|
|
|
+ } else {
|
|
|
+ checkItemDo.setPlanstarttime(startTime);
|
|
|
+ checkItemDo.setPlanendtime(endTime);
|
|
|
+ }
|
|
|
+ checkItemDo.setChecktype(checkTemplateDo.getTemplatetype());
|
|
|
+ checkItemDo.setTenantid(checkTemplateDo.getTenantid());
|
|
|
+ checkItemDo.setChecker(nameAndId.getValue());
|
|
|
+ checkItemDo.setCheckerid(nameAndId.getKey());
|
|
|
+ checkItemDo.setThemecheckworkspartid(aspRiskUnitDo.getResponsibledept());
|
|
|
+ checkItemDo.setCheckworkspart(aspRiskUnitDo.getResponsibledeptid());
|
|
|
+ checkItemDo.setCheckresult("20");
|
|
|
+ checkItemDo.setCheckstatus(THEME_CHECK_STATUS_WAIT);
|
|
|
+ themeCheckItemSaveDos.add(checkItemDo);
|
|
|
+ int finalI = i;
|
|
|
+ items = entry.getValue().stream()
|
|
|
+ .peek(info -> {
|
|
|
+ Integer shiftcount = Optional.ofNullable(info.getShiftcount()).orElse(1);
|
|
|
+ info.setShiftcount(shiftcount);
|
|
|
+ })
|
|
|
+ .filter(info -> info.getShiftcount() >= finalI)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ for (int j = 0; j < items.size(); j++) {
|
|
|
+ themeCheckContentDo = new ThemeCheckContentDo();
|
|
|
+ themeCheckContentDo.setItemsort(j + 1);
|
|
|
+ themeCheckContentDo.setTenantid(checkTemplateDo.getTenantid());
|
|
|
+ themeCheckContentDo.setId(SecurityUtil.getUUID());
|
|
|
+ themeCheckContentDo.setThemecheckitemid(checkItemDo.getId());
|
|
|
+ JSCommonUtils.setBaseDetail(themeCheckContentDo, currentUser);
|
|
|
+ themeCheckContentDo.setCheckposition(items.get(j).getCheckposition());
|
|
|
+ themeCheckContentDo.setCheckmethod(items.get(j).getChecktype());
|
|
|
+ themeCheckContentDo.setCheckcontent(items.get(j).getCheckcontent());
|
|
|
+ themeCheckContentDo.setManagement(items.get(j).getManagement());
|
|
|
+ themeCheckContentDos.add(themeCheckContentDo);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ checkUserMap.remove(aspRiskUnitDo.getDutyofficerid());
|
|
|
}
|
|
|
// 数据存表
|
|
|
JSCommonUtils.batchChunk(themeCheckItemSaveDos, themeCheckItemService::saveBatch, 20);
|
|
@@ -673,6 +681,4 @@ public class CheckTemplateServiceImpl extends ServiceImpl<CheckTemplateDao, Chec
|
|
|
calendar.set(Calendar.SECOND, Integer.parseInt(timeStr.split(":")[2]));
|
|
|
return calendar.getTime();
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|