You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
udi-spms-java/src/main/java/com/glxp/api/controller/sync/SpsSyncDownloadController.java

1009 lines
54 KiB
Java

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.glxp.api.controller.sync;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.Dict;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.glxp.api.annotation.AuthRuleAnnotation;
import com.glxp.api.common.enums.ResultEnum;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.BasicExportStatusEnum;
import com.glxp.api.constant.BasicExportTypeEnum;
import com.glxp.api.constant.BasicProcessStatus;
import com.glxp.api.constant.ConstantStatus;
import com.glxp.api.dao.auth.*;
import com.glxp.api.dao.basic.*;
import com.glxp.api.dao.inout.*;
import com.glxp.api.dao.purchase.*;
import com.glxp.api.dao.schedule.SystemParamConfigDao;
import com.glxp.api.dao.system.*;
import com.glxp.api.dao.thrsys.*;
import com.glxp.api.entity.auth.*;
import com.glxp.api.entity.basic.*;
import com.glxp.api.entity.inout.*;
import com.glxp.api.entity.purchase.*;
import com.glxp.api.entity.sync.BasicDownloadStatusEntity;
import com.glxp.api.entity.sync.BasicExportStatusEntity;
import com.glxp.api.entity.system.*;
import com.glxp.api.entity.thrsys.*;
import com.glxp.api.req.sync.SpsSyncDataRequest;
import com.glxp.api.req.sync.SyncUpLoadRequest;
import com.glxp.api.res.sync.*;
import com.glxp.api.service.basic.IBasicBussinessTypeService;
import com.glxp.api.service.inout.IoAddInoutService;
import com.glxp.api.service.inout.IoCheckInoutService;
import com.glxp.api.service.inout.IoOrderService;
import com.glxp.api.service.purchase.PurOrderDetailService;
import com.glxp.api.service.purchase.PurOrderService;
import com.glxp.api.service.sync.BasicDownloadService;
import com.glxp.api.service.sync.BasicExportService;
import com.glxp.api.service.sync.SpsSyncDownloadService;
import com.glxp.api.util.CustomUtil;
import com.glxp.api.util.JsonUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.TransactionIsolationLevel;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Date;
import java.util.List;
@RestController
@Api(tags = "同步下载相关")
@RequiredArgsConstructor
public class SpsSyncDownloadController {
@Resource
SpsSyncDownloadService spsSyncDownloadService;
@Resource
BasicExportService basicExportService;
@Resource
BasicDownloadService basicDownloadService;
@Resource
SqlSessionFactory sqlSessionFactory;
@Resource
IoOrderService orderService;
@Resource
PurOrderService purOrderService;
@Resource
IoAddInoutService addInoutService;
@Resource
IoCheckInoutService ioCheckInoutService;
@Resource
PurOrderDetailService purOrderDetailService;
@Resource
AuthAdminDao authAdminDao;
@Resource
InvBusUserDao invBusUserDao;
@Resource
DeptDao deptDao;
@Resource
DeptUserDao deptUserDao;
@Resource
InvWarehouseDao invWarehouseDao;
@Resource
WarehouseBussinessTypeDao warehouseBussinessTypeDao;
@Resource
WarehouseUserDao warehouseUserDao;
// 下发单据接口 供给中继服务UDI管理系统下载
@AuthRuleAnnotation("")
@GetMapping("sps/sync/order")
public BaseResponse getOrder(SpsSyncDataRequest spsSyncDataRequest) {
BaseResponse<SpsSyncOrderResponse> baseResponse = spsSyncDownloadService.findOrder(spsSyncDataRequest);
BasicExportStatusEntity basicExportStatusEntity = basicExportService.findByData(ConstantStatus.SYNC_SCAN_ORDER, 0);
String logs = "";
if (basicExportStatusEntity != null) {
logs = logs + "单据:" + baseResponse.getData().getOrderEntities().size() + "条\n";
if (CollUtil.isNotEmpty(baseResponse.getData().getOrderDetailBizEntities()))
logs = logs + "单据详情:" + baseResponse.getData().getOrderDetailBizEntities().size() + "条\n";
if (CollUtil.isNotEmpty(baseResponse.getData().getCodeEntities()))
logs = logs + "单据条码信息:" + baseResponse.getData().getCodeEntities().size() + "条\n";
basicExportStatusEntity.setRemark(logs);
basicExportService.updateExportStatus(basicExportStatusEntity);
SpsSyncOrderResponse spsSyncOrderResponse = baseResponse.getData();
spsSyncOrderResponse.setTaskId(basicExportStatusEntity.getId());
baseResponse.setData(spsSyncOrderResponse);
}
return baseResponse;
}
// 下发国家库DI数据供给中继服务UDI管理系统下载
@AuthRuleAnnotation("")
@GetMapping("sps/sync/syncUdis")
public BaseResponse getDiProducts(SpsSyncDataRequest spsSyncDataRequest) {
BaseResponse<SpSyncUdiResponse> baseResponse = spsSyncDownloadService.syncUdi(spsSyncDataRequest);
BasicExportStatusEntity basicExportStatusEntity = basicExportService.findByData(ConstantStatus.SYNC_DI_PRODUCTS, 0);
String logs = "";
if (basicExportStatusEntity != null) {
if (CollUtil.isNotEmpty(baseResponse.getData().getProductInfoEntityList()))
logs = logs + "DI信息" + baseResponse.getData().getProductInfoEntityList().size() + "条\n";
if (CollUtil.isNotEmpty(baseResponse.getData().getUdiCompanyEntities()))
logs = logs + "医疗器械注册人:" + baseResponse.getData().getUdiCompanyEntities().size() + "条\n";
basicExportStatusEntity.setRemark(logs);
basicExportService.updateExportStatus(basicExportStatusEntity);
SpSyncUdiResponse spSyncUdiResponse = baseResponse.getData();
spSyncUdiResponse.setTaskId(basicExportStatusEntity.getId());
baseResponse.setData(spSyncUdiResponse);
}
return baseResponse;
}
// 下发基础数据 供给中继服务UDI管理系统下载
@AuthRuleAnnotation("")
@GetMapping("sps/sync/data")
@ApiOperation("拉取同步任务数据")
public BaseResponse data(BasicExportTypeEnum exportType) {
BaseResponse<RelaySyncResponse> baseResponse = new BaseResponse<>();
BasicExportStatusEntity one = basicExportService.getOne(Wrappers.lambdaQuery(BasicExportStatusEntity.class)
.eq(BasicExportStatusEntity::getType, exportType.getRemark())
.orderByDesc(BasicExportStatusEntity::getStartTime)
.last("limit 1")
);
RelaySyncResponse relaySyncResponse = null;
if (one != null) {
if (BasicExportStatusEnum.WAIT_TRIGGERED.getCode().equals(one.getStatus())) {
basicExportService.update(Wrappers.lambdaUpdate(BasicExportStatusEntity.class)
.set(BasicExportStatusEntity::getStatus, BasicExportStatusEnum.WAIT_BUILT.getCode())
.set(BasicExportStatusEntity::getUpdateTime, new Date())
.eq(BasicExportStatusEntity::getStatus, BasicExportStatusEnum.WAIT_TRIGGERED.getCode())
.eq(BasicExportStatusEntity::getId, one.getId())
);
} else if (BasicExportStatusEnum.WAIT_SYNC.getCode().equals(one.getStatus())) {
if (StrUtil.isBlank(one.getCacheFilePath())) {
throw new RuntimeException("系统异常,文件名为空");
}
relaySyncResponse = RelaySyncResponse.builder()
.taskId(one.getId())
.filePath(one.getCacheFilePath())
.fileContent(this.readDataFile(one.getCacheFilePath()))
.build();
}
}
baseResponse.setCode(ResultEnum.SUCCESS.getCode());
baseResponse.setData(relaySyncResponse);
return baseResponse;
}
private String readDataFile(String fileFullPath) {
// 读取文件数据
try {
if (StrUtil.isBlank(fileFullPath)) {
throw new RuntimeException("系统异常,文件名为空");
}
FileReader reader = new FileReader(fileFullPath);
StringBuilder str = new StringBuilder();
int data;
while ((data = reader.read()) != -1) {
str.append((char) data);
}
reader.close();
return str.toString();
} catch (FileNotFoundException e) {
throw new RuntimeException("系统异常,未找到对应数据文件");
} catch (IOException e) {
throw new RuntimeException(e);
}
}
// 下发基础数据 供给中继服务UDI管理系统下载
@AuthRuleAnnotation("")
@GetMapping("sps/sync/basicData")
public BaseResponse getBasicData() {
BaseResponse<SpsSyncBasicDataResponse> baseResponse = new BaseResponse<>();
SpsSyncBasicDataResponse spsSyncBasicDataResponse = null;
BasicExportStatusEntity one = basicExportService.getOne(Wrappers.lambdaQuery(BasicExportStatusEntity.class)
.eq(BasicExportStatusEntity::getType, BasicExportTypeEnum.BASIC_DATA.getRemark())
.orderByDesc(BasicExportStatusEntity::getStartTime)
.last("limit 1")
);
if (one != null) {
if (BasicExportStatusEnum.WAIT_TRIGGERED.getCode().equals(one.getStatus())) {
basicExportService.update(Wrappers.lambdaUpdate(BasicExportStatusEntity.class)
.set(BasicExportStatusEntity::getStatus, BasicExportStatusEnum.WAIT_BUILT.getCode())
.set(BasicExportStatusEntity::getUpdateTime, new Date())
.eq(BasicExportStatusEntity::getStatus, BasicExportStatusEnum.WAIT_TRIGGERED.getCode())
.eq(BasicExportStatusEntity::getId, one.getId())
);
} else if (BasicExportStatusEnum.WAIT_SYNC.getCode().equals(one.getStatus())) {
// 读取文件数据
try {
FileReader reader = new FileReader(one.getCacheFilePath());
StringBuilder str = new StringBuilder();
int data;
while ((data = reader.read()) != -1) {
str.append((char) data);
}
reader.close();
Dict map = JsonUtils.parseMap(str.toString());
spsSyncBasicDataResponse = new SpsSyncBasicDataResponse();
// 组装返回数据
spsSyncBasicDataResponse.setTaskId(one.getId());
spsSyncBasicDataResponse.setHospTypeList((List<BasicHospTypeEntity>) map.get(BasicHospTypeEntity.class.getSimpleName()));
spsSyncBasicDataResponse.setUdiRelevanceList((List<UdiRelevanceEntity>) map.get(UdiRelevanceEntity.class.getSimpleName()));
spsSyncBasicDataResponse.setProductsList((List<BasicProductsEntity>) map.get(BasicProductsEntity.class.getSimpleName()));
spsSyncBasicDataResponse.setRelevanceList((List<CompanyProductRelevanceEntity>) map.get(CompanyProductRelevanceEntity.class.getSimpleName()));
spsSyncBasicDataResponse.setCorpList((List<BasicCorpEntity>) map.get(BasicCorpEntity.class.getSimpleName()));
spsSyncBasicDataResponse.setSupCertList((List<SupCertEntity>) map.get(SupCertEntity.class.getSimpleName()));
spsSyncBasicDataResponse.setSupCertSetList((List<SupCertSetEntity>) map.get(SupCertSetEntity.class.getSimpleName()));
spsSyncBasicDataResponse.setSupCompanyList((List<SupCompanyEntity>) map.get(SupCompanyEntity.class.getSimpleName()));
spsSyncBasicDataResponse.setSupManufacturerList((List<SupManufacturerEntity>) map.get(SupManufacturerEntity.class.getSimpleName()));
spsSyncBasicDataResponse.setSupProductList((List<SupProductEntity>) map.get(SupProductEntity.class.getSimpleName()));
} catch (FileNotFoundException e) {
throw new RuntimeException("系统异常,未找到对应数据文件");
} catch (IOException e) {
throw new RuntimeException(e);
}
// 修改任务状态
// basicExportService.update(Wrappers.lambdaUpdate(BasicExportStatusEntity.class)
// .set(BasicExportStatusEntity::getStatus, BasicExportStatusEnum.COMPLETED.getCode())
// .set(BasicExportStatusEntity::getUpdateTime, new Date())
// .set(BasicExportStatusEntity::getEndTime, new Date())
// .eq(BasicExportStatusEntity::getStatus, BasicExportStatusEnum.WAIT_SYNC.getCode())
// .eq(BasicExportStatusEntity::getId, one.getId())
// );
}
}
baseResponse.setCode(ResultVOUtils.success().getCode());
baseResponse.setData(spsSyncBasicDataResponse);
return baseResponse;
}
// 下发基础数据 供给中继服务UDI管理系统下载
@AuthRuleAnnotation("")
@GetMapping("sps/sync/otherData")
public BaseResponse getOtherData() {
BaseResponse<SpsSyncOtherDataResponse> baseResponse = new BaseResponse<>();
SpsSyncOtherDataResponse spsSyncOtherDataResponse = null;
BasicExportStatusEntity one = basicExportService.getOne(Wrappers.lambdaQuery(BasicExportStatusEntity.class)
.eq(BasicExportStatusEntity::getType, BasicExportTypeEnum.OTHER_DATA.getRemark())
.orderByDesc(BasicExportStatusEntity::getStartTime)
.last("limit 1")
);
if (one != null) {
if (BasicExportStatusEnum.WAIT_TRIGGERED.getCode().equals(one.getStatus())) {
basicExportService.update(Wrappers.lambdaUpdate(BasicExportStatusEntity.class)
.set(BasicExportStatusEntity::getStatus, BasicExportStatusEnum.WAIT_BUILT.getCode())
.set(BasicExportStatusEntity::getUpdateTime, new Date())
.eq(BasicExportStatusEntity::getStatus, BasicExportStatusEnum.WAIT_TRIGGERED.getCode())
.eq(BasicExportStatusEntity::getId, one.getId())
);
} else if (BasicExportStatusEnum.WAIT_SYNC.getCode().equals(one.getStatus())) {
// 读取文件数据
try {
FileReader reader = new FileReader(one.getCacheFilePath());
StringBuilder str = new StringBuilder();
int data;
while ((data = reader.read()) != -1) {
str.append((char) data);
}
reader.close();
Dict map = JsonUtils.parseMap(str.toString());
spsSyncOtherDataResponse = new SpsSyncOtherDataResponse();
// 组装返回数据
spsSyncOtherDataResponse.setTaskId(one.getId());
spsSyncOtherDataResponse.setIoCodeLostList((List<IoCodeLostEntity>) map.get(IoCodeLostEntity.class.getSimpleName()));
spsSyncOtherDataResponse.setIoCodeRelList((List<IoCodeRelEntity>) map.get(IoCodeRelEntity.class.getSimpleName()));
} catch (FileNotFoundException e) {
throw new RuntimeException("系统异常,未找到对应数据文件");
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
baseResponse.setCode(ResultVOUtils.success().getCode());
baseResponse.setData(spsSyncOtherDataResponse);
return baseResponse;
}
@ApiOperation("上传同步数据")
@PostMapping("sps/sync/upload/data")
public Object uploadData(@RequestBody SyncUpLoadRequest upLoadRequest) {
try {
JSONObject obj = JSONUtil.parseObj(upLoadRequest.getData());
switch (upLoadRequest.getExportType()) {
case BASIC_DATA:
saveUploadBasicData(JSONUtil.toBean(obj, SpsSyncBasicDataResponse.class));
break;
case OTHER_DATA:
saveUploadOtherData(JSONUtil.toBean(obj, SpsSyncOtherDataResponse.class));
break;
case DOCUMENT_TYPE_DATA:
saveUploadDocumentTypeData(JSONUtil.toBean(obj, SpsSyncBusResponse.class));
break;
case COUNTRY_DI_DATA:
}
String taskId = obj.getStr("taskId");
BasicDownloadStatusEntity downloadStatus = BasicDownloadStatusEntity.builder()
.id(taskId)
.taskId(taskId)
.startTime(new Date())
.endTime(new Date())
.updateTime(new Date())
.type(upLoadRequest.getExportType().getRemark())
.idDatas(upLoadRequest.getExportType().getKey())
.scheduleType(1)
.build();
basicDownloadService.insertDownloadStatus(downloadStatus);
return ResultVOUtils.success();
} catch (Exception e) {
e.printStackTrace();
return ResultVOUtils.error(ResultEnum.NOT_NETWORK, e.getMessage());
}
}
private final BasicBussinessTypeDao basicBussinessTypeDao;
private final BasicBusTypeChangeDao busTypeChangeDao;
private final ThrBusTypeOriginDao thrBusTypeOriginDao;
/**
* 保存上传的单据类型数据
*
* @param bean
*/
private void saveUploadDocumentTypeData(SpsSyncBusResponse bean) {
if (CollectionUtil.isNotEmpty(bean.getBussinessTypeEntities())) {
basicBussinessTypeDao.insertOrUpdateBatch(bean.getBussinessTypeEntities());
}
if (CollectionUtil.isNotEmpty(bean.getBusTypeChangeEntities())) {
busTypeChangeDao.insertOrUpdateBatch(bean.getBusTypeChangeEntities());
}
if (CollectionUtil.isNotEmpty(bean.getThrBusTypeOriginEntities())) {
thrBusTypeOriginDao.insertOrUpdateBatch(bean.getThrBusTypeOriginEntities());
}
}
private final IoCodeLostMapper ioCodeLostMapper;
private final IoCodeRelMapper ioCodeRelMapper;
/**
* 保存上传的其他数据
*
* @param bean
*/
private void saveUploadOtherData(SpsSyncOtherDataResponse bean) {
if (CollectionUtil.isNotEmpty(bean.getIoCodeLostList())) {
ioCodeLostMapper.insertOrUpdateBatch(bean.getIoCodeLostList());
}
if (CollectionUtil.isNotEmpty(bean.getIoCodeRelList())) {
ioCodeRelMapper.insertOrUpdateBatch(bean.getIoCodeRelList());
}
}
private final BasicHospTypeDao basicHospTypeDao;
private final UdiRelevanceDao udiRelevanceDao;
private final BasicProductsDao basicProductsDao;
private final CompanyProductRelevanceDao relevanceDao;
private final BasicCorpDao corpDao;
private final SupCertDao supCertDao;
private final SupCertSetDao supCertSetDao;
private final SupCompanyDao supCompanyDao;
private final SupManufacturerDao supManufacturerDao;
private final SupProductDao supProductDao;
/**
* 保存上传的基础数据
*
* @param bean
*/
private void saveUploadBasicData(SpsSyncBasicDataResponse bean) {
if (CollectionUtil.isNotEmpty(bean.getHospTypeList())) {
basicHospTypeDao.insertOrUpdateBatch(bean.getHospTypeList());
}
if (CollectionUtil.isNotEmpty(bean.getUdiRelevanceList())) {
udiRelevanceDao.insertOrUpdateBatch(bean.getUdiRelevanceList());
}
if (CollectionUtil.isNotEmpty(bean.getProductsList())) {
basicProductsDao.insertOrUpdateBatch(bean.getProductsList());
}
if (CollectionUtil.isNotEmpty(bean.getRelevanceList())) {
relevanceDao.insertOrUpdateBatch(bean.getRelevanceList());
}
if (CollectionUtil.isNotEmpty(bean.getCorpList())) {
corpDao.insertOrUpdateBatch(bean.getCorpList());
}
if (CollectionUtil.isNotEmpty(bean.getSupCertList())) {
supCertDao.insertOrUpdateBatch(bean.getSupCertList());
}
if (CollectionUtil.isNotEmpty(bean.getSupCertSetList())) {
supCertSetDao.insertOrUpdateBatch(bean.getSupCertSetList());
}
if (CollectionUtil.isNotEmpty(bean.getSupCompanyList())) {
supCompanyDao.insertOrUpdateBatch(bean.getSupCompanyList());
}
if (CollectionUtil.isNotEmpty(bean.getSupManufacturerList())) {
supManufacturerDao.insertOrUpdateBatch(bean.getSupManufacturerList());
}
if (CollectionUtil.isNotEmpty(bean.getSupProductList())) {
supProductDao.insertOrUpdateBatch(bean.getSupProductList());
}
}
//接收中继服务、UDI管理系统上传单据
@AuthRuleAnnotation("sps/sync/order/upload")
@PostMapping("/sps/sync/order/upload")
public BaseResponse uploadOrder(@RequestBody @Valid SpsSyncOrderResponse syncDataResponse) {
BasicDownloadStatusEntity basicDownloadStatusEntity = new BasicDownloadStatusEntity();
basicDownloadStatusEntity.setId(CustomUtil.getId());
basicDownloadStatusEntity.setTaskId(syncDataResponse.getTaskId());
basicDownloadStatusEntity.setStartTime(new Date());
basicDownloadStatusEntity.setIdDatas(ConstantStatus.SYNC_DOWNLOAD_SCAN_ORDER);
basicDownloadStatusEntity.setStatus(ConstantStatus.SYNC_STATUS_WAIT); //下载中
basicDownloadStatusEntity.setType(BasicProcessStatus.NEW_ALL_ORDER);
basicDownloadStatusEntity.setScheduleType(1);
basicDownloadService.insertDownloadStatus(basicDownloadStatusEntity);
StringBuffer remark = new StringBuffer();
SqlSession batchSession = sqlSessionFactory.openSession(ExecutorType.BATCH, TransactionIsolationLevel.READ_COMMITTED);
if (CollUtil.isNotEmpty(syncDataResponse.getOrderEntities())) {
try {
List<IoOrderEntity> orderEntities = syncDataResponse.getOrderEntities();
IoOrderDao mapper = batchSession.getMapper(IoOrderDao.class);
for (IoOrderEntity orderEntity : orderEntities) {
orderEntity.setUpdateTime(null);
orderEntity.setFromType(ConstantStatus.FROM_UDISP);
orderEntity.setStatus(ConstantStatus.ORDER_STATUS_PROCESS);
IoOrderEntity temp = orderService.findById(orderEntity.getBillNo());
if (temp == null) {
orderEntity.setId(null);
mapper.insert(orderEntity);
//更新码详情
if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailCodeEntities())) {
IoCodeTempDao codeMappert = batchSession.getMapper(IoCodeTempDao.class);
List<IoCodeEntity> warehouseEntityList = syncDataResponse.getCodeEntities();
for (IoCodeEntity warehouseEntity : warehouseEntityList) {
if (warehouseEntity.getOrderId().equals(orderEntity.getBillNo())) {
IoCodeTempEntity codeTempEntity = new IoCodeTempEntity();
BeanUtils.copyProperties(warehouseEntity, codeTempEntity);
codeTempEntity.setId(null);
codeMappert.insert(codeTempEntity);
}
}
}
//更新业务详情
if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailBizEntities())) {
IoOrderDetailBizDao orderDetailBizDao = batchSession.getMapper(IoOrderDetailBizDao.class);
List<IoOrderDetailBizEntity> orderDetailBizEntities = syncDataResponse.getOrderDetailBizEntities();
for (IoOrderDetailBizEntity bizEntity : orderDetailBizEntities) {
if (bizEntity.getOrderIdFk().equals(orderEntity.getBillNo())) {
orderDetailBizDao.insert(bizEntity);
}
}
}
//更新码详情
if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailCodeEntities())) {
IoOrderDetailCodeDao orderDetailCodeDao = batchSession.getMapper(IoOrderDetailCodeDao.class);
List<IoOrderDetailCodeEntity> orderDetailCodeEntities = syncDataResponse.getOrderDetailCodeEntities();
for (IoOrderDetailCodeEntity codeEntity : orderDetailCodeEntities) {
if (codeEntity.getOrderIdFk().equals(orderEntity.getBillNo())) {
orderDetailCodeDao.insert(codeEntity);
}
}
}
//更新结果详情
if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailResultEntities())) {
IoOrderDetailResultDao orderDetailResultDao = batchSession.getMapper(IoOrderDetailResultDao.class);
List<IoOrderDetailResultEntity> orderDetailResultEntities = syncDataResponse.getOrderDetailResultEntities();
for (IoOrderDetailResultEntity detailResultEntity : orderDetailResultEntities) {
if (detailResultEntity.getOrderIdFk().equals(orderEntity.getBillNo())) {
orderDetailResultDao.insert(detailResultEntity);
}
}
}
//更新发票信息
if (CollUtil.isNotEmpty(syncDataResponse.getOrderInvoiceEntities())) {
IoOrderInvoiceMapper orderInvoiceMapper = batchSession.getMapper(IoOrderInvoiceMapper.class);
List<IoOrderInvoiceEntity> orderInvoiceEntities = syncDataResponse.getOrderInvoiceEntities();
for (IoOrderInvoiceEntity orderInvoiceEntity : orderInvoiceEntities) {
if (orderInvoiceEntity.getOrderIdFk().equals(orderEntity.getBillNo())) {
orderInvoiceMapper.insert(orderInvoiceEntity);
}
}
}
batchSession.commit();
orderEntity = orderService.findByBillNo(orderEntity.getBillNo());
addInoutService.dealProcess(orderEntity);
orderEntity = orderService.findByBillNo(orderEntity.getBillNo());
if (orderEntity.getStatus() != ConstantStatus.ORDER_STATS_ERROR && !ioCheckInoutService.checkManual(orderEntity.getBillNo())) {
ioCheckInoutService.check(orderEntity.getBillNo());
}
}
}
batchSession.commit();
String logs = "";
if (CollUtil.isNotEmpty(syncDataResponse.getOrderEntities()))
logs = logs + "单据:" + syncDataResponse.getOrderEntities().size() + "条\n";
if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailBizEntities()))
logs = logs + "业务详情:" + syncDataResponse.getOrderDetailBizEntities().size() + "条\n";
if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailCodeEntities()))
logs = logs + "单据扫码详情:" + syncDataResponse.getOrderDetailCodeEntities().size() + "条\n";
if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailResultEntities()))
logs = logs + "单据结果详情:" + syncDataResponse.getOrderDetailResultEntities().size() + "条\n";
if (CollUtil.isNotEmpty(syncDataResponse.getCodeEntities()))
logs = logs + "单据条码信息:" + syncDataResponse.getCodeEntities().size() + "条\n";
remark.append(logs);
} catch (Exception e) {
e.printStackTrace();
}
}
batchSession.close();
basicDownloadStatusEntity.setUpdateTime(new Date());
basicDownloadStatusEntity.setEndTime(new Date());
basicDownloadStatusEntity.setRemark(remark.toString());
basicDownloadStatusEntity.setStatus(ConstantStatus.SYNC_STATUS_SUCCESS);
basicDownloadService.updateDownloadStatus(basicDownloadStatusEntity);
return ResultVOUtils.success("上传成功!");
}
//接收中级服务UDI管理系统上传业务单据
@AuthRuleAnnotation("/sps/sync/busOrder/upload")
@PostMapping("/sps/sync/busOrder/upload")
public BaseResponse uploadBusOrder(@RequestBody @Valid SpsSyncBusOrderResponse spsSyncBusOrderResponse) {
BasicDownloadStatusEntity basicDownloadStatusEntity = new BasicDownloadStatusEntity();
basicDownloadStatusEntity.setId(CustomUtil.getId());
basicDownloadStatusEntity.setTaskId(spsSyncBusOrderResponse.getTaskId());
basicDownloadStatusEntity.setStartTime(new Date());
basicDownloadStatusEntity.setIdDatas(ConstantStatus.SYNC_DOWNLOAD_SCAN_ORDER);
basicDownloadStatusEntity.setStatus(ConstantStatus.SYNC_STATUS_WAIT); //下载中
basicDownloadStatusEntity.setType(BasicProcessStatus.NEW_ALL_BUS_ORDER);
basicDownloadStatusEntity.setScheduleType(1);
basicDownloadService.insertDownloadStatus(basicDownloadStatusEntity);
StringBuffer remark = new StringBuffer();
if (CollUtil.isNotEmpty(spsSyncBusOrderResponse.getPurOrderEntities())) {
try {
List<PurOrderEntity> orderEntities = spsSyncBusOrderResponse.getPurOrderEntities();
for (PurOrderEntity orderEntity : orderEntities) {
orderEntity.setUpdateTime(null);
PurOrderEntity temp = purOrderService.selectByBillNo(orderEntity.getBillNo());
if (temp == null) {
orderEntity.setId(null);
purOrderService.insert(orderEntity);
if (CollUtil.isNotEmpty(spsSyncBusOrderResponse.getPurOrderDetailEntities())) {
List<PurOrderDetailEntity> purOrderDetailEntities = spsSyncBusOrderResponse.getPurOrderDetailEntities();
for (PurOrderDetailEntity purOrderDetailEntity : purOrderDetailEntities) {
PurOrderDetailEntity codeTempEntity = new PurOrderDetailEntity();
BeanUtils.copyProperties(purOrderDetailEntity, codeTempEntity);
codeTempEntity.setId(null);
codeTempEntity.setOrderIdFk(orderEntity.getId() + "");
purOrderDetailService.insert(codeTempEntity);
}
}
}
}
String logs = "";
if (CollUtil.isNotEmpty(spsSyncBusOrderResponse.getPurOrderEntities()))
logs = logs + "单据:" + spsSyncBusOrderResponse.getPurOrderEntities().size() + "条\n";
if (CollUtil.isNotEmpty(spsSyncBusOrderResponse.getPurOrderDetailEntities()))
logs = logs + "单据详情:" + spsSyncBusOrderResponse.getPurOrderDetailEntities().size() + "条\n";
remark.append(logs);
} catch (Exception e) {
e.printStackTrace();
}
}
basicDownloadStatusEntity.setUpdateTime(new Date());
basicDownloadStatusEntity.setEndTime(new Date());
basicDownloadStatusEntity.setRemark(remark.toString());
basicDownloadStatusEntity.setStatus(ConstantStatus.SYNC_STATUS_SUCCESS);
basicDownloadService.updateDownloadStatus(basicDownloadStatusEntity);
return ResultVOUtils.success("上传成功!");
}
//接收中继服务、UDI管理系统上传单据类型
@AuthRuleAnnotation("")
@PostMapping("sps/sync/busType/upload")
public BaseResponse uploadBusType(@RequestBody SpsSyncBusResponse syncDataResponse) {
if (syncDataResponse != null) {
SqlSession batchSession = sqlSessionFactory.openSession(ExecutorType.BATCH, TransactionIsolationLevel.READ_COMMITTED);
BasicDownloadStatusEntity basicDownloadStatusEntity = new BasicDownloadStatusEntity();
basicDownloadStatusEntity.setId(CustomUtil.getId());
basicDownloadStatusEntity.setTaskId(syncDataResponse.getTaskId());
basicDownloadStatusEntity.setStartTime(new Date());
basicDownloadStatusEntity.setIdDatas(ConstantStatus.SYNC_BUS_TYPE);
basicDownloadStatusEntity.setStatus(0);
basicDownloadStatusEntity.setType(BasicProcessStatus.NEW_ALL_BUS);
basicDownloadStatusEntity.setScheduleType(1);
basicDownloadService.insertDownloadStatus(basicDownloadStatusEntity);
StringBuffer remark = new StringBuffer();
// 扫码单据类型
if (CollUtil.isNotEmpty(syncDataResponse.getBussinessTypeEntities())) {
try {
List<BasicBussinessTypeEntity> bussinessTypeEntities = syncDataResponse.getBussinessTypeEntities();
BasicBussinessTypeDao mapper = batchSession.getMapper(BasicBussinessTypeDao.class);
for (BasicBussinessTypeEntity bussinessTypeEntity : bussinessTypeEntities) {
mapper.insertOrUpdate(bussinessTypeEntity);
}
batchSession.commit();
remark.append("扫码单据类型:").append(syncDataResponse.getBussinessTypeEntities().size()).append("条\n");
} catch (Exception e) {
e.printStackTrace();
}
}
//业务单据
if (CollUtil.isNotEmpty(syncDataResponse.getBusTypeChangeEntities())) {
try {
List<BasicBusTypeChangeEntity> busTypeChangeEntities = syncDataResponse.getBusTypeChangeEntities();
BasicBusTypeChangeDao mapper = batchSession.getMapper(BasicBusTypeChangeDao.class);
busTypeChangeEntities.forEach(busTypeChangeEntity ->
{
mapper.insertOrUpdate(busTypeChangeEntity);
});
batchSession.commit();
remark.append("业务单据类型:").append(syncDataResponse.getBussinessTypeEntities().size()).append("条\n");
} catch (Exception e) {
e.printStackTrace();
}
}
//原始单据
if (CollUtil.isNotEmpty(syncDataResponse.getThrBusTypeOriginEntities())) {
try {
List<ThrBusTypeOriginEntity> bussinessTypeEntities = syncDataResponse.getThrBusTypeOriginEntities();
ThrBusTypeOriginDao mapper = batchSession.getMapper(ThrBusTypeOriginDao.class);
for (ThrBusTypeOriginEntity bussinessTypeEntity : bussinessTypeEntities) {
mapper.insertOrUpdate(bussinessTypeEntity);
}
batchSession.commit();
remark.append("第三方单据类型:").append(syncDataResponse.getBussinessTypeEntities().size()).append("条\n");
} catch (Exception e) {
e.printStackTrace();
}
}
batchSession.close();
basicDownloadStatusEntity.setStatus(1);
basicDownloadStatusEntity.setUpdateTime(new Date());
basicDownloadStatusEntity.setEndTime(new Date());
basicDownloadStatusEntity.setRemark(remark.toString());
basicDownloadService.updateDownloadStatus(basicDownloadStatusEntity);
}
return ResultVOUtils.success("上传成功!");
}
//接收中继服务、UDI管理系统上传用户数据
@AuthRuleAnnotation("")
@PostMapping("sps/sync/userData/upload")
public BaseResponse uploadUserData(@RequestBody SpsSyncDataResponse syncDataResponse) {
if (syncDataResponse != null) {
SqlSession batchSession = sqlSessionFactory.openSession(ExecutorType.BATCH, TransactionIsolationLevel.READ_COMMITTED);
BasicDownloadStatusEntity basicDownloadStatusEntity = new BasicDownloadStatusEntity();
basicDownloadStatusEntity.setId(CustomUtil.getId());
basicDownloadStatusEntity.setTaskId(syncDataResponse.getTaskId());
basicDownloadStatusEntity.setStartTime(new Date());
basicDownloadStatusEntity.setIdDatas(ConstantStatus.SYNC_BASIC_DATA);
basicDownloadStatusEntity.setStatus(0);
basicDownloadStatusEntity.setType(BasicProcessStatus.NEW_ALL_DATA);
basicDownloadStatusEntity.setScheduleType(1);
basicDownloadService.insertDownloadStatus(basicDownloadStatusEntity);
StringBuffer remark = new StringBuffer();
//用户表
if (CollUtil.isNotEmpty(syncDataResponse.getAuthAdminList())) {
for (AuthAdmin authAdmin : syncDataResponse.getAuthAdminList()) {
authAdmin.setId(null);
authAdminDao.insertOrUpdate(authAdmin);
remark.append("用户信息:").append(syncDataResponse.getAuthAdminList().size()).append("条\n");
}
}
//用户对应单据类型
if (CollUtil.isNotEmpty(syncDataResponse.getInvBusUserEntities())) {
for (InvBusUserEntity invBusUserEntity : syncDataResponse.getInvBusUserEntities()) {
invBusUserDao.insertOrUpdate(invBusUserEntity);
}
}
// 部门信息
if (CollUtil.isNotEmpty(syncDataResponse.getDeptEntityList())) {
for (DeptEntity deptEntity : syncDataResponse.getDeptEntityList()) {
deptDao.insertOrUpdate(deptEntity);
}
}
// 部门信息关联用户信息
if (CollUtil.isNotEmpty(syncDataResponse.getDeptUserEntities())) {
for (DeptUserEntity deptUserEntity : syncDataResponse.getDeptUserEntities()) {
deptUserDao.insertOrUpdate(deptUserEntity);
}
}
//仓库字典导入
if (CollUtil.isNotEmpty(syncDataResponse.getInvWarehouseEntities())) {
for (InvWarehouseEntity invWarehouseEntity : syncDataResponse.getInvWarehouseEntities()) {
invWarehouseDao.insertOrUpdate(invWarehouseEntity);
}
remark.append("仓库字典:").append(syncDataResponse.getInvWarehouseEntities().size()).append("条\n");
}
//仓库用户表
if (CollUtil.isNotEmpty(syncDataResponse.getWarehouseUserEntities())) {
for (WarehouseUserEntity warehouseUserEntity : syncDataResponse.getWarehouseUserEntities()) {
warehouseUserDao.insertOrUpdate(warehouseUserEntity);
}
remark.append("仓库用户信息:").append(syncDataResponse.getWarehouseUserEntities().size()).append("条\n");
}
//仓库单据类型表
if (CollUtil.isNotEmpty(syncDataResponse.getWarehouseBussinessTypeEntities())) {
for (WarehouseBussinessTypeEntity warehouseUserEntity : syncDataResponse.getWarehouseBussinessTypeEntities()) {
warehouseBussinessTypeDao.insertOrUpdate(warehouseUserEntity);
}
remark.append("仓库所属单据类型:").append(syncDataResponse.getWarehouseBussinessTypeEntities().size()).append("条\n");
}
batchSession.close();
basicDownloadStatusEntity.setStatus(1);
basicDownloadStatusEntity.setUpdateTime(new Date());
basicDownloadStatusEntity.setEndTime(new Date());
basicDownloadStatusEntity.setRemark(remark.toString());
basicDownloadService.updateDownloadStatus(basicDownloadStatusEntity);
}
return ResultVOUtils.success("上传成功!");
}
//接收中继服务、UDI管理系统上传基础信息
//@AuthRuleAnnotation("")
@PostMapping("/sps/sync/thrData/upload")
public BaseResponse uploadThrData(@RequestBody @Valid SpsSyncThrDataResponse spsSyncThrDataResponse) {
if (spsSyncThrDataResponse != null) {
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, TransactionIsolationLevel.READ_COMMITTED);
BasicDownloadStatusEntity basicDownloadStatusEntity = new BasicDownloadStatusEntity();
basicDownloadStatusEntity.setId(CustomUtil.getId());
basicDownloadStatusEntity.setTaskId(spsSyncThrDataResponse.getTaskId());
basicDownloadStatusEntity.setStartTime(new Date());
basicDownloadStatusEntity.setIdDatas(ConstantStatus.SYNC_THR_DATA);
basicDownloadStatusEntity.setStatus(0);
basicDownloadStatusEntity.setType(BasicProcessStatus.NEW_ALL_THR_DATA);
basicDownloadStatusEntity.setScheduleType(1);
basicDownloadService.insertDownloadStatus(basicDownloadStatusEntity);
StringBuilder remark = new StringBuilder();
//第三方部门信息
if (CollUtil.isNotEmpty(spsSyncThrDataResponse.getDeptEntities())) {
List<ThrDeptEntity> deptEntities = spsSyncThrDataResponse.getDeptEntities();
ThrDeptDao mapper = sqlSession.getMapper(ThrDeptDao.class);
deptEntities.forEach(mapper::insertOrUpdate);
}
sqlSession.commit();
remark.append("第三方部门信息:").append(spsSyncThrDataResponse.getDeptEntities().size()).append("条\n");
//第三方仓库信息
if (CollUtil.isNotEmpty(spsSyncThrDataResponse.getInvWarehouseEntities())) {
List<ThrInvWarehouseEntity> invWarehouseEntities = spsSyncThrDataResponse.getInvWarehouseEntities();
ThrInvWarehouseDao mapper = sqlSession.getMapper(ThrInvWarehouseDao.class);
invWarehouseEntities.forEach(mapper::insertOrUpdate);
}
sqlSession.commit();
remark.append("第三方仓库信息:").append(spsSyncThrDataResponse.getInvWarehouseEntities().size()).append("条\n");
//第三方往来单位信息
if (CollUtil.isNotEmpty(spsSyncThrDataResponse.getCorpEntities())) {
List<ThrCorpEntity> corpEntities = spsSyncThrDataResponse.getCorpEntities();
ThrCorpDao mapper = sqlSession.getMapper(ThrCorpDao.class);
corpEntities.forEach(mapper::insertOrUpdate);
}
sqlSession.commit();
remark.append("第三方往来单位信息:").append(spsSyncThrDataResponse.getCorpEntities().size()).append("条\n");
sqlSession.close();
basicDownloadStatusEntity.setStatus(1);
basicDownloadStatusEntity.setUpdateTime(new Date());
basicDownloadStatusEntity.setEndTime(new Date());
basicDownloadStatusEntity.setRemark(remark.toString());
basicDownloadService.updateDownloadStatus(basicDownloadStatusEntity);
}
return ResultVOUtils.success("上传成功");
}
//接收中继服务、UDI管理系统上传系统设置
//@AuthRuleAnnotation("")
@PostMapping("/sps/sync/sys/setting")
public BaseResponse uploadSysSetting(@RequestBody @Valid SpsSyncSysSettingResponse spsSyncSysSettingResponse) {
if (spsSyncSysSettingResponse != null) {
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, TransactionIsolationLevel.READ_COMMITTED);
BasicDownloadStatusEntity basicDownloadStatusEntity = new BasicDownloadStatusEntity();
basicDownloadStatusEntity.setId(CustomUtil.getId());
basicDownloadStatusEntity.setTaskId(spsSyncSysSettingResponse.getTaskId());
basicDownloadStatusEntity.setStartTime(new Date());
basicDownloadStatusEntity.setIdDatas(ConstantStatus.SYNC_SYS_SETTING);
basicDownloadStatusEntity.setStatus(0);
basicDownloadStatusEntity.setType(BasicProcessStatus.NEW_ALL_SYS_SETTING);
basicDownloadStatusEntity.setScheduleType(1);
basicDownloadService.insertDownloadStatus(basicDownloadStatusEntity);
StringBuilder remark = new StringBuilder();
//系统运行参数
if (CollUtil.isNotEmpty(spsSyncSysSettingResponse.getSystemParamConfigEntities())) {
List<SystemParamConfigEntity> systemParamConfigEntities = spsSyncSysSettingResponse.getSystemParamConfigEntities();
SystemParamConfigDao mapper = sqlSession.getMapper(SystemParamConfigDao.class);
systemParamConfigEntities.forEach(mapper::insertOrUpdate);
}
sqlSession.commit();
remark.append("系统运行参数:").append(spsSyncSysSettingResponse.getSystemParamConfigEntities().size()).append("条\n");
//委托验收设置
if (CollUtil.isNotEmpty(spsSyncSysSettingResponse.getEntrustReceEntities())) {
List<EntrustReceEntity> entrustReceEntities = spsSyncSysSettingResponse.getEntrustReceEntities();
EntrustReceDao mapper = sqlSession.getMapper(EntrustReceDao.class);
entrustReceEntities.forEach(mapper::insertOrUpdate);
}
sqlSession.commit();
remark.append("委托验收设置:").append(spsSyncSysSettingResponse.getEntrustReceEntities().size()).append("条\n");
//打印模块
if (CollUtil.isNotEmpty(spsSyncSysSettingResponse.getSystemPDFModuleEntities())) {
List<SystemPDFModuleEntity> systemPDFModuleEntities = spsSyncSysSettingResponse.getSystemPDFModuleEntities();
SystemPDFModuleDao mapper = sqlSession.getMapper(SystemPDFModuleDao.class);
systemPDFModuleEntities.forEach(mapper::insertOrUpdate);
}
sqlSession.commit();
remark.append("打印模块:").append(spsSyncSysSettingResponse.getSystemPDFModuleEntities().size()).append("条\n");
//打印模板
if (CollUtil.isNotEmpty(spsSyncSysSettingResponse.getSystemPDFTemplateEntities())) {
List<SystemPDFTemplateEntity> systemPDFTemplateEntities = spsSyncSysSettingResponse.getSystemPDFTemplateEntities();
SystemPDFTemplateDao mapper = sqlSession.getMapper(SystemPDFTemplateDao.class);
systemPDFTemplateEntities.forEach(mapper::insertOrUpdate);
}
sqlSession.commit();
remark.append("打印模板:").append(spsSyncSysSettingResponse.getSystemPDFTemplateEntities().size()).append("条\n");
//扫码单据关联表
if (CollUtil.isNotEmpty(spsSyncSysSettingResponse.getSysPdfTemplateRelevanceCodeEntities())) {
List<SysPdfTemplateRelevanceCodeEntity> sysPdfTemplateRelevanceCodeEntities = spsSyncSysSettingResponse.getSysPdfTemplateRelevanceCodeEntities();
SysPdfTemplateRelevanceCodeDao mapper = sqlSession.getMapper(SysPdfTemplateRelevanceCodeDao.class);
sysPdfTemplateRelevanceCodeEntities.forEach(mapper::insertOrUpdate);
}
sqlSession.commit();
remark.append("扫码单据关联表:").append(spsSyncSysSettingResponse.getSysPdfTemplateRelevanceCodeEntities().size()).append("条\n");
//业务单据关联表
if (CollUtil.isNotEmpty(spsSyncSysSettingResponse.getSysPdfTemplateRelevanceBizEntities())) {
List<SysPdfTemplateRelevanceBizEntity> sysPdfTemplateRelevanceBizEntities = spsSyncSysSettingResponse.getSysPdfTemplateRelevanceBizEntities();
SysPdfTemplateRelevanceBizDao mapper = sqlSession.getMapper(SysPdfTemplateRelevanceBizDao.class);
sysPdfTemplateRelevanceBizEntities.forEach(mapper::insertOrUpdate);
}
sqlSession.commit();
remark.append("业务单据关联表:").append(spsSyncSysSettingResponse.getSysPdfTemplateRelevanceBizEntities().size()).append("条\n");
//内部码打印关联表
if (CollUtil.isNotEmpty(spsSyncSysSettingResponse.getSysPdfTemplateRelevanceLabelEntities())) {
List<SysPdfTemplateRelevanceLabelEntity> sysPdfTemplateRelevanceLabelEntities = spsSyncSysSettingResponse.getSysPdfTemplateRelevanceLabelEntities();
SysPdfTemplateRelevanceLabelDao mapper = sqlSession.getMapper(SysPdfTemplateRelevanceLabelDao.class);
sysPdfTemplateRelevanceLabelEntities.forEach(mapper::insertOrUpdate);
}
sqlSession.commit();
remark.append("内部码打印关联表:").append(spsSyncSysSettingResponse.getSystemParamConfigEntities().size()).append("条\n");
//资质证书打印关联表
if (CollUtil.isNotEmpty(spsSyncSysSettingResponse.getSysPdfTemplateRelevanceStatemenEntities())) {
List<SysPdfTemplateRelevanceStatemenEntity> sysPdfTemplateRelevanceStatemenEntities = spsSyncSysSettingResponse.getSysPdfTemplateRelevanceStatemenEntities();
SysPdfTemplateRelevanceStatemenDao mapper = sqlSession.getMapper(SysPdfTemplateRelevanceStatemenDao.class);
sysPdfTemplateRelevanceStatemenEntities.forEach(mapper::insertOrUpdate);
}
sqlSession.commit();
remark.append("资质证书打印关联表:").append(spsSyncSysSettingResponse.getSysPdfTemplateRelevanceStatemenEntities().size()).append("条\n");
//自动建出入库单设置
if (CollUtil.isNotEmpty(spsSyncSysSettingResponse.getBasicBusTypePreEntities())) {
List<BasicBusTypePreEntity> basicBusTypePreEntities = spsSyncSysSettingResponse.getBasicBusTypePreEntities();
BasicBusTypePreDao mapper = sqlSession.getMapper(BasicBusTypePreDao.class);
basicBusTypePreEntities.forEach(mapper::insertOrUpdate);
}
sqlSession.commit();
remark.append("自动建出入库单设置:").append(spsSyncSysSettingResponse.getBasicBusTypePreEntities().size()).append("条\n");
//自动建业务单设置
if (CollUtil.isNotEmpty(spsSyncSysSettingResponse.getBasicBusTypeChangeEntities())) {
List<BasicBusTypeChangeEntity> basicBusTypeChangeEntities = spsSyncSysSettingResponse.getBasicBusTypeChangeEntities();
BasicBusTypeChangeDao mapper = sqlSession.getMapper(BasicBusTypeChangeDao.class);
basicBusTypeChangeEntities.forEach(mapper::insertOrUpdate);
}
sqlSession.commit();
remark.append("自动建业务单设置:").append(spsSyncSysSettingResponse.getBasicBusTypeChangeEntities().size()).append("条\n");
sqlSession.close();
basicDownloadStatusEntity.setStatus(1);
basicDownloadStatusEntity.setUpdateTime(new Date());
basicDownloadStatusEntity.setEndTime(new Date());
basicDownloadStatusEntity.setRemark(remark.toString());
basicDownloadService.updateDownloadStatus(basicDownloadStatusEntity);
}
return ResultVOUtils.success("上传成功");
}
//接收中继服务、UDI管理系统上传第三方产品信息
//@AuthRuleAnnotation("")
@PostMapping("/sps/sync/thrData/products/upload")
public BaseResponse uploadThrProducts(@RequestBody @Valid SpsSyncThrProductsResponse spsSyncThrProductsResponse) {
if (spsSyncThrProductsResponse != null) {
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, TransactionIsolationLevel.READ_COMMITTED);
BasicDownloadStatusEntity basicDownloadStatusEntity = new BasicDownloadStatusEntity();
basicDownloadStatusEntity.setId(CustomUtil.getId());
basicDownloadStatusEntity.setTaskId(spsSyncThrProductsResponse.getTaskId());
basicDownloadStatusEntity.setStartTime(new Date());
basicDownloadStatusEntity.setIdDatas(ConstantStatus.SYNC_THR_PRODUCTS);
basicDownloadStatusEntity.setStatus(0);
basicDownloadStatusEntity.setType(BasicProcessStatus.NEW_ALL_THR_PRODUCTS);
basicDownloadStatusEntity.setScheduleType(1);
basicDownloadService.insertDownloadStatus(basicDownloadStatusEntity);
StringBuilder remark = new StringBuilder();
//第三方产品信息
if (CollUtil.isNotEmpty(spsSyncThrProductsResponse.getProductsEntities())) {
List<ThrProductsEntity> productsEntities = spsSyncThrProductsResponse.getProductsEntities();
ThrProductsDao mapper = sqlSession.getMapper(ThrProductsDao.class);
productsEntities.forEach(mapper::insertOrUpdate);
}
sqlSession.commit();
remark.append("第三方产品信息:").append(spsSyncThrProductsResponse.getProductsEntities().size()).append("条\n");
sqlSession.close();
basicDownloadStatusEntity.setStatus(1);
basicDownloadStatusEntity.setUpdateTime(new Date());
basicDownloadStatusEntity.setEndTime(new Date());
basicDownloadStatusEntity.setRemark(remark.toString());
basicDownloadService.updateDownloadStatus(basicDownloadStatusEntity);
}
return ResultVOUtils.success("上传成功");
}
}