| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | |
| | | import com.zy.asrs.entity.AgvLocMast; |
| | | import com.zy.asrs.entity.AgvWrkMast; |
| | | import com.zy.asrs.entity.param.LocMastInitParam; |
| | | import com.zy.asrs.service.AdjDetlService; |
| | | import com.zy.asrs.service.AgvLocDetlService; |
| | | import com.zy.asrs.service.AgvLocMastService; |
| | | import com.zy.asrs.service.AgvWrkMastService; |
| | | import com.zy.asrs.service.*; |
| | | 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.*; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/agv") |
| | | public class AgvLocMastController extends BaseController { |
| | |
| | | private AgvLocDetlService agvLocDetlService; |
| | | @Autowired |
| | | private AdjDetlService adjDetlService; |
| | | @Autowired |
| | | ApiLogService apiLogService; |
| | | |
| | | @Value("${agv.url}") |
| | | private String url; |
| | | @Value("${agv.locStsUrl}") |
| | | private String locStsUrl; |
| | | |
| | | @RequestMapping(value = "/locMast/list/auth") |
| | | @ManagerAuth |
| | |
| | | if (locMast.getLocSts().equals("F") && (oldLocMast.getLocSts().equals("D") || oldLocMast.getLocSts().equals("O"))) { |
| | | return R.error("当前操作已被阻止,请联系管理员"); |
| | | } |
| | | String barcode = oldLocMast.getBarcode(); |
| | | int br = 0; |
| | | if (locMast.getLocSts() == "O" || locMast.getLocSts() == "X") { |
| | | switch (locMast.getBarcode().substring(0, 2)) { |
| | |
| | | locMast.setModiTime(now); |
| | | if (!agvLockMastService.updateById(locMast)) { |
| | | throw new CoolException("主库位修改失败"); |
| | | } else { |
| | | try { |
| | | if (locMast.getLocSts().equals("O")) { |
| | | HashMap<String, String> data = new HashMap<>(); |
| | | data.put("reqCode", System.currentTimeMillis() + ""); |
| | | data.put("podCode", barcode); |
| | | data.put("positionCode", locMast.getLocNo()); |
| | | data.put("indBind", "0"); |
| | | String response = ""; |
| | | boolean success = false; |
| | | int code = 0; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(url) |
| | | .setPath(locStsUrl) |
| | | .setTimeout(30, TimeUnit.SECONDS) |
| | | .setJson(JSONObject.toJSONString(data)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | code = Integer.parseInt(jsonObject.get("code").toString()); |
| | | if (code != 0) { |
| | | log.info("库位解绑AGV接口调用失败,返回信息:" + response); |
| | | } else { |
| | | success = true; |
| | | } |
| | | } catch (Exception e) { |
| | | throw new CoolException("调用AGV响应错误"); |
| | | } finally { |
| | | apiLogService.save( |
| | | "货架与位置解绑", |
| | | url + locStsUrl, |
| | | null, |
| | | "127.0.0.1", |
| | | JSON.toJSONString(data), |
| | | response, |
| | | success |
| | | ); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |