| | |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.core.utils.qiyeweixin.QywxUtil; |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.dao.web.dto.CloseDTO; |
| | | import com.doumee.dao.web.dto.DCANoProblemDTO; |
| | | import com.doumee.dao.web.dto.PassOnDTO; |
| | | import com.doumee.dao.web.vo.WorkOrderDataVO; |
| | | import com.doumee.service.business.WorkorderService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import org.apache.catalina.Manager; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import javax.annotation.Resource; |
| | | import java.io.Serializable; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private ManagersMapper managersMapper; |
| | | |
| | | @Autowired |
| | | private CategoryMapper categoryMapper; |
| | | |
| | | @Resource(name="sessionRedisTemplate") |
| | | private RedisTemplate<Object, Serializable> redisTemplate; |
| | | |
| | | |
| | | @Override |
| | | public Integer create(Workorder workorder) { |
| | | this.isValidBaseParam(workorder); |
| | |
| | | workorder.setEditDate(new Date()); |
| | | workorder.setMemberId(workorder.getMemberId()); |
| | | workorder.setIsdeleted(Constants.ZERO); |
| | | workorder.setStatus(Constants.ZERO); |
| | | //跌绊滑事件上报 查询SHE负责人 |
| | | if(Constants.equalsInteger(workorder.getType(),Constants.THREE)){ |
| | | List<Managers> managersList = managersMapper.selectList(new QueryWrapper<Managers>().lambda().eq(Managers::getIsdeleted,Constants.ZERO) |
| | | .eq(Managers::getType,Constants.ZERO).orderByAsc(Managers::getSortnum) |
| | | ); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(managersList)){ |
| | | workorder.setQwnoticeMemberIds(managersList.stream().map(i->i.getMemberId().toString()).collect(Collectors.joining(","))); |
| | | } |
| | | } |
| | | workorder.setCode(this.getNextCode(workorder.getType())); |
| | | //处理人员类信息 |
| | | this.dealNoticeData(workorder); |
| | | //处理SHE事件状态 |
| | | workorder.setStatus(Constants.equalsInteger(workorder.getType(),Constants.ZERO)?Constants.WorkOrderStatus.close.getKey():Constants.WorkOrderStatus.waitConfirm.getKey()); |
| | | workorderMapper.insert(workorder); |
| | | //存储DCA 问题记录表 |
| | | this.saveProblemData(workorder); |
| | | //存储附件信息 |
| | | this.saveMutiFile(workorder); |
| | | //存储日志 |
| | | this.dealLogData(workorder); |
| | | //TODO 发送企微通知 |
| | | |
| | | return workorder.getId(); |
| | | } |
| | | |
| | | |
| | | public void dealLogData(Workorder workorder){ |
| | | //处理上报日志 DCA工单 日志存储至子业务 不存在于父级 |
| | | if(!Constants.equalsInteger(workorder.getType(),Constants.ONE)){ |
| | | String logTitle = "工单提报"; |
| | | if(!Constants.equalsInteger(workorder.getType(),Constants.ZERO)){ |
| | | logTitle = Constants.equalsInteger(workorder.getType(),Constants.ONE)?"跌绊滑风险提报":"DCA上报"; |
| | | } |
| | | this.saveLog(null,workorder,Constants.ZERO,workorder.getMemberId(),logTitle,null); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 存储附件信息 |
| | | * @param workorder |
| | | */ |
| | | public void saveMutiFile(Workorder workorder){ |
| | | List<Multifile> multifileList = workorder.getMultifileList(); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ |
| | | for (Multifile multifile:multifileList) { |
| | | multifile.setObjId(workorder.getId()); |
| | | multifile.setCreateDate(new Date()); |
| | | //TODO 后续整理处理 |
| | | if(Constants.equalsInteger(workorder.getType(),Constants.ZERO)){//SHE事件上报图片 |
| | | multifile.setObjType(Constants.ZERO); |
| | | }else if(Constants.equalsInteger(workorder.getType(),Constants.THREE)){//跌绊滑事件上报图片 |
| | | multifile.setObjType(Constants.ONE); |
| | | } |
| | | multifile.setObjType(Constants.multiFileType.upload); |
| | | } |
| | | multifileMapper.insert(multifileList); |
| | | } |
| | | //处理上报日志 |
| | | this.saveLog(null,workorder,Constants.ZERO,workorder.getMemberId()); |
| | | return workorder.getId(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 处理 DCA 提报 问题数据 |
| | | * @param workorder |
| | | */ |
| | | public void saveProblemData(Workorder workorder){ |
| | | if(Constants.equalsInteger(workorder.getType(),Constants.TWO)){ |
| | | List<DCANoProblemDTO> dcaNoProblemDTOList = workorder.getDcaNoProblemDTOList(); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(dcaNoProblemDTOList)){ |
| | | for (DCANoProblemDTO dcaNoProblemDTO:dcaNoProblemDTOList) { |
| | | Category problem = categoryMapper.selectById(dcaNoProblemDTO.getProblemId()); |
| | | Workorder dcaWorkOrder = new Workorder(); |
| | | dcaWorkOrder.setCreateDate(new Date()); |
| | | dcaWorkOrder.setEditDate(new Date()); |
| | | dcaWorkOrder.setMemberId(workorder.getMemberId()); |
| | | dcaWorkOrder.setTypeId(dcaNoProblemDTO.getProblemId()); |
| | | dcaWorkOrder.setType(Constants.TWO); |
| | | dcaWorkOrder.setStatus(Constants.ZERO); |
| | | dcaWorkOrder.setIsdeleted(Constants.ZERO); |
| | | dcaWorkOrder.setProblemTitle(problem.getName()); |
| | | dcaWorkOrder.setProblemId(problem.getId()); |
| | | dcaWorkOrder.setProblemInfo(problem.getRemark()); |
| | | dcaWorkOrder.setDcaRecordId(workorder.getId()); |
| | | dcaWorkOrder.setEventInfo(dcaNoProblemDTO.getEventInfo()); |
| | | workorderMapper.insert(dcaWorkOrder); |
| | | //存储日志 |
| | | this.dealLogData(dcaWorkOrder); |
| | | List<Multifile> multifileList = dcaNoProblemDTO.getMultifileList(); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ |
| | | for (Multifile multifile:multifileList) { |
| | | multifile.setObjId(dcaWorkOrder.getId()); |
| | | multifile.setCreateDate(new Date()); |
| | | multifile.setObjType(Constants.multiFileType.upload); |
| | | } |
| | | multifileMapper.insert(multifileList); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 处理通知类人员信息 |
| | | * @param workorder |
| | | */ |
| | | public void dealNoticeData(Workorder workorder){ |
| | | //SHE上报 提交类型为同事 处理同事信息 |
| | | if(Constants.equalsInteger(workorder.getType(),Constants.ZERO)&&Constants.equalsInteger(workorder.getMemberType(),Constants.ONE)){ |
| | | List<Member> memberList = memberMapper.selectList(new QueryWrapper<Member>().lambda().eq(Member::getIsdeleted,Constants.ZERO).in(Member::getQwId,workorder.getMemberQwids().split(","))); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(memberList)){ |
| | | workorder.setMemberNames(memberList.stream().map(i->i.getName()).collect(Collectors.joining(","))); |
| | | } |
| | | } |
| | | //跌绊滑事件上报 查询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) |
| | | .leftJoin(Member.class,Member::getId,Managers::getMemberId) |
| | | .eq(Managers::getIsdeleted,Constants.ZERO) |
| | | .eq(Managers::getType,Constants.ZERO).orderByAsc(Managers::getSortnum) |
| | | ); |
| | | 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(","))); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | * |
| | | * @param beforeJson |
| | | * @param afterWorkorder |
| | | * @param objType 操作类型 0任务上报 1任务确认 2任务分配物业主管 3任务关闭 4任务分配处理人 5任务催促 |
| | | * @param objType 操作类型 0任务上报 1任务分配物业主管 2任务分配处理人 3任务处理关闭 4任务催促 |
| | | * @param memberId |
| | | */ |
| | | public void saveLog(String beforeJson,Workorder afterWorkorder,Integer objType,Integer memberId){ |
| | | public Integer saveLog(String beforeJson,Workorder afterWorkorder,Integer objType,Integer memberId,String title,String content){ |
| | | WorkorderLog workorderLog = new WorkorderLog(); |
| | | workorderLog.setCreateDate(new Date()); |
| | | workorderLog.setEditDate(new Date()); |
| | |
| | | workorderLog.setParam1(memberId.toString()); |
| | | workorderLog.setObjId(afterWorkorder.getId().toString()); |
| | | workorderLog.setObjType(objType); |
| | | workorderLog.setTitle(title); |
| | | workorderLog.setContent(content); |
| | | workorderLogMapper.insert(workorderLog); |
| | | return workorderLog.getId(); |
| | | } |
| | | |
| | | |
| | |
| | | || Objects.isNull(workorder.getSubmitDate()) |
| | | || Objects.isNull(workorder.getHappenTime()) |
| | | || Objects.isNull(workorder.getType()) |
| | | || !( Constants.equalsInteger(workorder.getType(),Constants.ZERO) || Constants.equalsInteger(workorder.getType(),Constants.ONE) |
| | | || Constants.equalsInteger(workorder.getType(),Constants.TWO) || Constants.equalsInteger(workorder.getType(),Constants.THREE) |
| | | || Objects.isNull(workorder.getTypeId()) |
| | | || Objects.isNull(workorder.getLocaltionId()) |
| | | || !( Constants.equalsInteger(workorder.getType(),Constants.ZERO) || Constants.equalsInteger(workorder.getType(),Constants.ONE) ||Constants.equalsInteger(workorder.getType(),Constants.THREE) |
| | | )){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | //SHE 事件上报 |
| | | if(Constants.equalsInteger(workorder.getType(),Constants.ZERO)){ |
| | | if(Objects.isNull(workorder.getMemberType()) |
| | | || Objects.isNull(workorder.getLocaltionId()) |
| | | || Objects.isNull(workorder.getOutJiuyi()) |
| | | || (Constants.equalsInteger(workorder.getOutJiuyi(),Constants.ZERO) && Objects.isNull(workorder.getIsYiwushi())) |
| | | || (Constants.equalsInteger(workorder.getIsYiwushi(),Constants.ZERO) && Objects.isNull(workorder.getIsHurted())) |
| | | || Objects.isNull(workorder.getCategoryId()) |
| | | || Objects.isNull(workorder.getWorkRelated()) |
| | | || (Constants.equalsInteger(workorder.getMemberType(),Constants.TWO) && StringUtils.isEmpty(workorder.getMemberNames())) |
| | | || (Constants.equalsInteger(workorder.getMemberType(),Constants.ZERO) && StringUtils.isEmpty(workorder.getMemberQwids())) |
| | | || (Constants.equalsInteger(workorder.getMemberType(),Constants.ONE) && StringUtils.isEmpty(workorder.getMemberQwids())) |
| | | || org.apache.commons.lang3.StringUtils.isBlank(workorder.getEventInfo()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | |
| | | } |
| | | //跌绊滑 事件上报 |
| | | if(Constants.equalsInteger(workorder.getType(),Constants.THREE)){ |
| | | if(Objects.isNull(workorder.getTypeId()) |
| | | || Objects.isNull(workorder.getLocaltionId()) |
| | | || org.apache.commons.lang3.StringUtils.isBlank(workorder.getEventInfo()) |
| | | if(org.apache.commons.lang3.StringUtils.isBlank(workorder.getRiskInfo()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | } |
| | | //DCA 事件上报 |
| | | if(Constants.equalsInteger(workorder.getType(),Constants.ONE)){ |
| | | if(Objects.isNull(workorder.getDcaYesNum()) |
| | | || Objects.isNull(workorder.getDcaNoNum()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | } |
| | | |
| | | |
| | | //数据库数据校验 |
| | | Category typeCategory = categoryMapper.selectById(workorder.getTypeId()); |
| | | if(Objects.isNull(typeCategory)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | Category locationCategory = categoryMapper.selectById(workorder.getLocaltionId()); |
| | | if(Objects.isNull(locationCategory)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | workorder.setLocationName(locationCategory.getNamePath()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | .last(" limit 1 ") |
| | | ); |
| | | if(Objects.nonNull(workorder)){ |
| | | //如果是SHE事件上报 SHE涉及人员类型为同事信息 需要查询同事名称 |
| | | if(Constants.equalsInteger(workorder.getType(),Constants.ZERO)&&Constants.equalsInteger(workorder.getMemberType(),Constants.ONE)){ |
| | | List<Member> memberList = memberMapper.selectList(new QueryWrapper<Member>().lambda().eq(Member::getIsdeleted,Constants.ZERO).in(Member::getQwId, Arrays.asList(workorder.getMemberQwids().split(",")))); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(memberList)){ |
| | | workorder.setColleague(memberList.stream().map(i->i.getName()).collect(Collectors.joining(","))); |
| | | } |
| | | } |
| | | //查询附件信息 |
| | | List<Multifile> multifileList = multifileMapper.selectList(new QueryWrapper<Multifile>().lambda().eq(Multifile::getIsdeleted,Constants.ZERO) |
| | | .eq(Multifile::getObjId,workorder).orderByAsc(Multifile::getId)); |
| | |
| | | workorder.setMultifileList(multifileList); |
| | | } |
| | | } |
| | | //查询日志信息 |
| | | workorder.setLogList(this.getLogList(workorder.getId())); |
| | | return workorder; |
| | | } |
| | | |
| | | |
| | | public List<WorkorderLog> getLogList(Integer orderId){ |
| | | 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) |
| | | ); |
| | | 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(); |
| | | for (WorkorderLog workorderLog:logList) { |
| | | //查询附件信息 |
| | | List<Multifile> multifileList = multifileMapper.selectList(new QueryWrapper<Multifile>().lambda() |
| | | .eq(Multifile::getIsdeleted,Constants.ZERO) |
| | | .ne(Multifile::getObjType,Constants.multiFileType.upload) |
| | | .eq(Multifile::getObjId,workorderLog.getId()) |
| | | .orderByAsc(Multifile::getId)); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ |
| | | for (Multifile multifile:multifileList) { |
| | | multifile.setFileurlFull(path+multifile.getFileurl()); |
| | | } |
| | | workorderLog.setMultifileList(multifileList); |
| | | } |
| | | } |
| | | } |
| | | return logList; |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void deleteById(Integer id) { |
| | |
| | | return workorderMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | public String getNextCode(Integer type){ |
| | | String date = DateUtil.getFomartDate(new Date(),"yyyyMMddHHmmss"); |
| | | String key = "S"; |
| | | if(Constants.equalsInteger(type,Constants.ONE)){ |
| | | key = "D"; |
| | | }else if(Constants.equalsInteger(type,Constants.THREE)){ |
| | | key = "A"; |
| | | } |
| | | String code = redisTemplate.opsForValue().get(key+"_CODE").toString(); |
| | | if(StringUtils.isEmpty(code)){ |
| | | code = "01"; |
| | | } |
| | | redisTemplate.opsForValue().set(key+"_CODE",Integer.valueOf(code)+1); |
| | | return key + date + org.apache.commons.lang3.StringUtils.leftPad(code,2,"0"); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void initializationCode(){ |
| | | redisTemplate.opsForValue().set("A_CODE",1); |
| | | redisTemplate.opsForValue().set("S_CODE",1); |
| | | redisTemplate.opsForValue().set("D_CODE",1); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void closeWorkOrder(CloseDTO closeDTO){ |
| | | 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())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | Workorder workorder = workorderMapper.selectById(closeDTO.getWorkorderId()); |
| | | String beforeJson = JSONObject.toJSONString(workorder); |
| | | if(Objects.isNull(workorder)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到工单数据"); |
| | | } |
| | | if(Constants.equalsInteger(workorder.getType(),Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"SHE工单无法进行该操作"); |
| | | } |
| | | if(Constants.equalsInteger(workorder.getStatus(),Constants.WorkOrderStatus.sheClose.getKey())||Constants.equalsInteger(workorder.getStatus(),Constants.WorkOrderStatus.wtsClose.getKey())||Constants.equalsInteger(workorder.getStatus(),Constants.WorkOrderStatus.close.getKey())){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"工单状态已流转"); |
| | | } |
| | | //提交后的 待确认/待初审状态 如果去关闭 只有工单里绑定的SHE人员可以关闭 |
| | | if(Constants.equalsInteger(workorder.getStatus(),Constants.WorkOrderStatus.waitConfirm.getKey())){ |
| | | //判断SHE人员内是否有当前登录账号 |
| | | if(workorder.getQwnoticeMemberIds().indexOf(closeDTO.getMember().getQwId())<Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,当前工单非您的工单,无法进行处理"); |
| | | } |
| | | workorder.setStatus(Constants.WorkOrderStatus.sheClose.getKey()); |
| | | }else if(Constants.equalsInteger(workorder.getStatus(),Constants.WorkOrderStatus.waitAllocation.getKey())){ |
| | | //判断SHE人员内是否有当前登录账号 |
| | | if(workorder.getQwnoticeMemberIds().indexOf(closeDTO.getMember().getQwId())<Constants.ZERO && !workorder.getManagerId().equals(closeDTO.getMember().getQwId())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,当前工单非您的工单,无法进行处理"); |
| | | } |
| | | workorder.setStatus(Constants.WorkOrderStatus.wtsClose.getKey()); |
| | | }else if(Constants.equalsInteger(workorder.getStatus(),Constants.WorkOrderStatus.waitDeal.getKey())){ |
| | | //判断SHE人员内是否有当前登录账号 |
| | | if(workorder.getQwnoticeMemberIds().indexOf(closeDTO.getMember().getQwId())<Constants.ZERO && !workorder.getManagerId().equals(closeDTO.getMember().getQwId()) |
| | | && !workorder.getDealerId().equals(closeDTO.getMember().getQwId()) ){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,当前工单非您的工单,无法进行处理"); |
| | | } |
| | | workorder.setStatus(Constants.WorkOrderStatus.wtsClose.getKey()); |
| | | }else{ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"工单状态已流转"); |
| | | } |
| | | workorder.setEditDate(new Date()); |
| | | workorder.setDealTime(new Date()); |
| | | workorder.setDealInfo(closeDTO.getInfo()); |
| | | workorderMapper.updateById(workorder); |
| | | //处理上报日志 |
| | | Integer logId = this.saveLog(beforeJson,workorder,Constants.THREE,workorder.getMemberId(),"任务已处理",closeDTO.getInfo()); |
| | | List<Multifile> multifileList = workorder.getMultifileList(); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ |
| | | for (Multifile multifile:multifileList) { |
| | | multifile.setObjId(logId); |
| | | multifile.setCreateDate(new Date()); |
| | | multifile.setObjType(Constants.multiFileType.deal); |
| | | } |
| | | multifileMapper.insert(multifileList); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void passOn(PassOnDTO passOnDTO){ |
| | | if(Objects.isNull(passOnDTO) |
| | | || Objects.isNull(passOnDTO.getWorkorderId()) |
| | | || Objects.isNull(passOnDTO.getPassOnUserId()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | Member member = memberMapper.selectById(passOnDTO.getPassOnUserId()); |
| | | if(Objects.isNull(member)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到被转交人信息"); |
| | | } |
| | | Workorder workorder = workorderMapper.selectById(passOnDTO.getWorkorderId()); |
| | | String beforeJson = JSONObject.toJSONString(workorder); |
| | | if(Objects.isNull(workorder)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到工单数据"); |
| | | } |
| | | if(Constants.equalsInteger(workorder.getType(),Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"SHE工单无法进行该操作"); |
| | | } |
| | | if(Constants.equalsInteger(passOnDTO.getPassOnType(),Constants.ZERO)){ |
| | | if(!Constants.equalsInteger(workorder.getStatus(),Constants.WorkOrderStatus.waitConfirm.getKey())){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"工单状态已流转"); |
| | | } |
| | | workorder.setManagerId(member.getQwId()); |
| | | workorder.setStatus(Constants.WorkOrderStatus.waitAllocation.getKey()); |
| | | }else{ |
| | | if(!(Constants.equalsInteger(workorder.getStatus(),Constants.WorkOrderStatus.waitAllocation.getKey()) |
| | | || Constants.equalsInteger(workorder.getStatus(),Constants.WorkOrderStatus.waitDeal.getKey()))){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"工单状态已流转"); |
| | | } |
| | | workorder.setDealerId(member.getQwId()); |
| | | workorder.setStatus(Constants.WorkOrderStatus.waitDeal.getKey()); |
| | | } |
| | | workorder.setEditDate(new Date()); |
| | | workorder.setUrgeDate(DateUtil.afterHoursDate(new Date(),24)); |
| | | workorderMapper.updateById(workorder); |
| | | //处理上报日志 |
| | | 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(); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ |
| | | for (Multifile multifile:multifileList) { |
| | | multifile.setObjId(logId); |
| | | multifile.setCreateDate(new Date()); |
| | | multifile.setObjType(Constants.multiFileType.passOn); |
| | | } |
| | | multifileMapper.insert(multifileList); |
| | | } |
| | | //TODO 企业微信通知 |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public void urge(Integer workorderId,Member member){ |
| | | Workorder workorder = workorderMapper.selectById(workorderId); |
| | | workorder.setEditDate(new Date()); |
| | | workorder.setUrgeDate(DateUtil.afterHoursDate(new Date(),24)); |
| | | workorderMapper.updateById(workorder); |
| | | if(Objects.isNull(workorder)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到工单数据"); |
| | | } |
| | | Member urgeUser = new Member(); |
| | | //如果已分配 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())){ |
| | | 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()); |
| | | //TODO 发送企微通知 |
| | | |
| | | } |
| | | |
| | | @Override |
| | | 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() ") |
| | | ); |
| | | 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)); |
| | | workorderMapper.updateById(workorder); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | public void autoUrge(Workorder workorder){ |
| | | if(Objects.isNull(workorder)){ |
| | | return; |
| | | } |
| | | Member urgeUser = new Member(); |
| | | //如果已分配 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())){ |
| | | urgeUser = memberMapper.selectOne(new QueryWrapper<Member>().lambda().eq(Member::getIsdeleted,Constants.ZERO).eq(Member::getQwId,workorder.getDealerId()).last("limit 1 ")); |
| | | }else{ |
| | | return; |
| | | } |
| | | //TODO 发送企微通知 |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 数据报表 |
| | | * @param queryType 0=按照月份;1=按照季度;2=按照年份(暂不处理) |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<WorkOrderDataVO> getWorkOrderData(Integer queryType) throws Exception { |
| | | String year = DateUtil.getNowYear(); |
| | | Integer nowMonth = DateUtil.getNowMonth(); |
| | | Integer quarter = (nowMonth - 1) / 3 + 1; |
| | | List<WorkOrderDataVO> workOrderDataVOList = new ArrayList<>(); |
| | | //查询今年所有的数据 |
| | | List<Workorder> workorderList = workorderMapper.selectList(new QueryWrapper<Workorder>().lambda().like(Workorder::getCreateDate,year) |
| | | .eq(Workorder::getIsdeleted,Constants.ZERO)); |
| | | if(Constants.equalsInteger(queryType,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"); |
| | | List<Workorder> dataList = workorderList.stream().filter(j->DateUtil.formatDate(j.getCreateDate(),"yyyy-MM").equals(monthDay)) |
| | | .collect(Collectors.toList()); |
| | | workOrderDataVO.setDateStr(monthDay); |
| | | workOrderDataVO.setGcsTotal(Constants.ZERO); |
| | | workOrderDataVO.setWtsTotal(Constants.ZERO); |
| | | workOrderDataVO.setSheTotal(Constants.ZERO); |
| | | workOrderDataVO.setUnCloseTotal(Constants.ZERO); |
| | | workOrderDataVO.setTotal(Constants.ZERO); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(dataList)){ |
| | | 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.setWtsTotal(dataList.stream().filter(j->Constants.equalsInteger(j.getStatus(),Constants.WorkOrderStatus.wtsClose.getKey())).collect(Collectors.toList()).size()); |
| | | workOrderDataVO.setUnCloseTotal(workOrderDataVO.getTotal() - workOrderDataVO.getSheTotal() - workOrderDataVO.getWtsTotal() - workOrderDataVO.getGcsTotal()); |
| | | } |
| | | workOrderDataVOList.add(workOrderDataVO); |
| | | } |
| | | }else if(Constants.equalsInteger(queryType,Constants.ONE)){ |
| | | //按照季度查询 |
| | | for (int i = 1 ; i <= quarter; i++) { |
| | | List<Workorder> dataList = new ArrayList<>(); |
| | | if(Constants.equalsInteger(i,Constants.ONE)){ |
| | | dataList = workorderList.stream().filter(j->Integer.valueOf(DateUtil.formatDate(j.getCreateDate(),"MM"))<=3 ) |
| | | .collect(Collectors.toList()); |
| | | }else if(Constants.equalsInteger(i,Constants.TWO)){ |
| | | dataList = workorderList.stream().filter(j->Integer.valueOf(DateUtil.formatDate(j.getCreateDate(),"MM"))<=6 && Integer.valueOf(DateUtil.formatDate(j.getCreateDate(),"MM"))>=4 ) |
| | | .collect(Collectors.toList()); |
| | | }else if(Constants.equalsInteger(i,Constants.THREE)){ |
| | | dataList = workorderList.stream().filter(j->Integer.valueOf(DateUtil.formatDate(j.getCreateDate(),"MM"))<=9 && Integer.valueOf(DateUtil.formatDate(j.getCreateDate(),"MM"))>=7 ) |
| | | .collect(Collectors.toList()); |
| | | }else { |
| | | dataList = workorderList.stream().filter(j-> Integer.valueOf(DateUtil.formatDate(j.getCreateDate(),"MM"))>=10 ) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | WorkOrderDataVO workOrderDataVO = new WorkOrderDataVO(); |
| | | workOrderDataVO.setDateStr(i+"季度"); |
| | | workOrderDataVO.setGcsTotal(Constants.ZERO); |
| | | workOrderDataVO.setWtsTotal(Constants.ZERO); |
| | | workOrderDataVO.setSheTotal(Constants.ZERO); |
| | | workOrderDataVO.setUnCloseTotal(Constants.ZERO); |
| | | workOrderDataVO.setTotal(Constants.ZERO); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(dataList)){ |
| | | 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.setWtsTotal(dataList.stream().filter(j->Constants.equalsInteger(j.getStatus(),Constants.WorkOrderStatus.wtsClose.getKey())).collect(Collectors.toList()).size()); |
| | | workOrderDataVO.setUnCloseTotal(workOrderDataVO.getTotal() - workOrderDataVO.getSheTotal() - workOrderDataVO.getWtsTotal() - workOrderDataVO.getGcsTotal()); |
| | | } |
| | | workOrderDataVOList.add(workOrderDataVO); |
| | | |
| | | } |
| | | } |
| | | return workOrderDataVOList; |
| | | } |
| | | |
| | | |
| | | |
| | | |