#
taisheng
3 天以前 bc48a855d98e360042a7e2fff5594a91a82578c6
src/main/java/com/zy/asrs/controller/OpenController.java
@@ -12,9 +12,11 @@
import com.zy.asrs.entity.param.*;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.Utils;
import com.zy.common.utils.HttpHandler;
import com.zy.common.web.BaseController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
@@ -48,6 +50,11 @@
    @Autowired
    private BasCrnErrorService basCrnErrorService;
    @Value("${agv.url}")
    private String agvUrl;
    @Value("${agv.bindPodAndBerth}")
    private String bindPodAndBerth;
    private static final boolean auth = true;
    public static final ArrayList<String> APP_KEY_LIST = new ArrayList<String>() {{
@@ -65,8 +72,46 @@
            return R.error("任务不存在");
        }
        if (taskWrk.getTargetPoint().equals("0900601")) {
            HashMap<String, Object> requestParam = new HashMap<>();
            int nextInt = new Random().nextInt(100);
            requestParam.put("reqCode", taskWrk.getTaskNo() + "-" + nextInt);
            requestParam.put("podCode", param.get("podCode"));
            requestParam.put("positionCode", taskWrk.getTargetPoint());
            requestParam.put("indBind", 0);
            String response = null;
            boolean requestStatus = false;
            try {
                log.info("WCS解绑AGV货架={}", taskWrk);
                response = new HttpHandler.Builder()
                        .setUri(agvUrl)
                        .setPath(bindPodAndBerth)
                        .setJson(JSON.toJSONString(requestParam))
                        .build()
                        .doPost();
                JSONObject jsonObject = JSON.parseObject(response);
                if (jsonObject.get("code").equals("0")) {
                    requestStatus = true;
                }
            } catch (Exception e) {
                log.error("WCS派发任务给AGV失败{},返回值={}", taskWrk, response);
            } finally {
                apiLogService.save("WCS派发任务给AGV"
                        , agvUrl + bindPodAndBerth
                        , null
                        , "127.0.0.1"
                        , JSON.toJSONString(requestParam)
                        , response
                        , requestStatus
                );
            }
        }
        taskWrk.setStatus(TaskStatusType.COMPLETE.id);
        taskWrk.setModiTime(new Date());
        taskWrk.setBarcode(param.get("podCode").toString());
        taskWrkService.updateById(taskWrk);
        return R.ok();
    }