同步任务备份

dev2.0
anthonywj 2 years ago
parent a50fc4f2fb
commit d28b4f1699

@ -112,6 +112,13 @@ public enum BasicExportStatusTimeEnum {
*
*/
BUS_TYPE_CHANGE("bus_type_change","自动建业务单设置"),
/**
*
*/
DEVICE_TASK("device_task", "设备任务"),
;
@EnumValue
private String key;

@ -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", "业务单据"),

@ -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,6 +63,7 @@ public class DeviceInspectTakeController {
PageInfo<DeviceInspectTakeResponse> 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());
@ -86,7 +94,6 @@ public class DeviceInspectTakeController {
}
@PostMapping("/udiwms/inv/device/inspect/take/addDeviceInspecTake")
public BaseResponse addDeviceInspecTake(@RequestBody DeviceInspectTaskEntity deviceInspectTaskEntity) {
String orderId = gennerOrderUtils.createStOrderNo(new OrderNoTypeBean(Constant.DEVICE_INSPECT_PLAN_ORDER, "yyyyMMdd"));
@ -105,23 +112,36 @@ public class DeviceInspectTakeController {
return ResultVOUtils.success(deviceInspectTaskEntity);
}
@Resource
HeartService heartService;
@Resource
SyncDataSetService syncDataSetService;
void UploadDeviceTake(Integer id, Integer type) {
//提交上传到自助
//查询任务表
DeviceInspectTaskEntity deviceInspectTaskEntity=deviceInspectTaskService.getById(id);
List<DeviceInspectTaskDetailEntity> deviceInspectTaskDetailEntityList = deviceInspectTaskDetailService
.list(new QueryWrapper<DeviceInspectTaskDetailEntity>().eq("taskOrderIdFk",deviceInspectTaskEntity.getOrderId()));
SpsSyncDeviceTakeResponse spsSyncDeviceTakeResponse=new SpsSyncDeviceTakeResponse();
spsSyncDeviceTakeResponse.setDeviceInspectTaskEntity(deviceInspectTaskEntity);
spsSyncDeviceTakeResponse.setDeviceInspectTaskDetailEntityList(deviceInspectTaskDetailEntityList);
spsSyncDeviceTakeResponse.setType(type);
spGetHttpClient.postAllDeviceTake(spsSyncDeviceTakeResponse);
}
// DeviceInspectTaskEntity deviceInspectTaskEntity = deviceInspectTaskService.getById(id);
// List<DeviceInspectTaskDetailEntity> deviceInspectTaskDetailEntityList = deviceInspectTaskDetailService
// .list(new QueryWrapper<DeviceInspectTaskDetailEntity>().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();
}
});
}
//------------------------------------------ 详情方法--------------------------------------------------------------//
@ -162,5 +182,4 @@ public class DeviceInspectTakeController {
}
}

@ -68,5 +68,9 @@ public class SyncDataSetEntity {
private int manufacturerCert;
private int productCert;
private int orderInvoice; //发票信息
/**
*
*/
private int deviceTask;
}

@ -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<DeviceInspectTaskEntity> deviceInspectTaskEntities;
List<DeviceInspectTaskDetailEntity> deviceInspectTaskDetailEntities;
}

@ -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<String, Object> 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<String, Object> map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.DEVICE_TASK);
List<DeviceInspectTaskEntity> 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<DeviceInspectTaskDetailEntity> datas = new ArrayList<>();
List<String> files = new ArrayList<>();
for (DeviceInspectTaskEntity deviceInspectTaskEntity : deviceInspectTaskEntities) {
List<DeviceInspectTaskDetailEntity> deviceInspectTaskDetailEntities = deviceInspectTaskDetailService.list(new QueryWrapper<DeviceInspectTaskDetailEntity>().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;

@ -132,7 +132,7 @@ public class uploadController {
file.transferTo(file1);
Map<String, String> 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) {

@ -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

Loading…
Cancel
Save