| | |
| | | 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.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 { |
| | |
| | | private TaskService taskService; |
| | | |
| | | @Autowired |
| | | private PageParamService paramService; |
| | | private AbeInfService abeInfService; |
| | | |
| | | public Response getMaterialList() { |
| | | String httpUrl = "http://192.168.10.133:8051"+"/api/Wms_material/get_all"; |
| | |
| | | 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); |
| | | if(palletDto.getDes()==3) { //活化,填入活化参数 |
| | | List<String> activateParameter = palletDto.getActivateParameter(); |
| | | task.setActivateParameter(String.join(",", activateParameter)); |
| | | } |
| | | task.setCreateTime(date); |
| | | |
| | | taskService.add(task); |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | return response; |
| | |
| | | //对结果进行处理 |
| | | 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; |
| | |
| | | if(pallet == null){ |
| | | pallet = taskService.getByTaskNo(taskNo).getPallets(); |
| | | } |
| | | //更新电池编号 |
| | | PageParam pageParam = new PageParam(); |
| | | pageParam.setId(3); |
| | | pageParam.setValue(Integer.valueOf(pallet)); |
| | | paramService.updateById(pageParam); |
| | | //更新电池单体编号和任务编号 |
| | | AbeInf abeInf = abeInfService.get(); |
| | | abeInf.setAbeMonId(Integer.valueOf(pallet)); |
| | | abeInf.setTaskNo(taskNo); |
| | | abeInfService.updateById(abeInf); |
| | | //更新任务时间 |
| | | task.setPickUpStartTime(statusTime); |
| | | }break; |