New file |
| | |
| | | package zy.cloud.wms.common.service.erp; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * Created by vincent on 2021/6/29 |
| | | */ |
| | | @Data |
| | | public class ErpR { |
| | | |
| | | private Boolean success; |
| | | |
| | | private String msg; |
| | | |
| | | public ErpR() { |
| | | } |
| | | |
| | | public ErpR(Boolean success, String msg) { |
| | | this.success = success; |
| | | this.msg = msg; |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 单据上报 |
| | | */ |
| | | public Boolean uploadBill(List<BillDto> dtos, Integer docId, String docNumber){ |
| | | public ErpR uploadBill(List<BillDto> dtos, Integer docId, String docNumber){ |
| | | try { |
| | | if (Cools.isEmpty(dtos)) { |
| | | return false; |
| | | return new ErpR(false, null); |
| | | } |
| | | DocType docType = docTypeService.selectById(docId); |
| | | if (Cools.isEmpty(docType)) { |
| | | return false; |
| | | return new ErpR(false, null); |
| | | } |
| | | |
| | | UploadBill uploadBill = new UploadBill(); |
| | |
| | | log.warn(response); |
| | | Result result = JSON.parseObject(response, Result.class); |
| | | if (result.getCode() != 1) { |
| | | return false; |
| | | return new ErpR(false, result.getMsg()); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return false; |
| | | return new ErpR(false, e.getMessage()); |
| | | } |
| | | return Boolean.TRUE; |
| | | return new ErpR(true, null); |
| | | } |
| | | |
| | | |
| | |
| | | res.setMatnr(executeData.getMatnr()); |
| | | res.setQty(executeData.getQty()); |
| | | dtos.add(res); |
| | | if (erpService.uploadBill(dtos, docId, docNum)) { |
| | | if (erpService.uploadBill(dtos, docId, docNum).getSuccess()) { |
| | | // 成功后删除任务 |
| | | if (!wrkLocSyncService.delete(new EntityWrapper<WrkLocSync>().eq("matnr", executeData.getMatnr()))) { |
| | | log.info("库存同步删除任务失败,任务matnr=" + executeData.getMatnr() + "时间=" + new Date()); |
| | |
| | | |
| | | @PostMapping("/erp/upload") |
| | | public R erpUpload(@RequestBody ErpUpload erpUpload){ |
| | | Boolean result = erpService.uploadBill(erpUpload.getDtos(), erpUpload.getDocId(), erpUpload.getDocNumber()); |
| | | Boolean result = erpService.uploadBill(erpUpload.getDtos(), erpUpload.getDocId(), erpUpload.getDocNumber()).getSuccess(); |
| | | return result ? R.ok() : R.error(); |
| | | } |
| | | |
| | |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import zy.cloud.wms.common.model.BillDto; |
| | | import zy.cloud.wms.common.service.erp.ErpR; |
| | | import zy.cloud.wms.common.service.erp.ErpService; |
| | | import zy.cloud.wms.common.web.BaseController; |
| | | import zy.cloud.wms.manager.entity.*; |
| | |
| | | throw new CoolException("数据异常"); |
| | | } |
| | | // erp上传盘盈盘亏 |
| | | if (!erpService.uploadBill(dtos, docId, docNum)) { |
| | | throw new CoolException("无法上报至erp"); |
| | | ErpR erpR = erpService.uploadBill(dtos, docId, docNum); |
| | | if (!erpR.getSuccess()) { |
| | | throw new CoolException("无法上报至erp:"+erpR.getMsg()); |
| | | } |
| | | String dotsStr = JSON.toJSONString(dtos); |
| | | log.info("盘点上传,类型:" + (docId == 14 ? "盘盈" : "盘亏") + ",单号:" + docNum + ",上传物料清单:" + dotsStr); |
| | |
| | | import zy.cloud.wms.common.service.MainService; |
| | | import zy.cloud.wms.common.service.asrs.AsrsService; |
| | | import zy.cloud.wms.common.service.asrs.entity.Result1; |
| | | import zy.cloud.wms.common.service.erp.ErpR; |
| | | import zy.cloud.wms.common.service.erp.ErpService; |
| | | import zy.cloud.wms.common.utils.VersionUtils; |
| | | import zy.cloud.wms.manager.entity.*; |
| | |
| | | billDto.setQty(dto.getCount()); |
| | | dtos.add(billDto); |
| | | } |
| | | if (!erpService.uploadBill(dtos, docId, docNum)) { |
| | | throw new CoolException("无法上报至erp"); |
| | | ErpR erpR = erpService.uploadBill(dtos, docId, docNum); |
| | | if (!erpR.getSuccess()) { |
| | | throw new CoolException("无法上报至erp:"+erpR.getMsg()); |
| | | } |
| | | |
| | | return R.ok("入库成功"); |
| | |
| | | billDto.setQty(comb.getAnfme()); |
| | | dtos.add(billDto); |
| | | } |
| | | if (!erpService.uploadBill(dtos, param.getDocType(), docNum)) { |
| | | throw new CoolException("无法上报至erp"); |
| | | ErpR erpR = erpService.uploadBill(dtos, param.getDocType(), docNum); |
| | | if (!erpR.getSuccess()) { |
| | | throw new CoolException("无法上报至erp:"+erpR.getMsg()); |
| | | } |
| | | return R.ok(); |
| | | } |
| | |
| | | billDto.setMatnr(check.getMatnr()); |
| | | billDto.setQty(Math.abs(check.getDiffQty())); |
| | | dtos.add(billDto); |
| | | if (!erpService.uploadBill(dtos, docId.intValue(), docNum)) { |
| | | throw new CoolException("无法上报至erp"); |
| | | ErpR erpR = erpService.uploadBill(dtos, docId.intValue(), docNum); |
| | | if (!erpR.getSuccess()) { |
| | | throw new CoolException("无法上报至erp:"+erpR.getMsg()); |
| | | } |
| | | return R.ok(); |
| | | } |