From 025d2d4b67f7dce2a2a55c419e62e5c504feff37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E6=98=8E=E6=A2=81?= <2429105222@qq.com> Date: Fri, 18 Aug 2023 17:32:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E4=BB=BB=E5=8A=A1=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E5=88=B0=E8=87=AA=E5=8A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inv/DeviceInspectTakeController.java | 24 +++++++++++++++++++ .../glxp/api/http/sync/SpGetHttpClient.java | 11 +++++++++ .../res/sync/SpsSyncDeviceTakeResponse.java | 19 +++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 src/main/java/com/glxp/api/res/sync/SpsSyncDeviceTakeResponse.java diff --git a/src/main/java/com/glxp/api/controller/inv/DeviceInspectTakeController.java b/src/main/java/com/glxp/api/controller/inv/DeviceInspectTakeController.java index d9d086aa..3ad14903 100644 --- a/src/main/java/com/glxp/api/controller/inv/DeviceInspectTakeController.java +++ b/src/main/java/com/glxp/api/controller/inv/DeviceInspectTakeController.java @@ -1,5 +1,6 @@ package com.glxp.api.controller.inv; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.PageInfo; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; @@ -7,11 +8,14 @@ import com.glxp.api.constant.Constant; import com.glxp.api.constant.DeviceStatus; import com.glxp.api.entity.inv.DeviceInspectTaskDetailEntity; import com.glxp.api.entity.inv.DeviceInspectTaskEntity; +import com.glxp.api.http.sync.SpGetHttpClient; import com.glxp.api.req.inv.FilterDeviceInspectTakeRequest; import com.glxp.api.res.inv.DeviceInspectTakeResponse; +import com.glxp.api.res.sync.SpsSyncDeviceTakeResponse; import com.glxp.api.service.inv.DeviceInspectTaskDetailService; import com.glxp.api.service.inv.DeviceInspectTaskService; import com.glxp.api.util.GennerOrderUtils; +import com.glxp.api.util.OkHttpCli; import com.glxp.api.util.OrderNoTypeBean; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.GetMapping; @@ -37,6 +41,8 @@ public class DeviceInspectTakeController { DeviceInspectTaskDetailService deviceInspectTaskDetailService; @Resource private GennerOrderUtils gennerOrderUtils; + @Resource + SpGetHttpClient spGetHttpClient; /** * 查询设设备巡检任务接口 @@ -59,6 +65,7 @@ public class DeviceInspectTakeController { deviceInspectTaskEntity.setEndTime(new Date()); } boolean falg=deviceInspectTaskService.updateById(deviceInspectTaskEntity); + UploadDeviceTake(deviceInspectTaskEntity.getId(),2); if(!falg){ return ResultVOUtils.error(999,"更新失败"); } @@ -69,6 +76,9 @@ public class DeviceInspectTakeController { public BaseResponse uploadDeviceTake(@RequestBody DeviceInspectTaskEntity deviceInspectTaskEntity) { deviceInspectTaskEntity.setUpdateTime(new Date()); boolean falg=deviceInspectTaskService.updateById(deviceInspectTaskEntity); + if(deviceInspectTaskEntity.getStatus() == 2){ + UploadDeviceTake(deviceInspectTaskEntity.getId(),1); + } if(!falg){ return ResultVOUtils.error(999,"更新失败"); } @@ -90,9 +100,23 @@ public class DeviceInspectTakeController { public BaseResponse delectDeviceInspecTake(@RequestBody DeviceInspectTaskEntity deviceInspectTaskEntity) { deviceInspectTaskService.delectDeviceInspectTask(deviceInspectTaskEntity); + deviceInspectTaskDetailService.remove(new QueryWrapper().eq("taskOrderIdFk",deviceInspectTaskEntity.getOrderId())); + UploadDeviceTake(deviceInspectTaskEntity.getId(),3); return ResultVOUtils.success(deviceInspectTaskEntity); } + void UploadDeviceTake(Integer id,Integer type){ + //提交上传到自助 + //查询任务表 + DeviceInspectTaskEntity deviceInspectTaskEntity=deviceInspectTaskService.getById(id); + List deviceInspectTaskDetailEntityList = deviceInspectTaskDetailService + .list(new QueryWrapper().eq("taskOrderIdFk",deviceInspectTaskEntity.getOrderId())); + SpsSyncDeviceTakeResponse spsSyncDeviceTakeResponse=new SpsSyncDeviceTakeResponse(); + spsSyncDeviceTakeResponse.setDeviceInspectTaskEntity(deviceInspectTaskEntity); + spsSyncDeviceTakeResponse.setDeviceInspectTaskDetailEntityList(deviceInspectTaskDetailEntityList); + spsSyncDeviceTakeResponse.setType(type); + spGetHttpClient.postAllDeviceTake(spsSyncDeviceTakeResponse); + } diff --git a/src/main/java/com/glxp/api/http/sync/SpGetHttpClient.java b/src/main/java/com/glxp/api/http/sync/SpGetHttpClient.java index 997f400b..03282d76 100644 --- a/src/main/java/com/glxp/api/http/sync/SpGetHttpClient.java +++ b/src/main/java/com/glxp/api/http/sync/SpGetHttpClient.java @@ -597,4 +597,15 @@ public class SpGetHttpClient { } + //上传设备任务 + public BaseResponse postAllDeviceTake(SpsSyncDeviceTakeResponse spsSyncDeviceTakeResponse) { + String json = JSONUtil.toJsonStr(spsSyncDeviceTakeResponse); + String result = okHttpCli.doPostJson(getIpUrl() + "/directToSpms" + "/deviceTakeApi/sps/sync/deviceTake/upload", json, buildHeader()); + BaseResponse response = + JSONObject.parseObject(result, new TypeReference>() { + }); + return response; + } + + } diff --git a/src/main/java/com/glxp/api/res/sync/SpsSyncDeviceTakeResponse.java b/src/main/java/com/glxp/api/res/sync/SpsSyncDeviceTakeResponse.java new file mode 100644 index 00000000..aacad0d2 --- /dev/null +++ b/src/main/java/com/glxp/api/res/sync/SpsSyncDeviceTakeResponse.java @@ -0,0 +1,19 @@ +package com.glxp.api.res.sync; + +import com.glxp.api.entity.inv.DeviceInspectTaskDetailEntity; +import com.glxp.api.entity.inv.DeviceInspectTaskEntity; +import com.glxp.api.entity.purchase.PurOrderDetailEntity; +import com.glxp.api.entity.purchase.PurOrderEntity; +import lombok.Data; + +import java.util.List; + +//同步设备任务 +@Data +public class SpsSyncDeviceTakeResponse { + + private DeviceInspectTaskEntity deviceInspectTaskEntity; + private List deviceInspectTaskDetailEntityList; + private Integer type; //1 新增 2 编辑 3删除 + +}