|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.service.impl.ServiceImpl; | 
|---|
|  |  |  | import com.core.common.Cools; | 
|---|
|  |  |  | import com.core.exception.CoolException; | 
|---|
|  |  |  | import com.zy.asrs.entity.MatCode; | 
|---|
|  |  |  | import com.zy.asrs.entity.Mat; | 
|---|
|  |  |  | import com.zy.asrs.entity.WrkDetl; | 
|---|
|  |  |  | import com.zy.asrs.entity.MatCodeCountDto; | 
|---|
|  |  |  | import com.zy.asrs.mapper.WrkDetlMapper; | 
|---|
|  |  |  | import com.zy.asrs.service.MatCodeService; | 
|---|
|  |  |  | import com.zy.asrs.service.MatService; | 
|---|
|  |  |  | import com.zy.asrs.service.WrkDetlService; | 
|---|
|  |  |  | import com.zy.common.model.DetlDto; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  | 
|---|
|  |  |  | public class WrkDetlServiceImpl extends ServiceImpl<WrkDetlMapper, WrkDetl> implements WrkDetlService { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MatCodeService matCodeService; | 
|---|
|  |  |  | private MatService matService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void createWorkDetail(Integer workNo, List<MatCodeCountDto> matCodeCountDtos, Long userId) { | 
|---|
|  |  |  | if (matCodeCountDtos.isEmpty()){ | 
|---|
|  |  |  | public void createWorkDetail(Integer workNo, List<DetlDto> detlDtos, String barcode, Long userId) { | 
|---|
|  |  |  | if (detlDtos.isEmpty()){ | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (MatCodeCountDto dto : matCodeCountDtos) { | 
|---|
|  |  |  | MatCode matCode = matCodeService.selectById(dto.getMatNo()); | 
|---|
|  |  |  | if (Cools.isEmpty(matCode)){ | 
|---|
|  |  |  | throw new CoolException("物料条码数据为空"); | 
|---|
|  |  |  | Date now = new Date(); | 
|---|
|  |  |  | for (DetlDto dto : detlDtos) { | 
|---|
|  |  |  | Mat mat = matService.selectByMatnr(dto.getMatnr()); | 
|---|
|  |  |  | if (Cools.isEmpty(mat)){ | 
|---|
|  |  |  | throw new CoolException(dto.getMatnr() + "商品维护失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 保持工作档明细 | 
|---|
|  |  |  | WrkDetl wrkDetl = new WrkDetl(); | 
|---|
|  |  |  | wrkDetl.sync(mat); | 
|---|
|  |  |  | wrkDetl.setWrkNo(workNo); | 
|---|
|  |  |  | wrkDetl.setIoTime(new Date()); | 
|---|
|  |  |  | wrkDetl.setMatnr(matCode.getMatNo()); // 物料编号 | 
|---|
|  |  |  | wrkDetl.setAnfme((double) dto.getCount()); // 数量 | 
|---|
|  |  |  | wrkDetl.setIoTime(now); | 
|---|
|  |  |  | wrkDetl.setBatch(dto.getBatch()); | 
|---|
|  |  |  | wrkDetl.setAnfme(dto.getAnfme()); // 数量 | 
|---|
|  |  |  | wrkDetl.setZpallet(barcode); // 货架条码 | 
|---|
|  |  |  | wrkDetl.setAppeUser(userId); | 
|---|
|  |  |  | wrkDetl.setAppeTime(new Date()); | 
|---|
|  |  |  | wrkDetl.setAppeTime(now); | 
|---|
|  |  |  | wrkDetl.setModiUser(userId); | 
|---|
|  |  |  | wrkDetl.setModiTime(new Date()); | 
|---|
|  |  |  | wrkDetl.setModiTime(now); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | wrkDetl.setThreeCode(dto.getCsocode()); | 
|---|
|  |  |  | wrkDetl.setDeadTime(dto.getIsoseq()); | 
|---|
|  |  |  | wrkDetl.setSuppCode(dto.getContainerCode()); | 
|---|
|  |  |  | if (!this.insert(wrkDetl)) { | 
|---|
|  |  |  | throw new CoolException("保存工作明细失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<WrkDetl> selectByWrkNo(Integer wrkNo) { | 
|---|
|  |  |  | return this.baseMapper.selectByWrkNo(wrkNo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public boolean updateAnfme(Double anfme, Integer wrkNo, String matnr, String batch) { | 
|---|
|  |  |  | if (anfme <= 0) { | 
|---|
|  |  |  | return this.baseMapper.deleteItem(wrkNo, matnr, batch) > 0; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | return baseMapper.updateAnfme(anfme, wrkNo, matnr, batch) > 0; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<WrkDetl> selectAndLogByOrderNo(String orderNo) { | 
|---|
|  |  |  | return this.baseMapper.selectAndLogByOrderNo(orderNo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<WrkDetl> selectAndLogByOrderNoGroupByMatnrOfSum(String orderNo) { | 
|---|
|  |  |  | return this.baseMapper.selectAndLogByOrderNoGroupByMatnrOfSum(orderNo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public boolean updateInspect(Integer wrkNo, String matnr, String batch) { | 
|---|
|  |  |  | return this.baseMapper.updateInspect(wrkNo, matnr, batch) > 0; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<WrkDetl> selectPakoutQuery(Integer staNo, String matnr) { | 
|---|
|  |  |  | return this.baseMapper.selectPakoutQuery(staNo, matnr); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public boolean updateOrderNo(String orderNo, Integer wrkNo, String matnr, String batch) { | 
|---|
|  |  |  | return baseMapper.updateOrderNo(orderNo, wrkNo, matnr, batch) > 0; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|