|
|
@@ -0,0 +1,336 @@
|
|
|
+package com.xunmei.core.resumption.gx.service;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.xunmei.common.core.utils.DateHelper;
|
|
|
+import com.xunmei.common.security.utils.SecurityUtils;
|
|
|
+import com.xunmei.core.resumption.domain.*;
|
|
|
+import com.xunmei.core.resumption.gx.vo.*;
|
|
|
+import com.xunmei.core.resumption.mapper.*;
|
|
|
+import com.xunmei.core.resumption.vo.ResumptionTaskNewDto;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+@Service("gxResumptionService")
|
|
|
+public class ResumptionServiceImpl implements ResumptionService{
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ResumptionMapper resumptionMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AppPlanMapper appPlanMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AppResumptionDataRemarkimgMapper appResumptionDataRemarkimgMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AppResumptionDataMapper appResumptionDataMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AppResumptionDataNfcMapper appResumptionDataNfcMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, List<ResumptionTaskListVo>> getTaskList(ResumptionTaskNewDto dto) {
|
|
|
+
|
|
|
+ Date dateTime = dto.getDateTime();
|
|
|
+ if(dateTime == null){
|
|
|
+ dateTime = new Date();
|
|
|
+ dto.setDateTime(dateTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ *根据机构id,角色权限,日期,获取对应的履职任务数据
|
|
|
+ */
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResumptionTaskDetailVo getTask(ResumptionTaskDetailVo taskDetailVo) throws Exception {
|
|
|
+ /**
|
|
|
+ * 逻辑梳理如下:
|
|
|
+ * 1、根据任务获取plan_id
|
|
|
+ * 2、根据任务的状态,进行不同的操作。根据数据分为:保存过数据任务,未保存过数据的任务
|
|
|
+ * 保存过数据的任务:进行中、已完成
|
|
|
+ * 未保存过数据的任务: 待履职,已逾期,未完成
|
|
|
+ * 3、未保存过任务的数据处理逻辑如下:
|
|
|
+ * 1)根据计划id组装任务的数据,并根据履职区域进行分组:
|
|
|
+ * 2)根据履职区域获取相应的NFC扫描点
|
|
|
+ * 3)组装数据
|
|
|
+ * 4、保存过任务的数据处理逻辑如下:
|
|
|
+ * 1)根据任务数据获取,要点数据,要点对应的备注,图片,nfc数据
|
|
|
+ * 2)获取计划对应的数据,组装数据
|
|
|
+ */
|
|
|
+ DateHelper dateTime = new DateHelper(taskDetailVo.getTaskDate());
|
|
|
+ int year =dateTime.getYear();
|
|
|
+ int quarter =dateTime.getQuarter() ;
|
|
|
+ //履职状态:1 待履职,2 进行中,3 已完成,4 已过期
|
|
|
+ Resumption resumption = resumptionMapper.findOneByTaskIdAndDate(taskDetailVo.getTaskId(), year,quarter);
|
|
|
+ Integer status = resumption.getStatus();
|
|
|
+ List<ResumptionPlanVo> resumptionPlanVos = new ArrayList<>();
|
|
|
+ boolean isExist = false;
|
|
|
+ if(status == 1 || status == 4){
|
|
|
+ //履职中待履职 和已过期的数据是没有保存过数据的只能根据计划获取
|
|
|
+ Long planId = resumption.getPlanId();
|
|
|
+ resumptionPlanVos = appPlanMapper.selectResumptionPlan(planId);
|
|
|
+ isExist = false;
|
|
|
+
|
|
|
+ }else{
|
|
|
+ resumptionPlanVos = resumptionMapper.selectResumptionPlan(taskDetailVo.getTaskId());
|
|
|
+ isExist = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按区域组合的数据
|
|
|
+ */
|
|
|
+ ResumptionTaskDetailVo detailVo = assemblyData(resumptionPlanVos, isExist, resumption);
|
|
|
+
|
|
|
+ return detailVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public void saveTask(ResumptionTaskDetailVo taskDetailVo) throws Exception {
|
|
|
+ /**
|
|
|
+ * subtype =1 表示保存数据
|
|
|
+ * subtype = 2 表示提交数据
|
|
|
+ */
|
|
|
+ Long taskId = taskDetailVo.getTaskId();
|
|
|
+ DateHelper dateTime = new DateHelper(taskDetailVo.getTaskDate());
|
|
|
+ int year =dateTime.getYear();
|
|
|
+ int quarter =dateTime.getQuarter() ;
|
|
|
+ //获取履职任务
|
|
|
+ Resumption sysResumption = resumptionMapper.findOneByTaskIdAndDate(taskId,year,quarter);
|
|
|
+ sysResumption.setUpdateBy(SecurityUtils.getUsername());
|
|
|
+ sysResumption.setUpdateTime(new Date());
|
|
|
+ sysResumption.setSubmitTime(new Date());
|
|
|
+ sysResumption.setStatus(2);
|
|
|
+
|
|
|
+ if(taskDetailVo.getSubType() == 2){
|
|
|
+ if (sysResumption.getStatus() == 3) {
|
|
|
+ throw new RuntimeException("该任务已过期不能完成提交");
|
|
|
+ }
|
|
|
+ sysResumption.setStatus(3);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ resumptionMapper.updateById(sysResumption);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //删除之前的数据
|
|
|
+ appResumptionDataMapper.deleteByResumptionId(taskId);
|
|
|
+ appResumptionDataNfcMapper.deleteByResumptionId(taskId);
|
|
|
+ appResumptionDataRemarkimgMapper.deleteByResumptionId(taskId);
|
|
|
+
|
|
|
+ //保存新的数据
|
|
|
+ AppResumptionData data = null;
|
|
|
+ List<ResumptionItemVo> checks = taskDetailVo.getChecks();
|
|
|
+ for (ResumptionItemVo check : checks) {
|
|
|
+ List<ResumptionPointVo> points = check.getPoints();
|
|
|
+ for (ResumptionPointVo point : points) {
|
|
|
+ data = new AppResumptionData();
|
|
|
+ data.setDataStatus(point.getDataStatus());
|
|
|
+ data.setResumptionId(taskId);
|
|
|
+ data.setAreaId(check.getAreaId());
|
|
|
+ data.setItemId(point.getPointId());
|
|
|
+ data.setRectificationDeadline(point.getRectificationDeadline());
|
|
|
+ data.setResRemark(point.getResRemark());
|
|
|
+ data.setResValue(point.getResValue());
|
|
|
+ data.setSubmitTime(new Date());
|
|
|
+ data.setResTime(new Date());
|
|
|
+ data.setPlanId(sysResumption.getPlanId());
|
|
|
+ data.setSubmitBy(SecurityUtils.getLoginUser().getUserid());
|
|
|
+ data.setSubmitName(SecurityUtils.getUsername());
|
|
|
+ if(taskDetailVo.getSubType() == 2){
|
|
|
+ if(point.getDataStatus() == 1){
|
|
|
+ data.setDataStatus(2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ appResumptionDataMapper.insert(data);
|
|
|
+
|
|
|
+ List<AppResumptionDataRemarkimg> imgs = point.getImgs();
|
|
|
+ for (AppResumptionDataRemarkimg img : imgs) {
|
|
|
+ img.setResumptionDataId(data.getId());
|
|
|
+ img.setResumptionId(taskId);
|
|
|
+ appResumptionDataRemarkimgMapper.insert(img);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<ResumptionNFCVo> nfcs = taskDetailVo.getNfcs();
|
|
|
+ AppResumptionDataNfc dataNfc = null;
|
|
|
+ for (ResumptionNFCVo nfc : nfcs) {
|
|
|
+ if(nfc.getStatus() == 0){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ dataNfc = new AppResumptionDataNfc();
|
|
|
+ dataNfc.setResumptionId(taskId);
|
|
|
+ dataNfc.setNfcId(nfc.getNfcId());
|
|
|
+ dataNfc.setPointId(nfc.getAreaId());
|
|
|
+ dataNfc.setSubmitTime(new Date());
|
|
|
+ dataNfc.setImg(nfc.getImg());
|
|
|
+ dataNfc.setScanMethod(nfc.getScanMethod());
|
|
|
+ dataNfc.setStatus(nfc.getStatus());
|
|
|
+ appResumptionDataNfcMapper.insert(dataNfc);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 组装到前端的数据
|
|
|
+ * @param resumptionPlanVos
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private ResumptionTaskDetailVo assemblyData(List<ResumptionPlanVo> resumptionPlanVos, boolean isExist, Resumption resumption){
|
|
|
+
|
|
|
+ ResumptionTaskDetailVo taskVo = new ResumptionTaskDetailVo();
|
|
|
+ taskVo.setTaskId(resumption.getId());
|
|
|
+ taskVo.setTaskName(resumption.getName());
|
|
|
+ taskVo.setStatus(resumption.getStatus());
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 组装数据:
|
|
|
+ * 1.对数据按区域分组。
|
|
|
+ * 2.根据检查内容获取检查图片
|
|
|
+ * 3.构建返回到前端的数据
|
|
|
+ */
|
|
|
+ Map<Long,List<AppResumptionDataRemarkimg>> imgMap = new HashMap<>();
|
|
|
+ if(isExist){
|
|
|
+ //数据存在,需要获取任务的所有图片信息
|
|
|
+ QueryWrapper<AppResumptionDataRemarkimg> qw = new QueryWrapper<>();
|
|
|
+ qw.lambda().eq(AppResumptionDataRemarkimg::getResumptionId, resumption.getId());
|
|
|
+ List<AppResumptionDataRemarkimg> imgs = appResumptionDataRemarkimgMapper.selectList(qw);
|
|
|
+ for (AppResumptionDataRemarkimg img : imgs) {
|
|
|
+ Long resumptionDataId = img.getResumptionDataId();
|
|
|
+ List<AppResumptionDataRemarkimg> paths = imgMap.get(resumptionDataId);
|
|
|
+ if(paths == null){
|
|
|
+ paths = new ArrayList<>();
|
|
|
+ }
|
|
|
+ paths.add(img);
|
|
|
+ imgMap.put(resumptionDataId, paths);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Integer yesPointNum = 0;
|
|
|
+ Integer noPointNum = 0;
|
|
|
+ Map<Long,ResumptionItemVo> itemMap = new HashMap<>();
|
|
|
+ Map<Long,Map<String,Integer>> itComMap = new HashMap<>();
|
|
|
+ for (ResumptionPlanVo vo : resumptionPlanVos) {
|
|
|
+ if(vo.getDataStatus() == 1){
|
|
|
+ noPointNum++;
|
|
|
+ }else{
|
|
|
+ yesPointNum++;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isExist){
|
|
|
+ //如果存在数据则设置图片啊
|
|
|
+ List<AppResumptionDataRemarkimg> imgs = imgMap.get(vo.getDataId());
|
|
|
+ if(imgs != null && imgs.size() > 0){
|
|
|
+ vo.getImgs().addAll(imgs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ResumptionItemVo resumptionItemVo = itemMap.get(vo.getItemId());
|
|
|
+ if(resumptionItemVo == null){
|
|
|
+ resumptionItemVo = new ResumptionItemVo();
|
|
|
+ }
|
|
|
+ resumptionItemVo.setItemName(vo.getItemName());
|
|
|
+ resumptionItemVo.setItemId(vo.getItemId());
|
|
|
+ resumptionItemVo.setAreaId(vo.getAreaId());
|
|
|
+ resumptionItemVo.setAreaName(vo.getAreaName());
|
|
|
+
|
|
|
+ ResumptionPointVo pointVo = new ResumptionPointVo();
|
|
|
+ pointVo.setPointName(vo.getPointName());
|
|
|
+ pointVo.setImgs(vo.getImgs());
|
|
|
+ pointVo.setPointId(vo.getPointId());
|
|
|
+ pointVo.setResRemark(vo.getResRemark());
|
|
|
+ if(vo.getResValue() == null){
|
|
|
+ pointVo.setResValue(0);
|
|
|
+ }else{
|
|
|
+ pointVo.setResValue(vo.getResValue());
|
|
|
+ }
|
|
|
+ pointVo.setRectificationDeadline(vo.getRectificationDeadline());
|
|
|
+ pointVo.setDataStatus(vo.getDataStatus());
|
|
|
+ resumptionItemVo.getPoints().add(pointVo);
|
|
|
+ Map<String, Integer> itCom = itComMap.get(vo.getAreaId());
|
|
|
+ if(itCom == null){
|
|
|
+ itCom = new HashMap<>();
|
|
|
+ itCom.put("total", 1);
|
|
|
+ if(pointVo.getDataStatus() == 1){
|
|
|
+ itCom.put("yes",0);
|
|
|
+ }else{
|
|
|
+ itCom.put("yes",1);
|
|
|
+ }
|
|
|
+ itComMap.put(vo.getAreaId(),itCom);
|
|
|
+ }else{
|
|
|
+ itCom.put("total",itCom.get("total") + 1);
|
|
|
+ if(pointVo.getDataStatus() == 2){
|
|
|
+ itCom.put("yes",itCom.get("yes") + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ itemMap.put(vo.getItemId(),resumptionItemVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<Long, AreaResumptionVo> map = new HashMap<>();
|
|
|
+ List<ResumptionItemVo> items = new ArrayList<>();
|
|
|
+ for (Map.Entry<Long, ResumptionItemVo> entry: itemMap.entrySet()) {
|
|
|
+ ResumptionItemVo itemVo = entry.getValue();
|
|
|
+ AreaResumptionVo areaData = map.get(itemVo.getAreaId());
|
|
|
+ if(areaData == null){
|
|
|
+ areaData = new AreaResumptionVo();
|
|
|
+ areaData.setAreaId(itemVo.getAreaId());
|
|
|
+ areaData.setAreaName(itemVo.getAreaName());
|
|
|
+ map.put(itemVo.getAreaId(),areaData);
|
|
|
+ }
|
|
|
+ items.add(itemVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer yesNFC = 0;
|
|
|
+ Integer noNFC = 0;
|
|
|
+
|
|
|
+
|
|
|
+ List<ResumptionNFCVo> nfcs = new ArrayList<>();
|
|
|
+ List<AreaResumptionVo> areas = new ArrayList<>();
|
|
|
+ for (Map.Entry<Long, AreaResumptionVo> entry: map.entrySet()) {
|
|
|
+ AreaResumptionVo vo = entry.getValue();
|
|
|
+ Long areaId = entry.getKey();
|
|
|
+ //获取每个区域下的nfc
|
|
|
+ List<ResumptionNFCVo> resumptionNFCVos = resumptionMapper.selectResumptionNFC(resumption.getId(), areaId, resumption.getOrgId());
|
|
|
+ for (ResumptionNFCVo resumptionNFCVo : resumptionNFCVos) {
|
|
|
+ Integer status = resumptionNFCVo.getStatus();
|
|
|
+ if(status == 0){
|
|
|
+ noNFC++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ yesNFC++;
|
|
|
+ }
|
|
|
+ nfcs.addAll(resumptionNFCVos);
|
|
|
+ Map<String, Integer> com = itComMap.get(areaId);
|
|
|
+ Integer total = com.get("total");
|
|
|
+ Integer yes = com.get("yes");
|
|
|
+ if(total.equals(yes)){
|
|
|
+ //总数等于处理数
|
|
|
+ vo.setAreaStatus("1");
|
|
|
+ }else if(yes > 0){
|
|
|
+ vo.setAreaStatus("2");
|
|
|
+ }else if(yes == 0){
|
|
|
+ vo.setAreaStatus("0");
|
|
|
+ }
|
|
|
+ areas.add(vo);
|
|
|
+ }
|
|
|
+
|
|
|
+ taskVo.setNoNFCNums(noNFC);
|
|
|
+ taskVo.setYesNFCNums(yesNFC);
|
|
|
+ taskVo.setNoPointNums(noPointNum);
|
|
|
+ taskVo.setYesPointNums(yesPointNum);
|
|
|
+ taskVo.setAreas(areas);
|
|
|
+ taskVo.setChecks(items);
|
|
|
+ taskVo.setNfcs(nfcs);
|
|
|
+ return taskVo;
|
|
|
+ }
|
|
|
+}
|