whycxzp
2025-04-03 918fa28b3f48b9598e264d0f483508b92f8d8a3b
src/main/java/com/whyc/service/WmsService.java
@@ -11,9 +11,12 @@
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 {
@@ -61,20 +64,25 @@
            WmsResponse responseInside = JsonUtil.getGson().fromJson(dataStr, WmsResponse.class);
            response.set(1,responseInside);
            //对下发的任务进行数据库存储
            Task task = new Task();
            task.setTaskNo(responseInside.getTask_no());
            task.setDes(palletDto.getDes());
            //将字符串列表转为1组字符串,每个元素用逗号分割
            List<String> pallets = palletDto.getPallets();
            task.setPallets(String.join(",", pallets));
            List<String> activateParameter = palletDto.getActivateParameter();
            task.setActivateParameter(String.join(",",activateParameter));
            Date date = new Date();
            task.setCreateTime(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());
            taskService.add(task);
                List<String> activateParameter = palletDto.getActivateParameter();
                task.setActivateParameter(String.join(",",activateParameter));
                task.setCreateTime(date);
                taskService.add(task);
            }
        }
        return response;
@@ -86,27 +94,34 @@
        //对结果进行处理
        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() {
    public Response getPalletList(int MaterialType, int PalletStatus) {
        String httpUrl = "http://192.168.10.133:8051"+"/api/Wms_pallet/get_all";
        Response response = HttpUtil.doGet(httpUrl, (String) null);
        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);
            //WmsLocationDto wmsLocationDto = JsonUtil.getGson().fromJson(dataStr, WmsLocationDto.class);
            List<WmsPallet> wmsPalletList = JsonUtil.getGson().fromJson(dataStr, new TypeToken<List<WmsPallet>>(){}.getType());
            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;
@@ -142,7 +157,7 @@
                if(pallet == null){
                    pallet = taskService.getByTaskNo(taskNo).getPallets();
                }
                //更新电池编号
                //更新电池单体编号
                PageParam pageParam = new PageParam();
                pageParam.setId(3);
                pageParam.setValue(Integer.valueOf(pallet));