diff --git a/src/main/java/com/glxp/api/constant/BasicExportStatusTimeEnum.java b/src/main/java/com/glxp/api/constant/BasicExportStatusTimeEnum.java index 6e5b2ac0..8e9089e5 100644 --- a/src/main/java/com/glxp/api/constant/BasicExportStatusTimeEnum.java +++ b/src/main/java/com/glxp/api/constant/BasicExportStatusTimeEnum.java @@ -112,6 +112,13 @@ public enum BasicExportStatusTimeEnum { * 自动建业务单设置 */ BUS_TYPE_CHANGE("bus_type_change","自动建业务单设置"), + + /** + * 设备任务同步 + */ + DEVICE_TASK("device_task", "设备任务"), + + ; @EnumValue private String key; diff --git a/src/main/java/com/glxp/api/constant/BasicExportTypeEnum.java b/src/main/java/com/glxp/api/constant/BasicExportTypeEnum.java index 34258cd7..b1b50976 100644 --- a/src/main/java/com/glxp/api/constant/BasicExportTypeEnum.java +++ b/src/main/java/com/glxp/api/constant/BasicExportTypeEnum.java @@ -54,6 +54,12 @@ public enum BasicExportTypeEnum { ORDER_INVOICE("io_order_invoice", "扫码单据发票信息"), + /** + * 设备任务同步 + */ + DEVICE_TASK("device_task", "设备任务"), + + // // NEW_ALL_ORDER("all_order", "出入库扫码单据"), // ALL_BUS_ORDER("all_bus_order", "业务单据"), 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 3ad14903..e15231a2 100644 --- a/src/main/java/com/glxp/api/controller/inv/DeviceInspectTakeController.java +++ b/src/main/java/com/glxp/api/controller/inv/DeviceInspectTakeController.java @@ -1,23 +1,30 @@ package com.glxp.api.controller.inv; +import cn.hutool.core.exceptions.ExceptionUtil; +import cn.hutool.core.thread.ThreadUtil; 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; +import com.glxp.api.constant.BasicExportTypeEnum; 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.entity.system.SyncDataSetEntity; 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.service.sync.HeartService; +import com.glxp.api.service.sync.SyncDataSetService; 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.apache.commons.lang3.exception.ExceptionUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -56,18 +63,19 @@ public class DeviceInspectTakeController { PageInfo pageInfo = new PageInfo<>(list); return ResultVOUtils.page(pageInfo); } + @PostMapping("/udiwms/inv/device/inspect/take/uploadDeviceInspecTake") public BaseResponse uploadDeviceInspecTake(@RequestBody DeviceInspectTaskEntity deviceInspectTaskEntity) { deviceInspectTaskEntity.setUpdateTime(new Date()); - if(deviceInspectTaskEntity.getStatus() == DeviceStatus.DEVICE_STATUS_TEMP_DURINGINSPECTTION){ + if (deviceInspectTaskEntity.getStatus() == DeviceStatus.DEVICE_STATUS_TEMP_DURINGINSPECTTION) { deviceInspectTaskEntity.setStrartTime(new Date()); - }else if (deviceInspectTaskEntity.getStatus() == DeviceStatus.DEVICE_STATUS_TEMP_INSPECTED){ + } else if (deviceInspectTaskEntity.getStatus() == DeviceStatus.DEVICE_STATUS_TEMP_INSPECTED) { deviceInspectTaskEntity.setEndTime(new Date()); } - boolean falg=deviceInspectTaskService.updateById(deviceInspectTaskEntity); - UploadDeviceTake(deviceInspectTaskEntity.getId(),2); - if(!falg){ - return ResultVOUtils.error(999,"更新失败"); + boolean falg = deviceInspectTaskService.updateById(deviceInspectTaskEntity); + UploadDeviceTake(deviceInspectTaskEntity.getId(), 2); + if (!falg) { + return ResultVOUtils.error(999, "更新失败"); } return ResultVOUtils.success(); } @@ -75,53 +83,65 @@ public class DeviceInspectTakeController { @PostMapping("/udiwms/inv/device/inspect/take/uploadDeviceTake") public BaseResponse uploadDeviceTake(@RequestBody DeviceInspectTaskEntity deviceInspectTaskEntity) { deviceInspectTaskEntity.setUpdateTime(new Date()); - boolean falg=deviceInspectTaskService.updateById(deviceInspectTaskEntity); - if(deviceInspectTaskEntity.getStatus() == 2){ - UploadDeviceTake(deviceInspectTaskEntity.getId(),1); + boolean falg = deviceInspectTaskService.updateById(deviceInspectTaskEntity); + if (deviceInspectTaskEntity.getStatus() == 2) { + UploadDeviceTake(deviceInspectTaskEntity.getId(), 1); } - if(!falg){ - return ResultVOUtils.error(999,"更新失败"); + if (!falg) { + return ResultVOUtils.error(999, "更新失败"); } return ResultVOUtils.success(); } - @PostMapping("/udiwms/inv/device/inspect/take/addDeviceInspecTake") - public BaseResponse addDeviceInspecTake(@RequestBody DeviceInspectTaskEntity deviceInspectTaskEntity) { + public BaseResponse addDeviceInspecTake(@RequestBody DeviceInspectTaskEntity deviceInspectTaskEntity) { String orderId = gennerOrderUtils.createStOrderNo(new OrderNoTypeBean(Constant.DEVICE_INSPECT_PLAN_ORDER, "yyyyMMdd")); deviceInspectTaskEntity.setOrderId(orderId); deviceInspectTaskEntity.setCreateTime(new Date()); - deviceInspectTaskService.addDeviceInspectTask(deviceInspectTaskEntity); - return ResultVOUtils.success(deviceInspectTaskEntity); + deviceInspectTaskService.addDeviceInspectTask(deviceInspectTaskEntity); + return ResultVOUtils.success(deviceInspectTaskEntity); } @PostMapping("/udiwms/inv/device/inspect/take/delectDeviceInspecTake") - public BaseResponse delectDeviceInspecTake(@RequestBody DeviceInspectTaskEntity deviceInspectTaskEntity) { + public BaseResponse delectDeviceInspecTake(@RequestBody DeviceInspectTaskEntity deviceInspectTaskEntity) { deviceInspectTaskService.delectDeviceInspectTask(deviceInspectTaskEntity); - deviceInspectTaskDetailService.remove(new QueryWrapper().eq("taskOrderIdFk",deviceInspectTaskEntity.getOrderId())); - UploadDeviceTake(deviceInspectTaskEntity.getId(),3); + 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); - } - - + @Resource + HeartService heartService; + @Resource + SyncDataSetService syncDataSetService; + 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); + + SyncDataSetEntity syncDataSetEntity = syncDataSetService.findSet(); + ThreadUtil.execAsync(() -> { + try { + heartService.pushData(syncDataSetEntity, null, BasicExportTypeEnum.DEVICE_TASK); + } catch (Exception e) { + log.error(ExceptionUtils.getStackTrace(e)); + e.printStackTrace(); + } + + }); + } //------------------------------------------ 详情方法--------------------------------------------------------------// @@ -132,21 +152,21 @@ public class DeviceInspectTakeController { } @PostMapping("/udiwms/inv/device/inspect/take/detail/uploadDeviceInspecTakeDetail") - public BaseResponse uploadDeviceInspecTakeDetail(@RequestBody DeviceInspectTaskDetailEntity deviceInspectTaskDetailEntity) { + public BaseResponse uploadDeviceInspecTakeDetail(@RequestBody DeviceInspectTaskDetailEntity deviceInspectTaskDetailEntity) { deviceInspectTaskDetailEntity.setUpdateTime(new Date()); - boolean falg=deviceInspectTaskDetailService.uploadDeviceInspecTakeDetail(deviceInspectTaskDetailEntity); - if(!falg){ - return ResultVOUtils.error(999,"更新失败"); - } + boolean falg = deviceInspectTaskDetailService.uploadDeviceInspecTakeDetail(deviceInspectTaskDetailEntity); + if (!falg) { + return ResultVOUtils.error(999, "更新失败"); + } return ResultVOUtils.success(); } @PostMapping("/udiwms/inv/device/inspect/take/detail/addDeviceInspecTakeDetail") - public BaseResponse addDeviceInspecTakeDetail(@RequestBody DeviceInspectTaskDetailEntity deviceInspectTaskDetailEntity) { + public BaseResponse addDeviceInspecTakeDetail(@RequestBody DeviceInspectTaskDetailEntity deviceInspectTaskDetailEntity) { - boolean falg=deviceInspectTaskDetailService.addDeviceInspectTaskDelect(deviceInspectTaskDetailEntity); - if(!falg){ - return ResultVOUtils.error(999,"更新失败"); + boolean falg = deviceInspectTaskDetailService.addDeviceInspectTaskDelect(deviceInspectTaskDetailEntity); + if (!falg) { + return ResultVOUtils.error(999, "更新失败"); } return ResultVOUtils.success(); } @@ -154,13 +174,12 @@ public class DeviceInspectTakeController { @GetMapping("/udiwms/inv/device/inspect/take/detail/delectDeviceInspecTakeDetail") public BaseResponse delecttDeviceInspecTakeDetail(String id) { - boolean falg=deviceInspectTaskDetailService.removeById(id); - if(!falg){ - return ResultVOUtils.error(999,"删除失败"); + boolean falg = deviceInspectTaskDetailService.removeById(id); + if (!falg) { + return ResultVOUtils.error(999, "删除失败"); } return ResultVOUtils.success(); } - } diff --git a/src/main/java/com/glxp/api/controller/purchase/SupCertController.java b/src/main/java/com/glxp/api/controller/purchase/SupCertController.java index 8d9b21af..4ee2c9f9 100644 --- a/src/main/java/com/glxp/api/controller/purchase/SupCertController.java +++ b/src/main/java/com/glxp/api/controller/purchase/SupCertController.java @@ -406,7 +406,7 @@ public class SupCertController { } String param = JSON.toJSONString(list); - JasperUtils.jasperReport(request, response, param, filePath+"pdf/template/"+systemPDFTemplateEntity.getPath(), "pdf"); + JasperUtils.jasperReport(request, response, param, filePath + "pdf/template/" + systemPDFTemplateEntity.getPath(), "pdf"); } /** @@ -521,7 +521,7 @@ public class SupCertController { } String param = JSON.toJSONString(list); - JasperUtils.jasperReport(request, response, param, filePath+"pdf/template/"+systemPDFTemplateEntity.getPath(), "pdf"); + JasperUtils.jasperReport(request, response, param, filePath + "pdf/template/" + systemPDFTemplateEntity.getPath(), "pdf"); } /** @@ -587,7 +587,7 @@ public class SupCertController { } String param = JSON.toJSONString(list); - JasperUtils.jasperReport(request, response, param, filePath+"pdf/template/"+systemPDFTemplateEntity.getPath(), "pdf"); + JasperUtils.jasperReport(request, response, param, filePath + "pdf/template/" + systemPDFTemplateEntity.getPath(), "pdf"); } //首营预览文件 diff --git a/src/main/java/com/glxp/api/entity/system/SyncDataSetEntity.java b/src/main/java/com/glxp/api/entity/system/SyncDataSetEntity.java index f69eb4dd..788288bd 100644 --- a/src/main/java/com/glxp/api/entity/system/SyncDataSetEntity.java +++ b/src/main/java/com/glxp/api/entity/system/SyncDataSetEntity.java @@ -68,5 +68,9 @@ public class SyncDataSetEntity { private int manufacturerCert; private int productCert; private int orderInvoice; //发票信息 + /** + * 设备任务 + */ + private int deviceTask; } diff --git a/src/main/java/com/glxp/api/res/sync/SpsSyncDeviceTaskResponse.java b/src/main/java/com/glxp/api/res/sync/SpsSyncDeviceTaskResponse.java new file mode 100644 index 00000000..b87fa16e --- /dev/null +++ b/src/main/java/com/glxp/api/res/sync/SpsSyncDeviceTaskResponse.java @@ -0,0 +1,16 @@ +package com.glxp.api.res.sync; + +import com.glxp.api.entity.inv.DeviceInspectTaskDetailEntity; +import com.glxp.api.entity.inv.DeviceInspectTaskEntity; +import lombok.Data; + +import java.util.List; + +@Data +public class SpsSyncDeviceTaskResponse extends BaseSyncResponse { + + List deviceInspectTaskEntities; + + List deviceInspectTaskDetailEntities; + +} diff --git a/src/main/java/com/glxp/api/service/sync/HeartService.java b/src/main/java/com/glxp/api/service/sync/HeartService.java index 2981aad4..5e34a41c 100644 --- a/src/main/java/com/glxp/api/service/sync/HeartService.java +++ b/src/main/java/com/glxp/api/service/sync/HeartService.java @@ -10,6 +10,7 @@ import cn.hutool.json.JSONArray; import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; @@ -22,6 +23,8 @@ import com.glxp.api.dto.RelaySyncDto; import com.glxp.api.entity.auth.*; import com.glxp.api.entity.basic.*; import com.glxp.api.entity.inout.*; +import com.glxp.api.entity.inv.DeviceInspectTaskDetailEntity; +import com.glxp.api.entity.inv.DeviceInspectTaskEntity; import com.glxp.api.entity.purchase.*; import com.glxp.api.entity.sync.BasicDownloadStatusEntity; import com.glxp.api.entity.sync.BasicExportStatusEntity; @@ -37,6 +40,8 @@ import com.glxp.api.service.auth.*; import com.glxp.api.service.basic.*; import com.glxp.api.service.inout.*; import com.glxp.api.service.inout.impl.IoOrderInvoiceService; +import com.glxp.api.service.inv.DeviceInspectTaskDetailService; +import com.glxp.api.service.inv.DeviceInspectTaskService; import com.glxp.api.service.system.*; import com.glxp.api.service.thrsys.*; import com.glxp.api.util.CustomUtil; @@ -233,7 +238,6 @@ public class HeartService { @Transactional(rollbackFor = Exception.class) public void pushData(SyncDataSetEntity info, Date syncTime, BasicExportTypeEnum exportType) { - Date now = new Date(); String taskId = CustomUtil.getId(); switch (exportType) { @@ -270,6 +274,12 @@ public class HeartService { case IO_ORDER: if (needExec()) break; + break; + case DEVICE_TASK: + if (needExec(info.getDeviceTask())) { + uploadData(exportType, taskId, x -> x.getDeviceTaskData(info, taskId, now, syncTime)); + } + break; } } @@ -1066,6 +1076,69 @@ public class HeartService { return dataResponse; } + + @Resource + DeviceInspectTaskService deviceInspectTaskService; + @Resource + DeviceInspectTaskDetailService deviceInspectTaskDetailService; + @Value("${file_path}") + private String filePath; + @Resource + FileService fileService; + + /** + * @param info + * @param taskId + * @param now + * @param syncTime + * @return + */ + private SpsSyncDeviceTaskResponse getDeviceTaskData(SyncDataSetEntity info, String taskId, Date now, Date syncTime) { + SpsSyncDeviceTaskResponse dataResponse = null; + Map syncTimeMap = new WeakHashMap<>(3); + syncTimeMap.put("isNew", true); + boolean ge = false; + if (syncTime != null) { + ge = true; + } + StringBuffer remark = new StringBuffer(); + //确认有开启第三方部门信息同步 + if (needExec(info.getDeviceTask())) { + Map map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.DEVICE_TASK); + List deviceInspectTaskEntities = deviceInspectTaskService.list(Wrappers.lambdaQuery(DeviceInspectTaskEntity.class) + .le(!ge && (boolean) map.get("isNew"), DeviceInspectTaskEntity::getUpdateTime, now) + .between(ge, DeviceInspectTaskEntity::getUpdateTime, syncTime, now) + .between(!ge && !(boolean) map.get("isNew"), DeviceInspectTaskEntity::getUpdateTime + , map.get("oldDate"), now) + ); + if (CollectionUtil.isNotEmpty(deviceInspectTaskEntities)) { + dataResponse = new SpsSyncDeviceTaskResponse(); + dataResponse.setDeviceInspectTaskEntities(deviceInspectTaskEntities); + + remark.append("设备任务:").append(deviceInspectTaskEntities.size()).append("条\n"); + List datas = new ArrayList<>(); + List files = new ArrayList<>(); + for (DeviceInspectTaskEntity deviceInspectTaskEntity : deviceInspectTaskEntities) { + List deviceInspectTaskDetailEntities = deviceInspectTaskDetailService.list(new QueryWrapper().eq("taskOrderIdFk", deviceInspectTaskEntity.getOrderId())); + datas.addAll(deviceInspectTaskDetailEntities); + for (DeviceInspectTaskDetailEntity detailEntity : deviceInspectTaskDetailEntities) { + if (StrUtil.isNotEmpty(detailEntity.getInspectImage())) { + files.add(filePath + detailEntity.getInspectImage().replace(",", "")); + } + } + } + fileService.upload(files); + } + } + if (dataResponse != null) { + dataResponse.setTaskId(taskId); + dataResponse.setType(BasicExportTypeEnum.THIRD_DATA.getRemark()); + dataResponse.setSyncRemark(remark.toString()); + } + return dataResponse; + } + + /** * 判断是否需要执行 由内向外 * @@ -1716,8 +1789,6 @@ public class HeartService { } } - @Resource - FileService fileService; private final IdcService idcService; private final IoCodeLostMapper ioCodeLostMapper; diff --git a/src/main/java/com/glxp/api/upload/uploadController.java b/src/main/java/com/glxp/api/upload/uploadController.java index a4dce48c..dcde54dd 100644 --- a/src/main/java/com/glxp/api/upload/uploadController.java +++ b/src/main/java/com/glxp/api/upload/uploadController.java @@ -91,7 +91,7 @@ public class uploadController { file.transferTo(file1); Map rMap = new HashMap<>(); rMap.put("msg", "上传成功"); - rMap.put("path",newName); + rMap.put("path", newName); return ResultVOUtils.success(rMap); } catch (IOException e) { e.printStackTrace(); @@ -132,7 +132,7 @@ public class uploadController { file.transferTo(file1); Map rMap = new HashMap<>(); rMap.put("msg", "上传成功"); - rMap.put("name", fileUrl + savePath1 + "&name=" + newName); + rMap.put("name", newName); rMap.put("type", type); return ResultVOUtils.success(rMap); } catch (IOException e) { diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 55bc9cd7..390b02b7 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -8,7 +8,7 @@ spring: enabled: true max-file-size: 200MB max-request-size: 200MB - location: E:/tmp + location: D:/tmp mybatis-plus: mapper-locations: classpath:mybatis/mapper/*/*.xml