|
|
|
@ -7,6 +7,7 @@ import com.glxp.api.admin.constant.BasicProcessStatus;
|
|
|
|
|
import com.glxp.api.admin.entity.info.SystemParamConfigEntity;
|
|
|
|
|
import com.glxp.api.admin.entity.thrsys.ThrOrderDetailEntity;
|
|
|
|
|
import com.glxp.api.admin.entity.thrsys.ThrOrderEntity;
|
|
|
|
|
import com.glxp.api.admin.entity.thrsys.ThrOrderImportDetailEntity;
|
|
|
|
|
import com.glxp.api.admin.entity.thrsys.ThrOrderImportLogEntity;
|
|
|
|
|
import com.glxp.api.admin.req.inout.DeleteRequest;
|
|
|
|
|
import com.glxp.api.admin.req.thrsys.*;
|
|
|
|
@ -14,8 +15,10 @@ import com.glxp.api.admin.res.PageSimpleResponse;
|
|
|
|
|
import com.glxp.api.admin.res.inout.ErpOrderResponse;
|
|
|
|
|
import com.glxp.api.admin.service.info.SystemParamConfigService;
|
|
|
|
|
import com.glxp.api.admin.service.thrsys.ThrOrderDetailService;
|
|
|
|
|
import com.glxp.api.admin.service.thrsys.ThrOrderImportDetailService;
|
|
|
|
|
import com.glxp.api.admin.service.thrsys.ThrOrderImportLogService;
|
|
|
|
|
import com.glxp.api.admin.service.thrsys.ThrOrderService;
|
|
|
|
|
import com.glxp.api.admin.thread.ThrOrderImportService;
|
|
|
|
|
import com.glxp.api.admin.thread.ThrOrdersDlService;
|
|
|
|
|
import com.glxp.api.admin.util.Constant;
|
|
|
|
|
import com.glxp.api.admin.util.CustomUtil;
|
|
|
|
@ -45,9 +48,13 @@ public class ThrOrderController {
|
|
|
|
|
@Resource
|
|
|
|
|
private ThrOrderImportLogService thrOrderImportLogService;
|
|
|
|
|
@Resource
|
|
|
|
|
private ThrOrderImportDetailService thrOrderImportDetailService;
|
|
|
|
|
@Resource
|
|
|
|
|
RedisUtil redisUtil;
|
|
|
|
|
@Resource
|
|
|
|
|
private SystemParamConfigService systemParamConfigService;
|
|
|
|
|
@Resource
|
|
|
|
|
ThrOrderImportService thrOrderImportService;
|
|
|
|
|
|
|
|
|
|
@GetMapping("/udiwms/thrsys/getOrders")
|
|
|
|
|
public BaseResponse getOrders(FilterThrOrderRequest filterThrOrderRequest,
|
|
|
|
@ -98,48 +105,45 @@ public class ThrOrderController {
|
|
|
|
|
}
|
|
|
|
|
ThrOrderImportLogEntity thrOrderImportLogEntity = thrOrderImportLogService.selectByGenKey(genKey);
|
|
|
|
|
if (thrOrderImportLogEntity == null) {
|
|
|
|
|
thrOrderImportLogEntity = new ThrOrderImportLogEntity();
|
|
|
|
|
thrOrderImportLogEntity.setGenKey(genKey);
|
|
|
|
|
thrOrderImportLogEntity.setFromType("第三方系统上传");
|
|
|
|
|
thrOrderImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_PROCESS);
|
|
|
|
|
thrOrderImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_UNPROCESS);
|
|
|
|
|
thrOrderImportLogEntity.setUpdateTime(new Date());
|
|
|
|
|
thrOrderImportLogEntity.setThirdSysFk(postThrOrderRequest.getThirdSys());
|
|
|
|
|
thrOrderImportLogService.insertImportLog(thrOrderImportLogEntity);
|
|
|
|
|
}
|
|
|
|
|
List<ThrOrderEntity> thrOrderEntities;
|
|
|
|
|
List<ErpOrderResponse> erpOrderResponses = postThrOrderRequest.getDatas();
|
|
|
|
|
if (erpOrderResponses != null && erpOrderResponses.size() > 0) {
|
|
|
|
|
|
|
|
|
|
thrOrderEntities = erpOrderResponses.stream().map(
|
|
|
|
|
item -> {
|
|
|
|
|
ThrOrderEntity thrOrderEntity = new ThrOrderEntity();
|
|
|
|
|
BeanUtils.copyProperties(item, thrOrderEntity);
|
|
|
|
|
thrOrderEntity.setThirdSysFk(postThrOrderRequest.getThirdSys());
|
|
|
|
|
thrOrderService.insertThrOrder(thrOrderEntity);
|
|
|
|
|
thrOrderEntity = thrOrderService.findByUnique(thrOrderEntity.getBillNo(), thrOrderEntity.getThirdSysFk());
|
|
|
|
|
List<ErpOrderResponse.SubErpOrder> subErpOrders = item.getSubErpOrders();
|
|
|
|
|
if (subErpOrders != null && subErpOrders.size() > 0) {
|
|
|
|
|
List<ThrOrderDetailEntity> thrOrderDetailEntities;
|
|
|
|
|
ThrOrderEntity finalThrOrderEntity = thrOrderEntity;
|
|
|
|
|
thrOrderDetailEntities = subErpOrders.stream().map(subItem ->
|
|
|
|
|
{
|
|
|
|
|
ThrOrderDetailEntity thrOrderDetailEntity = new ThrOrderDetailEntity();
|
|
|
|
|
BeanUtils.copyProperties(subItem, finalThrOrderEntity);
|
|
|
|
|
thrOrderDetailEntity.setOrderIdFk(finalThrOrderEntity.getId() + "");
|
|
|
|
|
thrOrderDetailEntity.setThirdSysFk(finalThrOrderEntity.getThirdSysFk());
|
|
|
|
|
return thrOrderDetailEntity;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
thrOrderDetailService.insertThrOrderDetails(thrOrderDetailEntities);
|
|
|
|
|
}
|
|
|
|
|
return thrOrderEntity;
|
|
|
|
|
List<ThrOrderImportDetailEntity> thrOrderImportDetailEntities = new ArrayList<>();
|
|
|
|
|
String finalGenKey = genKey;
|
|
|
|
|
for (ErpOrderResponse erpOrderResponse : erpOrderResponses) {
|
|
|
|
|
List<ErpOrderResponse.SubErpOrder> subErpOrders = erpOrderResponse.getSubErpOrders();
|
|
|
|
|
if (subErpOrders != null && subErpOrders.size() > 0) {
|
|
|
|
|
for (ErpOrderResponse.SubErpOrder subErpOrder : subErpOrders) {
|
|
|
|
|
ThrOrderImportDetailEntity thrOrderDetailEntity = new ThrOrderImportDetailEntity();
|
|
|
|
|
BeanUtils.copyProperties(erpOrderResponse, thrOrderDetailEntity);
|
|
|
|
|
BeanUtils.copyProperties(subErpOrder, thrOrderDetailEntity);
|
|
|
|
|
thrOrderDetailEntity.setGenKeyFk(finalGenKey);
|
|
|
|
|
thrOrderDetailEntity.setThirdSysFk(postThrOrderRequest.getThirdSys());
|
|
|
|
|
thrOrderDetailEntity.setUpdateTime(new Date());
|
|
|
|
|
thrOrderImportDetailEntities.add(thrOrderDetailEntity);
|
|
|
|
|
}
|
|
|
|
|
).collect(Collectors.toList());
|
|
|
|
|
thrOrderService.insertThrOrders(thrOrderEntities);
|
|
|
|
|
return ResultVOUtils.success("单据上传成功!");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
thrOrderImportDetailService.insertOrderImportDetails(thrOrderImportDetailEntities);
|
|
|
|
|
thrOrderImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_UNPROCESS);
|
|
|
|
|
thrOrderImportLogEntity.setUpdateTime(new Date());
|
|
|
|
|
thrOrderImportLogService.updateImportLog(thrOrderImportLogEntity);
|
|
|
|
|
thrOrderImportService.importThrOrder(finalGenKey);
|
|
|
|
|
} else {
|
|
|
|
|
thrOrderImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
|
|
|
|
|
thrOrderImportLogEntity.setUpdateTime(new Date());
|
|
|
|
|
thrOrderImportLogService.updateImportLog(thrOrderImportLogEntity);
|
|
|
|
|
return ResultVOUtils.error(500, "上传数据为空");
|
|
|
|
|
}
|
|
|
|
|
thrOrderImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
|
|
|
|
|
thrOrderImportLogEntity.setUpdateTime(new Date());
|
|
|
|
|
thrOrderImportLogService.updateImportLog(thrOrderImportLogEntity);
|
|
|
|
|
return ResultVOUtils.error(500, "上传数据为空");
|
|
|
|
|
return ResultVOUtils.success("单据上传成功!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/udiwms/thrsys/delOrder")
|
|
|
|
@ -184,7 +188,7 @@ public class ThrOrderController {
|
|
|
|
|
thrOrderImportLogEntity.setThirdSysFk(filterThrProductsRequest.getThirdSysFk());
|
|
|
|
|
thrOrderImportLogService.insertImportLog(thrOrderImportLogEntity);
|
|
|
|
|
|
|
|
|
|
thrOrdersDlService.importOrders(genKey,filterThrProductsRequest.getBillAction());
|
|
|
|
|
thrOrdersDlService.importOrders(genKey, filterThrProductsRequest.getBillAction());
|
|
|
|
|
return ResultVOUtils.success("后台开始下载更新,请稍后刷新查看");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|