| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.core.annotations.AppAuth; |
| | | import com.core.common.*; |
| | | import com.core.exception.CoolException; |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @PostMapping("/order/pakout/new/default/v1") |
| | | @AppAuth(memo = "添加订单出库") |
| | | public synchronized R pakoutOrderCreate(@RequestHeader(required = false) String appkey, |
| | | @RequestBody OpenOrderPakoutParam param, |
| | | HttpServletRequest request) { |
| | | public synchronized R pakoutOrderCreate( |
| | | @RequestBody HashMap<String , Object> map |
| | | ) { |
| | | // auth(appkey, param, request); |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | String toJSONString = JSONObject.toJSONString(map.get("data")); |
| | | List<OpenOrderPakoutParam> openOrderPakoutParams=JSON.parseArray(toJSONString,OpenOrderPakoutParam.class); |
| | | int i=1; |
| | | for (OpenOrderPakoutParam param: openOrderPakoutParams){ |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | if (Cools.isEmpty(param.getOrderNo())) { |
| | | return R.error("单据编号[orderNo]不能为空"); |
| | | } |
| | | System.out.println(i+"-------------------------------"+param.getOrderNo()); |
| | | i++; |
| | | if (Cools.isEmpty(param.getOrderType())) { |
| | | return R.error("单据类型[orderType]不能为空"); |
| | | } |
| | | if (Cools.isEmpty(param.getOrderDetails())) { |
| | | return R.error("单据明细[orderDetails]不能为空"); |
| | | } |
| | | openService.pakoutOrderCreate(param); |
| | | } |
| | | if (Cools.isEmpty(param.getOrderNo())) { |
| | | return R.error("单据编号[orderNo]不能为空"); |
| | | } |
| | | if (Cools.isEmpty(param.getOrderType())) { |
| | | return R.error("单据类型[orderType]不能为空"); |
| | | } |
| | | if (Cools.isEmpty(param.getOrderDetails())) { |
| | | return R.error("单据明细[orderDetails]不能为空"); |
| | | } |
| | | openService.pakoutOrderCreate(param); |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | List<DetlDto> list = new ArrayList<>(); |
| | | List<DetlDto> orderDetails = param.getOrderDetails(); |
| | | for (DetlDto detail : orderDetails) { |
| | | DetlDto dto = new DetlDto(detail.getMatnr(), detail.getBatch(), detail.getAnfme()); |
| | | DetlDto dto = new DetlDto(detail.getMatnr(),detail.getMaktx(), detail.getBatch(), detail.getAnfme()); |
| | | if (DetlDto.has(list, dto)) { |
| | | DetlDto detlDto = DetlDto.find(list, dto.getMatnr(), dto.getBatch()); |
| | | assert detlDto != null; |
| | |
| | | for (DetlDto detlDto : list) { |
| | | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | | throw new CoolException(detlDto.getMatnr() + "编号商品检索失败,请先添加商品"); |
| | | Mat mat1=new Mat(); |
| | | mat1.setTagId(1L); |
| | | mat1.setMatnr(detlDto.getMatnr()); |
| | | mat1.setMaktx(detlDto.getMaktx()); |
| | | mat1.setMatType(3); |
| | | matService.insert(mat1); |
| | | } |
| | | OrderDetl orderDetl = new OrderDetl(); |
| | | orderDetl.sync(mat); |
| | | // orderDetl.sync(mat); |
| | | orderDetl.setMatnr(detlDto.getMatnr()); |
| | | orderDetl.setMaktx(detlDto.getMaktx()); |
| | | orderDetl.setBatch(detlDto.getBatch()); |
| | | orderDetl.setAnfme(detlDto.getAnfme()); |
| | | orderDetl.setOrderId(order.getId()); |
| | |
| | | wrkMast.setIoType(101); |
| | | wrkMast.setWrkSts(17L); |
| | | wrkMast.setMemo("捡料转全板工作档"); |
| | | wrkMastService.update(wrkMast, new EntityWrapper<WrkMast>() |
| | | .eq("wrk_no", wrkMast.getWrkNo())); |
| | | List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()); |
| | | List<LocDetl> locDetls = locDetlService.selectByLocNo(wrkMast.getSourceLocNo()); |
| | | for (LocDetl locDetl : locDetls) { |
| | |
| | | } |
| | | } |
| | | locMastService.updateLocSts(wrkMast.getSourceLocNo(), "R"); |
| | | wrkMastService.update(wrkMast, new EntityWrapper<WrkMast>() |
| | | .eq("wrk_no", wrkMast.getWrkNo())); |
| | | } |
| | | |
| | | |
| | |
| | | mat1.setMatnr(orderResult.getItemNo()); |
| | | mat1.setMaktx(orderResult.getItemName()); |
| | | mat1.setSpecs(orderResult.getItemSpec()); |
| | | mat1.setMatType(3); |
| | | matService.insert(mat1); |
| | | // throw new CoolException(orderResult.getItemNo() + "编号商品检索失败,请先添加商品"); |
| | | } |
| | |
| | | if(wrkDetls!=null&&wrkDetls.size()>0){ |
| | | List<LinkedHashMap<String,Object>> datas=new ArrayList<>(); |
| | | for(WrkDetl wrkDetl:wrkDetls){ |
| | | if(Cools.isEmpty(wrkDetl.getOrderNo())){ |
| | | continue; |
| | | } |
| | | OrderDetl orderDetl= orderDetlService.selectItem(wrkDetl.getOrderNo(),wrkDetl.getMatnr(),wrkDetl.getBatch()); |
| | | if(orderDetl==null){ |
| | | log.error("orderNo={},matnr={},batch={},没有查询到订单明细",wrkDetl.getOrderNo(),wrkDetl.getMatnr(),wrkDetl.getBatch()); |
| | |
| | | } |
| | | DocType docType = docTypeService.selectById(order.getDocType());//单据编号 |
| | | LinkedHashMap<String,Object> map=new LinkedHashMap<>(); |
| | | map.put("orgNo",orderDetl.getManu());//组织编码 |
| | | if(wrkMast.getIoType()<50){ |
| | | map.put("orgNo",orderDetl.getManu());//组织编码 |
| | | map.put("docType",docType.getMemo()); |
| | | map.put("cellNo",orderDetl.getBrand()); |
| | | }else{ |
| | | map.put("orgNo","2");//组织编码 |
| | | int i = orderDetl.getOrderNo().indexOf("5D"); |
| | | if(i!=-1){ |
| | | map.put("docType","B064"); |
| | | }else{ |
| | | map.put("docType","D001"); |
| | | } |
| | | map.put("cellNo","L01A20"); |
| | | } |
| | | |
| | | map.put("docNo",orderDetl.getOrderNo()); |
| | | map.put("docType",docType.getMemo()); |
| | | map.put("docSeqNo",orderDetl.getModel()); |
| | | map.put("itemNo",orderDetl.getMatnr()); |
| | | map.put("qty",wrkDetl.getAnfme()); |
| | | map.put("unitNo",orderDetl.getUnit()); |
| | | map.put("warehouseNo","02201"); |
| | | map.put("cellNo",orderDetl.getBrand()); |
| | | |
| | | map.put("combinationLotNo",String.valueOf(orderDetl.getBatch())); |
| | | map.put("barcode",wrkDetl.getMatnr()); |
| | | datas.add(map); |
| | | } |
| | | String path= ""; |
| | | String work= ""; |
| | | if(wrkMast.getIoType()<100){ |
| | | if(wrkMast.getIoType()<50){ |
| | | path=inReportAddress; |
| | | work="入库"; |
| | | }else{ |
| | |
| | | path=outReportAddress; |
| | | HashMap<String,Object> map=new HashMap<>(); |
| | | map.put("data",datas); |
| | | System.out.println(map.toString()); |
| | | //上报ERP |
| | | String response = ""; |
| | | boolean success = false; |
| | |
| | | |
| | | private String matnr; |
| | | |
| | | private String maktx; |
| | | |
| | | private String batch; |
| | | |
| | | private Double anfme; |
| | |
| | | this.batch = batch; |
| | | this.anfme = anfme; |
| | | } |
| | | public DetlDto(String matnr,String maktx, String batch, Double anfme) { |
| | | this.matnr = matnr; |
| | | this.maktx = maktx; |
| | | this.batch = batch; |
| | | this.anfme = anfme; |
| | | } |
| | | |
| | | public DetlDto(String matnr, String batch, Double anfme,Long owner) { |
| | | this.matnr = matnr; |
| | |
| | | } |
| | | |
| | | |
| | | public DetlDto(String orderNo, String matnr, String batch, Double anfme) { |
| | | this.orderNo = orderNo; |
| | | this.matnr = matnr; |
| | | this.batch = batch; |
| | | this.anfme = anfme; |
| | | } |
| | | // public DetlDto(String orderNo, String matnr, String batch, Double anfme) { |
| | | // this.orderNo = orderNo; |
| | | // this.matnr = matnr; |
| | | // this.batch = batch; |
| | | // this.anfme = anfme; |
| | | // } |
| | | |
| | | public DetlDto(String matnr, String batch, Double anfme, String memo, String cstmr) { |
| | | this.matnr = matnr; |