第三方单据代码提交

master
郑明梁 2 years ago
parent 5da45aea70
commit 9f5c9687b1

@ -0,0 +1,423 @@
package com.glxp.api.controller.thrsys;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.github.pagehelper.PageInfo;
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.BasicProcessStatus;
import com.glxp.api.constant.Constant;
import com.glxp.api.entity.system.SystemParamConfigEntity;
import com.glxp.api.entity.thrsys.*;
import com.glxp.api.http.HttpOkClient;
import com.glxp.api.req.system.DeleteRequest;
import com.glxp.api.req.thrsys.*;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.thrsys.ThrOrderResponse;
import com.glxp.api.service.system.SystemParamConfigService;
import com.glxp.api.service.thrsys.*;
import com.glxp.api.util.CustomUtil;
import com.glxp.api.util.RedisUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@RestController
public class ThrOrderController {
@Resource
private ThrOrderService thrOrderService;
@Resource
private ThrOrderDetailService thrOrderDetailService;
@Resource
private ThrOrdersDlService thrOrdersDlService;
@Resource
private ThrOrderImportLogService thrOrderImportLogService;
@Resource
private ThrOrderImportDetailService thrOrderImportDetailService;
@Resource
RedisUtil redisUtil;
@Resource
private SystemParamConfigService systemParamConfigService;
@Resource
private IThrBusTypeOriginService iThrBusTypeOriginService;
@Resource
HttpOkClient httpOkClient;
@AuthRuleAnnotation("")
@GetMapping("/udiwms/thrsys/getOrders")
public BaseResponse getOrders(FilterThrOrderRequest filterThrOrderRequest,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
List<ThrOrderEntity> thrOrderEntities
= thrOrderService.filterThrOrder(filterThrOrderRequest);
PageInfo<ThrOrderEntity> pageInfo;
pageInfo = new PageInfo<>(thrOrderEntities);
PageSimpleResponse<ThrOrderEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(thrOrderEntities);
return ResultVOUtils.success(pageSimpleResponse);
}
@AuthRuleAnnotation("")
@GetMapping("/udiwms/thrsys/getOrderDetails")
public BaseResponse getOrderDetails(FilterThrOrderDetailRequest filterThrOrderDetailRequest,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
List<ThrOrderDetailEntity> thrOrderDetailEntities
= thrOrderDetailService.filterThrOrderDetailDetail(filterThrOrderDetailRequest);
PageInfo<ThrOrderDetailEntity> pageInfo;
pageInfo = new PageInfo<>(thrOrderDetailEntities);
PageSimpleResponse<ThrOrderDetailEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(thrOrderDetailEntities);
return ResultVOUtils.success(pageSimpleResponse);
}
@AuthRuleAnnotation("")
@PostMapping("/udiwms/thrsys/postOrderDetail")
public BaseResponse postOrderDetail(@RequestBody PostThrOrderRequest postThrOrderRequest,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
String genKey = postThrOrderRequest.getGenKey();
if (genKey == null) {
genKey = CustomUtil.getId();
}
ThrOrderImportLogEntity thrOrderImportLogEntity = thrOrderImportLogService.selectByGenKey(genKey);
if (thrOrderImportLogEntity == null) {
thrOrderImportLogEntity = new ThrOrderImportLogEntity();
thrOrderImportLogEntity.setGenKey(genKey);
if (postThrOrderRequest.getUploadType() != null) {
thrOrderImportLogEntity.setFromType("文件上传");
} else
thrOrderImportLogEntity.setFromType("第三方系统上传");
thrOrderImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_UNPROCESS);
thrOrderImportLogEntity.setUpdateTime(new Date());
thrOrderImportLogEntity.setThirdSysFk(postThrOrderRequest.getThirdSys());
thrOrderImportLogService.insertImportLog(thrOrderImportLogEntity);
}
List<ThrOrderResponse> erpOrderResponses = postThrOrderRequest.getDatas();
if (erpOrderResponses != null && erpOrderResponses.size() > 0) {
List<ThrOrderImportDetailEntity> thrOrderImportDetailEntities = new ArrayList<>();
String finalGenKey = genKey;
for (ThrOrderResponse erpOrderResponse : erpOrderResponses) {
List<ThrOrderResponse.SubErpOrder> subErpOrders = erpOrderResponse.getSubErpOrders();
if (subErpOrders != null && subErpOrders.size() > 0) {
for (ThrOrderResponse.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);
}
}
}
thrOrderImportDetailService.insertOrderImportDetails(thrOrderImportDetailEntities);
thrOrderImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_UNPROCESS);
thrOrderImportLogEntity.setUpdateTime(new Date());
thrOrderImportLogService.updateImportLog(thrOrderImportLogEntity);
thrOrderImportLogService.importThrOrder(finalGenKey);
} else {
thrOrderImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
thrOrderImportLogEntity.setUpdateTime(new Date());
thrOrderImportLogService.updateImportLog(thrOrderImportLogEntity);
return ResultVOUtils.error(500, "上传数据为空");
}
return ResultVOUtils.success("单据上传成功!");
}
@PostMapping("/udiwms/thrsys/postFileOrder")
public BaseResponse postFileOrder(@RequestBody PostFileThrOrderRequest postThrOrderRequest,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
String genKey = postThrOrderRequest.getGenKey();
if (genKey == null) {
genKey = CustomUtil.getId();
}
ThrOrderImportLogEntity thrOrderImportLogEntity = thrOrderImportLogService.selectByGenKey(genKey);
if (thrOrderImportLogEntity == null) {
thrOrderImportLogEntity = new ThrOrderImportLogEntity();
thrOrderImportLogEntity.setGenKey(genKey);
if (postThrOrderRequest.getUploadType() != null) {
thrOrderImportLogEntity.setFromType("文件上传");
} else
thrOrderImportLogEntity.setFromType("第三方系统上传");
thrOrderImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_UNPROCESS);
thrOrderImportLogEntity.setUpdateTime(new Date());
thrOrderImportLogEntity.setThirdSysFk(postThrOrderRequest.getThirdSys());
thrOrderImportLogService.insertImportLog(thrOrderImportLogEntity);
}
List<ThrOrderImportDetailEntity> thrOrderImportDetailEntities = postThrOrderRequest.getDatas();
if (thrOrderImportDetailEntities != null && thrOrderImportDetailEntities.size() > 0) {
String finalGenKey = genKey;
for (ThrOrderImportDetailEntity thrOrderImportDetailEntity : thrOrderImportDetailEntities) {
thrOrderImportDetailEntity.setThirdSysFk(postThrOrderRequest.getThirdSys());
thrOrderImportDetailEntity.setGenKeyFk(genKey);
thrOrderImportDetailEntity.setStatus(String.valueOf(BasicProcessStatus.UDIINFO_IMPORT_CODE_UNPROCESS));
thrOrderImportDetailEntity.setUpdateTime(new Date(System.currentTimeMillis()));
}
thrOrderImportDetailService.insertOrderImportDetails(thrOrderImportDetailEntities);
thrOrderImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_UNPROCESS);
thrOrderImportLogEntity.setUpdateTime(new Date());
thrOrderImportLogService.updateImportLog(thrOrderImportLogEntity);
thrOrderImportLogService.importThrOrder(finalGenKey);
} else {
thrOrderImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
thrOrderImportLogEntity.setUpdateTime(new Date());
thrOrderImportLogService.updateImportLog(thrOrderImportLogEntity);
return ResultVOUtils.error(500, "上传数据为空");
}
return ResultVOUtils.success("单据上传成功!");
}
@PostMapping("/udiwms/thrsys/delOrder")
public BaseResponse delOrder(@RequestBody DeleteRequest deleteRequest, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
String id = deleteRequest.getId();
ThrOrderEntity thrOrderEntity = thrOrderService.findById(id);
String msg = selectDelect(thrOrderEntity);
if (msg == null) {
boolean b = thrOrderService.deleteById(id);
thrOrderDetailService.deleteByOrderIdFk(thrOrderEntity.getId() + "");
if (b)
return ResultVOUtils.success("删除成功");
else return ResultVOUtils.error(500, "无法删除!");
} else return ResultVOUtils.error(500, msg);
}
@AuthRuleAnnotation("")
@PostMapping("/udiwms/thrsys/delOrderDetail")
public BaseResponse delOrderDetail(@RequestBody DeleteRequest deleteRequest, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
boolean b = thrOrderDetailService.deleteById(deleteRequest.getId());
if (b)
return ResultVOUtils.success("删除成功");
else return ResultVOUtils.error(500, "无法删除!");
}
public String selectDelect(ThrOrderEntity thrOrderEntity) {
FilterThrOrderRequest filterErpOrderRequest = new FilterThrOrderRequest();
//todo 单据类型还没设计好
// filterErpOrderRequest.setErpOrderId(thrOrderEntity.getBillNo());
// List<ThrErpOrderResponse> erpOrderEntities = myErpOrderService.filterAllMyErpOrder(filterErpOrderRequest);
// if (erpOrderEntities != null && erpOrderEntities.size() > 0) {
// return "单据" + thrOrderEntity.getBillNo() + "已于出入库单据关联,无法删除";
// } else {
// return null;
// }
return null;
}
@AuthRuleAnnotation("")
@RequestMapping("/udiwms/thrsys/order/delAll")
public BaseResponse delAll() {
thrOrderService.deleteAll();
thrOrderDetailService.deleteAll();
return ResultVOUtils.success("删除成功");
}
@AuthRuleAnnotation("")
@RequestMapping("/udiwms/thrsys/orders/downloadAll")
public BaseResponse downloadAll(FilterThrOrderRequest filterThrProductsRequest) {
String data = (String) redisUtil.get(Constant.dlThrOrders);
if (false) {//(data != null && data.equals("true")) {
return ResultVOUtils.error(500, "当前任务正在下载更新业务单据信息,请稍后重试!");
} else {
redisUtil.set(Constant.dlThrOrders, "true", 10 * 30);
if (filterThrProductsRequest.getBillAction() == null) {
return ResultVOUtils.error(500, "未选择业务类型!");
}
ThrOrderImportLogEntity thrOrderImportLogEntity = new ThrOrderImportLogEntity();
String genKey = CustomUtil.getId();
thrOrderImportLogEntity.setGenKey(genKey);
thrOrderImportLogEntity.setFromType("第三方系统获取");
thrOrderImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_UNPROCESS);
thrOrderImportLogEntity.setUpdateTime(new Date());
thrOrderImportLogEntity.setThirdSysFk(filterThrProductsRequest.getThirdSysFk());
thrOrderImportLogService.insertImportLog(thrOrderImportLogEntity);
if (filterThrProductsRequest.getErpOrderResponses() != null) {//选中导出
thrOrdersDlService.importSelectOrders(genKey, filterThrProductsRequest.getErpOrderResponses(), filterThrProductsRequest.getThirdSysFk());
} else { //结果导出
thrOrdersDlService.importOrders(genKey, filterThrProductsRequest.getBillAction(), null);
}
return ResultVOUtils.success("后台开始下载更新,请稍后刷新查看");
}
}
@AuthRuleAnnotation("")
@PostMapping("/udiwms/thrsys/orders/orderDownload")
public BaseResponse orderDownload(@RequestBody FilterThrOrderRequest filterThrProductsRequest) {
String data = (String) redisUtil.get(Constant.dlThrOrders);
if (false) {//(data != null && data.equals("true")) {
return ResultVOUtils.error(500, "当前任务正在下载更新业务单据信息,请稍后重试!");
} else {
redisUtil.set(Constant.dlThrOrders, "true", 10 * 30);
if (filterThrProductsRequest.getBillAction() == null) {
return ResultVOUtils.error(500, "未选择业务类型!");
}
ThrOrderImportLogEntity thrOrderImportLogEntity = new ThrOrderImportLogEntity();
String genKey = CustomUtil.getId();
thrOrderImportLogEntity.setGenKey(genKey);
thrOrderImportLogEntity.setFromType("第三方系统获取");
thrOrderImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_UNPROCESS);
thrOrderImportLogEntity.setUpdateTime(new Date());
thrOrderImportLogEntity.setThirdSysFk(filterThrProductsRequest.getThirdSysFk());
thrOrderImportLogService.insertImportLog(thrOrderImportLogEntity);
if (filterThrProductsRequest.getErpOrderResponses() != null && filterThrProductsRequest.getErpOrderResponses().size() > 0) {//选中导出
thrOrdersDlService.importSelectOrders(genKey, filterThrProductsRequest.getErpOrderResponses(), filterThrProductsRequest.getThirdSysFk());
} else { //结果导出
thrOrdersDlService.importOrders(genKey, filterThrProductsRequest.getBillAction(), filterThrProductsRequest);
}
return ResultVOUtils.success("后台开始下载更新,请稍后刷新查看");
}
}
@AuthRuleAnnotation("")
@PostMapping("/udiwms/smp/postOrder")
public BaseResponse postSmpOrder(@RequestBody PostSmpOrderRequest postSmpOrderRequest,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("smp_uploadOrder_url");
String postUrl;
if (systemParamConfigEntity == null)
return ResultVOUtils.error(500, "上传供应商平台接口地址未定义");
else
postUrl = systemParamConfigEntity.getParamValue();
List<String> ids = postSmpOrderRequest.getIds();
for (String id : ids) {
ThrOrderEntity thrOrderEntity = thrOrderService.findById(id);
UploadSmpRequest uploadSmpRequest = new UploadSmpRequest();
BeanUtils.copyProperties(thrOrderEntity, uploadSmpRequest);
uploadSmpRequest.setType(1);
FilterThrOrderDetailRequest filterThrOrderDetailRequest = new FilterThrOrderDetailRequest();
filterThrOrderDetailRequest.setOrderIdFk(id);
List<ThrOrderDetailEntity> thrOrderDetailEntities = thrOrderDetailService.filterThrOrderDetailDetail(filterThrOrderDetailRequest);
if (thrOrderDetailEntities != null && thrOrderDetailEntities.size() > 0) {
List<UploadSmpRequest.SubErpOrder> subErpOrders = new ArrayList<>();
for (ThrOrderDetailEntity thrOrderDetailEntity : thrOrderDetailEntities) {
UploadSmpRequest.SubErpOrder subErpOrder = new UploadSmpRequest.SubErpOrder();
BeanUtils.copyProperties(thrOrderDetailEntity, subErpOrder);
subErpOrders.add(subErpOrder);
}
uploadSmpRequest.setSubErpOrders(subErpOrders);
String response = httpOkClient.uCloudPost(postUrl, uploadSmpRequest);
BaseResponse baseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
});
if (baseResponse.getCode() == 20000) {
return ResultVOUtils.success("上传成功!");
} else {
return ResultVOUtils.error(baseResponse.getCode(), baseResponse.getMessage());
}
}
}
return ResultVOUtils.error(500, "上传数据成功");
}
//只查询第三方单据
@GetMapping("/udiwms/thirdOrder/filter")
public BaseResponse filterThirdOrder(FilterOrderRequest filterErpOrderRequest,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
//
// if (filterErpOrderRequest.getIsDownThrSys()) {
// BaseResponse<PageSimpleResponse<ErpOrderResponse>> responseBaseResponse = erpOrderClient.getErpOrderResponse(filterErpOrderRequest);
// return responseBaseResponse;
// }
ThrSystemDetailEntity thrSystemDetailEntity = iThrBusTypeOriginService.findSysByAction(filterErpOrderRequest.getBillAction(), "orderQueryUrl");
filterErpOrderRequest.setThirdOrderFk(thrSystemDetailEntity.getThirdSysFk());
if (thrSystemDetailEntity == null || !thrSystemDetailEntity.getEnabled()) {
return ResultVOUtils.error(500, "第三方系统业务单据接口服务未启用");
}
if (thrSystemDetailEntity.getThirdSysFk() == null) {
return ResultVOUtils.error(500, "第三方业务单据服务未关联");
}
FilterThrOrderRequest filterThrOrderRequest = new FilterThrOrderRequest();
BeanUtils.copyProperties(filterErpOrderRequest, filterThrOrderRequest);
filterThrOrderRequest.setPage(filterErpOrderRequest.getPage());
filterThrOrderRequest.setLimit(filterErpOrderRequest.getLimit());
List<ThrOrderResponse> erpOrderResponses = new ArrayList<>();
List<ThrOrderEntity> data = thrOrderService.filterThrOrder(filterThrOrderRequest);
if (data != null && data.size() > 0) {
for (ThrOrderEntity thrOrderEntity : data) {
FilterThrOrderDetailRequest filterThrOrderDetailRequest = new FilterThrOrderDetailRequest();
filterThrOrderDetailRequest.setOrderIdFk(thrOrderEntity.getId() + "");
List<ThrOrderDetailEntity> thrOrderDetailEntities = thrOrderDetailService.filterThrOrderDetailDetail(filterThrOrderDetailRequest);
ThrOrderResponse erpOrderResponse = new ThrOrderResponse();
BeanUtils.copyProperties(thrOrderEntity, erpOrderResponse);
List<ThrOrderResponse.SubErpOrder> subErpOrders = new ArrayList<>();
if (thrOrderDetailEntities != null && thrOrderDetailEntities.size() > 0) {
for (ThrOrderDetailEntity thrOrderDetailEntity : thrOrderDetailEntities) {
ThrOrderResponse.SubErpOrder subErpOrder = new ThrOrderResponse.SubErpOrder();
BeanUtils.copyProperties(thrOrderDetailEntity, subErpOrder);
subErpOrders.add(subErpOrder);
}
}
erpOrderResponse.setSubErpOrders(subErpOrders);
erpOrderResponses.add(erpOrderResponse);
}
}
//todo 单据表还未设计好
// if (thrSystemDetailEntity.getLocalAction() != null) {
// BaseResponse<PageSimpleResponse<ThrOrderResponse>> loca = getLoaclData(filterErpOrderRequest);
// erpOrderResponses.addAll(loca.getData().getList());
// }
PageInfo<ThrOrderEntity> pageInfo;
pageInfo = new PageInfo<>(data);
PageSimpleResponse<ThrOrderResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(erpOrderResponses);
return ResultVOUtils.success(pageSimpleResponse);
}
}

@ -0,0 +1,221 @@
package com.glxp.api.controller.thrsys;
import com.github.pagehelper.PageInfo;
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.BasicProcessStatus;
import com.glxp.api.entity.thrsys.ThrOrderDetailEntity;
import com.glxp.api.entity.thrsys.ThrOrderEntity;
import com.glxp.api.entity.thrsys.ThrOrderExportLogEntity;
import com.glxp.api.entity.thrsys.ThrSystemDetailEntity;
import com.glxp.api.http.ErpOrderClient;
import com.glxp.api.req.system.DeleteRequest;
import com.glxp.api.req.thrsys.*;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.thrsys.ThrOrderResponse;
import com.glxp.api.service.thrsys.ThrOrderDetailService;
import com.glxp.api.service.thrsys.ThrOrderExportLogService;
import com.glxp.api.service.thrsys.ThrOrderService;
import com.glxp.api.service.thrsys.ThrOrdersDlService;
import com.glxp.api.util.CustomUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.BindingResult;
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.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@RestController
public class ThrOrderExportLogController {
@Resource
ThrOrderExportLogService thrOrderExportLogService;
@Resource
ThrOrdersDlService thrOrdersDlService;
@Resource
private ThrOrderService thrOrderService;
@Resource
private ThrOrderDetailService thrOrderDetailService;
@Resource
private ErpOrderClient erpOrderClient;
@GetMapping("/udiwms/thrOrder/exportLog/filter")
public BaseResponse filter(FilterThrCorpImportLogRequest filterUdiEpLogReques,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
List<ThrOrderExportLogEntity> udiInfoExportLogEntities
= thrOrderExportLogService.filterThrOrderExportLog(filterUdiEpLogReques);
PageInfo<ThrOrderExportLogEntity> pageInfo;
pageInfo = new PageInfo<>(udiInfoExportLogEntities);
PageSimpleResponse<ThrOrderExportLogEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(udiInfoExportLogEntities);
return ResultVOUtils.success(pageSimpleResponse);
}
@PostMapping("/udiwms/thrOrder/exportLog/deleteLog")
public BaseResponse deleteLog(@RequestBody DeleteRequest deleteRequest, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
String id = deleteRequest.getId();
thrOrderExportLogService.deleteById(id + "");
return ResultVOUtils.success("删除成功");
}
//业务单据excel文件下载
@GetMapping("/udiwms/thrOrder/exportLog/download")
public void download(FilterThrCorpImportLogRequest filterUdiEpLogRequest, HttpServletResponse res) {
List<ThrOrderExportLogEntity> thrOrderExportLogEntities = thrOrderExportLogService.filterThrOrderExportLog(filterUdiEpLogRequest);
ThrOrderExportLogEntity thrOrderExportLogEntity = thrOrderExportLogEntities.get(0);
try {
String filePath = thrOrderExportLogEntity.getFilePath();
String fileName = "temp";
if (filePath != null && filePath.length() > 0) {
String[] data = filePath.split("/");
fileName = data[data.length - 1];
}
res.setHeader("Content-disposition", "attachment;fileName=" + fileName);
res.setContentType("text/plain;charset=UTF-8");
FileInputStream input = new FileInputStream(new File(filePath));
OutputStream out = res.getOutputStream();
byte[] b = new byte[2048];
int len;
while ((len = input.read(b)) != -1) {
out.write(b, 0, len);
}
input.close();
if (thrOrderExportLogEntity.getDlCount() == 0) {
thrOrderExportLogEntity.setDlCount(1);
} else {
thrOrderExportLogEntity.setDlCount(thrOrderExportLogEntity.getDlCount() + 1);
}
thrOrderExportLogService.updateThrOrderExportLog(thrOrderExportLogEntity);
} catch (Exception ex) {
System.out.println("下载失败!");
}
}
//业务单据导出生成Excel并创建生成记录
@PostMapping("/udiwms/thrOrder/importLog/export")
public BaseResponse excelDownload(@RequestBody ThrOrderExportRequest thrOrderExportRequest) {
String fileName = "D:\\udiwms\\exportFile\\" + "业务单据导出" + System.currentTimeMillis() + ".xls";
File file = new File(fileName);
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
ThrOrderExportLogEntity udiInfoExportLogEntity = new ThrOrderExportLogEntity();
udiInfoExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_PROCESS);
String genKey = CustomUtil.getId();
udiInfoExportLogEntity.setGenKey(genKey);
udiInfoExportLogEntity.setFilePath(fileName);
udiInfoExportLogEntity.setUpdateTime(new Date());
udiInfoExportLogEntity.setType(BasicProcessStatus.EXPORT_EXCEL);
udiInfoExportLogEntity.setDlCount(0);
thrOrderExportLogService.insertThrOrderExportLog(udiInfoExportLogEntity);
thrOrdersDlService.genExcel(genKey, thrOrderExportRequest);
return ResultVOUtils.success("后台正在导出生成excel文件请稍后刷新查看!");
}
//业务单据上传SMP并创建生成记录
@PostMapping("/udiwms/thrOrder/importLog/uploadSmp")
public BaseResponse uploadSmp(@RequestBody ThrOrderExportRequest thrOrderExportRequest) {
ThrOrderExportLogEntity udiInfoExportLogEntity = new ThrOrderExportLogEntity();
udiInfoExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_PROCESS);
String genKey = CustomUtil.getId();
udiInfoExportLogEntity.setGenKey(genKey);
udiInfoExportLogEntity.setUpdateTime(new Date());
udiInfoExportLogEntity.setType(BasicProcessStatus.EXPORT_SMP);
udiInfoExportLogEntity.setDlCount(0);
thrOrderExportLogService.insertThrOrderExportLog(udiInfoExportLogEntity);
thrOrdersDlService.uploadSmp(genKey, thrOrderExportRequest);
return ResultVOUtils.success("后台正在上传,请稍后刷新查看!");
}
//第三方业务单据接口下载(第三方使用)
@GetMapping("/udiwms/thrsys/thrOrder/download")
public BaseResponse downloadThrOrders(FilterOrderRequest filterErpOrderRequest,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
//todo关联表未涉及好
// BasicThirdSysDetailEntity basicThirdSysDetailEntity = bussinessTypeService.findByActionKey(filterErpOrderRequest.getBillAction(), "orderQueryUrl");
// if (!basicThirdSysDetailEntity.getEnabled() || basicThirdSysDetailEntity.getThirdSysFk() == null) {
// return ResultVOUtils.error(500, "第三方系统业务单据接口服务未启用");
// }
// if (basicThirdSysDetailEntity.getValue() == null) {
// return ResultVOUtils.error(500, "业务单据查询接口未定义");
// }
ThrSystemDetailEntity thrSystemDetailEntity=new ThrSystemDetailEntity();
if (thrSystemDetailEntity.getFromType() != null && thrSystemDetailEntity.getFromType() == 0) {
return erpOrderClient.getThrOrderResponse(filterErpOrderRequest);
} else {
//todo 订单查询,需加日期
FilterThrOrderRequest filterThrOrderRequest = new FilterThrOrderRequest();
BeanUtils.copyProperties(filterErpOrderRequest, filterThrOrderRequest);
filterThrOrderRequest.setPage(filterErpOrderRequest.getPage());
filterThrOrderRequest.setLimit(filterErpOrderRequest.getLimit());
List<ThrOrderResponse> erpOrderResponses = new ArrayList<>();
List<ThrOrderEntity> data = thrOrderService.filterThrOrder(filterThrOrderRequest);
if (data != null && data.size() > 0) {
for (ThrOrderEntity thrOrderEntity : data) {
FilterThrOrderDetailRequest filterThrOrderDetailRequest = new FilterThrOrderDetailRequest();
filterThrOrderDetailRequest.setOrderIdFk(thrOrderEntity.getId() + "");
List<ThrOrderDetailEntity> thrOrderDetailEntities = thrOrderDetailService.filterThrOrderDetailDetail(filterThrOrderDetailRequest);
ThrOrderResponse erpOrderResponse = new ThrOrderResponse();
BeanUtils.copyProperties(thrOrderEntity, erpOrderResponse);
List<ThrOrderResponse.SubErpOrder> subErpOrders = new ArrayList<>();
if (thrOrderDetailEntities != null && thrOrderDetailEntities.size() > 0) {
for (ThrOrderDetailEntity thrOrderDetailEntity : thrOrderDetailEntities) {
ThrOrderResponse.SubErpOrder subErpOrder = new ThrOrderResponse.SubErpOrder();
BeanUtils.copyProperties(thrOrderDetailEntity, subErpOrder);
subErpOrders.add(subErpOrder);
}
}
erpOrderResponse.setSubErpOrders(subErpOrders);
erpOrderResponses.add(erpOrderResponse);
}
}
PageInfo<ThrOrderEntity> pageInfo;
pageInfo = new PageInfo<>(data);
PageSimpleResponse<ThrOrderResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(erpOrderResponses);
return ResultVOUtils.success(pageSimpleResponse);
}
}
}

@ -0,0 +1,327 @@
package com.glxp.api.controller.thrsys;
import com.github.pagehelper.PageInfo;
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.BasicProcessStatus;
import com.glxp.api.entity.thrsys.ThrOrderImportDetailEntity;
import com.glxp.api.entity.thrsys.ThrOrderImportLogEntity;
import com.glxp.api.req.system.DeleteRequest;
import com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.service.thrsys.ThrOrderImportDetailService;
import com.glxp.api.service.thrsys.ThrOrderImportLogService;
import com.glxp.api.util.CustomUtil;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@RestController
public class ThrOrderImportLogController {
@Resource
ThrOrderImportLogService thrOrderImportLogService;
@Resource
ThrOrderImportDetailService thrOrderImportDetailService;
@GetMapping("/udiwms/thrOrder/importLog/filter")
public BaseResponse filter(FilterThrCorpImportLogRequest filterThrCorpImportLogRequest,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
List<ThrOrderImportLogEntity> udiInfoImportLogEntities
= thrOrderImportLogService.filterThrOrderImportLog(filterThrCorpImportLogRequest);
PageInfo<ThrOrderImportLogEntity> pageInfo;
pageInfo = new PageInfo<>(udiInfoImportLogEntities);
PageSimpleResponse<ThrOrderImportLogEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(udiInfoImportLogEntities);
return ResultVOUtils.success(pageSimpleResponse);
}
@GetMapping("/udiwms/thrOrder/importLog/filterDetail")
public BaseResponse filterDetail(FilterThrCorpImportLogRequest filterThrCorpImportLogRequest,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
List<ThrOrderImportDetailEntity> thrOrderImportDetailEntities
= thrOrderImportDetailService.filterOrderImportDetail(filterThrCorpImportLogRequest);
PageInfo<ThrOrderImportDetailEntity> pageInfo;
pageInfo = new PageInfo<>(thrOrderImportDetailEntities);
PageSimpleResponse<ThrOrderImportDetailEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(thrOrderImportDetailEntities);
return ResultVOUtils.success(pageSimpleResponse);
}
@PostMapping("/udiwms/thrOrder/importLog/deleteLog")
public BaseResponse deleteLog(@RequestBody DeleteRequest deleteRequest, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
String id = deleteRequest.getId();
FilterThrCorpImportLogRequest filterInCodeLogRequest = new FilterThrCorpImportLogRequest();
filterInCodeLogRequest.setId(Integer.parseInt(id));
List<ThrOrderImportLogEntity> corpImportLogEntities = thrOrderImportLogService.filterThrOrderImportLog(filterInCodeLogRequest);
if (corpImportLogEntities != null && corpImportLogEntities.size() > 0) {
ThrOrderImportLogEntity corpImportLogEntity = corpImportLogEntities.get(0);
thrOrderImportLogService.deleteById(corpImportLogEntity.getId() + "");
thrOrderImportDetailService.deleteByGenkey(corpImportLogEntity.getGenKey());
}
return ResultVOUtils.success("删除成功");
}
@PostMapping("/udiwms/thrOrder/importLog/delete")
public BaseResponse delete(@RequestBody DeleteRequest deleteRequest, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
if (thrOrderImportDetailService.deleteById(deleteRequest.getId()))
return ResultVOUtils.success("删除成功");
else
return ResultVOUtils.error(500, "删除成功");
}
@PostMapping("/udiwms/thrOrder/importLog/upload")
public BaseResponse uploadOrders(@RequestParam("file") List<MultipartFile> files, @RequestParam("thirdSys") String thirdSys) {
String filePath = "D:\\udiwms\\filePath\\";
File createFile = new File(filePath);
if (!createFile.exists()) {
createFile.mkdirs();
}
for (int i = 0; i < files.size(); i++) {
MultipartFile file = files.get(i);
if (file.isEmpty()) {
return ResultVOUtils.error(500, "上传第" + (i++) + "个文件失败");
}
String fileName = file.getOriginalFilename();
try {
InputStream inputStream = file.getInputStream();
Workbook workbook = null;
String filetype = fileName.substring(fileName.lastIndexOf("."));
if (".xls".equals(filetype)) {
workbook = new HSSFWorkbook(inputStream);
} else if (".xlsx".equals(filetype)) {
workbook = new XSSFWorkbook(inputStream);
} else {
return ResultVOUtils.error(500, "请上传excel文件");
}
Sheet sheet = null;
Row row = null;
ThrOrderImportLogEntity thrOrderImportLogEntity = new ThrOrderImportLogEntity();
String genKey = CustomUtil.getId();
thrOrderImportLogEntity.setGenKey(genKey);
thrOrderImportLogEntity.setThirdSysFk(thirdSys);
thrOrderImportLogEntity.setFromType("文件导入");
thrOrderImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_UNPROCESS);
thrOrderImportLogEntity.setUpdateTime(new Date(System.currentTimeMillis()));
thrOrderImportLogService.insertImportLog(thrOrderImportLogEntity);
List<ThrOrderImportDetailEntity> corpImportDetailEntities = new ArrayList<>();
for (int j = 0; j < 1; j++) {//workbook.getNumberOfSheets()
sheet = workbook.getSheetAt(j);
if (sheet == null) {
continue;
}
// 滤过第一行标题
row = sheet.getRow(0);
if ((row.getCell(0) == null || row.getCell(1) == null || row.getCell(2) == null
|| row.getCell(3) == null || row.getCell(4) == null || row.getCell(5) == null || row.getCell(6) == null) ||
(!"单据号".equals(row.getCell(0).getStringCellValue())
|| !"单据日期".equals(row.getCell(1).getStringCellValue())
|| !"往来单位ID".equals(row.getCell(2).getStringCellValue())
|| !"往来单位名称".equals(row.getCell(3).getStringCellValue())
|| !"单据类型".equals(row.getCell(4).getStringCellValue())
|| !"单据状态".equals(row.getCell(5).getStringCellValue())
|| !"产品ID".equals(row.getCell(6).getStringCellValue()))) {
return ResultVOUtils.error(500, "文件格式错误!");
}
for (int k = sheet.getFirstRowNum() + 1; k <= sheet.getLastRowNum(); k++) {
row = sheet.getRow(k);
if (row == null || row.getRowNum() <= 0) {
continue;
}
if (filterEmpty(row)) {
continue;
}
ThrOrderImportDetailEntity corpImportDetailEntity = new ThrOrderImportDetailEntity();
Cell cell1 = row.getCell(0);
if (cell1 != null) {
cell1.setCellType(CellType.STRING);
corpImportDetailEntity.setBillNo(cell1.getStringCellValue());
}
Cell cell2 = row.getCell(1);
if (cell2 != null) {
cell2.setCellType(CellType.STRING);
corpImportDetailEntity.setBilldate(cell2.getStringCellValue());
}
Cell cell3 = row.getCell(2);
if (cell3 != null) {
cell3.setCellType(CellType.STRING);
corpImportDetailEntity.setCorpId(cell3.getStringCellValue());
}
Cell cell4 = row.getCell(3);
if (cell4 != null) {
cell4.setCellType(CellType.STRING);
corpImportDetailEntity.setCorpName(cell4.getStringCellValue());
}
Cell cell5 = row.getCell(4);
if (cell5 != null) {
cell5.setCellType(CellType.STRING);
String billType = cell5.getStringCellValue();
//todo 表功能还未设计好
// BussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findBTByName(billType);
// if (bussinessTypeEntity != null) {
// corpImportDetailEntity.setBillType(bussinessTypeEntity.getAction());
// } else
// corpImportDetailEntity.setBillType(billType);
}
Cell cell6 = row.getCell(5);
if (cell6 != null) {
cell6.setCellType(CellType.STRING);
corpImportDetailEntity.setBillFlag(cell6.getStringCellValue());
}
Cell cell7 = row.getCell(6);
if (cell7 != null) {
cell7.setCellType(CellType.STRING);
corpImportDetailEntity.setProductId(cell7.getStringCellValue());
}
Cell cell8 = row.getCell(7);
if (cell8 != null) {
cell8.setCellType(CellType.STRING);
corpImportDetailEntity.setProductName(cell8.getStringCellValue());
}
Cell cell9 = row.getCell(8);
if (cell9 != null) {
cell9.setCellType(CellType.STRING);
corpImportDetailEntity.setSpec(cell9.getStringCellValue());
}
Cell cell10 = row.getCell(9);
if (cell10 != null) {
cell10.setCellType(CellType.STRING);
corpImportDetailEntity.setBatchNo(cell10.getStringCellValue());
}
Cell cell11 = row.getCell(10);
if (cell11 != null) {
cell11.setCellType(CellType.STRING);
corpImportDetailEntity.setProductDate(cell11.getStringCellValue());
}
Cell cell12 = row.getCell(11);
if (cell12 != null) {
cell12.setCellType(CellType.STRING);
corpImportDetailEntity.setExpireDate(cell12.getStringCellValue());
}
Cell cell13 = row.getCell(12);
if (cell13 != null) {
cell13.setCellType(CellType.STRING);
String count = cell13.getStringCellValue();
if (count != null && !"".equals(count)) {
corpImportDetailEntity.setCount(String.valueOf(Integer.parseInt(count)));
}
}
Cell cell14 = row.getCell(13);
if (cell14 != null) {
cell14.setCellType(CellType.STRING);
String count = cell14.getStringCellValue();
if (count != null && !"".equals(count)) {
corpImportDetailEntity.setReCount(String.valueOf(Integer.parseInt(count)));
}
}
corpImportDetailEntity.setThirdSysFk(thirdSys);
corpImportDetailEntity.setGenKeyFk(genKey);
corpImportDetailEntity.setStatus(String.valueOf(BasicProcessStatus.UDIINFO_IMPORT_CODE_UNPROCESS));
corpImportDetailEntity.setUpdateTime(new Date(System.currentTimeMillis()));
corpImportDetailEntities.add(corpImportDetailEntity);
}
}
thrOrderImportDetailService.insertOrderImportDetails(corpImportDetailEntities);
thrOrderImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_UNPROCESS);
thrOrderImportLogService.updateImportLog(thrOrderImportLogEntity);
workbook.close();
thrOrderImportLogService.importThrOrder(genKey);
} catch (IOException e) {
e.printStackTrace();
}
}
return ResultVOUtils.success("上传成功");
}
public boolean filterEmpty(Row row) {
if (row.getCell(0) != null) {
row.getCell(0).setCellType(CellType.STRING);
}
if (row.getCell(1) != null) {
row.getCell(1).setCellType(CellType.STRING);
}
if (row.getCell(2) != null) {
row.getCell(2).setCellType(CellType.STRING);
}
if (row.getCell(3) != null) {
row.getCell(3).setCellType(CellType.STRING);
}
if (row.getCell(4) != null) {
row.getCell(4).setCellType(CellType.STRING);
}
if (row.getCell(5) != null) {
row.getCell(5).setCellType(CellType.STRING);
}
if (row.getCell(6) != null) {
row.getCell(6).setCellType(CellType.STRING);
}
if ((row.getCell(0) == null && row.getCell(1) == null && row.getCell(2) == null
&& row.getCell(3) == null && row.getCell(4) == null && row.getCell(5) == null && row.getCell(6) == null) ||
(
(row.getCell(0) != null && row.getCell(1) != null && row.getCell(2) != null
&& row.getCell(3) != null && row.getCell(4) != null && row.getCell(5) != null && row.getCell(6) != null) &&
("".equals(row.getCell(0).getStringCellValue())
&& "".equals(row.getCell(1).getStringCellValue())
&& "".equals(row.getCell(2).getStringCellValue())
&& "".equals(row.getCell(3).getStringCellValue())
&& "".equals(row.getCell(4).getStringCellValue())
&& "".equals(row.getCell(5).getStringCellValue())
&& "".equals(row.getCell(6).getStringCellValue()))
)) {
return true;
}
return false;
}
}

@ -0,0 +1,30 @@
package com.glxp.api.dao.thrsys;
import com.glxp.api.entity.thrsys.ThrOrderEntity;
import com.glxp.api.req.thrsys.FilterThrOrderRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface ThrOrderDao {
List<ThrOrderEntity> filterThrOrder(FilterThrOrderRequest filterThrOrderRequest);
List<ThrOrderEntity> filterReceiveOrder(FilterThrOrderRequest filterThrOrderRequest);
boolean insertThrOrder(ThrOrderEntity thrCorpEntity);
boolean importThrOrder(ThrOrderEntity thrCorpEntity);
boolean insertThrOrders(@Param("thrOrderEntities") List<ThrOrderEntity> thrOrderEntities);
boolean updateThrOrder(ThrOrderEntity thrOrderEntity);
boolean deleteById(@Param("id") String id);
boolean deleteAll();
}

@ -0,0 +1,32 @@
package com.glxp.api.dao.thrsys;
import com.glxp.api.entity.thrsys.ThrOrderDetailEntity;
import com.glxp.api.req.thrsys.FilterThrOrderDetailRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface ThrOrderDetailDao {
List<ThrOrderDetailEntity> filterThrOrderDetailDetail(FilterThrOrderDetailRequest filterThrOrderDetailRequest);
boolean insertThrOrderDetail(ThrOrderDetailEntity thrOrderDetailEntity);
boolean importThrOrderDetail(ThrOrderDetailEntity thrOrderDetailEntity);
boolean insertThrOrderDetails(@Param("thrOrderDetailEntities") List<ThrOrderDetailEntity> thrOrderDetailEntities);
boolean updateThrOrderDetail(ThrOrderDetailEntity thrOrderDetailEntity);
boolean deleteById(@Param("id") String id);
boolean deleteByOrderIdFk(@Param("orderIdFk") String orderIdFk);
boolean deleteAll();
boolean deleteByTime();
}

@ -0,0 +1,23 @@
package com.glxp.api.dao.thrsys;
import com.glxp.api.entity.thrsys.ThrOrderExportLogEntity;
import com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface ThrOrderExportLogDao {
List<ThrOrderExportLogEntity> filterThrOrderExportLog(FilterThrCorpImportLogRequest filterThrCorpImportLogRequest);
boolean insertThrOrderExportLog(ThrOrderExportLogEntity thrOrderExportLogEntity);
boolean updateThrOrderExportLog(ThrOrderExportLogEntity thrOrderExportLogEntity);
boolean deleteById(@Param("id") String id);
boolean deleteByTime();
}

@ -0,0 +1,27 @@
package com.glxp.api.dao.thrsys;
import com.glxp.api.entity.thrsys.ThrOrderImportDetailEntity;
import com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface ThrOrderImportDetailDao {
List<ThrOrderImportDetailEntity> filterOrderdDetailImport(FilterThrCorpImportLogRequest filterThrCorpImportLogRequest);
boolean insertOrderdDetailImport(ThrOrderImportDetailEntity thrOrderImportDetailEntity);
boolean updateOrderdDetailImport(ThrOrderImportDetailEntity thrOrderImportDetailEntity);
boolean insertOrderdDetailImports(@Param("orders") List<ThrOrderImportDetailEntity> thrOrderImportDetailEntities);
boolean deleteById(@Param("id") String id);
boolean deleteByGenkey(@Param("genKey") String genKey);
boolean deleteByTime();
}

@ -0,0 +1,24 @@
package com.glxp.api.dao.thrsys;
import com.glxp.api.entity.thrsys.ThrOrderImportLogEntity;
import com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface ThrOrderImportLogDao {
List<ThrOrderImportLogEntity> filterThrOrderImportLog(FilterThrCorpImportLogRequest filterThrCorpImportLogRequest);
boolean insertImportLog(ThrOrderImportLogEntity thrOrderImportLogEntity);
boolean updateImportLog(ThrOrderImportLogEntity thrOrderImportLogEntity);
boolean deleteById(@Param("id") String id);
boolean deleteByTime();
}

@ -0,0 +1,122 @@
package com.glxp.api.entity.thrsys;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author
* @since 2023-01-13
*/
@Data
@TableName("thr_order_detail")
public class ThrOrderDetailEntity{
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@TableField("productId")
private String productId;
@TableField("productName")
private String productName;
@TableField("spec")
private String spec;
@TableField("batchNo")
private String batchNo;
@TableField("expireDate")
private String expireDate;
@TableField("productDate")
private String productDate;
@TableField("count")
private String count;
@TableField("reCount")
private String reCount;
@TableField("orderIdFk")
private String orderIdFk;
@TableField("thirdSysFk")
private String thirdSysFk;
/**
*
*/
@TableField("price")
private BigDecimal price;
/**
*
*/
@TableField("corpName")
private String corpName;
/**
*
*/
@TableField("ylqxzcrbarmc")
private String ylqxzcrbarmc;
/**
*
*/
@TableField("zczbhhzbapzbh")
private String zczbhhzbapzbh;
/**
*
*/
@TableField("manufactory")
private String manufactory;
/**
*
*/
@TableField("createUser")
private String createUser;
/**
*
*/
@TableField("createTime")
private Date createTime;
/**
*
*/
@TableField("updateUser")
private String updateUser;
/**
*
*/
@TableField("updateTime")
private Date updateTime;
/**
*
*/
@TableField("remark")
private String remark;
}

@ -0,0 +1,190 @@
package com.glxp.api.entity.thrsys;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author
* @since 2023-01-13
*/
@Data
@TableName("thr_order")
public class ThrOrderEntity{
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@TableField("billNo")
private String billNo;
@TableField("billdate")
private String billdate;
@TableField("corpId")
private String corpId;
@TableField("corpName")
private String corpName;
@TableField("billType")
private String billType;
@TableField("billFlag")
private String billFlag;
@TableField("thirdSysFk")
private String thirdSysFk;
/**
*
*/
@TableField("originType")
private String originType;
/**
*
*/
@TableField("startDate")
private String startDate;
/**
*
*/
@TableField("endDate")
private String endDate;
/**
*
*/
@TableField("reviewUser")
private String reviewUser;
/**
*
*/
@TableField("address")
private String address;
/**
*
*/
@TableField("linkMan")
private String linkMan;
/**
*
*/
@TableField("linkTel")
private String linkTel;
/**
*
*/
@TableField("remark")
private String remark;
/**
* 1
*/
@TableField("remark1")
private String remark1;
/**
* 2
*/
@TableField("remark2")
private String remark2;
/**
* 3
*/
@TableField("remark3")
private String remark3;
@TableField("type")
private Integer type;
@TableField("locStorageCode")
private String locStorageCode;
@TableField("editStatus")
private Integer editStatus;
/**
*
*/
@TableField("invWarehouseCode")
private String invWarehouseCode;
/**
*
*/
@TableField("ylqxzcrbarmc")
private String ylqxzcrbarmc;
/**
*
*/
@TableField("zczbhhzbapzbh")
private String zczbhhzbapzbh;
/**
*
*/
@TableField("manufactory")
private String manufactory;
/**
* 1 2
*/
@TableField("thirdPartyDate")
private Integer thirdPartyDate;
@TableField("unitIdFk")
private String unitIdFk;
/**
*
*/
@TableField("fromSubInvCode")
private String fromSubInvCode;
/**
*
*/
@TableField("createUser")
private String createUser;
/**
*
*/
@TableField("createTime")
private Date createTime;
/**
*
*/
@TableField("updateUser")
private String updateUser;
/**
*
*/
@TableField("updateTime")
private Date updateTime;
}

@ -0,0 +1,89 @@
package com.glxp.api.entity.thrsys;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author
* @since 2023-01-13
*/
@Data
@TableName("thr_order_export_log")
public class ThrOrderExportLogEntity{
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/**
*
*/
@TableField("genKey")
private String genKey;
/**
* 01
*/
@TableField("status")
private Integer status;
/**
*
*/
@TableField("dlCount")
private Integer dlCount;
/**
*
*/
@TableField("filePath")
private String filePath;
@TableField("type")
private Integer type;
/**
*
*/
@TableField("createUser")
private String createUser;
/**
*
*/
@TableField("createTime")
private Date createTime;
/**
*
*/
@TableField("updateUser")
private String updateUser;
/**
*
*/
@TableField("updateTime")
private Date updateTime;
/**
*
*/
@TableField("remark")
private String remark;
}

@ -0,0 +1,116 @@
package com.glxp.api.entity.thrsys;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author
* @since 2023-01-13
*/
@Data
@TableName("thr_order_import_detail")
public class ThrOrderImportDetailEntity {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@TableField("billNo")
private String billNo;
@TableField("billdate")
private String billdate;
@TableField("corpId")
private String corpId;
@TableField("corpName")
private String corpName;
@TableField("billType")
private String billType;
@TableField("billFlag")
private String billFlag;
@TableField("productId")
private String productId;
@TableField("productName")
private String productName;
@TableField("spec")
private String spec;
@TableField("batchNo")
private String batchNo;
@TableField("expireDate")
private String expireDate;
@TableField("productDate")
private String productDate;
@TableField("count")
private String count;
@TableField("reCount")
private String reCount;
@TableField("status")
private String status;
@TableField("genKeyFk")
private String genKeyFk;
@TableField("thirdSysFk")
private String thirdSysFk;
@TableField("originType")
private String originType;
/**
*
*/
@TableField("createUser")
private String createUser;
/**
*
*/
@TableField("createTime")
private Date createTime;
/**
*
*/
@TableField("updateUser")
private String updateUser;
/**
*
*/
@TableField("updateTime")
private Date updateTime;
/**
*
*/
@TableField("remark")
private String remark;
}

@ -0,0 +1,77 @@
package com.glxp.api.entity.thrsys;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author
* @since 2023-01-13
*/
@Data
@TableName("thr_order_import_log")
public class ThrOrderImportLogEntity{
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@TableField("genKey")
private String genKey;
/**
* 0:1.2.3.
*/
@TableField("status")
private Integer status;
@TableField("fromType")
private String fromType;
@TableField("thirdSysFk")
private String thirdSysFk;
/**
*
*/
@TableField("createUser")
private String createUser;
/**
*
*/
@TableField("createTime")
private Date createTime;
/**
*
*/
@TableField("updateUser")
private String updateUser;
/**
*
*/
@TableField("updateTime")
private Date updateTime;
/**
*
*/
@TableField("remark")
private String remark;
}

@ -0,0 +1,68 @@
package com.glxp.api.entity.thrsys;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* <p>
*
* </p>
*
* @author
* @since 2023-01-13
*/
@Data
@TableName("thr_order_upload_bustypes")
public class ThrOrderUploadBustypesEntity {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@TableField("action")
private String action;
@TableField("name")
private String name;
/**
*
*/
@TableField("createUser")
private String createUser;
/**
*
*/
@TableField("createTime")
private Data createTime;
/**
*
*/
@TableField("updateUser")
private String updateUser;
/**
*
*/
@TableField("updateTime")
private Data updateTime;
/**
*
*/
@TableField("remark")
private String remark;
}

@ -0,0 +1,142 @@
package com.glxp.api.entity.thrsys;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* <p>
*
* </p>
*
* @author
* @since 2023-01-13
*/
@Data
@TableName("thr_order_upload")
public class ThrOrderUploadEntity{
private static final long serialVersionUID = 1L;
@TableId("id")
private Integer id;
/**
*
*/
@TableField("autoUpload")
private Integer autoUpload;
/**
*
*/
@TableField("orderSyncTime")
private Integer orderSyncTime;
/**
*
*/
@TableField("orderUnCheck")
private Integer orderUnCheck;
/**
*
*/
@TableField("orderUnReceive")
private Integer orderUnReceive;
/**
*
*/
@TableField("orderScanFinish")
private Integer orderScanFinish;
/**
* UDIMS
*/
@TableField("checkUdims")
private Integer checkUdims;
/**
* PDA
*/
@TableField("checkPdaEd")
private Integer checkPdaEd;
/**
* pda
*/
@TableField("checkPdaUn")
private Integer checkPdaUn;
/**
*
*/
@TableField("checkPc")
private Integer checkPc;
/**
*
*/
@TableField("checkWebNew")
private Integer checkWebNew;
/**
*
*/
@TableField("checkChange")
private Integer checkChange;
/**
*
*/
@TableField("checkSp")
private Integer checkSp;
/**
*
*/
@TableField("checkBalacne")
private Integer checkBalacne;
/**
*
*/
@TableField("orderStartTime")
private String orderStartTime;
/**
*
*/
@TableField("createUser")
private String createUser;
/**
*
*/
@TableField("createTime")
private Data createTime;
/**
*
*/
@TableField("updateUser")
private String updateUser;
/**
*
*/
@TableField("updateTime")
private Data updateTime;
/**
*
*/
@TableField("remark")
private String remark;
}

@ -0,0 +1,146 @@
package com.glxp.api.http;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.constant.ConstantStatus;
import com.glxp.api.entity.thrsys.ThrSystemEntity;
import com.glxp.api.req.thrsys.FilterOrderRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.thrsys.ThrErpOrderResponse;
import com.glxp.api.res.thrsys.ThrOrderResponse;
import com.glxp.api.service.thrsys.ThrSystemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* ERP
*/
@Slf4j
@Service
public class ErpOrderClient {
@Autowired
private ThrSystemService thrSystemService;
@Resource
HttpOkClient httpOkClient;
public List<ThrOrderResponse> getErpOrder(String url, List<String> billCodes, String action) {
List<ThrOrderResponse> erpOrderEntities = new ArrayList<>();
if (billCodes != null && billCodes.size() > 0) {
for (int i = 0; i < billCodes.size(); i++) {
List<ThrOrderResponse> ThrErpOrderResponses = getErpOrder(url, Arrays.asList(billCodes.get(i)), action);
if (ThrErpOrderResponses != null) {
erpOrderEntities.addAll(ThrErpOrderResponses);
}
}
}
return erpOrderEntities;
}
public BaseResponse<PageSimpleResponse<ThrOrderResponse>> getThrOrderResponse(FilterOrderRequest filterOrderRequest) {
//查询第三方服务授权参数
ThrSystemEntity thrSystemEntity = thrSystemService.selectByThirdId("thirdId");
String url = thrSystemEntity.getThridUrl() + "/udiwms/erp/getOrders";
String response = httpOkClient.uCloudPost(url, filterOrderRequest, thrSystemEntity);
try {
BaseResponse<PageSimpleResponse<ThrOrderResponse>> responseBaseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<ThrOrderResponse>>>() {
});
return responseBaseResponse;
} catch (Exception e) {
log.error("获取订单数据异常", e);
}
return null;
}
public List<ThrErpOrderResponse> getErpOrder(FilterOrderRequest filterOrderRequest) {
try {
BaseResponse<PageSimpleResponse<ThrOrderResponse>> responseBaseResponse = getThrOrderResponse(filterOrderRequest);
List<ThrOrderResponse> purchaseinResponseList = responseBaseResponse.getData().getList();
if (purchaseinResponseList != null && purchaseinResponseList.size() > 0) {
List<ThrErpOrderResponse> erpOrderEntities = new ArrayList<>();
for (ThrOrderResponse ThrOrderResponse : purchaseinResponseList) {
for (ThrOrderResponse.SubErpOrder subPurchase : ThrOrderResponse.getSubErpOrders()) {
ThrErpOrderResponse ThrErpOrderResponse = new ThrErpOrderResponse();
ThrErpOrderResponse.setErpOrderId(ThrOrderResponse.getBillNo());
ThrErpOrderResponse.setCompanyid(ThrOrderResponse.getCorpId());
ThrErpOrderResponse.setCompanyname(ThrOrderResponse.getCorpName());
ThrErpOrderResponse.setCredate(ThrOrderResponse.getBilldate());
ThrErpOrderResponse.setGoodsid(subPurchase.getProductId());
ThrErpOrderResponse.setGoodsname(subPurchase.getProductName());
ThrErpOrderResponse.setBatchNo(subPurchase.getBatchNo());
ThrErpOrderResponse.setProductDate(subPurchase.getProductDate());
ThrErpOrderResponse.setExpireDate(subPurchase.getExpireDate());
ThrErpOrderResponse.setErpCount(subPurchase.getCount());
ThrErpOrderResponse.setReCount(subPurchase.getReCount());
ThrErpOrderResponse.setOriginType(ThrOrderResponse.getOriginType());
ThrErpOrderResponse.setGoodsunit(subPurchase.getSpec());
ThrErpOrderResponse.setOrderFromType(ConstantStatus.SORDER_FROM_ONLINE);
erpOrderEntities.add(ThrErpOrderResponse);
}
}
return erpOrderEntities;
}
} catch (
Exception e) {
e.printStackTrace();
}
return null;
}
// public BaseResponse submitOrder(UdiwmsOrderRequest udiwmsOrderRequest) {
// BasicThirdSysEntity basicThirdSysEntity = basicThirdSysService.selectByThirdId(udiwmsOrderRequest.getThirdSys());
// String url = basicThirdSysEntity.getThridUrl() + "/udiwms/erp/submitOrders";
// String response = httpOkClient.uCloudPost(url, udiwmsOrderRequest);
// try {
// BaseResponse<PageSimpleResponse<ThrOrderResponse>> responseBaseResponse =
// JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<ThrOrderResponse>>>() {
// });
// return responseBaseResponse;
// } catch (Exception e) {
// log.error("获取订单数据异常", e);
// }
// return null;
// }
// public BaseResponse postBill(Map<String, List<ThrErpOrderResponse>> postMap, String billAction, String uploadUrl, String thirdSysFk) {
// ERPPostBillRequest erpPostBillRequest = new ERPPostBillRequest();
// erpPostBillRequest.setPostMap(postMap);
// erpPostBillRequest.setBillAction(billAction);
//
// //查询第三方服务授权参数
// BasicThirdSysEntity basicThirdSysEntity = basicThirdSysService.selectByThirdId(thirdSysFk);
// String response = httpOkClient.uCloudPost(uploadUrl, erpPostBillRequest, basicThirdSysEntity);
// BaseResponse baseResponse = JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
// });
// return baseResponse;
// }
//
// public BaseResponse postBill(ERPPostBillRequest erpPostBillRequest, String uploadUrl) {
// String response = httpOkClient.uCloudPost(uploadUrl, erpPostBillRequest);
// BaseResponse baseResponse =
// JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
// });
// return baseResponse;
// }
//
// public BaseResponse signBill(USignRequest signRequest, String url) {
// String response = httpOkClient.uCloudPost(url, signRequest);
// BaseResponse baseResponse =
// JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
// });
// return baseResponse;
// }
}

@ -0,0 +1,36 @@
package com.glxp.api.req.thrsys;
import lombok.Data;
@Data
public class FilterOrderRequest {
private Integer id;
private String startDate; //起始日期
private String endDate; //结束日期
private String billNo; //单据号
private String billFlag; //单据状态,0.未签字1.已签字
private String billAction;
private String corpName;
private Integer limit;
private Integer page;
private String originType;
private String customerId;
private String status;
private Boolean isDownThrSys;
private Boolean isLocal;
private String localAction;
private String locStorageCode;
private String invWarehouseCode;
//第三方系统ID
private String thirdSys;
private Integer editStatus;
private String action;
private String thirdAction;
private String thirdOrderFk;
private Integer type;
private Integer allocateStatus;
}

@ -0,0 +1,14 @@
package com.glxp.api.req.thrsys;
import com.glxp.api.req.ListPageRequest;
import lombok.Data;
@Data
public class FilterThrOrderDetailRequest extends ListPageRequest {
private String orderIdFk;
private String thirdSysFk;
}

@ -0,0 +1,32 @@
package com.glxp.api.req.thrsys;
import com.glxp.api.req.ListPageRequest;
import com.glxp.api.res.thrsys.ThrOrderResponse;
import lombok.Data;
import java.util.List;
@Data
public class FilterThrOrderRequest extends ListPageRequest {
private String id;
private String billNo;
private String thirdSysFk;
private String startDate; //起始日期
private String endDate; //结束日期
private String billFlag; //单据状态,0.未签字1.已签字
private String billAction;
private String corpName;
private String unitIdFk;
private String originType;
private String status;
private String thirdSys;
private Integer editStatus;
private String lastUpdateTime;
private Integer thirdPartyDate;
private Integer type;
private Integer allocateStatus;
private List<ThrOrderResponse> erpOrderResponses;
}

@ -0,0 +1,17 @@
package com.glxp.api.req.thrsys;
import com.glxp.api.entity.thrsys.ThrOrderImportDetailEntity;
import lombok.Data;
import java.util.List;
@Data
public class PostFileThrOrderRequest {
private String genKey;
private String thirdSys;
private String uploadType;
private List<ThrOrderImportDetailEntity> datas;
}

@ -0,0 +1,11 @@
package com.glxp.api.req.thrsys;
import lombok.Data;
import java.util.List;
@Data
public class PostSmpOrderRequest {
List<String> ids;
}

@ -0,0 +1,30 @@
package com.glxp.api.req.thrsys;
import com.glxp.api.res.thrsys.ThrOrderResponse;
import lombok.Data;
import java.util.List;
@Data
public class PostThrOrderRequest {
private String genKey;
private String thirdSys;
private String uploadType;
private List<ThrOrderResponse> datas;
//增加字段
private String startDate; //起始日期
private String endDate; //结束日期
private String createUser; //创建人
private String reviewUser; //审核人
private String address; //地址
private String linkMan; //联系人
private String linkTel; //联系电话
private String remark; //备注
private String remark1; //备注1
private String remark2; //备注2
private String remark3; //备注3
}

@ -0,0 +1,22 @@
package com.glxp.api.req.thrsys;
import com.glxp.api.res.thrsys.ThrOrderResponse;
import lombok.Data;
import java.util.List;
@Data
public class ThrOrderExportRequest {
private List<ThrOrderResponse> erpOrderResponses;
private String id;
private String billNo;
private String thirdSysFk;
private String startDate; //起始日期
private String endDate; //结束日期
private String billFlag; //单据状态,0.未签字1.已签字
private String billAction;
}

@ -0,0 +1,166 @@
package com.glxp.api.req.thrsys;
import java.util.List;
public class UploadSmpRequest {
private String billNo;
private String billdate;
private String corpId;
private String corpName;
private String billType;
private String billFlag;
private String thirdSysFk;
private Integer type;
private List<SubErpOrder> subErpOrders;
public String getBillNo() {
return billNo;
}
public void setBillNo(String billNo) {
this.billNo = billNo;
}
public String getBilldate() {
return billdate;
}
public void setBilldate(String billdate) {
this.billdate = billdate;
}
public String getCorpId() {
return corpId;
}
public void setCorpId(String corpId) {
this.corpId = corpId;
}
public String getCorpName() {
return corpName;
}
public void setCorpName(String corpName) {
this.corpName = corpName;
}
public String getBillType() {
return billType;
}
public void setBillType(String billType) {
this.billType = billType;
}
public List<SubErpOrder> getSubErpOrders() {
return subErpOrders;
}
public void setSubErpOrders(List<SubErpOrder> subErpOrders) {
this.subErpOrders = subErpOrders;
}
public String getBillFlag() {
return billFlag;
}
public void setBillFlag(String billFlag) {
this.billFlag = billFlag;
}
public String getThirdSysFk() {
return thirdSysFk;
}
public void setThirdSysFk(String thirdSysFk) {
this.thirdSysFk = thirdSysFk;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public static class SubErpOrder {
private String productId;
private String productName;
private String spec;
private String batchNo;
private String expireDate;
private String productDate;
private Integer count; //账面数量
private Integer reCount; //实际数量
public String getProductId() {
return productId;
}
public void setProductId(String productId) {
this.productId = productId;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public String getSpec() {
return spec;
}
public void setSpec(String spec) {
this.spec = spec;
}
public String getBatchNo() {
return batchNo;
}
public void setBatchNo(String batchNo) {
this.batchNo = batchNo;
}
public String getExpireDate() {
return expireDate;
}
public void setExpireDate(String expireDate) {
this.expireDate = expireDate;
}
public String getProductDate() {
return productDate;
}
public void setProductDate(String productDate) {
this.productDate = productDate;
}
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
public Integer getReCount() {
return reCount;
}
public void setReCount(Integer reCount) {
this.reCount = reCount;
}
}
}

@ -0,0 +1,78 @@
package com.glxp.api.res.thrsys;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class ThrErpOrderResponse {
private long id;
private String erpOrderId;
private String iodtlId;
private String inoutId;
private String companyid;
private String companyname;
private String goodsid;
private String goodsname;
private String goodsunit;
private String batchNoId;
private String batchNo;
private String credate;
private String warehouseCode;
private String productDate;
private String expireDate;
private Integer erpCount;
private String originType;
private Integer reCount;
private String uuidFk;
private String supId;
private String supName;
private Integer bindSupStatus;
private String nameCode;
private String productCompany;
private String coName;
private String authCode;
private String packSpec;
private String packRatio;
private int bhzxxsbzsl;
private int zxxsbzbhsydysl;
private String isDownload;
private String orderIdFk;
private String nameCodes;
private String status;
private Integer count;
private String relIdFk;
private Integer bindStatus;
private int orderFromType; //1.本地业务单据0.本地缓存第三方业务单据;(默认02.实时拉取第三方业务单据
private String ylqxzcrbarmc;
private String secSalesListNo;
private String firstSalesInvNo;
private String secSalesInvNo;
private String invoiceDate;
private BigDecimal price;
private boolean checkSuccess;
private String locStorageCode;
private String invWarehouseCode;//当前分库
private String fromSubInvCode; //往来分库
private String billType;
public Integer getBindStatus() {
if (bindStatus == null)
return 0;
return bindStatus;
}
private String bindRlFk;
private String serialNo;
private String code;
private Integer codeId;
}

@ -0,0 +1,190 @@
package com.glxp.api.res.thrsys;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
@Data
public class ThrOrderResponse {
private Integer id;
private String billNo;
private String billdate;
private String corpId;
private String corpName;
private String billType;
private String billFlag;
private String originType;
private String locStorageCode;
private String invWarehouseCode;//当前分库
private String fromSubInvCode; //往来分库
private String thirdSysFk;
private List<ThrOrderResponse.SubErpOrder> subErpOrders;
//增加字段
private String startDate; //起始日期
private String endDate; //结束日期
private String createUser; //创建人
private String reviewUser; //审核人
private String address; //地址
private String linkMan; //联系人
private String linkTel; //联系电话
private String remark; //备注
private String remark1; //备注1
private String remark2; //备注2
private String remark3; //备注3
private String invWarehouseName;
private String fromSubInvName;
public static class SubErpOrder {
private Integer id;
private String productId;
private String productName;
private String spec;
private String batchNo;
private String expireDate;
private String productDate;
private Integer count; //账面数量
private Integer reCount; //实际数量
private String orderIdFk;
private String thirdSysFk;
private String sweepCount;
private String relId; //基础信息关联表主键
private String detailId; //明细ID
private String corpName; //往来单位
private BigDecimal price; //单价
public String getDetailId() {
return detailId;
}
public void setDetailId(String detailId) {
this.detailId = detailId;
}
public String getCorpName() {
return corpName;
}
public void setCorpName(String corpName) {
this.corpName = corpName;
}
public BigDecimal getPrice() {
return price;
}
public void setPrice(BigDecimal price) {
this.price = price;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getOrderIdFk() {
return orderIdFk;
}
public void setOrderIdFk(String orderIdFk) {
this.orderIdFk = orderIdFk;
}
public String getThirdSysFk() {
return thirdSysFk;
}
public void setThirdSysFk(String thirdSysFk) {
this.thirdSysFk = thirdSysFk;
}
public String getProductId() {
return productId;
}
public void setProductId(String productId) {
this.productId = productId;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public String getSpec() {
return spec;
}
public void setSpec(String spec) {
this.spec = spec;
}
public String getBatchNo() {
return batchNo;
}
public void setBatchNo(String batchNo) {
this.batchNo = batchNo;
}
public String getExpireDate() {
return expireDate;
}
public void setExpireDate(String expireDate) {
this.expireDate = expireDate;
}
public String getProductDate() {
return productDate;
}
public void setProductDate(String productDate) {
this.productDate = productDate;
}
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
public Integer getReCount() {
return reCount;
}
public void setReCount(Integer reCount) {
this.reCount = reCount;
}
public String getSweepCount() {
return sweepCount;
}
public void setSweepCount(String sweepCount) {
this.sweepCount = sweepCount;
}
public String getRelId() {
return relId;
}
public void setRelId(String relId) {
this.relId = relId;
}
}
}

@ -0,0 +1,29 @@
package com.glxp.api.service.thrsys;
import com.glxp.api.entity.thrsys.ThrOrderDetailEntity;
import com.glxp.api.req.thrsys.FilterThrOrderDetailRequest;
import java.util.List;
public interface ThrOrderDetailService {
List<ThrOrderDetailEntity> filterThrOrderDetailDetail(FilterThrOrderDetailRequest filterThrOrderDetailRequest);
boolean insertThrOrderDetail(ThrOrderDetailEntity thrOrderDetailEntity);
boolean insertThrOrderDetails(List<ThrOrderDetailEntity> thrOrderDetailEntities);
boolean updateThrOrderDetail(ThrOrderDetailEntity thrOrderDetailEntity);
boolean deleteById(String id);
boolean deleteByOrderIdFk(String id);
boolean deleteAll();
boolean deleteByTime();
}

@ -0,0 +1,23 @@
package com.glxp.api.service.thrsys;
import com.glxp.api.entity.thrsys.ThrOrderExportLogEntity;
import com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest;
import java.util.List;
public interface ThrOrderExportLogService {
ThrOrderExportLogEntity selectByGenKey(String genKey);
List<ThrOrderExportLogEntity> filterThrOrderExportLog(FilterThrCorpImportLogRequest filterThrCorpImportLogRequest);
boolean insertThrOrderExportLog(ThrOrderExportLogEntity thrOrderExportLogEntity);
boolean updateThrOrderExportLog(ThrOrderExportLogEntity thrOrderExportLogEntity);
boolean deleteById(String id);
boolean deleteByTime();
}

@ -0,0 +1,25 @@
package com.glxp.api.service.thrsys;
import com.glxp.api.entity.thrsys.ThrOrderImportDetailEntity;
import com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest;
import java.util.List;
public interface ThrOrderImportDetailService {
List<ThrOrderImportDetailEntity> filterOrderImportDetail(FilterThrCorpImportLogRequest filterThrCorpImportLogRequest);
boolean insertOrderImportDetail(ThrOrderImportDetailEntity thrOrderImportDetailEntity);
boolean updateOrderImportDetail(ThrOrderImportDetailEntity thrOrderImportDetailEntity);
boolean insertOrderImportDetails(List<ThrOrderImportDetailEntity> thrOrderImportDetailEntities);
boolean deleteById(String id);
boolean deleteByTime();
boolean deleteByGenkey(String genKey);
}

@ -0,0 +1,25 @@
package com.glxp.api.service.thrsys;
import com.glxp.api.entity.thrsys.ThrOrderImportLogEntity;
import com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest;
import java.util.List;
public interface ThrOrderImportLogService {
ThrOrderImportLogEntity selectByGenKey(String genKey);
List<ThrOrderImportLogEntity> filterThrOrderImportLog(FilterThrCorpImportLogRequest filterThrCorpImportLogRequest);
boolean insertImportLog(ThrOrderImportLogEntity thrOrderImportLogEntity);
boolean updateImportLog(ThrOrderImportLogEntity thrOrderImportLogEntity);
boolean deleteById(String id);
boolean deleteByTime();
void importThrOrder(String genKey);
}

@ -0,0 +1,40 @@
package com.glxp.api.service.thrsys;
import com.glxp.api.entity.thrsys.ThrOrderEntity;
import com.glxp.api.req.thrsys.FilterThrOrderRequest;
import com.glxp.api.res.thrsys.ThrErpOrderResponse;
import com.glxp.api.res.thrsys.ThrOrderResponse;
import java.util.List;
public interface ThrOrderService {
List<ThrOrderEntity> filterThrOrder(FilterThrOrderRequest filterThrOrderRequest);
List<ThrOrderEntity> filterReceiveOrder(FilterThrOrderRequest filterThrOrderRequest);
List<ThrErpOrderResponse> filterAllOrders(List<String> billNos, String action);
List<ThrOrderResponse> filterAllDetail(FilterThrOrderRequest filterThrOrderRequest);
ThrOrderEntity findByUnique(String billNo, String thirdSysFk);
ThrOrderEntity findReceiveOrder(String billNo);
ThrOrderEntity findById(String id);
boolean insertThrOrder(ThrOrderEntity thrCorpEntity);
boolean insertThrOrders(List<ThrOrderEntity> thrOrderEntities);
boolean updateThrOrder(ThrOrderEntity thrOrderEntity);
boolean deleteById(String id);
boolean deleteAll();
}

@ -0,0 +1,678 @@
package com.glxp.api.service.thrsys;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.config.WebSocketServer;
import com.glxp.api.constant.BasicProcessStatus;
import com.glxp.api.constant.Constant;
import com.glxp.api.entity.system.SyncDataSetEntity;
import com.glxp.api.entity.thrsys.*;
import com.glxp.api.http.ErpOrderClient;
import com.glxp.api.http.HttpOkClient;
import com.glxp.api.req.thrsys.*;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.thrsys.ThrOrderResponse;
import com.glxp.api.service.system.SyncDataSetService;
import com.glxp.api.util.RedisUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service
public class ThrOrdersDlService {
// @Value("${SPSYNC_IP}")
// private String spsSyncUrl;
@Resource
ThrOrderService thrOrderService;
@Resource
ThrOrderDetailService thrOrderDetailService;
@Resource
ThrSystemDetailService thrSystemDetailService;
@Resource
RedisUtil redisUtil;
@Resource
private ThrOrderImportLogService thrOrderImportLogService;
@Resource
ThrOrderExportLogService thrOrderExportLogService;
@Resource
ThrOrderImportDetailService thrOrderImportDetailService;
// @Resource
// ThrOrderImportService thrOrderImportService;
@Resource
private ErpOrderClient erpOrderClient;
@Resource
SyncDataSetService syncDataSetService;
@Resource
HttpOkClient httpOkClient;
public String getIpUrl() {
SyncDataSetEntity syncDataSetEntity = syncDataSetService.findSet();
return syncDataSetEntity.getSyncIp();
}
@Async
public void importOrders(String genKey, String action, FilterThrOrderRequest filterThrProductsRequest) {
ThrOrderImportLogEntity thrOrderImportLogEntity = thrOrderImportLogService.selectByGenKey(genKey);
//todo单据还没设计好
// BasicThirdSysDetailEntity basicThirdSysDetailEntity = bussinessTypeService.findByActionKey(action, "orderQueryUrl");
// if (basicThirdSysDetailEntity == null || basicThirdSysDetailEntity.getValue() == null) {
// WebSocketServer.sendInfo("业务单据查询接口未设置!", "sid");
// return;
// }
ThrSystemDetailEntity thrSystemDetailEntity=new ThrSystemDetailEntity();
int page = 1;
int limit = 100;
while (page != -1) {
page = getOrders(page, limit, thrSystemDetailEntity.getValue(), thrSystemDetailEntity.getThirdSysFk(), thrOrderImportLogEntity, action, filterThrProductsRequest);
}
thrOrderImportLogService.importThrOrder(genKey);
redisUtil.set(Constant.dlThrProducts, "false");
WebSocketServer.sendInfo("业务单据信息下载已完成,请刷新查看!", "sid");
thrOrderImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
thrOrderImportLogService.updateImportLog(thrOrderImportLogEntity);
}
@Async
public void importSelectOrders(String genKey, List<ThrOrderResponse> erpOrderResponses, String thirdSys) {
ThrOrderImportLogEntity thrOrderImportLogEntity = thrOrderImportLogService.selectByGenKey(genKey);
if (erpOrderResponses != null && erpOrderResponses.size() > 0) {
for (ThrOrderResponse erpOrderResponse : erpOrderResponses) {
List<ThrOrderImportDetailEntity> thrOrderDetailEntities = new ArrayList<>();
for (ThrOrderResponse.SubErpOrder subPurchase : erpOrderResponse.getSubErpOrders()) {
ThrOrderImportDetailEntity thrOrderDetailEntity = new ThrOrderImportDetailEntity();
BeanUtils.copyProperties(subPurchase, thrOrderDetailEntity);
BeanUtils.copyProperties(erpOrderResponse, thrOrderDetailEntity);
thrOrderDetailEntity.setGenKeyFk(thrOrderImportLogEntity.getGenKey());
thrOrderDetailEntity.setThirdSysFk(thirdSys);
thrOrderDetailEntity.setUpdateTime(new Date());
thrOrderDetailEntities.add(thrOrderDetailEntity);
}
thrOrderImportDetailService.insertOrderImportDetails(thrOrderDetailEntities);
}
}
thrOrderImportLogService.importThrOrder(genKey);
redisUtil.set(Constant.dlThrProducts, "false");
WebSocketServer.sendInfo("业务单据信息下载已完成,请刷新查看!", "sid");
thrOrderImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
thrOrderImportLogService.updateImportLog(thrOrderImportLogEntity);
}
@Async
public void genExcel(String genKey, ThrOrderExportRequest thrOrderExportRequest) {
ThrOrderExportLogEntity thrOrderExportLogEntity = thrOrderExportLogService.selectByGenKey(genKey);
List<List<String>> excelData = new ArrayList<>();
List<String> head = new ArrayList<>();
head.add("单据号");
head.add("单据日期");
head.add("往来单位ID");
head.add("往来单位名称");
head.add("单据类型");
head.add("单据状态");
head.add("产品ID");
head.add("产品名称");
head.add("规格型号");
head.add("批次号");
head.add("生产日期");
head.add("失效日期");
head.add("订单数量");
head.add("实际数量");
head.add("原单据类型");
excelData.add(head);
//todo改功能有关表还未设计
// BussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findBTByAction(thrOrderExportRequest.getBillAction());
//
// //选中导出
// if (thrOrderExportRequest.getErpOrderResponses() != null && thrOrderExportRequest.getErpOrderResponses().size() > 0) {
// BussinessTypeFilterRequest bussinessTypeFilterRequest = new BussinessTypeFilterRequest();
// bussinessTypeFilterRequest.setEnabled(true);
// List<BussinessTypeEntity> bussinessTypeEntities = bussinessTypeService.filterList(bussinessTypeFilterRequest);
// List<ErpOrderResponse> erpOrderResponses = thrOrderExportRequest.getErpOrderResponses();
// for (ErpOrderResponse erpOrderResponse : erpOrderResponses) {
// List<ErpOrderResponse.SubErpOrder> subErpOrders = erpOrderResponse.getSubErpOrders();
// for (ErpOrderResponse.SubErpOrder subErpOrder : subErpOrders) {
// List<String> rows = new ArrayList<>();
// rows.add(erpOrderResponse.getBillNo());
// rows.add(erpOrderResponse.getBilldate());
//// BasicUnitMaintainEntity basicUnitMaintainEntity = basicUnitMaintainService.selectByThirdId(erpOrderResponse.getCorpId(), bussinessTypeEntity.getThirdSysFk());
//// if (basicUnitMaintainEntity != null)
//// rows.add(basicUnitMaintainEntity.getErpId());
//// else
// rows.add(erpOrderResponse.getCorpId());
//
// rows.add(erpOrderResponse.getCorpName());
// rows.add(getName(bussinessTypeEntities, erpOrderResponse.getBillType()));
// rows.add(erpOrderResponse.getBillFlag());
// rows.add(subErpOrder.getProductId());
// rows.add(subErpOrder.getProductName());
// rows.add(subErpOrder.getSpec());
// rows.add(subErpOrder.getBatchNo());
// rows.add(subErpOrder.getProductDate());
// rows.add(subErpOrder.getExpireDate());
// rows.add(subErpOrder.getCount() + "");
// rows.add(subErpOrder.getReCount() + "");
// rows.add(erpOrderResponse.getOriginType());
// excelData.add(rows);
// }
//
// }
//
// } else {//一键导出
//
// BasicThirdSysDetailEntity basicThirdSysDetailEntity = thrSystemDetailService.selectByKey("orderQueryUrl", bussinessTypeEntity.getThirdSysFk());
//
// if (basicThirdSysDetailEntity == null || basicThirdSysDetailEntity.getValue() == null) {
// thrOrderExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
// thrOrderExportLogEntity.setRemark("业务单据接口地址未定义");
// thrOrderExportLogService.updateThrOrderExportLog(thrOrderExportLogEntity);
// return;
// }
// if (!basicThirdSysDetailEntity.getEnabled() || basicThirdSysDetailEntity.getThirdSysFk() == null) {
// thrOrderExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
// thrOrderExportLogEntity.setRemark("第三方系统业务单据接口服务未启用");
// thrOrderExportLogService.updateThrOrderExportLog(thrOrderExportLogEntity);
// return;
// }
//
//
// if (basicThirdSysDetailEntity.getFromType() == 0) {
// FilterThrOrderRequest filterThrOrderRequest = new FilterThrOrderRequest();
// filterThrOrderRequest.setThirdSysFk(bussinessTypeEntity.getThirdSysFk());
// BeanUtils.copyProperties(thrOrderExportRequest, filterThrOrderRequest);
// List<List<String>> datas = exportThrOrders(filterThrOrderRequest);
// excelData.addAll(datas);
// } else {
// FilterThrOrderRequest filterThrOrderRequest = new FilterThrOrderRequest();
// BeanUtils.copyProperties(thrOrderExportRequest, filterThrOrderRequest);
// List<List<String>> genDatas = genExcelData(filterThrOrderRequest);
// if (genDatas != null && genDatas.size() > 0) {
// excelData.addAll(genDatas);
// }
// }
//
// }
// String sheetName = "业务单据";
// new ExcelUtil().exportExcel(excelData, sheetName, thrOrderExportLogEntity.getFilePath(), 20);
// thrOrderExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
thrOrderExportLogService.updateThrOrderExportLog(thrOrderExportLogEntity);
}
//
//
// @Async
// public void genJsonFile(String genKey, ThrOrderExportRequest thrOrderExportRequest) {
// ThrOrderExportJsonResponse thrOrderExportJsonResponse = new ThrOrderExportJsonResponse();
// ThrOrderExportLogEntity thrOrderExportLogEntity = thrOrderExportLogService.selectByGenKey(genKey);
// BussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findBTByAction(thrOrderExportRequest.getBillAction());
// List<ErpOrderResponse> erpOrderResponses = thrOrderExportRequest.getErpOrderResponses();
// //选中导出
// if (thrOrderExportRequest.getErpOrderResponses() != null && thrOrderExportRequest.getErpOrderResponses().size() > 0) {
// BussinessTypeFilterRequest bussinessTypeFilterRequest = new BussinessTypeFilterRequest();
// bussinessTypeFilterRequest.setEnabled(true);
// if (erpOrderResponses != null && erpOrderResponses.size() > 0) {
// List<ThrOrderEntity> thrOrderEntities = new ArrayList<>();
// List<ThrOrderDetailEntity> thrOrderDetailEntities = new ArrayList<>();
// for (ErpOrderResponse erpOrderResponse : erpOrderResponses) {
// ThrOrderEntity thrOrderEntity = new ThrOrderEntity();
// BeanUtils.copyProperties(erpOrderResponse, thrOrderEntity);
// thrOrderEntities.add(thrOrderEntity);
// if (erpOrderResponse.getSubErpOrders() != null && erpOrderResponse.getSubErpOrders().size() > 0) {
// for (ErpOrderResponse.SubErpOrder subErpOrder : erpOrderResponse.getSubErpOrders()) {
// ThrOrderDetailEntity thrOrderDetailEntity = new ThrOrderDetailEntity();
// BeanUtils.copyProperties(subErpOrder, thrOrderDetailEntity);
// thrOrderDetailEntities.add(thrOrderDetailEntity);
// }
// }
// }
// thrOrderExportJsonResponse.setThrOrderEntityList(thrOrderEntities);
// thrOrderExportJsonResponse.setThrOrderDetailEntities(thrOrderDetailEntities);
// }
// } else {//一键导出
// BasicThirdSysDetailEntity basicThirdSysDetailEntity = basicThirdSysDetailService.selectByKey("orderQueryUrl", bussinessTypeEntity.getThirdSysFk());
// if (basicThirdSysDetailEntity == null || basicThirdSysDetailEntity.getValue() == null) {
// thrOrderExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
// thrOrderExportLogEntity.setRemark("业务单据接口地址未定义");
// thrOrderExportLogService.updateThrOrderExportLog(thrOrderExportLogEntity);
// return;
// }
// if (!basicThirdSysDetailEntity.getEnabled() || basicThirdSysDetailEntity.getThirdSysFk() == null) {
// thrOrderExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
// thrOrderExportLogEntity.setRemark("第三方系统业务单据接口服务未启用");
// thrOrderExportLogService.updateThrOrderExportLog(thrOrderExportLogEntity);
// return;
// }
// if (basicThirdSysDetailEntity.getFromType() == 0) {
// FilterThrOrderRequest filterThrOrderRequest = new FilterThrOrderRequest();
// filterThrOrderRequest.setThirdSysFk(bussinessTypeEntity.getThirdSysFk());
// BeanUtils.copyProperties(thrOrderExportRequest, filterThrOrderRequest);
// erpOrderResponses = getThrOrders(filterThrOrderRequest);
// if (erpOrderResponses != null && erpOrderResponses.size() > 0) {
// List<ThrOrderEntity> thrOrderEntities = new ArrayList<>();
// List<ThrOrderDetailEntity> thrOrderDetailEntities = new ArrayList<>();
// for (ErpOrderResponse erpOrderResponse : erpOrderResponses) {
// ThrOrderEntity thrOrderEntity = new ThrOrderEntity();
// BeanUtils.copyProperties(erpOrderResponse, thrOrderEntity);
// thrOrderEntities.add(thrOrderEntity);
// if (erpOrderResponse.getSubErpOrders() != null && erpOrderResponse.getSubErpOrders().size() > 0) {
// for (ErpOrderResponse.SubErpOrder subErpOrder : erpOrderResponse.getSubErpOrders()) {
// ThrOrderDetailEntity thrOrderDetailEntity = new ThrOrderDetailEntity();
// BeanUtils.copyProperties(subErpOrder, thrOrderDetailEntity);
// thrOrderDetailEntities.add(thrOrderDetailEntity);
// }
// }
// }
// thrOrderExportJsonResponse.setThrOrderEntityList(thrOrderEntities);
// thrOrderExportJsonResponse.setThrOrderDetailEntities(thrOrderDetailEntities);
// }
// } else {
// FilterThrOrderRequest filterThrOrderRequest = new FilterThrOrderRequest();
// BeanUtils.copyProperties(thrOrderExportRequest, filterThrOrderRequest);
// List<ThrOrderEntity> thrOrderEntities = thrOrderService.filterThrOrder(filterThrOrderRequest);
// List<ThrOrderDetailEntity> results = new ArrayList<>();
// for (ThrOrderEntity thrOrderEntity : thrOrderEntities) {
// FilterThrOrderDetailRequest filterThrOrderDetailRequest = new FilterThrOrderDetailRequest();
// filterThrOrderDetailRequest.setOrderIdFk(thrOrderEntity.getId() + "");
// List<ThrOrderDetailEntity> thrOrderDetailEntities = thrOrderDetailService.filterThrOrderDetailDetail(filterThrOrderDetailRequest);
// if (thrOrderDetailEntities != null) {
// results.addAll(thrOrderDetailEntities);
// }
//
// }
//
// thrOrderExportJsonResponse.setThrOrderEntityList(thrOrderEntities);
// thrOrderExportJsonResponse.setThrOrderDetailEntities(results);
// }
//
// }
// FileWriter writer = new FileWriter(thrOrderExportLogEntity.getFilePath());
// writer.write(JSONUtil.toJsonStr(thrOrderExportJsonResponse));
// thrOrderExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
// thrOrderExportLogService.updateThrOrderExportLog(thrOrderExportLogEntity);
// }
//
//
// @Async
// public void uploadSpssync(String genKey, ThrOrderExportRequest thrOrderExportRequest) {
//
// ThrOrderExportJsonResponse thrOrderExportJsonResponse = new ThrOrderExportJsonResponse();
// ThrOrderExportLogEntity thrOrderExportLogEntity = thrOrderExportLogService.selectByGenKey(genKey);
// BussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findBTByAction(thrOrderExportRequest.getBillAction());
// List<ErpOrderResponse> erpOrderResponses = thrOrderExportRequest.getErpOrderResponses();
// //选中导出
// if (thrOrderExportRequest.getErpOrderResponses() != null && thrOrderExportRequest.getErpOrderResponses().size() > 0) {
// BussinessTypeFilterRequest bussinessTypeFilterRequest = new BussinessTypeFilterRequest();
// bussinessTypeFilterRequest.setEnabled(true);
// if (erpOrderResponses != null && erpOrderResponses.size() > 0) {
// List<ThrOrderEntity> thrOrderEntities = new ArrayList<>();
// List<ThrOrderDetailEntity> thrOrderDetailEntities = new ArrayList<>();
// for (ErpOrderResponse erpOrderResponse : erpOrderResponses) {
// ThrOrderEntity thrOrderEntity = new ThrOrderEntity();
// BeanUtils.copyProperties(erpOrderResponse, thrOrderEntity);
// thrOrderEntities.add(thrOrderEntity);
// if (erpOrderResponse.getSubErpOrders() != null && erpOrderResponse.getSubErpOrders().size() > 0) {
// for (ErpOrderResponse.SubErpOrder subErpOrder : erpOrderResponse.getSubErpOrders()) {
// ThrOrderDetailEntity thrOrderDetailEntity = new ThrOrderDetailEntity();
// BeanUtils.copyProperties(subErpOrder, thrOrderDetailEntity);
// thrOrderDetailEntities.add(thrOrderDetailEntity);
// }
// }
// }
// thrOrderExportJsonResponse.setThrOrderEntityList(thrOrderEntities);
// thrOrderExportJsonResponse.setThrOrderDetailEntities(thrOrderDetailEntities);
// }
// } else {//一键导出
// BasicThirdSysDetailEntity basicThirdSysDetailEntity = basicThirdSysDetailService.selectByKey("orderQueryUrl", bussinessTypeEntity.getThirdSysFk());
// if (basicThirdSysDetailEntity == null || basicThirdSysDetailEntity.getValue() == null) {
// thrOrderExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
// thrOrderExportLogEntity.setRemark("业务单据接口地址未定义");
// thrOrderExportLogService.updateThrOrderExportLog(thrOrderExportLogEntity);
// return;
// }
// if (!basicThirdSysDetailEntity.getEnabled() || basicThirdSysDetailEntity.getThirdSysFk() == null) {
// thrOrderExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
// thrOrderExportLogEntity.setRemark("第三方系统业务单据接口服务未启用");
// thrOrderExportLogService.updateThrOrderExportLog(thrOrderExportLogEntity);
// return;
// }
// if (basicThirdSysDetailEntity.getFromType() == 0) {
// FilterThrOrderRequest filterThrOrderRequest = new FilterThrOrderRequest();
// filterThrOrderRequest.setThirdSysFk(bussinessTypeEntity.getThirdSysFk());
// BeanUtils.copyProperties(thrOrderExportRequest, filterThrOrderRequest);
// erpOrderResponses = getThrOrders(filterThrOrderRequest);
// if (erpOrderResponses != null && erpOrderResponses.size() > 0) {
// List<ThrOrderEntity> thrOrderEntities = new ArrayList<>();
// List<ThrOrderDetailEntity> thrOrderDetailEntities = new ArrayList<>();
// for (ErpOrderResponse erpOrderResponse : erpOrderResponses) {
// ThrOrderEntity thrOrderEntity = new ThrOrderEntity();
// BeanUtils.copyProperties(erpOrderResponse, thrOrderEntity);
// thrOrderEntities.add(thrOrderEntity);
// if (erpOrderResponse.getSubErpOrders() != null && erpOrderResponse.getSubErpOrders().size() > 0) {
// for (ErpOrderResponse.SubErpOrder subErpOrder : erpOrderResponse.getSubErpOrders()) {
// ThrOrderDetailEntity thrOrderDetailEntity = new ThrOrderDetailEntity();
// BeanUtils.copyProperties(subErpOrder, thrOrderDetailEntity);
// thrOrderDetailEntities.add(thrOrderDetailEntity);
// }
// }
// }
// thrOrderExportJsonResponse.setThrOrderEntityList(thrOrderEntities);
// thrOrderExportJsonResponse.setThrOrderDetailEntities(thrOrderDetailEntities);
// }
// } else {
// FilterThrOrderRequest filterThrOrderRequest = new FilterThrOrderRequest();
// BeanUtils.copyProperties(thrOrderExportRequest, filterThrOrderRequest);
// List<ThrOrderEntity> thrOrderEntities = thrOrderService.filterThrOrder(filterThrOrderRequest);
// List<ThrOrderDetailEntity> results = new ArrayList<>();
// for (ThrOrderEntity thrOrderEntity : thrOrderEntities) {
// FilterThrOrderDetailRequest filterThrOrderDetailRequest = new FilterThrOrderDetailRequest();
// filterThrOrderDetailRequest.setOrderIdFk(thrOrderEntity.getId() + "");
// List<ThrOrderDetailEntity> thrOrderDetailEntities = thrOrderDetailService.filterThrOrderDetailDetail(filterThrOrderDetailRequest);
// if (thrOrderDetailEntities != null) {
// results.addAll(thrOrderDetailEntities);
// }
//
// }
//
// thrOrderExportJsonResponse.setThrOrderEntityList(thrOrderEntities);
// thrOrderExportJsonResponse.setThrOrderDetailEntities(results);
// }
//
// }
// thrOrderExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
// thrOrderExportLogService.updateThrOrderExportLog(thrOrderExportLogEntity);
// String response = httpOkClient.uCloudPost(getIpUrl() + "/spssync/thirdsys/order/upload", thrOrderExportJsonResponse);
// BaseResponse baseResponse = JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
// });
// if (baseResponse.getCode() == 20000) {
// thrOrderExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
// } else {
// thrOrderExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
// }
// thrOrderExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
// thrOrderExportLogService.updateThrOrderExportLog(thrOrderExportLogEntity);
// }
//
// public String getName(List<BussinessTypeEntity> bussinessTypeEntities, String action) {
// for (BussinessTypeEntity bussinessTypeEntity : bussinessTypeEntities) {
// if (bussinessTypeEntity.getAction().equals(action)) {
// return bussinessTypeEntity.getName();
// }
// }
// return action;
// }
//
@Async
public void uploadSmp(String genKey, ThrOrderExportRequest thrOrderExportRequest) {
ThrOrderExportLogEntity thrOrderExportLogEntity = thrOrderExportLogService.selectByGenKey(genKey);
PostThrOrderRequest postThrOrderRequest = new PostThrOrderRequest();
//选中导出
if (thrOrderExportRequest.getErpOrderResponses() != null && thrOrderExportRequest.getErpOrderResponses().size() > 0) {
List<ThrOrderResponse> erpOrderResponses = thrOrderExportRequest.getErpOrderResponses();
postThrOrderRequest.setDatas(erpOrderResponses);
} else {//一键导出
List<ThrOrderResponse> erpOrderResponses = new ArrayList<>();
ThrSystemDetailEntity thrSystemDetailEntity = thrSystemDetailService.selectByKey("orderQueryUrl", thrOrderExportRequest.getThirdSysFk());
if (thrSystemDetailEntity == null || thrSystemDetailEntity.getValue() == null) {
thrOrderExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
thrOrderExportLogEntity.setRemark("往来单位接口地址未定义");
thrOrderExportLogService.updateThrOrderExportLog(thrOrderExportLogEntity);
return;
}
if (!thrSystemDetailEntity.getEnabled()) {
thrOrderExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
thrOrderExportLogEntity.setRemark("第三方接口往来单位服务接口未启用");
thrOrderExportLogService.updateThrOrderExportLog(thrOrderExportLogEntity);
return;
}
if (thrSystemDetailEntity.getFromType() == 0) {
FilterThrOrderRequest filterThrOrderRequest = new FilterThrOrderRequest();
BeanUtils.copyProperties(thrOrderExportRequest, filterThrOrderRequest);
List<ThrOrderResponse> datas = getThrOrders(filterThrOrderRequest);
erpOrderResponses.addAll(datas);
} else {
FilterThrOrderRequest filterThrOrderRequest = new FilterThrOrderRequest();
BeanUtils.copyProperties(thrOrderExportRequest, filterThrOrderRequest);
List<ThrOrderEntity> thrOrderEntities = thrOrderService.filterThrOrder(filterThrOrderRequest);
for (ThrOrderEntity thrOrderEntity : thrOrderEntities) {
ThrOrderResponse erpOrderResponse = new ThrOrderResponse();
BeanUtils.copyProperties(thrOrderEntity, erpOrderResponse);
FilterThrOrderDetailRequest filterThrOrderDetailRequest = new FilterThrOrderDetailRequest();
filterThrOrderDetailRequest.setOrderIdFk(thrOrderEntity.getId() + "");
List<ThrOrderDetailEntity> thrOrderDetailEntities = thrOrderDetailService.filterThrOrderDetailDetail(filterThrOrderDetailRequest);
if (thrOrderDetailEntities != null) {
List<ThrOrderResponse.SubErpOrder> subErpOrders = new ArrayList<>();
for (ThrOrderDetailEntity thrOrderDetailEntity : thrOrderDetailEntities) {
ThrOrderResponse.SubErpOrder subErpOrder = new ThrOrderResponse.SubErpOrder();
BeanUtils.copyProperties(thrOrderDetailEntity, subErpOrder);
subErpOrders.add(subErpOrder);
}
erpOrderResponse.setSubErpOrders(subErpOrders);
}
erpOrderResponses.add(erpOrderResponse);
}
}
postThrOrderRequest.setDatas(erpOrderResponses);
}
//toDo 上傳SMP
postThrOrderRequest.setGenKey(genKey);
postThrOrderRequest.setThirdSys(thrOrderExportRequest.getThirdSysFk());
// SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("smp_service_ip");
// if (systemParamConfigEntity != null) {
String response = httpOkClient.uCloudPost(getIpUrl() + "/udiwms/thrsys/postOrderDetail", postThrOrderRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
});
if (baseResponse.getCode() == 20000) {
thrOrderExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
} else {
thrOrderExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
}
// } else {
// thrOrderExportLogEntity.setRemark("SMP服务IP地址未定义");
// thrOrderExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
// }
thrOrderExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
thrOrderExportLogService.updateThrOrderExportLog(thrOrderExportLogEntity);
}
public int getOrders(int page, int limit, String orderUrl, String thirdSys, ThrOrderImportLogEntity
thrOrderImportLogEntity, String action, FilterThrOrderRequest filterThrOrderRequest) {
if (filterThrOrderRequest == null)
filterThrOrderRequest = new FilterThrOrderRequest();
filterThrOrderRequest.setPage(page);
filterThrOrderRequest.setLimit(limit);
filterThrOrderRequest.setBillAction(action);
FilterOrderRequest filterOrderRequest = new FilterOrderRequest();
BeanUtils.copyProperties(filterThrOrderRequest, filterOrderRequest);
BaseResponse<PageSimpleResponse<ThrOrderResponse>> responseBaseResponse = erpOrderClient.getThrOrderResponse(filterOrderRequest);
if (responseBaseResponse != null && responseBaseResponse.getCode() == 20000) {
List<ThrOrderResponse> erpOrderResponses = responseBaseResponse.getData().getList();
if (erpOrderResponses != null && erpOrderResponses.size() > 0) {
for (ThrOrderResponse erpOrderResponse : erpOrderResponses) {
ThrOrderEntity thrOrderEntity = new ThrOrderEntity();
BeanUtils.copyProperties(erpOrderResponse, thrOrderEntity);
thrOrderEntity.setThirdSysFk(thirdSys);
thrOrderEntity.setUpdateTime(new Date());
thrOrderService.insertThrOrder(thrOrderEntity);
// thrOrderEntity = thrOrderService.findByUnique(thrOrderEntity.getBillNo(), thrOrderEntity.getThirdSysFk());
List<ThrOrderImportDetailEntity> thrOrderDetailEntities = new ArrayList<>();
for (ThrOrderResponse.SubErpOrder subPurchase : erpOrderResponse.getSubErpOrders()) {
ThrOrderImportDetailEntity thrOrderDetailEntity = new ThrOrderImportDetailEntity();
BeanUtils.copyProperties(subPurchase, thrOrderDetailEntity);
BeanUtils.copyProperties(erpOrderResponse, thrOrderDetailEntity);
thrOrderDetailEntity.setGenKeyFk(thrOrderImportLogEntity.getGenKey());
thrOrderDetailEntity.setThirdSysFk(thirdSys);
thrOrderDetailEntity.setUpdateTime(new Date());
thrOrderDetailEntities.add(thrOrderDetailEntity);
}
thrOrderImportDetailService.insertOrderImportDetails(thrOrderDetailEntities);
}
page++;
if (page * limit < responseBaseResponse.getData().getTotal()) {
return page;
}
}
} else {
thrOrderImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
if (responseBaseResponse != null) {
thrOrderImportLogEntity.setRemark(responseBaseResponse.getMessage());
} else {
thrOrderImportLogEntity.setRemark("第三方服务出错!");
}
thrOrderImportLogService.updateImportLog(thrOrderImportLogEntity);
return -1;
}
return -1;
}
//
// public List<List<String>> exportThrOrders(FilterThrOrderRequest filterThrOrderRequest) {
// BussinessTypeFilterRequest bussinessTypeFilterRequest = new BussinessTypeFilterRequest();
// bussinessTypeFilterRequest.setEnabled(true);
// List<BussinessTypeEntity> bussinessTypeEntities = bussinessTypeService.filterList(bussinessTypeFilterRequest);
// BasicThirdSysDetailEntity basicThirdSysDetailEntity = basicThirdSysDetailService.selectByKey("orderQueryUrl", filterThrOrderRequest.getThirdSysFk());
// int page = 1;
// int limit = 100;
// List<ErpOrderResponse> erpOrderResponseList = new ArrayList<>();
// while (true) {
// List<ErpOrderResponse> datas = getThrOrders(page, limit, basicThirdSysDetailEntity.getValue(), filterThrOrderRequest);
// if (datas != null && datas.size() >= limit) {
// erpOrderResponseList.addAll(datas);
// page++;
//
// } else {
// if (datas != null) {
// erpOrderResponseList.addAll(datas);
// }
// break;
// }
// }
// List<List<String>> excelData = new ArrayList<>();
// for (ErpOrderResponse erpOrderResponse : erpOrderResponseList) {
// for (ErpOrderResponse.SubErpOrder subPurchase : erpOrderResponse.getSubErpOrders()) {
// List<String> rows = new ArrayList<>();
// rows.add(erpOrderResponse.getBillNo());
// rows.add(erpOrderResponse.getBilldate());
// BasicUnitMaintainEntity basicUnitMaintainEntity = basicUnitMaintainService.selectByThirdId(erpOrderResponse.getCorpId(), filterThrOrderRequest.getThirdSysFk());
//// if (basicUnitMaintainEntity != null)
//// rows.add(basicUnitMaintainEntity.getErpId());
//// else
// rows.add(erpOrderResponse.getCorpId());
//// rows.add(basicUnitMaintainEntity.getErpId());
//// rows.add(erpOrderResponse.getCorpId());
// rows.add(erpOrderResponse.getCorpName());
// rows.add(getName(bussinessTypeEntities, erpOrderResponse.getBillType()));
//// rows.add(erpOrderResponse.getBillType());
// rows.add(erpOrderResponse.getBillFlag());
// rows.add(subPurchase.getProductId());
// rows.add(subPurchase.getProductName());
// rows.add(subPurchase.getSpec());
// rows.add(subPurchase.getBatchNo());
// rows.add(subPurchase.getProductDate());
// rows.add(subPurchase.getExpireDate());
// rows.add(subPurchase.getCount() + "");
// rows.add(subPurchase.getReCount() + "");
// rows.add(erpOrderResponse.getOriginType());
// excelData.add(rows);
// }
// }
// return excelData;
// }
//
public List<ThrOrderResponse> getThrOrders(FilterThrOrderRequest filterThrOrderRequest) {
ThrSystemDetailEntity thrSystemDetailEntity = thrSystemDetailService.selectByKey("orderQueryUrl", filterThrOrderRequest.getThirdSysFk());
int page = 1;
int limit = 100;
List<ThrOrderResponse> erpOrderResponseList = new ArrayList<>();
while (true) {
List<ThrOrderResponse> datas = getThrOrders(page, limit, thrSystemDetailEntity.getValue(), filterThrOrderRequest);
if (datas != null && datas.size() >= limit) {
erpOrderResponseList.addAll(datas);
page++;
} else {
if (datas != null) {
erpOrderResponseList.addAll(datas);
}
break;
}
}
return erpOrderResponseList;
}
public List<ThrOrderResponse> getThrOrders(int page, int limit, String orderQueryUrl, FilterThrOrderRequest
filterThrOrderRequest) {
FilterOrderRequest filterOrderRequest = new FilterOrderRequest();
BeanUtils.copyProperties(filterThrOrderRequest, filterOrderRequest);
filterOrderRequest.setPage(page);
filterOrderRequest.setLimit(limit);
BaseResponse<PageSimpleResponse<ThrOrderResponse>> responseBaseResponse = erpOrderClient.getThrOrderResponse(filterOrderRequest);
if (responseBaseResponse != null && responseBaseResponse.getCode() == 20000) {
List<ThrOrderResponse> erpOrderResponses = responseBaseResponse.getData().getList();
if (erpOrderResponses != null && erpOrderResponses.size() > 0) {
return erpOrderResponses;
}
}
return null;
}
//
// public List<List<String>> genExcelData(FilterThrOrderRequest filterThrOrderRequest) {
//
// BussinessTypeFilterRequest bussinessTypeFilterRequest = new BussinessTypeFilterRequest();
// bussinessTypeFilterRequest.setEnabled(true);
// List<BussinessTypeEntity> bussinessTypeEntities = bussinessTypeService.filterList(bussinessTypeFilterRequest);
// List<List<String>> excelData = new ArrayList<>();
// List<ThrOrderEntity> thrOrderEntities = thrOrderService.filterThrOrder(filterThrOrderRequest);
// for (ThrOrderEntity thrOrderEntity : thrOrderEntities) {
// FilterThrOrderDetailRequest filterThrOrderDetailRequest = new FilterThrOrderDetailRequest();
// filterThrOrderDetailRequest.setOrderIdFk(thrOrderEntity.getId() + "");
// List<ThrOrderDetailEntity> thrOrderDetailEntities = thrOrderDetailService.filterThrOrderDetailDetail(filterThrOrderDetailRequest);
// if (thrOrderDetailEntities != null) {
// for (ThrOrderDetailEntity thrOrderDetailEntity : thrOrderDetailEntities) {
// List<String> rows = new ArrayList<>();
// rows.add(thrOrderEntity.getBillNo());
// rows.add(thrOrderEntity.getBilldate());
//
//// BasicUnitMaintainEntity basicUnitMaintainEntity = basicUnitMaintainService.selectByThirdId(thrOrderEntity.getCorpId(), filterThrOrderRequest.getThirdSysFk());
//// if (basicUnitMaintainEntity != null)
//// rows.add(basicUnitMaintainEntity.getErpId());
//// else
// rows.add(thrOrderEntity.getCorpId());
//
//// rows.add(thrOrderEntity.getCorpId());
// rows.add(thrOrderEntity.getCorpName());
// rows.add(getName(bussinessTypeEntities, thrOrderEntity.getBillType()));
// rows.add(thrOrderEntity.getBillFlag());
// rows.add(thrOrderDetailEntity.getProductId());
// rows.add(thrOrderDetailEntity.getProductName());
// rows.add(thrOrderDetailEntity.getSpec());
// rows.add(thrOrderDetailEntity.getBatchNo());
// rows.add(thrOrderDetailEntity.getProductDate());
// rows.add(thrOrderDetailEntity.getExpireDate());
// rows.add(thrOrderDetailEntity.getCount() + "");
// rows.add(thrOrderDetailEntity.getReCount() + "");
// rows.add(thrOrderEntity.getOriginType());
// excelData.add(rows);
// }
// }
//
// }
// return excelData;
// }
}

@ -0,0 +1,67 @@
package com.glxp.api.service.thrsys.impl;
import com.github.pagehelper.PageHelper;
import com.glxp.api.dao.thrsys.ThrOrderDetailDao;
import com.glxp.api.entity.thrsys.ThrOrderDetailEntity;
import com.glxp.api.req.thrsys.FilterThrOrderDetailRequest;
import com.glxp.api.service.thrsys.ThrOrderDetailService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
@Service
public class ThrOrderDetailServiceImpl implements ThrOrderDetailService {
@Resource
ThrOrderDetailDao thrOrderDetailDao;
@Override
public List<ThrOrderDetailEntity> filterThrOrderDetailDetail(FilterThrOrderDetailRequest filterThrOrderDetailRequest) {
if (filterThrOrderDetailRequest == null) {
return Collections.emptyList();
}
if (filterThrOrderDetailRequest.getPage() != null) {
int offset = (filterThrOrderDetailRequest.getPage() - 1) * filterThrOrderDetailRequest.getLimit();
PageHelper.offsetPage(offset, filterThrOrderDetailRequest.getLimit());
}
List<ThrOrderDetailEntity> data = thrOrderDetailDao.filterThrOrderDetailDetail(filterThrOrderDetailRequest);
return data;
}
@Override
public boolean insertThrOrderDetail(ThrOrderDetailEntity thrOrderDetailEntity) {
return thrOrderDetailDao.insertThrOrderDetail(thrOrderDetailEntity);
}
@Override
public boolean insertThrOrderDetails(List<ThrOrderDetailEntity> thrOrderDetailEntities) {
return thrOrderDetailDao.insertThrOrderDetails(thrOrderDetailEntities);
}
@Override
public boolean updateThrOrderDetail(ThrOrderDetailEntity thrOrderDetailEntity) {
return thrOrderDetailDao.updateThrOrderDetail(thrOrderDetailEntity);
}
@Override
public boolean deleteById(String id) {
return thrOrderDetailDao.deleteById(id);
}
@Override
public boolean deleteByOrderIdFk(String id) {
return thrOrderDetailDao.deleteByOrderIdFk(id);
}
@Override
public boolean deleteAll() {
return thrOrderDetailDao.deleteAll();
}
@Override
public boolean deleteByTime() {
return thrOrderDetailDao.deleteByTime();
}
}

@ -0,0 +1,63 @@
package com.glxp.api.service.thrsys.impl;
import com.github.pagehelper.PageHelper;
import com.glxp.api.dao.thrsys.ThrOrderExportLogDao;
import com.glxp.api.entity.thrsys.ThrOrderExportLogEntity;
import com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest;
import com.glxp.api.service.thrsys.ThrOrderExportLogService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
@Service
public class ThrOrderExportLogServiceImpl implements ThrOrderExportLogService {
@Resource
ThrOrderExportLogDao thrOrderExportLogDao;
@Override
public ThrOrderExportLogEntity selectByGenKey(String genKey) {
FilterThrCorpImportLogRequest filterUdiEpLogRequest = new FilterThrCorpImportLogRequest();
filterUdiEpLogRequest.setGenKey(genKey);
List<ThrOrderExportLogEntity> thrOrderExportLogEntities = thrOrderExportLogDao.filterThrOrderExportLog(filterUdiEpLogRequest);
if (thrOrderExportLogEntities != null) {
return thrOrderExportLogEntities.get(0);
}
return null;
}
@Override
public List<ThrOrderExportLogEntity> filterThrOrderExportLog(FilterThrCorpImportLogRequest filterThrCorpImportLogRequest) {
if (filterThrCorpImportLogRequest == null) {
return Collections.emptyList();
}
if (filterThrCorpImportLogRequest.getPage() != null) {
int offset = (filterThrCorpImportLogRequest.getPage() - 1) * filterThrCorpImportLogRequest.getLimit();
PageHelper.offsetPage(offset, filterThrCorpImportLogRequest.getLimit());
}
List<ThrOrderExportLogEntity> data = thrOrderExportLogDao.filterThrOrderExportLog(filterThrCorpImportLogRequest);
return data;
}
@Override
public boolean insertThrOrderExportLog(ThrOrderExportLogEntity thrOrderExportLogEntity) {
return thrOrderExportLogDao.insertThrOrderExportLog(thrOrderExportLogEntity);
}
@Override
public boolean updateThrOrderExportLog(ThrOrderExportLogEntity thrOrderExportLogEntity) {
return thrOrderExportLogDao.updateThrOrderExportLog(thrOrderExportLogEntity);
}
@Override
public boolean deleteById(String id) {
return thrOrderExportLogDao.deleteById(id);
}
@Override
public boolean deleteByTime() {
return thrOrderExportLogDao.deleteByTime();
}
}

@ -0,0 +1,62 @@
package com.glxp.api.service.thrsys.impl;
import com.github.pagehelper.PageHelper;
import com.glxp.api.dao.thrsys.ThrOrderImportDetailDao;
import com.glxp.api.entity.thrsys.ThrOrderImportDetailEntity;
import com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest;
import com.glxp.api.service.thrsys.ThrOrderImportDetailService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
@Service
public class ThrOrderImportDetailServiceImpl implements ThrOrderImportDetailService {
@Resource
ThrOrderImportDetailDao thrOrderImportDetailDao;
@Override
public List<ThrOrderImportDetailEntity> filterOrderImportDetail(FilterThrCorpImportLogRequest filterThrCorpImportLogRequest) {
if (filterThrCorpImportLogRequest == null) {
return Collections.emptyList();
}
if (filterThrCorpImportLogRequest.getPage() != null) {
int offset = (filterThrCorpImportLogRequest.getPage() - 1) * filterThrCorpImportLogRequest.getLimit();
PageHelper.offsetPage(offset, filterThrCorpImportLogRequest.getLimit());
}
List<ThrOrderImportDetailEntity> data = thrOrderImportDetailDao.filterOrderdDetailImport(filterThrCorpImportLogRequest);
return data;
}
@Override
public boolean insertOrderImportDetail(ThrOrderImportDetailEntity thrOrderImportDetailEntity) {
return thrOrderImportDetailDao.insertOrderdDetailImport(thrOrderImportDetailEntity);
}
@Override
public boolean updateOrderImportDetail(ThrOrderImportDetailEntity thrOrderImportDetailEntity) {
return thrOrderImportDetailDao.updateOrderdDetailImport(thrOrderImportDetailEntity);
}
@Override
public boolean insertOrderImportDetails(List<ThrOrderImportDetailEntity> thrOrderImportDetailEntities) {
return thrOrderImportDetailDao.insertOrderdDetailImports(thrOrderImportDetailEntities);
}
@Override
public boolean deleteById(String id) {
return thrOrderImportDetailDao.deleteById(id);
}
@Override
public boolean deleteByTime() {
return thrOrderImportDetailDao.deleteByTime();
}
@Override
public boolean deleteByGenkey(String genKey) {
return thrOrderImportDetailDao.deleteByGenkey(genKey);
}
}

@ -0,0 +1,128 @@
package com.glxp.api.service.thrsys.impl;
import com.github.pagehelper.PageHelper;
import com.glxp.api.constant.BasicProcessStatus;
import com.glxp.api.dao.thrsys.ThrOrderImportLogDao;
import com.glxp.api.entity.thrsys.ThrOrderDetailEntity;
import com.glxp.api.entity.thrsys.ThrOrderEntity;
import com.glxp.api.entity.thrsys.ThrOrderImportDetailEntity;
import com.glxp.api.entity.thrsys.ThrOrderImportLogEntity;
import com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest;
import com.glxp.api.service.thrsys.ThrOrderDetailService;
import com.glxp.api.service.thrsys.ThrOrderImportDetailService;
import com.glxp.api.service.thrsys.ThrOrderImportLogService;
import com.glxp.api.service.thrsys.ThrOrderService;
import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class ThrOrderImportLogServiceImpl implements ThrOrderImportLogService {
@Resource
ThrOrderImportLogDao thrOrderImportLogDao;
@Resource
ThrOrderImportLogService thrOrderImportLogService;
@Resource
ThrOrderImportDetailService thrOrderImportDetailService;
@Resource
ThrOrderService thrOrderService;
@Resource
ThrOrderDetailService thrOrderDetailService;
@Override
public ThrOrderImportLogEntity selectByGenKey(String genKey) {
FilterThrCorpImportLogRequest filterThrCorpImportLogRequest = new FilterThrCorpImportLogRequest();
filterThrCorpImportLogRequest.setGenKey(genKey);
List<ThrOrderImportLogEntity> data = thrOrderImportLogDao.filterThrOrderImportLog(filterThrCorpImportLogRequest);
if (data != null && data.size() > 0) {
return data.get(0);
}
return null;
}
@Override
public List<ThrOrderImportLogEntity> filterThrOrderImportLog(FilterThrCorpImportLogRequest filterThrCorpImportLogRequest) {
if (filterThrCorpImportLogRequest == null) {
return Collections.emptyList();
}
if (filterThrCorpImportLogRequest.getPage() != null) {
int offset = (filterThrCorpImportLogRequest.getPage() - 1) * filterThrCorpImportLogRequest.getLimit();
PageHelper.offsetPage(offset, filterThrCorpImportLogRequest.getLimit());
}
List<ThrOrderImportLogEntity> data = thrOrderImportLogDao.filterThrOrderImportLog(filterThrCorpImportLogRequest);
return data;
}
@Override
public boolean insertImportLog(ThrOrderImportLogEntity thrOrderImportLogEntity) {
return thrOrderImportLogDao.insertImportLog(thrOrderImportLogEntity);
}
@Override
public boolean updateImportLog(ThrOrderImportLogEntity thrOrderImportLogEntity) {
return thrOrderImportLogDao.updateImportLog(thrOrderImportLogEntity);
}
@Override
public boolean deleteById(String id) {
return thrOrderImportLogDao.deleteById(id);
}
@Override
public boolean deleteByTime() {
return thrOrderImportLogDao.deleteByTime();
}
@Async
public void importThrOrder(String genKey) {
ThrOrderImportLogEntity thrOrderImportLogEntity = thrOrderImportLogService.selectByGenKey(genKey);
if (thrOrderImportLogEntity.getStatus() == BasicProcessStatus.UDIINFO_IMPORT_UNPROCESS) {
FilterThrCorpImportLogRequest filterUdiIpLogRequest = new FilterThrCorpImportLogRequest();
filterUdiIpLogRequest.setGenKey(genKey);
List<ThrOrderImportDetailEntity> thrOrderImportDetailEntities = thrOrderImportDetailService.filterOrderImportDetail(filterUdiIpLogRequest);
if (thrOrderImportDetailEntities != null && thrOrderImportDetailEntities.size() > 0) {
Map<String, List<ThrOrderImportDetailEntity>> map = thrOrderImportDetailEntities.stream().collect(Collectors.groupingBy(ThrOrderImportDetailEntity::getBillNo));
for (List<ThrOrderImportDetailEntity> datas : map.values()) {
ThrOrderImportDetailEntity thrOrderImportDetailEntity = datas.get(0);
ThrOrderEntity thrOrderEntity = new ThrOrderEntity();
BeanUtils.copyProperties(thrOrderImportDetailEntity, thrOrderEntity);
thrOrderEntity.setUpdateTime(new Date());
// BussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findBTByName(thrOrderEntity.getBillType());
// if (bussinessTypeEntity != null) {
// thrOrderEntity.setBillType(bussinessTypeEntity.getAction());
// }
thrOrderService.insertThrOrder(thrOrderEntity);
thrOrderEntity = thrOrderService.findByUnique(thrOrderEntity.getBillNo(), thrOrderEntity.getThirdSysFk());
ThrOrderEntity finalThrOrderEntity = thrOrderEntity;
List<ThrOrderDetailEntity> postDatas = datas.stream().map(item ->
{
ThrOrderDetailEntity thrOrderDetailEntity = new ThrOrderDetailEntity();
thrOrderDetailEntity.setUpdateTime(new Date());
BeanUtils.copyProperties(item, thrOrderDetailEntity);
thrOrderDetailEntity.setOrderIdFk(finalThrOrderEntity.getId() + "");
return thrOrderDetailEntity;
}).collect(Collectors.toList());
thrOrderDetailService.insertThrOrderDetails(postDatas);
}
thrOrderImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
thrOrderImportLogService.updateImportLog(thrOrderImportLogEntity);
}
}
}
}

@ -0,0 +1,191 @@
package com.glxp.api.service.thrsys.impl;
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageHelper;
import com.glxp.api.dao.thrsys.ThrOrderDao;
import com.glxp.api.dao.thrsys.ThrOrderDetailDao;
import com.glxp.api.entity.thrsys.ThrOrderDetailEntity;
import com.glxp.api.entity.thrsys.ThrOrderEntity;
import com.glxp.api.req.thrsys.FilterThrOrderDetailRequest;
import com.glxp.api.req.thrsys.FilterThrOrderRequest;
import com.glxp.api.res.thrsys.ThrErpOrderResponse;
import com.glxp.api.res.thrsys.ThrOrderResponse;
import com.glxp.api.service.thrsys.ThrOrderService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@Service
public class ThrOrderServiceImpl implements ThrOrderService {
@Resource
private ThrOrderDao thrOrderDao;
@Resource
private ThrOrderDetailDao thrOrderDetailDao;
@Override
public List<ThrOrderEntity> filterThrOrder(FilterThrOrderRequest filterThrOrderRequest) {
if (filterThrOrderRequest == null) {
return Collections.emptyList();
}
if (filterThrOrderRequest.getPage() != null) {
int offset = (filterThrOrderRequest.getPage() - 1) * filterThrOrderRequest.getLimit();
PageHelper.offsetPage(offset, filterThrOrderRequest.getLimit());
}
List<ThrOrderEntity> data = thrOrderDao.filterThrOrder(filterThrOrderRequest);
return data;
}
@Override
public List<ThrOrderEntity> filterReceiveOrder(FilterThrOrderRequest filterThrOrderRequest) {
if (filterThrOrderRequest == null) {
return Collections.emptyList();
}
if (filterThrOrderRequest.getPage() != null) {
int offset = (filterThrOrderRequest.getPage() - 1) * filterThrOrderRequest.getLimit();
PageHelper.offsetPage(offset, filterThrOrderRequest.getLimit());
}
List<ThrOrderEntity> data = thrOrderDao.filterReceiveOrder(filterThrOrderRequest);
return data;
}
@Override
public List<ThrErpOrderResponse> filterAllOrders(List<String> billNos, String thirdSys) {
List<ThrErpOrderResponse> erpOrderEntities = new ArrayList<>();
for (String billNo : billNos) {
FilterThrOrderRequest filterThrOrderRequest = new FilterThrOrderRequest();
filterThrOrderRequest.setBillNo(billNo);
filterThrOrderRequest.setThirdSysFk(thirdSys);
List<ThrOrderEntity> data = thrOrderDao.filterThrOrder(filterThrOrderRequest);
if (data != null && data.size() > 0) {
for (ThrOrderEntity thrOrderEntity : data) {
FilterThrOrderDetailRequest filterThrOrderDetailRequest = new FilterThrOrderDetailRequest();
filterThrOrderDetailRequest.setOrderIdFk(thrOrderEntity.getId() + "");
List<ThrOrderDetailEntity> thrOrderDetailEntities = thrOrderDetailDao.filterThrOrderDetailDetail(filterThrOrderDetailRequest);
if (thrOrderDetailEntities != null && thrOrderDetailEntities.size() > 0) {
for (ThrOrderDetailEntity thrOrderDetailEntity : thrOrderDetailEntities) {
ThrErpOrderResponse thrErpOrderResponse = new ThrErpOrderResponse();
BeanUtils.copyProperties(thrOrderEntity, thrErpOrderResponse);
BeanUtils.copyProperties(thrOrderDetailEntity, thrErpOrderResponse);
thrErpOrderResponse.setCompanyid(thrOrderEntity.getCorpId());
thrErpOrderResponse.setCompanyname(thrOrderEntity.getCorpName());
thrErpOrderResponse.setErpOrderId(thrOrderEntity.getBillNo());
thrErpOrderResponse.setIodtlId(thrOrderEntity.getBillNo());
thrErpOrderResponse.setErpCount(Integer.valueOf(thrOrderDetailEntity.getCount()));
thrErpOrderResponse.setReCount(Integer.valueOf(thrOrderDetailEntity.getReCount()));
thrErpOrderResponse.setBatchNo(thrOrderDetailEntity.getBatchNo());
thrErpOrderResponse.setGoodsid(thrOrderDetailEntity.getProductId());
thrErpOrderResponse.setGoodsname(thrOrderDetailEntity.getProductName());
thrErpOrderResponse.setCredate(thrOrderDetailEntity.getProductDate());
thrErpOrderResponse.setExpireDate(thrOrderDetailEntity.getExpireDate());
thrErpOrderResponse.setPackSpec(thrOrderDetailEntity.getSpec());
erpOrderEntities.add(thrErpOrderResponse);
}
}
}
}
}
return erpOrderEntities;
}
@Override
public List<ThrOrderResponse> filterAllDetail(FilterThrOrderRequest filterThrOrderRequest) {
List<ThrOrderResponse> erpOrderResponses = new ArrayList<>();
List<ThrOrderEntity> data = filterThrOrder(filterThrOrderRequest);
if (data != null && data.size() > 0) {
for (ThrOrderEntity thrOrderEntity : data) {
FilterThrOrderDetailRequest filterThrOrderDetailRequest = new FilterThrOrderDetailRequest();
filterThrOrderDetailRequest.setOrderIdFk(thrOrderEntity.getId() + "");
List<ThrOrderDetailEntity> thrOrderDetailEntities = thrOrderDetailDao.filterThrOrderDetailDetail(filterThrOrderDetailRequest);
ThrOrderResponse erpOrderResponse = new ThrOrderResponse();
BeanUtils.copyProperties(thrOrderEntity, erpOrderResponse);
List<ThrOrderResponse.SubErpOrder> subErpOrders = new ArrayList<>();
if (thrOrderDetailEntities != null && thrOrderDetailEntities.size() > 0) {
for (ThrOrderDetailEntity thrOrderDetailEntity : thrOrderDetailEntities) {
ThrOrderResponse.SubErpOrder subErpOrder = new ThrOrderResponse.SubErpOrder();
BeanUtils.copyProperties(thrOrderDetailEntity, subErpOrder);
subErpOrders.add(subErpOrder);
}
}
erpOrderResponse.setSubErpOrders(subErpOrders);
erpOrderResponses.add(erpOrderResponse);
}
}
return erpOrderResponses;
}
@Override
public ThrOrderEntity findByUnique(String billNo, String thirdSysFk) {
if (StrUtil.isEmpty(billNo) || StrUtil.isEmpty(thirdSysFk)) {
return null;
}
FilterThrOrderRequest filterThrOrderRequest = new FilterThrOrderRequest();
filterThrOrderRequest.setBillNo(billNo);
filterThrOrderRequest.setThirdSysFk(thirdSysFk);
List<ThrOrderEntity> thrOrderEntities = filterThrOrder(filterThrOrderRequest);
if (thrOrderEntities != null && thrOrderEntities.size() > 0) {
return thrOrderEntities.get(0);
}
return null;
}
@Override
public ThrOrderEntity findReceiveOrder(String billNo) {
if (StrUtil.isEmpty(billNo)) {
return null;
}
FilterThrOrderRequest filterThrOrderRequest = new FilterThrOrderRequest();
filterThrOrderRequest.setBillNo(billNo);
filterThrOrderRequest.setType(1);
List<ThrOrderEntity> thrOrderEntities = filterThrOrder(filterThrOrderRequest);
if (thrOrderEntities != null && thrOrderEntities.size() > 0) {
return thrOrderEntities.get(0);
}
return null;
}
@Override
public ThrOrderEntity findById(String id) {
FilterThrOrderRequest filterThrOrderRequest = new FilterThrOrderRequest();
filterThrOrderRequest.setId(id);
List<ThrOrderEntity> thrOrderEntities = filterThrOrder(filterThrOrderRequest);
if (thrOrderEntities != null && thrOrderEntities.size() > 0) {
return thrOrderEntities.get(0);
}
return null;
}
@Override
public boolean insertThrOrder(ThrOrderEntity thrCorpEntity) {
return thrOrderDao.insertThrOrder(thrCorpEntity);
}
@Override
public boolean insertThrOrders(List<ThrOrderEntity> thrOrderEntities) {
return thrOrderDao.insertThrOrders(thrOrderEntities);
}
@Override
public boolean updateThrOrder(ThrOrderEntity thrOrderEntity) {
return thrOrderDao.updateThrOrder(thrOrderEntity);
}
@Override
public boolean deleteById(String id) {
return thrOrderDao.deleteById(id);
}
@Override
public boolean deleteAll() {
return thrOrderDao.deleteAll();
}
}

@ -0,0 +1,257 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.glxp.api.dao.thrsys.ThrOrderDao">
<select id="filterThrOrder" parameterType="com.glxp.api.req.thrsys.FilterThrOrderRequest"
resultType="com.glxp.api.entity.thrsys.ThrOrderEntity">
SELECT thr_order.*,basic_bustype_origin.name billTypeName FROM thr_order
left join basic_bustype_origin on thr_order.billType = basic_bustype_origin.action
<where>
<if test="billNo != '' and billNo != null">
AND billNo = #{billNo}
</if>
<if test="id != '' and id !=null">
AND thr_order.id = #{id}
</if>
<if test="billAction != '' and billAction !=null">
AND billType = #{billAction}
</if>
<if test="originType != '' and originType !=null">
AND originType = #{originType}
</if>
<if test="type !=null">
AND thr_order.`type` = #{type}
</if>
<if test="allocateStatus!= null">
AND allocateStatus = #{allocateStatus}
</if>
<if test="billFlag != '' and billFlag !=null">
AND billFlag = #{billFlag}
</if>
<if test="unitIdFk != '' and unitIdFk !=null">
AND unitIdFk = #{unitIdFk}
</if>
<if test="thirdSysFk != '' and thirdSysFk != null">
AND thirdSysFk = #{thirdSysFk}
</if>
<if test="corpName != '' and corpName != null">
AND corpName like concat('%',#{corpName},'%')
</if>
<if test="startDate!=null and startDate!=''">
<![CDATA[ and DATE_FORMAT(billdate, '%Y-%m-%d')>= DATE_FORMAT(#{startDate}, '%Y-%m-%d') ]]>
</if>
<if test="endDate!=null and endDate!=''">
<![CDATA[ and DATE_FORMAT(billdate, '%Y-%m-%d') <= DATE_FORMAT(#{endDate}, '%Y-%m-%d') ]]>
</if>
<if test="editStatus!= null">
AND editStatus = #{editStatus}
</if>
<if test="lastUpdateTime!=null and lastUpdateTime!=''">
<![CDATA[ and DATE_FORMAT(thr_order.updateTime, '%Y-%m-%d %H:%i:%S')>= DATE_FORMAT(#{lastUpdateTime}, '%Y-%m-%d %H:%i:%S') ]]>
</if>
</where>
ORDER BY thr_order.updateTime DESC
</select>
<select id="filterReceiveOrder" parameterType="com.glxp.api.req.thrsys.FilterThrOrderRequest"
resultType="com.glxp.api.entity.thrsys.ThrOrderEntity">
SELECT thr_order.*,basic_bustype_change.originName billTypeName,s1.name as invWarehouseName,s2.name as fromSubInvName FROM thr_order
left join basic_bustype_change on thr_order.billType = basic_bustype_change.originAction
LEFT JOIN inv_warehouse_sub s1 ON thr_order.invWarehouseCode=s1.`code`
LEFT JOIN inv_warehouse_sub s2 ON thr_order.fromSubInvCode=s2.`code`
<where>
<if test="billNo != '' and billNo != null">
AND billNo = #{billNo}
</if>
<if test="id != '' and id !=null">
AND thr_order.id = #{id}
</if>
<if test="billAction != '' and billAction !=null">
AND billType = #{billAction}
</if>
<if test="originType != '' and originType !=null">
AND originType = #{originType}
</if>
<if test="type !=null">
AND thr_order.`type` = #{type}
</if>
<if test="billFlag != '' and billFlag !=null">
AND billFlag = #{billFlag}
</if>
<if test="unitIdFk != '' and unitIdFk !=null">
AND unitIdFk = #{unitIdFk}
</if>
<if test="thirdSysFk != '' and thirdSysFk != null">
AND thirdSysFk = #{thirdSysFk}
</if>
<if test="corpName != '' and corpName != null">
AND corpName like concat('%',#{corpName},'%')
</if>
<if test="startDate!=null and startDate!=''">
<![CDATA[ and DATE_FORMAT(billdate, '%Y-%m-%d')>= DATE_FORMAT(#{startDate}, '%Y-%m-%d') ]]>
</if>
<if test="endDate!=null and endDate!=''">
<![CDATA[ and DATE_FORMAT(billdate, '%Y-%m-%d') <= DATE_FORMAT(#{endDate}, '%Y-%m-%d') ]]>
</if>
<if test="editStatus!= null">
AND editStatus = #{editStatus}
</if>
<if test="thirdPartyDate!= null">
AND thirdPartyDate = #{thirdPartyDate}
</if>
<if test="lastUpdateTime!=null and lastUpdateTime!=''">
<![CDATA[ and DATE_FORMAT(thr_order.updateTime, '%Y-%m-%d %H:%i:%S')>= DATE_FORMAT(#{lastUpdateTime}, '%Y-%m-%d %H:%i:%S') ]]>
</if>
<if test="allocateStatus!= null">
AND allocateStatus = #{allocateStatus}
</if>
</where>
ORDER BY thr_order.updateTime DESC
</select>
<insert id="insertThrOrder" keyProperty="id" parameterType="com.glxp.api.entity.thrsys.ThrOrderEntity">
replace
INTO thr_order
(id,billNo, billdate, corpId, corpName, billType, billFlag, thirdSysFk, updateTime, originType, unitIdFk,
startDate, endDate, createUser, reviewUser, address, linkMan, linkTel, remark, remark1, remark2,
remark3, locStorageCode,editStatus,invWarehouseCode,thirdPartyDate,fromSubInvCode,`type`,allocateStatus)
values (
#{id},
#{billNo},
#{billdate},
#{corpId},
#{corpName},
#{billType},
#{billFlag},
#{thirdSysFk},
#{updateTime},
#{originType},
#{unitIdFk},
#{startDate},
#{endDate},
#{createUser},
#{reviewUser},
#{address},
#{linkMan},
#{linkTel},
#{remark},
#{remark1},
#{remark2},
#{remark3},
#{locStorageCode},
#{editStatus},
#{invWarehouseCode},
#{thirdPartyDate},
#{fromSubInvCode},
#{type},
#{allocateStatus}
)
</insert>
<insert id="importThrOrder" keyProperty="id" parameterType="com.glxp.api.entity.thrsys.ThrOrderEntity">
replace
INTO thr_order
(id,billNo, billdate, corpId, corpName, billType, billFlag, thirdSysFk, updateTime, originType,
startDate, endDate, createUser, reviewUser, address, linkMan, linkTel, remark, remark1, remark2,
remark3,invWarehouseCode,fromSubInvCode,`type`,allocateStatus)
values (
#{id},
#{billNo},
#{billdate},
#{corpId},
#{corpName},
#{billType},
#{billFlag},
#{thirdSysFk},
#{updateTime},
#{originType},
#{startDate},
#{endDate},
#{createUser},
#{reviewUser},
#{address},
#{linkMan},
#{linkTel},
#{remark},
#{remark1},
#{remark2},
#{remark3},
#{invWarehouseCode},
#{fromSubInvCode},
#{type},
#{allocateStatus}
)
</insert>
<insert id="insertThrOrders" keyProperty="id" parameterType="java.util.List">
replace INTO thr_order
(billNo, billdate, corpId, corpName, billType, billFlag, thirdSysFk, updateTime, originType, unitIdFk,
startDate, endDate, createUser, reviewUser, address, linkMan, linkTel, remark, remark1, remark2,
remark3,locStorageCode,editStatus,invWarehouseCode,fromSubInvCode,`type`,allocateStatus)
values
<foreach collection="thrOrderEntities" item="item" index="index"
separator=",">
(#{item.billNo},
#{item.billdate},
#{item.corpId},
#{item.corpName},
#{item.billType},
#{item.billFlag},
#{item.thirdSysFk}, #{item.updateTime}, #{item.originType}, #{item.unitIdFk},
#{item.startDate}, #{item.endDate}, #{item.createUser}, #{item.reviewUser},
#{item.address}, #{item.linkMan}, #{item.linkTel}, #{item.remark}, #{item.remark1},
#{item.remark2},
#{item.remark3},#{item.locStorageCode},#{item.editStatus},#{item.invWarehouseCode},#{item.fromSubInvCode},#{item.type},#{item.allocateStatus}
)
</foreach>
</insert>
<delete id="deleteById" parameterType="Map">
DELETE
FROM thr_order
WHERE id = #{id}
</delete>
<delete id="deleteAll">
DELETE
FROM thr_order
</delete>
<update id="updateThrOrder" parameterType="com.glxp.api.entity.thrsys.ThrOrderEntity">
UPDATE thr_order
<trim prefix="set" suffixOverrides=",">
<if test="billNo != null">billNo=#{billNo},</if>
<if test="billdate != null">billdate=#{billdate},</if>
<if test="corpId != null">corpId=#{corpId},</if>
<if test="corpName != null">corpName=#{corpName},</if>
<if test="billType != null">billType=#{billType},</if>
<if test="billFlag != null">billFlag=#{billFlag},</if>
<if test="thirdSysFk != null">thirdSysFk=#{thirdSysFk},</if>
<if test="updateTime != null">updateTime=#{updateTime},</if>
<if test="originType != null">originType=#{originType},</if>
<if test="startDate != null">startDate=#{startDate},</if>
<if test="endDate != null">endDate=#{endDate},</if>
<if test="createUser != null">createUser=#{createUser},</if>
<if test="reviewUser != null">reviewUser=#{reviewUser},</if>
<if test="address != null">address=#{address},</if>
<if test="linkMan != null">linkMan=#{linkMan},</if>
<if test="linkTel != null">linkTel=#{linkTel},</if>
<if test="remark != null">remark=#{remark},</if>
<if test="remark1 != null">remark1=#{remark1},</if>
<if test="remark2 != null">remark2=#{remark2},</if>
<if test="remark3 != null">remark3=#{remark3},</if>
<if test="locStorageCode != null">locStorageCode=#{locStorageCode},</if>
<if test="editStatus != null">editStatus=#{editStatus},</if>
<if test="invWarehouseCode != null">invWarehouseCode=#{invWarehouseCode},</if>
<if test="fromSubInvCode != null">fromSubInvCode=#{fromSubInvCode},</if>
<if test="type != null">`type`=#{type},</if>
<if test="allocateStatus != null">`allocateStatus`=#{allocateStatus},</if>
</trim>
WHERE id = #{id}
</update>
</mapper>

@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.glxp.api.dao.thrsys.ThrOrderDetailDao">
<select id="filterThrOrderDetailDetail" parameterType="com.glxp.api.req.thrsys.FilterThrOrderDetailRequest"
resultType="com.glxp.api.entity.thrsys.ThrOrderDetailEntity">
SELECT * FROM thr_order_detail
<where>
<if test="orderIdFk != '' and orderIdFk != null">
AND orderIdFk = #{orderIdFk}
</if>
<if test="thirdSysFk != '' and thirdSysFk != null">
AND thirdSysFk = #{thirdSysFk}
</if>
</where>
</select>
<insert id="insertThrOrderDetail" keyProperty="id"
parameterType="com.glxp.api.entity.thrsys.ThrOrderDetailEntity">
replace
INTO thr_order_detail
(productId, productName, spec, batchNo, expireDate,
productDate, `count`, reCount, orderIdFk, thirdSysFk, updateTime, price, corpName,ylqxzcrbarmc,zczbhhzbapzbh,manufactory)
values (
#{productId},
#{productName},
#{spec},
#{batchNo},
#{expireDate},
#{productDate},
#{count},
#{reCount},
#{orderIdFk},
#{thirdSysFk},
#{updateTime},
#{price},
#{corpName},
#{ylqxzcrbarmc},
#{zczbhhzbapzbh},
#{manufactory}
)
</insert>
<insert id="importThrOrderDetail" keyProperty="id"
parameterType="com.glxp.api.entity.thrsys.ThrOrderDetailEntity">
replace
INTO thr_order_detail
(id,productId, productName, spec, batchNo, expireDate,
productDate, `count`, reCount, orderIdFk, thirdSysFk, updateTime, price, corpName,ylqxzcrbarmc,zczbhhzbapzbh,manufactory)
values (
#{id},
#{productId},
#{productName},
#{spec},
#{batchNo},
#{expireDate},
#{productDate},
#{count},
#{reCount},
#{orderIdFk},
#{thirdSysFk},
#{updateTime},
#{price},
#{corpName},
#{ylqxzcrbarmc},
#{zczbhhzbapzbh},
#{manufactory}
)
</insert>
<insert id="insertThrOrderDetails" keyProperty="id" parameterType="java.util.List" useGeneratedKeys="true">
replace INTO thr_order_detail
(productId, productName, spec, batchNo, expireDate,
productDate, `count`, reCount, orderIdFk, thirdSysFk, updateTime
, price, corpName,ylqxzcrbarmc,zczbhhzbapzbh,manufactory)
values
<foreach collection="thrOrderDetailEntities" item="item" index="index"
separator=",">
(#{item.productId}, #{item.productName}, #{item.spec}, #{item.batchNo}, #{item.expireDate},
#{item.productDate}, #{item.count}, #{item.reCount}, #{item.orderIdFk}, #{item.thirdSysFk},
#{item.updateTime},
#{item.price}, #{item.corpName}, #{item.ylqxzcrbarmc}, #{item.zczbhhzbapzbh}, #{item.manufactory})
</foreach>
</insert>
<delete id="deleteById" parameterType="Map">
DELETE
FROM thr_order_detail
WHERE id = #{id}
</delete>
<delete id="deleteByOrderIdFk" parameterType="Map">
DELETE
FROM thr_order_detail
WHERE orderIdFk = #{orderIdFk}
</delete>
<update id="updateThrOrderDetail" parameterType="com.glxp.api.entity.thrsys.ThrOrderDetailEntity">
UPDATE thr_order_detail
<trim prefix="set" suffixOverrides=",">
<if test="productId != null">productId=#{productId},</if>
<if test="productName != null">productName=#{productName},</if>
<if test="spec != null">spec=#{spec},</if>
<if test="batchNo != null">batchNo=#{batchNo},</if>
<if test="expireDate != null">expireDate=#{expireDate},</if>
<if test="productDate != null">productDate=#{productDate},</if>
<if test="count != null">count=#{count},</if>
<if test="reCount != null">reCount=#{reCount},</if>
<if test="orderIdFk != null">orderIdFk=#{orderIdFk},</if>
<if test="thirdSysFk != null">thirdSysFk=#{thirdSysFk},</if>
<if test="updateTime != null">updateTime=#{updateTime},</if>
<if test="price != null">price=#{price},</if>
<if test="corpName != null">corpName=#{corpName},
</if>
<if test="ylqxzcrbarmc != null">ylqxzcrbarmc=#{ylqxzcrbarmc},</if>
<if test="zczbhhzbapzbh != null">zczbhhzbapzbh=#{zczbhhzbapzbh},</if>
<if test="manufactory != null">manufactory=#{manufactory},</if>
</trim>
WHERE id = #{id}
</update>
<delete id="deleteAll">
DELETE
FROM thr_order_detail
</delete>
<delete id="deleteByTime">
Delete From thr_order_detail
where date(updateTime) &lt;= date(DATE_SUB(NOW(),INTERVAL 30 day))
</delete>
</mapper>

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.glxp.api.dao.thrsys.ThrOrderExportLogDao">
<select id="filterThrOrderExportLog" parameterType="com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest"
resultType="com.glxp.api.entity.thrsys.ThrOrderExportLogEntity">
SELECT * FROM thr_order_export_log
<where>
<if test="genKey != '' and genKey != null">
AND genKey = #{genKey}
</if>
<if test="status != '' and status != null">
AND status = #{status}
</if>
<if test="type != '' and type != null">
AND `type` = #{type}
</if>
</where>
ORDER BY updateTime DESC
</select>
<insert id="insertThrOrderExportLog" keyProperty="id"
parameterType="com.glxp.api.entity.thrsys.ThrOrderExportLogEntity">
insert INTO thr_order_export_log
(genKey,updateTime,dlCount,status,filePath,remark,`type`)
values
(
#{genKey},
#{updateTime},
#{dlCount},#{status},#{filePath},#{remark},#{type}
)
</insert>
<delete id="deleteById" parameterType="Map">
DELETE FROM thr_order_export_log WHERE id = #{id}
</delete>
<update id="updateThrOrderExportLog" parameterType="com.glxp.api.entity.thrsys.ThrOrderExportLogEntity">
UPDATE thr_order_export_log
<set>
<if test="updateTime != null">updateTime=#{updateTime},</if>
<if test="dlCount != null">dlCount=#{dlCount},</if>
<if test="status != null">status=#{status},</if>
<if test="filePath != null">filePath=#{filePath},</if>
<if test="remark != null">remark=#{remark},</if>
</set>
WHERE genKey = #{genKey}
</update>
<delete id="deleteByTime">
Delete From thr_order_export_log
where date(updateTime) &lt;= date(DATE_SUB(NOW(),INTERVAL 30 day))
</delete>
</mapper>

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.glxp.api.dao.thrsys.ThrOrderImportDetailDao">
<select id="filterOrderdDetailImport" parameterType="com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest"
resultType="com.glxp.api.entity.thrsys.ThrOrderImportDetailEntity">
SELECT * FROM thr_order_import_detail
<where>
<if test="genKey != '' and genKey != null">
AND genKeyFk = #{genKey}
</if>
<if test="id != '' and id != null">
AND id = #{id}
</if>
<if test="status != '' and status != null">
AND status = #{status}
</if>
<if test="thirdSysFk != '' and thirdSysFk != null">
AND thirdSysFk = #{thirdSysFk}
</if>
</where>
</select>
<insert id="insertOrderdDetailImport" keyProperty="id"
parameterType="com.glxp.api.entity.thrsys.ThrOrderImportDetailEntity">
insert INTO thr_order_import_detail
(
billNo,billdate,corpId,corpName,billType,billFlag,productId,productName,spec,batchNo,expireDate,
productDate,count,reCount,status,updateTime,remark,genKeyFk,thirdSysFk,originType
)
values
(
#{billNo},#{billdate},#{corpId},#{corpName},#{billType},#{billFlag},#{productId},#{productName},#{spec},
#{batchNo},#{expireDate},#{productDate},#{count},#{reCount},#{status},#{updateTime},#{remark},#{genKeyFk},#{thirdSysFk},#{originType}
)
</insert>
<insert id="insertOrderdDetailImports" keyProperty="id" parameterType="java.util.List">
insert INTO thr_order_import_detail
(
billNo,billdate,corpId,corpName,billType,billFlag,productId,productName,spec,
batchNo,expireDate,productDate,count,reCount,status,updateTime,remark,genKeyFk,thirdSysFk,originType
)
values
<foreach collection="orders" item="item" index="index"
separator=",">
(
#{item.billNo},#{item.billdate},#{item.corpId},#{item.corpName},#{item.billType},
#{item.billFlag},#{item.productId},#{item.productName},#{item.spec},#{item.batchNo},#{item.expireDate},#{item.productDate},
#{item.count},#{item.reCount},#{item.status},#{item.updateTime},#{item.remark},#{item.genKeyFk},#{item.thirdSysFk},#{item.originType}
)
</foreach>
</insert>
<delete id="deleteById" parameterType="Map">
DELETE FROM thr_order_import_detail WHERE id = #{id}
</delete>
<delete id="deleteByGenkey" parameterType="Map">
DELETE FROM thr_order_import_detail WHERE genKeyFk = #{genKey}
</delete>
<update id="updateOrderdDetailImport" parameterType="com.glxp.api.entity.thrsys.ThrOrderImportDetailEntity">
UPDATE thr_order_import_detail
<trim prefix="set" suffixOverrides=",">
<if test="billNo != null">billNo=#{billNo},</if>
<if test="billdate != null">billdate=#{billdate},</if>
<if test="corpId != null">corpId=#{corpId},</if>
<if test="corpName != null">corpName=#{corpName},</if>
<if test="billType != null">billType=#{billType},</if>
<if test="billFlag != null">billFlag=#{billFlag},</if>
<if test="productId != null">productId=#{productId},</if>
<if test="productName != null">productName=#{productName},</if>
<if test="spec != null">spec=#{spec},</if>
<if test="expireDate != null">expireDate=#{expireDate},</if>
<if test="batchNo != null">batchNo=#{batchNo},</if>
<if test="productDate != null">productDate=#{productDate},</if>
<if test="count != null">count=#{count},</if>
<if test="reCount != null">reCount=#{reCount},</if>
<if test="status != null">status=#{status},</if>
<if test="updateTime != null">updateTime=#{updateTime},</if>
<if test="genKeyFk != null">genKeyFk=#{genKeyFk},</if>
<if test="remark != null">remark=#{remark},</if>
<if test="thirdSysFk != null">thirdSysFk=#{thirdSysFk},</if>
<if test="originType != null">originType=#{originType},</if>
</trim>
WHERE id = #{id}
</update>
<delete id="deleteByTime">
Delete From thr_order_import_detail
where date(updateTime) &lt;= date(DATE_SUB(NOW(),INTERVAL 30 day))
</delete>
</mapper>

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.glxp.api.dao.thrsys.ThrOrderImportLogDao">
<select id="filterThrOrderImportLog" parameterType="com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest"
resultType="com.glxp.api.entity.thrsys.ThrOrderImportLogEntity">
SELECT * FROM thr_order_import_log
<where>
<if test="genKey != '' and genKey != null">
AND genKey = #{genKey}
</if>
<if test="id != '' and id != null">
AND id = #{id}
</if>
<if test="status != '' and status != null">
AND status = #{status}
</if>
<if test="thirdSysFk != '' and thirdSysFk != null">
AND thirdSysFk = #{thirdSysFk}
</if>
</where>
ORDER BY updateTime DESC
</select>
<insert id="insertImportLog" keyProperty="id" parameterType="com.glxp.api.entity.thrsys.ThrOrderImportLogEntity">
insert INTO thr_order_import_log
(genKey,fromType,updateTime,thirdSysFk,status)
values
(
#{genKey},
#{fromType},
#{updateTime},
#{thirdSysFk},#{status}
)
</insert>
<delete id="deleteById" parameterType="Map">
DELETE FROM thr_order_import_log WHERE id = #{id}
</delete>
<update id="updateImportLog" parameterType="com.glxp.api.entity.thrsys.ThrOrderImportLogEntity">
UPDATE thr_order_import_log
<set>
<if test="genKey != null">genKey=#{genKey},</if>
<if test="fromType != null">fromType=#{fromType},</if>
<if test="updateTime != null">updateTime=#{updateTime},</if>
<if test="thirdSysFk != null">thirdSysFk=#{thirdSysFk},</if>
<if test="status != null">status=#{status},</if>
<if test="remark != null">remark=#{remark},</if>
</set>
WHERE genKey = #{genKey}
</update>
<delete id="deleteByTime">
Delete From thr_order_import_log
where date(updateTime) &lt;= date(DATE_SUB(NOW(),INTERVAL 30 day))
</delete>
</mapper>
Loading…
Cancel
Save