| | |
| | | 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.BattWarehouse; |
| | | 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; |
| | |
| | | |
| | | @Autowired |
| | | private AbeInfService abeInfService; |
| | | |
| | | @Autowired |
| | | private BattWarehouseService battWarehouseService; |
| | | |
| | | public Response getMaterialList() { |
| | | String httpUrl = "http://192.168.10.133:8051"+"/api/Wms_material/get_all"; |
| | |
| | | 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=搬运电池. 转化到字段Des中,1001=搬运空托,1002=搬运电池 |
| | | Integer type = taskDto.getType(); |
| | | String taskNo = (String) responseInside.getTask_no().get(0); |
| | | |
| | | 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 cancelTask(WmsTaskCancelDto stopDto) { |
| | | String httpUrl = "http://192.168.10.133:8051"+"/api/wms_task/force_send"; |
| | | Response response = HttpUtil.doPost(httpUrl, JsonUtil.getGson().toJson(stopDto)); |
| | | //对结果进行处理 |
| | | if(response.getCode() == 1){ //请求成功,data有正常数据 |
| | | String dataStr = (String) response.getData(); |
| | | WmsResponseTaskCancelDto responseInside = JsonUtil.getGson().fromJson(dataStr, WmsResponseTaskCancelDto.class); |
| | | response.set(1,responseInside); |
| | | if(responseInside.getCode() ==0) { |
| | | //取消成功,任务需要添加完结时间 |
| | | Task task = new Task(); |
| | | task.setTaskNo(stopDto.getTask_no()); |
| | | task.setEndTime(new Date()); |
| | | taskService.update(task); |
| | | } |
| | | } |
| | | return response; |
| | | } |
| | | |
| | | public Response getLocationList() { |
| | | String httpUrl = "http://192.168.10.133:8051"+"/api/wms_location/get_all"; |
| | | Response response = HttpUtil.doGet(httpUrl, (String) null); |
| | |
| | | //通过taskNo从数据库查找对应的记录 |
| | | Task taskInDB = taskService.getByTaskNo(taskNo); |
| | | if(taskInDB == null){ |
| | | return new Response<>().setII(1,"未找到对应的任务"); |
| | | return new Response<>().setII(1,"任务上报失败,无法定位到任务,任务可能不是通过监控平台下发"); |
| | | } |
| | | Task task = new Task(); |
| | | task.setTaskNo(taskNo); |
| | |
| | | task.setActivationChamberStartTime(statusTime); |
| | | }break; |
| | | case 14: |
| | | //开始取活化结束的电池,如果任务编号在更新电池仓库中存在,则更新活化时间为当前时间 |
| | | BattWarehouse battWarehouse =battWarehouseService.getByTaskNo(taskNo); |
| | | if(battWarehouse != null){ |
| | | battWarehouseService.finishActivationById(battWarehouse.getId()); |
| | | } |
| | | task.setActivationChamberPickUpTime(statusTime);break; |
| | | case 24: |
| | | //测压任务,开始取测压结束的电池. 读取abe_inf表中的内阻,插入到任务里 |
| | | AbeInf abeInf = abeInfService.get(); |
| | | task.setNowMonRes(abeInf.getNowMonRes()); |
| | | task.setActivationChamberPickUpTime(statusTime);break; |
| | | case 15: |
| | | case 25: |