| | |
| | | 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.DuWorktypeMapper; |
| | | import com.doumee.dao.business.WorktypeMapper; |
| | | import com.doumee.dao.business.model.DispatchUnit; |
| | | import com.doumee.dao.business.model.DuWorktype; |
| | | import com.doumee.dao.business.model.Worktype; |
| | | import com.doumee.service.business.DuWorktypeService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | |
| | | @Autowired |
| | | private DuWorktypeMapper duWorktypeMapper; |
| | | |
| | | @Autowired |
| | | private WorktypeMapper worktypeMapper; |
| | | |
| | | @Autowired |
| | | private DispatchUnitMapper dispatchUnitMapper; |
| | | |
| | | @Override |
| | | public Integer create(DuWorktype duWorktype) { |
| | | duWorktypeMapper.insert(duWorktype); |
| | |
| | | |
| | | @Override |
| | | public void deleteById(Integer id) { |
| | | DuWorktype duWorktype = duWorktypeMapper.selectById(id); |
| | | if(Objects.isNull(duWorktype)){ |
| | | DuWorktype dbDuWorkType = duWorktypeMapper.selectById(id); |
| | | if(Objects.isNull(dbDuWorkType)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(duWorktype.getStatus().equals(Constants.TWO)){ |
| | | duWorktypeMapper.deleteById(id); |
| | | }else{ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"当前状态无法进行删除"); |
| | | if(!dbDuWorkType.getStatus().equals(Constants.TWO)){ |
| | | throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"数据状态错误,无法进行删除"); |
| | | } |
| | | DispatchUnit dispatchUnit = dispatchUnitMapper.selectById(dbDuWorkType.getDispatchUnitId()); |
| | | if(Objects.isNull(dispatchUnit)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | duWorktypeMapper.deleteById(id); |
| | | |
| | | if(duWorktypeMapper.selectCount(new QueryWrapper<DuWorktype>().lambda() |
| | | .eq(DuWorktype::getWorkTypeId,dbDuWorkType.getWorkTypeId()) |
| | | .eq(DuWorktype::getStatus,Constants.ZERO) |
| | | .ne(DuWorktype::getId,dbDuWorkType.getId()) |
| | | )>Constants.ZERO){ |
| | | dispatchUnit.setWorktypeStatus(0); |
| | | }else if(duWorktypeMapper.selectCount(new QueryWrapper<DuWorktype>().lambda() |
| | | .eq(DuWorktype::getWorkTypeId,dbDuWorkType.getWorkTypeId()) |
| | | .eq(DuWorktype::getStatus,Constants.TWO) |
| | | .ne(DuWorktype::getId,dbDuWorkType.getId()) |
| | | )>Constants.ZERO){ |
| | | dispatchUnit.setWorktypeStatus(2); |
| | | }else{ |
| | | dispatchUnit.setWorktypeStatus(1); |
| | | } |
| | | dispatchUnitMapper.updateById(dispatchUnit); |
| | | } |
| | | |
| | | @Override |