|
|
@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
|
@ -13,6 +14,8 @@ import com.glxp.api.controller.sync.SpsSyncWebSocket;
|
|
|
|
import com.glxp.api.dao.basic.BasicProductsDao;
|
|
|
|
import com.glxp.api.dao.basic.BasicProductsDao;
|
|
|
|
import com.glxp.api.entity.basic.*;
|
|
|
|
import com.glxp.api.entity.basic.*;
|
|
|
|
import com.glxp.api.entity.inout.*;
|
|
|
|
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.purchase.*;
|
|
|
|
import com.glxp.api.entity.sync.BasicExportStatusEntity;
|
|
|
|
import com.glxp.api.entity.sync.BasicExportStatusEntity;
|
|
|
|
import com.glxp.api.entity.sync.BasicExportStatusTimeEntity;
|
|
|
|
import com.glxp.api.entity.sync.BasicExportStatusTimeEntity;
|
|
|
@ -24,11 +27,14 @@ import com.glxp.api.req.basic.UdiCompanyRequest;
|
|
|
|
import com.glxp.api.req.inout.FilterOrderRequest;
|
|
|
|
import com.glxp.api.req.inout.FilterOrderRequest;
|
|
|
|
import com.glxp.api.req.sync.SpsSyncDataRequest;
|
|
|
|
import com.glxp.api.req.sync.SpsSyncDataRequest;
|
|
|
|
import com.glxp.api.res.sync.SpSyncUdiResponse;
|
|
|
|
import com.glxp.api.res.sync.SpSyncUdiResponse;
|
|
|
|
|
|
|
|
import com.glxp.api.res.sync.SpsSyncDeviceTaskResponse;
|
|
|
|
import com.glxp.api.res.sync.SpsSyncOrderResponse;
|
|
|
|
import com.glxp.api.res.sync.SpsSyncOrderResponse;
|
|
|
|
import com.glxp.api.res.system.SyncDataSetResponse;
|
|
|
|
import com.glxp.api.res.system.SyncDataSetResponse;
|
|
|
|
import com.glxp.api.service.basic.*;
|
|
|
|
import com.glxp.api.service.basic.*;
|
|
|
|
import com.glxp.api.service.inout.*;
|
|
|
|
import com.glxp.api.service.inout.*;
|
|
|
|
import com.glxp.api.service.inout.impl.IoOrderInvoiceService;
|
|
|
|
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.purchase.*;
|
|
|
|
import com.glxp.api.service.purchase.*;
|
|
|
|
import com.glxp.api.service.thrsys.IThrBusTypeOriginService;
|
|
|
|
import com.glxp.api.service.thrsys.IThrBusTypeOriginService;
|
|
|
|
import com.glxp.api.util.CustomUtil;
|
|
|
|
import com.glxp.api.util.CustomUtil;
|
|
|
@ -233,6 +239,11 @@ public class SpsSyncDownloadService {
|
|
|
|
// , x -> x.generateDocumentTypeDataFile(info, now, true, syncTime));
|
|
|
|
// , x -> x.generateDocumentTypeDataFile(info, now, true, syncTime));
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case DEVICE_TASK:
|
|
|
|
|
|
|
|
basicExportInfoCreate(exportType, syncTime, now
|
|
|
|
|
|
|
|
, x -> x.generateDevTaskDataFile(info, now, false, syncTime)
|
|
|
|
|
|
|
|
, x -> x.generateDevTaskDataFile(info, now, true, syncTime));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -716,6 +727,89 @@ public class SpsSyncDownloadService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
DeviceInspectTaskService deviceInspectTaskService;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
DeviceInspectTaskDetailService deviceInspectTaskDetailService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 读取设备任务数据,创建文件
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
protected boolean generateDevTaskDataFile(SyncDataSetResponse info, Date now, boolean createFile, Date syncTime) {
|
|
|
|
|
|
|
|
StringBuffer remark = new StringBuffer();
|
|
|
|
|
|
|
|
BasicExportTypeEnum exportType = BasicExportTypeEnum.DEVICE_TASK;
|
|
|
|
|
|
|
|
List<String> syncFiles = new ArrayList<>();
|
|
|
|
|
|
|
|
Map<String, Object> jsonMap = new WeakHashMap<>(4);
|
|
|
|
|
|
|
|
Map<BasicExportStatusTimeEnum, Map<String, Object>> totalTimeMap = new WeakHashMap<>(10);
|
|
|
|
|
|
|
|
Map<String, Object> syncTimeMap = new WeakHashMap<>(3);
|
|
|
|
|
|
|
|
syncTimeMap.put("isNew", true);
|
|
|
|
|
|
|
|
boolean ge = false;
|
|
|
|
|
|
|
|
if (syncTime != null) {
|
|
|
|
|
|
|
|
ge = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Map<String, Object> map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.DEVICE_TASK, createFile);
|
|
|
|
|
|
|
|
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)) {
|
|
|
|
|
|
|
|
remark.append("设备任务主表:").append(deviceInspectTaskEntities.size()).append("条\n");
|
|
|
|
|
|
|
|
jsonMap.put(DeviceInspectTaskEntity.class.getSimpleName(), deviceInspectTaskEntities);
|
|
|
|
|
|
|
|
List<DeviceInspectTaskDetailEntity> datas = 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())) {
|
|
|
|
|
|
|
|
syncFiles.add(filePath + detailEntity.getInspectImage().replace(",", ""));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(datas)) {
|
|
|
|
|
|
|
|
remark.append("设备任务字表:").append(datas.size()).append("条\n");
|
|
|
|
|
|
|
|
jsonMap.put(DeviceInspectTaskDetailEntity.class.getSimpleName(), datas);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(syncFiles)) {
|
|
|
|
|
|
|
|
jsonMap.put("syncFiles", syncFiles);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (jsonMap.size() > 0) {
|
|
|
|
|
|
|
|
jsonMap.put(SYNC_REMARK, remark.toString());
|
|
|
|
|
|
|
|
if (!createFile) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
String fileFullPath = writeFile(filePath, exportType.getRemark(), JsonUtils.toJsonString(jsonMap));
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
//修改任务数据
|
|
|
|
|
|
|
|
boolean update = updateExportStatus(exportType, fileFullPath, remark.toString());
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
// 异常回滚
|
|
|
|
|
|
|
|
this.exportTimeRollback(totalTimeMap, exportType, fileFullPath);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
logger.error(String.format("syncIdcSps----process------------生成[%s]文件及更改库操作异常,异常信息<%s>"
|
|
|
|
|
|
|
|
, exportType.getRemark(), e.getMessage()));
|
|
|
|
|
|
|
|
// 异常回滚
|
|
|
|
|
|
|
|
this.exportTimeRollback(totalTimeMap, exportType, null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
} catch (
|
|
|
|
|
|
|
|
Exception e) {
|
|
|
|
|
|
|
|
logger.error(e.getMessage());
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 插入 basicExportStatusTime表
|
|
|
|
* 插入 basicExportStatusTime表
|
|
|
|
*
|
|
|
|
*
|
|
|
|