|  |  |  | 
|---|
|  |  |  | import com.doumee.core.utils.qiyeweixin.model.request.QywxTextCardMsgRequest; | 
|---|
|  |  |  | import com.doumee.dao.business.*; | 
|---|
|  |  |  | import com.doumee.dao.business.model.*; | 
|---|
|  |  |  | import com.doumee.dao.business.vo.WorkorderIndexNumVO; | 
|---|
|  |  |  | import com.doumee.dao.web.dto.*; | 
|---|
|  |  |  | import com.doumee.dao.web.vo.WorkOrderDataVO; | 
|---|
|  |  |  | import com.doumee.service.business.WorkorderService; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.doumee.service.common.EmailService; | 
|---|
|  |  |  | import com.github.yulichang.wrapper.MPJLambdaWrapper; | 
|---|
|  |  |  | import com.sun.corba.se.spi.orbutil.threadpool.Work; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.apache.catalina.Manager; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.data.redis.core.RedisTemplate; | 
|---|
|  |  |  | 
|---|
|  |  |  | * @since 2025/04/02 17:49 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Service | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | public class WorkorderServiceImpl implements WorkorderService { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SystemDictDataBiz systemDictDataBiz; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private EmailService emailService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MemberMapper memberMapper; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) | 
|---|
|  |  |  | public Integer create(Workorder workorder) { | 
|---|
|  |  |  | this.isValidBaseParam(workorder); | 
|---|
|  |  |  | workorder.setCreateDate(new Date()); | 
|---|
|  |  |  | workorder.setEditDate(new Date()); | 
|---|
|  |  |  | workorder.setMemberId(workorder.getMemberId()); | 
|---|
|  |  |  | workorder.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | workorder.setCode(this.getNextCode(workorder.getType())); | 
|---|
|  |  |  | workorder.setEmailStatus(Constants.ZERO); | 
|---|
|  |  |  | workorder.setCreateDate(new Date()); | 
|---|
|  |  |  | //处理人员类信息 | 
|---|
|  |  |  | this.dealNoticeData(workorder); | 
|---|
|  |  |  | //处理SHE事件状态 | 
|---|
|  |  |  | 
|---|
|  |  |  | * @param csInfo 抄送信息 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public void sendQwMsg(Workorder workorder,String qwIds,Member member,String categoryName,Integer contentType,String csInfo){ | 
|---|
|  |  |  | if(Constants.equalsInteger(workorder.getType(),Constants.TWO)){ | 
|---|
|  |  |  | workorder = workorderMapper.selectById(workorder.getDcaRecordId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(StringUtils.isEmpty(qwIds)){ | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | QywxSendMsgRequest qywxSendMsgRequest = new QywxSendMsgRequest(); | 
|---|
|  |  |  | qywxSendMsgRequest.setMsgtype("text"); | 
|---|
|  |  |  | qywxSendMsgRequest.setMsgtype("textcard"); | 
|---|
|  |  |  | qywxSendMsgRequest.setTouser(qwIds.replace(",","|")); | 
|---|
|  |  |  | qywxSendMsgRequest.setAgentid(systemDictDataBiz.queryByCode(Constants.QYWX,Constants.QYWX_AGENTID).getCode()); | 
|---|
|  |  |  | String sendUser = ""; | 
|---|
|  |  |  | 
|---|
|  |  |  | qywxSendMsgRequest.setTextcard(textCard); | 
|---|
|  |  |  | QywxUtil.sendMsg(systemDictDataBiz.queryByCode(Constants.QYWX,Constants.QYWX_TOKEN).getCode(), | 
|---|
|  |  |  | qywxSendMsgRequest); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //https://open.weixin.qq.com/connect/oauth2/authorize?appid=${corpId}&redirect_uri=https://dmtest.ahapp.net/lianhelihua_web/&response_type=code&scope=snsapi_base&state={status}#wechat_redirect | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static  final String jumpUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={corpId}&redirect_uri={ourUrl}"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | public QywxTextCardMsgRequest dealMessageContent(Workorder workorder,String userName ,String categoryName,Integer contentType,String csInfo){ | 
|---|
|  |  |  | QywxTextCardMsgRequest textCard = new QywxTextCardMsgRequest(); | 
|---|
|  |  |  | String message = ""; | 
|---|
|  |  |  | String url = jumpUrl.replace("{corpId}",systemDictDataBiz.queryByCode(Constants.QYWX,Constants.QYWX_CORPID).getCode()); | 
|---|
|  |  |  | String jumpOurUrl = systemDictDataBiz.queryByCode(Constants.QYWX,Constants.JUMP_OUT_URL).getCode().replace("{status}", | 
|---|
|  |  |  | workorder.getType()+"_"+workorder.getId()); | 
|---|
|  |  |  | textCard.setUrl(url.replace("{ourUrl}",jumpOurUrl)); | 
|---|
|  |  |  | log.error("企微链接地址"+url); | 
|---|
|  |  |  | if(Constants.equalsInteger(workorder.getType(),Constants.ZERO)){ | 
|---|
|  |  |  | textCard.setTitle("【SHE事件上报】"); | 
|---|
|  |  |  | if(Constants.equalsInteger(workorder.getMemberType(),Constants.ZERO)){ | 
|---|
|  |  |  | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | message = Constants.equalsInteger(workorder.getMemberType(),Constants.ONE)?"同事":"供应商"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | message = message + "-" + workorder.getMemberNames() + " " + DateUtil.formatDate(new Date(),"yyyy-MM-dd HH:mm") + workorder.getLocationName() + categoryName; | 
|---|
|  |  |  | textCard.setDescription(" <div class=\"normal\">"+message+"</div>"); | 
|---|
|  |  |  | message = message + "-" + workorder.getMemberNames() + " " + DateUtil.formatDate(new Date(),"yyyy-MM-dd HH:mm") + "/" +workorder.getLocationName() + "/" + categoryName; | 
|---|
|  |  |  | textCard.setDescription("<div class=\"normal\">"+message+"</div>"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | textCard.setTitle(Constants.equalsInteger(workorder.getType(),Constants.ONE)?"【DCA上报】":"跌绊滑风险上报"); | 
|---|
|  |  |  | textCard.setTitle(Constants.equalsInteger(workorder.getType(),Constants.ONE)?"【DCA上报】":"【跌绊滑风险上报】"); | 
|---|
|  |  |  | if(Constants.equalsInteger(workorder.getType(),Constants.THREE)){ | 
|---|
|  |  |  | message = message + " <div class=\"normal\">"+ (org.apache.commons.lang3.StringUtils.isNotBlank(userName)?userName:"系统") + (Constants.equalsInteger(contentType,Constants.ZERO)?"任务分配给你":(Constants.equalsInteger(contentType,Constants.ONE)?"对该工单进行了催促,请尽快处理":"任务已处理")) +"</div>"; | 
|---|
|  |  |  | message = message + " <div class=\"normal\">"+  DateUtil.formatDate(new Date(),"yyyy-MM-dd HH:mm") +"/"+ workorder.getLocationName() +"/"+  categoryName+"</div>"; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | message = message + " <div class=\"normal\">"+ (org.apache.commons.lang3.StringUtils.isNotBlank(userName)?userName:"系统") + (Constants.equalsInteger(contentType,Constants.ZERO)?"任务分配给你":(Constants.equalsInteger(contentType,Constants.ONE)?"对该工单进行了催促,请尽快处理":((Constants.equalsInteger(contentType,Constants.TWO)?"抄送给你":"已处理一项")))) +"</div>"; | 
|---|
|  |  |  | message = message + " <div class=\"normal\">观察主题"+  categoryName +"</div>"; | 
|---|
|  |  |  | message = message + " <div class=\"normal\">符合:"+ workorder.getDcaYesNum()  +" 不符合:"+workorder.getDcaNoNum()+"</div>"; | 
|---|
|  |  |  | message = message + "  <div class=\"normal\">"+ (org.apache.commons.lang3.StringUtils.isNotBlank(userName)?userName:"系统") + (Constants.equalsInteger(contentType,Constants.ZERO)?"任务分配给你":(Constants.equalsInteger(contentType,Constants.ONE)?"对该工单进行了催促,请尽快处理":((Constants.equalsInteger(contentType,Constants.TWO)?"抄送给你":"已处理一项")))) +"</div>"; | 
|---|
|  |  |  | message = message + "  <div class=\"normal\">观察主题  "+ categoryName +"</div>"; | 
|---|
|  |  |  | message = message + "  <div class=\"normal\">符合:"+ workorder.getDcaYesNum()  +" 不符合:"+workorder.getDcaNoNum()+"</div>"; | 
|---|
|  |  |  | if(Constants.equalsInteger(contentType,Constants.TWO)){ | 
|---|
|  |  |  | message = message + " <div class=\"normal\">说明:"+ csInfo +"</div>"; | 
|---|
|  |  |  | message = message + "  <div class=\"normal\">说明    "+ csInfo +"</div>"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | textCard.setDescription(message); | 
|---|
|  |  |  | 
|---|
|  |  |  | if (Constants.equalsInteger(workorder.getType(), Constants.THREE) || Constants.equalsInteger(workorder.getType(), Constants.TWO) ) { | 
|---|
|  |  |  | //处理上报日志 DCA工单 日志存储至子业务 不存在于父级  与跌绊滑 | 
|---|
|  |  |  | String logTitle = Constants.equalsInteger(workorder.getType(), Constants.THREE) ? "跌绊滑风险" : "DCA"; | 
|---|
|  |  |  | this.saveLog(null,workorder,Constants.ZERO,workorder.getMemberId(),workOrderStatus.getLogTitle().replace("{title}",logTitle),null); | 
|---|
|  |  |  | workorder.setCreateDate(workorder.getSubmitDate()); | 
|---|
|  |  |  | this.saveLog(null,workorder,Constants.ZERO,workorder.getMemberId(),workOrderStatus.getLogTitle().replace("{title}",logTitle),null,null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | List<Multifile> multifileList = workorder.getMultifileList(); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ | 
|---|
|  |  |  | for (Multifile multifile:multifileList) { | 
|---|
|  |  |  | if(StringUtils.isEmpty(multifile.getFileurl())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"附件信息错误!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | multifile.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | multifile.setObjId(workorder.getId()); | 
|---|
|  |  |  | multifile.setCreateDate(new Date()); | 
|---|
|  |  |  | multifile.setObjType(Constants.multiFileType.upload); | 
|---|
|  |  |  | multifileMapper.insert(multifile); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | multifileMapper.insert(multifileList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | * @param workorder | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public void saveProblemData(Workorder workorder){ | 
|---|
|  |  |  | if(Constants.equalsInteger(workorder.getType(),Constants.TWO)){ | 
|---|
|  |  |  | if(Constants.equalsInteger(workorder.getType(),Constants.ONE)){ | 
|---|
|  |  |  | List<DCANoProblemDTO> dcaNoProblemDTOList = workorder.getDcaNoProblemDTOList(); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(dcaNoProblemDTOList)){ | 
|---|
|  |  |  | Integer indexCode =  0 ; | 
|---|
|  |  |  | for (DCANoProblemDTO dcaNoProblemDTO:dcaNoProblemDTOList) { | 
|---|
|  |  |  | indexCode = indexCode + 1; | 
|---|
|  |  |  | Category problem = categoryMapper.selectById(dcaNoProblemDTO.getProblemId()); | 
|---|
|  |  |  | if(!Constants.equalsInteger(problem.getType(),6)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"题目分类错误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Constants.WorkOrderStatus workOrderStatus = Constants.WorkOrderStatus.waitConfirm; | 
|---|
|  |  |  | Workorder dcaWorkOrder = new Workorder(); | 
|---|
|  |  |  | dcaWorkOrder.setCreateDate(new Date()); | 
|---|
|  |  |  | 
|---|
|  |  |  | dcaWorkOrder.setProblemId(problem.getId()); | 
|---|
|  |  |  | dcaWorkOrder.setProblemInfo(problem.getRemark()); | 
|---|
|  |  |  | dcaWorkOrder.setDcaRecordId(workorder.getId()); | 
|---|
|  |  |  | dcaWorkOrder.setHappenTime(workorder.getHappenTime()); | 
|---|
|  |  |  | dcaWorkOrder.setLocaltionId(workorder.getLocaltionId()); | 
|---|
|  |  |  | dcaWorkOrder.setLocationName(workorder.getLocationName()); | 
|---|
|  |  |  | dcaWorkOrder.setSubmitDate(workorder.getSubmitDate()); | 
|---|
|  |  |  | dcaWorkOrder.setCode(workorder.getCode()+"_"+ org.apache.commons.lang3.StringUtils.leftPad(indexCode.toString(),2,"0")); | 
|---|
|  |  |  | dcaWorkOrder.setEventInfo(dcaNoProblemDTO.getEventInfo()); | 
|---|
|  |  |  | dcaWorkOrder.setQwnoticeMemberIds(workorder.getQwnoticeMemberIds()); | 
|---|
|  |  |  | dcaWorkOrder.setMemberNames(workorder.getMemberNames()); | 
|---|
|  |  |  | workorderMapper.insert(dcaWorkOrder); | 
|---|
|  |  |  | //存储日志 | 
|---|
|  |  |  | this.dealLogData(dcaWorkOrder,workOrderStatus); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //存储待办人员信息 | 
|---|
|  |  |  | this.saveNotice(Arrays.asList(dcaWorkOrder.getQwnoticeMemberIds().split(",")),dcaWorkOrder.getId(),Constants.ZERO,Constants.ZERO); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Multifile> multifileList = dcaNoProblemDTO.getMultifileList(); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ | 
|---|
|  |  |  | for (Multifile multifile:multifileList) { | 
|---|
|  |  |  | 
|---|
|  |  |  | multifileMapper.insert(multifileList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | workorder.setStatus(Constants.WorkOrderStatus.sheClose.getKey()); | 
|---|
|  |  |  | workorderMapper.updateById(workorder); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查询主题下的所有观察项 | 
|---|
|  |  |  | Category type = categoryMapper.selectById(workorder.getTypeId()); | 
|---|
|  |  |  | if(Objects.nonNull(type)){ | 
|---|
|  |  |  | //存储DCA工单详情 | 
|---|
|  |  |  | Map<String,Object> detail  = new HashMap<>(); | 
|---|
|  |  |  | detail.put("title","观察主题:"+type.getName()); | 
|---|
|  |  |  | List<Category> categoryList = categoryMapper.selectList(new QueryWrapper<Category>().lambda().eq(Category::getType,4) | 
|---|
|  |  |  | .eq(Category::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Category::getParentId,workorder.getTypeId())); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(categoryList)){ | 
|---|
|  |  |  | List<Map<String,Object>> childMapList = new ArrayList<>(); | 
|---|
|  |  |  | for (Category category:categoryList) { | 
|---|
|  |  |  | Map<String,Object> childMap = new HashMap<>(); | 
|---|
|  |  |  | childMap.put("childTitle",category.getName()); | 
|---|
|  |  |  | List<Category> problemList = categoryMapper.selectList(new QueryWrapper<Category>().lambda() | 
|---|
|  |  |  | .eq(Category::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Category::getType,6).eq(Category::getParentId,category.getId())); | 
|---|
|  |  |  | List<Map<String,Object>> problemMapList = new ArrayList<>(); | 
|---|
|  |  |  | Integer index = Constants.ONE; | 
|---|
|  |  |  | for (Category problem:problemList) { | 
|---|
|  |  |  | Map<String,Object>  problemMap = new HashMap<>(); | 
|---|
|  |  |  | problemMap.put("title",index + "、" + problem.getName()); | 
|---|
|  |  |  | List<DCANoProblemDTO> pList = dcaNoProblemDTOList.stream().filter(i->Constants.equalsInteger(i.getProblemId(),problem.getId())).collect(Collectors.toList()); | 
|---|
|  |  |  | if(pList.size()>Constants.ZERO){ | 
|---|
|  |  |  | DCANoProblemDTO  dcaNoProblemDTO = pList.get(Constants.ZERO); | 
|---|
|  |  |  | problemMap.put("status",Constants.TWO); | 
|---|
|  |  |  | problemMap.put("eventInfo","不符合原因:"+dcaNoProblemDTO.getEventInfo()); | 
|---|
|  |  |  | problemMap.put("imgList",dcaNoProblemDTO.getMultifileList().stream().map(i->i.getFileurl()).collect(Collectors.joining(","))); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | problemMap.put("status",Constants.ONE); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | index = index + Constants.ONE; | 
|---|
|  |  |  | problemMapList.add(problemMap); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | childMap.put("problemMapList",problemMapList); | 
|---|
|  |  |  | childMapList.add(childMap); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | detail.put("childMapList",childMapList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | workorder.setRemark(JSONObject.toJSONString(detail)); | 
|---|
|  |  |  | workorderMapper.updateById(workorder); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | workorder.setMemberNames(memberList.stream().map(i->i.getName()).collect(Collectors.joining(","))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //跌绊滑事件上报 查询SHE负责人 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(Constants.equalsInteger(workorder.getType(),Constants.ZERO)){ | 
|---|
|  |  |  | List<Managers> managersList = managersMapper.selectJoinList(Managers.class,new MPJLambdaWrapper<Managers>().selectAll(Managers.class) | 
|---|
|  |  |  | .selectAs(Member::getName,Managers::getMemberName) | 
|---|
|  |  |  | .selectAs(Member::getQwId,Managers::getQwId) | 
|---|
|  |  |  | .leftJoin(Member.class,Member::getId,Managers::getMemberId) | 
|---|
|  |  |  | .eq(Managers::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Managers::getType,Constants.THREE).orderByAsc(Managers::getSortnum) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(Objects.isNull(managersList)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"未查询到SHE处理抄送人员"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(managersList)){ | 
|---|
|  |  |  | workorder.setQwnoticeMemberIds(managersList.stream().filter(i->Constants.equalsInteger(i.getIsQw(),Constants.ONE)).map(i->i.getQwId()).collect(Collectors.joining(","))); | 
|---|
|  |  |  | if(Constants.equalsInteger(workorder.getType(),Constants.ZERO)){ | 
|---|
|  |  |  | workorder.setEmialMemberIds(managersList.stream().filter(i->Constants.equalsInteger(i.getIsEmail(),Constants.ONE)).map(i->i.getMemberId().toString()).collect(Collectors.joining(","))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //跌绊滑事件上报 \ DCA  查询SHE负责人 | 
|---|
|  |  |  | if(Constants.equalsInteger(workorder.getType(),Constants.THREE) || Constants.equalsInteger(workorder.getType(),Constants.ONE)){ | 
|---|
|  |  |  | List<Managers> managersList = managersMapper.selectJoinList(Managers.class,new MPJLambdaWrapper<Managers>().selectAll(Managers.class) | 
|---|
|  |  |  | .selectAs(Member::getName,Managers::getMemberName) | 
|---|
|  |  |  | .selectAs(Member::getQwId,Managers::getQwId) | 
|---|
|  |  |  | .leftJoin(Member.class,Member::getId,Managers::getMemberId) | 
|---|
|  |  |  | .eq(Managers::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Managers::getType,Constants.ZERO).orderByAsc(Managers::getSortnum) | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"未查询到SHE处理抄送人员"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(managersList)){ | 
|---|
|  |  |  | workorder.setQwnoticeMemberIds(managersList.stream().map(i->i.getMemberId().toString()).collect(Collectors.joining(","))); | 
|---|
|  |  |  | if(Constants.equalsInteger(workorder.getType(),Constants.ZERO)){ | 
|---|
|  |  |  | workorder.setEmialMemberIds(managersList.stream().map(i->i.getMemberId().toString()).collect(Collectors.joining(","))); | 
|---|
|  |  |  | workorder.setQwnoticeMemberIds(managersList.stream().map(i->i.getQwId()).collect(Collectors.joining(","))); | 
|---|
|  |  |  | List<Member> memberList = memberMapper.selectList(new QueryWrapper<Member>().lambda().eq(Member::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .in(Member::getQwId,workorder.getQwnoticeMemberIds().split(","))); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(memberList)){ | 
|---|
|  |  |  | workorder.setMemberNames(memberList.stream().map(i->i.getName()).collect(Collectors.joining(","))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | * @param afterWorkorder | 
|---|
|  |  |  | * @param objType 操作类型 0任务上报 1任务分配物业主管 2任务分配处理人 3任务处理关闭 4任务催促 | 
|---|
|  |  |  | * @param memberId | 
|---|
|  |  |  | * @param paramr2 转交给的处理人 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Integer saveLog(String beforeJson,Workorder afterWorkorder,Integer objType,Integer memberId,String title,String content){ | 
|---|
|  |  |  | public Integer saveLog(String beforeJson,Workorder afterWorkorder,Integer objType,Integer memberId,String title,String content,String paramr2){ | 
|---|
|  |  |  | WorkorderLog workorderLog = new WorkorderLog(); | 
|---|
|  |  |  | workorderLog.setCreateDate(new Date()); | 
|---|
|  |  |  | workorderLog.setEditDate(new Date()); | 
|---|
|  |  |  | workorderLog.setCreateDate(afterWorkorder.getCreateDate()); | 
|---|
|  |  |  | workorderLog.setEditDate(afterWorkorder.getCreateDate()); | 
|---|
|  |  |  | workorderLog.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | workorderLog.setBeforeContent(beforeJson); | 
|---|
|  |  |  | workorderLog.setAfterContent(JSONObject.toJSONString(afterWorkorder)); | 
|---|
|  |  |  | workorderLog.setParam1(memberId.toString()); | 
|---|
|  |  |  | workorderLog.setParam2(paramr2); | 
|---|
|  |  |  | workorderLog.setObjId(afterWorkorder.getId().toString()); | 
|---|
|  |  |  | workorderLog.setObjType(objType); | 
|---|
|  |  |  | workorderLog.setTitle(title); | 
|---|
|  |  |  | 
|---|
|  |  |  | if(Constants.equalsInteger(workorder.getType(),Constants.ONE)){ | 
|---|
|  |  |  | if(Objects.isNull(workorder.getDcaYesNum()) | 
|---|
|  |  |  | || Objects.isNull(workorder.getDcaNoNum()) | 
|---|
|  |  |  | || Objects.isNull(workorder.getCategoryId()) | 
|---|
|  |  |  | //                    || Objects.isNull(workorder.getCategoryId()) | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Workorder getDetail(Integer id){ | 
|---|
|  |  |  | public Workorder getDetail(Integer id,Member member){ | 
|---|
|  |  |  | Workorder workorder = workorderMapper.selectJoinOne(Workorder.class, | 
|---|
|  |  |  | new MPJLambdaWrapper<Workorder>() | 
|---|
|  |  |  | .selectAll(Workorder.class) | 
|---|
|  |  |  | 
|---|
|  |  |  | .selectAs(Member::getName,Workorder::getMemberName) | 
|---|
|  |  |  | .selectAs(Member::getCompanyName,Workorder::getCompanyName) | 
|---|
|  |  |  | .select(" c3.name ",Workorder::getTypeName) | 
|---|
|  |  |  | .select(" c3.name_path ",Workorder::getTypeNamePath) | 
|---|
|  |  |  | .select(" c4.name ",Workorder::getCategoryName) | 
|---|
|  |  |  | .leftJoin(Member.class,Member::getId,Workorder::getMemberId) | 
|---|
|  |  |  | .leftJoin(" category c3 on  t.TYPE_ID = c3.id   ") //风险类型 | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq(Workorder::getId,id) | 
|---|
|  |  |  | .last(" limit 1 ") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(Objects.nonNull(workorder)){ | 
|---|
|  |  |  | //查询附件信息 | 
|---|
|  |  |  | List<Multifile> multifileList = multifileMapper.selectList(new QueryWrapper<Multifile>().lambda().eq(Multifile::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Multifile::getObjId,workorder.getId()).orderByAsc(Multifile::getId)); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ | 
|---|
|  |  |  | String path = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() | 
|---|
|  |  |  | +systemDictDataBiz.queryByCode(Constants.FTP,Constants.WORKORDER_FILE_PATH).getCode(); | 
|---|
|  |  |  | for (Multifile multifile:multifileList) { | 
|---|
|  |  |  | multifile.setFileurlFull(path+multifile.getFileurl()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | workorder.setMultifileList(multifileList); | 
|---|
|  |  |  | if(Objects.isNull(workorder)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | this.dealButton(workorder,member); | 
|---|
|  |  |  | //查询附件信息 | 
|---|
|  |  |  | List<Multifile> multifileList = multifileMapper.selectList(new QueryWrapper<Multifile>().lambda().eq(Multifile::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Multifile::getObjId,workorder.getId()).orderByAsc(Multifile::getId)); | 
|---|
|  |  |  | String path = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() | 
|---|
|  |  |  | +systemDictDataBiz.queryByCode(Constants.FTP,Constants.WORKORDER_FILE_PATH).getCode(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | workorder.setPath(path); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ | 
|---|
|  |  |  | for (Multifile multifile:multifileList) { | 
|---|
|  |  |  | multifile.setFileurlFull(path+multifile.getFileurl()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | workorder.setMultifileList(multifileList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //查询日志信息 | 
|---|
|  |  |  | workorder.setLogList(this.getLogList(workorder.getId())); | 
|---|
|  |  |  | workorder.setLogList(this.getLogList(workorder,member)); | 
|---|
|  |  |  | if(Constants.equalsInteger(workorder.getType(),Constants.ONE)){ | 
|---|
|  |  |  | //如果是DCA提交记录,查询子工单集合 | 
|---|
|  |  |  | Workorder param = new Workorder(); | 
|---|
|  |  |  | param.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | param.setDcaRecordId(workorder.getId()); | 
|---|
|  |  |  | workorder.setDcaChildList(findList(param)); | 
|---|
|  |  |  | List<Workorder> dcaChildList = findList(param); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(dcaChildList)){ | 
|---|
|  |  |  | for (Workorder dcaChild:dcaChildList) { | 
|---|
|  |  |  | this.dealButton(dcaChild,member); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | workorder.setManagerId(dcaChildList.stream().filter(i->Objects.nonNull(i.getManagerId())).map(i->i.getManagerId()).collect(Collectors.joining(","))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | workorder.setDcaChildList(dcaChildList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return workorder; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void dealButton(Workorder workorder,Member member){ | 
|---|
|  |  |  | workorder.setPassOnButton(Constants.ZERO); | 
|---|
|  |  |  | workorder.setCloseButton(Constants.ZERO); | 
|---|
|  |  |  | if(member!=null && org.apache.commons.lang3.StringUtils.isNotBlank(member.getQwId())){ | 
|---|
|  |  |  | List<String> closeUserList = new ArrayList<>(); | 
|---|
|  |  |  | if(org.apache.commons.lang3.StringUtils.isNotBlank(workorder.getQwnoticeMemberIds())&& | 
|---|
|  |  |  | (Constants.equalsInteger(workorder.getStatus(),Constants.ZERO)|| | 
|---|
|  |  |  | Constants.equalsInteger(workorder.getStatus(),Constants.ONE)||Constants.equalsInteger(workorder.getStatus(),Constants.TWO))){ | 
|---|
|  |  |  | closeUserList.addAll(Arrays.asList(workorder.getQwnoticeMemberIds().split(","))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(org.apache.commons.lang3.StringUtils.isNotBlank(workorder.getManagerId())&& | 
|---|
|  |  |  | (Constants.equalsInteger(workorder.getStatus(),Constants.ONE)||Constants.equalsInteger(workorder.getStatus(),Constants.TWO))){ | 
|---|
|  |  |  | closeUserList.add(workorder.getManagerId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(org.apache.commons.lang3.StringUtils.isNotBlank(workorder.getDealerId())&& | 
|---|
|  |  |  | (Constants.equalsInteger(workorder.getStatus(),Constants.TWO))){ | 
|---|
|  |  |  | closeUserList.add(workorder.getDealerId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(closeUserList)){ | 
|---|
|  |  |  | workorder.setCloseButton(closeUserList.stream().filter(i->i.equals(member.getQwId())).collect(Collectors.toList()).size()>Constants.ZERO?Constants.ONE:Constants.ZERO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<String> passOnUserList = new ArrayList<>(); | 
|---|
|  |  |  | //待分配状态 处理转交按钮 | 
|---|
|  |  |  | if(Constants.equalsInteger(workorder.getStatus(),Constants.WorkOrderStatus.waitConfirm.getKey()) | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | passOnUserList.addAll(Arrays.asList(workorder.getQwnoticeMemberIds().split(","))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(Constants.equalsInteger(workorder.getStatus(),Constants.WorkOrderStatus.waitAllocation.getKey()) | 
|---|
|  |  |  | || Constants.equalsInteger(workorder.getStatus(),Constants.WorkOrderStatus.waitDeal.getKey()) | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | passOnUserList.add(workorder.getManagerId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(passOnUserList)){ | 
|---|
|  |  |  | workorder.setPassOnButton(passOnUserList.stream().filter(i->i.equals(member.getQwId())).collect(Collectors.toList()).size()>Constants.ZERO?Constants.ONE:Constants.ZERO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public List<WorkorderLog> getLogList(Integer orderId){ | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public List<WorkorderLog> getLogList(Workorder workorder,Member loginMember){ | 
|---|
|  |  |  | List<WorkorderLog> logList = workorderLogMapper.selectJoinList(WorkorderLog.class, | 
|---|
|  |  |  | new MPJLambdaWrapper<WorkorderLog>() | 
|---|
|  |  |  | .selectAll(WorkorderLog.class) | 
|---|
|  |  |  | .selectAs(Member::getName,WorkorderLog::getUserName) | 
|---|
|  |  |  | .selectAs(Member::getCompanyName,WorkorderLog::getCompanyName) | 
|---|
|  |  |  | .leftJoin(Member.class,Member::getId,WorkorderLog::getParam1) | 
|---|
|  |  |  | .eq(WorkorderLog::getObjId,orderId) | 
|---|
|  |  |  | .orderByAsc(WorkorderLog::getId) | 
|---|
|  |  |  | .eq(WorkorderLog::getObjId,workorder.getId()) | 
|---|
|  |  |  | .orderByDesc(WorkorderLog::getId) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(logList)){ | 
|---|
|  |  |  | String path = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() | 
|---|
|  |  |  | +systemDictDataBiz.queryByCode(Constants.FTP,Constants.WORKORDER_FILE_PATH).getCode(); | 
|---|
|  |  |  | +systemDictDataBiz.queryByCode(Constants.FTP,Constants.WORKORDER_LOG_FILE_PATH).getCode(); | 
|---|
|  |  |  | Boolean canOpenUrgeButton = true; | 
|---|
|  |  |  | for (WorkorderLog workorderLog:logList) { | 
|---|
|  |  |  | workorderLog.setUrgeButton(Constants.ZERO); | 
|---|
|  |  |  | if(Constants.equalsInteger(workorderLog.getObjType(),Constants.TWO)||Constants.equalsInteger(workorderLog.getObjType(),Constants.ONE)){ | 
|---|
|  |  |  | //物业主管处理中 | 
|---|
|  |  |  | if(Constants.equalsInteger(workorder.getStatus(),Constants.ONE)){ | 
|---|
|  |  |  | Member member = memberMapper.selectById(workorderLog.getParam1()); | 
|---|
|  |  |  | if(Objects.nonNull(member) && org.apache.commons.lang3.StringUtils.isNotBlank(member.getQwId()) | 
|---|
|  |  |  | && Objects.nonNull(loginMember) &&  Constants.equalsInteger(member.getId(),loginMember.getId()) | 
|---|
|  |  |  | && workorder.getQwnoticeMemberIds().indexOf(member.getQwId())>=Constants.ZERO){ | 
|---|
|  |  |  | workorderLog.setUrgeButton(Constants.ONE); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //工程师处理中 | 
|---|
|  |  |  | if(Constants.equalsInteger(workorder.getStatus(),Constants.TWO)){ | 
|---|
|  |  |  | Member member = memberMapper.selectById(workorderLog.getParam1()); | 
|---|
|  |  |  | if(Objects.nonNull(member) && org.apache.commons.lang3.StringUtils.isNotBlank(member.getQwId()) | 
|---|
|  |  |  | && canOpenUrgeButton | 
|---|
|  |  |  | && (workorder.getQwnoticeMemberIds().indexOf(member.getQwId()) >= Constants.ZERO ||  member.getQwId().equals(workorder.getManagerId()) ) | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | workorderLog.setUrgeButton(Constants.ONE); | 
|---|
|  |  |  | canOpenUrgeButton = false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查询附件信息 | 
|---|
|  |  |  | List<Multifile> multifileList = multifileMapper.selectList(new QueryWrapper<Multifile>().lambda() | 
|---|
|  |  |  | .eq(Multifile::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | 
|---|
|  |  |  | .selectAs(Member::getPhone,Workorder::getMemberPhone) | 
|---|
|  |  |  | .select(" c2.name ",Workorder::getCategoryName) | 
|---|
|  |  |  | .select(" c3.name ",Workorder::getTypeName) | 
|---|
|  |  |  | .select(" c3.name_path ",Workorder::getTypeNamePath) | 
|---|
|  |  |  | .leftJoin(Member.class,Member::getId,Workorder::getMemberId) | 
|---|
|  |  |  | .leftJoin(" category c3 on  t.TYPE_ID = c3.id   ") //风险类型 | 
|---|
|  |  |  | .leftJoin(" category c2 on  t.CATEGORY_ID = c2.id   ") //DCA一级问题编码 | 
|---|
|  |  |  | .apply(Objects.nonNull(pageWrap.getMyWorkOrder())&& | 
|---|
|  |  |  | org.apache.commons.lang3.StringUtils.isNotBlank(pageWrap.getQwId()) | 
|---|
|  |  |  | &&Constants.equalsInteger(Constants.ONE,pageWrap.getMyWorkOrder()), | 
|---|
|  |  |  | " ( t.id in (  select OBJ_ID from notices where param1 = '"+pageWrap.getQwId()+"' and type != 3  ))  ") | 
|---|
|  |  |  | .ne(org.apache.commons.lang3.StringUtils.isNotBlank(pageWrap.getQwId()),Workorder::getType,Constants.TWO) | 
|---|
|  |  |  | .in(Objects.nonNull(pageWrap.getDealStatus())&& | 
|---|
|  |  |  | Constants.equalsInteger(pageWrap.getDealStatus(),Constants.ZERO), | 
|---|
|  |  |  | Workorder::getStatus,Constants.WorkOrderStatus.waitConfirm.getKey(),Constants.WorkOrderStatus.waitAllocation.getKey(),Constants.WorkOrderStatus.waitDeal.getKey()) | 
|---|
|  |  |  | .in(Objects.nonNull(pageWrap.getDealStatus())&& | 
|---|
|  |  |  | Constants.equalsInteger(pageWrap.getDealStatus(),Constants.ONE), | 
|---|
|  |  |  | Workorder::getStatus,Constants.WorkOrderStatus.sheClose.getKey(),Constants.WorkOrderStatus.close.getKey(),Constants.WorkOrderStatus.wtsClose.getKey()) | 
|---|
|  |  |  | .eq( pageWrap.getId() != null, Workorder::getId, pageWrap.getId()) | 
|---|
|  |  |  | .eq( pageWrap.getCreator() != null, Workorder::getCreator, pageWrap.getCreator()) | 
|---|
|  |  |  | .ge( pageWrap.getCreateDate() != null, Workorder::getCreateDate, Utils.Date.getStart( pageWrap.getCreateDate())) | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq( pageWrap.getDcaYesNum() != null, Workorder::getDcaYesNum,  pageWrap.getDcaYesNum()) | 
|---|
|  |  |  | .eq( pageWrap.getDcaNoNum() != null, Workorder::getDcaNoNum,  pageWrap.getDcaNoNum()) | 
|---|
|  |  |  | .eq( pageWrap.getDcaRecordId() != null, Workorder::getDcaRecordId,  pageWrap.getDcaRecordId()) | 
|---|
|  |  |  | .likeRight( pageWrap.getTypeIdPath() != null,"c3.id_path",  pageWrap.getTypeIdPath()) | 
|---|
|  |  |  | .eq( pageWrap.getDcaCsIds() != null, Workorder::getDcaCsIds,  pageWrap.getDcaCsIds()) ; | 
|---|
|  |  |  | if ( pageWrap.getMemberName() != null) { | 
|---|
|  |  |  | queryWrapper.and( ms->ms.like(Member::getName, pageWrap.getMemberName()) | 
|---|
|  |  |  | .or().like(Member::getPhone, pageWrap.getMemberName()) ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | queryWrapper.orderByDesc(Workorder::getProblemId); | 
|---|
|  |  |  | queryWrapper.orderByDesc(Workorder::getId); | 
|---|
|  |  |  | return queryWrapper; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | }else if(Constants.equalsInteger(type,Constants.THREE)){ | 
|---|
|  |  |  | key = "A"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String code = redisTemplate.opsForValue().get(key+"_CODE").toString(); | 
|---|
|  |  |  | if(StringUtils.isEmpty(code)){ | 
|---|
|  |  |  | code = "01"; | 
|---|
|  |  |  | String code = "01"; | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | code = redisTemplate.opsForValue().get(key+"_CODE").toString(); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | redisTemplate.opsForValue().set(key+"_CODE",Integer.valueOf(code)+1); | 
|---|
|  |  |  | return key + date + org.apache.commons.lang3.StringUtils.leftPad(code,2,"0"); | 
|---|
|  |  |  | 
|---|
|  |  |  | if(Objects.isNull(closeDTO) | 
|---|
|  |  |  | || Objects.isNull(closeDTO.getWorkorderId()) | 
|---|
|  |  |  | || org.apache.commons.lang3.StringUtils.isBlank(closeDTO.getInfo()) | 
|---|
|  |  |  | || com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(closeDTO.getMultifileList())){ | 
|---|
|  |  |  | || com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(closeDTO.getMultifileList())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Workorder workorder = workorderMapper.selectById(closeDTO.getWorkorderId()); | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,当前工单非您的工单,无法进行处理"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | workorder.setStatus(Constants.WorkOrderStatus.wtsClose.getKey()); | 
|---|
|  |  |  | qwIds = Arrays.asList(workorder.getQwnoticeMemberIds()); | 
|---|
|  |  |  | qwIds.addAll(Arrays.asList(workorder.getQwnoticeMemberIds().split(","))); | 
|---|
|  |  |  | qwIds.add(workorder.getManagerId()); | 
|---|
|  |  |  | qwIds.remove(closeDTO.getMember().getQwId()); | 
|---|
|  |  |  | }else if(Constants.equalsInteger(workorder.getStatus(),Constants.WorkOrderStatus.waitDeal.getKey())){ | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,当前工单非您的工单,无法进行处理"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | workorder.setStatus(Constants.WorkOrderStatus.wtsClose.getKey()); | 
|---|
|  |  |  | qwIds = Arrays.asList(workorder.getQwnoticeMemberIds()); | 
|---|
|  |  |  | qwIds.addAll(Arrays.asList(workorder.getQwnoticeMemberIds().split(","))); | 
|---|
|  |  |  | qwIds.add(workorder.getDealerId()); | 
|---|
|  |  |  | qwIds.remove(closeDTO.getMember().getQwId()); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | 
|---|
|  |  |  | workorder.setDealInfo(closeDTO.getInfo()); | 
|---|
|  |  |  | workorderMapper.updateById(workorder); | 
|---|
|  |  |  | //处理上报日志 | 
|---|
|  |  |  | Integer logId = this.saveLog(beforeJson,workorder,Constants.THREE,workorder.getMemberId(),"任务已处理",closeDTO.getInfo()); | 
|---|
|  |  |  | List<Multifile> multifileList = workorder.getMultifileList(); | 
|---|
|  |  |  | Integer logId = this.saveLog(beforeJson,workorder,Constants.THREE,workorder.getMemberId(),"任务已处理",closeDTO.getInfo(),null); | 
|---|
|  |  |  | List<Multifile> multifileList = closeDTO.getMultifileList(); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ | 
|---|
|  |  |  | for (Multifile multifile:multifileList) { | 
|---|
|  |  |  | multifile.setObjId(logId); | 
|---|
|  |  |  | multifile.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | multifile.setCreateDate(new Date()); | 
|---|
|  |  |  | multifile.setObjType(Constants.multiFileType.deal); | 
|---|
|  |  |  | multifileMapper.insert(multifile); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | multifileMapper.insert(multifileList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //发送企微通知 | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(qwIds)){ | 
|---|
|  |  |  | 
|---|
|  |  |  | public void passOn(PassOnDTO passOnDTO){ | 
|---|
|  |  |  | if(Objects.isNull(passOnDTO) | 
|---|
|  |  |  | || Objects.isNull(passOnDTO.getWorkorderId()) | 
|---|
|  |  |  | || Objects.isNull(passOnDTO.getPassOnUserId()) | 
|---|
|  |  |  | || org.apache.commons.lang3.StringUtils.isBlank(passOnDTO.getPassOnUserId()) | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Member member = memberMapper.selectById(passOnDTO.getPassOnUserId()); | 
|---|
|  |  |  | Member member = memberMapper.selectOne(new QueryWrapper<Member>().lambda().eq(Member::getQwId,passOnDTO.getPassOnUserId())); | 
|---|
|  |  |  | if(Objects.isNull(member)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到被转交人信息"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | workorder.setStatus(Constants.WorkOrderStatus.waitDeal.getKey()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | workorder.setEditDate(new Date()); | 
|---|
|  |  |  | workorder.setUrgeDate(DateUtil.afterHoursDate(new Date(),24)); | 
|---|
|  |  |  | workorder.setUrgeDate(DateUtil.afterMinutesDate(new Date(),10)); | 
|---|
|  |  |  | workorderMapper.updateById(workorder); | 
|---|
|  |  |  | String paramr2 = member.getCompanyName()+"/"+member.getName(); | 
|---|
|  |  |  | //处理上报日志 | 
|---|
|  |  |  | Integer logId = this.saveLog(beforeJson,workorder, | 
|---|
|  |  |  | Constants.equalsInteger(passOnDTO.getPassOnType(),Constants.ZERO)?Constants.ONE:Constants.TWO | 
|---|
|  |  |  | ,workorder.getMemberId(),"任务分配",passOnDTO.getInfo()); | 
|---|
|  |  |  | List<Multifile> multifileList = workorder.getMultifileList(); | 
|---|
|  |  |  | ,workorder.getMemberId(),"任务分配",passOnDTO.getInfo(),paramr2); | 
|---|
|  |  |  | List<Multifile> multifileList = passOnDTO.getMultifileList(); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ | 
|---|
|  |  |  | for (Multifile multifile:multifileList) { | 
|---|
|  |  |  | multifile.setObjId(logId); | 
|---|
|  |  |  | 
|---|
|  |  |  | Category category = categoryMapper.selectById(workorder.getTypeId()); | 
|---|
|  |  |  | if(Objects.nonNull(passOnDTO.getMember())&&Objects.nonNull(category)){ | 
|---|
|  |  |  | // 发送企微通知 | 
|---|
|  |  |  | this.sendQwMsg(workorder,member.getQwId(),passOnDTO.getMember(),category.getName(),Constants.ZERO,null); | 
|---|
|  |  |  | this.sendQwMsg(workorder,passOnDTO.getPassOnUserId(),passOnDTO.getMember(),category.getName(),Constants.ZERO,null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //存储待办人员信息 | 
|---|
|  |  |  | this.saveNotice(Arrays.asList(passOnDTO.getMember().getQwId().split(",")),workorder.getId(),Constants.ZERO,Constants.TWO); | 
|---|
|  |  |  | this.saveNotice(Arrays.asList(passOnDTO.getPassOnUserId().split(",")), | 
|---|
|  |  |  | Constants.equalsInteger(workorder.getType(),Constants.TWO)?workorder.getDcaRecordId():workorder.getId(),Constants.ZERO,Constants.TWO); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Member> memberList = memberMapper.selectList(new QueryWrapper<Member>().lambda().eq(Member::getIsdeleted, Constants.ZERO) | 
|---|
|  |  |  | .isNotNull(Member::getQwId) | 
|---|
|  |  |  | .in(Member::getId, sendCopyDTO.getUserIds().split(","))); | 
|---|
|  |  |  | .in(Member::getQwId, sendCopyDTO.getUserIds().split(","))); | 
|---|
|  |  |  | if (com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(memberList)) { | 
|---|
|  |  |  | List<String> qwIdList = memberList.stream().map(i -> i.getQwId()).collect(Collectors.toList()); | 
|---|
|  |  |  | Category category = categoryMapper.selectById(workorder.getTypeId()); | 
|---|
|  |  |  | if (Objects.nonNull(category)) { | 
|---|
|  |  |  | // 发送企微通知 | 
|---|
|  |  |  | this.sendQwMsg(workorder, String.join(",", qwIdList), sendCopyDTO.getMember(), category.getName(), Constants.ONE, null); | 
|---|
|  |  |  | this.sendQwMsg(workorder, String.join(",", qwIdList), sendCopyDTO.getMember(), category.getName(), Constants.TWO, sendCopyDTO.getInfo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //存储待办信息 | 
|---|
|  |  |  | this.saveNotice(qwIdList, workorder.getId(), Constants.ONE, Constants.ONE); | 
|---|
|  |  |  | this.saveNotice(qwIdList, Constants.equalsInteger(workorder.getType(),Constants.TWO)?workorder.getDcaRecordId():workorder.getId(), Constants.ONE, Constants.ONE); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void sendSheEmail(){ | 
|---|
|  |  |  | if(Constants.WORKORDER_SHE_EMAIL_SENDING){ | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Constants.WORKORDER_SHE_EMAIL_SENDING = true; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | List<Workorder> list = workorderMapper.selectJoinList(Workorder.class,new MPJLambdaWrapper<Workorder>() | 
|---|
|  |  |  | .selectAll(Workorder.class) | 
|---|
|  |  |  | .selectAs(Member::getName,Workorder::getMemberName) | 
|---|
|  |  |  | .selectAs(Member::getCompanyName,Workorder::getCompanyName) | 
|---|
|  |  |  | .selectAs(Member::getPhone,Workorder::getMemberPhone) | 
|---|
|  |  |  | .select(" c2.name_path ",Workorder::getCategoryName) | 
|---|
|  |  |  | .select(" c3.name_path ",Workorder::getTypeName) | 
|---|
|  |  |  | .leftJoin(Member.class,Member::getId,Workorder::getMemberId) | 
|---|
|  |  |  | .leftJoin(" category c3 on  t.TYPE_ID = c3.id   ") //风险类型 | 
|---|
|  |  |  | .leftJoin(" category c2 on  t.CATEGORY_ID = c2.id   ") //DCA一级问题编码 | 
|---|
|  |  |  | .eq(Workorder::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Workorder::getEmailStatus,Constants.ZERO) | 
|---|
|  |  |  | .eq(Workorder::getType,Constants.ZERO) | 
|---|
|  |  |  | .isNotNull(Workorder::getEmialMemberIds )//邮箱通知 | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(list!=null && list.size()>0){ | 
|---|
|  |  |  | Date date = new Date(); | 
|---|
|  |  |  | String path = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() | 
|---|
|  |  |  | +systemDictDataBiz.queryByCode(Constants.FTP,Constants.WORKORDER_FILE_PATH).getCode(); | 
|---|
|  |  |  | for(Workorder workorder :list){ | 
|---|
|  |  |  | dealEmailBiz(workorder,date,path); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | log.error("==================定时发生SHE邮件失败:"+e.getMessage()); | 
|---|
|  |  |  | }finally { | 
|---|
|  |  |  | Constants.WORKORDER_SHE_EMAIL_SENDING = false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | private void dealEmailBiz(Workorder workorder, Date date,String path) { | 
|---|
|  |  |  | List<Notices> noticesList = new ArrayList<>(); | 
|---|
|  |  |  | int status =1; | 
|---|
|  |  |  | String info ="邮箱已发送:"; | 
|---|
|  |  |  | String ids = workorder.getEmialMemberIds(); | 
|---|
|  |  |  | List<Member> memberList = getEmailMemberlistByIDs(ids); | 
|---|
|  |  |  | if(memberList == null || memberList.size() ==0){ | 
|---|
|  |  |  | status = 2; | 
|---|
|  |  |  | info ="无效员工信息,无法发送邮箱"; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | List<String>    successInfo = new ArrayList<>(); | 
|---|
|  |  |  | List<String> errorInfo = new ArrayList<>(); | 
|---|
|  |  |  | Map<String,String> contentForm = getEmailContentFormByModel(workorder); | 
|---|
|  |  |  | List<String> imgList = getEmailImglistByModel(workorder,path); | 
|---|
|  |  |  | for(Member m : memberList){ | 
|---|
|  |  |  | if(org.apache.commons.lang3.StringUtils.isNotBlank(m.getEmail())){ | 
|---|
|  |  |  | //如果邮箱不为空,进行邮箱发送 | 
|---|
|  |  |  | successInfo.add(m.getName()+"邮箱"+m.getEmail()+""); | 
|---|
|  |  |  | if( emailService.sendEmailWithImages(m.getEmail(),"SHE事件工单上报通知", contentForm,imgList)){ | 
|---|
|  |  |  | Notices notices = new Notices(); | 
|---|
|  |  |  | notices.setType(Constants.THREE+""); | 
|---|
|  |  |  | notices.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | notices.setObjId(workorder.getId()); | 
|---|
|  |  |  | notices.setTitle("SHE事件工单上报邮件通知"); | 
|---|
|  |  |  | notices.setContent(JSONObject.toJSONString(contentForm)); | 
|---|
|  |  |  | notices.setRemark(JSONObject.toJSONString(imgList)); | 
|---|
|  |  |  | notices.setObjType(Constants.ZERO+""); | 
|---|
|  |  |  | notices.setStatus(Constants.ZERO); | 
|---|
|  |  |  | notices.setSendacopy(Constants.ONE); | 
|---|
|  |  |  | notices.setMemberId(m.getId()); | 
|---|
|  |  |  | noticesList.add(notices); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | errorInfo.add(m.getName()+"/无邮箱"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | errorInfo.add(m.getName()+"/邮箱"+m.getEmail()+""); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | info += "成功:"+JSONObject.toJSONString(successInfo) +"失败:"+JSONObject.toJSONString(errorInfo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Workorder update = new Workorder(); | 
|---|
|  |  |  | update.setId(workorder.getId()); | 
|---|
|  |  |  | update.setEmailDate(date); | 
|---|
|  |  |  | update.setEmailStatus(status ); | 
|---|
|  |  |  | update.setEmailInfo(info); | 
|---|
|  |  |  | this.updateById(update);//更新工单邮件发送状态 | 
|---|
|  |  |  | if(noticesList.size()>0){ | 
|---|
|  |  |  | noticesMapper.insert(noticesList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private List<String> getEmailImglistByModel(Workorder workorder,   String path ) { | 
|---|
|  |  |  | List<String> list = new ArrayList<>(); | 
|---|
|  |  |  | //查询附件信息 | 
|---|
|  |  |  | List<Multifile> multifileList = multifileMapper.selectList(new QueryWrapper<Multifile>().lambda().eq(Multifile::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Multifile::getObjId,workorder.getId()).orderByAsc(Multifile::getId)); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ | 
|---|
|  |  |  | for (Multifile multifile:multifileList) { | 
|---|
|  |  |  | list.add(path+multifile.getFileurl()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return list; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private List<Member> getEmailMemberlistByIDs(String ids) { | 
|---|
|  |  |  | List<Member> memberList = new ArrayList<>(); | 
|---|
|  |  |  | if(org.apache.commons.lang3.StringUtils.isNotBlank(ids)){ | 
|---|
|  |  |  | String[] tt = ids.split(","); | 
|---|
|  |  |  | List<Integer> idList =new ArrayList<>(); | 
|---|
|  |  |  | if(tt.length>0){ | 
|---|
|  |  |  | for(String s :tt){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | idList.add(Integer.parseInt(s)); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(idList.size()>0){ | 
|---|
|  |  |  | memberList = memberMapper.selectList(new QueryWrapper<Member>().lambda() | 
|---|
|  |  |  | .eq(Member::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .in(Member::getId,idList) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return memberList; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private Map<String, String> getEmailContentFormByModel(Workorder workorder) { | 
|---|
|  |  |  | Map<String, String>  map =  new LinkedHashMap<>(); | 
|---|
|  |  |  | map.put("上报人",workorder.getCompanyName()+"/" +workorder.getMemberName()); | 
|---|
|  |  |  | map.put("上报时间",DateUtil.getPlusTime2(workorder.getSubmitDate())); | 
|---|
|  |  |  | map.put("事件发生时间/地点",DateUtil.getPlusTime2(workorder.getHappenTime())+" / "+workorder.getLocationName()); | 
|---|
|  |  |  | map.put("伤害类型", workorder.getTypeName()); | 
|---|
|  |  |  | map.put("是否外部就医", Constants.equalsInteger(workorder.getOutJiuyi(),Constants.ONE)?"是":"否"); | 
|---|
|  |  |  | map.put("是否医务室", Constants.equalsInteger(workorder.getIsYiwushi(),Constants.ONE)?"是":"否"); | 
|---|
|  |  |  | map.put("是否受伤", Constants.equalsInteger(workorder.getIsHurted(),Constants.ONE)?"是":"否"); | 
|---|
|  |  |  | map.put("是否和工作相关", Constants.equalsInteger(workorder.getWorkRelated(),Constants.ONE)?"是":"否"); | 
|---|
|  |  |  | map.put("事件说明", org.apache.commons.lang3.StringUtils.defaultString(workorder.getEventInfo(),"-")); | 
|---|
|  |  |  | return  map; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | public void urge(Integer workorderId,Member member){ | 
|---|
|  |  |  | Workorder workorder = workorderMapper.selectById(workorderId); | 
|---|
|  |  |  | workorder.setEditDate(new Date()); | 
|---|
|  |  |  | workorder.setUrgeDate(DateUtil.afterHoursDate(new Date(),24)); | 
|---|
|  |  |  | workorder.setUrgeDate(DateUtil.afterMinutesDate(new Date(),10)); | 
|---|
|  |  |  | workorderMapper.updateById(workorder); | 
|---|
|  |  |  | if(Objects.isNull(workorder)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到工单数据"); | 
|---|
|  |  |  | 
|---|
|  |  |  | //如果已分配 wts 则是催促wts | 
|---|
|  |  |  | if(Constants.equalsInteger(workorder.getStatus(),Constants.WorkOrderStatus.waitAllocation.getKey())){ | 
|---|
|  |  |  | urgeUser = memberMapper.selectOne(new QueryWrapper<Member>().lambda().eq(Member::getIsdeleted,Constants.ZERO).eq(Member::getQwId,workorder.getManagerId()).last("limit 1 ")); | 
|---|
|  |  |  | }else if(Constants.equalsInteger(workorder.getStatus(),Constants.WorkOrderStatus.waitAllocation.getKey())){ | 
|---|
|  |  |  | }else if(Constants.equalsInteger(workorder.getStatus(),Constants.WorkOrderStatus.waitDeal.getKey())){ | 
|---|
|  |  |  | urgeUser = memberMapper.selectOne(new QueryWrapper<Member>().lambda().eq(Member::getIsdeleted,Constants.ZERO).eq(Member::getQwId,workorder.getDealerId()).last("limit 1 ")); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"状态已流转无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | this.saveLog(null,workorder, | 
|---|
|  |  |  | Constants.ONE | 
|---|
|  |  |  | ,member.getId(),"催促","已催促 "+urgeUser.getCompanyName() + "/" + urgeUser.getName()); | 
|---|
|  |  |  | Constants.FOUR | 
|---|
|  |  |  | ,member.getId(),"催促","已催促 "+urgeUser.getCompanyName() + "/" + urgeUser.getName(),null); | 
|---|
|  |  |  | //发送企微通知 | 
|---|
|  |  |  | Category category = categoryMapper.selectById(workorder.getTypeId()); | 
|---|
|  |  |  | if(Objects.nonNull(category)){ | 
|---|
|  |  |  | // 发送企微通知 | 
|---|
|  |  |  | this.sendQwMsg(workorder,urgeUser.getQwId(),null,category.getName(),Constants.ONE,null); | 
|---|
|  |  |  | this.sendQwMsg(workorder,urgeUser.getQwId(),member,category.getName(),Constants.ONE,null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | public void jobUrge(){ | 
|---|
|  |  |  | List<Workorder> workorderList = workorderMapper.selectList(new QueryWrapper<Workorder>().lambda().eq(Workorder::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .in(Workorder::getStatus,Constants.WorkOrderStatus.waitAllocation.getKey(),Constants.WorkOrderStatus.waitDeal.getKey()) | 
|---|
|  |  |  | .apply(" urge_time > now() ") | 
|---|
|  |  |  | .apply(" URGE_DATE < now() ") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(workorderList)){ | 
|---|
|  |  |  | for (Workorder workorder:workorderList) { | 
|---|
|  |  |  | this.autoUrge(workorder); | 
|---|
|  |  |  | workorder.setEditDate(new Date()); | 
|---|
|  |  |  | workorder.setUrgeDate(DateUtil.afterHoursDate(new Date(),24)); | 
|---|
|  |  |  | workorder.setUrgeDate(DateUtil.afterMinutesDate(new Date(),10));//DateUtil.afterHoursDate(new Date(),24)); | 
|---|
|  |  |  | workorderMapper.updateById(workorder); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void saveNotice(List<String> qwIdList ,Integer workorderId,Integer isSendCopy,Integer type){ | 
|---|
|  |  |  | public void saveNotice(List<String> qwIdList , Integer workorderId, Integer isSendCopy, Integer type){ | 
|---|
|  |  |  | List<Notices> noticesList = new ArrayList<>(); | 
|---|
|  |  |  | for (String qwId:qwIdList) { | 
|---|
|  |  |  | //存储抄送记录 | 
|---|
|  |  |  | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<WorkOrderDataVO> getWorkOrderData(OrderDataDTO orderDataDTO) throws Exception { | 
|---|
|  |  |  | public List<WorkOrderDataVO> getWorkOrderData(OrderDataDTO orderDataDTO)  { | 
|---|
|  |  |  | if (Objects.isNull(orderDataDTO.getQueryType())||Objects.isNull(orderDataDTO.getOrderType())) { | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String year = DateUtil.getNowYear(); | 
|---|
|  |  |  | Integer nowMonth = DateUtil.getNowMonth(); | 
|---|
|  |  |  | Integer quarter  = (nowMonth - 1) / 3 + 1; | 
|---|
|  |  |  | //        Integer nowMonth = DateUtil.getNowMonth(); | 
|---|
|  |  |  | Integer nowMonth = 12; | 
|---|
|  |  |  | //        Integer quarter  = (nowMonth - 1) / 3 + 1; | 
|---|
|  |  |  | Integer quarter  =4; | 
|---|
|  |  |  | List<WorkOrderDataVO> workOrderDataVOList = new ArrayList<>(); | 
|---|
|  |  |  | //查询今年所有的数据 | 
|---|
|  |  |  | List<Workorder> workorderList = workorderMapper.selectJoinList(Workorder.class,new MPJLambdaWrapper<Workorder>() | 
|---|
|  |  |  | 
|---|
|  |  |  | if(Constants.equalsInteger(orderDataDTO.getQueryType(),Constants.ZERO)){ | 
|---|
|  |  |  | for (int i = 1 ; i <= nowMonth; i++) { | 
|---|
|  |  |  | WorkOrderDataVO workOrderDataVO = new WorkOrderDataVO(); | 
|---|
|  |  |  | String monthDay = year + "-" + org.apache.commons.lang3.StringUtils.leftPad(nowMonth.toString(),2,"0"); | 
|---|
|  |  |  | String monthDay = year + "-" + org.apache.commons.lang3.StringUtils.leftPad(i+"",2,"0"); | 
|---|
|  |  |  | List<Workorder> dataList = workorderList.stream().filter(j->DateUtil.formatDate(j.getCreateDate(),"yyyy-MM").equals(monthDay)) | 
|---|
|  |  |  | .collect(Collectors.toList()); | 
|---|
|  |  |  | workOrderDataVO.setDateStr(monthDay); | 
|---|
|  |  |  | workOrderDataVO.setDateStr(i+"月"); | 
|---|
|  |  |  | workOrderDataVO.setGcsTotal(Constants.ZERO); | 
|---|
|  |  |  | workOrderDataVO.setWtsTotal(Constants.ZERO); | 
|---|
|  |  |  | workOrderDataVO.setSheTotal(Constants.ZERO); | 
|---|
|  |  |  | workOrderDataVO.setDcaNoTotal(Constants.ZERO); | 
|---|
|  |  |  | workOrderDataVO.setDcaYesTotal(Constants.ZERO); | 
|---|
|  |  |  | workOrderDataVO.setUnCloseTotal(Constants.ZERO); | 
|---|
|  |  |  | workOrderDataVO.setTotal(Constants.ZERO); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(dataList)){ | 
|---|
|  |  |  | workOrderDataVO.setTotal(dataList.size()); | 
|---|
|  |  |  | for(Workorder e :dataList){ | 
|---|
|  |  |  | if(Constants.equalsInteger(e.getType(),Constants.ONE)){ | 
|---|
|  |  |  | workOrderDataVO.setDcaYesTotal(workOrderDataVO.getDcaYesTotal()+Constants.formatIntegerNum(e.getDcaYesNum()));//DCA符合项 | 
|---|
|  |  |  | workOrderDataVO.setDcaNoTotal(workOrderDataVO.getDcaNoTotal()+Constants.formatIntegerNum(e.getDcaNoNum()));//DCA不符合项 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | workOrderDataVO.setGcsTotal(dataList.stream().filter(j->Constants.equalsInteger(j.getStatus(),Constants.WorkOrderStatus.close.getKey())).collect(Collectors.toList()).size()); | 
|---|
|  |  |  | workOrderDataVO.setSheTotal(dataList.stream().filter(j->Constants.equalsInteger(j.getStatus(),Constants.WorkOrderStatus.sheClose.getKey())).collect(Collectors.toList()).size()); | 
|---|
|  |  |  | workOrderDataVO.setWtsTotal(dataList.stream().filter(j->Constants.equalsInteger(j.getStatus(),Constants.WorkOrderStatus.wtsClose.getKey())).collect(Collectors.toList()).size()); | 
|---|
|  |  |  | 
|---|
|  |  |  | workOrderDataVO.setSheTotal(Constants.ZERO); | 
|---|
|  |  |  | workOrderDataVO.setUnCloseTotal(Constants.ZERO); | 
|---|
|  |  |  | workOrderDataVO.setTotal(Constants.ZERO); | 
|---|
|  |  |  | workOrderDataVO.setDcaNoTotal(Constants.ZERO); | 
|---|
|  |  |  | workOrderDataVO.setDcaYesTotal(Constants.ZERO); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(dataList)){ | 
|---|
|  |  |  | for(Workorder e :dataList){ | 
|---|
|  |  |  | if(Constants.equalsInteger(e.getType(),Constants.ONE)){ | 
|---|
|  |  |  | workOrderDataVO.setDcaYesTotal(workOrderDataVO.getDcaYesTotal()+Constants.formatIntegerNum(e.getDcaYesNum()));//DCA符合项 | 
|---|
|  |  |  | workOrderDataVO.setDcaNoTotal(workOrderDataVO.getDcaNoTotal()+Constants.formatIntegerNum(e.getDcaNoNum()));//DCA不符合项 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | workOrderDataVO.setTotal(dataList.size()); | 
|---|
|  |  |  | workOrderDataVO.setGcsTotal(dataList.stream().filter(j->Constants.equalsInteger(j.getStatus(),Constants.WorkOrderStatus.close.getKey())).collect(Collectors.toList()).size()); | 
|---|
|  |  |  | workOrderDataVO.setSheTotal(dataList.stream().filter(j->Constants.equalsInteger(j.getStatus(),Constants.WorkOrderStatus.sheClose.getKey())).collect(Collectors.toList()).size()); | 
|---|
|  |  |  | 
|---|
|  |  |  | workOrderDataVO.setUnCloseTotal(workOrderDataVO.getTotal() - workOrderDataVO.getSheTotal() - workOrderDataVO.getWtsTotal() - workOrderDataVO.getGcsTotal()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | workOrderDataVOList.add(workOrderDataVO); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return workOrderDataVOList; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * SHE / 跌绊滑报表 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public WorkorderIndexNumVO getIndexData(Workorder workorder) { | 
|---|
|  |  |  | WorkorderIndexNumVO model = new WorkorderIndexNumVO(); | 
|---|
|  |  |  | //查询今年所有的数据 | 
|---|
|  |  |  | List<Workorder> list = workorderMapper.selectJoinList(Workorder.class,new MPJLambdaWrapper<Workorder>() | 
|---|
|  |  |  | .select("type,count(id) as num") | 
|---|
|  |  |  | .eq(Workorder::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .groupBy(Workorder::getType  )); | 
|---|
|  |  |  | if(list !=null){ | 
|---|
|  |  |  | for(Workorder w : list){ | 
|---|
|  |  |  | if(Constants.equalsInteger(w.getType(),Constants.ZERO)){ | 
|---|
|  |  |  | //SHE | 
|---|
|  |  |  | model.setSheNum(Constants.formatLongNum(w.getNum())); | 
|---|
|  |  |  | }else  if(Constants.equalsInteger(w.getType(),Constants.ONE)){ | 
|---|
|  |  |  | //DCA提交数 | 
|---|
|  |  |  | model.setDcaNum(Constants.formatLongNum(w.getNum())); | 
|---|
|  |  |  | }else   if(Constants.equalsInteger(w.getType(),Constants.TWO)){ | 
|---|
|  |  |  | //DCA子工单 | 
|---|
|  |  |  | model.setDcaChildNum(Constants.formatLongNum(w.getNum())); | 
|---|
|  |  |  | }else   if(Constants.equalsInteger(w.getType(),Constants.THREE)){ | 
|---|
|  |  |  | //跌绊滑 | 
|---|
|  |  |  | model.setDbhNum(Constants.formatLongNum(w.getNum())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Workorder> todays = workorderMapper.selectJoinList(Workorder.class,new MPJLambdaWrapper<Workorder>() | 
|---|
|  |  |  | .select("type,count(id) as num") | 
|---|
|  |  |  | .eq(Workorder::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .apply("to_days(create_date)=to_days(now())") | 
|---|
|  |  |  | .groupBy(Workorder::getType  )); | 
|---|
|  |  |  | if(todays !=null){ | 
|---|
|  |  |  | for(Workorder w : todays){ | 
|---|
|  |  |  | if(Constants.equalsInteger(w.getType(),Constants.ZERO)){ | 
|---|
|  |  |  | //SHE | 
|---|
|  |  |  | model.setTodaySheNum(Constants.formatLongNum(w.getNum())); | 
|---|
|  |  |  | }else  if(Constants.equalsInteger(w.getType(),Constants.ONE)){ | 
|---|
|  |  |  | //DCA提交数 | 
|---|
|  |  |  | model.setTodayDcaNum(Constants.formatLongNum(w.getNum())); | 
|---|
|  |  |  | }else   if(Constants.equalsInteger(w.getType(),Constants.TWO)){ | 
|---|
|  |  |  | //DCA子工单 | 
|---|
|  |  |  | model.setTodayDcaChildNum(Constants.formatLongNum(w.getNum())); | 
|---|
|  |  |  | }else   if(Constants.equalsInteger(w.getType(),Constants.THREE)){ | 
|---|
|  |  |  | //跌绊滑 | 
|---|
|  |  |  | model.setTodayDbhNum(Constants.formatLongNum(w.getNum())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Workorder> yeslist = workorderMapper.selectJoinList(Workorder.class,new MPJLambdaWrapper<Workorder>() | 
|---|
|  |  |  | .select("type,count(id) as num") | 
|---|
|  |  |  | .eq(Workorder::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .in(Workorder::getStatus,Constants.THREE,Constants.FOUR,Constants.FIVE) | 
|---|
|  |  |  | .in(Workorder::getType,Constants.THREE,Constants.TWO) | 
|---|
|  |  |  | .groupBy(Workorder::getType  )); | 
|---|
|  |  |  | if(yeslist !=null){ | 
|---|
|  |  |  | for(Workorder w : yeslist){ | 
|---|
|  |  |  | if(Constants.equalsInteger(w.getType(),Constants.TWO)){ | 
|---|
|  |  |  | //DCA子工单已解决和未解决 | 
|---|
|  |  |  | model.setDcaChildYesNum(Constants.formatLongNum(w.getNum())); | 
|---|
|  |  |  | model.setDcaChildNoNum(Constants.formatLongNum(model.getDcaChildNum()) -model.getDcaChildYesNum()); | 
|---|
|  |  |  | }else   if(Constants.equalsInteger(w.getType(),Constants.THREE)){ | 
|---|
|  |  |  | //跌绊滑已解决和未解决 | 
|---|
|  |  |  | model.setDbhYesNum(Constants.formatLongNum(w.getNum())); | 
|---|
|  |  |  | model.setDbhNoNum(Constants.formatLongNum(model.getDbhNum()) -model.getDbhYesNum()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Workorder  dcaList = workorderMapper.selectJoinOne(Workorder.class,new MPJLambdaWrapper<Workorder>() | 
|---|
|  |  |  | .select("sum(dca_yes_num) as dcaYesNum,sum(dca_no_num) as dcaNoNum") | 
|---|
|  |  |  | .eq(Workorder::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Workorder::getType,Constants.ONE) ); | 
|---|
|  |  |  | if(dcaList !=null){ | 
|---|
|  |  |  | //DCA符合项和不符合项统计 | 
|---|
|  |  |  | model.setDcaYesNum((long)Constants.formatIntegerNum(dcaList.getDcaYesNum())); | 
|---|
|  |  |  | model.setDcaNoNum((long)Constants.formatIntegerNum(dcaList.getDcaNoNum())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return model; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|