| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.service.business.third.model.PageData; |
| | | import com.doumee.service.business.third.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.PlatformWmsDetailMapper; |
| | | import com.doumee.dao.business.PlatformWmsJobMapper; |
| | | import com.doumee.dao.business.model.PlatformWmsDetail; |
| | | import com.doumee.dao.business.model.PlatformWmsJob; |
| | | import com.doumee.dao.business.vo.WmsJobContractVO; |
| | | import com.doumee.service.business.PlatformWmsJobService; |
| | | 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 org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.function.BinaryOperator; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * æå°_WMSä½ä¸éç¥åè¡æ°æ®Serviceå®ç° |
| | | * @author æ±è¹è¹ |
| | | * @date 2024/06/28 10:03 |
| | | */ |
| | | @Service |
| | | public class PlatformWmsJobServiceImpl implements PlatformWmsJobService { |
| | | |
| | | @Autowired |
| | | private PlatformWmsJobMapper platformWmsJobMapper; |
| | | |
| | | @Autowired |
| | | private PlatformWmsDetailMapper platformWmsDetailMapper; |
| | | |
| | | @Override |
| | | public Integer create(PlatformWmsJob platformWmsJob) { |
| | | platformWmsJobMapper.insert(platformWmsJob); |
| | | return platformWmsJob.getId(); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteById(Integer id) { |
| | | platformWmsJobMapper.deleteById(id); |
| | | } |
| | | |
| | | @Override |
| | | public void delete(PlatformWmsJob platformWmsJob) { |
| | | UpdateWrapper<PlatformWmsJob> deleteWrapper = new UpdateWrapper<>(platformWmsJob); |
| | | platformWmsJobMapper.delete(deleteWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteByIdInBatch(List<Integer> ids) { |
| | | if (CollectionUtils.isEmpty(ids)) { |
| | | return; |
| | | } |
| | | platformWmsJobMapper.deleteBatchIds(ids); |
| | | } |
| | | |
| | | @Override |
| | | public void updateById(PlatformWmsJob platformWmsJob) { |
| | | platformWmsJobMapper.updateById(platformWmsJob); |
| | | } |
| | | |
| | | @Override |
| | | public void updateByIdInBatch(List<PlatformWmsJob> platformWmsJobs) { |
| | | if (CollectionUtils.isEmpty(platformWmsJobs)) { |
| | | return; |
| | | } |
| | | for (PlatformWmsJob platformWmsJob: platformWmsJobs) { |
| | | this.updateById(platformWmsJob); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public PlatformWmsJob findById(Integer id) { |
| | | return platformWmsJobMapper.selectById(id); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public PlatformWmsJob findByDetailId(Integer id) { |
| | | PlatformWmsJob platformWmsJob = platformWmsJobMapper.selectOne(new QueryWrapper<PlatformWmsJob>(). |
| | | lambda().eq(PlatformWmsJob::getIsdeleted, Constants.ZERO) |
| | | .eq(PlatformWmsJob::getJobId,id).last(" limit 1 ")); |
| | | if(Objects.isNull(platformWmsJob)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"æªæ¥è¯¢å°è¿åä¿¡æ¯"); |
| | | } |
| | | List<PlatformWmsDetail> platformWmsDetailList = platformWmsDetailMapper.selectList(new QueryWrapper<PlatformWmsDetail>() |
| | | .lambda().eq(PlatformWmsDetail::getJobId,id).eq(PlatformWmsDetail::getIsdeleted, Constants.ZERO)); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(platformWmsDetailList)){ |
| | | platformWmsJob.setIoQty( |
| | | platformWmsDetailList.stream().map(m->m.getIoQty()).reduce(BigDecimal.ZERO,BigDecimal::add) |
| | | ); |
| | | //è·åææååå·(å»éï¼ |
| | | List<String> ioCodeList = platformWmsDetailList.stream().map(m->m.getContractNum()).distinct().collect(Collectors.toList()); |
| | | Set<String> ioCodeSet = new HashSet<String>(ioCodeList); |
| | | List<WmsJobContractVO> wmsJobContractVOList = new ArrayList<>(); |
| | | for (String ioCode:ioCodeSet) { |
| | | if(StringUtils.isBlank(ioCode)){ |
| | | // continue; |
| | | } |
| | | WmsJobContractVO wmsJobContractVO = new WmsJobContractVO(); |
| | | wmsJobContractVO.setContractCode(ioCode); |
| | | wmsJobContractVO.setPlatformWmsDetailList( |
| | | platformWmsDetailList.stream().filter(i-> StringUtils.equals(i.getContractNum(),ioCode)).collect(Collectors.toList()) |
| | | ); |
| | | if(wmsJobContractVO.getPlatformWmsDetailList()!=null&& wmsJobContractVO.getPlatformWmsDetailList().size()>0){ |
| | | wmsJobContractVO.setAddress(wmsJobContractVO.getPlatformWmsDetailList().get(0).getRepertotyAddress()); |
| | | } |
| | | if(Objects.isNull(wmsJobContractVO.getLockStatus())&& |
| | | com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(wmsJobContractVO.getPlatformWmsDetailList())){ |
| | | if(Constants.equalsInteger(platformWmsJob.getType(),Constants.ONE)){ |
| | | if(Objects.isNull(wmsJobContractVO.getPlatformWmsDetailList().get(Constants.ZERO).getLockStatus())){ |
| | | wmsJobContractVO.setLockStatus(Constants.ZERO |
| | | ); |
| | | }else{ |
| | | wmsJobContractVO.setLockStatus( |
| | | wmsJobContractVO.getPlatformWmsDetailList().get(Constants.ZERO).getLockStatus() |
| | | ); |
| | | } |
| | | wmsJobContractVO.setStatus( |
| | | wmsJobContractVO.getPlatformWmsDetailList().get(Constants.ZERO).getStatus() |
| | | ); |
| | | } |
| | | } |
| | | wmsJobContractVOList.add(wmsJobContractVO); |
| | | } |
| | | |
| | | platformWmsJob.setWmsJobContractVOList(wmsJobContractVOList); |
| | | }else{ |
| | | platformWmsJob.setIoQty(BigDecimal.ZERO); |
| | | } |
| | | return platformWmsJob; |
| | | } |
| | | |
| | | @Override |
| | | public PlatformWmsJob findOne(PlatformWmsJob platformWmsJob) { |
| | | QueryWrapper<PlatformWmsJob> wrapper = new QueryWrapper<>(platformWmsJob); |
| | | return platformWmsJobMapper.selectOne(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<PlatformWmsJob> findList(PlatformWmsJob platformWmsJob) { |
| | | QueryWrapper<PlatformWmsJob> wrapper = new QueryWrapper<>(platformWmsJob); |
| | | return platformWmsJobMapper.selectList(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public PageData<PlatformWmsJob> findPage(PageWrap<PlatformWmsJob> pageWrap) { |
| | | IPage<PlatformWmsJob> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | QueryWrapper<PlatformWmsJob> queryWrapper = new QueryWrapper<>(); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | queryWrapper.lambda() |
| | | .eq(pageWrap.getModel().getId() != null, PlatformWmsJob::getId, pageWrap.getModel().getId()) |
| | | .eq(pageWrap.getModel().getCreator() != null, PlatformWmsJob::getCreator, pageWrap.getModel().getCreator()) |
| | | .ge(pageWrap.getModel().getCreateDate() != null, PlatformWmsJob::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate())) |
| | | .le(pageWrap.getModel().getCreateDate() != null, PlatformWmsJob::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate())) |
| | | .eq(pageWrap.getModel().getEditor() != null, PlatformWmsJob::getEditor, pageWrap.getModel().getEditor()) |
| | | .ge(pageWrap.getModel().getEditDate() != null, PlatformWmsJob::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate())) |
| | | .le(pageWrap.getModel().getEditDate() != null, PlatformWmsJob::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate())) |
| | | .eq(pageWrap.getModel().getIsdeleted() != null, PlatformWmsJob::getIsdeleted, pageWrap.getModel().getIsdeleted()) |
| | | .eq(pageWrap.getModel().getRemark() != null, PlatformWmsJob::getRemark, pageWrap.getModel().getRemark()) |
| | | .eq(pageWrap.getModel().getJobId() != null, PlatformWmsJob::getJobId, pageWrap.getModel().getJobId()) |
| | | .eq(pageWrap.getModel().getIocode() != null, PlatformWmsJob::getIocode, pageWrap.getModel().getIocode()) |
| | | .eq(pageWrap.getModel().getType() != null, PlatformWmsJob::getType, pageWrap.getModel().getType()) |
| | | .eq(pageWrap.getModel().getDriverPhone() != null, PlatformWmsJob::getDriverPhone, pageWrap.getModel().getDriverPhone()) |
| | | .eq(pageWrap.getModel().getDriverName() != null, PlatformWmsJob::getDriverName, pageWrap.getModel().getDriverName()) |
| | | .eq(pageWrap.getModel().getCarrierName() != null, PlatformWmsJob::getCarrierName, pageWrap.getModel().getCarrierName()) |
| | | .eq(pageWrap.getModel().getCarryBillCode() != null, PlatformWmsJob::getCarryBillCode, pageWrap.getModel().getCarryBillCode()) |
| | | .eq(pageWrap.getModel().getStatus() != null, PlatformWmsJob::getStatus, pageWrap.getModel().getStatus()) |
| | | .ge(pageWrap.getModel().getCancelDate() != null, PlatformWmsJob::getCancelDate, Utils.Date.getStart(pageWrap.getModel().getCancelDate())) |
| | | .le(pageWrap.getModel().getCancelDate() != null, PlatformWmsJob::getCancelDate, Utils.Date.getEnd(pageWrap.getModel().getCancelDate())) |
| | | .eq(pageWrap.getModel().getCancelInfo() != null, PlatformWmsJob::getCancelInfo, pageWrap.getModel().getCancelInfo()) |
| | | .eq(pageWrap.getModel().getPlateNumber() != null, PlatformWmsJob::getPlateNumber, pageWrap.getModel().getPlateNumber()) |
| | | .eq(pageWrap.getModel().getRepertotyAddress() != null, PlatformWmsJob::getRepertotyAddress, pageWrap.getModel().getRepertotyAddress()) |
| | | .eq(pageWrap.getModel().getContractNum() != null, PlatformWmsJob::getContractNum, pageWrap.getModel().getContractNum()) |
| | | ; |
| | | for(PageWrap.SortData sortData: pageWrap.getSorts()) { |
| | | if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { |
| | | queryWrapper.orderByDesc(sortData.getProperty()); |
| | | } else { |
| | | queryWrapper.orderByAsc(sortData.getProperty()); |
| | | } |
| | | } |
| | | return PageData.from(platformWmsJobMapper.selectPage(page, queryWrapper)); |
| | | } |
| | | |
| | | @Override |
| | | public long count(PlatformWmsJob platformWmsJob) { |
| | | QueryWrapper<PlatformWmsJob> wrapper = new QueryWrapper<>(platformWmsJob); |
| | | return platformWmsJobMapper.selectCount(wrapper); |
| | | } |
| | | } |