|  |  |  | 
|---|
|  |  |  | import com.zy.asrs.entity.BasDevp; | 
|---|
|  |  |  | import com.zy.asrs.entity.WrkDetl; | 
|---|
|  |  |  | import com.zy.asrs.entity.WrkMast; | 
|---|
|  |  |  | import com.zy.asrs.entity.WrkMastSta; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.BalconyWrkMastParam; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.TrussCombParam; | 
|---|
|  |  |  | import com.zy.asrs.service.*; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Value; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  | import sun.security.smartcardio.SunPCSC; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private BasDevpService basDevpService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private OrderService orderService; | 
|---|
|  |  |  | private WrkMastStaService wrkMastStaService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Value("${srHangJia.url}") | 
|---|
|  |  |  | private String srHangJiaUrl; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Value("${srHangJia.reportInPath}") | 
|---|
|  |  |  | private String reportOutPath; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public ReturnT<String> start(int staNo) { | 
|---|
|  |  |  | public ReturnT<String> start(int staNo,int staNoEnd) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | Integer staOther = getStaOther(staNoEnd); | 
|---|
|  |  |  | BasDevp basDevp = basDevpService.selectById(staNo); | 
|---|
|  |  |  | if (Cools.isEmpty(basDevp) || basDevp.getWrkNo()==0 | 
|---|
|  |  |  | || !basDevp.getAutoing().equals("Y") || !basDevp.getLoading().equals("Y") || !basDevp.getInEnable().equals("Y")){ | 
|---|
|  |  |  | return FAIL; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | BasDevp basDevp131 = basDevpService.selectById(131); | 
|---|
|  |  |  | if (Cools.isEmpty(basDevp131) || !basDevp131.getAutoing().equals("Y") || !( basDevp131.getWrkNo()>9899 && basDevp131.getWrkNo()<10000)){ | 
|---|
|  |  |  | if (Cools.isEmpty(basDevp131) || !basDevp131.getAutoing().equals("Y") | 
|---|
|  |  |  | || !( basDevp131.getWrkNo()>9899 && basDevp131.getWrkNo()<10000) || basDevp131.getReportSign()!=0){ | 
|---|
|  |  |  | return FAIL; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>() | 
|---|
|  |  |  | 
|---|
|  |  |  | return FAIL; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()); | 
|---|
|  |  |  | if (Cools.isEmpty(wrkDetls) || wrkDetls.size()!=1){ | 
|---|
|  |  |  | if (Cools.isEmpty(wrkDetls) || wrkDetls.size()==0){ | 
|---|
|  |  |  | return FAIL; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | BasDevp basDevp118 = basDevpService.selectById(118); | 
|---|
|  |  |  | if (Cools.isEmpty(basDevp118) || !basDevp118.getAutoing().equals("Y") || basDevp118.getReportSign()!=0 ){ | 
|---|
|  |  |  | WrkDetl wrkDetl = wrkDetls.get(0); | 
|---|
|  |  |  | if (Cools.isEmpty(wrkDetl) || Cools.isEmpty(wrkDetl.getOrigin()) || Cools.isEmpty(wrkDetl.getBatch()) | 
|---|
|  |  |  | || Cools.isEmpty(wrkDetl.getBrand())){ | 
|---|
|  |  |  | return FAIL; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | BasDevp basDevp119 = basDevpService.selectById(119); | 
|---|
|  |  |  | if (Cools.isEmpty(basDevp119) || basDevp119.getReportSign()!=0){ | 
|---|
|  |  |  | BasDevp basDevpEnd = basDevpService.selectById(staNoEnd); | 
|---|
|  |  |  | if (Cools.isEmpty(basDevpEnd) || !basDevpEnd.getAutoing().equals("Y") || basDevpEnd.getReportSign()!=0 ){ | 
|---|
|  |  |  | return FAIL; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | BasDevp basDevpOther = basDevpService.selectById(staOther); | 
|---|
|  |  |  | if (Cools.isEmpty(basDevpOther) || basDevpOther.getReportSign()!=0){ | 
|---|
|  |  |  | return FAIL; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (basDevp118.getLoading().equals("Y")){ | 
|---|
|  |  |  | if (basDevpEnd.getLoading().equals("Y") && basDevpEnd.getEmptyMk().equals("Y")){ | 
|---|
|  |  |  | //生成机械臂任务 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //                TrussCombParam trussCombParam = new TrussCombParam(param, order, orderDetlList); | 
|---|
|  |  |  | //            try{ | 
|---|
|  |  |  | //                ReturnT<String> success = postMesData(reportOutPath, trussCombParam); | 
|---|
|  |  |  | //                if (success.getCode()!=200){ | 
|---|
|  |  |  | //                    throw new CoolException("桁架上位软件退库失败"); | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //            } catch (Exception e){ | 
|---|
|  |  |  | //                throw new CoolException("桁架上位软件退库失败"); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | //生成拆盘任务 | 
|---|
|  |  |  | TrussCombParam trussCombParam = new TrussCombParam(wrkDetl,staNoEnd); | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | ReturnT<String> success = postMesData(reportOutPath, trussCombParam); | 
|---|
|  |  |  | if (success.getCode()!=200){ | 
|---|
|  |  |  | log.error("桁架上位软件退库失败"); | 
|---|
|  |  |  | return FAIL; | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | wrkMast.setSheetNo("3"); | 
|---|
|  |  |  | wrkMastService.updateById(wrkMast); | 
|---|
|  |  |  | basDevp.setReportSign(3); | 
|---|
|  |  |  | basDevpService.updateById(basDevp); | 
|---|
|  |  |  | basDevpEnd.setReportSign(3); | 
|---|
|  |  |  | basDevpService.updateById(basDevpEnd); | 
|---|
|  |  |  | wrkDetl.setOrigin(trussCombParam.getPalletizingNo2()==118? "2":"1"); | 
|---|
|  |  |  | wrkDetlService.update(wrkDetl,new EntityWrapper<WrkDetl>().eq("wrk_no",wrkDetl.getWrkNo())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return SUCCESS; | 
|---|
|  |  |  | } catch (Exception e){ | 
|---|
|  |  |  | log.error("桁架上位软件退库失败"+e); | 
|---|
|  |  |  | return FAIL; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else if (!basDevpEnd.getLoading().equals("Y") ){ | 
|---|
|  |  |  | Thread.sleep(1000); | 
|---|
|  |  |  | basDevpEnd = basDevpService.selectById(staNoEnd); | 
|---|
|  |  |  | if (Cools.isEmpty(basDevpEnd) || !basDevpEnd.getAutoing().equals("Y") || basDevpEnd.getReportSign()!=0 || !basDevpEnd.getLoading().equals("Y") ){ | 
|---|
|  |  |  | return FAIL; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | WrkMastSta wrkMastSta = wrkMastStaService.selectOne(new EntityWrapper<WrkMastSta>().eq("wrk_no",staNoEnd + 19999L)); | 
|---|
|  |  |  | if (Cools.isEmpty(wrkMastSta)){ | 
|---|
|  |  |  | //生成拆盘任务 | 
|---|
|  |  |  | WrkMastSta wrkMastSta1 = new WrkMastSta(new Date(),staNoEnd); | 
|---|
|  |  |  | wrkMastSta1.setType(2);      //类型 1:非空  2:空板 | 
|---|
|  |  |  | wrkMastSta1.setWrkType(2);                    //工作类型  1:取(叠盘)  2:拆盘  3:取放 5:满取  6:满放 | 
|---|
|  |  |  | wrkMastStaService.insert(wrkMastSta1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return SUCCESS; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | log.error("异常!!!"+e); | 
|---|
|  |  |  | log.error("退货入库机械臂取货异常!!!"+e); | 
|---|
|  |  |  | return FAIL; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return FAIL; | 
|---|
|  |  |  | 
|---|
|  |  |  | .build() | 
|---|
|  |  |  | .doPost(); | 
|---|
|  |  |  | JSONObject jsonObject = JSON.parseObject(response); | 
|---|
|  |  |  | if (jsonObject.getString("result").equals("Y")) { | 
|---|
|  |  |  | if (jsonObject.getInteger("Code").equals(200)) { | 
|---|
|  |  |  | success = true; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | log.error("请求接口失败!!!url:{};request:{};response:{}"+srHangJiaUrl+erpPath, JSON.toJSONString(combParam), response); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return SUCCESS; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Integer getStaOther(Integer staNo){ | 
|---|
|  |  |  | switch (staNo){ | 
|---|
|  |  |  | case 118: | 
|---|
|  |  |  | return 119; | 
|---|
|  |  |  | case 119: | 
|---|
|  |  |  | return 118; | 
|---|
|  |  |  | case 120: | 
|---|
|  |  |  | return 121; | 
|---|
|  |  |  | case 121: | 
|---|
|  |  |  | return 120; | 
|---|
|  |  |  | default: | 
|---|
|  |  |  | return 0; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|