| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | |
| | | import com.zy.asrs.utils.OrderInAndOutUtil; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.common.utils.NodeUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.rmi.CORBA.Util; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * Created by vincent on 2022/4/9 |
| | |
| | | private BasAgvMastService basAgvMastService; |
| | | @Autowired |
| | | private LocOwnerService locOwnerService; |
| | | |
| | | @Autowired |
| | | private ApiLogService apiLogService; |
| | | @Value("${wms.url}") |
| | | private String wmsUrl; |
| | | @Override |
| | | @Transactional |
| | | public void pakinOrderCreate(OpenOrderPakinParam param) { |
| | |
| | | } |
| | | |
| | | for(MatSyncParam.MatParam matParam : param.getMatDetails()){ |
| | | if(Cools.isEmpty(matParam.getMatnr())){ |
| | | if(Cools.isEmpty(matParam.getMatNr())){ |
| | | throw new CoolException("商品编码不能为空"); |
| | | } |
| | | |
| | | Date now = new Date(); |
| | | Mat mat = matService.selectByMatnr(matParam.getMatnr()); |
| | | Mat mat = matService.selectByMatnr(matParam.getMatNr()); |
| | | if (mat == null) { |
| | | mat = new Mat(); |
| | | // 分类 |
| | |
| | | } |
| | | } else { |
| | | mat.sync(matParam); |
| | | if (!matService.update(mat, new EntityWrapper<Mat>().eq("matnr",matParam.getMatnr()))) { |
| | | if (!matService.update(mat, new EntityWrapper<Mat>().eq("matnr",matParam.getMatNr()))) { |
| | | throw new CoolException("更新已存在商品信息失败,请联系管理员"); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public boolean reportTaskStatus(String taskNo, Integer status, Integer ioType, String barcode) { |
| | | try { |
| | | TaskStatusFeedbackParam param = new TaskStatusFeedbackParam(); |
| | | param.setTaskNo(taskNo); |
| | | param.setStatus(status); |
| | | param.setIoType(ioType); |
| | | param.setBarcode(barcode); |
| | | param.setReportTime(new Date()); |
| | | |
| | | Map<String, Object> headers = new HashMap<>(); |
| | | headers.put("appkey", "ea1f0459efc02a79f046f982767939ae"); |
| | | |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath("/taskStatusFeedback") |
| | | .setJson(JSON.toJSONString(param)) |
| | | .setHeaders(headers) |
| | | .build() |
| | | .doPost(); |
| | | |
| | | boolean success = false; |
| | | log.info("任务状态反馈上报结果:{}", response); |
| | | if (response != null) { |
| | | try { |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | // 假设返回code为200表示成功 |
| | | if (jsonObject != null && jsonObject.containsKey("code") && jsonObject.getInteger("code") == 200) { |
| | | success = true; |
| | | } |
| | | } catch (Exception e) { |
| | | log.warn("解析响应失败", e); |
| | | } |
| | | } |
| | | |
| | | // 记录日志 |
| | | try { |
| | | apiLogService.save("任务状态反馈上报", |
| | | "/taskStatusFeedback", |
| | | "ea1f0459efc02a79f046f982767939ae", |
| | | wmsUrl, |
| | | JSON.toJSONString(param), |
| | | response, |
| | | success); |
| | | } catch (Exception e) { |
| | | log.error("保存API日志异常", e); |
| | | } |
| | | |
| | | return success; |
| | | } catch (Exception e) { |
| | | log.error("任务状态反馈上报异常", e); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |