|  |  | 
 |  |  | import com.doumee.core.model.PageWrap; | 
 |  |  | import com.doumee.core.utils.Constants; | 
 |  |  | import com.doumee.core.utils.Utils; | 
 |  |  | import com.doumee.dao.business.DispatchUnitMapper; | 
 |  |  | import com.doumee.dao.business.DuLogMapper; | 
 |  |  | import com.doumee.dao.business.DuSolutionMapper; | 
 |  |  | import com.doumee.dao.business.DuWorktypeMapper; | 
 |  |  | import com.doumee.dao.business.*; | 
 |  |  | import com.doumee.dao.business.dto.*; | 
 |  |  | import com.doumee.dao.business.join.DispatchUnitJoinMapper; | 
 |  |  | import com.doumee.dao.business.join.DuLogJoinMapper; | 
 |  |  | import com.doumee.dao.business.join.DuSolutionJoinMapper; | 
 |  |  | import com.doumee.dao.business.join.DuWorkTypeJoinMapper; | 
 |  |  | import com.doumee.dao.business.join.*; | 
 |  |  | import com.doumee.dao.business.model.*; | 
 |  |  | import com.doumee.dao.system.model.SystemUser; | 
 |  |  | import com.doumee.service.business.DispatchUnitService; | 
 |  |  | 
 |  |  |     private DuSolutionMapper duSolutionMapper; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private SolutionWorktypeJoinMapper solutionWorktypeJoinMapper; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private DuWorktypeMapper    duWorktypeMapper; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private SystemDictDataBiz systemDictDataBiz; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private NoticesMapper noticesMapper; | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     @Transactional(rollbackFor = {Exception.class,BusinessException.class}) | 
 |  |  |     public Integer checkWorktype(DispatchUnit param) { | 
 |  |  | 
 |  |  |         } | 
 |  |  |         LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
 |  |  |         DispatchUnit model = dispatchUnitMapper.selectById(param.getId()); | 
 |  |  |         if(Objects.isNull(model) || Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO) ||!Constants.equalsInteger(model.getDataType(),Constants.ZERO)){ | 
 |  |  |         if(Objects.isNull(model) || !Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO) ||!Constants.equalsInteger(model.getDataType(),Constants.ZERO)){ | 
 |  |  |             throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到派遣单位信息"); | 
 |  |  |         } | 
 |  |  |         if(!Constants.equalsInteger(model.getStatus(),Constants.ONE)){ | 
 |  |  |         if(!Constants.equalsInteger(model.getUnitStatus(),Constants.ONE)){ | 
 |  |  |             throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,该派遣单位尚未审核通过,不支持该操作!"); | 
 |  |  |         } | 
 |  |  |         if(Constants.equalsInteger(model.getWorktypeStatus(),Constants.ZERO)){ | 
 |  |  |         if(!Constants.equalsInteger(model.getWorktypeStatus(),Constants.ZERO)){ | 
 |  |  |             throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,该派遣单位工种已审核,请勿重复提交~"); | 
 |  |  |         } | 
 |  |  |         DispatchUnit update = new DispatchUnit(); | 
 |  |  | 
 |  |  |         dispatchUnitMapper.updateById(update); | 
 |  |  |         if(Constants.equalsInteger(param.getWorktypeStatus(),Constants.ONE)){ | 
 |  |  |             //审核通过,修改状态,产生历史版本 | 
 |  |  |             newVersionData(dispatchUnitMapper.selectById(param.getId()),update); | 
 |  |  |             newVersionData(model,update,false); | 
 |  |  |             //存储操作历史 | 
 |  |  |             this.saveDuLog(update,Constants.DispatchUnitLogType.WORK_TYPE_AUDIT_PASS,update.getCheckInfo()); | 
 |  |  |         }else{ | 
 |  |  |             //更新明细数据为审核失败 | 
 |  |  |             duSolutionMapper.update(null,new UpdateWrapper<DuSolution>().lambda() | 
 |  |  | 
 |  |  |                     .set(DuSolution::getCheckUserId,update.getCheckUserId()) | 
 |  |  |                     .set(DuSolution::getCheckInfo,update.getCheckInfo()) | 
 |  |  |                     .eq(DuSolution::getDispatchUnitId,update.getId())); | 
 |  |  |  | 
 |  |  |             duWorktypeMapper.update(null,new UpdateWrapper<DuWorktype>().lambda() | 
 |  |  |                     .set(DuWorktype::getStatus,Constants.TWO) | 
 |  |  |                     .set(DuWorktype::getCheckUserId,update.getCheckUserId()) | 
 |  |  |                     .set(DuWorktype::getCheckInfo,update.getCheckInfo()) | 
 |  |  |                     .set(DuWorktype::getCheckDate,new Date() ) | 
 |  |  |                     .eq(DuWorktype::getIsdeleted,Constants.ZERO) | 
 |  |  |                     .eq(DuWorktype::getStatus,Constants.ZERO) | 
 |  |  |                     .eq(DuWorktype::getDispatchUnitId,update.getId())); | 
 |  |  |             //存储操作历史 | 
 |  |  |             this.saveDuLog(update,Constants.DispatchUnitLogType.WORK_TYPE_AUDIT_UN_PASS,update.getCheckInfo()); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         //存储待办信息 | 
 |  |  |         Constants.NoticeObjectType noticeObjectType = Constants.NoticeObjectType.DISPATCH_UNIT; | 
 |  |  |         //删除其他待办 | 
 |  |  |         noticesMapper.delete(new QueryWrapper<Notices>().lambda().eq(Notices::getObjType,noticeObjectType.getKey()).eq(Notices::getObjId,model.getId())); | 
 |  |  |  | 
 |  |  |         return  1; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private void newVersionData(DispatchUnit model, DispatchUnit update) { | 
 |  |  |         dispatchUnitMapper.update(null,new UpdateWrapper<DispatchUnit>().lambda() | 
 |  |  |                 .set(DispatchUnit::getDataType,Constants.ZERO) | 
 |  |  |                 .eq(DispatchUnit::getIsdeleted,Constants.ZERO) | 
 |  |  |                 .eq(DispatchUnit::getBaseId,model.getId())); | 
 |  |  |     private void newVersionData(DispatchUnit model, DispatchUnit update,Boolean flag) { | 
 |  |  |         DispatchUnit newVersion = new DispatchUnit(); | 
 |  |  |         BeanUtils.copyProperties(model, newVersion); | 
 |  |  |         newVersion.setWorktypeStatus(Constants.ONE); | 
 |  |  |         newVersion.setCheckDate(update.getEditDate()); | 
 |  |  |         newVersion.setCheckUserId(update.getCheckUserId()); | 
 |  |  |         newVersion.setCheckInfo(update.getCheckInfo()); | 
 |  |  |         newVersion.setCreateDate(update.getCreateDate()); | 
 |  |  |         newVersion.setCreator(update.getEditor()); | 
 |  |  |         newVersion.setBaseId(model.getBaseId()); | 
 |  |  |         newVersion.setDataType(Constants.TWO); | 
 |  |  |         dispatchUnitMapper.insert(newVersion); | 
 |  |  |  | 
 |  |  |         if(flag){ | 
 |  |  |             dispatchUnitMapper.update(null,new UpdateWrapper<DispatchUnit>().lambda() | 
 |  |  |                     .set(DispatchUnit::getDataType,Constants.ZERO) | 
 |  |  |                     .eq(DispatchUnit::getIsdeleted,Constants.ZERO) | 
 |  |  |                     .eq(DispatchUnit::getBaseId,model.getId())); | 
 |  |  |             BeanUtils.copyProperties(model, newVersion); | 
 |  |  |             newVersion.setWorktypeStatus(Constants.ONE); | 
 |  |  |             newVersion.setCheckDate(update.getEditDate()); | 
 |  |  |             newVersion.setCheckUserId(update.getCheckUserId()); | 
 |  |  |             newVersion.setCheckInfo(update.getCheckInfo()); | 
 |  |  |             newVersion.setCreateDate(update.getCreateDate()); | 
 |  |  |             newVersion.setCreator(update.getEditor()); | 
 |  |  |             newVersion.setBaseId(model.getId()); | 
 |  |  |             newVersion.setDataType(Constants.TWO); | 
 |  |  |             dispatchUnitMapper.insert(newVersion); | 
 |  |  |         }else{ | 
 |  |  |             newVersion = dispatchUnitMapper.selectOne(new QueryWrapper<DispatchUnit>().lambda() | 
 |  |  |                     .eq(DispatchUnit::getIsdeleted,Constants.ZERO) | 
 |  |  |                     .eq(DispatchUnit::getDataType,Constants.TWO) | 
 |  |  |                     .eq(DispatchUnit::getBaseId,model.getId()) | 
 |  |  |                     .last(" limit 1")); | 
 |  |  |         } | 
 |  |  |         if(Objects.isNull(newVersion)){ | 
 |  |  |             throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到派遣单位最新版本"); | 
 |  |  |         } | 
 |  |  |         List<DuWorktype> newWorktypes = new ArrayList<>(); | 
 |  |  |         List<DuSolution> solutions = duSolutionMapper.selectList(new QueryWrapper<DuSolution>().lambda() | 
 |  |  |                 .eq(DuSolution::getIsdeleted,Constants.ZERO) | 
 |  |  | 
 |  |  |  | 
 |  |  |         duSolutionMapper.update(null,new UpdateWrapper<DuSolution>().lambda() | 
 |  |  |                         .set(DuSolution::getStatus,Constants.ONE) | 
 |  |  |                 .set(DuSolution::getCheckDate,update.getEditDate() ) | 
 |  |  |                 .set(DuSolution::getCheckUserId,update.getCheckUserId()) | 
 |  |  |                 .set(DuSolution::getCheckInfo,update.getCheckInfo()) | 
 |  |  |                 .eq(DuSolution::getIsdeleted,Constants.ZERO) | 
 |  |  |                 .eq(DuSolution::getStatus,Constants.ZERO) | 
 |  |  |                 .eq(DuSolution::getDispatchUnitId,model.getId()) | 
 |  |  |         ); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         if(solutions == null || solutions.size() ==0){ | 
 |  |  | 
 |  |  |  | 
 |  |  |             duWorktypeMapper.update(null,new UpdateWrapper<DuWorktype>().lambda() | 
 |  |  |                     .set(DuWorktype::getStatus,Constants.ONE) | 
 |  |  |                     .set(DuWorktype::getCheckDate,update.getEditDate()) | 
 |  |  |                     .set(DuWorktype::getCheckUserId,update.getCheckUserId()) | 
 |  |  |                     .set(DuWorktype::getCheckInfo,update.getCheckInfo()) | 
 |  |  |                     .eq(DuWorktype::getIsdeleted,Constants.ZERO) | 
 |  |  |                     .eq(DuWorktype::getStatus,Constants.ZERO) | 
 |  |  |                     .eq(DuWorktype::getDuSolutionId,s.getId())); | 
 |  |  | 
 |  |  |         update.setEditDate(new Date()); | 
 |  |  |         update.setId(model.getId()); | 
 |  |  |         update.setUnitStatus(param.getUnitStatus()); | 
 |  |  |         update.setWorktypeStatus(param.getWorktypeStatus()); | 
 |  |  |         update.setWorktypeStatus(param.getUnitStatus()); | 
 |  |  |         update.setCheckDate(update.getEditDate()); | 
 |  |  |         update.setCheckUserId(user.getId()); | 
 |  |  |         update.setCheckInfo(param.getCheckInfo()); | 
 |  |  | 
 |  |  |         DispatchUnit dispatchUnit = dispatchUnitMapper.selectById(param.getId()); | 
 |  |  |         if(Constants.equalsInteger(param.getUnitStatus(),Constants.ONE)){ | 
 |  |  |             //审核通过,修改状态,产生历史版本 | 
 |  |  |             newVersionData(dispatchUnit,update); | 
 |  |  |             newVersionData(dispatchUnit,update,true); | 
 |  |  |             //存储操作历史 | 
 |  |  |             this.saveDuLog(dispatchUnit,Constants.DispatchUnitLogType.AUDIT_PASS,null); | 
 |  |  |             this.saveDuLog(dispatchUnit,Constants.DispatchUnitLogType.AUDIT_PASS,update.getCheckInfo()); | 
 |  |  |         }else{ | 
 |  |  |             //更新明细数据为审核失败 | 
 |  |  |             duSolutionMapper.update(null,new UpdateWrapper<DuSolution>().lambda() | 
 |  |  |                     .set(DuSolution::getCheckDate,new Date() ) | 
 |  |  |                     .set(DuSolution::getStatus,Constants.TWO) | 
 |  |  |                     .set(DuSolution::getCheckDate,new Date() ) | 
 |  |  |                     .set(DuSolution::getCheckUserId,update.getCheckUserId()) | 
 |  |  |                     .set(DuSolution::getCheckInfo,update.getCheckInfo()) | 
 |  |  |                     .eq(DuSolution::getDispatchUnitId,update.getId())); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |             List<DuSolution> solutions = duSolutionMapper.selectList(new QueryWrapper<DuSolution>().lambda() | 
 |  |  |                     .eq(DuSolution::getIsdeleted,Constants.ZERO) | 
 |  |  |                     .eq(DuSolution::getDispatchUnitId,model.getId())); | 
 |  |  |  | 
 |  |  |             if(solutions == null || solutions.size() ==0){ | 
 |  |  |                 throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,该派遣单位未设置方案工种信息,审核通过失败!"); | 
 |  |  |             } | 
 |  |  |             for (DuSolution s : solutions){ | 
 |  |  |                 duWorktypeMapper.update(null,new UpdateWrapper<DuWorktype>().lambda() | 
 |  |  |                         .set(DuWorktype::getStatus,Constants.TWO) | 
 |  |  |                         .set(DuWorktype::getCheckUserId,update.getCheckUserId()) | 
 |  |  |                         .set(DuWorktype::getCheckInfo,update.getCheckInfo()) | 
 |  |  |                         .set(DuWorktype::getCheckDate,new Date() ) | 
 |  |  |                         .eq(DuWorktype::getIsdeleted,Constants.ZERO) | 
 |  |  |                         .eq(DuWorktype::getStatus,Constants.ZERO) | 
 |  |  |                         .eq(DuWorktype::getDuSolutionId,s.getId())); | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             duWorktypeMapper.update(null,new UpdateWrapper<DuWorktype>().lambda() | 
 |  |  |                     .set(DuWorktype::getStatus,Constants.TWO) | 
 |  |  |                     .set(DuWorktype::getCheckUserId,update.getCheckUserId()) | 
 |  |  |                     .set(DuWorktype::getCheckInfo,update.getCheckInfo()) | 
 |  |  |                     .set(DuWorktype::getCheckDate,new Date() ) | 
 |  |  |                     .eq(DuWorktype::getIsdeleted,Constants.ZERO) | 
 |  |  |                     .eq(DuWorktype::getStatus,Constants.ZERO) | 
 |  |  |                     .eq(DuWorktype::getDispatchUnitId,update.getId())); | 
 |  |  |             //存储操作历史 | 
 |  |  |             this.saveDuLog(dispatchUnit,Constants.DispatchUnitLogType.AUDIT_UN_PASS,update.getCheckInfo()); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         //存储待办信息 | 
 |  |  |         Constants.NoticeObjectType noticeObjectType = Constants.NoticeObjectType.DISPATCH_UNIT; | 
 |  |  |         //删除其他待办 | 
 |  |  |         noticesMapper.delete(new QueryWrapper<Notices>().lambda().eq(Notices::getObjType,noticeObjectType.getKey()).eq(Notices::getObjId,dispatchUnit.getId())); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         return  1; | 
 |  |  |     } | 
 |  |  |     @Override | 
 |  |  | 
 |  |  |     public Integer create(SaveDispatchUnitDTO saveDispatchUnitDTO) { | 
 |  |  |         if(Objects.isNull(saveDispatchUnitDTO) | 
 |  |  |             || StringUtils.isEmpty(saveDispatchUnitDTO.getName()) | 
 |  |  |             || StringUtils.isEmpty(saveDispatchUnitDTO.getCode()) | 
 |  |  |             || StringUtils.isEmpty(saveDispatchUnitDTO.getContent()) | 
 |  |  |             || CollectionUtils.isEmpty(saveDispatchUnitDTO.getSaveDuSolutionDTOList()) | 
 |  |  |         ){ | 
 |  |  |             throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
 |  |  | 
 |  |  |         )> Constants.ZERO){ | 
 |  |  |             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【派遣单位名称】已存在"); | 
 |  |  |         }; | 
 |  |  |         if(dispatchUnitMapper.selectCount(new QueryWrapper<DispatchUnit>().lambda() | 
 |  |  |                 .eq(DispatchUnit::getCompanyId,loginUserInfo.getCompanyId()) | 
 |  |  |                 .eq(DispatchUnit::getCode,saveDispatchUnitDTO.getCode()) | 
 |  |  |                 .eq(DispatchUnit::getIsdeleted,Constants.ZERO) | 
 |  |  |         )> Constants.ZERO){ | 
 |  |  |             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【派遣单位信用代码】已存在"); | 
 |  |  |         }; | 
 |  |  | //        if(dispatchUnitMapper.selectCount(new QueryWrapper<DispatchUnit>().lambda() | 
 |  |  | //                .eq(DispatchUnit::getCompanyId,loginUserInfo.getCompanyId()) | 
 |  |  | //                .eq(DispatchUnit::getCode,saveDispatchUnitDTO.getCode()) | 
 |  |  | //                .eq(DispatchUnit::getIsdeleted,Constants.ZERO) | 
 |  |  | //        )> Constants.ZERO){ | 
 |  |  | //            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【派遣单位信用代码】已存在"); | 
 |  |  | //        }; | 
 |  |  |         DispatchUnit dispatchUnit = new DispatchUnit(); | 
 |  |  |         dispatchUnit.setCreateDate(new Date()); | 
 |  |  |         dispatchUnit.setCreator(loginUserInfo.getId()); | 
 |  |  | 
 |  |  |                 duWorktype.setDuSolutionId(duSolution.getId()); | 
 |  |  |                 duWorktype.setStatus(Constants.ZERO); | 
 |  |  |                 duWorktype.setSortnum(j); | 
 |  |  |                 duWorktype.setDispatchUnitId(dispatchUnit.getId()); | 
 |  |  |                 duWorktype.setWorkTypeId(saveDuWorkTypeDTO.getWorkTypeId()); | 
 |  |  |                 duWorktype.setVideoUrl(saveDuWorkTypeDTO.getVideoUrl()); | 
 |  |  |                 duWorktype.setStatus2(Constants.ZERO); | 
 |  |  |                 duWorktypeMapper.insert(duWorktype); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         //存储待办信息 | 
 |  |  |         Constants.NoticeObjectType noticeObjectType = Constants.NoticeObjectType.DISPATCH_UNIT; | 
 |  |  |         //删除其他待办 | 
 |  |  |         noticesMapper.delete(new QueryWrapper<Notices>().lambda().eq(Notices::getObjType,noticeObjectType.getKey()).eq(Notices::getObjId,dispatchUnit.getId())); | 
 |  |  |         Notices notices = new Notices(noticeObjectType,Constants.ZERO,dispatchUnit.getId(),dispatchUnit.getName(), | 
 |  |  |                 dispatchUnit.getCompanyId(), Constants.NoticeType.ZERO); | 
 |  |  |         noticesMapper.insert(notices); | 
 |  |  |  | 
 |  |  |         return dispatchUnit.getId(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |         )> Constants.ZERO){ | 
 |  |  |             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【派遣单位名称】已存在"); | 
 |  |  |         }; | 
 |  |  |         if(dispatchUnitMapper.selectCount(new QueryWrapper<DispatchUnit>().lambda() | 
 |  |  |                 .ne(DispatchUnit::getId,saveDispatchUnitDTO.getId()) | 
 |  |  |                 .eq(DispatchUnit::getCompanyId,loginUserInfo.getCompanyId()) | 
 |  |  |                 .eq(DispatchUnit::getCode,saveDispatchUnitDTO.getCode()) | 
 |  |  |                 .eq(DispatchUnit::getIsdeleted,Constants.ZERO) | 
 |  |  |         )> Constants.ZERO){ | 
 |  |  |             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【派遣单位信用代码】已存在"); | 
 |  |  |         } | 
 |  |  |         dispatchUnit.setCode(saveDispatchUnitDTO.getCode()); | 
 |  |  |         dispatchUnit.setContent(saveDispatchUnitDTO.getContent()); | 
 |  |  |         dispatchUnit.setName(saveDispatchUnitDTO.getName()); | 
 |  |  | 
 |  |  |         //存储操作记录 | 
 |  |  |         this.saveDuLog(dispatchUnit,Constants.DispatchUnitLogType.EDIT_UNIT,null); | 
 |  |  |  | 
 |  |  | //        this.dealDuData(saveDispatchUnitDTO,loginUserInfo); | 
 |  |  |         //存储待办信息 | 
 |  |  |         Constants.NoticeObjectType noticeObjectType = Constants.NoticeObjectType.DISPATCH_UNIT; | 
 |  |  |         //删除其他待办 | 
 |  |  |         noticesMapper.delete(new QueryWrapper<Notices>().lambda().eq(Notices::getObjType,noticeObjectType.getKey()).eq(Notices::getObjId,dispatchUnit.getId())); | 
 |  |  |         Notices notices = new Notices(noticeObjectType,Constants.ZERO,dispatchUnit.getId(),dispatchUnit.getName(), | 
 |  |  |                 dispatchUnit.getCompanyId(), Constants.NoticeType.ZERO); | 
 |  |  |         noticesMapper.insert(notices); | 
 |  |  |  | 
 |  |  |         return dispatchUnit.getId(); | 
 |  |  |     } | 
 |  |  | 
 |  |  |         } | 
 |  |  |         LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
 |  |  |         DispatchUnit dispatchUnit = this.dispatchUnitMapper.selectById(saveDispatchUnitDTO.getId()); | 
 |  |  |         if(!dispatchUnit.getUnitStatus().equals(Constants.ONE)){ | 
 |  |  |             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"派遣单位未审批通过,无法进行该操作"); | 
 |  |  |         } | 
 |  |  |         dispatchUnit.setWorktypeStatus(Constants.ZERO); | 
 |  |  |         dispatchUnit.setEditDate(new Date()); | 
 |  |  |         dispatchUnit.setEditor(loginUserInfo.getId()); | 
 |  |  | 
 |  |  |         //存储操作历史 | 
 |  |  |         this.saveDuLog(dispatchUnit,Constants.DispatchUnitLogType.ADD_WORK_TYPE,null); | 
 |  |  |         this.dealDuData(saveDispatchUnitDTO,loginUserInfo); | 
 |  |  |  | 
 |  |  |         //存储待办信息 | 
 |  |  |         Constants.NoticeObjectType noticeObjectType = Constants.NoticeObjectType.DISPATCH_UNIT; | 
 |  |  |         //删除其他待办 | 
 |  |  |         noticesMapper.delete(new QueryWrapper<Notices>().lambda().eq(Notices::getObjType,noticeObjectType.getKey()).eq(Notices::getObjId,dispatchUnit.getId())); | 
 |  |  |         Notices notices = new Notices(noticeObjectType,Constants.ZERO,dispatchUnit.getId(),dispatchUnit.getName(), | 
 |  |  |                 dispatchUnit.getCompanyId(), Constants.NoticeType.ONE); | 
 |  |  |         noticesMapper.insert(notices); | 
 |  |  |  | 
 |  |  |         return dispatchUnit.getId(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |                 if(Objects.isNull(saveDuWorkTypeDTO.getWorkTypeId())){ | 
 |  |  |                     throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+saveDuSolutionDTO.getSolutionName()+"】该方案下"+saveDuWorkTypeDTO.getWorkTypeName()+"该工种信息异常"); | 
 |  |  |                 } | 
 |  |  |                 //验证方案与工种的关系 | 
 |  |  |                 if(solutionWorktypeJoinMapper.selectCount(new QueryWrapper<SolutionWorktype>().lambda().eq(SolutionWorktype::getSolutionId,saveDuSolutionDTO.getSolutionId()) | 
 |  |  |                         .eq(SolutionWorktype::getWorktypeId,saveDuWorkTypeDTO.getWorkTypeId()))<=0){ | 
 |  |  |                     throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+saveDuSolutionDTO.getSolutionName()+"】该方案下"+saveDuWorkTypeDTO.getWorkTypeName()+"该工种信息无绑定关系"); | 
 |  |  |                 }; | 
 |  |  |                 if(duWorktypeMapper.selectCount(new QueryWrapper<DuWorktype>() | 
 |  |  |                         .lambda().eq(DuWorktype::getDuSolutionId,duSolution.getId()) | 
 |  |  |                         .eq(DuWorktype::getIsdeleted,Constants.ZERO) | 
 |  |  | 
 |  |  |                 duWorktype.setDuSolutionId(duSolution.getId()); | 
 |  |  |                 duWorktype.setStatus(Constants.ZERO); | 
 |  |  |                 duWorktype.setSortnum(duWorkTypeNum + j); | 
 |  |  |                 duWorktype.setDispatchUnitId(saveDispatchUnitDTO.getId()); | 
 |  |  |                 duWorktype.setWorkTypeId(saveDuWorkTypeDTO.getWorkTypeId()); | 
 |  |  |                 duWorktype.setVideoUrl(saveDuWorkTypeDTO.getVideoUrl()); | 
 |  |  |                 duWorktype.setStatus2(Constants.ZERO); | 
 |  |  | 
 |  |  |         if(Objects.isNull(dispatchUnit)){ | 
 |  |  |             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未查询到派遣单位信息"); | 
 |  |  |         } | 
 |  |  |         //派遣单位审批 | 
 |  |  |         //派遣单位审核 | 
 |  |  |         if(dispatchUnitAuditDTO.getAuditType().equals(Constants.ZERO)){ | 
 |  |  |             if(dispatchUnit.getStatus().equals(Constants.ONE)){ | 
 |  |  |                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"派遣单位信息已审核"); | 
 |  |  | 
 |  |  |     @Override | 
 |  |  |     public PageData<DispatchUnit> findPage(PageWrap<DispatchUnit> pageWrap) { | 
 |  |  |         IPage<DispatchUnit> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); | 
 |  |  |         QueryWrapper<DispatchUnit> queryWrapper = new QueryWrapper<>(); | 
 |  |  |         if(pageWrap.getModel().getDataType() ==null){ | 
 |  |  |             pageWrap.getModel().setDataType(Constants.ZERO); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
 |  |  |         Utils.MP.blankToNull(pageWrap.getModel()); | 
 |  |  |         queryWrapper.lambda().eq(DispatchUnit::getIsdeleted,Constants.ZERO); | 
 |  |  |         MPJLambdaWrapper<DispatchUnit>  queryWrapper =    new MPJLambdaWrapper<DispatchUnit>(); | 
 |  |  |         queryWrapper.selectAll(DispatchUnit.class) | 
 |  |  |                 .selectAs(Company::getName,DispatchUnit::getCompanyName) | 
 |  |  |                 .leftJoin(Company.class,Company::getId,DispatchUnit::getCompanyId); | 
 |  |  |         queryWrapper.eq(DispatchUnit::getIsdeleted,Constants.ZERO); | 
 |  |  |         if(Constants.equalsInteger(user.getType(),Constants.ZERO)){ | 
 |  |  |             //只能看权限范围内 | 
 |  |  |             if(user.getCompanyIdList() == null || user.getCompanyIdList().size() == 0){ | 
 |  |  |                 queryWrapper. eq(Company::getId,-1);//设置无效访问 | 
 |  |  |             }else { | 
 |  |  |                 queryWrapper. in(Company::getId, user.getCompanyIdList()); | 
 |  |  |             } | 
 |  |  |         } else  { | 
 |  |  |             //企业用户只看自己的数据 | 
 |  |  |             pageWrap.getModel().setCompanyId(user.getCompanyId()); | 
 |  |  |         } | 
 |  |  |         if (pageWrap.getModel().getId() != null) { | 
 |  |  |             queryWrapper.lambda().eq(DispatchUnit::getId, pageWrap.getModel().getId()); | 
 |  |  |             queryWrapper.eq(DispatchUnit::getId, pageWrap.getModel().getId()); | 
 |  |  |         } | 
 |  |  |         if (pageWrap.getModel().getCreator() != null) { | 
 |  |  |             queryWrapper.lambda().eq(DispatchUnit::getCreator, pageWrap.getModel().getCreator()); | 
 |  |  |             queryWrapper.eq(DispatchUnit::getCreator, pageWrap.getModel().getCreator()); | 
 |  |  |         } | 
 |  |  |         if (pageWrap.getModel().getCreateDate() != null) { | 
 |  |  |             queryWrapper.lambda().ge(DispatchUnit::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate())); | 
 |  |  |             queryWrapper.lambda().le(DispatchUnit::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate())); | 
 |  |  |             queryWrapper.ge(DispatchUnit::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate())); | 
 |  |  |             queryWrapper.le(DispatchUnit::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate())); | 
 |  |  |         } | 
 |  |  |         if (pageWrap.getModel().getEditor() != null) { | 
 |  |  |             queryWrapper.lambda().eq(DispatchUnit::getEditor, pageWrap.getModel().getEditor()); | 
 |  |  |             queryWrapper.eq(DispatchUnit::getEditor, pageWrap.getModel().getEditor()); | 
 |  |  |         } | 
 |  |  |         if (pageWrap.getModel().getEditDate() != null) { | 
 |  |  |             queryWrapper.lambda().ge(DispatchUnit::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate())); | 
 |  |  |             queryWrapper.lambda().le(DispatchUnit::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate())); | 
 |  |  |             queryWrapper.ge(DispatchUnit::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate())); | 
 |  |  |             queryWrapper.le(DispatchUnit::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate())); | 
 |  |  |         } | 
 |  |  |         if (pageWrap.getModel().getIsdeleted() != null) { | 
 |  |  |             queryWrapper.lambda().eq(DispatchUnit::getIsdeleted, pageWrap.getModel().getIsdeleted()); | 
 |  |  |             queryWrapper.eq(DispatchUnit::getIsdeleted, pageWrap.getModel().getIsdeleted()); | 
 |  |  |         } | 
 |  |  |         if (pageWrap.getModel().getName() != null) { | 
 |  |  |             queryWrapper.lambda().eq(DispatchUnit::getName, pageWrap.getModel().getName()); | 
 |  |  |             queryWrapper.like(DispatchUnit::getName, pageWrap.getModel().getName()); | 
 |  |  |         } | 
 |  |  |         if (pageWrap.getModel().getRemark() != null) { | 
 |  |  |             queryWrapper.lambda().eq(DispatchUnit::getRemark, pageWrap.getModel().getRemark()); | 
 |  |  |             queryWrapper.eq(DispatchUnit::getRemark, pageWrap.getModel().getRemark()); | 
 |  |  |         } | 
 |  |  |         if (pageWrap.getModel().getStatus() != null) { | 
 |  |  |             queryWrapper.lambda().eq(DispatchUnit::getStatus, pageWrap.getModel().getStatus()); | 
 |  |  |             queryWrapper.eq(DispatchUnit::getStatus, pageWrap.getModel().getStatus()); | 
 |  |  |         } | 
 |  |  |         if (pageWrap.getModel().getUnitStatus() != null) { | 
 |  |  |             queryWrapper.lambda().eq(DispatchUnit::getUnitStatus, pageWrap.getModel().getUnitStatus()); | 
 |  |  |             queryWrapper.eq(DispatchUnit::getUnitStatus, pageWrap.getModel().getUnitStatus()); | 
 |  |  |         } | 
 |  |  |         if (pageWrap.getModel().getWorktypeStatus() != null) { | 
 |  |  |             queryWrapper.lambda().eq(DispatchUnit::getWorktypeStatus, pageWrap.getModel().getWorktypeStatus()); | 
 |  |  |             queryWrapper.eq(DispatchUnit::getWorktypeStatus, pageWrap.getModel().getWorktypeStatus()); | 
 |  |  |         } | 
 |  |  |         if (pageWrap.getModel().getSortnum() != null) { | 
 |  |  |             queryWrapper.lambda().eq(DispatchUnit::getSortnum, pageWrap.getModel().getSortnum()); | 
 |  |  |             queryWrapper.eq(DispatchUnit::getSortnum, pageWrap.getModel().getSortnum()); | 
 |  |  |         } | 
 |  |  |         if (pageWrap.getModel().getCompanyId() != null) { | 
 |  |  |             queryWrapper.lambda().eq(DispatchUnit::getCompanyId, pageWrap.getModel().getCompanyId()); | 
 |  |  |             queryWrapper.eq(DispatchUnit::getCompanyId, pageWrap.getModel().getCompanyId()); | 
 |  |  |         } | 
 |  |  |         if (pageWrap.getModel().getPhone() != null) { | 
 |  |  |             queryWrapper.lambda().eq(DispatchUnit::getPhone, pageWrap.getModel().getPhone()); | 
 |  |  |             queryWrapper.eq(DispatchUnit::getPhone, pageWrap.getModel().getPhone()); | 
 |  |  |         } | 
 |  |  |         if (pageWrap.getModel().getLinkname() != null) { | 
 |  |  |             queryWrapper.lambda().eq(DispatchUnit::getLinkname, pageWrap.getModel().getLinkname()); | 
 |  |  |             queryWrapper.eq(DispatchUnit::getLinkname, pageWrap.getModel().getLinkname()); | 
 |  |  |         } | 
 |  |  |         if (pageWrap.getModel().getCheckDate() != null) { | 
 |  |  |             queryWrapper.lambda().ge(DispatchUnit::getCheckDate, Utils.Date.getStart(pageWrap.getModel().getCheckDate())); | 
 |  |  |             queryWrapper.lambda().le(DispatchUnit::getCheckDate, Utils.Date.getEnd(pageWrap.getModel().getCheckDate())); | 
 |  |  |             queryWrapper.ge(DispatchUnit::getCheckDate, Utils.Date.getStart(pageWrap.getModel().getCheckDate())); | 
 |  |  |             queryWrapper.le(DispatchUnit::getCheckDate, Utils.Date.getEnd(pageWrap.getModel().getCheckDate())); | 
 |  |  |         } | 
 |  |  |         if (pageWrap.getModel().getCheckInfo() != null) { | 
 |  |  |             queryWrapper.lambda().eq(DispatchUnit::getCheckInfo, pageWrap.getModel().getCheckInfo()); | 
 |  |  |             queryWrapper.eq(DispatchUnit::getCheckInfo, pageWrap.getModel().getCheckInfo()); | 
 |  |  |         } | 
 |  |  |         if (pageWrap.getModel().getCheckUserId() != null) { | 
 |  |  |             queryWrapper.lambda().eq(DispatchUnit::getCheckUserId, pageWrap.getModel().getCheckUserId()); | 
 |  |  |             queryWrapper.eq(DispatchUnit::getCheckUserId, pageWrap.getModel().getCheckUserId()); | 
 |  |  |         } | 
 |  |  |         if (pageWrap.getModel().getVersion() != null) { | 
 |  |  |             queryWrapper.lambda().eq(DispatchUnit::getVersion, pageWrap.getModel().getVersion()); | 
 |  |  |             queryWrapper.eq(DispatchUnit::getVersion, pageWrap.getModel().getVersion()); | 
 |  |  |         } | 
 |  |  |         if (pageWrap.getModel().getDataType() != null) { | 
 |  |  |             queryWrapper.lambda().eq(DispatchUnit::getDataType, pageWrap.getModel().getDataType()); | 
 |  |  |             queryWrapper.eq(DispatchUnit::getDataType, pageWrap.getModel().getDataType()); | 
 |  |  |         } | 
 |  |  |         if (pageWrap.getModel().getBaseId() != null) { | 
 |  |  |             queryWrapper.lambda().eq(DispatchUnit::getBaseId, pageWrap.getModel().getBaseId()); | 
 |  |  |             queryWrapper.eq(DispatchUnit::getBaseId, pageWrap.getModel().getBaseId()); | 
 |  |  |         } | 
 |  |  |         for(PageWrap.SortData sortData: pageWrap.getSorts()) { | 
 |  |  |             if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { | 
 |  |  |                 queryWrapper.orderByDesc(sortData.getProperty()); | 
 |  |  |             } else { | 
 |  |  |                 queryWrapper.orderByAsc(sortData.getProperty()); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         PageData<DispatchUnit> dispatchUnitPageData = PageData.from(dispatchUnitMapper.selectPage(page, queryWrapper)); | 
 |  |  |         return dispatchUnitPageData; | 
 |  |  |         queryWrapper.orderByAsc(DispatchUnit::getUnitStatus); | 
 |  |  |         queryWrapper.orderByAsc(DispatchUnit::getWorktypeStatus); | 
 |  |  |         queryWrapper.orderByDesc(DispatchUnit::getCreateDate); | 
 |  |  | //        for(PageWrap.SortData sortData: pageWrap.getSorts()) { | 
 |  |  | //            if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { | 
 |  |  | //                queryWrapper.orderByDesc(sortData.getProperty()); | 
 |  |  | //            } else { | 
 |  |  | //                queryWrapper.orderByAsc(sortData.getProperty()); | 
 |  |  | //            } | 
 |  |  | //        } | 
 |  |  |         PageData<DispatchUnit> pageData = PageData.from(dispatchUnitJoinMapper.selectJoinPage(page,DispatchUnit.class, queryWrapper)); | 
 |  |  |         return pageData; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public DispatchUnit detailById(Integer id) { | 
 |  |  |         DispatchUnit dispatchUnit = dispatchUnitMapper.selectById(id); | 
 |  |  |         DispatchUnit dispatchUnit = dispatchUnitJoinMapper.selectJoinOne(DispatchUnit.class, | 
 |  |  |                 new MPJLambdaWrapper<DispatchUnit>() | 
 |  |  |                         .selectAll(DispatchUnit.class) | 
 |  |  |                         .selectAs(Company::getName,DispatchUnit::getCompanyName) | 
 |  |  |                         .leftJoin(Company.class,Company::getId,DispatchUnit::getCompanyId) | 
 |  |  |                         .eq(DispatchUnit::getId,id) ); | 
 |  |  |         //方案配置表 | 
 |  |  |         List<DuSolution> duSolutionList = duSolutionJoinMapper.selectJoinList(DuSolution.class, | 
 |  |  |                 new MPJLambdaWrapper<DuSolution>() | 
 |  |  | 
 |  |  |         List<DuLog> duLogList = duLogJoinMapper.selectJoinList(DuLog.class, | 
 |  |  |                 new MPJLambdaWrapper<DuLog>() | 
 |  |  |                         .selectAll(DuLog.class) | 
 |  |  |                         .selectAs(SystemUser::getType,DuLog::getCreatorType) | 
 |  |  |                         .selectAs(SystemUser::getRealname,DuLog::getCreatorName) | 
 |  |  |                         .selectAs(Company::getName,DuLog::getCompanyName) | 
 |  |  |                         .leftJoin(SystemUser.class,SystemUser::getId,DuLog::getCreator) | 
 |  |  | 
 |  |  |     @Override | 
 |  |  |     public List<DispatchUnit> findByDTO(DispatchUnitQueryDTO dispatchUnitQueryDTO) { | 
 |  |  |         LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
 |  |  | //        List<DispatchUnit> dispatchUnitList = dispatchUnitMapper.selectList(new QueryWrapper<DispatchUnit>().lambda() | 
 |  |  | //                .eq(DispatchUnit::getIsdeleted,Constants.ZERO) | 
 |  |  | //                .eq(loginUserInfo.getType().equals(Constants.ONE),DispatchUnit::getCompanyId,loginUserInfo.getCompanyId()) | 
 |  |  | //                .eq(DispatchUnit::getStatus,Constants.ZERO) | 
 |  |  | //                .eq(DispatchUnit::getDataType,dispatchUnitQueryDTO.getDataType()) | 
 |  |  | //                .apply(!Objects.isNull(dispatchUnitQueryDTO.getSolutionId()), " id in ( select d.dispatch_unit_id from du_solution d where d.solution_id = "+dispatchUnitQueryDTO.getSolutionId()+"  ) " ) | 
 |  |  | //                .exists(!Objects.isNull(dispatchUnitQueryDTO.getApplyId()), | 
 |  |  | //                        " select 1 from apply_detail ad where ad.isdeleted = 0 and ad.apply_id = "+dispatchUnitQueryDTO.getApplyId()+" " + | 
 |  |  | //                                " ad.du_id = t.id ") | 
 |  |  | //                .orderByAsc(DispatchUnit::getSortnum) | 
 |  |  | //        ); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         List<DispatchUnit> dispatchUnitList  = dispatchUnitJoinMapper.selectJoinList(DispatchUnit.class, | 
 |  |  |                 new MPJLambdaWrapper<DispatchUnit>().selectAll(DispatchUnit.class) | 
 |  |  |                         .selectAs(DuSolution::getId,DispatchUnit::getDuSolutionId) | 
 |  |  |                         .leftJoin(DuSolution.class,DuSolution::getDispatchUnitId,DispatchUnit::getId) | 
 |  |  |                         .eq(DispatchUnit::getIsdeleted,Constants.ZERO) | 
 |  |  |                         .eq(loginUserInfo.getType().equals(Constants.ONE),DispatchUnit::getCompanyId,loginUserInfo.getCompanyId()) | 
 |  |  |                         .eq(DispatchUnit::getStatus,Constants.ZERO) | 
 |  |  |                         .eq(DispatchUnit::getDataType,dispatchUnitQueryDTO.getDataType()) | 
 |  |  |                         .eq(!Objects.isNull(dispatchUnitQueryDTO.getSolutionId()),DuSolution::getSolutionId,dispatchUnitQueryDTO.getSolutionId()) | 
 |  |  |                         .select("(select b.id from du_solution b where b.isdeleted=0 and b.dispatch_unit_id=t.id and b.solution_id="+dispatchUnitQueryDTO.getSolutionId()+" limit 1) as du_solution_id" ) | 
 |  |  |                         .eq(loginUserInfo.getType().equals(Constants.ONE),DispatchUnit::getCompanyId,loginUserInfo.getCompanyId()) | 
 |  |  |                         .eq(Objects.isNull(dispatchUnitQueryDTO.getDataType()),DispatchUnit::getDataType,Constants.TWO) | 
 |  |  |                         .eq(!Objects.isNull(dispatchUnitQueryDTO.getDataType()),DispatchUnit::getDataType,dispatchUnitQueryDTO.getDataType()) | 
 |  |  |                         .exists(!Objects.isNull(dispatchUnitQueryDTO.getSolutionId()), | 
 |  |  |                                 "select b.id from du_solution b where b.isdeleted=0 and b.dispatch_unit_id=t.id and b.status = 1 and  b.solution_id="+dispatchUnitQueryDTO.getSolutionId() ) | 
 |  |  |                         .exists(!Objects.isNull(dispatchUnitQueryDTO.getApplyId()), | 
 |  |  |                                 " select 1 from apply_detail ad where ad.isdeleted = 0 and ad.apply_id = "+dispatchUnitQueryDTO.getApplyId()+" " + | 
 |  |  |                                         " ad.du_id = t.id ") | 
 |  |  |                                         " and ad.du_id = t.id ") | 
 |  |  |         ); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         return dispatchUnitList; | 
 |  |  |     } |