From 2c183f0f9d534e37dd69809f0eedc19fabea82e8 Mon Sep 17 00:00:00 2001 From: 刘小明 <liuxm_a@163.com> Date: 星期三, 28 八月 2024 11:16:03 +0800 Subject: [PATCH] 添加查询所有工站接口; 修改查询任务计划列表接口 --- pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/ScheduleCtrl.java | 8 ++-- pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationSv.java | 11 +++++ pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrAssemblyPlanMapper.java | 3 + pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationCtrl.java | 13 ++++++ pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/ScheduleSv.java | 31 +++++++++++++-- pms-parent/pms-global/src/main/resources/mapper/PrAssemblyPlanMapper.xml | 13 ------ 6 files changed, 57 insertions(+), 22 deletions(-) diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrAssemblyPlanMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrAssemblyPlanMapper.java index f14d6d1..6d4ea68 100644 --- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrAssemblyPlanMapper.java +++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoPr/PrAssemblyPlanMapper.java @@ -1,5 +1,6 @@ package com.dy.pmsGlobal.daoPr; +import cn.hutool.json.JSONObject; import com.dy.pmsGlobal.pojoPr.PrAssemblyPlan; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -39,7 +40,7 @@ PrAssemblyPlan selectByDeviceNo(@Param("proCode") String proCode,@Param("batchNumber") String batchNumber); Long countByPlanIdAndNodeId(@Param("planId") Long planId,@Param("nodeId") Long nodeId); - List<Map<String,Object>> selectByPlanName(@Param("planName") String planName); + List<JSONObject> selectByPlanName(@Param("planName") String planName); List<PrAssemblyPlan> selectAssyPlanList(PrAssemblyPlan params); diff --git a/pms-parent/pms-global/src/main/resources/mapper/PrAssemblyPlanMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/PrAssemblyPlanMapper.xml index c3ee987..45d60ae 100644 --- a/pms-parent/pms-global/src/main/resources/mapper/PrAssemblyPlanMapper.xml +++ b/pms-parent/pms-global/src/main/resources/mapper/PrAssemblyPlanMapper.xml @@ -414,18 +414,7 @@ where ap.id = #{planId} and pn.id= #{nodeId} </select> - - <resultMap id="jsonResultMap" type="java.util.HashMap"> - <id column="planId" property="planId"/> - <result column="planName" property="planName"/> - <result column="status" property="status"/> - - <collection property="nodes" javaType="java.util.HashMap"> - <result column="content" property="content"/> - <result column="nodeId" property="nodeId"/> - </collection> - </resultMap> - <select id="selectByPlanName" resultMap="jsonResultMap"> + <select id="selectByPlanName" resultType="cn.hutool.json.JSONObject"> select ap.id planId,ap.name planName,ap.`status`,pn.id nodeId,pn.content from pr_assembly_plan ap left join pr_production_node pn on ap.process_id = pn.process_id where status != -1 diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationCtrl.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationCtrl.java index e1284e0..fcaafc3 100644 --- a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationCtrl.java +++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationCtrl.java @@ -1,5 +1,6 @@ package com.dy.pmsPlatform.station; +import cn.hutool.json.JSONArray; import com.alibaba.excel.converters.Converter; import com.alibaba.fastjson2.JSON; import com.dy.common.aop.SsoPowerAop; @@ -117,6 +118,18 @@ return BaseResponseUtils.buildSuccess(list); } + /** + * 鏌ヨ鎵�鏈夊伐绔� + * @return + */ + @GetMapping(path="all") + @SsoPowerAop(power = "10300006") + @Log("鏌ヨ鎵�鏈夊伐绔�") + public BaseResponse<JSONArray> all(){ + JSONArray array = sv.selectAllIdAndName() ; + return BaseResponseUtils.buildSuccess(array); + } + @PostMapping(path="disabled") @SsoPowerAop(power = "10300007") @Log("绂佺敤鎴栧惎鐢ㄥ伐绔�") diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationSv.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationSv.java index fceba39..35556f6 100644 --- a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationSv.java +++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/station/StationSv.java @@ -1,5 +1,7 @@ package com.dy.pmsPlatform.station; +import cn.hutool.json.JSONArray; +import cn.hutool.json.JSONObject; import com.alibaba.excel.util.StringUtils; import com.dy.common.webUtil.QueryResultVo; import com.dy.pmsGlobal.daoPlt.PltProductionLineMapper; @@ -149,5 +151,14 @@ public List<PltStation> selectAll() { return dao.selectAll(); } + + public JSONArray selectAllIdAndName() { + List<PltStation> list = dao.selectAll(); + JSONArray child = new JSONArray(); + list.forEach(item->{ + child.add(new JSONObject().set("id", item.getId()).set("name", item.getName())); + }); + return child; + } } diff --git a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/ScheduleCtrl.java b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/ScheduleCtrl.java index 7f13c65..20ccf5f 100644 --- a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/ScheduleCtrl.java +++ b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/ScheduleCtrl.java @@ -1,5 +1,6 @@ package com.dy.pmsProduct.schedule; +import cn.hutool.json.JSONObject; import com.alibaba.excel.EasyExcel; import com.dy.common.aop.SsoPowerAop; import com.dy.common.webUtil.BaseResponse; @@ -20,7 +21,6 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; -import java.util.Map; /** * 鎺掔彮 @@ -74,9 +74,9 @@ @PostMapping(path="selectPlan") @SsoPowerAop(power = "-1") @Log("鏌ヨ浠诲姟璁″垝鍒楄〃") - public BaseResponse<List<Map<String,Object>>> selectPlan(@RequestBody QueryVo vo){ - List<Map<String,Object>> list = sv.selectPlan(vo) ; - return BaseResponseUtils.buildSuccess(list); + public BaseResponse<List<JSONObject>> selectPlan(@RequestBody QueryVo vo){ + List<JSONObject> array = sv.selectPlan(vo) ; + return BaseResponseUtils.buildSuccess(array); } /** * 鏍规嵁ID鏌ヨ diff --git a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/ScheduleSv.java b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/ScheduleSv.java index 2df51e4..5080bd1 100644 --- a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/ScheduleSv.java +++ b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/schedule/ScheduleSv.java @@ -1,7 +1,8 @@ package com.dy.pmsProduct.schedule; +import cn.hutool.json.JSONArray; +import cn.hutool.json.JSONObject; import com.dy.common.webUtil.QueryResultVo; -import com.dy.pmsGlobal.daoBa.BaPrivilegeMapper; import com.dy.pmsGlobal.daoBa.BaUserMapper; import com.dy.pmsGlobal.daoPlt.PltStationMapper; import com.dy.pmsGlobal.daoPr.PrAssemblyPlanMapper; @@ -20,6 +21,8 @@ import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; @Slf4j @Service @@ -61,7 +64,6 @@ saveRel(schedule); return count; } - @Transactional public int update(PrSchedule schedule) { scheduleRelDao.deleteByScheduleId(schedule.id); @@ -121,9 +123,28 @@ return rsVo; } - public List<Map<String, Object>> selectPlan(QueryVo vo) { - List<Map<String, Object>> list = assemblyPlanDao.selectByPlanName(vo.planName); - return list; + public List<JSONObject> selectPlan(QueryVo vo) { + List<JSONObject> list = assemblyPlanDao.selectByPlanName(vo.planName); + Map<Long, JSONObject> map = new ConcurrentHashMap<>(); // 浣跨敤骞跺彂瀹夊叏鐨凪ap + for(JSONObject item:list){ + Long planId = (Long) item.getObj("planId"); + JSONObject innerObject = new JSONObject() + .set("nodeId", item.getObj("nodeId")) + .set("content", item.getObj("content")); + if(map.containsKey(planId)){ + JSONArray array = (JSONArray)map.get(planId).get("nodes"); + array.add(innerObject); + }else{ + JSONArray array = new JSONArray(); + array.add(innerObject); + JSONObject outObject= new JSONObject() + .set("planId", planId) + .set("planName", item.getObj("planName")) + .set("nodes", array); + map.put(planId,outObject); + } + } + return map.values().stream().collect(Collectors.toList()); } public List<PrSchedule> selectAll(QueryVo queryVo) { -- Gitblit v1.8.0