| | |
| | | import zy.cloud.wms.common.model.BillDto; |
| | | import zy.cloud.wms.common.service.erp.entity.UploadBill; |
| | | import zy.cloud.wms.common.service.erp.entity.UploadBillDetail; |
| | | import zy.cloud.wms.manager.entity.DocLog; |
| | | import zy.cloud.wms.manager.entity.DocType; |
| | | import zy.cloud.wms.manager.entity.Mat; |
| | | import zy.cloud.wms.manager.entity.RequestLog; |
| | | import zy.cloud.wms.manager.service.DocLogService; |
| | | import zy.cloud.wms.manager.service.DocTypeService; |
| | | import zy.cloud.wms.manager.service.MatService; |
| | | import zy.cloud.wms.manager.service.RequestLogService; |
| | |
| | | private MatService matService; |
| | | @Autowired |
| | | private RequestLogService requestLogService; |
| | | @Autowired |
| | | private DocLogService docLogService; |
| | | |
| | | /** |
| | | * 单据上报 |
| | | */ |
| | | public Boolean uploadBill(List<BillDto> dtos, Integer docId, String docNumber){ |
| | | public ErpR uploadBill(List<BillDto> dtos, Integer docId, String docNumber){ |
| | | try { |
| | | Date now = new Date(); |
| | | 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); |
| | | } |
| | | |
| | | // 日志 |
| | | List<DocLog> docLogs = new ArrayList<>(); |
| | | |
| | | UploadBill uploadBill = new UploadBill(); |
| | | uploadBill.setNumber(docNumber); |
| | |
| | | detl.setPrice(0); |
| | | detl.setUnit(mat==null?"暂无":mat.getUnit()); |
| | | detail.add(detl); |
| | | |
| | | // 日志 |
| | | docLogs.add(new DocLog( |
| | | docNumber, // 单据编号 |
| | | docId.longValue(), // 单据类型 |
| | | null, // 单据名称 |
| | | dto.getMatnr(), // 商品编号 |
| | | dto.getQty(), // 上报数量 |
| | | 1, // 结果 |
| | | now, // 上报时间 |
| | | null // 备注 |
| | | )); |
| | | } |
| | | System.out.println(JSON.toJSONString(uploadBill)); |
| | | log.warn(JSON.toJSONString(uploadBill)); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(ErpScheduler.URI) |
| | | .setPath(ErpScheduler.UPLOAD_BILL) |
| | |
| | | .doPost(); |
| | | |
| | | try { |
| | | for (DocLog docLog : docLogs) { |
| | | docLogService.insert(docLog); |
| | | } |
| | | |
| | | // 日志记录 |
| | | RequestLog logInfo = new RequestLog(); |
| | | logInfo.setName("单据上传,单据类型" + docId.toString()); |
| | | logInfo.setName("单据上传,单据类型" + docId); |
| | | logInfo.setRequest(JSON.toJSONString(uploadBill)); // 入参 |
| | | logInfo.setResponse(response); // 出参 |
| | | logInfo.setCreateTime(new Date()); |
| | |
| | | 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); |
| | | } |
| | | |
| | | |