package com.zy.asrs.service.impl; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.core.common.Cools; import com.core.exception.CoolException; import com.zy.asrs.entity.*; import com.zy.asrs.mapper.InOutMapper; import com.zy.asrs.service.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; @Service("InOutService") public class InOutServiceImpl extends ServiceImpl implements InOutService { @Autowired private InOutMapper inOutMapper; @Autowired private LocDetlService locDetlService; @Autowired private MatBarcodeService matBarcodeService; @Autowired private WrkDetlService wrkDetlService; @Autowired private WaitPakinService waitPakinService; @Autowired private MatService matService; @Autowired private WrkMastService wrkMastService; @Override public InOut selectByMatnr(String matnr) { return inOutMapper.selectByMatnr(matnr); } @Transactional @Override public void deleteInOut(List inOutList) { for (InOut inOut : inOutList) { //没有商品编号 直接删除 if (inOut.getMatnr() == null){ inOutMapper.deleteById(inOut.getId()); } //判断是否有库存 LocDetl locDetl = locDetlService.selectOne(new EntityWrapper().eq("matnr", inOut.getMatnr())); if (locDetl != null){ throw new CoolException("该模具存在库存,不能删除--->" + inOut.getMatnr()); } //判断是否绑定 MatBarcode matBarcode = matBarcodeService.selectbyMatnr(inOut.getMatnr()); if (matBarcode != null){ throw new CoolException("该模具已绑定托盘,不能删除--->" + inOut.getMatnr()); } //判断是否有工作档 WrkDetl wrkDetl = wrkDetlService.selectOne(new EntityWrapper().eq("matnr", inOut.getMatnr())); if (wrkDetl != null){ WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper().eq("wrk_no", wrkDetl.getWrkNo())); if (wrkMast == null){ throw new CoolException("工作档异常,有工作明细档,无工作主档"); } if ((wrkMast.getIoType() != 101 && wrkMast.getWrkSts() != 15) || (wrkMast.getIoType() != 103 && wrkMast.getWrkSts() != 14)){ throw new CoolException("该模具存在工作档,不能删除--->" + inOut.getMatnr()); } } //判断是否组托 List waitPakins = waitPakinService.selectList(new EntityWrapper().eq("matnr", inOut.getMatnr())); if (!Cools.isEmpty(waitPakins)){ throw new CoolException("该模具已组托,不能删除--->" + inOut.getMatnr()); } //判断是否有商品档案 Mat mat = matService.selectByMatnr(inOut.getMatnr()); if (mat != null){ throw new CoolException("商品档案存在该模具,不能删除--->" + inOut.getMatnr()); } inOutMapper.deleteById(inOut.getId()); } } }