From 288e45a990a5abf4ab50f820ed4e870e8314468e Mon Sep 17 00:00:00 2001 From: 野心家 <1051256694@qq.com> Date: 星期六, 21 六月 2025 15:14:10 +0800 Subject: [PATCH] 完善 --- src/main/java/com/zy/asrs/controller/MobileController.java | 128 ++++++++++++++++++++++++++---------------- 1 files changed, 79 insertions(+), 49 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/MobileController.java b/src/main/java/com/zy/asrs/controller/MobileController.java index 245a0a1..7971216 100644 --- a/src/main/java/com/zy/asrs/controller/MobileController.java +++ b/src/main/java/com/zy/asrs/controller/MobileController.java @@ -14,9 +14,12 @@ import com.zy.asrs.entity.*; import com.zy.asrs.entity.param.CombParam; import com.zy.asrs.entity.param.MobileAdjustParam; +import com.zy.asrs.entity.param.RCSParam; import com.zy.asrs.entity.param.Review; import com.zy.asrs.entity.result.MobileAdjustResult; import com.zy.asrs.service.*; +import com.zy.asrs.service.impl.MobileServiceImpl; +import com.zy.asrs.task.WorkMastScheduler; import com.zy.asrs.task.handler.WorkLogHandler; import com.zy.common.constant.MesConstant; import com.zy.common.model.LocDto; @@ -25,13 +28,18 @@ import com.zy.common.utils.HttpHandler; import com.zy.common.web.BaseController; import com.zy.common.web.param.SearchLocParam; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.*; /** @@ -41,7 +49,7 @@ @RestController @RequestMapping("mobile") public class MobileController extends BaseController { - + private static final Logger log = LoggerFactory.getLogger(WorkMastScheduler.class); @Autowired private MobileService mobileService; @Autowired @@ -62,6 +70,12 @@ private BasDevpService basDevpService; @Autowired private PackService packService; + @Autowired + private ApiLogService apiLogService; + @Value("${rcs.address.url}") + private String url; + @Value("${rcs.address.attrcs}") + private String attrcs; // 鍟嗗搧涓婃灦 @@ -438,57 +452,73 @@ map.put("rows",list); return R.ok(map); } - /** - * 鏅�20-绗簩澶╂棭8 - */ - @RequestMapping("/pack/evening/v2") -// @ManagerAuth(memo = "娴嬭瘯搴撳悎鏍兼暟") - public R chartAxisEveningV2(){ - Map<String,Object> map=new HashMap<String, Object>(); - List<AxisBean> list = new ArrayList<AxisBean>(); - List<WorkChartAxis> listChart = mobileService.chartAxisEvening(); - - if(listChart!=null) { - ArrayList<Integer> data1 = new ArrayList<Integer>(); - ArrayList<Integer> data2 = new ArrayList<Integer>(); - - SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); - Calendar calendar = Calendar.getInstance(); - calendar.add(Calendar.DATE, -12); - for(int i=0;i<12;i++) { - boolean flag = true; - calendar.add(Calendar.DATE, 1); - String str = sf.format(calendar.getTime()); - for(WorkChartAxis workChart : listChart) { - if(str.equals(workChart.getYmd())) { - data1.add(workChart.getInqty()); - data2.add(workChart.getOutqty()); - flag = false; - break; - } - } - if(flag) { - data1.add(0); - data2.add(0); - } - } - AxisBean inqty = new AxisBean(); - inqty.setName("鍏ュ簱鏁伴噺"); - Integer[] array1 = new Integer[data1.size()]; - inqty.setData(data1.toArray(array1)); - list.add(inqty); - AxisBean outqty = new AxisBean(); - outqty.setName("鍑哄簱鏁伴噺"); - Integer[] array2 = new Integer[data2.size()]; - outqty.setData(data2.toArray(array2)); - list.add(outqty); - } - map.put("rows",list); - return R.ok(map); - } /*...........................璧e窞鏂板..............浠ヤ笂.............璧e窞鏂板...........................*/ + /** + * 鎵ц绉诲簱浠诲姟 + * @param sourceStaNo + * @param staNo + * @return + */ + @RequestMapping("/AGVMove") + public R AGVMove(@RequestParam(required = false) String sourceStaNo + ,@RequestParam(required = false) String staNo + ,Integer priority){ + String noww="aa" + new Date().getTime(); + + LinkedHashMap<String,Object> rcsParam=new LinkedHashMap<>(); + rcsParam.put("task_id",noww); + rcsParam.put("start_location",sourceStaNo); + rcsParam.put("start_command",1); + rcsParam.put("target_location",staNo); + rcsParam.put("target_command",2); + rcsParam.put("priority",1);//浼樺厛绾ц秺灏忓厛鎵ц + rcsParam.put("robot_type",1);//杞� 杈� 绫� 鍨� 0:XC 1:XCD 2:XP_T 3:XP_L + rcsParam.put("MoverID","XCD"); + + LinkedHashMap<String,Object> map=new LinkedHashMap<>(); + map.put("data",rcsParam); + String response =""; + Boolean bool =false; + String msg = ""; + try { + log.info("wms娲惧彂鎼繍浠诲姟缁橝GV鎼繍={}", rcsParam); + response = new HttpHandler.Builder() + // .setHeaders(headParam) + .setUri(url) + .setPath(attrcs) + .setJson(JSON.toJSONString(map)) + .build() + .doPost(); + JSONObject jsonObject = JSON.parseObject(response); + JSONObject data = jsonObject.getJSONObject("data"); + JSONObject errInfo = jsonObject.getJSONObject("err_info"); + if(data.getInteger("result")==0){ + bool = true; + }else{ + msg=errInfo.getString("err_msg"); + } + } catch (Exception e) { + log.error("wms娲惧彂鎼繍浠诲姟缁橝GV鎼繍澶辫触杩斿洖鍊�={}", response); + } finally { + apiLogService.save("wms娲惧彂鎼繍浠诲姟缁橝GV鎼繍" + , url + attrcs + , null + , "127.0.0.1" + , JSON.toJSONString(map) + , response + , bool + ); + } + + if(bool){ + return R.ok(noww); + }else { + return R.error("涓嬪彂浠诲姟澶辫触"); + } + + } } -- Gitblit v1.9.1