| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.core.annotations.AppAuth; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.entity.DocType; |
| | | import com.zy.asrs.entity.param.CheckParam; |
| | | import com.zy.asrs.entity.param.MatSyncParam; |
| | | import com.zy.asrs.entity.param.OrderProdSyncParam; |
| | | import com.zy.asrs.entity.param.OrderSyncParam; |
| | | import com.zy.asrs.service.DocTypeService; |
| | | import com.zy.asrs.service.OpenService; |
| | | import com.zy.common.web.BaseController; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | }}; |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private OpenService openService; |
| | | |
| | | @Autowired |
| | | private DocTypeService docTypeService; |
| | | |
| | | /** |
| | | * 库存统计 |
| | | */ |
| | | @RequestMapping("/stock/default/v1") |
| | | public R queryStock(@RequestHeader(required = false) String appkey, |
| | | HttpServletRequest request) { |
| | | public R queryStock(@RequestHeader(required = false) String appkey, HttpServletRequest request) { |
| | | auth(appkey, null, request); |
| | | return R.ok().add(openService.queryStock()); |
| | | } |
| | |
| | | */ |
| | | @PostMapping("/mat/v1") |
| | | @AppAuth(memo = "物料同步接口") |
| | | public synchronized R syncMatInfoErp(@RequestHeader(required = false) String appkey, |
| | | @RequestBody(required = false) MatSyncParam param, |
| | | HttpServletRequest request){ |
| | | public synchronized R syncMatInfoErp(@RequestHeader(required = false) String appkey, @RequestBody(required = false) MatSyncParam param, HttpServletRequest request) { |
| | | auth(appkey, param, request); |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | |
| | | return R.ok("更新成功"); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | private void auth(String appkey, Object obj, HttpServletRequest request) { |
| | |
| | | |
| | | @PostMapping("/order/pak/default/v1") |
| | | @AppAuth(memo = "生成退货补货单据") |
| | | public synchronized R orderAccept(@RequestHeader(required = false) String appkey, |
| | | @RequestBody(required = true) OrderSyncParam param, |
| | | HttpServletRequest request){ |
| | | log.info("生成退货补货单据,{}",JSON.toJSONString(param)); |
| | | public synchronized R orderAccept(@RequestHeader(required = false) String appkey, @RequestBody(required = true) OrderSyncParam param, HttpServletRequest request) { |
| | | log.info("生成退货补货单据,{}", JSON.toJSONString(param)); |
| | | auth(appkey, param, request); |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | |
| | | String docName = param.get操作单据(); |
| | | boolean pakin = param.getPakin() == 1 ? true : false; |
| | | |
| | | openService.syncOrder(param,pakin,docName); |
| | | DocType type = getType(param.get操作单据(), param.getChildren().get(0).getIQuantity()); |
| | | if (!Cools.isEmpty(type)) { |
| | | if (type.getPakin() == 1) { |
| | | openService.syncOrder(param, true, type.getDocName()); |
| | | } else { |
| | | openService.syncOrder(param, false, type.getDocName()); |
| | | } |
| | | } else { |
| | | return R.ok("单据接受失败,不是约定的单据l类型"); |
| | | } |
| | | // String docName = param.get操作单据(); |
| | | // boolean pakin = param.getPakin() == 1 ? true : false; |
| | | // |
| | | // openService.syncOrder(param, pakin, docName); |
| | | |
| | | return R.ok("单据接受成功"); |
| | | |
| | |
| | | |
| | | @PostMapping("/order/pakin/default/v1") |
| | | @AppAuth(memo = "生成入库单据") |
| | | public synchronized R orderPakin(@RequestHeader(required = false) String appkey, |
| | | @RequestBody(required = true) OrderSyncParam param, |
| | | HttpServletRequest request){ |
| | | log.info("生成入库单据,{}",JSON.toJSONString(param)); |
| | | public synchronized R orderPakin(@RequestHeader(required = false) String appkey, @RequestBody(required = true) OrderSyncParam param, HttpServletRequest request) { |
| | | log.info("生成入库单据,{}", JSON.toJSONString(param)); |
| | | auth(appkey, param, request); |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | |
| | | String docName = !Cools.isEmpty(param.getOrderType()) ? param.getOrderType() : param.getChildren().get(0).getIQuantity() > 0 ? "银座采购入库单" : "银座采购退货单"; |
| | | boolean pakin = param.getChildren().get(0).getIQuantity() > 0 ? true : false; |
| | | // String docName = !Cools.isEmpty(param.getOrderType()) ? param.getOrderType() : param.getChildren().get(0).getIQuantity() > 0 ? "银座采购入库单" : "银座采购退货单"; |
| | | // boolean pakin = param.getChildren().get(0).getIQuantity() > 0 ? true : false; |
| | | |
| | | openService.syncOrder(param,pakin,docName); |
| | | |
| | | DocType type = getType(param.get操作单据(), param.getChildren().get(0).getIQuantity()); |
| | | if (!Cools.isEmpty(type)) { |
| | | if (type.getPakin() == 1) { |
| | | openService.syncOrder(param, true, type.getDocName()); |
| | | } else { |
| | | openService.syncOrder(param, false, type.getDocName()); |
| | | } |
| | | } else { |
| | | return R.ok("单据接受失败,不是约定的单据l类型"); |
| | | } |
| | | return R.ok("单据接受成功"); |
| | | |
| | | } |
| | |
| | | */ |
| | | @PostMapping("/check/default/v1") |
| | | @AppAuth(memo = "库存盘点") |
| | | public synchronized R checkLoc(@RequestHeader(required = false) String appkey, |
| | | @RequestBody(required = true) CheckParam param, |
| | | HttpServletRequest request){ |
| | | public synchronized R checkLoc(@RequestHeader(required = false) String appkey, @RequestBody(required = true) CheckParam param, HttpServletRequest request) { |
| | | auth(appkey, param, request); |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | |
| | | @AppAuth(memo = "同步工单单据") |
| | | public synchronized R orderPakout(@RequestHeader(required = false) String appkey, |
| | | //@RequestBody(required = false) HashMap<String,Object> param, |
| | | @RequestBody(required = false) OrderProdSyncParam param, |
| | | HttpServletRequest request){ |
| | | log.info("同步工单单据,{}",JSON.toJSONString(param)); |
| | | @RequestBody(required = false) OrderProdSyncParam param, HttpServletRequest request) { |
| | | log.info("同步工单单据,{}", JSON.toJSONString(param)); |
| | | auth(appkey, param, request); |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | if(!Cools.eq("生产",param.getCVouchtype())){ |
| | | String docName = param.getIQuantity() > 0 ? "银座委外入库单" : "银座委外入库退货单"; |
| | | boolean pakin = param.getIQuantity() > 0 ? true : false; |
| | | mappingPakInOrderParam(param,pakin,docName); |
| | | |
| | | if(!Cools.isEmpty(param.getChildren())){ |
| | | String docName1 = param.getChildren().get(0).getIQuantity() > 0 ? "银座委外材料出库单" : "银座委外材料退料单"; |
| | | boolean pakin1 = param.getChildren().get(0).getIQuantity() > 0 ? true : false; |
| | | mappingPakOutOrderParam(param,pakin1,docName1); |
| | | DocType type = getType(param.get操作单据(), param.getIQuantity()); |
| | | if (!Cools.isEmpty(type)) { |
| | | if (type.getDocName().equals("MO")) { |
| | | mappingPakInOrderParam(param, true, type.getDocName()); |
| | | mappingPakOutOrderParam(param, false, "银座委外材料出库单"); |
| | | } else if (type.getDocName().equals("OM")) { |
| | | mappingPakInOrderParam(param, true, type.getDocName()); |
| | | mappingPakOutOrderParam(param, false, "银座生产材料出库单"); |
| | | } else { |
| | | if (type.getPakin() == 1) { |
| | | mappingPakInOrderParam(param, true, type.getDocName()); |
| | | if (!Cools.isEmpty(param.getChildren())) { |
| | | mappingPakOutOrderParam(param, false, type.getDocName()); |
| | | } |
| | | } else { |
| | | mappingPakOutOrderParam(param, false, type.getDocName()); |
| | | } |
| | | } |
| | | |
| | | }else if(!Cools.isEmpty(param.getChildren())) { |
| | | String docName1 = param.getChildren().get(0).getIQuantity() > 0 ? "银座生产材料出库单" : "银座生产材料退料单"; |
| | | boolean pakin1 = param.getChildren().get(0).getIQuantity() > 0 ? true : false; |
| | | mappingPakOutOrderParam(param,pakin1,docName1); |
| | | } else { |
| | | return R.ok("单据接受失败,不是约定的单据l类型"); |
| | | } |
| | | |
| | | // if (!Cools.eq("生产", param.getCVouchtype())) { |
| | | // String docName = param.getIQuantity() > 0 ? "银座委外入库单" : "银座委外入库退货单"; |
| | | // boolean pakin = param.getIQuantity() > 0 ? true : false; |
| | | // mappingPakInOrderParam(param, pakin, docName); |
| | | // |
| | | // if (!Cools.isEmpty(param.getChildren())) { |
| | | // String docName1 = param.getChildren().get(0).getIQuantity() > 0 ? "银座委外材料出库单" : "银座委外材料退料单"; |
| | | // boolean pakin1 = param.getChildren().get(0).getIQuantity() > 0 ? true : false; |
| | | // mappingPakOutOrderParam(param, pakin1, docName1); |
| | | // } |
| | | // |
| | | // } else if (!Cools.isEmpty(param.getChildren())) { |
| | | // String docName1 = param.getChildren().get(0).getIQuantity() > 0 ? "银座生产材料出库单" : "银座生产材料退料单"; |
| | | // boolean pakin1 = param.getChildren().get(0).getIQuantity() > 0 ? true : false; |
| | | // mappingPakOutOrderParam(param, pakin1, docName1); |
| | | // } |
| | | |
| | | return R.ok("单据接受成功"); |
| | | |
| | |
| | | |
| | | @PostMapping("/order/delete/default/v1") |
| | | @AppAuth(memo = "单据删除审核") |
| | | public synchronized R orderDelete(@RequestHeader(required = false) String appkey, |
| | | @RequestBody(required = false) Map<String, Object> param, |
| | | HttpServletRequest request){ |
| | | log.info("单据删除审核,{}",JSON.toJSONString(param)); |
| | | public synchronized R orderDelete(@RequestHeader(required = false) String appkey, @RequestBody(required = false) Map<String, Object> param, HttpServletRequest request) { |
| | | log.info("单据删除审核,{}", JSON.toJSONString(param)); |
| | | auth(appkey, param, request); |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | |
| | | |
| | | boolean success = openService.orderDelete(param.get("id").toString()); |
| | | |
| | | if(success){ |
| | | if (success) { |
| | | return R.ok("单据删除成功"); |
| | | }else { |
| | | } else { |
| | | return R.error("单据正在执行,删除失败"); |
| | | } |
| | | |
| | | } |
| | | |
| | | private void mappingPakInOrderParam(OrderProdSyncParam param,boolean pakin,String docName){ |
| | | private void mappingPakInOrderParam(OrderProdSyncParam param, boolean pakin, String docName) { |
| | | //生成单据主体 |
| | | OrderSyncParam orderSyncParam = new OrderSyncParam(); |
| | | orderSyncParam.set操作系统号(param.get操作系统号()); |
| | |
| | | // String docName = param.getIQuantity() > 0 ? "银座产品生产入库单" : "入库退回单"; |
| | | // boolean pakin = param.getIQuantity() > 0 ? true : false; |
| | | |
| | | openService.syncOrder(orderSyncParam,pakin,docName); |
| | | openService.syncOrder(orderSyncParam, pakin, docName); |
| | | |
| | | //return orderSyncParam; |
| | | } |
| | | |
| | | private void mappingPakOutOrderParam(OrderProdSyncParam param,boolean pakin,String docName){ |
| | | private void mappingPakOutOrderParam(OrderProdSyncParam param, boolean pakin, String docName) { |
| | | OrderSyncParam orderSyncParam = new OrderSyncParam(); |
| | | |
| | | List<OrderProdSyncParam.ChildInfo> child = param.getChildren(); |
| | |
| | | //生成单据明细 |
| | | List<OrderSyncParam.OrderDetl> orderDetls = new ArrayList<>(); |
| | | |
| | | for(OrderProdSyncParam.ChildInfo childInfo : child){ |
| | | for (OrderProdSyncParam.ChildInfo childInfo : child) { |
| | | OrderSyncParam.OrderDetl orderDetl = new OrderSyncParam.OrderDetl(); |
| | | orderDetl.setcInvCode(childInfo.getCInvCode()); |
| | | orderDetl.setiQuantity(childInfo.getIQuantity()); |
| | |
| | | } |
| | | orderSyncParam.setChildren(orderDetls); |
| | | |
| | | openService.syncOrder(orderSyncParam,false,docName); |
| | | openService.syncOrder(orderSyncParam, false, docName); |
| | | |
| | | //return orderSyncParam; |
| | | } |
| | | |
| | | |
| | | private DocType getType(String type, Double iQuantity) { |
| | | DocType docType = new DocType(); |
| | | switch (type) { |
| | | case "Purchase": |
| | | docType.setDocName("银座采购入库单"); |
| | | docType.setPakin(1); |
| | | break; |
| | | case "MO": |
| | | docType.setDocName("银座生产订单"); |
| | | docType.setPakin(0); |
| | | break; |
| | | case "OM": |
| | | docType.setDocName("银座委外生产订单"); |
| | | docType.setPakin(0); |
| | | break; |
| | | case "采购入库单退货": |
| | | docType.setDocName("银座采购入库单退货单"); |
| | | docType.setPakin(0); |
| | | break; |
| | | case "委外入库单退货": |
| | | docType.setDocName("银座委外入库单退货单"); |
| | | docType.setPakin(1); |
| | | break; |
| | | case "生产材料出库退料": |
| | | docType.setDocName("银座生产材料出库退料单"); |
| | | docType.setPakin(1); |
| | | break; |
| | | case "委外材料出库退料": |
| | | docType.setDocName("银座委外材料出库退料单"); |
| | | docType.setPakin(1); |
| | | break; |
| | | case "生产材料出库补料": |
| | | docType.setDocName("银座生产材料出库补料单"); |
| | | docType.setPakin(0); |
| | | break; |
| | | case "委外材料出库补料": |
| | | docType.setDocName("银座委外材料出库补料单"); |
| | | docType.setPakin(0); |
| | | break; |
| | | case "其他入库单": |
| | | docType.setDocName("银座其他入库单"); |
| | | docType.setPakin(1); |
| | | break; |
| | | case "其他出库单": |
| | | docType.setDocName("银座其他出库单"); |
| | | docType.setPakin(0); |
| | | break; |
| | | default: |
| | | docType = docTypeService.selectOrAdd(type, iQuantity > 0); |
| | | } |
| | | return docType; |
| | | } |
| | | } |
| | |
| | | if (this == object) return true; |
| | | if (object == null || getClass() != object.getClass()) return false; |
| | | OrderDetl orderDetl = (OrderDetl) object; |
| | | return Objects.equals(cInvCode, orderDetl.cInvCode) && Objects.equals(bFree1, orderDetl.bFree1) && Objects.equals(cDefine22, orderDetl.cDefine22); |
| | | return Objects.equals(cInvCode, orderDetl.cInvCode) && Objects.equals(batch, orderDetl.batch) && Objects.equals(bFree1, orderDetl.bFree1) && Objects.equals(cDefine22, orderDetl.cDefine22); |
| | | } |
| | | |
| | | @Override |
| | |
| | | */ |
| | | OrderDetl selectItemByOrderNo(@Param("orderNo") String orderNo, @Param("matnr") String matnr, @Param("batch") String batch, @Param("csocode")String csocode, @Param("isocode")String isocode); |
| | | |
| | | OrderDetl selectItemByOrderNo2(@Param("orderNo") String orderNo, @Param("matnr") String matnr, @Param("threeCode") String threeCode); |
| | | OrderDetl selectItemByOrderNo2(@Param("orderNo") String orderNo, @Param("matnr") String matnr, @Param("batch") String batch, @Param("threeCode") String threeCode); |
| | | |
| | | OrderDetl selectItemNoneOfBatch(@Param("orderNo")String orderNo, @Param("matnr")String matnr); |
| | | |
| | |
| | | |
| | | OrderDetl selectItem(String orderNo, String matnr, String batch, String csocode, String isoCode); |
| | | |
| | | OrderDetl selectItem(String orderNo, String matnr, String threeCode); |
| | | OrderDetl selectItem(String orderNo, String matnr, String batch,String threeCode); |
| | | |
| | | OrderDetl selectItemNoneOfBatch(String orderNo, String matnr); |
| | | |
| | |
| | | agvWaitPakinList.forEach(wp -> { |
| | | createWrkDetlReWrite(wp.getMatnr(),wrkMast.getWrkNo(),wp.getOrderNo(),wp.getBatch(),wp.getAnfme(),wp.getSuppCode(),now,userId,wp.getThreeCode(),wp.getDeadTime(),wp.getProcessSts()); |
| | | // 流水 -- 新增订单明细 |
| | | OrderDetl orderDetl = orderDetlService.selectItem(wp.getOrderNo(), wp.getMatnr(), wp.getThreeCode()); |
| | | OrderDetl orderDetl = orderDetlService.selectItem(wp.getOrderNo(), wp.getMatnr(),wp.getBatch(), wp.getThreeCode()); |
| | | // FlowLog flowLog = new FlowLog(); |
| | | // flowLog.setFid(String.valueOf(flowId)); |
| | | // flowLog.setSpare2(wrkMast.getWrkNo().toString()); |
| | |
| | | for (DetlDto detail : orderDetails) { |
| | | DetlDto dto = new DetlDto(detail.getMatnr(), detail.getBatch(), detail.getAnfme()); |
| | | if (DetlDto.has(list, dto)) { |
| | | DetlDto detlDto = DetlDto.find(list, dto.getMatnr(), dto.getBatch(),dto.getCsocode(),dto.getIsoseq(),null); |
| | | DetlDto detlDto = DetlDto.find(list, dto.getMatnr(), dto.getBatch(), dto.getCsocode(), dto.getIsoseq(), null); |
| | | assert detlDto != null; |
| | | detlDto.setAnfme(detlDto.getAnfme() + detail.getAnfme()); |
| | | } else { |
| | |
| | | } |
| | | OrderDetl orderDetl = new OrderDetl(); |
| | | orderDetl.sync(mat); |
| | | if (!Cools.isEmpty(detlDto.getCFree1())){ |
| | | if (!Cools.isEmpty(detlDto.getCFree1())) { |
| | | orderDetl.setSpecs(detlDto.getCFree1()); |
| | | } |
| | | orderDetl.setBatch(detlDto.getBatch()); |
| | |
| | | for (DetlDto detail : orderDetails) { |
| | | DetlDto dto = new DetlDto(detail.getMatnr(), detail.getBatch(), detail.getAnfme()); |
| | | if (DetlDto.has(dbList, dto)) { |
| | | DetlDto detlDto = DetlDto.find(dbList, dto.getMatnr(), dto.getBatch(),dto.getCsocode(),dto.getIsoseq(),null); |
| | | DetlDto detlDto = DetlDto.find(dbList, dto.getMatnr(), dto.getBatch(), dto.getCsocode(), dto.getIsoseq(), null); |
| | | assert detlDto != null; |
| | | detlDto.setAnfme(detlDto.getAnfme() + detail.getAnfme()); |
| | | } else { |
| | |
| | | for (DetlDto detail : orderDetails) { |
| | | DetlDto dto = new DetlDto(detail.getMatnr(), detail.getBatch(), detail.getAnfme()); |
| | | if (DetlDto.has(list, dto)) { |
| | | DetlDto detlDto = DetlDto.find(list, dto.getMatnr(), dto.getBatch(),dto.getCsocode(),dto.getIsoseq(),null); |
| | | DetlDto detlDto = DetlDto.find(list, dto.getMatnr(), dto.getBatch(), dto.getCsocode(), dto.getIsoseq(), null); |
| | | assert detlDto != null; |
| | | detlDto.setAnfme(detlDto.getAnfme() + detail.getAnfme()); |
| | | } else { |
| | |
| | | for (DetlDto detail : orderDetails) { |
| | | DetlDto dto = new DetlDto(detail.getMatnr(), detail.getBatch(), detail.getAnfme()); |
| | | if (DetlDto.has(dbList, dto)) { |
| | | DetlDto detlDto = DetlDto.find(dbList, dto.getMatnr(), dto.getBatch(),dto.getCsocode(),dto.getIsoseq(),null); |
| | | DetlDto detlDto = DetlDto.find(dbList, dto.getMatnr(), dto.getBatch(), dto.getCsocode(), dto.getIsoseq(), null); |
| | | assert detlDto != null; |
| | | detlDto.setAnfme(detlDto.getAnfme() + detail.getAnfme()); |
| | | } else { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public Mat syncMat(MatSyncParam param) { |
| | | if (Cools.isEmpty(param.getCInvCode()) ) { |
| | | if (Cools.isEmpty(param.getCInvCode())) { |
| | | throw new CoolException("商品数据为空"); |
| | | } |
| | | Tag tag = tagService.selectByName("全部", 1); |
| | |
| | | if (Cools.isEmpty(mat)) { |
| | | mat = new Mat(); |
| | | mat.setTagId(tag.getId()); |
| | | syncMat(mat,param); |
| | | syncMat(mat, param); |
| | | if (matService.insert(mat)) { |
| | | callApiLogSave(mat, "/open/asrs/mat/v1", "接收ERP下发商品信息成功!添加商品信息成功!", true); |
| | | } else { |
| | |
| | | |
| | | } else { |
| | | mat.setTagId(tag.getId()); |
| | | syncMat(mat,param); |
| | | syncMat(mat, param); |
| | | System.out.println(mat.getMaktx().length()); |
| | | if (matService.updateById(mat)) { |
| | | callApiLogSave(mat, "/open/asrs/mat/v1", "接收ERP下发商品信息成功!添加商品信息成功!", true); |
| | |
| | | return mat; |
| | | } |
| | | |
| | | private void syncMat(Mat mat, MatSyncParam param){ |
| | | private void syncMat(Mat mat, MatSyncParam param) { |
| | | Date date = new Date(); |
| | | mat.setMatnr(param.getCInvCode());//物料编码 |
| | | mat.setMaktx(param.getCInvName());//物料名称 |
| | | mat.setSpecs(param.getCInvStd());//规格 |
| | | mat.setUnit(param.getCComUnitName()); |
| | | mat.setBeBatch(Cools.eq("true",param.getBInvBatch()) ? 1 : 0); |
| | | mat.setBeBatch(Cools.eq("true", param.getBInvBatch()) ? 1 : 0); |
| | | mat.setStatus(param.getStates()); |
| | | |
| | | mat.setCreateBy(9999L);//9999表示erp下发 |
| | |
| | | @Override |
| | | @Transactional |
| | | public void combMes(CombParam param) { |
| | | Long userId=9999l; |
| | | Long userId = 9999l; |
| | | if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) { |
| | | callApiLogSaveMES(null, null, BaseRes.PARAM, false); |
| | | throw new CoolException(BaseRes.PARAM); |
| | | } |
| | | if(param.getBarcode().length()!=8){ |
| | | if (param.getBarcode().length() != 8) { |
| | | callApiLogSaveMES(param, null, param.getBarcode() + ":条码长度不是8位", false); |
| | | throw new CoolException("条码长度不是8位===>>" + param.getBarcode()); |
| | | } |
| | |
| | | throw new CoolException(param.getBarcode() + "数据正在进行入库"); |
| | | } |
| | | |
| | | int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet",param.getBarcode())); |
| | | int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet",param.getBarcode())); |
| | | int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet", param.getBarcode())); |
| | | int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet", param.getBarcode())); |
| | | if (countLoc > 0) { |
| | | callApiLogSaveMES(param, null, param.getBarcode() + ":库存条码数据已存在", false); |
| | | throw new CoolException("库存条码数据已存在===>>" + param.getBarcode()); |
| | | }else if (countWrk > 0){ |
| | | } else if (countWrk > 0) { |
| | | callApiLogSaveMES(param, null, param.getBarcode() + ":工作明细档已存在此数据", false); |
| | | throw new CoolException("工作明细档已存在此数据===>>" + param.getBarcode()); |
| | | } |
| | | |
| | | Date now = new Date(); |
| | | try{ |
| | | try { |
| | | // 生成入库通知档 |
| | | List<DetlDto> detlDtos = new ArrayList<>(); |
| | | param.getCombMats().forEach(elem -> { |
| | | 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.getCsocode(),detlDto.getIsoseq(),detlDto.getContainerCode()); |
| | | 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 { |
| | |
| | | for (DetlDto detlDto : detlDtos) { |
| | | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | | callApiLogSaveMES(param, null,mat.getMatnr()+"商品档案不存在", false); |
| | | callApiLogSaveMES(param, null, mat.getMatnr() + "商品档案不存在", false); |
| | | throw new CoolException(detlDto.getMatnr() + "商品档案不存在"); |
| | | } |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | |
| | | waitPakin.setModiUser(userId); |
| | | waitPakin.setModiTime(now); |
| | | if (!waitPakinService.insert(waitPakin)) { |
| | | callApiLogSaveMES(param, null,mat.getMatnr()+"保存入库通知档失败", false); |
| | | callApiLogSaveMES(param, null, mat.getMatnr() + "保存入库通知档失败", false); |
| | | throw new CoolException("保存入库通知档失败"); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | callApiLogSaveMES(null, null,""+e, false); |
| | | } catch (Exception e) { |
| | | callApiLogSaveMES(null, null, "" + e, false); |
| | | } |
| | | callApiLogSaveMES(param, param.getCombMats().get(0),"组托成功", true); |
| | | callApiLogSaveMES(param, param.getCombMats().get(0), "组托成功", true); |
| | | } |
| | | public void callApiLogSaveMES(CombParam combParam,CombParam.CombMat combMat, String response, Boolean bool) { |
| | | if (Cools.isEmpty(combParam)){ |
| | | |
| | | public void callApiLogSaveMES(CombParam combParam, CombParam.CombMat combMat, String response, Boolean bool) { |
| | | if (Cools.isEmpty(combParam)) { |
| | | apiLogService.save("MES下发入库通知单", "/open/asrs/comb/v1", "null", "10.10.10.1", |
| | | "", |
| | | response, bool); |
| | | }else if (Cools.isEmpty(combMat)){ |
| | | } else if (Cools.isEmpty(combMat)) { |
| | | apiLogService.save("MES下发入库通知单", "/open/asrs/comb/v1", "null", "10.10.10.1", |
| | | "托盘码:" + combParam.getBarcode(), |
| | | response, bool); |
| | | }else { |
| | | } else { |
| | | apiLogService.save("MES下发入库通知单", "/open/asrs/comb/v1", "null", "10.10.10.1", |
| | | "托盘码:" + combParam.getBarcode() + "、物料编号:" + combMat.getMatnr() + "、数量:" + combMat.getAnfme(), |
| | | response, bool); |
| | |
| | | public List<ViewWorkInBean> inlogERP() { |
| | | List<ViewWorkInBean> viewWorkInERP = reportQueryMapper.getViewWorkInERP(); |
| | | ArrayList<ViewWorkInBean> viewWorkInBeans = new ArrayList<>(); |
| | | for (ViewWorkInBean viewWorkInBean:viewWorkInERP){ |
| | | for (ViewWorkInBean viewWorkInBean : viewWorkInERP) { |
| | | viewWorkInBean.sype(); |
| | | viewWorkInBeans.add(viewWorkInBean); |
| | | } |
| | |
| | | public List<ViewWorkInBean> outlogERP() { |
| | | List<ViewWorkInBean> viewWorkInERP = reportQueryMapper.getViewWorkOutERP(); |
| | | ArrayList<ViewWorkInBean> viewWorkInBeans = new ArrayList<>(); |
| | | for (ViewWorkInBean viewWorkInBean:viewWorkInERP){ |
| | | for (ViewWorkInBean viewWorkInBean : viewWorkInERP) { |
| | | viewWorkInBean.sype(); |
| | | viewWorkInBeans.add(viewWorkInBean); |
| | | } |
| | |
| | | Date now = new Date(); |
| | | Mat mat = matService.selectByMatnr(param.getCinvcode()); |
| | | boolean update = true; |
| | | if(Cools.isEmpty(matService.selectByMatnr(param.getCinvcode()))){ |
| | | if (Cools.isEmpty(matService.selectByMatnr(param.getCinvcode()))) { |
| | | //物料号 |
| | | mat = new Mat(); |
| | | mat.setMatnr(param.getCinvcode()); |
| | |
| | | |
| | | mat.setUpdateTime(now); |
| | | |
| | | if(update){ |
| | | if (matService.updateById(mat)){ |
| | | if (update) { |
| | | if (matService.updateById(mat)) { |
| | | callApiLogSave(param, "/open/asrs/mat/v1", "接收ERP下发商品信息成功!添加商品信息成功!", true); |
| | | param.setUpdate(true); |
| | | } else { |
| | |
| | | param.setError(true); |
| | | param.setMemo("添加ERP下发商品信息失败!"); |
| | | } |
| | | }else { |
| | | } else { |
| | | if (matService.insert(mat)) { |
| | | callApiLogSave(param, "/open/asrs/mat/v1", "接收ERP下发商品信息成功!添加商品信息成功!", true); |
| | | param.setInsert(true); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | return true; |
| | | } |
| | | |
| | | @Transactional |
| | | public boolean syncOrder(OrderSyncParam param, boolean pakin, String docName) { |
| | | if(Cools.isEmpty(param) || Cools.isEmpty(param.getChildren())){ |
| | | if (Cools.isEmpty(param) || Cools.isEmpty(param.getChildren())) { |
| | | callApiLogSave(param, "/order/pakout/default/v1", "接受单据失败,单据参数为空或者单据详情为空,无法生成单据信息", false); |
| | | throw new CoolException("单据参数为空或者单据详情为空,无法生成单据信息"); |
| | | } |
| | | |
| | | Order orderOld = null; |
| | | |
| | | if(!Cools.isEmpty(orderService.selectByNo(param.getCPOID()))){ |
| | | if (!Cools.isEmpty(orderService.selectByNo(param.getCPOID()))) { |
| | | |
| | | orderOld = orderService.selectByNo(param.getCPOID()); |
| | | if(orderOld.getSettle() > 1){ |
| | | if (orderOld.getSettle() > 1) { |
| | | throw new CoolException("该单据已在作业中,无法更改单据信息"); |
| | | } |
| | | |
| | |
| | | //throw new CoolException("该单据已存在,无法生成单据信息"); |
| | | } |
| | | List<OrderSyncParam.OrderDetl> collect = param.getChildren().stream().distinct().collect(Collectors.toList()); |
| | | if (collect.size()!= param.getChildren().size()){ |
| | | if (collect.size() != param.getChildren().size()) { |
| | | callApiLogSave(param, "/order/pakout/default/v1", "接受单据失败,单据明细重复,无法生成单据信息", false); |
| | | throw new CoolException("接受单据失败,单据明细重复,无法生成单据信息"); |
| | | } |
| | | Date now = new Date(); |
| | | Order order = orderMapping(param,now,pakin,docName); |
| | | Order order = orderMapping(param, now, pakin, docName); |
| | | orderService.insert(order); |
| | | param.getChildren().forEach(od -> { |
| | | OrderDetl orderDetl = orderDetlMapping(order,od,now); |
| | | OrderDetl orderDetl = orderDetlMapping(order, od, now); |
| | | orderDetlService.insert(orderDetl); |
| | | }); |
| | | |
| | | if(!Cools.isEmpty(orderOld)){ |
| | | if (!Cools.isEmpty(orderOld)) { |
| | | //删除原有单据信息 |
| | | orderService.delete(new EntityWrapper<Order>().eq("id",orderOld.getId())); |
| | | orderDetlService.delete(new EntityWrapper<OrderDetl>().eq("order_id",orderOld.getId())); |
| | | orderService.delete(new EntityWrapper<Order>().eq("id", orderOld.getId())); |
| | | orderDetlService.delete(new EntityWrapper<OrderDetl>().eq("order_id", orderOld.getId())); |
| | | } |
| | | |
| | | callApiLogSave(param, "/order/pakout/default/v1", "接受单据成功", true); |
| | |
| | | @Transactional |
| | | public boolean orderDelete(String orderNo) { |
| | | Order order = orderService.selectByNo(orderNo); |
| | | if(Cools.isEmpty(order)){ |
| | | if (Cools.isEmpty(order)) { |
| | | throw new CoolException("单据不存在,无法删除单据"); |
| | | } |
| | | |
| | | if(order.getSettle() != 1){ |
| | | if (order.getSettle() != 1) { |
| | | return false; |
| | | } |
| | | |
| | | orderService.deleteById(order); |
| | | orderDetlService.delete(new EntityWrapper<OrderDetl>().eq("order_id",order.getId())); |
| | | orderDetlService.delete(new EntityWrapper<OrderDetl>().eq("order_id", order.getId())); |
| | | |
| | | return true; |
| | | } |
| | |
| | | |
| | | //判断库位是否存在 |
| | | AgvLocMast agvLocMast = agvLocMastService.selectById(params.getLocNo()); |
| | | if(Cools.isEmpty(agvLocMast)){ |
| | | if (Cools.isEmpty(agvLocMast)) { |
| | | throw new CoolException("库位号不存在"); |
| | | } |
| | | |
| | | if(!Cools.eq("O",agvLocMast.getLocSts()) && !Cools.eq("F",agvLocMast.getLocSts())){ |
| | | if (!Cools.eq("O", agvLocMast.getLocSts()) && !Cools.eq("F", agvLocMast.getLocSts())) { |
| | | throw new CoolException("当前库位正在作业中,无法盘点调整"); |
| | | } |
| | | |
| | | if(Cools.isEmpty(params.getLocDetls())){ |
| | | if (Cools.isEmpty(params.getLocDetls())) { |
| | | agvLocMast.setLocSts("O"); |
| | | }else { |
| | | } else { |
| | | agvLocMast.setLocSts("F"); |
| | | } |
| | | |
| | | agvLocMastService.updateById(agvLocMast); |
| | | |
| | | //删除旧库存 |
| | | agvLocDetlService.delete(new EntityWrapper<AgvLocDetl>().eq("loc_no",params.getLocNo())); |
| | | agvLocDetlService.delete(new EntityWrapper<AgvLocDetl>().eq("loc_no", params.getLocNo())); |
| | | |
| | | //新增盘点库存 |
| | | for (DetlDto detlDto : params.getLocDetls()){ |
| | | for (DetlDto detlDto : params.getLocDetls()) { |
| | | AgvLocDetl agvLocDetl = new AgvLocDetl(); |
| | | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | | BeanUtils.copyProperties(mat,agvLocDetl); |
| | | BeanUtils.copyProperties(mat, agvLocDetl); |
| | | agvLocDetl.setLocNo(params.getLocNo()); |
| | | agvLocDetl.setSuppCode(params.getContainerCode()); |
| | | agvLocDetl.setAnfme(detlDto.getAnfme()); |
| | |
| | | return true; |
| | | } |
| | | |
| | | private Order orderMapping(OrderSyncParam param, Date now, boolean pakin, String docName){ |
| | | private Order orderMapping(OrderSyncParam param, Date now, boolean pakin, String docName) { |
| | | Order order = new Order(); |
| | | //uuid |
| | | order.setUuid(String.valueOf(snowflakeIdWorker.nextId())); |
| | |
| | | return order; |
| | | } |
| | | |
| | | private OrderDetl orderDetlMapping(Order order, OrderSyncParam.OrderDetl odParam, Date now){ |
| | | private OrderDetl orderDetlMapping(Order order, OrderSyncParam.OrderDetl odParam, Date now) { |
| | | |
| | | Mat mat = matService.selectByMatnr(odParam.getCInvCode()); |
| | | if(Cools.isEmpty(mat)){ |
| | | if (Cools.isEmpty(mat)) { |
| | | throw new CoolException("存货编码:" + odParam.getCInvCode() + "不存在,请先同步存货档案"); |
| | | } |
| | | |
| | |
| | | //销售订单号 |
| | | od.setThreeCode(odParam.getCDefine22()); |
| | | //自由项 |
| | | od.setBatch(odParam.getBFree1()); |
| | | od.setBatch(Cools.isEmpty(odParam.getBatch()) ? "" : odParam.getBatch() + "__" + (Cools.isEmpty(odParam.getBFree1()) ? "" : odParam.getBFree1())); |
| | | //IDs |
| | | od.setSku(odParam.getId()); |
| | | |
| | |
| | | return od; |
| | | } |
| | | |
| | | private String toString(Object o){ |
| | | if(StringUtils.isEmpty(o)){ |
| | | private String toString(Object o) { |
| | | if (StringUtils.isEmpty(o)) { |
| | | return null; |
| | | }else{ |
| | | } else { |
| | | return o.toString(); |
| | | } |
| | | } |
| | |
| | | |
| | | public static void main(String[] args) { |
| | | Object s = null; |
| | | if(StringUtils.isEmpty(s)){ |
| | | if (StringUtils.isEmpty(s)) { |
| | | System.out.println("null"); |
| | | }else { |
| | | } else { |
| | | System.out.println(s.toString()); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public OrderDetl selectItem(String orderNo, String matnr, String threeCode) { |
| | | return this.baseMapper.selectItemByOrderNo2(orderNo, matnr, threeCode); |
| | | public OrderDetl selectItem(String orderNo, String matnr,String batch, String threeCode) { |
| | | return this.baseMapper.selectItemByOrderNo2(orderNo, matnr, batch, threeCode); |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Transactional |
| | | public void timelyStart(Order order) { |
| | | |
| | | List<String> docNames = new ArrayList<>(Arrays.asList("银座采购入库单", "银座委外材料出库单")); |
| | | List<String> docNames = new ArrayList<>(Arrays.asList("银座采购入库单", "银座委外材料出库单","其他入库单","其他出库单")); |
| | | |
| | | DocType docType = docTypeService.selectById(order.getDocType()); |
| | | if (docNames.contains(docType.getDocName())) { |
| | |
| | | childInfo.setIrowno(orderDetl.getItemNum()); |
| | | childInfo.setCInvCode(orderDetl.getMatnr()); |
| | | childInfo.setIQuantity(orderDetl.getQty() - (orderDetl.getReportQty() == null ? 0D : orderDetl.getReportQty()) + ""); |
| | | childInfo.setCBatch(orderDetl.getBatch()); |
| | | String batch = orderDetl.getBatch(); |
| | | if (Cools.isEmpty(batch)) { |
| | | childInfo.setCBatch(""); |
| | | childInfo.setBFree1(""); |
| | | } else { |
| | | String[] s = batch.split("__"); |
| | | if (s.length > 1) { |
| | | childInfo.setCBatch(s[0]); |
| | | childInfo.setBFree1(s[1]); |
| | | } else { |
| | | childInfo.setCBatch(s[0]); |
| | | childInfo.setBFree1(""); |
| | | } |
| | | } |
| | | childInfo.setINum(orderDetl.getLength() + ""); |
| | | childInfo.setIinvexchrate(""); |
| | | childInfo.setBFree1(orderDetl.getDeadTime()); |
| | | childInfo.setIPOsID(orderDetl.getSku()); |
| | | childInfo.setCOrderCode(orderDetl.getOrderNo()); |
| | | childInfo.setIvouchrowno(orderDetl.getItemNum()); |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | private int doHttpRequest(Object requestParam, String namespace, String url, String path, String appkey, String ip) { |
| | | String response = ""; |
| | |
| | | success = true; |
| | | return code; |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | log.error("报错信息:{},{}", e.getMessage(), JSON.toJSONString(requestParam)); |
| | | throw new CoolException("调用接口响应错误"); |
| | | } finally { |
| | | apiLogService.save(namespace, url + path, appkey, ip, JSON.toJSONString(JSONObject.toJSONString(requestParam)), response, success); |
| | |
| | | where 1=1 |
| | | and order_no = #{orderNo} |
| | | and matnr = #{matnr} |
| | | <choose> |
| | | <when test="batch != null and batch != ''"> |
| | | and batch = #{batch} |
| | | </when> |
| | | <otherwise> |
| | | and (batch IS NULL OR batch = '') |
| | | </otherwise> |
| | | </choose> |
| | | <if test="threeCode!=null and threeCode!='' "> |
| | | and three_code = #{threeCode} |
| | | </if> |