|  |  | 
 |  |  | package com.zy.asrs.service.impl; | 
 |  |  |  | 
 |  |  | 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.WrkDetl; | 
 |  |  | import com.zy.asrs.entity.MatCodeCountDto; | 
 |  |  | import com.zy.asrs.mapper.WrkDetlMapper; | 
 |  |  | import com.zy.asrs.service.MatCodeService; | 
 |  |  | import com.zy.asrs.service.WrkDetlService; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.stereotype.Service; | 
 |  |  | import org.springframework.transaction.annotation.Transactional; | 
 |  |  |  | 
 |  |  | import java.util.Date; | 
 |  |  | import java.util.List; | 
 |  |  |  | 
 |  |  | @Service("wrkDetlService") | 
 |  |  | public class WrkDetlServiceImpl extends ServiceImpl<WrkDetlMapper, WrkDetl> implements WrkDetlService { | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private MatCodeService matCodeService; | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     @Transactional | 
 |  |  |     public void createWorkDetail(Integer workNo, List<MatCodeCountDto> matCodeCountDtos, Long userId) { | 
 |  |  |         if (matCodeCountDtos.isEmpty()){ | 
 |  |  |             return; | 
 |  |  |         } | 
 |  |  |         for (MatCodeCountDto dto : matCodeCountDtos) { | 
 |  |  |             MatCode matCode = matCodeService.selectById(dto.getMatNo()); | 
 |  |  |             if (Cools.isEmpty(matCode)){ | 
 |  |  |                 throw new CoolException("物料条码数据为空"); | 
 |  |  |             } | 
 |  |  |             // 保持工作档明细 | 
 |  |  |             WrkDetl wrkDetl = new WrkDetl(); | 
 |  |  |             wrkDetl.setWrkNo(workNo); | 
 |  |  |             wrkDetl.setIoTime(new Date()); | 
 |  |  |             wrkDetl.setMatnr(matCode.getMatNo()); // 物料编号 | 
 |  |  |             wrkDetl.setAnfme((double) dto.getCount()); // 数量 | 
 |  |  |             wrkDetl.setLgnum("待定"); // todo | 
 |  |  |             wrkDetl.setTbnum(0); // todo | 
 |  |  |             wrkDetl.setTbpos(0); // todo | 
 |  |  |             wrkDetl.setZmatid("待定"); // todo | 
 |  |  |             wrkDetl.setAppeUser(userId); | 
 |  |  |             wrkDetl.setAppeTime(new Date()); | 
 |  |  |             wrkDetl.setModiUser(userId); | 
 |  |  |             wrkDetl.setModiTime(new Date()); | 
 |  |  |             if (!this.insert(wrkDetl)) { | 
 |  |  |                 throw new CoolException("保存工作明细失败"); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  | } |