From c330e65b8ea172fface685efaa8e9c2e8a7f9520 Mon Sep 17 00:00:00 2001 From: whycxzp <glperry@163.com> Date: 星期三, 23 四月 2025 13:57:13 +0800 Subject: [PATCH] 更新停止任务接口 --- src/main/java/com/whyc/service/WmsService.java | 207 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 204 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/whyc/service/WmsService.java b/src/main/java/com/whyc/service/WmsService.java index 7539110..daca90b 100644 --- a/src/main/java/com/whyc/service/WmsService.java +++ b/src/main/java/com/whyc/service/WmsService.java @@ -1,15 +1,32 @@ package com.whyc.service; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import com.google.gson.reflect.TypeToken; import com.whyc.dto.*; +import com.whyc.pojo.db_abe_ram.AbeInf; +import com.whyc.pojo.db_param.PageParam; +import com.whyc.pojo.db_wms.Task; import com.whyc.util.HttpUtil; import com.whyc.util.JsonUtil; +import com.whyc.util.ThreadLocalUtil; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import sun.applet.Main; +import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; @Service public class WmsService { + + @Autowired + private TaskService taskService; + + @Autowired + private AbeInfService abeInfService; public Response getMaterialList() { String httpUrl = "http://192.168.10.133:8051"+"/api/Wms_material/get_all"; @@ -47,6 +64,78 @@ String dataStr = (String) response.getData(); WmsResponse responseInside = JsonUtil.getGson().fromJson(dataStr, WmsResponse.class); response.set(1,responseInside); + if(responseInside.getCode() ==0) { + //瀵逛笅鍙戠殑浠诲姟杩涜鏁版嵁搴撳瓨鍌� + Date date = new Date(); + List<String> pallets = palletDto.getPallets(); + List<String> taskNos = responseInside.getTask_no(); + for (int i = 0; i < pallets.size(); i++) { + String pallet = pallets.get(i); + String taskNo = taskNos.get(i); + Task task = new Task(); + task.setTaskNo(taskNo); + task.setPallets(pallet); + task.setDes(palletDto.getDes()); + + if (palletDto.getDes() == 3) { //娲诲寲,濉叆娲诲寲鍙傛暟 + List<String> activateParameter = palletDto.getActivateParameter(); + task.setActivateParameter(String.join(",", activateParameter)); + } + task.setCreateTime(date); + + taskService.add(task); + + + } + } + } + return response; + } + + public Response sendTaskInbound(WmsTaskDto taskDto) { + String httpUrl = "http://192.168.10.133:8051"+"/api/wms_task/inbound"; + Response response = HttpUtil.doPost(httpUrl, JsonUtil.getGson().toJson(taskDto)); + //瀵圭粨鏋滆繘琛屽鐞� + if(response.getCode() == 1){ //璇锋眰鎴愬姛,data鏈夋甯告暟鎹� + String dataStr = (String) response.getData(); + WmsTaskResponse responseInside = JsonUtil.getGson().fromJson(dataStr, WmsTaskResponse.class); + response.set(1,responseInside); + if(responseInside.getCode() ==0) { + //瀵逛笅鍙戠殑浠诲姟杩涜鏁版嵁搴撳瓨鍌� + Date date = new Date(); + String pallet = taskDto.getPallet_code(); + String startLocationCode = taskDto.getStartlocation_code(); + //1=鎼繍绌烘墭,2=鎼繍鐢垫睜. 杞寲鍒板瓧娈礑es涓�,1001=鎼繍绌烘墭,1002=鎼繍鐢垫睜 + Integer type = taskDto.getType(); + String taskNo = responseInside.getTask_no(); + + Task task = new Task(); + task.setTaskNo(taskNo); + task.setPallets(pallet); + task.setStartLocationCode(startLocationCode); + task.setDes(type ==1?1001:1002); + + task.setCreateTime(date); + + taskService.add(task); + + + } + } + return response; + } + + public Response stopTask(WmsTaskStopDto stopDto) { + String httpUrl = "http://192.168.10.133:8051"+"/api/wms_task/inbound"; + Response response = HttpUtil.doPost(httpUrl, JsonUtil.getGson().toJson(stopDto)); + //瀵圭粨鏋滆繘琛屽鐞� + if(response.getCode() == 1){ //璇锋眰鎴愬姛,data鏈夋甯告暟鎹� + String dataStr = (String) response.getData(); + WmsResponseTaskStopDto responseInside = JsonUtil.getGson().fromJson(dataStr, WmsResponseTaskStopDto.class); + response.set(1,responseInside); + /*if(responseInside.getCode() ==0) { + + }*/ } return response; } @@ -57,13 +146,125 @@ //瀵圭粨鏋滆繘琛屽鐞� if(response.getCode() == 1){ //璇锋眰鎴愬姛,data鏈夋甯告暟鎹� String dataStr = (String) response.getData(); - //鎴彇dataStr涓�"data:"鍚庣殑瀛楃涓� + /*//鎴彇dataStr涓�"data:"鍚庣殑瀛楃涓� int index = dataStr.indexOf("data"); dataStr = dataStr.substring(index+6, dataStr.length()-3); - //WmsLocationDto wmsLocationDto = JsonUtil.getGson().fromJson(dataStr, WmsLocationDto.class); - List<WmsLocationDto> wmsLocationDtoList = JsonUtil.getGson().fromJson(dataStr, new TypeToken<List<WmsLocationDto>>(){}.getType()); + //WmsLocationDto wmsLocationDto = JsonUtil.getGson().fromJson(dataStr, WmsLocationDto.class);*/ + WmsResponse<List<WmsLocationDto>> wmsResponse = JsonUtil.getGson().fromJson(dataStr, new TypeToken<WmsResponse<List<WmsLocationDto>>>(){}.getType()); + List<WmsLocationDto> wmsLocationDtoList = wmsResponse.getData(); response.set(1,wmsLocationDtoList); } return response; } + + public Response getPalletList(int MaterialType, int PalletStatus) { + String httpUrl = "http://192.168.10.133:8051"+"/api/Wms_pallet/get_all"; + + Map<String,Integer> queryMap = new HashMap<>(); + queryMap.put("MaterialType",MaterialType); + queryMap.put("PalletStatus",PalletStatus); + Response response = HttpUtil.doGet(httpUrl, HttpUtil.urlEncode(queryMap)); + //瀵圭粨鏋滆繘琛屽鐞� + if(response.getCode() == 1){ //璇锋眰鎴愬姛,data鏈夋甯告暟鎹� + String dataStr = (String) response.getData(); + /* + //鎴彇dataStr涓�"data:"鍚庣殑瀛楃涓� + int index = dataStr.indexOf("data"); + dataStr = dataStr.substring(index+6, dataStr.length()-3); + List<WmsPallet> wmsPalletList = JsonUtil.getGson().fromJson(dataStr, new TypeToken<List<WmsPallet>>(){}.getType());*/ + WmsResponse<List<WmsPallet>> wmsResponse = JsonUtil.getGson().fromJson(dataStr, new TypeToken<WmsResponse<List<WmsPallet>>>(){}.getType()); + List<WmsPallet> wmsPalletList = wmsResponse.getData(); + response.set(1,wmsPalletList); + } + return response; + } + + public Response sendTaskStatus(TaskDto taskDto) { + String taskNo = taskDto.getTask_no(); + //閫氳繃taskNo浠庢暟鎹簱鏌ユ壘瀵瑰簲鐨勮褰� + Task taskInDB = taskService.getByTaskNo(taskNo); + if(taskInDB == null){ + return new Response<>().setII(1,"浠诲姟涓婃姤澶辫触锛屾棤娉曞畾浣嶅埌浠诲姟锛屼换鍔″彲鑳戒笉鏄�氳繃鐩戞帶骞冲彴涓嬪彂"); + } + Task task = new Task(); + task.setTaskNo(taskNo); + task.setTaskType(taskDto.getTask_type()); + //杩欎釜鍦版柟璧峰鐐圭殑瀹氫箟,杩愯杩囩▼涓渶瑕佸叧娉�,浠ュ強缂栫爜瀵瑰簲鐨勫叿浣撲綅缃�,闇�瑕佷粬浠彁渚� + task.setStartLocationCode(taskDto.getStart_location_code()); + task.setEndLocationCode(taskDto.getEnd_location_code()); + + task.setStatus(taskDto.getStatus()); + task.setStatusTime(ThreadLocalUtil.parse(taskDto.getStatus_time(),1)); + + //瀵规帴鏀跺埌鐨勪换鍔¤繘琛岄�昏緫鍒ゆ柇鍜屾暟鎹瓨鍌� + //String taskNo = task.getTaskNo(); + //taskType=4,鍏ュ簱娴嬪帇浠诲姟,杩欎釜涓轰粨鍌ㄨ嚜鍔ㄨЕ鍙戠殑浠诲姟,闈炰富鍔ㄥ钩鍙颁笅杈�, + // 闇�瑕佹墜鍔ㄦ坊鍔犱换鍔$被鍨�,鍜岀數姹犵粍缂栧彿 + Integer taskType = task.getTaskType(); + if(taskType == 4){ + task.setDes(2); + task.setPallets(taskDto.getPallet()); + } + Integer status = task.getStatus(); + Date statusTime = task.getStatusTime(); + switch (status){ + case 1: + case 11: + case 21: { + task.setPickUpStartTime(statusTime); + }break; + case 2: + case 12: + case 22: task.setPickUpTime(statusTime);break; + case 13: + case 23: { + /*String pallet = task.getPallets(); + if(pallet == null){ + pallet = taskService.getByTaskNo(taskNo).getPallets(); + }*/ + String pallet = taskInDB.getPallets(); + //鏇存柊鐢垫睜鍗曚綋缂栧彿鍜屼换鍔$紪鍙� + AbeInf abeInf = abeInfService.get(); + abeInf.setAbeMonId(Integer.valueOf(pallet)); + abeInf.setTaskNo(taskNo); + abeInfService.updateById(abeInf); + //璁剧疆鏀剧疆鍒版椿鍖栦粨鐨勫紑濮嬫椂闂� + task.setActivationChamberStartTime(statusTime); + }break; + case 14: + task.setActivationChamberPickUpTime(statusTime);break; + case 24: + //娴嬪帇浠诲姟,寮�濮嬪彇娴嬪帇缁撴潫鐨勭數姹�. 璇诲彇abe_inf琛ㄤ腑鐨勫唴闃�,鎻掑叆鍒颁换鍔¢噷 + AbeInf abeInf = abeInfService.get(); + task.setNowMonRes(abeInf.getNowMonRes()); + task.setActivationChamberPickUpTime(statusTime);break; + case 15: + case 25: + task.setActivationChamberEndTime(statusTime);break; + case 4: + case 16: + case 26: + task.setBackFinishTime(statusTime); + task.setEndTime(new Date()); + break; + default: + throw new IllegalArgumentException("status瀛楁鏈畾涔�,鏃犳硶琚瘑鍒�: " + status); + } + taskService.update(task); + + return new Response().setII(1,"涓婃姤鐘舵�佸畬鎴�"); + } + + public Response getFinishedPage(int pageNum, int pageSize) { + PageHelper helper = new PageHelper(); + helper.startPage(pageNum,pageSize); + List<Task> tasks = taskService.getFinishedList(); + PageInfo<Task> pageInfo = new PageInfo<>(tasks); + return new Response().set(1,pageInfo); + } + + public Response getOngoingList() { + List<Task> taskList = taskService.getOngoingList(); + return new Response().set(1,taskList); + } } -- Gitblit v1.9.1