|
|
@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.xunmei.common.core.constant.Constants;
|
|
|
+import com.xunmei.common.core.constant.DictConstants;
|
|
|
import com.xunmei.common.core.constant.ErrorMsgConstants;
|
|
|
import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
import com.xunmei.common.core.domain.DateRange;
|
|
|
@@ -28,6 +29,7 @@ import com.xunmei.common.core.utils.DateUtils;
|
|
|
import com.xunmei.common.core.utils.IDHelper;
|
|
|
import com.xunmei.common.core.vo.IdNameVo;
|
|
|
import com.xunmei.common.core.web.domain.AjaxResult;
|
|
|
+import com.xunmei.common.security.utils.DictUtils;
|
|
|
import com.xunmei.common.security.utils.SecurityUtils;
|
|
|
import com.xunmei.core.question.QuestionSrcType;
|
|
|
import com.xunmei.core.question.domain.Question;
|
|
|
@@ -45,8 +47,6 @@ import com.xunmei.core.resumption.vo.appPlan.*;
|
|
|
import com.xunmei.core.resumption.vo.resumptionRecord.AppResumptionDataInfoVo;
|
|
|
import com.xunmei.core.resumption.vo.resumptionRecord.ResumptionRecordItemVo;
|
|
|
import com.xunmei.core.resumption.vo.resumptionRecord.ResumptionRecordVo;
|
|
|
-import com.xunmei.core.safetyCheck.domain.CoreSafecheckPlanToExecOrg;
|
|
|
-import com.xunmei.core.safetyCheck.enums.SafetyPlanCycle;
|
|
|
import com.xunmei.core.thread.ThreadPoolConfig;
|
|
|
import com.xunmei.system.api.RemoteFileService;
|
|
|
import com.xunmei.system.api.RemoteOrgService;
|
|
|
@@ -65,7 +65,6 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.io.File;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -905,24 +904,26 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
|
|
|
/**
|
|
|
* 获取详情
|
|
|
+ *
|
|
|
* @param planId
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public AppPlanDetailVo getDetail(Long planId){
|
|
|
- AppPlanVo vo= findById(planId);
|
|
|
- AppPlanDetailVo detailVo=new AppPlanDetailVo();
|
|
|
- BeanUtils.copyProperties(vo,detailVo);
|
|
|
-
|
|
|
- if(ObjectUtil.isNotEmpty(vo.getOrgList())){
|
|
|
- List<IdNameVo> idNameVos= remoteOrgService.selectOrgByIdList(vo.getOrgList(),SecurityConstants.INNER)
|
|
|
- .stream().map(o->new IdNameVo(o.getId(),o.getName(),null))
|
|
|
+ public AppPlanDetailVo getDetail(Long planId) {
|
|
|
+ AppPlanVo vo = findById(planId);
|
|
|
+ AppPlanDetailVo detailVo = new AppPlanDetailVo();
|
|
|
+ BeanUtils.copyProperties(vo, detailVo);
|
|
|
+
|
|
|
+ if (ObjectUtil.isNotEmpty(vo.getOrgList())) {
|
|
|
+ List<IdNameVo> idNameVos = remoteOrgService.selectOrgByIdList(vo.getOrgList(), SecurityConstants.INNER)
|
|
|
+ .stream().map(o -> new IdNameVo(o.getId(), o.getName(), null))
|
|
|
.collect(Collectors.toList());
|
|
|
detailVo.setOrgs(idNameVos);
|
|
|
}
|
|
|
|
|
|
- return detailVo;
|
|
|
+ return detailVo;
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void deleted(Long id) throws Exception {
|
|
|
@@ -1065,13 +1066,49 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void buildResumptionNotWorkTimePdf(Long orgId, Date date) {
|
|
|
+ SysOrg sysOrg = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectOrgById(orgId, SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
|
|
|
+ String fileName = registerBookPdfService.getPdfFileName(RegisterBookType.ON_DUTY_USER, sysOrg.getName());
|
|
|
+ Map<String, Object> data = this.getFtlResumptionNotWorkTime(orgId, date);
|
|
|
+ data.put("fileName", fileName);
|
|
|
+ data.put("orgName", sysOrg.getShortName());
|
|
|
+ data.put("dateStr", DateUtil.format(new Date(), Constants.DAILY_FORMAT));
|
|
|
+ data.put("remark", "");
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ R<String> r = RemoteCallHandlerExecutor.executeRemoteCall(() -> fileService.generateResumptionPdf(data), ErrorMsgConstants.GENERATE_PDF_ERROR);
|
|
|
+ if (null == r || null == r.getData()) {
|
|
|
+ throw new SystemException(ErrorMsgConstants.GENERATE_PDF_ERROR);
|
|
|
+ }
|
|
|
+ /* Long id = (Long) data.get("id");
|
|
|
+ if (ObjectUtil.isNull(id)) {
|
|
|
+ throw new SystemException(ErrorMsgConstants.GENERATE_PDF_ERROR);
|
|
|
+ }*/
|
|
|
+ String pdfUrl = r.getData();
|
|
|
+ CoreRegisterBookPdf registerBookPdf = new CoreRegisterBookPdf();
|
|
|
+ registerBookPdf.setId(IdWorker.getId());
|
|
|
+ registerBookPdf.setRegisterBookType(RegisterBookType.ON_DUTY_USER.getNum());
|
|
|
+ registerBookPdf.setDate(date);
|
|
|
+ registerBookPdf.setOrgId(orgId);
|
|
|
+ registerBookPdf.setOrgName(sysOrg.getShortName());
|
|
|
+ registerBookPdf.setOrgPath(sysOrg.getPath());
|
|
|
+ registerBookPdf.setFileUrl(pdfUrl);
|
|
|
+ registerBookPdf.setFileName(fileName);
|
|
|
+ if (StringUtils.isEmpty(registerBookPdf.getFileName()) || StringUtils.isEmpty(pdfUrl)) {
|
|
|
+ throw new SystemException(ErrorMsgConstants.GENERATE_PDF_ERROR);
|
|
|
+ }
|
|
|
+ registerBookPdfService.saveOrUpdate(registerBookPdf);
|
|
|
+ }, threadPoolTaskExecutor);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Async
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public AjaxResult buildResumptionPdf(Long orgid) {
|
|
|
- SysOrg sysOrg = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectOrgById(orgid, SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
|
|
|
+ public AjaxResult buildResumptionPdfDaily(Long orgId, Date date) {
|
|
|
+ SysOrg sysOrg = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectOrgById(orgId, SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
|
|
|
String fileName = registerBookPdfService.getPdfFileName(RegisterBookType.SECURITY_PERFORMANCE, sysOrg.getName());
|
|
|
- Map<String, Object> data = this.getFtlResumption(orgid);
|
|
|
+ Map<String, Object> data = this.getFtlResumptionDaily(orgId, date);
|
|
|
data.put("fileName", fileName);
|
|
|
data.put("orgName", sysOrg.getShortName());
|
|
|
data.put("dateStr", DateUtil.format(new Date(), Constants.DAILY_FORMAT));
|
|
|
@@ -1081,30 +1118,24 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
if (null == r || null == r.getData()) {
|
|
|
throw new SystemException(ErrorMsgConstants.GENERATE_PDF_ERROR);
|
|
|
}
|
|
|
- Long id = (Long) data.get("id");
|
|
|
+ /*Long id = (Long) data.get("id");
|
|
|
if (ObjectUtil.isNull(id)) {
|
|
|
throw new SystemException(ErrorMsgConstants.GENERATE_PDF_ERROR);
|
|
|
- }
|
|
|
+ }*/
|
|
|
String pdfUrl = r.getData();
|
|
|
CoreRegisterBookPdf registerBookPdf = new CoreRegisterBookPdf();
|
|
|
- registerBookPdf.setId(id);
|
|
|
+ registerBookPdf.setId(IdWorker.getId());
|
|
|
registerBookPdf.setRegisterBookType(RegisterBookType.SECURITY_PERFORMANCE.getNum());
|
|
|
- registerBookPdf.setDate(new Date());
|
|
|
- registerBookPdf.setOrgId(orgid);
|
|
|
+ registerBookPdf.setDate(date);
|
|
|
+ registerBookPdf.setOrgId(orgId);
|
|
|
registerBookPdf.setOrgName(sysOrg.getShortName());
|
|
|
registerBookPdf.setOrgPath(sysOrg.getPath());
|
|
|
registerBookPdf.setFileUrl(pdfUrl);
|
|
|
- //registerBookPdf.setFileName(StringUtils.substringAfterLast(pdfUrl, "\\"));
|
|
|
registerBookPdf.setFileName(fileName);
|
|
|
- //registerBookPdf.setFileName(StringUtils.substringAfterLast(pdfUrl, File.separator));
|
|
|
if (StringUtils.isEmpty(registerBookPdf.getFileName()) || StringUtils.isEmpty(pdfUrl)) {
|
|
|
throw new SystemException(ErrorMsgConstants.GENERATE_PDF_ERROR);
|
|
|
}
|
|
|
- registerBookPdfService.save(registerBookPdf);
|
|
|
-// LambdaUpdateWrapper<AppPlan> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
-// updateWrapper.eq(AppPlan::getId, id);
|
|
|
-// updateWrapper.set(AppPlan::getPdfUrl, pdfUrl);
|
|
|
-// this.update(updateWrapper);
|
|
|
+ registerBookPdfService.saveOrUpdate(registerBookPdf);
|
|
|
}, threadPoolTaskExecutor);
|
|
|
|
|
|
|
|
|
@@ -1113,21 +1144,110 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
|
|
|
@Async
|
|
|
@Override
|
|
|
- public void buildPdf() {
|
|
|
- Date date = new Date();
|
|
|
+ public void buildPdf(Date date) {
|
|
|
|
|
|
- List<Resumption> resumptions = resumptionMapper.selectList(new LambdaQueryWrapper<Resumption>().eq(Resumption::getYmdDate, DateUtils.toLocalDate(date)).eq(Resumption::getStatus, 3));
|
|
|
+ List<Resumption> resumptions = resumptionMapper.selectList(new LambdaQueryWrapper<Resumption>().like(Resumption::getSubmitTime, DateUtils.toLocalDate(date)).eq(Resumption::getStatus, 3));
|
|
|
List<Long> orgIds = resumptions.stream().map(Resumption::getOrgId).distinct().collect(Collectors.toList());
|
|
|
- orgIds.forEach(this::buildResumptionPdf);
|
|
|
+ for (Long orgId : orgIds) {
|
|
|
+ buildResumptionPdfDaily(orgId, date);
|
|
|
+ buildResumptionNotWorkTimePdf(orgId, date);
|
|
|
+ buildResumptionAllDayPdf(orgId, date);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- private Map<String, Object> getFtlResumption(Long orgId) {
|
|
|
+ //1703700546288825444
|
|
|
+ @Override
|
|
|
+ public void buildResumptionAllDayPdf(Long orgId, Date date) {
|
|
|
+ final List<Map<String, Object>> mapList = this.getFtlResumptionAllDay(orgId, date);
|
|
|
+ for (Map<String, Object> data : mapList) {
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ R<String> r = RemoteCallHandlerExecutor.executeRemoteCall(() -> fileService.generateResumptionPdf(data), ErrorMsgConstants.GENERATE_PDF_ERROR);
|
|
|
+ if (null == r || null == r.getData()) {
|
|
|
+ throw new SystemException(ErrorMsgConstants.GENERATE_PDF_ERROR);
|
|
|
+ }
|
|
|
+ /* Long id = (Long) data.get("id");
|
|
|
+ if (ObjectUtil.isNull(id)) {
|
|
|
+ throw new SystemException(ErrorMsgConstants.GENERATE_PDF_ERROR);
|
|
|
+ }*/
|
|
|
+ SysOrg sysOrg = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectOrgById(orgId, SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
|
|
|
+ String pdfUrl = r.getData();
|
|
|
+ CoreRegisterBookPdf registerBookPdf = new CoreRegisterBookPdf();
|
|
|
+ registerBookPdf.setId(IdWorker.getId());
|
|
|
+ registerBookPdf.setRegisterBookType(RegisterBookType.getEnums((Integer) data.get("planType")).getNum());
|
|
|
+ registerBookPdf.setDate(date);
|
|
|
+ registerBookPdf.setOrgId(orgId);
|
|
|
+ registerBookPdf.setOrgName(sysOrg.getShortName());
|
|
|
+ registerBookPdf.setOrgPath(sysOrg.getPath());
|
|
|
+ registerBookPdf.setFileUrl(pdfUrl);
|
|
|
+ registerBookPdf.setFileName(data.get("fileName").toString());
|
|
|
+ if (StringUtils.isEmpty(registerBookPdf.getFileName()) || StringUtils.isEmpty(pdfUrl)) {
|
|
|
+ throw new SystemException(ErrorMsgConstants.GENERATE_PDF_ERROR);
|
|
|
+ }
|
|
|
+ registerBookPdfService.saveOrUpdate(registerBookPdf);
|
|
|
+ }, threadPoolTaskExecutor);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Map<String, Object>> getFtlResumptionAllDay(Long orgId, Date date) {
|
|
|
+
|
|
|
+ SysOrg sysOrg = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectOrgById(orgId, SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
|
|
|
+
|
|
|
+ //查询执行时刻为全天的的履职数据
|
|
|
+ List<Resumption> allDayDataList = resumptionMapper.selectByYmdDateAndExecList(date, Arrays.asList(1), orgId);
|
|
|
+ //全天的的履职数据需要生成三种登记簿,所以还需要跟根据任务类型来分组 // 4:“110”入侵报警系统测试 5:不间断电源(UPS)维护 6:离行式自助银行巡检
|
|
|
+ final Map<Integer, List<Resumption>> listMap = allDayDataList.stream().filter(res -> Arrays.asList(4, 5, 6).contains(res.getPlanType())).collect(Collectors.groupingBy(Resumption::getPlanType));
|
|
|
+ final ArrayList<Map<String, Object>> maps = new ArrayList<>();
|
|
|
+ for (Integer planType : listMap.keySet()) {
|
|
|
+ String fileName = registerBookPdfService.getPdfFileName(RegisterBookType.getEnums(planType), sysOrg.getName());
|
|
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
+ data.put("planType", planType);
|
|
|
+ List<AppResumptionDataInfoVo> allDayInfo = getItems(allDayDataList);
|
|
|
+ Map<Long, List<AppResumptionDataInfoVo>> afterf = allDayInfo.stream().collect(Collectors.groupingBy(AppResumptionDataInfoVo::getItemId));
|
|
|
+ data.put(DictUtils.getDictLabel(DictConstants.RESUMPTION_PLAN_EXEC, 1), getResult(afterf));
|
|
|
+ // 提交人
|
|
|
+ data.put("submiterNames", allDayDataList.stream().map(Resumption::getSubmitorName).distinct().collect(Collectors.joining(",")));
|
|
|
+ // 获取任务相关问题
|
|
|
+ data.put("questions", getListQuestionPdfVo(allDayDataList.stream().map(Resumption::getId).collect(Collectors.toList())));
|
|
|
+ data.put("fileName", fileName);
|
|
|
+ data.put("orgName", sysOrg.getShortName());
|
|
|
+ data.put("dateStr", DateUtil.format(date, Constants.DAILY_FORMAT));
|
|
|
+ data.put("remark", "");
|
|
|
+ maps.add(data);
|
|
|
+ }
|
|
|
+ return maps;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, Object> getFtlResumptionNotWorkTime(Long orgId, Date date) {
|
|
|
Map<String, Object> data = new HashMap<>();
|
|
|
- //获取前一天
|
|
|
-// Date date = DateUtils.addDays(new Date(), 0);
|
|
|
-// Date date = DateUtil.date().setField(DateField.DAY_OF_MONTH,26);//new Date(123,12,26);
|
|
|
- Date date = new Date();
|
|
|
+ List<Resumption> dataList = resumptionMapper.selectByYmdDateAndExecList(date, Arrays.asList(5), orgId);
|
|
|
+ List<AppResumptionDataInfoVo> notWorkTimeInfo = getItems(dataList);
|
|
|
+ Map<Long, List<AppResumptionDataInfoVo>> afterf = notWorkTimeInfo.stream().collect(Collectors.groupingBy(AppResumptionDataInfoVo::getItemId));
|
|
|
+ data.put(DictUtils.getDictLabel(DictConstants.RESUMPTION_PLAN_EXEC, 5), getResult(afterf));
|
|
|
+ // 提交人
|
|
|
+ data.put("submiterNames", dataList.stream().map(Resumption::getSubmitorName).distinct().collect(Collectors.joining(",")));
|
|
|
+ // 获取任务相关问题
|
|
|
+ data.put("questions", getListQuestionPdfVo(dataList.stream().map(Resumption::getId).collect(Collectors.toList())));
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<QuestionPdfVo> getListQuestionPdfVo(List<Long> taskIds) {
|
|
|
+ List<QuestionPdfVo> questionPdfVos = new ArrayList<>();
|
|
|
+ if (ObjectUtil.isNotEmpty(taskIds)) {
|
|
|
+ List<Question> questions = questionService.selectQuestionByTaskIds(taskIds);
|
|
|
+ questions.forEach(x -> {
|
|
|
+ QuestionPdfVo questionPdfVo = new QuestionPdfVo();
|
|
|
+ BeanUtils.copyProperties(x, questionPdfVo);
|
|
|
+ questionPdfVos.add(questionPdfVo);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return questionPdfVos;
|
|
|
+ }
|
|
|
|
|
|
+ private Map<String, Object> getFtlResumptionDaily(Long orgId, Date date) {
|
|
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
+ //获取前一天
|
|
|
//获取营业前的所有履职信息
|
|
|
List<Resumption> before = resumptionMapper.selectByYmdDateAndExec(date, 2, orgId);
|
|
|
//获取营业期间的所有履职信息
|
|
|
@@ -1142,9 +1262,9 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
Map<Long, List<AppResumptionDataInfoVo>> afterf = aftervos.stream().collect(Collectors.groupingBy(AppResumptionDataInfoVo::getItemId));
|
|
|
|
|
|
data.put("id", CollectionUtil.isNotEmpty(before) ? before.get(0).getId() : (CollectionUtil.isNotEmpty(ing) ? ing.get(0).getId() : (CollectionUtil.isNotEmpty(after) ? after.get(0).getId() : null)));
|
|
|
- data.put("营业前", getResult(bef));
|
|
|
- data.put("营业期间", getResult(ingf));
|
|
|
- data.put("营业终了", getResult(afterf));
|
|
|
+ data.put(DictUtils.getDictLabel(DictConstants.RESUMPTION_PLAN_EXEC, 2), getResult(bef));
|
|
|
+ data.put(DictUtils.getDictLabel(DictConstants.RESUMPTION_PLAN_EXEC, 3), getResult(ingf));
|
|
|
+ data.put(DictUtils.getDictLabel(DictConstants.RESUMPTION_PLAN_EXEC, 4), getResult(afterf));
|
|
|
// 提交人
|
|
|
|
|
|
List<String> submiterNames = before.stream().map(x -> x.getSubmitorName()).collect(Collectors.toList());
|
|
|
@@ -1153,21 +1273,10 @@ public class AppPlanServiceImpl extends ServiceImpl<AppPlanMapper, AppPlan> impl
|
|
|
submiterNames = submiterNames.stream().distinct().collect(Collectors.toList());
|
|
|
data.put("submiterNames", String.join(",", submiterNames));
|
|
|
// 获取任务相关问题
|
|
|
- List<QuestionPdfVo> questionPdfVos = new ArrayList<>();
|
|
|
List<Long> taskIds = before.stream().map(x -> x.getId()).collect(Collectors.toList());
|
|
|
taskIds.addAll(ing.stream().map(x -> x.getId()).collect(Collectors.toList()));
|
|
|
taskIds.addAll(after.stream().map(x -> x.getId()).collect(Collectors.toList()));
|
|
|
- if (ObjectUtil.isNotEmpty(taskIds)) {
|
|
|
- List<Question> questions = questionService.selectQuestionByTaskIds(taskIds);
|
|
|
-
|
|
|
- questions.forEach(x -> {
|
|
|
- QuestionPdfVo questionPdfVo = new QuestionPdfVo();
|
|
|
- BeanUtils.copyProperties(x, questionPdfVo);
|
|
|
- questionPdfVos.add(questionPdfVo);
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- data.put("questions", questionPdfVos);
|
|
|
+ data.put("questions", getListQuestionPdfVo(taskIds));
|
|
|
return data;
|
|
|
}
|
|
|
|