| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.model.PageData; |
| | | 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.model.DispatchUnit; |
| | | import com.doumee.dao.business.DuLogMapper; |
| | | import com.doumee.dao.business.DuSolutionMapper; |
| | | import com.doumee.dao.business.DuWorktypeMapper; |
| | | import com.doumee.dao.business.dto.*; |
| | | 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.model.*; |
| | | import com.doumee.service.business.DispatchUnitService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | 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.github.xiaoymin.knife4j.core.util.CollectionUtils; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * 派遣单位信息表Service实现 |
| | | * @author 江蹄蹄 |
| | | * @date 2024/01/15 15:07 |
| | | * @date 2024/01/16 10:03 |
| | | */ |
| | | @Service |
| | | public class DispatchUnitServiceImpl implements DispatchUnitService { |
| | |
| | | @Autowired |
| | | private DispatchUnitMapper dispatchUnitMapper; |
| | | |
| | | @Autowired |
| | | private DuSolutionMapper duSolutionMapper; |
| | | |
| | | @Autowired |
| | | private DuWorktypeMapper duWorktypeMapper; |
| | | |
| | | @Autowired |
| | | private DuLogMapper duLogMapper; |
| | | |
| | | @Autowired |
| | | private DuLogJoinMapper duLogJoinMapper; |
| | | |
| | | @Autowired |
| | | private DuSolutionJoinMapper duSolutionJoinMapper; |
| | | |
| | | @Autowired |
| | | private DuWorkTypeJoinMapper duWorkTypeJoinMapper; |
| | | |
| | | |
| | | @Override |
| | | public Integer create(DispatchUnit dispatchUnit) { |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | 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); |
| | | } |
| | | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(dispatchUnitMapper.selectCount(new QueryWrapper<DispatchUnit>().lambda() |
| | | .eq(DispatchUnit::getCompanyId,loginUserInfo.getCompanyId()) |
| | | .eq(DispatchUnit::getName,saveDispatchUnitDTO.getName()) |
| | | .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()); |
| | | dispatchUnit.setCompanyId(loginUserInfo.getCompanyId()); |
| | | dispatchUnit.setIsdeleted(Constants.ZERO); |
| | | dispatchUnit.setName(saveDispatchUnitDTO.getName()); |
| | | dispatchUnit.setCode(saveDispatchUnitDTO.getCode()); |
| | | dispatchUnit.setContent(saveDispatchUnitDTO.getContent()); |
| | | dispatchUnit.setStatus(Constants.ZERO); |
| | | dispatchUnit.setVersion(UUID.randomUUID().toString()); |
| | | dispatchUnit.setUnitStatus(Constants.ZERO); |
| | | dispatchUnit.setWorktypeStatus(Constants.ZERO); |
| | | dispatchUnit.setDataType(Constants.ZERO); |
| | | dispatchUnitMapper.insert(dispatchUnit); |
| | | |
| | | //存储操作历史 |
| | | this.saveDuLog(dispatchUnit,Constants.DispatchUnitLogType.UPLOAD,null); |
| | | |
| | | List<SaveDuSolutionDTO> saveDuSolutionDTOList = saveDispatchUnitDTO.getSaveDuSolutionDTOList(); |
| | | for (int i = 0; i < saveDuSolutionDTOList.size(); i++) { |
| | | SaveDuSolutionDTO saveDuSolutionDTO = saveDuSolutionDTOList.get(i); |
| | | DuSolution duSolution = new DuSolution(); |
| | | duSolution.setCreateDate(new Date()); |
| | | duSolution.setCreator(loginUserInfo.getId()); |
| | | duSolution.setIsdeleted(Constants.ZERO); |
| | | duSolution.setDispatchUnitId(dispatchUnit.getId()); |
| | | duSolution.setSortnum(i); |
| | | duSolution.setSolutionId(saveDuSolutionDTO.getSolutionId()); |
| | | duSolutionMapper.insert(duSolution); |
| | | |
| | | List<SaveDuWorkTypeDTO> saveDuWorkTypeDTOList = saveDuSolutionDTO.getSaveDuWorkTypeDTOList(); |
| | | if(!CollectionUtils.isNotEmpty(saveDuSolutionDTOList)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+saveDuSolutionDTO.getSolutionName()+"】该方案下未选择工种!"); |
| | | } |
| | | for (int j = 0; j < saveDuWorkTypeDTOList.size(); j++) { |
| | | SaveDuWorkTypeDTO saveDuWorkTypeDTO = saveDuWorkTypeDTOList.get(j); |
| | | DuWorktype duWorktype = new DuWorktype(); |
| | | duWorktype.setCreateDate(new Date()); |
| | | duWorktype.setCreator(loginUserInfo.getId()); |
| | | duWorktype.setIsdeleted(Constants.ZERO); |
| | | duWorktype.setDuSolutionId(duSolution.getId()); |
| | | duWorktype.setSortnum(j); |
| | | duWorktype.setWorkTypeId(saveDuWorkTypeDTO.getWorkTypeId()); |
| | | duWorktype.setVideoUrl(saveDuWorkTypeDTO.getVideoUrl()); |
| | | duWorktype.setStatus2(Constants.ZERO); |
| | | duWorktypeMapper.insert(duWorktype); |
| | | } |
| | | } |
| | | return dispatchUnit.getId(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | public Integer editDispatchUnit(SaveDispatchUnitDTO saveDispatchUnitDTO) { |
| | | if(Objects.isNull(saveDispatchUnitDTO) |
| | | ||Objects.isNull(saveDispatchUnitDTO.getId()) |
| | | || CollectionUtils.isEmpty(saveDispatchUnitDTO.getSaveDuSolutionDTOList()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | DispatchUnit dispatchUnit = this.dispatchUnitMapper.selectById(saveDispatchUnitDTO.getId()); |
| | | if(Objects.isNull(dispatchUnit)){ |
| | | 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::getName,saveDispatchUnitDTO.getName()) |
| | | .eq(DispatchUnit::getIsdeleted,Constants.ZERO) |
| | | )> 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()); |
| | | dispatchUnit.setUnitStatus(Constants.ZERO); |
| | | dispatchUnit.setWorktypeStatus(Constants.ZERO); |
| | | dispatchUnit.setEditDate(new Date()); |
| | | dispatchUnit.setEditor(loginUserInfo.getId()); |
| | | dispatchUnitMapper.updateById(dispatchUnit); |
| | | |
| | | //存储操作记录 |
| | | this.saveDuLog(dispatchUnit,Constants.DispatchUnitLogType.EDIT_UNIT,null); |
| | | |
| | | this.dealDuData(saveDispatchUnitDTO,loginUserInfo); |
| | | |
| | | return dispatchUnit.getId(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加方案信息 |
| | | * @param saveDispatchUnitDTO |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | public Integer createSolution(SaveDispatchUnitDTO saveDispatchUnitDTO) { |
| | | if(Objects.isNull(saveDispatchUnitDTO) |
| | | ||Objects.isNull(saveDispatchUnitDTO.getId()) |
| | | || CollectionUtils.isEmpty(saveDispatchUnitDTO.getSaveDuSolutionDTOList()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | DispatchUnit dispatchUnit = this.dispatchUnitMapper.selectById(saveDispatchUnitDTO.getId()); |
| | | dispatchUnit.setWorktypeStatus(Constants.ZERO); |
| | | dispatchUnit.setEditDate(new Date()); |
| | | dispatchUnit.setEditor(loginUserInfo.getId()); |
| | | dispatchUnitMapper.updateById(dispatchUnit); |
| | | |
| | | if(Objects.isNull(dispatchUnit)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未查询到派遣单位信息"); |
| | | } |
| | | //存储操作历史 |
| | | this.saveDuLog(dispatchUnit,Constants.DispatchUnitLogType.ADD_WORK_TYPE,null); |
| | | this.dealDuData(saveDispatchUnitDTO,loginUserInfo); |
| | | return dispatchUnit.getId(); |
| | | } |
| | | |
| | | |
| | | public void dealDuData(SaveDispatchUnitDTO saveDispatchUnitDTO,LoginUserInfo loginUserInfo){ |
| | | List<SaveDuSolutionDTO> saveDuSolutionDTOList = saveDispatchUnitDTO.getSaveDuSolutionDTOList(); |
| | | for (int i = 0; i < saveDuSolutionDTOList.size(); i++) { |
| | | SaveDuSolutionDTO saveDuSolutionDTO = saveDuSolutionDTOList.get(i); |
| | | DuSolution duSolution = duSolutionMapper.selectOne(new QueryWrapper<DuSolution>().lambda().eq(DuSolution::getDispatchUnitId,saveDuSolutionDTO.getId()) |
| | | .eq(DuSolution::getIsdeleted,Constants.ZERO) |
| | | .eq(DuSolution::getSolutionId,saveDuSolutionDTO.getSolutionId()).last("limit 1")); |
| | | Integer duSolutionNum = duSolutionMapper.selectCount(new QueryWrapper<DuSolution>().lambda().eq(DuSolution::getDispatchUnitId,saveDuSolutionDTO.getId())); |
| | | if(Objects.isNull(duSolution)){ |
| | | duSolution = new DuSolution(); |
| | | duSolution.setCreateDate(new Date()); |
| | | duSolution.setCreator(loginUserInfo.getId()); |
| | | duSolution.setIsdeleted(Constants.ZERO); |
| | | duSolution.setDispatchUnitId(saveDispatchUnitDTO.getId()); |
| | | duSolution.setSortnum(duSolutionNum + i); |
| | | duSolution.setSolutionId(saveDuSolutionDTO.getSolutionId()); |
| | | duSolutionMapper.insert(duSolution); |
| | | } |
| | | List<SaveDuWorkTypeDTO> saveDuWorkTypeDTOList = saveDuSolutionDTO.getSaveDuWorkTypeDTOList(); |
| | | if(!CollectionUtils.isNotEmpty(saveDuSolutionDTOList)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+saveDuSolutionDTO.getSolutionName()+"】该方案下未选择工种!"); |
| | | } |
| | | for (int j = 0; j < saveDuWorkTypeDTOList.size(); j++) { |
| | | SaveDuWorkTypeDTO saveDuWorkTypeDTO = saveDuWorkTypeDTOList.get(j); |
| | | if(duWorktypeMapper.selectCount(new QueryWrapper<DuWorktype>().lambda().eq(DuWorktype::getDuSolutionId,duSolution.getId()) |
| | | .eq(DuWorktype::getIsdeleted,Constants.ZERO) |
| | | .eq(DuWorktype::getWorkTypeId,saveDuWorkTypeDTO.getWorkTypeId()))>0){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+saveDuSolutionDTO.getSolutionName()+"】该方案下"+saveDuWorkTypeDTO.getWorkTypeName()+"该工种已存在工种已存在"); |
| | | } |
| | | Integer duWorkTypeNum = duWorktypeMapper.selectCount(new QueryWrapper<DuWorktype>().lambda().eq(DuWorktype::getDuSolutionId,duSolution.getId())); |
| | | DuWorktype duWorktype = new DuWorktype(); |
| | | duWorktype.setCreateDate(new Date()); |
| | | duWorktype.setCreator(loginUserInfo.getId()); |
| | | duWorktype.setIsdeleted(Constants.ZERO); |
| | | duWorktype.setDuSolutionId(duSolution.getId()); |
| | | duWorktype.setSortnum(duWorkTypeNum + j); |
| | | duWorktype.setWorkTypeId(saveDuWorkTypeDTO.getWorkTypeId()); |
| | | duWorktype.setVideoUrl(saveDuWorkTypeDTO.getVideoUrl()); |
| | | duWorktype.setStatus2(Constants.ZERO); |
| | | duWorktypeMapper.insert(duWorktype); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public void auditData(DispatchUnitAuditDTO dispatchUnitAuditDTO){ |
| | | if(Objects.isNull(dispatchUnitAuditDTO) |
| | | || Objects.isNull(dispatchUnitAuditDTO.getId()) |
| | | || Objects.isNull(dispatchUnitAuditDTO.getAuditType()) |
| | | || Objects.isNull(dispatchUnitAuditDTO.getStatus()) |
| | | || !(dispatchUnitAuditDTO.getAuditType().equals(Constants.ZERO) || dispatchUnitAuditDTO.getAuditType().equals(Constants.ONE)) |
| | | || !(dispatchUnitAuditDTO.getStatus().equals(Constants.ONE) || dispatchUnitAuditDTO.getAuditType().equals(Constants.TWO)) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(loginUserInfo.getType().equals(Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"用户类型错误:企业用户无法进行该操作"); |
| | | } |
| | | DispatchUnit dispatchUnit = this.dispatchUnitMapper.selectById(dispatchUnitAuditDTO.getId()); |
| | | 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(),"派遣单位信息已审核"); |
| | | } |
| | | dispatchUnit.setStatus(dispatchUnitAuditDTO.getStatus()); |
| | | dispatchUnit.setCheckDate(new Date()); |
| | | dispatchUnit.setCheckUserId(loginUserInfo.getId()); |
| | | dispatchUnit.setCheckInfo(dispatchUnitAuditDTO.getAuditRemark()); |
| | | dispatchUnitMapper.updateById(dispatchUnit); |
| | | if(dispatchUnitAuditDTO.getStatus().equals(Constants.ONE)){ |
| | | this.saveDuLog(dispatchUnit,Constants.DispatchUnitLogType.AUDIT_PASS,dispatchUnitAuditDTO.getAuditRemark()); |
| | | }else{ |
| | | this.saveDuLog(dispatchUnit,Constants.DispatchUnitLogType.AUDIT_UN_PASS,dispatchUnitAuditDTO.getAuditRemark()); |
| | | } |
| | | |
| | | }else if(dispatchUnitAuditDTO.getAuditType().equals(Constants.ONE)){ |
| | | if(!dispatchUnit.getStatus().equals(Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"派遣单位信息未审核,无法进行该操作"); |
| | | } |
| | | if(dispatchUnitAuditDTO.getStatus().equals(Constants.ONE)){ |
| | | this.saveDuLog(dispatchUnit,Constants.DispatchUnitLogType.WORK_TYPE_AUDIT_PASS,dispatchUnitAuditDTO.getAuditRemark()); |
| | | }else{ |
| | | this.saveDuLog(dispatchUnit,Constants.DispatchUnitLogType.WORK_TYPE_AUDIT_UN_PASS,dispatchUnitAuditDTO.getAuditRemark()); |
| | | } |
| | | }else{ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | //更新方案数据 |
| | | List<DuSolution> duSolutionList = duSolutionMapper.selectList(new QueryWrapper<DuSolution>().lambda() |
| | | .eq(DuSolution::getStatus,Constants.ZERO) |
| | | .eq(DuSolution::getIsdeleted,Constants.ZERO) |
| | | .eq(DuSolution::getDispatchUnitId,dispatchUnit.getId())); |
| | | for (DuSolution duSolution:duSolutionList) { |
| | | duSolution.setStatus(dispatchUnitAuditDTO.getStatus()); |
| | | duSolution.setCheckDate(new Date()); |
| | | duSolution.setCheckUserId(loginUserInfo.getId()); |
| | | duSolution.setCheckInfo(dispatchUnitAuditDTO.getAuditRemark()); |
| | | dispatchUnitMapper.updateById(dispatchUnit); |
| | | //查询工种数据 |
| | | List<DuWorktype> duWorktypeList = duWorktypeMapper.selectList(new QueryWrapper<DuWorktype>().lambda() |
| | | .eq(DuWorktype::getStatus,Constants.ZERO) |
| | | .eq(DuWorktype::getIsdeleted,Constants.ZERO) |
| | | .eq(DuWorktype::getDuSolutionId,duSolution.getId())); |
| | | for (DuWorktype duWorktype:duWorktypeList) { |
| | | duWorktype.setStatus(dispatchUnitAuditDTO.getStatus()); |
| | | duWorktype.setCheckDate(new Date()); |
| | | duWorktype.setCheckUserId(loginUserInfo.getId()); |
| | | duWorktype.setCheckInfo(dispatchUnitAuditDTO.getAuditRemark()); |
| | | dispatchUnitMapper.updateById(dispatchUnit); |
| | | } |
| | | } |
| | | this.saveHistory(dispatchUnit); |
| | | } |
| | | |
| | | |
| | | public void saveHistory(DispatchUnit dispatchUnit){ |
| | | if(dispatchUnit.getStatus().equals(Constants.ONE)){ |
| | | DispatchUnit his = new DispatchUnit(); |
| | | BeanUtils.copyProperties(dispatchUnit,his); |
| | | his.setBaseId(dispatchUnit.getId()); |
| | | his.setId(null); |
| | | his.setDataType(Constants.TWO); |
| | | dispatchUnitMapper.insert(his); |
| | | //修改其他历史版本数据为 历史版本 |
| | | dispatchUnitMapper.update(null,new UpdateWrapper<DispatchUnit>().lambda().set(DispatchUnit::getDataType,Constants.ONE).eq(DispatchUnit::getBaseId,dispatchUnit.getId()) |
| | | .eq(DispatchUnit::getDataType,Constants.TWO).ne(DispatchUnit::getId,his.getId()) |
| | | ); |
| | | //存储方案数据 |
| | | List<DuSolution> duSolutionList = duSolutionMapper.selectList(new QueryWrapper<DuSolution>().lambda() |
| | | .eq(DuSolution::getStatus,Constants.ONE) |
| | | .eq(DuSolution::getDispatchUnitId,dispatchUnit.getId())); |
| | | for (DuSolution duSolution:duSolutionList) { |
| | | DuSolution hisDuSolution = new DuSolution(); |
| | | BeanUtils.copyProperties(duSolution,hisDuSolution); |
| | | hisDuSolution.setId(null); |
| | | hisDuSolution.setDispatchUnitId(his.getId()); |
| | | duSolutionMapper.insert(hisDuSolution); |
| | | //查询工种数据 |
| | | List<DuWorktype> duWorktypeList = duWorktypeMapper.selectList(new QueryWrapper<DuWorktype>().lambda() |
| | | .eq(DuWorktype::getStatus,Constants.ONE) |
| | | .eq(DuWorktype::getDuSolutionId,duSolution.getId())); |
| | | for (DuWorktype duWorktype:duWorktypeList) { |
| | | DuWorktype hisDuWorktype = new DuWorktype(); |
| | | BeanUtils.copyProperties(duWorktype,hisDuWorktype); |
| | | hisDuWorktype.setId(null); |
| | | hisDuWorktype.setDuSolutionId(hisDuSolution.getId()); |
| | | duWorktypeMapper.insert(hisDuWorktype); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | public void saveDuLog(DispatchUnit dispatchUnit,Constants.DispatchUnitLogType dispatchUnitLogType,String content){ |
| | | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | DuLog duLog = new DuLog(); |
| | | duLog.setCreateDate(new Date()); |
| | | duLog.setCreator(loginUserInfo.getId()); |
| | | duLog.setIsdeleted(Constants.ZERO); |
| | | duLog.setDuId(dispatchUnit.getId()); |
| | | duLog.setTitle(dispatchUnitLogType.getName()); |
| | | duLog.setContent(content); |
| | | duLog.setObjType(dispatchUnitLogType.getKey()); |
| | | duLog.setObjId(Integer.toString(dispatchUnit.getId())); |
| | | duLog.setStatus(Constants.ZERO); |
| | | duLogMapper.insert(duLog); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void deleteById(Integer id) { |
| | |
| | | |
| | | @Override |
| | | public List<DispatchUnit> findList(DispatchUnit dispatchUnit) { |
| | | dispatchUnit.setIsdeleted(Constants.ZERO); |
| | | QueryWrapper<DispatchUnit> wrapper = new QueryWrapper<>(dispatchUnit); |
| | | return dispatchUnitMapper.selectList(wrapper); |
| | | } |
| | |
| | | QueryWrapper<DispatchUnit> wrapper = new QueryWrapper<>(dispatchUnit); |
| | | return dispatchUnitMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public DispatchUnit detailById(Integer id) { |
| | | DispatchUnit dispatchUnit = dispatchUnitMapper.selectById(id); |
| | | //方案配置表 |
| | | List<DuSolution> duSolutionList = duSolutionJoinMapper.selectJoinList(DuSolution.class, |
| | | new MPJLambdaWrapper<DuSolution>() |
| | | .selectAll(DuSolution.class) |
| | | .selectAs(Solutions::getName,DuSolution::getSolutionName) |
| | | .leftJoin(Solutions.class,Solutions::getId,DuSolution::getSolutionId) |
| | | .eq(DuSolution::getSolutionId,dispatchUnit.getId()) |
| | | .orderByAsc(DuSolution::getSortnum) |
| | | ); |
| | | if(CollectionUtils.isNotEmpty(duSolutionList)){ |
| | | for (DuSolution duSolution:duSolutionList) { |
| | | //查询方案下的工种信息 |
| | | List<DuWorktype> duWorkTypeList = duWorkTypeJoinMapper.selectJoinList(DuWorktype.class, |
| | | new MPJLambdaWrapper<DuWorktype>() |
| | | .selectAll(DuWorktype.class) |
| | | .selectAs(Worktype::getName,DuWorktype::getWorkTypeName) |
| | | .leftJoin(Worktype.class,Worktype::getId,DuWorktype::getWorkTypeId) |
| | | .eq(DuWorktype::getDuSolutionId,duSolution.getId()) |
| | | ); |
| | | duSolution.setDuWorktypeList(duWorkTypeList); |
| | | } |
| | | dispatchUnit.setDuSolutionList(duSolutionList); |
| | | } |
| | | //查询操作记录 |
| | | List<DuLog> duLogList = duLogJoinMapper.selectJoinList(DuLog.class, |
| | | new MPJLambdaWrapper<DuLog>() |
| | | .selectAll(DuLog.class) |
| | | .selectAs(Member::getName,DuLog::getCreatorName) |
| | | .selectAs(Company::getName,DuLog::getCompanyName) |
| | | .leftJoin(Member.class,Member::getId,DuLog::getCreator) |
| | | .leftJoin(Company.class,Company::getId,Member::getCompanyId) |
| | | .eq(DuLog::getDuId,dispatchUnit.getId()) |
| | | .orderByAsc(DuLog::getCreateDate) |
| | | ); |
| | | dispatchUnit.setDuLogList(duLogList); |
| | | return dispatchUnit; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询企业下的派遣单位 |
| | | * @return |
| | | */ |
| | | @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.solutionId = "+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) |
| | | ); |
| | | return dispatchUnitList; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |