自动化立体仓库 - WMS系统
Junjie
2023-09-20 c8ec0494e03be47ec0f1b3a89ad5e0a004bd7501
src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -16,12 +16,15 @@
import com.zy.asrs.task.core.ReturnT;
import com.zy.asrs.task.handler.WorkLogHandler;
import com.zy.asrs.utils.MatUtils;
import com.zy.asrs.utils.SaasUtils;
import com.zy.common.constant.MesConstant;
import com.zy.common.entity.Parameter;
import com.zy.common.model.DetlDto;
import com.zy.common.model.MesCombParam;
import com.zy.common.utils.HttpHandler;
import com.zy.system.entity.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -63,6 +66,10 @@
    private ApiLogService apiLogService;
    @Autowired
    private WorkLogHandler workLogHandler;
    @Autowired
    private ManLocDetlService manLocDetlService;
    @Autowired
    private WaitPakinLogService waitPakinLogService;
    @Override
    @Transactional
@@ -93,9 +100,11 @@
            // 生成入库通知档
            List<DetlDto> detlDtos = new ArrayList<>();
            param.getCombMats().forEach(elem -> {
                DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme());
                DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme(), elem.getCsocode(), elem.getIsoseq());
                detlDto.setContainerCode(elem.getContainerCode());
                if (DetlDto.has(detlDtos, detlDto)) {
                    DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch());
                    DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch(),detlDto.getCsocode(),detlDto.getIsoseq(),detlDto.getContainerCode());
                    assert one != null;
                    one.setAnfme(one.getAnfme() + detlDto.getAnfme());
                } else {
@@ -120,6 +129,10 @@
                waitPakin.setAppeTime(now);
                waitPakin.setModiUser(userId);
                waitPakin.setModiTime(now);
                waitPakin.setThreeCode(detlDto.getCsocode());
                waitPakin.setDeadTime(detlDto.getIsoseq());
                waitPakin.setSuppCode(detlDto.getContainerCode());
                if (!waitPakinService.insert(waitPakin)) {
                    throw new CoolException("保存入库通知档失败");
                }
@@ -144,9 +157,11 @@
                    throw new CoolException("修改单据明细数量失败");
                }
                DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme());
                DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme(),elem.getCsocode(),elem.getIsoseq());
                detlDto.setContainerCode(elem.getContainerCode());
                if (DetlDto.has(detlDtos, detlDto)) {
                    DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch());
                    DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch(),detlDto.getCsocode(),detlDto.getIsoseq(),detlDto.getContainerCode());
                    assert one != null;
                    one.setAnfme(one.getAnfme() + detlDto.getAnfme());
                } else {
@@ -170,6 +185,11 @@
                waitPakin.setAppeTime(now);
                waitPakin.setModiUser(userId);
                waitPakin.setModiTime(now);
                waitPakin.setThreeCode(detlDto.getCsocode());
                waitPakin.setDeadTime(detlDto.getIsoseq());
                waitPakin.setSuppCode(detlDto.getContainerCode());
                if (!waitPakinService.insert(waitPakin)) {
                    throw new CoolException("保存入库通知档失败");
                }
@@ -290,10 +310,12 @@
                }
                Mat analyse = MatUtils.analyseMat(elem.getMatnr());
                // 条码、物料代码、序列号、数量
                DetlDto detlDto = new DetlDto(elem.getMatnr(), analyse.getMatnr(), analyse.getBarcode(), elem.getAnfme());
                DetlDto detlDto = new DetlDto(elem.getMatnr(), analyse.getMatnr(), analyse.getBarcode(), elem.getAnfme(),elem.getCsocode(),elem.getIsoseq());
//                DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme());
                detlDto.setContainerCode(elem.getContainerCode());
                if (DetlDto.has(detlDtos, detlDto)) {
                    DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch());
                    DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch(),detlDto.getCsocode(),detlDto.getIsoseq(),detlDto.getContainerCode());
                    assert one != null;
                    one.setAnfme(one.getAnfme() + detlDto.getAnfme());
                } else {
@@ -398,6 +420,10 @@
                waitPakin.setAppeTime(now);
                waitPakin.setModiUser(userId);
                waitPakin.setModiTime(now);
                waitPakin.setThreeCode(detlDto.getCsocode());
                waitPakin.setDeadTime(detlDto.getIsoseq());
                waitPakin.setSuppCode(detlDto.getContainerCode());
                if (!waitPakinService.insert(waitPakin)) {
                    throw new CoolException("保存入库通知档失败");
                }
@@ -414,4 +440,53 @@
        }
    }
    @Transactional
    public void nodePutway(String zpallet, String locNo, User user) {
        Date now = new Date();
        //增加平库库存
        List<WaitPakin> waitPakinList = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", zpallet));
        waitPakinList.forEach(waitPakin -> {
            //料想码
            String containerCode = waitPakin.getSuppCode();
            //如果当前料想码已存在,则修改该料想的物料数量
            ManLocDetl manLocDetl = manLocDetlService.selectOne(new EntityWrapper<ManLocDetl>().eq("container_code", containerCode));
            if(Cools.isEmpty(manLocDetl)){
                saveManlocDetl(manLocDetl,waitPakin,now,locNo);
            }else{
                if(Cools.eq(manLocDetl.getMatnr(),waitPakin.getMatnr())
                        && Cools.eq(manLocDetl.getCsocode(),waitPakin.getThreeCode())
                        && Cools.eq(manLocDetl.getIsoseq(),waitPakin.getDeadTime())){
                    manLocDetl.setAnfme(manLocDetl.getAnfme() + waitPakin.getAnfme());
                    manLocDetlService.update(manLocDetl,new EntityWrapper<ManLocDetl>()
                            .eq("loc_no",manLocDetl.getLocNo())
                            .eq("container_code",manLocDetl.getContainerCode()));
                }else{
                    saveManlocDetl(manLocDetl,waitPakin,now,locNo);
                }
            }
            //生成平库入出库日志
            SaasUtils.insertLog(0,locNo,waitPakin.getMatnr(), waitPakin.getAnfme(),user.getUsername());
        });
        //生成入库通知历史档
        waitPakinLogService.save(zpallet);
        //删除入库通知档
        waitPakinService.delete(new EntityWrapper<WaitPakin>().eq("zpallet", zpallet));
    }
    private void saveManlocDetl(ManLocDetl manLocDetl, WaitPakin waitPakin, Date now, String locNo){
        manLocDetl = new ManLocDetl();
        BeanUtils.copyProperties(waitPakin,manLocDetl);
        manLocDetl.setContainerCode(waitPakin.getSuppCode());
        manLocDetl.setCsocode(waitPakin.getThreeCode());
        manLocDetl.setIsoseq(waitPakin.getDeadTime());
        manLocDetl.setCreateTime(now);
        manLocDetl.setModiTime(now);
        manLocDetl.setLocNo(locNo);
        manLocDetlService.insert(manLocDetl);
    }
}