| | |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.entity.result.OpenOrderCompeteResult; |
| | | import com.zy.asrs.entity.result.StockVo; |
| | | import com.zy.asrs.entity.vo.JarMastTableVo; |
| | | import com.zy.asrs.mapper.TagMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import com.zy.asrs.task.handler.BareBoardHandler; |
| | | import com.zy.asrs.utils.CodeDetectionUtil; |
| | | import com.zy.asrs.utils.MatUtils; |
| | | import com.zy.asrs.utils.PostMesDataUtils; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.model.LocTypeDto; |
| | | import com.zy.common.model.StartupDto; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | |
| | | private LocMastService locMastService; |
| | | @Autowired |
| | | private WorkService workService; |
| | | @Autowired |
| | | private BareBoardHandler bareBoardHandler; |
| | | @Autowired |
| | | private BasJarMastService basJarMastService; |
| | | @Autowired |
| | | private BasCrnpService basCrnpService; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | } |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | waitPakin.sync(mat); |
| | | waitPakin.setBatch(matList.getBatch()); //木箱编码 //批次 唯一值 箱号 |
| | | waitPakin.setBatch(matList.getBatch()); //木箱编码 //批次 唯一值 批次 |
| | | waitPakin.setModel(matList.getModel()); //卷号 唯一值 |
| | | waitPakin.setBrand(param.getBoxType()); //木箱类型 |
| | | waitPakin.setZpallet(param.getBarcode()); //托盘码 |
| | |
| | | waitPakin.setWeight(matList.getWeight()); //净重 |
| | | waitPakin.setVolume(matList.getRoughWeight()); //毛重 |
| | | waitPakin.setPrice(matList.getRollExtent()); //长度 |
| | | waitPakin.setSpecs(String.valueOf(matList.getJoint())); //接头 |
| | | waitPakin.setSpecs(String.valueOf(matList.getJoint())); //接头 MES订单号 |
| | | waitPakin.setIoStatus("N"); // 入出状态 |
| | | waitPakin.setAnfme(matList.getAnfme()); // 数量 |
| | | waitPakin.setStatus("Y"); // 状态 |
| | |
| | | } else if (param.getType()==3){//直供产线 |
| | | smallContainersSta(param); |
| | | } |
| | | // else if (param.getType()==99){//库内供产线 //出库 测试 |
| | | // smallContainersBig99(param); |
| | | // } |
| | | } catch (Exception e){ |
| | | throw new CoolException("失败!!!原因:"+e.getMessage()); |
| | | } |
| | |
| | | if (Cools.isEmpty(basDevp.getCanining()) || !basDevp.getCanining().equals("Y")){ |
| | | throw new CoolException("码垛位编号 palletizingNo="+param.getStaNo()+" 所处站点不是能入状态"); |
| | | } |
| | | if (Cools.isEmpty(basDevp.getBarcode())){ |
| | | if (Cools.isEmpty(basDevp.getBarcode()) || basDevp.getBarcode().equals("00000000")){ |
| | | throw new CoolException("码垛位编号 palletizingNo="+param.getStaNo()+" 所处站点料箱码异常状态;料箱码==》为空"+basDevp.getBarcode()); |
| | | } |
| | | if (!basDevp.getInEnable().equals("Y")){ |
| | | try{ |
| | | Thread.sleep(500); |
| | | } catch (Exception e){ |
| | | |
| | | } |
| | | BasDevp basDevp1111 = basDevpService.selectById(param.getStaNo()); |
| | | if (!basDevp1111.getInEnable().equals("Y")){ |
| | | throw new CoolException("码垛位编号 palletizingNo="+param.getStaNo()+" 所处站点,请等待翻转完成;料箱码==》"+basDevp.getBarcode()); |
| | | } |
| | | |
| | | } |
| | | if (!CodeDetectionUtil.barcodeDetection(basDevp.getBarcode(),8)){ |
| | | throw new CoolException("码垛位编号 palletizingNo="+param.getStaNo()+" 所处站点料箱码异常状态;料箱码:"+basDevp.getBarcode()); |
| | |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | waitPakin.sync(mat); |
| | | waitPakin.setBatch(param.getBatch()); //木箱编码 //批次 唯一值 箱号 |
| | | // waitPakin.setModel(matList.getModel()); //卷号 唯一值 |
| | | waitPakin.setModel(param.getTaskNo()); //卷号 唯一值 工作号 |
| | | // waitPakin.setBrand(param.getBoxType()); //木箱类型 |
| | | waitPakin.setZpallet(basDevp.getBarcode()); //托盘码 |
| | | // waitPakin.setOrigin(matList.getPosition()); //木箱在托盘上的位置 |
| | | waitPakin.setWeight(param.getWeight()); //净重 |
| | | // waitPakin.setVolume(matList.getRoughWeight()); //毛重 |
| | | // waitPakin.setPrice(matList.getRollExtent()); //长度 |
| | | // waitPakin.setSpecs(String.valueOf(matList.getJoint())); //接头 |
| | | waitPakin.setSpecs(param.getOrderNo()); //MES订单号 借用规格 |
| | | // waitPakin.setIoStatus("N"); // 入出状态 |
| | | // waitPakin.setAnfme(matList.getAnfme()); // 数量 |
| | | waitPakin.setColor(param.getColor()); // 颜色 |
| | |
| | | throw new CoolException("参数:品号 matnr为空"); |
| | | }else if (Cools.isEmpty(param.getWeight())){ |
| | | throw new CoolException("参数:物料重量 wright为空"); |
| | | } |
| | | if (param.getDevNo()==131){ |
| | | param.setDevNo(130); |
| | | } else if (param.getDevNo()==126){ |
| | | param.setDevNo(125); |
| | | }else if (Cools.isEmpty(param.getBatchNum())){ |
| | | throw new CoolException("参数:出库数量 batchNum为空"); |
| | | } |
| | | |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("matnr", param.getMatnr()).eq("weight", param.getWeight()).eq("color", param.getColor())); |
| | | Mat mat = matService.selectByMatnr(param.getMatnr()); |
| | | if (Cools.isEmpty(mat)){ |
| | | throw new CoolException("品号 matnr,请先下发基础档案!!!"); |
| | | } |
| | | if (Cools.isEmpty(mat.getUnits())){ |
| | | throw new CoolException("品号 matnr,重量范围偏移值为空!!!,请先维护基础档案!!!"); |
| | | } |
| | | |
| | | ArrayList<Integer> crns =new ArrayList<>(); |
| | | ArrayList<Integer> crnList =new ArrayList<>(); |
| | | |
| | | crns.add(1);crns.add(2);crns.add(3);crns.add(4);crns.add(5);crns.add(6);crns.add(7); |
| | | |
| | | for (Integer crnNo : crns){ |
| | | // 检测路径 |
| | | Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | | .eq("type_no", 101) |
| | | .eq("stn_no", param.getDevNo()) |
| | | .eq("crn_no", crnNo); |
| | | StaDesc staDesc = staDescService.selectOne(wrapper); |
| | | if (Cools.isEmpty(staDesc)){ |
| | | continue; |
| | | } |
| | | BasCrnp basCrnp = basCrnpService.selectById(crnNo); |
| | | if (basCrnp.getCrnSts()!=3 || !basCrnp.getOutEnable().equals("Y")){ |
| | | continue; |
| | | } |
| | | if (!basCrnpService.checkSiteError(crnNo, false)){ |
| | | continue; |
| | | } |
| | | crnList.add(crnNo); |
| | | } |
| | | |
| | | if (crnList.isEmpty()){ |
| | | throw new CoolException("无可用堆垛机"); |
| | | } |
| | | |
| | | ArrayList<LocDetl> locDetlArrayList = new ArrayList<>(); |
| | | Wrapper<LocDetl> wrapper = new EntityWrapper<LocDetl>() |
| | | .eq("matnr", param.getMatnr()) |
| | | .eq("weight", param.getWeight()) |
| | | .orderBy("batch", true); |
| | | if (param.getDevNo() == 536) { |
| | | wrapper.eq("model", param.getModel()) |
| | | .eq("specs", param.getOrderNo()); |
| | | } |
| | | |
| | | List<LocDetl> locDetls = locDetlService.selectList(wrapper); |
| | | if (locDetls.isEmpty()){ |
| | | locDetls = new ArrayList<LocDetl>(); |
| | | } |
| | | if (locDetls.isEmpty()){ |
| | | throw new CoolException("未找到符合条件的物料明细:品号==》matnr:"+param.getMatnr()+";重量==》wright:"+param.getWeight()+";颜色==》color:"+param.getColor()); |
| | | for (LocDetl locDetl:locDetls){ |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetl.getLocNo())); |
| | | if (locMast.getLocSts().equals("F")){ |
| | | if (crnList.contains(locMast.getCrnNo())){ |
| | | if (locDetlArrayList.size()<param.getBatchNum()) {//下 |
| | | locDetlArrayList.add(locDetl); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | for (LocDetl locDetl : locDetls){ |
| | | StockOutParam stockOutParam = new StockOutParam(param,locDetl); |
| | | |
| | | Integer batchNum = param.getBatchNum(); |
| | | if (locDetlArrayList.size()<batchNum){//上 |
| | | Wrapper<LocDetl> locDetlWrapper = new EntityWrapper<LocDetl>().eq("matnr", param.getMatnr()) |
| | | .lt("weight", param.getWeight() + mat.getUnits()) |
| | | .and() |
| | | .gt("weight", param.getWeight()) |
| | | .orderBy("batch", true) |
| | | .orderBy("weight", true); |
| | | if (param.getDevNo() == 536){ |
| | | locDetlWrapper.eq("model", param.getModel()) |
| | | .eq("specs", param.getOrderNo()); |
| | | } |
| | | locDetls = locDetlService.selectList(locDetlWrapper); |
| | | if (locDetls.isEmpty()){ |
| | | locDetls = new ArrayList<LocDetl>(); |
| | | } |
| | | for (LocDetl locDetl:locDetls){ |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetl.getLocNo())); |
| | | if (locMast.getLocSts().equals("F")){ |
| | | if (crnList.contains(locMast.getCrnNo())){ |
| | | if (locDetlArrayList.size()<batchNum) {//下 |
| | | locDetlArrayList.add(locDetl); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (locDetlArrayList.size()<batchNum){//下 |
| | | Wrapper<LocDetl> locDetlWrapper = new EntityWrapper<LocDetl>().eq("matnr", param.getMatnr()) |
| | | .gt("weight", param.getWeight() - mat.getUnits()) |
| | | .and() |
| | | .lt("weight", param.getWeight()) |
| | | .orderBy("batch", true) |
| | | .orderBy("weight", false); |
| | | if (param.getDevNo() == 536){ |
| | | locDetlWrapper.eq("model", param.getModel()) |
| | | .eq("specs", param.getOrderNo()); |
| | | } |
| | | locDetls = locDetlService.selectList(locDetlWrapper); |
| | | |
| | | if (locDetls.isEmpty()){ |
| | | locDetls = new ArrayList<LocDetl>(); |
| | | } |
| | | for (LocDetl locDetl:locDetls){ |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetl.getLocNo())); |
| | | if (locMast.getLocSts().equals("F")){ |
| | | if (crnList.contains(locMast.getCrnNo())){ |
| | | if (locDetlArrayList.size()<batchNum) {//下 |
| | | locDetlArrayList.add(locDetl); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (locDetlArrayList.isEmpty()){ |
| | | throw new CoolException("未找到符合条件的物料明细:品号==》matnr:"+param.getMatnr()+";重量==》wright:"+param.getWeight()); |
| | | } |
| | | if (locDetlArrayList.size()<batchNum){ |
| | | throw new CoolException("库存数量:"+locDetlArrayList.size()+";小于需求数量:"+param.getBatchNum()); |
| | | } |
| | | ArrayList<String> locS = new ArrayList<>(); |
| | | |
| | | ArrayList<LocDetl> locDetlArrayAnd = new ArrayList<>(); |
| | | for (LocDetl locDetl : locDetlArrayList){ |
| | | if (!locS.contains(locDetl.getLocNo())){ |
| | | locDetlArrayAnd.add(locDetl); |
| | | locS.add(locDetl.getLocNo()); |
| | | if (crnList.contains(1) || crnList.contains(2)){ |
| | | String singleLoc = Utils.singleLoc(locDetl.getLocNo()); |
| | | if (Cools.isEmpty(singleLoc)){ |
| | | log.error("异常库位号:"+singleLoc+";输入库位号:"+locDetl.getLocNo()); |
| | | continue; |
| | | } |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", singleLoc)); |
| | | if (locMast.getLocSts().equals("F")){ |
| | | LocDetl locDetl1 = locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("loc_no", singleLoc)); |
| | | if (Cools.isEmpty(locDetl1)){ |
| | | throw new CoolException("库位"+locMast.getLocNo()+"异常,在库但是无库存!!!"); |
| | | } |
| | | if (!locS.contains(locDetl1.getLocNo())){ |
| | | if (locDetl1.getMatnr().equals(locDetl.getMatnr())){ |
| | | locDetlArrayAnd.add(locDetl1); |
| | | locS.add(locDetl1.getLocNo()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (locDetlArrayAnd.isEmpty()){ |
| | | throw new CoolException("未找到符合条件的物料明细:品号==》matnr:"+param.getMatnr()+";重量==》wright:"+param.getWeight()); |
| | | } |
| | | if (locDetlArrayAnd.size()<batchNum){ |
| | | throw new CoolException("库存数量:"+locDetlArrayAnd.size()+";小于需求数量:"+param.getBatchNum()); |
| | | } |
| | | |
| | | ArrayList<LocDetl> locDetlArraySou = new ArrayList<>(); |
| | | |
| | | for (LocDetl locDetl : locDetlArrayAnd){ |
| | | if (batchNum <= 0){ |
| | | break; |
| | | } |
| | | locDetlArraySou.add(locDetl); |
| | | batchNum --; |
| | | } |
| | | try{ |
| | | StockOutParam stockOutParam = new StockOutParam(param,locDetlArraySou); |
| | | workService.startupFullTakeStore(stockOutParam, userId); |
| | | return; |
| | | } catch (Exception e){ |
| | | // throw new CoolException("生成出库任务失败:出库数量:"+locDetlArraySou.size()); |
| | | throw new CoolException("生成出库任务失败:"+e.getMessage()); |
| | | } |
| | | |
| | | } |
| | | |
| | | public void smallContainersJar(SmallCompleteParam param) { |
| | |
| | | |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | waitPakin.sync(mat); |
| | | // waitPakin.setBatch(matList.getBatch()); //木箱编码 //批次 唯一值 箱号 |
| | | // waitPakin.setModel(matList.getModel()); //卷号 唯一值 |
| | | waitPakin.setBatch(param.getBatch()); //木箱编码 //批次 唯一值 箱号 |
| | | waitPakin.setModel(param.getTaskNo()); //卷号 唯一值 |
| | | // waitPakin.setBrand(param.getBoxType()); //木箱类型 |
| | | waitPakin.setZpallet(basDevp.getBarcode()); //托盘码 |
| | | // waitPakin.setOrigin(matList.getPosition()); //木箱在托盘上的位置 |
| | | waitPakin.setWeight(param.getWeight()); //净重 |
| | | // waitPakin.setVolume(matList.getRoughWeight()); //毛重 |
| | | // waitPakin.setPrice(matList.getRollExtent()); //长度 |
| | | // waitPakin.setSpecs(String.valueOf(matList.getJoint())); //接头 |
| | | waitPakin.setSpecs(param.getOrderNo()); //单号 借用 |
| | | // waitPakin.setIoStatus("N"); // 入出状态 |
| | | // waitPakin.setAnfme(matList.getAnfme()); // 数量 |
| | | waitPakin.setColor(param.getColor()); // 颜色 |
| | |
| | | wrkDetl.setWrkNo(wrkMast.getWrkNo()); |
| | | wrkDetl.setIoTime(wrkMast.getIoTime()); |
| | | wrkDetl.setMatnr(param.getMatnr()); |
| | | wrkDetl.setModel(param.getTaskNo()); |
| | | wrkDetl.setBatch(param.getBatch()); |
| | | wrkDetl.setSpecs(param.getOrderNo()); |
| | | wrkDetl.setAnfme(1D); |
| | | wrkDetl.setWeight(param.getWeight()); |
| | | wrkDetl.setBarcode(basDevp.getBarcode()); |
| | |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作明细失败==》小料箱直供产线任务明细生成"); |
| | | } |
| | | } |
| | | |
| | | public Integer getStaEnd(Integer staNo){ |
| | | switch (staNo){ |
| | | case 118: |
| | | case 119: |
| | | return 131; |
| | | case 120: |
| | | case 121: |
| | | return 135; |
| | | default: |
| | | return staNo; |
| | | } |
| | | } |
| | | |
| | | /* |
| | | * 出库 |
| | | * 直供产线 |
| | | * */ |
| | | public void smallContainersBig99(SmallCompleteParam param) {//直供产线//出库 |
| | | Long userId = 7777L;//mes |
| | | //判断param参数 |
| | | if (Cools.isEmpty(param.getType())){ |
| | | throw new CoolException("参数:类型 type为空"); |
| | | // }else if (Cools.isEmpty(param.getStaNo())){ |
| | | // throw new CoolException("参数:投料点位 staNo为空"); |
| | | }else if (Cools.isEmpty(param.getDevNo())){ |
| | | throw new CoolException("参数:产线点位 devNo为空"); |
| | | }else if (Cools.isEmpty(param.getMatnr())){ |
| | | throw new CoolException("参数:品号 matnr为空"); |
| | | }else if (Cools.isEmpty(param.getWeight())){ |
| | | throw new CoolException("参数:物料重量 wright为空"); |
| | | }else if (Cools.isEmpty(param.getBatchNum())){ |
| | | throw new CoolException("参数:出库数量 batchNum为空"); |
| | | } |
| | | Integer devNo = param.getDevNo(); |
| | | Integer batchNum = param.getBatchNum(); |
| | | |
| | | |
| | | for (int i =0;i<batchNum;i++){ |
| | | bareBoardHandler.startYx(devNo,99); |
| | | } |
| | | } |
| | | |
| | | /* |
| | | * 获取硫化罐任务信息 // |
| | | * */ |
| | | @Override |
| | | @Transactional |
| | | public List<JarMastTableVo> getJatIdList(Integer id) { |
| | | List<BasJarMast> jarMasts = basJarMastService.selectList(new EntityWrapper<BasJarMast>().eq("jar_id", id)); |
| | | if (Cools.isEmpty(jarMasts)){ |
| | | return new ArrayList<JarMastTableVo>(); |
| | | } |
| | | ArrayList<JarMastTableVo> jarMastTableVos = new ArrayList<>(); |
| | | for (BasJarMast jarMast : jarMasts) { |
| | | JarMastTableVo jarMastTableVo = new JarMastTableVo(); |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", jarMast.getWrkNo())); |
| | | List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", jarMast.getWrkNo())); |
| | | if (wrkDetls.isEmpty()){ |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetls.add(wrkDetl); |
| | | } |
| | | if (Cools.isEmpty(wrkMast) || Cools.isEmpty(wrkDetls)){ |
| | | continue; |
| | | } |
| | | jarMastTableVo.setJarId(jarMast.getJarId()); |
| | | jarMastTableVo.setJarWrkNo(jarMast.getWrkNo().toString()); |
| | | jarMastTableVo.setStatus(jarMast.getStatus()); |
| | | jarMastTableVo.setStatus$(jarMast.getStatus$()); |
| | | jarMastTableVo.setMatnr(wrkDetls.get(0).getMatnr()); |
| | | jarMastTableVo.setMaktx(wrkDetls.get(0).getMaktx()); |
| | | jarMastTableVo.setWeight(wrkDetls.get(0).getWeight()); |
| | | jarMastTableVos.add(jarMastTableVo); |
| | | } |
| | | return jarMastTableVos; |
| | | } |
| | | |
| | | /*...........................亳州煜星..............以上.............亳州煜星...........................*/ |