| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.R; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.zy.asrs.entity.LocChartPie; |
| | | import com.zy.asrs.entity.LocDetl; |
| | | import com.zy.asrs.entity.LocMast; |
| | | import com.zy.asrs.entity.digitaltwin.*; |
| | | import com.zy.asrs.mapper.LocDetlMapper; |
| | | import com.zy.asrs.mapper.ReportQueryMapper; |
| | | import com.zy.asrs.service.DigitalTwinService; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.common.web.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import com.fasterxml.jackson.core.type.TypeReference; |
| | | import javax.annotation.Resource; |
| | | import java.io.IOException; |
| | | import java.text.ParseException; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @RequestMapping("/digitalTwin") |
| | | @RestController |
| | | public class DigitalTwinController extends BaseController { |
| | | |
| | | @Value("${digitalTwins.jgUrl}") |
| | | private String JG_URL; |
| | | |
| | | @Value("${digitalTwins.djUrl}") |
| | | private String DJ_URL; |
| | | |
| | | @Value("${digitalTwins.ljqUrl}") |
| | | private String LJQ_URL; |
| | | |
| | | @Resource |
| | | private DigitalTwinService digitalTwinService; |
| | | @Autowired |
| | | ReportQueryMapper reportQueryMapper; |
| | | @Autowired |
| | | private LocDetlMapper locDetlMapper; |
| | | |
| | | /** |
| | | * 数据总览 |
| | |
| | | */ |
| | | @RequestMapping(value = "/overview") |
| | | // @ManagerAuth |
| | | public R overview(@RequestParam(required = false) String areaId){ |
| | | public R overview(@RequestParam(required = false) String areaId) throws IOException { |
| | | |
| | | //digitalTwinService.overview(areaId); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if (areaId != null) { |
| | | map.put("areaId", areaId); |
| | | } |
| | | HttpHandler.Builder builder = new HttpHandler.Builder() |
| | | .setPath("/digitalTwin/overview") |
| | | .setParams(map); |
| | | |
| | | DtOverviewVo dtOverviewVo = DtOverviewVo.builder() |
| | | .totalLoc(999) |
| | | .useLoc(900) |
| | | .idleLoc(99) |
| | | .todayOutbound(160) |
| | | .todayWarehousing(170) |
| | | .remainingStock(180) |
| | | .build(); |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | if (areaId != null) { |
| | | switch (areaId) { |
| | | case "A": { |
| | | String resA = builder.setUri(JG_URL).build().doGet(); |
| | | |
| | | return R.ok().add(dtOverviewVo); |
| | | Map<String, Object> result = objectMapper.readValue(resA, Map.class); |
| | | |
| | | // 如果只需要data部分 |
| | | Map<String, Object> data = (Map<String, Object>) result.get("data"); |
| | | return R.ok(data); |
| | | } |
| | | case "B": { |
| | | String resB = builder.setUri(DJ_URL).build().doGet(); |
| | | |
| | | Map<String, Object> result = objectMapper.readValue(resB, Map.class); |
| | | |
| | | // 如果只需要data部分 |
| | | Map<String, Object> data = (Map<String, Object>) result.get("data"); |
| | | return R.ok(data); |
| | | } |
| | | case "C": { |
| | | |
| | | String resC = builder.setUri(LJQ_URL).build().doGet(); |
| | | |
| | | Map<String, Object> result = objectMapper.readValue(resC, Map.class); |
| | | |
| | | // 如果只需要data部分 |
| | | Map<String, Object> data = (Map<String, Object>) result.get("data"); |
| | | return R.ok(data); |
| | | } |
| | | case "D": { |
| | | return R.ok(digitalTwinService.overview(areaId)); |
| | | } |
| | | default: |
| | | Map<String, Object> mergedResult = new HashMap<>(); |
| | | Map<String, Object> mergedData = new HashMap<>(); |
| | | |
| | | String resA = builder.setUri(JG_URL).build().doGet(); |
| | | Map<String, Object> resultA = objectMapper.readValue(resA, Map.class); |
| | | if (resultA.get("data") != null) { |
| | | mergedData.put("A", resultA.get("data")); |
| | | } |
| | | |
| | | String resB = builder.setUri(DJ_URL).build().doGet(); |
| | | Map<String, Object> resultB = objectMapper.readValue(resB, Map.class); |
| | | if (resultB.get("data") != null) { |
| | | mergedData.put("B", resultB.get("data")); |
| | | } |
| | | |
| | | String resC = builder.setUri(LJQ_URL).build().doGet(); |
| | | Map<String, Object> resultC = objectMapper.readValue(resC, Map.class); |
| | | if (resultC.get("data") != null) { |
| | | mergedData.put("C", resultC.get("data")); |
| | | } |
| | | |
| | | Object resultD = digitalTwinService.overview(areaId); |
| | | if (resultD != null) { |
| | | mergedData.put("D", resultD); |
| | | } |
| | | |
| | | return R.ok(mergedData); |
| | | } |
| | | } else { |
| | | Map<String, Object> mergedResult = new HashMap<>(); |
| | | Map<String, Object> mergedData = new HashMap<>(); |
| | | |
| | | String resA = builder.setUri(JG_URL).build().doGet(); |
| | | Map<String, Object> resultA = objectMapper.readValue(resA, Map.class); |
| | | if (resultA.get("data") != null) { |
| | | mergedData.put("A", resultA.get("data")); |
| | | } |
| | | |
| | | String resB = builder.setUri(DJ_URL).build().doGet(); |
| | | Map<String, Object> resultB = objectMapper.readValue(resB, Map.class); |
| | | if (resultB.get("data") != null) { |
| | | mergedData.put("B", resultB.get("data")); |
| | | } |
| | | |
| | | String resC = builder.setUri(LJQ_URL).build().doGet(); |
| | | Map<String, Object> resultC = objectMapper.readValue(resC, Map.class); |
| | | if (resultC.get("data") != null) { |
| | | mergedData.put("C", resultC.get("data")); |
| | | } |
| | | |
| | | Object resultD = digitalTwinService.overview(areaId); |
| | | if (resultD != null) { |
| | | mergedData.put("D", resultD); |
| | | } |
| | | |
| | | return R.ok(mergedData); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 近期订单(默认7天) |
| | | * |
| | | * @param areaId 库区编码 |
| | | * @param startDate 格式:yyyyMMdd,20251022 |
| | | * @param endDate 格式:yyyyMMdd,20251027 |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/recentOrder") |
| | | // @ManagerAuth |
| | | public R recentOrder(@RequestParam(required = false) String startDate, |
| | | @RequestParam(required = false) String endDate){ |
| | | public R recentOrder(@RequestParam(required = false) String areaId, |
| | | @RequestParam(required = false) String startDate, |
| | | @RequestParam(required = false) String endDate) throws IOException { |
| | | |
| | | // digitalTwinService.order(startDate, endDate); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if (areaId != null) { |
| | | map.put("areaId", areaId); |
| | | } |
| | | if (startDate != null) { |
| | | map.put("startDate", startDate); |
| | | } |
| | | if (endDate != null) { |
| | | map.put("endDate", endDate); |
| | | } |
| | | HttpHandler.Builder builder = new HttpHandler.Builder() |
| | | .setPath("/digitalTwin/recentOrder") |
| | | .setParams(map); |
| | | |
| | | DtOrderVo dtOrderVo = DtOrderVo.builder() |
| | | .orderDate("2025-10-22") |
| | | .orderNum(156) |
| | | .build(); |
| | | DtOrderVo dtOrderVo2 = DtOrderVo.builder() |
| | | .orderDate("2025-10-23") |
| | | .orderNum(166) |
| | | .build(); |
| | | List<DtOrderVo> orderVoList = new ArrayList<>(); |
| | | orderVoList.add(dtOrderVo); |
| | | orderVoList.add(dtOrderVo2); |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | if (areaId != null) { |
| | | switch (areaId) { |
| | | case "A": { |
| | | |
| | | return R.ok().add(orderVoList); |
| | | String resA = builder.setUri(JG_URL).build().doGet(); |
| | | |
| | | Map<String, Object> result = objectMapper.readValue(resA, Map.class); |
| | | |
| | | // 如果只需要data部分 |
| | | List data = (List) result.get("data"); |
| | | return R.ok(data); |
| | | } |
| | | case "B": { |
| | | |
| | | String resB = builder.setUri(DJ_URL).build().doGet(); |
| | | |
| | | Map<String, Object> result = objectMapper.readValue(resB, Map.class); |
| | | |
| | | // 如果只需要data部分 |
| | | List data = (List) result.get("data"); |
| | | return R.ok(data); |
| | | } |
| | | case "C": { |
| | | |
| | | String resC = builder.setUri(LJQ_URL).build().doGet(); |
| | | |
| | | Map<String, Object> result = objectMapper.readValue(resC, Map.class); |
| | | |
| | | // 如果只需要data部分 |
| | | List data = (List) result.get("data"); |
| | | return R.ok(data); |
| | | } |
| | | case "D": { |
| | | return R.ok(digitalTwinService.order(startDate, endDate)); |
| | | } |
| | | default: |
| | | Map<String, Object> mergedResult = new HashMap<>(); |
| | | Map<String, Object> mergedData = new HashMap<>(); |
| | | |
| | | String resA = builder.setUri(JG_URL).build().doGet(); |
| | | Map<String, Object> resultA = objectMapper.readValue(resA, Map.class); |
| | | if (resultA.get("data") != null) { |
| | | mergedData.put("A", resultA.get("data")); |
| | | } |
| | | |
| | | String resB = builder.setUri(DJ_URL).build().doGet(); |
| | | Map<String, Object> resultB = objectMapper.readValue(resB, Map.class); |
| | | if (resultB.get("data") != null) { |
| | | mergedData.put("B", resultB.get("data")); |
| | | } |
| | | |
| | | String resC = builder.setUri(LJQ_URL).build().doGet(); |
| | | Map<String, Object> resultC = objectMapper.readValue(resC, Map.class); |
| | | if (resultC.get("data") != null) { |
| | | mergedData.put("C", resultC.get("data")); |
| | | } |
| | | |
| | | Object resultD = digitalTwinService.order(startDate, endDate); |
| | | if (resultD != null) { |
| | | mergedData.put("D", resultD); |
| | | } |
| | | |
| | | return R.ok(mergedData); |
| | | } |
| | | } else { |
| | | Map<String, Object> mergedResult = new HashMap<>(); |
| | | Map<String, Object> mergedData = new HashMap<>(); |
| | | |
| | | String resA = builder.setUri(JG_URL).build().doGet(); |
| | | Map<String, Object> resultA = objectMapper.readValue(resA, Map.class); |
| | | if (resultA.get("data") != null) { |
| | | mergedData.put("A", resultA.get("data")); |
| | | } |
| | | |
| | | String resB = builder.setUri(DJ_URL).build().doGet(); |
| | | Map<String, Object> resultB = objectMapper.readValue(resB, Map.class); |
| | | if (resultB.get("data") != null) { |
| | | mergedData.put("B", resultB.get("data")); |
| | | } |
| | | |
| | | String resC = builder.setUri(LJQ_URL).build().doGet(); |
| | | Map<String, Object> resultC = objectMapper.readValue(resC, Map.class); |
| | | if (resultC.get("data") != null) { |
| | | mergedData.put("C", resultC.get("data")); |
| | | } |
| | | |
| | | Object resultD = digitalTwinService.order(startDate, endDate); |
| | | if (resultD != null) { |
| | | mergedData.put("D", resultD); |
| | | } |
| | | |
| | | return R.ok(mergedData); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | // @ManagerAuth |
| | | public R recentIdleLoc(@RequestParam(required = false) String areaId, |
| | | @RequestParam(required = false) String startDate, |
| | | @RequestParam(required = false) String endDate){ |
| | | @RequestParam(required = false) String endDate) throws IOException { |
| | | |
| | | // digitalTwinService.recentLoc(areaId, startDate, endDate); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if (areaId != null) { |
| | | map.put("areaId", areaId); |
| | | } |
| | | if (startDate != null) { |
| | | map.put("startDate", startDate); |
| | | } |
| | | if (endDate != null) { |
| | | map.put("endDate", endDate); |
| | | } |
| | | HttpHandler.Builder builder = new HttpHandler.Builder() |
| | | .setPath("/digitalTwin/recentIdleLoc") |
| | | .setParams(map); |
| | | |
| | | DtLocVo dtLocVo = DtLocVo.builder() |
| | | .locDate("2025-10-22") |
| | | .idleNum(208) |
| | | .build(); |
| | | DtLocVo dtLocVo2 = DtLocVo.builder() |
| | | .locDate("2025-10-23") |
| | | .idleNum(177) |
| | | .build(); |
| | | List<DtLocVo> locVoList = new ArrayList<>(); |
| | | locVoList.add(dtLocVo); |
| | | locVoList.add(dtLocVo2); |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | if (areaId != null) { |
| | | switch (areaId) { |
| | | case "A": { |
| | | |
| | | return R.ok().add(locVoList); |
| | | String resA = builder.setUri(JG_URL).build().doGet(); |
| | | |
| | | Map<String, Object> result = objectMapper.readValue(resA, Map.class); |
| | | |
| | | // 如果只需要data部分 |
| | | List data = (List) result.get("data"); |
| | | return R.ok(data); |
| | | } |
| | | case "B": { |
| | | |
| | | String resA = builder.setUri(DJ_URL).build().doGet(); |
| | | |
| | | Map<String, Object> result = objectMapper.readValue(resA, Map.class); |
| | | |
| | | // 如果只需要data部分 |
| | | List data = (List) result.get("data"); |
| | | return R.ok(data); |
| | | } |
| | | case "C": { |
| | | |
| | | String resA = builder.setUri(LJQ_URL).build().doGet(); |
| | | |
| | | Map<String, Object> result = objectMapper.readValue(resA, Map.class); |
| | | |
| | | // 如果只需要data部分 |
| | | List data = (List) result.get("data"); |
| | | return R.ok(data); |
| | | } |
| | | case "D": { |
| | | return R.ok(digitalTwinService.recentLoc(areaId, startDate, endDate)); |
| | | } |
| | | default: |
| | | Map<String, Object> mergedResult = new HashMap<>(); |
| | | Map<String, Object> mergedData = new HashMap<>(); |
| | | |
| | | String resA = builder.setUri(JG_URL).build().doGet(); |
| | | Map<String, Object> resultA = objectMapper.readValue(resA, Map.class); |
| | | if (resultA.get("data") != null) { |
| | | mergedData.put("A", resultA.get("data")); |
| | | } |
| | | |
| | | String resB = builder.setUri(DJ_URL).build().doGet(); |
| | | Map<String, Object> resultB = objectMapper.readValue(resB, Map.class); |
| | | if (resultB.get("data") != null) { |
| | | mergedData.put("B", resultB.get("data")); |
| | | } |
| | | |
| | | String resC = builder.setUri(LJQ_URL).build().doGet(); |
| | | Map<String, Object> resultC = objectMapper.readValue(resC, Map.class); |
| | | if (resultC.get("data") != null) { |
| | | mergedData.put("C", resultC.get("data")); |
| | | } |
| | | |
| | | Object resultD = digitalTwinService.recentLoc(areaId, startDate, endDate); |
| | | if (resultD != null) { |
| | | mergedData.put("D", resultD); |
| | | } |
| | | |
| | | return R.ok(mergedData); |
| | | } |
| | | } else { |
| | | Map<String, Object> mergedResult = new HashMap<>(); |
| | | Map<String, Object> mergedData = new HashMap<>(); |
| | | |
| | | String resA = builder.setUri(JG_URL).build().doGet(); |
| | | Map<String, Object> resultA = objectMapper.readValue(resA, Map.class); |
| | | if (resultA.get("data") != null) { |
| | | mergedData.put("A", resultA.get("data")); |
| | | } |
| | | |
| | | String resB = builder.setUri(DJ_URL).build().doGet(); |
| | | Map<String, Object> resultB = objectMapper.readValue(resB, Map.class); |
| | | if (resultB.get("data") != null) { |
| | | mergedData.put("B", resultB.get("data")); |
| | | } |
| | | |
| | | String resC = builder.setUri(LJQ_URL).build().doGet(); |
| | | Map<String, Object> resultC = objectMapper.readValue(resC, Map.class); |
| | | if (resultC.get("data") != null) { |
| | | mergedData.put("C", resultC.get("data")); |
| | | } |
| | | |
| | | Object resultD = digitalTwinService.recentLoc(areaId, startDate, endDate); |
| | | if (resultD != null) { |
| | | mergedData.put("D", resultD); |
| | | } |
| | | |
| | | return R.ok(mergedData); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | @RequestMapping(value = "/recentInAndOutBound") |
| | | // @ManagerAuth |
| | | public R recentInAndOutBound(@RequestParam(required = false) String areaId, |
| | | @RequestParam(required = false) String startDate, |
| | | @RequestParam(required = false) String endDate){ |
| | | @RequestParam(required = false) String startDate, |
| | | @RequestParam(required = false) String endDate) throws ParseException, IOException { |
| | | |
| | | // digitalTwinService.inAndOutBound(areaId, startDate, endDate); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if (areaId != null) { |
| | | map.put("areaId", areaId); |
| | | } |
| | | if (startDate != null) { |
| | | map.put("startDate", startDate); |
| | | } |
| | | if (endDate != null) { |
| | | map.put("endDate", endDate); |
| | | } |
| | | HttpHandler.Builder builder = new HttpHandler.Builder() |
| | | .setPath("/digitalTwin/recentInAndOutBound") |
| | | .setParams(map); |
| | | |
| | | DtInAndOutBoundVo dtInAndOutBoundVo = DtInAndOutBoundVo.builder() |
| | | .boundDate("2025-10-22") |
| | | .inBoundNum(237) |
| | | .outBoundNum(487) |
| | | .build(); |
| | | DtInAndOutBoundVo dtInAndOutBoundVo2 = DtInAndOutBoundVo.builder() |
| | | .boundDate("2025-10-23") |
| | | .inBoundNum(187) |
| | | .outBoundNum(287) |
| | | .build(); |
| | | List<DtInAndOutBoundVo> inAndOutBoundVoList = new ArrayList<>(); |
| | | inAndOutBoundVoList.add(dtInAndOutBoundVo); |
| | | inAndOutBoundVoList.add(dtInAndOutBoundVo2); |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | if (areaId != null) { |
| | | switch (areaId) { |
| | | case "A": { |
| | | |
| | | return R.ok().add(inAndOutBoundVoList); |
| | | String resA = builder.setUri(JG_URL).build().doGet(); |
| | | |
| | | Map<String, Object> result = objectMapper.readValue(resA, Map.class); |
| | | |
| | | // 如果只需要data部分 |
| | | List data = (List) result.get("data"); |
| | | return R.ok(data); |
| | | } |
| | | case "B": { |
| | | |
| | | String resA = builder.setUri(DJ_URL).build().doGet(); |
| | | |
| | | Map<String, Object> result = objectMapper.readValue(resA, Map.class); |
| | | |
| | | // 如果只需要data部分 |
| | | List data = (List) result.get("data"); |
| | | return R.ok(data); |
| | | } |
| | | case "C": { |
| | | |
| | | String resA = builder.setUri(LJQ_URL).build().doGet(); |
| | | |
| | | Map<String, Object> result = objectMapper.readValue(resA, Map.class); |
| | | |
| | | // 如果只需要data部分 |
| | | List data = (List) result.get("data"); |
| | | return R.ok(data); |
| | | } |
| | | case "D": { |
| | | return R.ok(digitalTwinService.inAndOutBound(areaId, startDate, endDate)); |
| | | } |
| | | default: |
| | | Map<String, Object> mergedResult = new HashMap<>(); |
| | | Map<String, Object> mergedData = new HashMap<>(); |
| | | |
| | | String resA = builder.setUri(JG_URL).build().doGet(); |
| | | Map<String, Object> resultA = objectMapper.readValue(resA, Map.class); |
| | | if (resultA.get("data") != null) { |
| | | mergedData.put("A", resultA.get("data")); |
| | | } |
| | | |
| | | String resB = builder.setUri(DJ_URL).build().doGet(); |
| | | Map<String, Object> resultB = objectMapper.readValue(resB, Map.class); |
| | | if (resultB.get("data") != null) { |
| | | mergedData.put("B", resultB.get("data")); |
| | | } |
| | | |
| | | String resC = builder.setUri(LJQ_URL).build().doGet(); |
| | | Map<String, Object> resultC = objectMapper.readValue(resC, Map.class); |
| | | if (resultC.get("data") != null) { |
| | | mergedData.put("C", resultC.get("data")); |
| | | } |
| | | |
| | | Object resultD = digitalTwinService.inAndOutBound(areaId, startDate, endDate); |
| | | if (resultD != null) { |
| | | mergedData.put("D", resultD); |
| | | } |
| | | |
| | | return R.ok(mergedData); |
| | | } |
| | | } else { |
| | | // 如果没有提供areaId,默认调用本地服务 |
| | | Map<String, Object> mergedResult = new HashMap<>(); |
| | | Map<String, Object> mergedData = new HashMap<>(); |
| | | |
| | | String resA = builder.setUri(JG_URL).build().doGet(); |
| | | Map<String, Object> resultA = objectMapper.readValue(resA, Map.class); |
| | | if (resultA.get("data") != null) { |
| | | mergedData.put("A", resultA.get("data")); |
| | | } |
| | | |
| | | String resB = builder.setUri(DJ_URL).build().doGet(); |
| | | Map<String, Object> resultB = objectMapper.readValue(resB, Map.class); |
| | | if (resultB.get("data") != null) { |
| | | mergedData.put("B", resultB.get("data")); |
| | | } |
| | | |
| | | String resC = builder.setUri(LJQ_URL).build().doGet(); |
| | | Map<String, Object> resultC = objectMapper.readValue(resC, Map.class); |
| | | if (resultC.get("data") != null) { |
| | | mergedData.put("C", resultC.get("data")); |
| | | } |
| | | |
| | | Object resultD = digitalTwinService.inAndOutBound(areaId, startDate, endDate); |
| | | if (resultD != null) { |
| | | mergedData.put("D", resultD); |
| | | } |
| | | |
| | | return R.ok(mergedData); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | public R recentDetainMat(@RequestParam(required = false) String areaId, |
| | | @RequestParam(required = false) Integer overDayNum, |
| | | @RequestParam(required = false) Integer pageIndex, |
| | | @RequestParam(required = false) Integer pageSize){ |
| | | @RequestParam(required = false) Integer pageSize, |
| | | @RequestParam(required = false) String condition) throws IOException { |
| | | |
| | | // digitalTwinService.recentDetainMat(areaId, overDayNum, pageIndex, pageSize); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if (areaId != null) { |
| | | map.put("areaId", areaId); |
| | | } |
| | | if (overDayNum != null) { |
| | | map.put("overDayNum", overDayNum); |
| | | } |
| | | if (pageIndex != null) { |
| | | map.put("pageIndex", pageIndex); |
| | | } |
| | | if (pageSize != null) { |
| | | map.put("pageSize", pageSize); |
| | | } |
| | | if (condition != null) { |
| | | map.put("condition", condition); |
| | | } |
| | | HttpHandler.Builder builder = new HttpHandler.Builder() |
| | | .setPath("/digitalTwin/recentDetainMat") |
| | | .setParams(map); |
| | | |
| | | DtDetainMatVo dtDetainMatVo = DtDetainMatVo.builder() |
| | | .belongAreaId("A1") |
| | | .belongAreaName("刀具库") |
| | | .matId("mat10001") |
| | | .matName("道具把") |
| | | .lokId("loc1001") |
| | | .lokName("库位10001") |
| | | .detainTime(765) |
| | | .inBoundTime("2025-10-11T11:15:16") |
| | | .build(); |
| | | DtDetainMatVo dtDetainMatVo2 = DtDetainMatVo.builder() |
| | | .belongAreaId("A1") |
| | | .belongAreaName("刀具库") |
| | | .matId("mat10002") |
| | | .matName("道具把") |
| | | .lokId("loc1002") |
| | | .lokName("库位10002") |
| | | .detainTime(665) |
| | | .inBoundTime("2025-10-10T11:15:16") |
| | | .build(); |
| | | List<DtDetainMatVo> detainMatVoList = new ArrayList<>(); |
| | | detainMatVoList.add(dtDetainMatVo); |
| | | detainMatVoList.add(dtDetainMatVo2); |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | if (areaId != null) { |
| | | switch (areaId) { |
| | | case "A": { |
| | | String resA = builder.setUri(JG_URL).build().doGet(); |
| | | |
| | | return R.ok().add(detainMatVoList); |
| | | Map<String, Object> result = objectMapper.readValue(resA, Map.class); |
| | | |
| | | // 如果只需要data部分 |
| | | List data = (List) result.get("data"); |
| | | return R.ok(data); |
| | | } |
| | | case "B": { |
| | | String resA = builder.setUri(DJ_URL).build().doGet(); |
| | | |
| | | Map<String, Object> result = objectMapper.readValue(resA, Map.class); |
| | | |
| | | // 如果只需要data部分 |
| | | List data = (List) result.get("data"); |
| | | return R.ok(data); |
| | | } |
| | | case "C": { |
| | | String resA = builder.setUri(LJQ_URL).build().doGet(); |
| | | |
| | | Map<String, Object> result = objectMapper.readValue(resA, Map.class); |
| | | |
| | | // 如果只需要data部分 |
| | | List data = (List) result.get("data"); |
| | | return R.ok(data); |
| | | } |
| | | case "D": { |
| | | return R.ok(digitalTwinService.recentDetainMat(areaId, overDayNum, pageIndex, pageSize, condition)); |
| | | } |
| | | default: |
| | | Map<String, Object> mergedResult = new HashMap<>(); |
| | | Map<String, Object> mergedData = new HashMap<>(); |
| | | |
| | | String resA = builder.setUri(JG_URL).build().doGet(); |
| | | Map<String, Object> resultA = objectMapper.readValue(resA, Map.class); |
| | | if (resultA.get("data") != null) { |
| | | mergedData.put("A", resultA.get("data")); |
| | | } |
| | | |
| | | String resB = builder.setUri(DJ_URL).build().doGet(); |
| | | Map<String, Object> resultB = objectMapper.readValue(resB, Map.class); |
| | | if (resultB.get("data") != null) { |
| | | mergedData.put("B", resultB.get("data")); |
| | | } |
| | | |
| | | String resC = builder.setUri(LJQ_URL).build().doGet(); |
| | | Map<String, Object> resultC = objectMapper.readValue(resC, Map.class); |
| | | if (resultC.get("data") != null) { |
| | | mergedData.put("C", resultC.get("data")); |
| | | } |
| | | |
| | | Object resultD = digitalTwinService.recentDetainMat(areaId, overDayNum, pageIndex, pageSize, condition); |
| | | if (resultD != null) { |
| | | mergedData.put("D", resultD); |
| | | } |
| | | |
| | | return R.ok(mergedData); |
| | | } |
| | | } else { |
| | | // 如果没有提供areaId,默认调用本地服务 |
| | | Map<String, Object> mergedResult = new HashMap<>(); |
| | | Map<String, Object> mergedData = new HashMap<>(); |
| | | |
| | | String resA = builder.setUri(JG_URL).build().doGet(); |
| | | Map<String, Object> resultA = objectMapper.readValue(resA, Map.class); |
| | | if (resultA.get("data") != null) { |
| | | mergedData.put("A", resultA.get("data")); |
| | | } |
| | | |
| | | String resB = builder.setUri(DJ_URL).build().doGet(); |
| | | Map<String, Object> resultB = objectMapper.readValue(resB, Map.class); |
| | | if (resultB.get("data") != null) { |
| | | mergedData.put("B", resultB.get("data")); |
| | | } |
| | | |
| | | String resC = builder.setUri(LJQ_URL).build().doGet(); |
| | | Map<String, Object> resultC = objectMapper.readValue(resC, Map.class); |
| | | if (resultC.get("data") != null) { |
| | | mergedData.put("C", resultC.get("data")); |
| | | } |
| | | |
| | | Object resultD = digitalTwinService.recentDetainMat(areaId, overDayNum, pageIndex, pageSize, condition); |
| | | if (resultD != null) { |
| | | mergedData.put("D", resultD); |
| | | } |
| | | |
| | | return R.ok(mergedData); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @RequestMapping(value = "/equipment") |
| | | // @ManagerAuth |
| | | public R equipment(@RequestParam(required = false) String areaId){ |
| | | public R equipment(@RequestParam(required = false) String areaId) throws IOException { |
| | | |
| | | DtEquipmentVo dtDetainMatVo = DtEquipmentVo.builder() |
| | | .equipmentId("eq1001") |
| | | .equipmentName("堆垛机1") |
| | | .equipmentType(1) |
| | | .belongAreaId("A1") |
| | | .belongAreaName("刀具库") |
| | | .verticalSpeed(288) |
| | | .horizontalSpeed(203) |
| | | .voltage(48) |
| | | .status(1) |
| | | .operateMethod(1) |
| | | .build(); |
| | | DtEquipmentVo dtDetainMatVo2 = DtEquipmentVo.builder() |
| | | .equipmentId("eq1002") |
| | | .equipmentName("堆垛机2") |
| | | .equipmentType(1) |
| | | .belongAreaId("A1") |
| | | .belongAreaName("刀具库") |
| | | .verticalSpeed(208) |
| | | .horizontalSpeed(253) |
| | | .voltage(48) |
| | | .status(1) |
| | | .operateMethod(1) |
| | | .build(); |
| | | List<DtEquipmentVo> dtEquipmentVoList = new ArrayList<>(); |
| | | dtEquipmentVoList.add(dtDetainMatVo); |
| | | dtEquipmentVoList.add(dtDetainMatVo2); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("areaId", areaId); |
| | | HttpHandler.Builder builder = new HttpHandler.Builder() |
| | | .setPath("/digitalTwin/equipment") |
| | | .setParams(map); |
| | | |
| | | return R.ok().add(dtEquipmentVoList); |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | if (areaId != null){ |
| | | switch (areaId) { |
| | | case "A": { |
| | | String resA = builder.setUri(JG_URL).build().doGet(); |
| | | Map<String, Object> result = objectMapper.readValue(resA, Map.class); |
| | | DtEquipmentVo data = objectMapper.convertValue(result.get("data"), DtEquipmentVo.class); |
| | | // 如果只需要data部分 |
| | | //DtEquipmentVo data = (DtEquipmentVo) result.get("data"); |
| | | return R.ok(data); |
| | | } |
| | | case "B": { |
| | | String resA = builder.setUri(DJ_URL).build().doGet(); |
| | | Map<String, Object> result = objectMapper.readValue(resA, Map.class); |
| | | DtEquipmentVo data = objectMapper.convertValue(result.get("data"), DtEquipmentVo.class); |
| | | // 如果只需要data部分 |
| | | //DtEquipmentVo data = (DtEquipmentVo) result.get("data"); |
| | | return R.ok(data); |
| | | } |
| | | case "C": { |
| | | String resA = builder.setUri(LJQ_URL).build().doGet(); |
| | | |
| | | Map<String, Object> result = objectMapper.readValue(resA, Map.class); |
| | | DtEquipmentVo data = objectMapper.convertValue(result.get("data"), DtEquipmentVo.class); |
| | | // 如果只需要data部分 |
| | | //DtEquipmentVo data = (DtEquipmentVo) result.get("data"); |
| | | return R.ok(data); |
| | | } |
| | | case "D": { |
| | | return R.ok(digitalTwinService.equipment(areaId)); |
| | | } |
| | | default: |
| | | Map<String, Object> mergedResult = new HashMap<>(); |
| | | Map<String, Object> mergedData = new HashMap<>(); |
| | | |
| | | String resA = builder.setUri(JG_URL).build().doGet(); |
| | | Map<String, Object> resultA = objectMapper.readValue(resA, Map.class); |
| | | if (resultA.get("data") != null) { |
| | | mergedData.put("A", resultA.get("data")); |
| | | } |
| | | |
| | | String resB = builder.setUri(DJ_URL).build().doGet(); |
| | | Map<String, Object> resultB = objectMapper.readValue(resB, Map.class); |
| | | if (resultB.get("data") != null) { |
| | | mergedData.put("B", resultB.get("data")); |
| | | } |
| | | |
| | | String resC = builder.setUri(LJQ_URL).build().doGet(); |
| | | Map<String, Object> resultC = objectMapper.readValue(resC, Map.class); |
| | | if (resultC.get("data") != null) { |
| | | mergedData.put("C", resultC.get("data")); |
| | | } |
| | | |
| | | Object resultD = digitalTwinService.equipment(areaId); |
| | | if (resultD != null) { |
| | | mergedData.put("D", resultD); |
| | | } |
| | | |
| | | return R.ok(mergedData); |
| | | } |
| | | }else { |
| | | Map<String, Object> mergedResult = new HashMap<>(); |
| | | Map<String, Object> mergedData = new HashMap<>(); |
| | | |
| | | String resA = builder.setUri(JG_URL).build().doGet(); |
| | | Map<String, Object> resultA = objectMapper.readValue(resA, Map.class); |
| | | if (resultA.get("data") != null) { |
| | | mergedData.put("A", resultA.get("data")); |
| | | } |
| | | |
| | | String resB = builder.setUri(DJ_URL).build().doGet(); |
| | | Map<String, Object> resultB = objectMapper.readValue(resB, Map.class); |
| | | if (resultB.get("data") != null) { |
| | | mergedData.put("B", resultB.get("data")); |
| | | } |
| | | |
| | | String resC = builder.setUri(LJQ_URL).build().doGet(); |
| | | Map<String, Object> resultC = objectMapper.readValue(resC, Map.class); |
| | | if (resultC.get("data") != null) { |
| | | mergedData.put("C", resultC.get("data")); |
| | | } |
| | | |
| | | Object resultD = digitalTwinService.equipment(areaId); |
| | | if (resultD != null) { |
| | | mergedData.put("D", resultD); |
| | | } |
| | | |
| | | return R.ok(mergedData); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @RequestMapping(value = "/warehouseDetail") |
| | | // @ManagerAuth |
| | | public R warehouseDetail(@RequestParam(required = false) String areaId){ |
| | | public R warehouseDetail(@RequestParam(required = false) String areaId) throws IOException { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if (areaId != null) { |
| | | map.put("areaId", areaId); |
| | | } |
| | | |
| | | // digitalTwinService.warehouseDetail(areaId); |
| | | HttpHandler.Builder builder = new HttpHandler.Builder() |
| | | .setPath("/digitalTwin/warehouseDetail") |
| | | .setParams(map); |
| | | |
| | | List<DtLocDetailVo> dtLocDetailVoList = new ArrayList<>(); |
| | | DtLocDetailVo dtLocDetailVo = new DtLocDetailVo(); |
| | | dtLocDetailVo.setLocNo("CA0100202"); |
| | | dtLocDetailVo.setLocSts("O"); |
| | | dtLocDetailVo.setAreaId(10010L); |
| | | dtLocDetailVo.setAreaName("刀具库"); |
| | | dtLocDetailVo.setRow1(1); |
| | | dtLocDetailVo.setBay1(2); |
| | | dtLocDetailVo.setLev1(2); |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | if (areaId != null) { |
| | | switch (areaId) { |
| | | case "A": { |
| | | |
| | | LocMast locMast = new LocMast(); |
| | | locMast.setLocNo("CA0100202"); |
| | | locMast.setLocSts("O"); |
| | | locMast.setRow1(1); |
| | | locMast.setBay1(2); |
| | | locMast.setLev1(2); |
| | | dtLocDetailVo.setLocMast(locMast); |
| | | String resA = builder.setUri(JG_URL).build().doGet(); |
| | | |
| | | LocDetl locDetl = new LocDetl(); |
| | | locDetl.setLocNo("CA0100202"); |
| | | locDetl.setAreaId(10010L); |
| | | locDetl.setAreaName("刀具库"); |
| | | locDetl.setMatnr("mat10001"); |
| | | locDetl.setMaktx("刀把"); |
| | | dtLocDetailVo.setLocDetl(locDetl); |
| | | dtLocDetailVoList.add(dtLocDetailVo); |
| | | Map<String, Object> result = objectMapper.readValue(resA, Map.class); |
| | | |
| | | // 如果只需要data部分 |
| | | List data = (List) result.get("data"); |
| | | return R.ok(data); |
| | | } |
| | | case "B": { |
| | | builder.setPath("/digitalTwin/warehouseDetail"); |
| | | String resA = builder.setUri(DJ_URL).build().doGet(); |
| | | |
| | | DtLocDetailVo dtLocDetailVo2 = new DtLocDetailVo(); |
| | | dtLocDetailVo2.setLocNo("CA0100202"); |
| | | dtLocDetailVo2.setLocSts("O"); |
| | | dtLocDetailVo2.setAreaId(10010L); |
| | | dtLocDetailVo2.setAreaName("刀具库"); |
| | | dtLocDetailVo2.setRow1(1); |
| | | dtLocDetailVo2.setBay1(2); |
| | | dtLocDetailVo2.setLev1(2); |
| | | Map<String, Object> result = objectMapper.readValue(resA, Map.class); |
| | | |
| | | LocMast locMast2 = new LocMast(); |
| | | locMast2.setLocNo("CA0100203"); |
| | | locMast2.setLocSts("O"); |
| | | locMast2.setRow1(1); |
| | | locMast2.setBay1(2); |
| | | locMast2.setLev1(3); |
| | | dtLocDetailVo2.setLocMast(locMast2); |
| | | // 如果只需要data部分 |
| | | List data = (List) result.get("data"); |
| | | return R.ok(data); |
| | | } |
| | | case "C": { |
| | | |
| | | LocDetl locDetl2 = new LocDetl(); |
| | | locDetl2.setLocNo("CA0100203"); |
| | | locDetl2.setAreaId(10010L); |
| | | locDetl2.setAreaName("刀具库"); |
| | | locDetl2.setMatnr("mat10001"); |
| | | locDetl2.setMaktx("刀把"); |
| | | dtLocDetailVo2.setLocDetl(locDetl2); |
| | | dtLocDetailVoList.add(dtLocDetailVo2); |
| | | String resA = builder.setUri(LJQ_URL).build().doGet(); |
| | | |
| | | Map<String, Object> result = objectMapper.readValue(resA, Map.class); |
| | | |
| | | // LocDetl locDetl2 = new LocDetl(); |
| | | // locDetl2.setLocNo("1001"); |
| | | // locDetl2.setAreaId(10010L); |
| | | // locDetl2.setAreaName("刀具库"); |
| | | // locDetl2.setMatnr("mat10001"); |
| | | // locDetl2.setMaktx("刀把"); |
| | | // |
| | | //// List<LocDetl> locDetlList = new ArrayList<>(); |
| | | //// locDetlList.add(locDetl); |
| | | //// locDetlList.add(locDetl2); |
| | | // 如果只需要data部分 |
| | | List data = (List) result.get("data"); |
| | | return R.ok(data); |
| | | } |
| | | case "D": { |
| | | return R.ok(digitalTwinService.warehouseDetail(areaId)); |
| | | } |
| | | default: |
| | | Map<String, Object> mergedResult = new HashMap<>(); |
| | | Map<String, Object> mergedData = new HashMap<>(); |
| | | |
| | | return R.ok().add(dtLocDetailVoList); |
| | | String resA = builder.setUri(JG_URL).build().doGet(); |
| | | Map<String, Object> resultA = objectMapper.readValue(resA, Map.class); |
| | | if (resultA.get("data") != null) { |
| | | mergedData.put("A", resultA.get("data")); |
| | | } |
| | | |
| | | String resB = builder.setUri(DJ_URL).build().doGet(); |
| | | Map<String, Object> resultB = objectMapper.readValue(resB, Map.class); |
| | | if (resultB.get("data") != null) { |
| | | mergedData.put("B", resultB.get("data")); |
| | | } |
| | | |
| | | String resC = builder.setUri(LJQ_URL).build().doGet(); |
| | | Map<String, Object> resultC = objectMapper.readValue(resC, Map.class); |
| | | if (resultC.get("data") != null) { |
| | | mergedData.put("C", resultC.get("data")); |
| | | } |
| | | |
| | | Object resultD = digitalTwinService.warehouseDetail(areaId); |
| | | if (resultD != null) { |
| | | mergedData.put("D", resultD); |
| | | } |
| | | |
| | | return R.ok(mergedData); |
| | | } |
| | | } else { |
| | | // 如果没有提供areaId,默认调用本地服务 |
| | | Map<String, Object> mergedResult = new HashMap<>(); |
| | | Map<String, Object> mergedData = new HashMap<>(); |
| | | |
| | | String resA = builder.setUri(JG_URL).build().doGet(); |
| | | Map<String, Object> resultA = objectMapper.readValue(resA, Map.class); |
| | | if (resultA.get("data") != null) { |
| | | mergedData.put("A", resultA.get("data")); |
| | | } |
| | | |
| | | String resB = builder.setUri(DJ_URL).build().doGet(); |
| | | Map<String, Object> resultB = objectMapper.readValue(resB, Map.class); |
| | | if (resultB.get("data") != null) { |
| | | mergedData.put("B", resultB.get("data")); |
| | | } |
| | | |
| | | String resC = builder.setUri(LJQ_URL).build().doGet(); |
| | | Map<String, Object> resultC = objectMapper.readValue(resC, Map.class); |
| | | if (resultC.get("data") != null) { |
| | | mergedData.put("C", resultC.get("data")); |
| | | } |
| | | |
| | | Object resultD = digitalTwinService.warehouseDetail(areaId); |
| | | if (resultD != null) { |
| | | mergedData.put("D", resultD); |
| | | } |
| | | |
| | | return R.ok(mergedData); |
| | | } |
| | | } |
| | | /** |
| | | * 查询所有库位状态和物料-二机床信息化数字孪生用 |
| | | */ |
| | | @RequestMapping(value = "/getAllLocations") |
| | | public R getAllLocations() throws IOException { |
| | | Map<String, Object> mergedData = new HashMap<>(); |
| | | HttpHandler.Builder builder = new HttpHandler.Builder() |
| | | .setPath("/digitalTwin/getAllLocations"); |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | String resA = builder.setUri(JG_URL).build().doGet(); |
| | | Map<String, Object> resultA = objectMapper.readValue(resA, Map.class); |
| | | if (resultA.get("data") != null) { |
| | | mergedData.put("A", resultA.get("data")); |
| | | } |
| | | |
| | | String resB = builder.setUri(DJ_URL).build().doGet(); |
| | | Map<String, Object> resultB = objectMapper.readValue(resB, Map.class); |
| | | if (resultB.get("data") != null) { |
| | | mergedData.put("B", resultB.get("data")); |
| | | } |
| | | |
| | | String resC = builder.setUri(LJQ_URL).build().doGet(); |
| | | Map<String, Object> resultC = objectMapper.readValue(resC, Map.class); |
| | | if (resultC.get("data") != null) { |
| | | mergedData.put("C", resultC.get("data")); |
| | | } |
| | | |
| | | mergedData.put("D",digitalTwinService.getAllLocations()); |
| | | |
| | | return R.ok(mergedData); |
| | | } |
| | | /** |
| | | * 查询所有库的库位利用率 |
| | | */ |
| | | @RequestMapping(value = "/getLocalInfo") |
| | | public R getLocalInfo() throws IOException { |
| | | Map<String, Object> mergedData = new HashMap<>(); |
| | | HttpHandler.Builder builder = new HttpHandler.Builder() |
| | | .setPath("/digitalTwin/getLocalInfo"); |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | |
| | | String resA = builder.setUri(JG_URL).build().doGet(); |
| | | Map<String, Object> resultA = objectMapper.readValue(resA, Map.class); |
| | | mergedData.put("A", resultA); |
| | | |
| | | String resB = builder.setUri(DJ_URL).build().doGet(); |
| | | Map<String, Object> resultB = objectMapper.readValue(resB, Map.class); |
| | | mergedData.put("B", resultB); |
| | | |
| | | String resC = builder.setUri(LJQ_URL).build().doGet(); |
| | | Map<String, Object> resultC = objectMapper.readValue(resC, Map.class); |
| | | mergedData.put("C", resultC); |
| | | |
| | | LocChartPie locUseRate = reportQueryMapper.getLocUseRate(); |
| | | mergedData.put("D", locUseRate); |
| | | |
| | | return R.ok(mergedData); |
| | | } |
| | | /** |
| | | * 查询所有库的库存明细 |
| | | */ |
| | | @RequestMapping(value = "/getLocalDetal") |
| | | public R getLocalDetal() throws IOException { |
| | | Map<String, Object> mergedData = new HashMap<>(); |
| | | HttpHandler.Builder builder = new HttpHandler.Builder() |
| | | .setPath("/digitalTwin/getLocalDetal"); |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | |
| | | String resA = builder.setUri(JG_URL).build().doGet(); |
| | | Map<String, Object> resultA = objectMapper.readValue(resA, Map.class); |
| | | if (resultA.get("data") != null) { |
| | | mergedData.put("A", resultA.get("data")); |
| | | } |
| | | |
| | | String resB = builder.setUri(DJ_URL).build().doGet(); |
| | | Map<String, Object> resultB = objectMapper.readValue(resB, Map.class); |
| | | if (resultB.get("data") != null) { |
| | | mergedData.put("B", resultB.get("data")); |
| | | } |
| | | |
| | | String resC = builder.setUri(LJQ_URL).build().doGet(); |
| | | Map<String, Object> resultC = objectMapper.readValue(resC, Map.class); |
| | | if (resultC.get("data") != null) { |
| | | mergedData.put("C", resultC.get("data")); |
| | | } |
| | | |
| | | List<Map<String, Object>> detalList = digitalTwinService.getLocalDetal(); |
| | | mergedData.put("D", detalList); |
| | | |
| | | return R.ok(mergedData); |
| | | } |
| | | |
| | | } |