| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.SnowflakeIdWorker; |
| | | import com.core.exception.CoolException; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import zy.cloud.wms.common.service.erp.entity.GetBasisResult; |
| | | import zy.cloud.wms.common.service.erp.entity.GetOrderResult0; |
| | | import zy.cloud.wms.common.service.erp.entity.GetOrderResultDetl0; |
| | | import zy.cloud.wms.manager.entity.Cstmr; |
| | | import zy.cloud.wms.manager.entity.CustOrder; |
| | | import zy.cloud.wms.manager.entity.Mat; |
| | | import zy.cloud.wms.manager.entity.Tag; |
| | | import zy.cloud.wms.common.service.erp.entity.*; |
| | | import zy.cloud.wms.manager.entity.*; |
| | | import zy.cloud.wms.manager.mapper.CustOrderMapper; |
| | | import zy.cloud.wms.manager.mapper.TagMapper; |
| | | import zy.cloud.wms.manager.service.*; |
| | |
| | | private TagMapper tagMapper; |
| | | @Autowired |
| | | private CustOrderMapper custOrderMapper; |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | |
| | | /** |
| | | * 商品下载 |
| | |
| | | /** |
| | | * 持久化销售订单 |
| | | */ |
| | | @Scheduled(cron = "0/45 * * * * ? ") |
| | | @Scheduled(cron = "0/5 * * * * ? ") |
| | | @Transactional |
| | | // @PostConstruct |
| | | public void getOrdersExecute(){ |
| | |
| | | data.getETypeID(), // 经手人编号[非空] |
| | | detl0.getUserCode(), // 商品编号 |
| | | detl0.getQty(), // 商品数量 |
| | | detl0.getQty(), // 总数量 |
| | | detl0.getPrice(), // 商品单价 |
| | | detl0.getComment(), // 商品备注[非空] |
| | | 0, // 状态 |
| | |
| | | // 表体 |
| | | GetOrderResultDetl0 detl0 = new GetOrderResultDetl0(); |
| | | detl0.setUserCode(custOrder.getUserCode()); |
| | | detl0.setQty(custOrder.getQty()); |
| | | detl0.setQty(custOrder.getTotal()); |
| | | detl0.setPrice(custOrder.getPrice()); |
| | | detl0.setComment(custOrder.getComment()); |
| | | list.add(detl0); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 更新库存 |
| | | * 库存上传 |
| | | */ |
| | | // @Scheduled(cron = "0/3 * * * * ? ") |
| | | // @Scheduled(cron = "0/15 * * * * ? ") |
| | | @GetMapping("test2") |
| | | public void uploadStockExecute(){ |
| | | try { |
| | | |
| | | // locDetlService |
| | | |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("rec", 0); |
| | | param.put("Flag", 1); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(URI) |
| | | .setPath(GET_BASIS) |
| | | .setJson(JSON.toJSONString(param)) |
| | | .build() |
| | | .doPost(); |
| | | if (!Cools.isEmpty(response)) { |
| | | log.info(response); |
| | | Date now = new Date(); |
| | | Result result = JSON.parseObject(response, Result.class); |
| | | if (result.getCode() != 1) { |
| | | return; |
| | | } |
| | | List<GetBasisResult> list = JSON.parseArray(result.getData(), GetBasisResult.class); |
| | | for (GetBasisResult data : list) { |
| | | Mat mat = matService.selectByMatnr(data.getUserCode()); |
| | | String modifyDate = data.getModifyDate(); |
| | | Date updateTime = null; |
| | | if (!Cools.isEmpty(modifyDate)) { |
| | | updateTime = DateUtils.convert(data.getModifyDate()); |
| | | } |
| | | if (null == mat) { |
| | | mat = new Mat( |
| | | String.valueOf(data.getRec()), // 编号 |
| | | null, // 所属区域 |
| | | null, // 所属归类 |
| | | data.getUserCode(), // 商品编号 |
| | | data.getFullName(), // 商品名称 |
| | | null, // 名称 |
| | | null, // 规格 |
| | | null, // 型号 |
| | | null, // 批号 |
| | | null, // 单位 |
| | | null, // 条码 |
| | | null, // 单据类型 |
| | | null, // 单据编号 |
| | | null, // 客户名称 |
| | | null, // 品项数 |
| | | null, // 库存余量 |
| | | null, // 重量 |
| | | 1, // |
| | | null, // 添加人员 |
| | | now, // 添加时间 |
| | | null, // 修改人员 |
| | | updateTime, // 修改时间 |
| | | null // 备注 |
| | | ); |
| | | matService.insert(mat); |
| | | } else { |
| | | mat.setUuid(String.valueOf(data.getRec())); |
| | | mat.setMatnr(data.getUserCode()); |
| | | mat.setMaktx(data.getFullName()); |
| | | mat.setUpdateTime(updateTime); |
| | | matService.updateById(mat); |
| | | } |
| | | log.info("====>> 更新物料:{}", data.getUserCode()); |
| | | List<LocDetl> statis = locDetlService.getLocDetlStatis(); |
| | | if (!Cools.isEmpty(statis)) { |
| | | UploadStock uploadStock = new UploadStock(); |
| | | uploadStock.setNumber(String.valueOf(snowflakeIdWorker.nextId())); |
| | | uploadStock.setVchType(89); |
| | | uploadStock.setBillDate(DateUtils.convert(new Date(), DateUtils.yyyyMMdd_F)); |
| | | uploadStock.setDataSize(statis.size()); |
| | | List<UploadStockDtel> detail = new ArrayList<>(); |
| | | uploadStock.setDetail(detail); |
| | | for (LocDetl locDetl : statis) { |
| | | Mat mat = matService.selectByMatnr(locDetl.getMatnr()); |
| | | if (mat == null) {continue;} |
| | | UploadStockDtel detl = new UploadStockDtel(); |
| | | detl.setUserCode(mat.getMatnr()); |
| | | detl.setQty(locDetl.getAnfme()); |
| | | // detl.setPrice(Double.parseDouble()); |
| | | detl.setComment(mat.getMemo()); |
| | | detail.add(detl); |
| | | } |
| | | |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(URI) |
| | | .setPath(UPLOAD_STOCK) |
| | | .setJson(JSON.toJSONString(uploadStock)) |
| | | .build() |
| | | .doPost(); |
| | | if (!Cools.isEmpty(response)) { |
| | | log.info("上报库存明细统计 ======>> \nrequest:{} \nresponse:{}", JSON.toJSONString(uploadStock), response); |
| | | Result result = JSON.parseObject(response, Result.class); |
| | | if (result.getCode() != 1) { |
| | | } |
| | | } |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException(e.getMessage()); |
| | | } |
| | | |
| | | |