| | |
| | | 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.service.OrderDetlService; |
| | | import com.zy.asrs.service.OrderService; |
| | | |
| | | import com.zy.asrs.service.impl.MatServiceImpl; |
| | | 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 javax.swing.text.DateFormatter; |
| | | 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") |
| | |
| | | * @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()))) { |