| | |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.api.entity.OrderParams; |
| | | import com.zy.api.entity.ReportOrderParam; |
| | | import com.zy.api.entity.PubOrderParams; |
| | | import com.zy.api.entity.ReportOrderParam; |
| | | import com.zy.api.entity.SyncMatParmas; |
| | | import com.zy.api.enums.MatLocType; |
| | | import com.zy.api.enums.MatType; |
| | | import com.zy.api.enums.OrderType; |
| | | import com.zy.api.enums.OrderWkType; |
| | | import com.zy.api.service.KopenApiService; |
| | |
| | | import com.zy.asrs.entity.OrderDetl; |
| | | import com.zy.asrs.enums.CommonEnum; |
| | | import com.zy.asrs.enums.OrderSettle; |
| | | import com.zy.asrs.service.MatService; |
| | | import com.zy.asrs.service.OrderDetlService; |
| | | import com.zy.asrs.service.OrderService; |
| | | |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.text.DateFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | @Service("kopenApiServiceImpl") |
| | |
| | | private OrderService orderService; |
| | | @Autowired |
| | | private OrderDetlService orderDetlService; |
| | | @Autowired |
| | | private MatService matService; |
| | | |
| | | /** |
| | | * 接收下发订单信息 |
| | |
| | | * @return com.core.common.R |
| | | */ |
| | | @Override |
| | | public R receiveOrders(OrderParams params) { |
| | | public R receiveOrders(PubOrderParams params) { |
| | | if (params.getType().equals(OrderWkType.getTypeVal(params.getType()))) { |
| | | return R.error("当前类型不是上架派工单!!"); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 上架派工单反馈 |
| | | * @author Ryan |
| | | * @date 2025/11/24 15:33 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R getInDispatchResult(ReportOrderParam params) { |
| | | if (Objects.isNull(params)) { |
| | | return R.error("参数不能为空!!"); |
| | | } |
| | | String response = null; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri("127.0.0.1:8081") |
| | | .setPath("/wms/order/getInDispatchResult") |
| | | .setJson(JSONObject.toJSONString(params)) |
| | | .build() |
| | | .doPost(); |
| | | if (Objects.isNull(response) || response.trim().isEmpty()) { |
| | | return R.error("外网接口无响应!!"); |
| | | } |
| | | JSONObject jsonObject = JSONObject.parseObject(response); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if (!Objects.isNull(code) && code.equals(1)) { |
| | | return R.ok("入库单上报完成!!"); |
| | | } else { |
| | | String msg = jsonObject.getString("message"); |
| | | return R.error(Objects.isNull(msg) ? "上报失败!!" : msg); |
| | | } |
| | | } catch (Exception e) { |
| | | return R.error(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 基础零件变更 |
| | | * |
| | | * @author Ryan |
| | | * @date 2025/11/24 15:05 |
| | | * @param matnrs |
| | | * @param params |
| | | * @return com.core.common.R |
| | | */ |
| | | @Override |
| | | public R basMatupdate(List<Mat> matnrs) { |
| | | return null; |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public synchronized R basMatupdate(SyncMatParmas params) { |
| | | if (Objects.isNull(params.getPro_komcode())) { |
| | | return R.error("零件编码不能为空!!"); |
| | | } |
| | | Mat matnr = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", params.getPro_komcode())); |
| | | if (!Objects.isNull(matnr)) { |
| | | // 订单时间 |
| | | if (Utils.isValidFormat(params.getUpdate_time(), "yyyy-MM-dd HH:mm:ss")) { |
| | | Date date1 = Utils.getFormateDate(params.getUpdate_time()); |
| | | matnr.setUpdateTime(date1); |
| | | } |
| | | matnr.setMaktx(params.getPro_name()); |
| | | matnr.setSpecs(params.getPro_size()); |
| | | matnr.setWeight(Double.parseDouble(params.getPro_wet())); |
| | | matnr.setSuppCode(params.getPro_id()); |
| | | matnr.setTagId(MatLocType.getTag(params.getPro_type())); |
| | | matnr.setManu(params.getCompany_id()); |
| | | if (!matService.updateById(matnr)) { |
| | | throw new CoolException("物料更新失败或无需更新!!"); |
| | | } |
| | | } else { |
| | | if (Objects.isNull(matnr)) { |
| | | matnr = new Mat(); |
| | | } |
| | | // 订单时间 |
| | | if (Utils.isValidFormat(params.getUpdate_time(), "yyyy-MM-dd HH:mm:ss")) { |
| | | Date date1 = Utils.getFormateDate(params.getUpdate_time()); |
| | | matnr.setUpdateTime(date1); |
| | | } |
| | | matnr.setMaktx(params.getPro_name()); |
| | | matnr.setMatnr(params.getPro_komcode()); |
| | | matnr.setSpecs(params.getPro_size()); |
| | | matnr.setWeight(Double.parseDouble(params.getPro_wet())); |
| | | matnr.setSuppCode(params.getPro_id()); |
| | | matnr.setTagId(MatLocType.getTag(params.getPro_type())); |
| | | matnr.setManu(params.getCompany_id()); |
| | | if (!matService.insert(matnr)) { |
| | | throw new CoolException("物料更新失败!!"); |
| | | } |
| | | } |
| | | return R.ok("保存成功!!"); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void addOrUpdateOrders(OrderParams params, String type) { |
| | | public void addOrUpdateOrders(PubOrderParams params, String type) { |
| | | if (Objects.isNull(params)) { |
| | | throw new CoolException("参数不能为空!!"); |
| | | } |
| | |
| | | * @param params |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void generateOrders(OrderParams params) { |
| | | public void generateOrders(PubOrderParams params) { |
| | | // 将数据当新订单插入 |
| | | Order newOrder = new Order(); |
| | | if (OrderType.ORDER_IN.type.equals(OrderWkType.getTypeVal(params.getType()))) { |
| | |
| | | newOrder.setNumber(params.getDispatch_no()); |
| | | // 箱号 |
| | | newOrder.setItemName(params.getPm_tktid()); |
| | | newOrder.setSettle(OrderSettle.ORDER_SETTLE_INIT.type); |
| | | newOrder.setSettle(OrderSettle.ORDER_SETTLE_HOLDING.type); |
| | | newOrder.setStatus(CommonEnum.COMMON_ENUM_Y.type); |
| | | // 订单时间 |
| | | newOrder.setOrderTime(DateUtils.convert(new Date(), "yyyy-MM-dd HH:mm:ss")); |
| | | if (Utils.isValidFormat(params.getUpdate_time(), "yyyy-MM-dd HH:mm:ss")) { |
| | | newOrder.setOrderTime(params.getUpdate_time()); |
| | | } |
| | | // 公司ID |
| | | newOrder.setCstmrName(params.getCompany_id()); |
| | | newOrder.setCreateTime(new Date()); |
| | |
| | | } |
| | | if (!Objects.isNull(params.getDetails()) && !params.getDetails().isEmpty()) { |
| | | params.getDetails().forEach(item -> { |
| | | Mat matnr = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", item.getPro_komcode())); |
| | | if (Objects.isNull(matnr)) { |
| | | throw new CoolException("物料编码不存在!!"); |
| | | } |
| | | OrderDetl orderItem = new OrderDetl(); |
| | | BeanUtils.copyProperties(item, orderItem); |
| | | BeanUtils.copyProperties(matnr, orderItem); |
| | | orderItem.setOrderId(newOrder.getId()); |
| | | orderItem.setOrderNo(newOrder.getOrderNo()); |
| | | orderItem.setAnfme(Math.round(item.getInv_qty() * 10000) / 10000.0); |
| | | orderItem.setMatnr(item.getPro_komcode()); |
| | | orderItem.setMatnr(matnr.getMatnr()); |
| | | orderItem.setMaktx(matnr.getMaktx()); |
| | | orderItem.setBrand(matnr.getBrand()); |
| | | orderItem.setBatch(1 + ""); |
| | | orderItem.setStandby1(item.getPro_id()); |
| | | //关联上加派工单号+零件代码+供应商代码 |