| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.CombParam; |
| | | import com.zy.asrs.entity.param.GDYKConfirmGoodsParam; |
| | | import com.zy.asrs.entity.param.MobileAdjustParam; |
| | | import com.zy.asrs.entity.param.OffSaleParam; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.entity.result.MobileAdjustResult; |
| | | import com.zy.asrs.mapper.ManLocDetlMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.common.constant.ApiInterfaceConstant; |
| | | import com.zy.common.model.WrkDto; |
| | | import com.zy.common.service.CommonService; |
| | | 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.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.text.DecimalFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 移动端接口控制器 |
| | |
| | | */ |
| | | @RestController |
| | | @RequestMapping("mobile") |
| | | @Slf4j |
| | | public class MobileController extends BaseController { |
| | | |
| | | @Autowired |
| | |
| | | @Autowired |
| | | private CommonService commonService; |
| | | |
| | | @PostMapping("/agv/start") |
| | | @ManagerAuth |
| | | public R pdaAgvStart(@RequestBody Map<String,Object> map){ |
| | | // HashMap<String, String> map1 = new HashMap<>(); |
| | | // map1.put("agv0001","sta0001"); |
| | | // String sta = map.get("sta").toString(); |
| | | // |
| | | // ForwardAGVTaskParam forwardAGVTaskParam = new ForwardAGVTaskParam(); |
| | | // getAgvTaskParam(forwardAGVTaskParam,sta,map1.get(sta)); |
| | | // String request = forwardAGVHttpRequest(forwardAGVTaskParam, "10.0.100.110:8182", "/rcms/services/rest/hikRpcService/genAgvSchedulingTask"); |
| | | // if ("SUCCESS".equals(request)) { |
| | | // return R.ok(); |
| | | // } |
| | | String sta = (String) map.get("sta"); // 暂存位 |
| | | String inSts = "1040"; // 入库站点 |
| | | |
| | | ForwardAGVTaskParam forwardAGVTaskParam = new ForwardAGVTaskParam(); |
| | | forwardAGVTaskParam.setReqCode(UUID.randomUUID().toString().replace("-", "")); |
| | | forwardAGVTaskParam.setTaskTyp("GT3"); |
| | | forwardAGVTaskParam.setCtnrTyp("2"); |
| | | forwardAGVTaskParam.setPriority("1"); |
| | | List<ForwardAGVTaskParam.PositionCodePaths> positionCodePathsList = new ArrayList<>(); |
| | | positionCodePathsList.add(new ForwardAGVTaskParam.PositionCodePaths(sta,"05")); |
| | | positionCodePathsList.add(new ForwardAGVTaskParam.PositionCodePaths(inSts,"05")); |
| | | forwardAGVTaskParam.setPositionCodePath(positionCodePathsList); |
| | | |
| | | String body = JSON.toJSONString(forwardAGVTaskParam); |
| | | String response = ""; |
| | | boolean success = false; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(ApiInterfaceConstant.AGV_IP) |
| | | .setPath(ApiInterfaceConstant.AGV_CALL_IN_PATH) |
| | | .setJson(body) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(0)) { |
| | | success = true; |
| | | } else { |
| | | log.error("入库呼叫agv失败!!!url:{};request:{};response:{}", ApiInterfaceConstant.AGV_IP+ApiInterfaceConstant.AGV_CALL_IN_PATH, body, response); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("入库呼叫agv异常", e); |
| | | } finally { |
| | | try { |
| | | // 保存接口日志 |
| | | // apiLogService.save( |
| | | // "请求仓储MES盘点单上报接口", |
| | | // MesConstant.MES_CC_IP_PORT + MesConstant.MES_CC_SB_URL, |
| | | // null, |
| | | // "127.0.0.1", |
| | | // JSON.toJSONString(collect), |
| | | // response, |
| | | // success |
| | | // ); |
| | | } catch (Exception e) { log.error("", e); } |
| | | } |
| | | |
| | | return R.error(); |
| | | } |
| | | |
| | | private void getAgvTaskParam(ForwardAGVTaskParam agvTaskCreateParam,String agv,String sta){ |
| | | List<ForwardAGVTaskParam.PositionCodePaths> agvTaskParamList = Arrays.asList( |
| | | //起始位 |
| | | new ForwardAGVTaskParam.PositionCodePaths(agv,"05"), |
| | | //目标位 |
| | | new ForwardAGVTaskParam.PositionCodePaths(sta,"05") |
| | | ); |
| | | Date date = new Date(); |
| | | DecimalFormat df = new DecimalFormat("0000"); |
| | | String wrkNo = "Crn"+date.getTime()/1000; |
| | | agvTaskCreateParam.setReqCode(wrkNo); |
| | | agvTaskCreateParam.setReqTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); |
| | | agvTaskCreateParam.setTaskTyp("GT1"); |
| | | agvTaskCreateParam.setCtnrCode("00000000"); |
| | | agvTaskCreateParam.setPositionCodePath(agvTaskParamList); |
| | | agvTaskCreateParam.setCtnrTyp("1"); |
| | | agvTaskCreateParam.setTaskCode(wrkNo); |
| | | |
| | | } |
| | | |
| | | private String forwardAGVHttpRequest(Object requestParam, String url, String path){ |
| | | String response = ""; |
| | | String success = "error"; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(url) |
| | | // .setHttps(true) |
| | | .setPath(path) |
| | | .setJson(JSONObject.toJSONString(requestParam)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | |
| | | String message = jsonObject.get("code").toString(); |
| | | if(("0").equals(message) || ("请求编号已存在").contains(message)){ |
| | | success = "SUCCESS"; |
| | | }else { |
| | | success = message; |
| | | } |
| | | log.info("转发agv任务:请求体:"+JSONObject.toJSONString(requestParam)+",返回值:"+jsonObject); |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | | return success; |
| | | } |
| | | |
| | | @RequestMapping("/select/workDetl/barcode") |
| | | @ManagerAuth |
| | | public R selectWorkDetlBarcode(@RequestBody Map<String,Object> map) { |