出入库替换成mongodb,beta

udims_mango
anthonywj 4 years ago
parent 03fceaf8d9
commit a202be5419

@ -150,6 +150,15 @@
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>com.github.Ryan-Miao</groupId>-->
<!--<artifactId>mongo-page-helper</artifactId>-->
<!--<version>1.0</version>-->
<!--</dependency>-->
</dependencies>

@ -0,0 +1,18 @@
package com.glxp.udi.admin.config;
import com.glxp.udi.admin.mongo.utils.MongoPageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.core.MongoTemplate;
@Configuration
public class MongoConfiguration {
@Autowired
private MongoTemplate mongoTemplate;
@Bean
public MongoPageHelper mongoPageHelper() {
return new MongoPageHelper(mongoTemplate);
}
}

@ -5,15 +5,15 @@ import com.glxp.udi.admin.constant.TypeConstant;
import com.glxp.udi.admin.entity.info.SetupEntity;
import com.glxp.udi.admin.entity.inout.*;
import com.glxp.udi.admin.entity.udid.UdiEntity;
import com.glxp.udi.admin.mongo.service.OrderDetailMdService;
import com.glxp.udi.admin.mongo.service.WarehouseMdService;
import com.glxp.udi.admin.req.inout.FilterWarehouseRequest;
import com.glxp.udi.admin.service.info.SetupService;
import com.glxp.udi.admin.service.inout.MyErpOrderService;
import com.glxp.udi.admin.service.inout.UdiInfoService;
import com.glxp.udi.admin.service.inout.UdiRelevanceService;
import com.glxp.udi.admin.service.inout.WarehouseService;
import com.glxp.udi.admin.service.receipts.ProductInfoService;
import com.glxp.udi.admin.util.FilterUdiUtils;
import com.glxp.udi.admin.util.WarehousBeanUtils;
import org.springframework.beans.BeanUtils;
import java.util.ArrayList;
import java.util.HashMap;
@ -31,13 +31,15 @@ public class InoutUtils {
this.udiUrl = udiUrl;
}
public String filterCode(WarehouseService warehouseService, Warehousetemp warehousetemp, SetupService setupService) {
public String filterCode(WarehouseMdService warehouseService, WarehousetempEntity warehousetemp, SetupService setupService) {
SetupEntity setupEntity = setupService.selectSetup();
FilterWarehouseRequest filterWarehouseRequest = new FilterWarehouseRequest();
filterWarehouseRequest.setCode(warehousetemp.getCode());
filterWarehouseRequest.setCustomerId(warehousetemp.getCustomerId());
List<WarehouseEntity> warehouseEntityList = warehouseService.findByCode(filterWarehouseRequest);
WarehouseEntity warehouseData = new WarehousBeanUtils().tempToEntity(warehousetemp);
WarehouseEntity warehouseData = new WarehouseEntity();
BeanUtils.copyProperties(warehousetemp,warehouseData);
if (warehouseEntityList == null || warehouseEntityList.size() == 0) { //数据库为null,可以添加
return nullVail(warehousetemp, setupEntity);
}
@ -104,7 +106,7 @@ public class InoutUtils {
return null;
}
public String nullVail(Warehousetemp warehousetemp, SetupEntity setupEntity) {
public String nullVail(WarehousetempEntity warehousetemp, SetupEntity setupEntity) {
if (warehousetemp.getAction().equals(TypeConstant.TYPE_PUT_RETURN)) {
if (setupEntity.isReturnWareHouseIn()) {
return null;
@ -247,7 +249,7 @@ public class InoutUtils {
}
public void generateConstrastDetail(UdiInfoService udiInfoService, UdiRelevanceService udiRelevanceService,
MyErpOrderService myErpOrderService,
OrderDetailMdService orderDetailMdService,
List<WarehouseEntity> warehouseEntityList) {
if (warehouseEntityList != null && warehouseEntityList.size() > 0) {
List<UdiInfoEntity> udiInfoEntities = new ArrayList<>();
@ -293,8 +295,9 @@ public class InoutUtils {
erpOrderEntity.setPackSpec(erpDetailCodeEntity.getGgxh());
erpOrderEntities.add(erpOrderEntity);
}
if (!erpOrderEntities.isEmpty())
myErpOrderService.insertErpOrders(erpOrderEntities);
if (!erpOrderEntities.isEmpty()){
orderDetailMdService.insertOrderDetail(erpOrderEntities);
}
}
}

@ -2,6 +2,7 @@ package com.glxp.udi.admin.controller.inout;
import com.github.pagehelper.PageInfo;
import com.glxp.udi.admin.entity.inout.ErpOrderEntity;
import com.glxp.udi.admin.mongo.service.OrderDetailMdService;
import com.glxp.udi.admin.req.inout.DeleteRequest;
import com.glxp.udi.admin.req.inout.FilterErpOrderRequest;
import com.glxp.udi.admin.res.PageSimpleResponse;
@ -25,6 +26,28 @@ public class MyErpOrderController {
private String ucloudUrl;
@Resource
MyErpOrderService myErpOrderService;
@Resource
private OrderDetailMdService orderDetailMdService;
@GetMapping(value = "/warehouse/inout/order/detail")
public BaseResponse orderDetail(FilterErpOrderRequest filterErpOrderRequest,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
if (filterErpOrderRequest.getOrderId() == null || filterErpOrderRequest.getOrderId().equals("")) {
filterErpOrderRequest.setOrderId("1");
}
filterErpOrderRequest.setPage(1);
filterErpOrderRequest.setLimit(100);
List<ErpOrderEntity> erpOrderEntities = orderDetailMdService.filterOrderDetails(filterErpOrderRequest);
return ResultVOUtils.success(erpOrderEntities);
}
/**
* ------------------------------------------------(
**/
@GetMapping("/warehouse/getMyErpOrders")
public BaseResponse getMyErpOrders(FilterErpOrderRequest filterErpOrderRequest,
@ -60,20 +83,5 @@ public class MyErpOrderController {
}
}
@GetMapping(value = "/warehouse/inout/order/detail")
public BaseResponse orderDetail(FilterErpOrderRequest filterErpOrderRequest,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
if (filterErpOrderRequest.getOrderId() == null || filterErpOrderRequest.getOrderId().equals("")) {
filterErpOrderRequest.setOrderId("1");
}
filterErpOrderRequest.setPage(1);
filterErpOrderRequest.setLimit(100);
List<ErpOrderEntity> erpOrderEntities = myErpOrderService.filterMyErpOrder(filterErpOrderRequest);
return ResultVOUtils.success(erpOrderEntities);
}
}

@ -3,11 +3,15 @@ package com.glxp.udi.admin.controller.inout;
import com.github.pagehelper.PageInfo;
import com.glxp.udi.admin.annotation.AuthRuleAnnotation;
import com.glxp.udi.admin.entity.auth.AuthAdmin;
import com.glxp.udi.admin.entity.info.SetupEntity;
import com.glxp.udi.admin.entity.inout.ErpOrderEntity;
import com.glxp.udi.admin.entity.inout.OrderEntity;
import com.glxp.udi.admin.entity.inout.OrderMdEntity;
import com.glxp.udi.admin.entity.inout.WarehouseEntity;
import com.glxp.udi.admin.exception.JsonException;
import com.glxp.udi.admin.mongo.service.OrderDetailMdService;
import com.glxp.udi.admin.mongo.service.OrderMdService;
import com.glxp.udi.admin.mongo.service.WarehouseMdService;
import com.glxp.udi.admin.mongo.utils.PageResult;
import com.glxp.udi.admin.req.inout.*;
import com.glxp.udi.admin.res.PageSimpleResponse;
import com.glxp.udi.admin.service.auth.AuthAdminService;
@ -53,6 +57,12 @@ public class OrderController {
private SetupService setupService;
@Resource
AuthAdminService authAdminService;
@Resource
private OrderDetailMdService orderDetailMdService;
@Resource
private OrderMdService orderMdService;
@Resource
private WarehouseMdService warehouseMdService;
@AuthRuleAnnotation("")
@GetMapping("/warehouse/inout/order/filter")
@ -70,22 +80,21 @@ public class OrderController {
AuthAdmin authAdmin = new GetAuthAdminUtil(authAdminService).getAuthAdmin(attributes);
orderFilterRequest.setCustomerId(authAdmin.getCustomerId());
orderFilterRequest.setStatus("success");
List<OrderEntity> orderEntityList;
if (orderFilterRequest.getCode() != null && !orderFilterRequest.getCode().equals("")) {
FilterWarehouseRequest filterWarehouseRequest = new FilterWarehouseRequest();
filterWarehouseRequest.setCustomerId(authAdmin.getCustomerId());
filterWarehouseRequest.setCode(orderFilterRequest.getCode());
List<WarehouseEntity> warehouseEntityList = warehouseService.findByCode(filterWarehouseRequest);
orderEntityList = orderService.filterListByCode(warehouseEntityList);
} else {
orderEntityList = orderService.filterList(orderFilterRequest);
}
// if (orderFilterRequest.getCode() != null && !orderFilterRequest.getCode().equals("")) {
// FilterWarehouseRequest filterWarehouseRequest = new FilterWarehouseRequest();
// filterWarehouseRequest.setCustomerId(authAdmin.getCustomerId());
// filterWarehouseRequest.setCode(orderFilterRequest.getCode());
// List<WarehouseEntity> warehouseEntityList = warehouseService.findByCode(filterWarehouseRequest);
// orderEntityList = orderService.filterListByCode(warehouseEntityList);
// } else {
//
// }
PageInfo<OrderEntity> pageInfo;
pageInfo = new PageInfo<>(orderEntityList);
PageSimpleResponse<OrderEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(orderEntityList);
PageResult<OrderMdEntity> pageResult =
orderMdService.filterList(orderFilterRequest);
PageSimpleResponse<OrderMdEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageResult.getTotal());
pageSimpleResponse.setList(pageResult.getList());
return ResultVOUtils.success(pageSimpleResponse);
}
@ -116,6 +125,81 @@ public class OrderController {
return ResultVOUtils.success(pageSimpleResponse);
}
@PostMapping("warehouse/inout/order/deleteOrder")
public BaseResponse deleteOrder(@RequestBody DeleteRequest deleteRequest, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
orderMdService.deleteOrder(deleteRequest);
orderDetailMdService.deleteOrderDetail(deleteRequest);
warehouseMdService.deleteCode(deleteRequest);
return ResultVOUtils.success("删除成功");
}
@AuthRuleAnnotation("")
@GetMapping("admin/warehouse/inout/order/listerror")
public BaseResponse listOrderError(OrderFilterRequest orderFilterRequest) {
orderFilterRequest.setIsError("success");
PageResult<OrderMdEntity> pageResult =
orderMdService.filterList(orderFilterRequest);
PageSimpleResponse<OrderMdEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageResult.getTotal());
pageSimpleResponse.setList(pageResult.getList());
return ResultVOUtils.success(pageSimpleResponse);
}
@AuthRuleAnnotation("")
@PostMapping("/warehouse/inout/order/mergeOrder")
public BaseResponse mergeOrder(@RequestBody OrderMergeRequest orderMergeRequest, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
List<String> orderList = orderMergeRequest.getOrderList();
if (orderList != null && orderList.size() > 1) {
for (String orderId : orderList) {
DeleteRequest deleteRequest = new DeleteRequest();
deleteRequest.setOrderId(orderId);
orderDetailMdService.deleteOrderDetail(deleteRequest);
}
String mainOrder = orderList.get(0);
for (int i = 1; i < orderList.size(); i++) {
warehouseMdService.updateOrderId(orderList.get(i), mainOrder);
DeleteRequest deleteRequest = new DeleteRequest();
deleteRequest.setOrderId(orderList.get(i));
orderMdService.deleteOrder(deleteRequest);
}
new Thread(() -> {
WarehouseQueryRequest warehouseQueryRequest = new WarehouseQueryRequest();
warehouseQueryRequest.setOrderId(mainOrder);
List<WarehouseEntity> transData = warehouseMdService.filterWarehouse(warehouseQueryRequest);
new InoutUtils().generateConstrastDetail(udiInfoService, udiRelevanceService, orderDetailMdService, transData);
}).start();
}
return ResultVOUtils.success("合并成功,后台正在数据转换,请稍后刷新重试!");
}
@PostMapping("/warehouse/inout/order/unit")
public BaseResponse updateUnit(@RequestBody @Valid OrderMdEntity orderEntity,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
orderMdService.updateOrder(orderEntity);
warehouseMdService.updateUnit(orderEntity.getOrderId(), orderEntity.getFromCorpId(), orderEntity.getFromCorp());
return ResultVOUtils.success("添加成功");
}
/**
* ---------------------------------------------
*/
@ -134,17 +218,6 @@ public class OrderController {
return ResultVOUtils.success(pageSimpleResponse);
}
@AuthRuleAnnotation("")
@GetMapping("admin/warehouse/inout/order/listerror")
public BaseResponse listOrderError(OrderQueryRequest orderQueryRequest) {
List<OrderEntity> orderEntityList = orderService.listOrderError(orderQueryRequest);
PageInfo<OrderEntity> pageInfo;
pageInfo = new PageInfo<>(orderEntityList);
PageSimpleResponse<OrderEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(orderEntityList);
return ResultVOUtils.success(pageSimpleResponse);
}
@AuthRuleAnnotation("")
@GetMapping("admin/warehouse/inout/order/listRepeat")
@ -176,89 +249,6 @@ public class OrderController {
return ResultVOUtils.success("添加成功");
}
@AuthRuleAnnotation("")
@PostMapping("/warehouse/inout/order/mergeOrder")
public BaseResponse mergeOrder(@RequestBody OrderMergeRequest orderMergeRequest, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
List<String> orderList = orderMergeRequest.getOrderList();
SetupEntity setupEntity = setupService.selectSetup();
if (!setupEntity.isForbidSameErp()) {
List<ErpOrderEntity> mergeList = new ArrayList<>();
if (orderList != null && orderList.size() > 1) {
for (String orderId : orderList) {
FilterErpOrderRequest filterErpOrderRequest = new FilterErpOrderRequest();
filterErpOrderRequest.setOrderId(orderId);
List<ErpOrderEntity> erpOrderEntities = myErpOrderService.filterAllMyErpOrder(filterErpOrderRequest);
if (erpOrderEntities != null && erpOrderEntities.size() > 0) {
mergeList.addAll(erpOrderEntities);
}
myErpOrderService.deleteByOrderId(orderId);
}
String mainOrder = orderList.get(0);
for (int i = 1; i < orderList.size(); i++) {
warehouseService.updateOrderId(orderList.get(i), mainOrder);
orderService.deleteByOrderId(orderList.get(i));
}
OrderEntity mainOrderEntity = orderService.findById(mainOrder);
List<String> docids = getDocids(mergeList);
String docidStr = "";
if (docids != null && docids.size() > 0) {
for (String temp : docids) {
docidStr = docidStr + "," + temp;
}
docidStr = docidStr.substring(1);
}
mainOrderEntity.setErpFk(docidStr);
orderService.updateOrder(mainOrderEntity);
// List<ErpOrderEntity> erpOrderEntities = new UCloudHttpClient(ucloudUrl).getErpOrders(docids, mainOrderEntity.getAction());
// if (erpOrderEntities != null && erpOrderEntities.size() > 0) {
// List<ErpOrderEntity> returnOrders = new ContrastErpUtil().transErp(erpOrderEntities, udiRelevanceService, mainOrder);
// myErpOrderService.insertErpOrders(returnOrders);
// List<WarehouseEntity> warehouseEntityList = warehouseService.findByReceiptId(mainOrder);
// new ContrastErpUtil().contrastErp(udiInfoService, udiRelevanceService, myErpOrderService, orderService, warehouseEntityList,setupService);
// } else {
// orderService.updateContrastStatus(mainOrder, "error");
// orderService.updateRemark(mainOrder, "U8Cloud获取ERP单失败");
// return ResultVOUtils.error(500, "U8Cloud获取ERP单失败");
// }
} else {
return ResultVOUtils.error(ResultEnum.DATA_ERROR);
}
} else {
if (orderList != null && orderList.size() > 1) {
for (String orderId : orderList) {
FilterErpOrderRequest filterErpOrderRequest = new FilterErpOrderRequest();
filterErpOrderRequest.setOrderId(orderId);
List<ErpOrderEntity> erpOrderEntities = myErpOrderService.filterAllMyErpOrder(filterErpOrderRequest);
if (erpOrderEntities != null && erpOrderEntities.size() > 0) {
for (ErpOrderEntity erpOrderEntity : erpOrderEntities) {
if (erpOrderEntity.getDocid() != null) {
return ResultVOUtils.error(500, "已校验过订单不能合并!");
}
}
}
myErpOrderService.deleteByOrderId(orderId);
}
String mainOrder = orderList.get(0);
for (int i = 1; i < orderList.size(); i++) {
warehouseService.updateOrderId(orderList.get(i), mainOrder);
orderService.deleteByOrderId(orderList.get(i));
}
new Thread(() -> {
List<WarehouseEntity> datas = warehouseService.findByReceiptId(mainOrder);
new InoutUtils().generateConstrastDetail(udiInfoService, udiRelevanceService, myErpOrderService, datas);
}).start();
}
}
return ResultVOUtils.success("合并成功,后台正在数据转换,请稍后刷新重试!");
}
public List<String> getDocids(List<ErpOrderEntity> mergeList) {
List<String> docids = new ArrayList<>();
@ -274,39 +264,6 @@ public class OrderController {
return false;
}
@PostMapping("warehouse/inout/order/deleteOrder")
public BaseResponse deleteOrder(@RequestBody DeleteRequest deleteRequest, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
String id = deleteRequest.getId();
orderService.deleteById(id);
myErpOrderService.deleteByOrderId(id);
return ResultVOUtils.success("删除成功");
}
@PostMapping("/warehouse/inout/order/unit")
public BaseResponse updateUnit(@RequestBody @Valid OrderEntity orderEntity,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
boolean b = orderService.updateUnit(orderEntity);
if (!b) {
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
}
b = warehouseService.updateUnit(orderEntity.getId(), orderEntity.getFromCorpId(), orderEntity.getFromCorp());
if (!b) {
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
}
return ResultVOUtils.success("添加成功");
}
@PostMapping("/warehouse/inout/order/updateExportStatus")
public BaseResponse updateExportStatus(@RequestBody UpdateExportStatusRequest updateExportStatusRequest,

@ -3,19 +3,19 @@ package com.glxp.udi.admin.controller.inout;
import com.github.pagehelper.PageInfo;
import com.glxp.udi.admin.annotation.AuthRuleAnnotation;
import com.glxp.udi.admin.entity.auth.AuthAdmin;
import com.glxp.udi.admin.entity.inout.ErpOrderEntity;
import com.glxp.udi.admin.entity.inout.WarehouseEntity;
import com.glxp.udi.admin.entity.inout.Warehousetemp;
import com.glxp.udi.admin.entity.inout.WarehousetempEntity;
import com.glxp.udi.admin.exception.JsonException;
import com.glxp.udi.admin.mongo.service.WarehouseMdService;
import com.glxp.udi.admin.mongo.service.WarehouseTempMdService;
import com.glxp.udi.admin.mongo.utils.PageResult;
import com.glxp.udi.admin.req.inout.*;
import com.glxp.udi.admin.res.PageSimpleResponse;
import com.glxp.udi.admin.res.inout.WarehouseResponse;
import com.glxp.udi.admin.service.auth.AuthAdminService;
import com.glxp.udi.admin.service.info.SetupService;
import com.glxp.udi.admin.service.inout.*;
import com.glxp.udi.admin.service.inout.WarehouseService;
import com.glxp.udi.admin.thread.TransInoutService;
import com.glxp.udi.admin.util.GetAuthAdminUtil;
import com.glxp.udi.admin.util.WarehousBeanUtils;
import com.glxp.udi.common.enums.ResultEnum;
import com.glxp.udi.common.res.BaseResponse;
import com.glxp.udi.common.util.ResultVOUtils;
@ -30,7 +30,6 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@ -39,17 +38,12 @@ public class WareHouseController {
@Resource
private WarehouseService warehouseService;
@Resource
private OrderService orderService;
private WarehouseMdService warehouseMdService;
@Resource
private MyErpOrderService myErpOrderService;
private WarehouseTempMdService warehouseTempMdService;
@Resource
private TransInoutService transInoutService;
@Resource
private UdiInfoService udiInfoService;
@Resource
private UdiRelevanceService udiRelevanceService;
@Resource
private SetupService setupService;
@Resource
AuthAdminService authAdminService;
@ -73,6 +67,24 @@ public class WareHouseController {
return ResultVOUtils.success("导入成功");
}
@GetMapping("admin/warehouse/inout/findByOrderId")
public BaseResponse findByOrderId(WarehouseQueryRequest warehouseQueryRequest) {
PageResult<WarehouseEntity> pageResult = warehouseMdService.filterWarehouseByPage(warehouseQueryRequest);
PageSimpleResponse<WarehouseEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageResult.getTotal());
pageSimpleResponse.setList(pageResult.getList());
return ResultVOUtils.success(pageSimpleResponse);
}
@GetMapping("admin/warehouse/inout/findErrorByOrderId")
public BaseResponse findErrorByOrderId(WarehouseQueryRequest warehouseQueryRequest) {
PageResult<WarehousetempEntity> pageResult = warehouseTempMdService.filterWarehouseByPage(warehouseQueryRequest);
PageSimpleResponse<WarehousetempEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageResult.getTotal());
pageSimpleResponse.setList(pageResult.getList());
return ResultVOUtils.success(pageSimpleResponse);
}
/**
* ---------------------------------------------
@ -131,22 +143,6 @@ public class WareHouseController {
return ResultVOUtils.success(pageSimpleResponse);
}
@GetMapping("admin/warehouse/inout/findByOrderId")
public BaseResponse findByOrderId(WarehouseQueryRequest warehouseQueryRequest) {
List<WarehouseEntity> warehouseEntityList = warehouseService.findByOrderId(warehouseQueryRequest);
List<WarehouseResponse> warehouseResponses = warehouseEntityList.stream().map(item ->
{
WarehouseResponse warehouseResponse = new WarehouseResponse();
BeanUtils.copyProperties(item, warehouseResponse);
return warehouseResponse;
}).collect(Collectors.toList());
PageInfo<WarehouseEntity> pageInfo;
pageInfo = new PageInfo<>(warehouseEntityList);
PageSimpleResponse<WarehouseResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(warehouseResponses);
return ResultVOUtils.success(pageSimpleResponse);
}
@GetMapping("admin/warehouse/inout/findAllByOrderId")
public BaseResponse findAllByOrderId(WarehouseQueryRequest warehouseQueryRequest) {
@ -166,34 +162,6 @@ public class WareHouseController {
}
@GetMapping("admin/warehouse/inout/findErrorByOrderId")
public BaseResponse findErrorByOrderId(WarehouseQueryRequest warehouseQueryRequest) {
List<Warehousetemp> warehousetempList = warehouseService.findErrorByOrderId(warehouseQueryRequest);
List<WarehouseResponse> warehouseResponses = WarehousBeanUtils.tempsToWarehouseResponse(warehousetempList);
PageInfo<Warehousetemp> pageInfo;
pageInfo = new PageInfo<>(warehousetempList);
PageSimpleResponse<WarehouseResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(warehouseResponses);
return ResultVOUtils.success(pageSimpleResponse);
}
public void updateErpOrderId(List<ErpOrderEntity> erpOrderEntities, String oldId, String newId) {
if (erpOrderEntities != null) {
List<ErpOrderEntity> inserts = new ArrayList<>();
for (ErpOrderEntity erpOrderEntity : erpOrderEntities) {
if (erpOrderEntity.getOrderIdFk().equals(oldId)) {
erpOrderEntity.setOrderIdFk(newId);
inserts.add(erpOrderEntity);
}
}
myErpOrderService.insertErpOrders(inserts);
}
}
@PostMapping("/admin/warehouse/inout/save")
public BaseResponse save(@RequestBody @Valid WarehouseSaveRequest warehouseSaveRequest,
BindingResult bindingResult) {

@ -6,22 +6,7 @@ import lombok.Data;
public class ErpOrderEntity {
/**
* companyid : 31443
* docid : 200959
* iodtlid : 1108752
* inoutid : 1064084
* credate : 2020-10-14 10:24:56.0
* goodsunit :
* goodsid : 26
* lotid : 84392
* goodsname : 120ml
* companyname :
* lotno : 1912198
* dtlgoodsqty : 4000
*/
private long id;
private String id;
private String companyid;
private String docid;
private String iodtlid;
@ -32,9 +17,9 @@ public class ErpOrderEntity {
private String goodsname;
private String companyname;
private String lotno;
private int dtlgoodsqty;
private Integer dtlgoodsqty;
private String credate;
private int reCount;
private Integer reCount;
private String nameCode;
@ -43,11 +28,11 @@ public class ErpOrderEntity {
private String authCode;
private String packSpec;
private String packRatio;
private int bhzxxsbzsl;
private int zxxsbzbhsydysl;
private Integer bhzxxsbzsl;
private Integer zxxsbzbhsydysl;
private String isDownload;
private String orderIdFk;
private int count;
private Integer count;
private String nameCodes;
private String status;

@ -0,0 +1,29 @@
package com.glxp.udi.admin.entity.inout;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
@Data
public class OrderMdEntity {
private String id;
private String orderId;
private String action;
private String corpOrderId;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
private Date actDate;
private String fromCorpId;
private String actor;
private String mainAction;
private String fromCorp;
private String status;
private String remark;
private String exportStatus;
private String fromType;
private String contrastStatus;
private String erpFk;
private Long customerId;
}

@ -14,7 +14,7 @@ public class WarehouseEntity {
private Integer wrongCode;
private String upperCorpOrderId;
private String fromCorpId;
private Long id;
private String id;
private String fromCorp;
private String orderId;
private String batchNo;

@ -11,10 +11,10 @@ public class WarehousetempEntity {
private String corpOrderId;
private String actor;
private String actDate;
private int wrongCode;
private Integer wrongCode;
private String upperCorpOrderId;
private String fromCorpID;
private long id;
private String fromCorpId;
private String id;
private String fromCorp;
private String orderId;
private String batchNo;
@ -23,7 +23,8 @@ public class WarehousetempEntity {
private String serialNo;
private String udi;
private Integer count;
private int type;
private int oddCount;
private Integer type;
private Long customerId;
}

@ -0,0 +1,93 @@
package com.glxp.udi.admin.mongo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Component;
import java.util.Collection;
import java.util.List;
/**
* @Desc TODO MongoDB
*/
@Component
public class MongoDBClient {
@Autowired
private MongoTemplate mongoTemplate;
/*
* @ClassName MongoDBClient
* @Desc TODO -2 / -1 / 1
* @Date 2019/4/1 10:59
* @Version 1.0
*/
public Integer createCollection(String collectionName){
// 先判断集合是否存在
if(mongoTemplate.collectionExists(collectionName)){
return -2;
}else{
// 创建一个集合
mongoTemplate.createCollection(collectionName);
// 判断集合是否存在
if(mongoTemplate.collectionExists(collectionName)){
return 1;
}else{
return -1;
}
}
}
/*
* @ClassName MongoDBClient
* @Desc TODO
* @Date 2019/4/1 11:12
* @Version 1.0
*/
public void add(Collection<?> batchToSave , String collectionName){
mongoTemplate.insert(batchToSave,collectionName);
}
/*
* @ClassName MongoDBClient
* @Desc TODO
* @Date 2019/4/1 14:20
* @Version 1.0
*/
public void delete(Query query , Object obj , String collectionName){
mongoTemplate.remove(query, obj.getClass(), collectionName);
}
/*
* @ClassName MongoDBClient
* @Desc TODO
* @Date 2019/4/1 14:30
* @Version 1.0
*/
public void update(Query query , Update update , Object obj , String collectionName){
mongoTemplate.updateMulti(query , update , obj.getClass() , collectionName);
}
/*
* @ClassName MongoDBClient
* @Desc TODO
* @Date 2019/4/1 11:18
* @Version 1.0
*/
public List<?> getAllByCollectionName(Object obj , String collectionName){
return mongoTemplate.findAll(obj.getClass(),collectionName);
}
/*
* @ClassName MongoDBClient
* @Desc TODO
* @Date 2019/4/1 11:31
* @Version 1.0
*/
public List<?> getByConditionAndCollectionName(Query query , Object obj , String collectionName){
return mongoTemplate.find(query, obj.getClass() , collectionName);
}
}

@ -0,0 +1,9 @@
package com.glxp.udi.admin.mongo;
public class MongoDBName {
public static final String NAME_ORDER = "io_order"; //订单表
public static final String NAME_CODE_ERROR = "io_code_temp"; //临时码表
public static final String NAME_CODE = "io_code"; //正式码表
public static final String NAME_ORDER_DETAIL = "io_order_detail"; //正式码表
}

@ -0,0 +1,71 @@
package com.glxp.udi.admin.mongo.service;
import com.glxp.udi.admin.entity.inout.ErpOrderEntity;
import com.glxp.udi.admin.mongo.MongoDBName;
import com.glxp.udi.admin.mongo.utils.MongoPageHelper;
import com.glxp.udi.admin.req.inout.DeleteRequest;
import com.glxp.udi.admin.req.inout.FilterErpOrderRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@Service
public class OrderDetailMdService {
@Autowired
private MongoTemplate mongoTemplate;
@Resource
MongoPageHelper mongoPageHelper;
public List<ErpOrderEntity> filterOrderDetails(FilterErpOrderRequest filterErpOrderRequest) {
Query query = new Query();
if (filterErpOrderRequest.getOrderId() != null && !filterErpOrderRequest.getOrderId().isEmpty()) {
query.addCriteria(Criteria.where("orderIdFk").is(filterErpOrderRequest.getOrderId()));
}
if (filterErpOrderRequest.getCustomerId() != null) {
query.addCriteria(Criteria.where("customerId").is(filterErpOrderRequest.getCustomerId()));
}
return mongoTemplate.find(query, ErpOrderEntity.class, MongoDBName.NAME_ORDER_DETAIL);
}
public void insertOrderDetail(List<ErpOrderEntity> erpOrderEntities) {
if (erpOrderEntities != null) {
Collection<ErpOrderEntity> warehouseEntityCollection = new ArrayList<>();
warehouseEntityCollection.addAll(erpOrderEntities);
mongoTemplate.insert(warehouseEntityCollection, MongoDBName.NAME_ORDER_DETAIL);
}
}
public void deleteOrderDetail(DeleteRequest deleteRequest) {
Query query = new Query();
if (deleteRequest.getId() != null) {
query.addCriteria(Criteria.where("id").is(deleteRequest.getId()));
}
if (deleteRequest.getOrderId() != null) {
query.addCriteria(Criteria.where("orderIdFk").is(deleteRequest.getOrderId()));
}
mongoTemplate.remove(query, ErpOrderEntity.class, MongoDBName.NAME_ORDER_DETAIL);
}
public void updateOrderDetail(ErpOrderEntity erpOrderEntity) {
Query query = new Query();
query.addCriteria(new Criteria().and("id").is(erpOrderEntity.getId()));
Update update = new Update();
if (erpOrderEntity.getCount() != null) {
update.set("count", erpOrderEntity.getCount());
}
if (erpOrderEntity.getReCount() != null) {
update.set("reCount", erpOrderEntity.getReCount());
}
mongoTemplate.updateMulti(query, update, MongoDBName.NAME_ORDER_DETAIL);
}
}

@ -0,0 +1,145 @@
package com.glxp.udi.admin.mongo.service;
import com.glxp.udi.admin.entity.inout.OrderMdEntity;
import com.glxp.udi.admin.mongo.MongoDBName;
import com.glxp.udi.admin.mongo.utils.MongoPageHelper;
import com.glxp.udi.admin.mongo.utils.PageResult;
import com.glxp.udi.admin.req.inout.DeleteRequest;
import com.glxp.udi.admin.req.inout.OrderFilterRequest;
import com.glxp.udi.admin.util.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
@Service
public class OrderMdService {
@Autowired
private MongoTemplate mongoTemplate;
@Resource
MongoPageHelper mongoPageHelper;
private static final Logger log = LoggerFactory.getLogger(OrderMdService.class);
public PageResult<OrderMdEntity> filterList(OrderFilterRequest orderFilterRequest) {
Query query = new Query();
if (orderFilterRequest.getId() != null && !orderFilterRequest.getId().isEmpty()) {
query.addCriteria(Criteria.where("id").is(orderFilterRequest.getId()));
}
if (orderFilterRequest.getMainAction() != null && !orderFilterRequest.getMainAction().isEmpty()) {
query.addCriteria(Criteria.where("mainAction").is(orderFilterRequest.getMainAction()));
}
if (orderFilterRequest.getAction() != null && !orderFilterRequest.getAction().isEmpty()) {
query.addCriteria(Criteria.where("action").is(orderFilterRequest.getAction()));
}
if (orderFilterRequest.getAction() == null || orderFilterRequest.getAction().isEmpty()) {
query.addCriteria(Criteria.where("action").ne("StockCheck"));
}
if (orderFilterRequest.getStatus() != null && !orderFilterRequest.getStatus().isEmpty()) {
query.addCriteria(Criteria.where("status").is(orderFilterRequest.getStatus()));
}
if (orderFilterRequest.getExportStatus() != null && !orderFilterRequest.getExportStatus().isEmpty()) {
query.addCriteria(Criteria.where("exportStatus").is(orderFilterRequest.getExportStatus()));
}
if (orderFilterRequest.getCustomerId() != null) {
if (orderFilterRequest.getStartTime() != null && !orderFilterRequest.getStartTime().isEmpty()
&& orderFilterRequest.getEndTime() != null && !orderFilterRequest.getEndTime().isEmpty()) {
Date sdate, edate = null;
if (orderFilterRequest.getStartTime().contains("T")) {
sdate = DateUtil.convertTimeFormat(orderFilterRequest.getStartTime());
} else {
sdate = DateUtil.parseDate(orderFilterRequest.getStartTime());
}
if (orderFilterRequest.getEndTime().contains("T")) {
edate = DateUtil.convertTimeFormat(orderFilterRequest.getEndTime());
} else {
edate = DateUtil.parseDate(orderFilterRequest.getEndTime());
}
query.addCriteria(Criteria.where("customerId").is(orderFilterRequest.getCustomerId()).andOperator(Criteria.where("actDate").gte(DateUtil.dateToISODate(sdate)
), Criteria.where("actDate").lt(DateUtil.dateToISODate(edate))));
} else
query.addCriteria(Criteria.where("customerId").is(orderFilterRequest.getCustomerId()));
}
if (orderFilterRequest.getIsError() != null) {
query.addCriteria(Criteria.where("status").ne(orderFilterRequest.getIsError()));
}
return mongoPageHelper.pageQuery(query, OrderMdEntity.class,
orderFilterRequest.getLimit(), orderFilterRequest.getPage(), orderFilterRequest.getLastId(), MongoDBName.NAME_ORDER);
}
public void updateOrder(OrderMdEntity orderMdEntity) {
Query query = new Query();
if (orderMdEntity.getOrderId() != null && !orderMdEntity.getOrderId().isEmpty()) {
query.addCriteria(new Criteria().and("orderId").is(orderMdEntity.getOrderId()));
} else if (orderMdEntity.getId() != null && !orderMdEntity.getId().isEmpty()) {
query.addCriteria(new Criteria().and("id").is(orderMdEntity.getId()));
} else {
log.error("更新失败未指定orderId");
return;
}
Update update = new Update();
if (orderMdEntity.getId() != null) {
update.set("fromCorp", orderMdEntity.getFromCorp());
}
if (orderMdEntity.getFromCorp() != null) {
update.set("fromCorp", orderMdEntity.getFromCorp());
}
if (orderMdEntity.getFromCorpId() != null) {
update.set("fromCorpId", orderMdEntity.getFromCorpId());
}
if (orderMdEntity.getActDate() != null) {
update.set("actDate", orderMdEntity.getActDate());
}
if (orderMdEntity.getStatus() != null) {
update.set("status", orderMdEntity.getStatus());
}
if (orderMdEntity.getRemark() != null) {
update.set("remark", orderMdEntity.getRemark());
}
if (orderMdEntity.getExportStatus() != null) {
update.set("exportStatus", orderMdEntity.getExportStatus());
}
if (orderMdEntity.getContrastStatus() != null) {
update.set("contrastStatus", orderMdEntity.getContrastStatus());
}
if (orderMdEntity.getErpFk() != null) {
update.set("erpFk", orderMdEntity.getErpFk());
}
mongoTemplate.updateMulti(query, update, MongoDBName.NAME_ORDER);
}
public void deleteOrder(DeleteRequest deleteRequest) {
Query query = new Query();
if (deleteRequest.getId() != null) {
query.addCriteria(Criteria.where("id").is(deleteRequest.getId()));
}
if (deleteRequest.getOrderId() != null) {
query.addCriteria(Criteria.where("orderId").is(deleteRequest.getOrderId()));
}
mongoTemplate.remove(query, OrderMdEntity.class, MongoDBName.NAME_ORDER);
}
public void insertOrder(OrderMdEntity orderMdEntity) {
if (orderMdEntity != null) {
Collection<OrderMdEntity> orderMdEntities = new ArrayList<>();
orderMdEntities.add(orderMdEntity);
mongoTemplate.insert(orderMdEntities, MongoDBName.NAME_ORDER);
}
}
}

@ -0,0 +1,128 @@
package com.glxp.udi.admin.mongo.service;
import com.glxp.udi.admin.entity.inout.WarehouseEntity;
import com.glxp.udi.admin.mongo.MongoDBName;
import com.glxp.udi.admin.mongo.utils.MongoPageHelper;
import com.glxp.udi.admin.mongo.utils.PageResult;
import com.glxp.udi.admin.req.inout.DeleteRequest;
import com.glxp.udi.admin.req.inout.FilterWarehouseRequest;
import com.glxp.udi.admin.req.inout.WarehouseQueryRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@Service
public class WarehouseMdService {
@Autowired
private MongoTemplate mongoTemplate;
@Resource
MongoPageHelper mongoPageHelper;
public PageResult<WarehouseEntity> filterWarehouseByPage(WarehouseQueryRequest warehouseQueryRequest) {
Query query = new Query();
if (warehouseQueryRequest.getCode() != null && !warehouseQueryRequest.getCode().isEmpty()) {
query.addCriteria(Criteria.where("code").is(warehouseQueryRequest.getCode()));
}
if (warehouseQueryRequest.getCorpOrderId() != null && !warehouseQueryRequest.getCorpOrderId().isEmpty()) {
query.addCriteria(Criteria.where("corpOrderId").is(warehouseQueryRequest.getCorpOrderId()));
}
if (warehouseQueryRequest.getOrderId() != null && !warehouseQueryRequest.getOrderId().isEmpty()) {
query.addCriteria(Criteria.where("orderId").is(warehouseQueryRequest.getOrderId()));
}
if (warehouseQueryRequest.getCustomerId() != null) {
query.addCriteria(Criteria.where("customerId").is(warehouseQueryRequest.getCustomerId()));
}
return mongoPageHelper.pageQuery(query, WarehouseEntity.class,
warehouseQueryRequest.getLimit(), warehouseQueryRequest.getPage(), warehouseQueryRequest.getLastId(), MongoDBName.NAME_CODE);
}
public List<WarehouseEntity> filterWarehouse(WarehouseQueryRequest warehouseQueryRequest) {
Query query = new Query();
if (warehouseQueryRequest.getCode() != null && !warehouseQueryRequest.getCode().isEmpty()) {
query.addCriteria(Criteria.where("code").is(warehouseQueryRequest.getCode()));
}
if (warehouseQueryRequest.getCorpOrderId() != null && !warehouseQueryRequest.getCorpOrderId().isEmpty()) {
query.addCriteria(Criteria.where("corpOrderId").is(warehouseQueryRequest.getCorpOrderId()));
}
if (warehouseQueryRequest.getOrderId() != null && !warehouseQueryRequest.getOrderId().isEmpty()) {
query.addCriteria(Criteria.where("orderId").is(warehouseQueryRequest.getOrderId()));
}
if (warehouseQueryRequest.getCustomerId() != null) {
query.addCriteria(Criteria.where("customerId").is(warehouseQueryRequest.getCustomerId()));
}
return mongoTemplate.find(query, WarehouseEntity.class, MongoDBName.NAME_CODE);
}
public void insertWarehouses(List<WarehouseEntity> warehouseEntities) {
if (warehouseEntities != null) {
Collection<WarehouseEntity> warehouseEntityCollection = new ArrayList<>();
warehouseEntityCollection.addAll(warehouseEntities);
mongoTemplate.insert(warehouseEntityCollection, MongoDBName.NAME_CODE);
}
}
public List<WarehouseEntity> findByCode(FilterWarehouseRequest filterWarehouseRequest) {
Query query = new Query();
query.addCriteria(
Criteria.where("customerId").is(filterWarehouseRequest.getCustomerId())
.and("code").is(filterWarehouseRequest.getCode())
);
return mongoTemplate.find(query, WarehouseEntity.class, MongoDBName.NAME_CODE);
}
public List<WarehouseEntity> searchCode(String code, Long customerId) {
Query query = new Query();
query.addCriteria(
Criteria.where("customerId").is(customerId)
.and("code").is(code)
.and("action").ne("StockCheck")
);
return mongoTemplate.find(query, WarehouseEntity.class, MongoDBName.NAME_CODE);
}
public void updateUnit(String orderId, String fromCorpId, String fromCorp) {
Query query = new Query();
query.addCriteria(new Criteria().and("orderId").is(orderId));
Update update = new Update();
update.set("fromCorp", fromCorp);
update.set("fromCorpId", fromCorpId);
mongoTemplate.updateMulti(query, update, MongoDBName.NAME_CODE);
}
public void updateOrderId(String orderId, String newOrderId) {
Query query = new Query();
query.addCriteria(new Criteria().and("orderId").is(orderId));
Update update = new Update();
update.set("orderId", newOrderId);
mongoTemplate.updateMulti(query, update, MongoDBName.NAME_CODE);
}
public void deleteCode(DeleteRequest deleteRequest) {
Query query = new Query();
if (deleteRequest.getId() != null) {
query.addCriteria(Criteria.where("id").is(deleteRequest.getId()));
}
if (deleteRequest.getOrderId() != null) {
query.addCriteria(Criteria.where("orderId").is(deleteRequest.getOrderId()));
}
mongoTemplate.remove(query, WarehouseEntity.class, MongoDBName.NAME_CODE);
}
}

@ -0,0 +1,103 @@
package com.glxp.udi.admin.mongo.service;
import com.glxp.udi.admin.entity.inout.WarehouseEntity;
import com.glxp.udi.admin.entity.inout.WarehousetempEntity;
import com.glxp.udi.admin.mongo.MongoDBName;
import com.glxp.udi.admin.mongo.utils.MongoPageHelper;
import com.glxp.udi.admin.mongo.utils.PageResult;
import com.glxp.udi.admin.req.inout.DeleteRequest;
import com.glxp.udi.admin.req.inout.WarehouseQueryRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@Service
public class WarehouseTempMdService {
@Autowired
private MongoTemplate mongoTemplate;
@Resource
MongoPageHelper mongoPageHelper;
public PageResult<WarehousetempEntity> filterWarehouseByPage(WarehouseQueryRequest warehouseQueryRequest) {
Query query = new Query();
if (warehouseQueryRequest.getCode() != null && !warehouseQueryRequest.getCode().isEmpty()) {
query.addCriteria(Criteria.where("code").is(warehouseQueryRequest.getCode()));
}
if (warehouseQueryRequest.getCorpOrderId() != null && !warehouseQueryRequest.getCorpOrderId().isEmpty()) {
query.addCriteria(Criteria.where("corpOrderId").is(warehouseQueryRequest.getCorpOrderId()));
}
if (warehouseQueryRequest.getOrderId() != null && !warehouseQueryRequest.getOrderId().isEmpty()) {
query.addCriteria(Criteria.where("orderId").is(warehouseQueryRequest.getOrderId()));
}
if (warehouseQueryRequest.getCustomerId() != null) {
query.addCriteria(Criteria.where("customerId").is(warehouseQueryRequest.getCustomerId()));
}
return mongoPageHelper.pageQuery(query, WarehousetempEntity.class,
warehouseQueryRequest.getLimit(), warehouseQueryRequest.getPage(), warehouseQueryRequest.getLastId(), MongoDBName.NAME_CODE_ERROR);
}
public List<WarehousetempEntity> filterWarehouse(WarehouseQueryRequest warehouseQueryRequest) {
Query query = new Query();
if (warehouseQueryRequest.getCode() != null && !warehouseQueryRequest.getCode().isEmpty()) {
query.addCriteria(Criteria.where("code").is(warehouseQueryRequest.getCode()));
}
if (warehouseQueryRequest.getCorpOrderId() != null && !warehouseQueryRequest.getCorpOrderId().isEmpty()) {
query.addCriteria(Criteria.where("corpOrderId").is(warehouseQueryRequest.getCorpOrderId()));
}
if (warehouseQueryRequest.getOrderId() != null && !warehouseQueryRequest.getOrderId().isEmpty()) {
query.addCriteria(Criteria.where("orderId").is(warehouseQueryRequest.getOrderId()));
}
if (warehouseQueryRequest.getCustomerId() != null) {
query.addCriteria(Criteria.where("customerId").is(warehouseQueryRequest.getCustomerId()));
}
return mongoTemplate.find(query, WarehousetempEntity.class, MongoDBName.NAME_CODE_ERROR);
}
public List<WarehousetempEntity> findTempByOrderId(String orderId) {
Query query = new Query(Criteria.where("orderId").is(orderId));
List<WarehousetempEntity> result = mongoTemplate.find(query, WarehousetempEntity.class, MongoDBName.NAME_CODE_ERROR);
return result;
}
public void insertTempWarehouses(List<WarehousetempEntity> warehouseEntities) {
if (warehouseEntities != null) {
Collection<WarehousetempEntity> warehousetempEntityCollection = new ArrayList<>();
warehousetempEntityCollection.addAll(warehouseEntities);
mongoTemplate.insert(warehousetempEntityCollection, MongoDBName.NAME_CODE_ERROR);
}
}
public void deleteTempWarehouses(List<String> ids) {
if (ids != null) {
for (String id : ids) {
Query query = new Query();
query.addCriteria(Criteria.where("id").is(id));
mongoTemplate.remove(query, MongoDBName.NAME_CODE_ERROR);
}
}
}
public void deleteCode(DeleteRequest deleteRequest) {
Query query = new Query();
if (deleteRequest.getId() != null) {
query.addCriteria(Criteria.where("id").is(deleteRequest.getId()));
}
if (deleteRequest.getOrderId() != null) {
query.addCriteria(Criteria.where("orderId").is(deleteRequest.getOrderId()));
}
mongoTemplate.remove(query, WarehouseEntity.class, MongoDBName.NAME_CODE_ERROR);
}
}

@ -0,0 +1,109 @@
package com.glxp.udi.admin.mongo.utils;
import org.apache.commons.lang3.StringUtils;
import org.bson.types.ObjectId;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.domain.Sort.Order;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* MongoDBSpring-data使.
*
* @author Ryan Miao at 2018-06-07 15:19
**/
public class MongoPageHelper {
private static final int FIRST_PAGE_NUM = 1;
private static final String ID = "_id";
private final MongoTemplate mongoTemplate;
public MongoPageHelper(MongoTemplate mongoTemplate) {
this.mongoTemplate = mongoTemplate;
}
/**
* .
*
* @see MongoPageHelper#pageQuery(Query,
* Class, Integer, Integer, Function,
* String)
*/
public <T> PageResult<T> pageQuery(Query query, Class<T> entityClass, Integer pageSize,
Integer pageNum, String tableName) {
return pageQuery(query, entityClass, pageSize, pageNum, Function.identity(), null, tableName);
}
/**
* 使skip-limit.
*
* @see MongoPageHelper#pageQuery(Query,
* Class, Integer, Integer, Function,
* String)
*/
public <T, R> PageResult<R> pageQuery(Query query, Class<T> entityClass,
Integer pageSize, Integer pageNum, Function<T, R> mapper, String tableName) {
return pageQuery(query, entityClass, pageSize, pageNum, mapper, null);
}
public <T> PageResult<T> pageQuery(Query query, Class<T> entityClass, Integer pageSize,
Integer pageNum, String lastId, String tableName) {
return pageQuery(query, entityClass, pageSize, pageNum, Function.identity(), null, tableName);
}
/**
* .
*
* @param query Mongo Query.
* @param entityClass Mongo collectionentity class.
* @param mapper dblistentityClass, 使mapper.
* @param pageSize .
* @param pageNum .
* @param lastId , skip-limitfind(_id>lastId).limit.
* ObjectId nullpageNum.
* @param <T> collectionclass.
* @param <R>
* @return PageResultpage.
*/
public <T, R> PageResult<R> pageQuery(Query query, Class<T> entityClass,
Integer pageSize, Integer pageNum, Function<T, R> mapper, String lastId, String tableName) {
//分页逻辑
long total = mongoTemplate.count(query, entityClass,tableName);
final Integer pages = (int) Math.ceil(total / (double) pageSize);
if (pageNum <= 0 || pageNum > pages) {
pageNum = FIRST_PAGE_NUM;
}
final Criteria criteria = new Criteria();
if (StringUtils.isNotBlank(lastId)) {
if (pageNum != FIRST_PAGE_NUM) {
criteria.and(ID).gt(new ObjectId(lastId));
}
query.limit(pageSize);
} else {
int skip = pageSize * (pageNum - 1);
query.skip(skip).limit(pageSize);
}
final List<T> entityList = mongoTemplate
.find(query.addCriteria(criteria)
.with(new Sort(Collections.singletonList(new Order(Direction.ASC, ID)))),
entityClass, tableName);
final PageResult<R> pageResult = new PageResult<>();
pageResult.setTotal(total);
pageResult.setPages(pages);
pageResult.setPageSize(pageSize);
pageResult.setPageNum(pageNum);
pageResult.setList(entityList.stream().map(mapper).collect(Collectors.toList()));
return pageResult;
}
}

@ -0,0 +1,44 @@
package com.glxp.udi.admin.mongo.utils;
import lombok.Data;
import java.util.List;
/**
* .
*
* @author Ryan
*/
@Data
//@AllArgsConstructor
//@NoArgsConstructor
//@JsonInclude(Include.NON_NULL)
public class PageResult<T> {
/**
* 1
*/
private Integer pageNum;
/**
*
*/
private Integer pageSize;
/**
*
*/
private Long total;
/**
*
*/
private Integer pages;
/**
*
*/
private List<T> list;
}

@ -7,5 +7,7 @@ public class DeleteRequest {
String id;
Long customerId;
String orderId;
String orderIdFk;
}

@ -18,6 +18,7 @@ public class FilterErpOrderRequest extends ListPageRequest {
private String billAction;
private String billcode;
private String fbillflag;
Long customerId;
List<String> orderIds;
}

@ -19,5 +19,7 @@ public class OrderFilterRequest extends ListPageRequest {
private String endTime;
private String stockCheckFk;
private Long customerId;
private String lastId;
private String isError;
}

@ -1,6 +1,6 @@
package com.glxp.udi.admin.req.inout;
import com.glxp.udi.admin.entity.inout.WarehouseEntity;
import com.glxp.udi.admin.entity.inout.WarehousetempEntity;
import lombok.Data;
import java.util.List;
@ -19,7 +19,7 @@ public class PostOrderRequest {
public static class PostOrder {
public List<String> erpOrders;
List<WarehouseEntity> codes;
List<WarehousetempEntity> codes;
private String billType;
private String orderId;
@ -57,11 +57,11 @@ public class PostOrderRequest {
this.erpOrders = erpOrders;
}
public List<WarehouseEntity> getCodes() {
public List<WarehousetempEntity> getCodes() {
return codes;
}
public void setCodes(List<WarehouseEntity> codes) {
public void setCodes(List<WarehousetempEntity> codes) {
this.codes = codes;
}
}

@ -7,6 +7,8 @@ import lombok.Data;
public class WarehouseQueryRequest extends ListPageRequest {
private String corpOrderId;
private String orderId;
private String code;
private Long customerId;
private String lastId;
}

@ -1,40 +1,43 @@
package com.glxp.udi.admin.thread;
import com.glxp.udi.admin.controller.inout.InoutUtils;
import com.glxp.udi.admin.entity.inout.ErpOrderEntity;
import com.glxp.udi.admin.entity.inout.OrderEntity;
import com.glxp.udi.admin.entity.inout.OrderMdEntity;
import com.glxp.udi.admin.entity.inout.WarehouseEntity;
import com.glxp.udi.admin.entity.inout.Warehousetemp;
import com.glxp.udi.admin.entity.inout.WarehousetempEntity;
import com.glxp.udi.admin.mongo.service.OrderDetailMdService;
import com.glxp.udi.admin.mongo.service.OrderMdService;
import com.glxp.udi.admin.mongo.service.WarehouseMdService;
import com.glxp.udi.admin.mongo.service.WarehouseTempMdService;
import com.glxp.udi.admin.req.inout.CommitRequest;
import com.glxp.udi.admin.req.inout.FilterErpOrderRequest;
import com.glxp.udi.admin.req.inout.OrderFilterRequest;
import com.glxp.udi.admin.req.inout.DeleteRequest;
import com.glxp.udi.admin.req.inout.PostOrderRequest;
import com.glxp.udi.admin.req.inout.WarehouseQueryRequest;
import com.glxp.udi.admin.service.info.SetupService;
import com.glxp.udi.admin.service.inout.*;
import com.glxp.udi.admin.service.inout.MyErpOrderService;
import com.glxp.udi.admin.service.inout.UdiInfoService;
import com.glxp.udi.admin.service.inout.UdiRelevanceService;
import com.glxp.udi.admin.service.receipts.MipsBarcodeService;
import com.glxp.udi.admin.service.receipts.ProductInfoService;
import com.glxp.udi.admin.service.receipts.ProductService;
import com.glxp.udi.admin.util.WarehousBeanUtils;
import com.glxp.udi.admin.util.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class TransInoutService {
private static final Logger logger = LoggerFactory.getLogger(TransInoutService.class);
@Resource
private WarehouseService warehouseService;
@Resource
private OrderService orderService;
@Resource
private MipsBarcodeService mipsBarcodeService;
@Resource
@ -54,6 +57,18 @@ public class TransInoutService {
@Value("${UDI_SERVER_URL}")
private String udiUrl;
@Resource
private OrderMdService orderService;
@Resource
private WarehouseTempMdService warehouseTempMdService;
@Resource
private WarehouseMdService warehouseMdService;
@Resource
private OrderDetailMdService orderDetailMdService;
@Async
public void transInout(PostOrderRequest postOrderRequest, long customerId) {
@ -61,57 +76,51 @@ public class TransInoutService {
if (postOrders != null && postOrders.size() > 0) {
for (int i = 0; i < postOrders.size(); i++) {
PostOrderRequest.PostOrder postOrder = postOrders.get(i);
List<WarehouseEntity> warehouseEntityList = postOrder.getCodes();
List<Warehousetemp> warehousetempList = new WarehousBeanUtils().entityToTemp(warehouseEntityList, customerId);
List<WarehousetempEntity> warehousetempList = postOrder.getCodes();
if (warehousetempList != null && warehousetempList.size() > 0) {
Warehousetemp warehouseEntity = warehousetempList.get(0);
WarehousetempEntity warehousetempEntity = warehousetempList.get(0);
String orderId = System.currentTimeMillis() + i + "";
OrderEntity orderSaveRequest = new OrderEntity();
orderSaveRequest.setId(orderId);
if (warehouseEntity.getActdate() != null) {
orderSaveRequest.setActDate(warehouseEntity.getActdate());
}
OrderMdEntity orderSaveRequest = new OrderMdEntity();
orderSaveRequest.setOrderId(orderId);
Date actDate = DateUtil.parseDate(warehousetempEntity.getActDate());
orderSaveRequest.setActDate(DateUtil.dateToISODate(actDate));
orderSaveRequest.setCustomerId(customerId);
orderSaveRequest.setAction(warehouseEntity.getAction());
orderSaveRequest.setActor(warehouseEntity.getActor());
orderSaveRequest.setCorpOrderId(warehouseEntity.getCorporderid());
orderSaveRequest.setFromCorpId(warehouseEntity.getFromcorpid());
orderSaveRequest.setMainAction(warehouseEntity.getMainaction());
orderSaveRequest.setFromCorp(warehouseEntity.getFromcorp());
orderSaveRequest.setAction(warehousetempEntity.getAction());
orderSaveRequest.setActor(warehousetempEntity.getActor());
orderSaveRequest.setCorpOrderId(warehousetempEntity.getCorpOrderId());
orderSaveRequest.setFromCorpId(warehousetempEntity.getFromCorpId());
orderSaveRequest.setMainAction(warehousetempEntity.getMainAction());
orderSaveRequest.setFromCorp(warehousetempEntity.getFromCorp());
orderSaveRequest.setFromType("手持终端");
orderSaveRequest.setStatus("process");
orderSaveRequest.setExportStatus("未上传");
orderSaveRequest.setStockCheckFk(postOrder.getStockIdFk());
orderSaveRequest.setSignStatus("0");
List<String> docidsList = postOrder.getErpOrders();
String docidStr = "";
if (docidsList != null) {
for (String key : docidsList) {
docidStr = docidStr + "," + key;
}
if (docidStr.length() > 1) {
docidStr = docidStr.substring(1);
orderSaveRequest.setErpFk(docidStr);
}
}
orderService.insertOrder(orderSaveRequest);
for (int index = 0; index < warehousetempList.size(); index++) {
warehousetempList.get(index).setOrderid(orderId);
warehousetempList.get(index).setOrderId(orderId);
}
warehouseService.insertTempWarehouses(warehousetempList);
List<Warehousetemp> filterList = warehousetempList;
List<Warehousetemp> insertList = new ArrayList<>();
warehouseTempMdService.insertTempWarehouses(warehousetempList);
List<WarehousetempEntity> filterList = warehousetempList;
List<WarehousetempEntity> insertList = new ArrayList<>();
//更新状态,正在处理
OrderMdEntity tempEntity = new OrderMdEntity();
tempEntity.setOrderId(filterList.get(0).getOrderId());
tempEntity.setRemark("正在处理");
orderService.updateOrder(tempEntity);
String result;
orderService.updateRemark(filterList.get(0).getOrderid(), "正在处理");
for (int j = 0; j < filterList.size(); j++) {
Warehousetemp warehousetemp = filterList.get(j);
result = new InoutUtils().filterCode(warehouseService, warehousetemp, setupService);
WarehousetempEntity warehousetemp = filterList.get(j);
result = new InoutUtils().filterCode(warehouseMdService, warehousetemp, setupService);
if (result == null) {
insertList.add(warehousetemp);
} else {
orderService.updateOrderStatus(warehousetemp.getOrderid(), "error");
orderService.updateRemark(warehousetemp.getOrderid(), result);
//更新状态,失败
OrderMdEntity tempEntity1 = new OrderMdEntity();
tempEntity1.setOrderId(filterList.get(0).getOrderId());
tempEntity1.setStatus("error");
tempEntity1.setRemark(result);
orderService.updateOrder(tempEntity1);
insertList.clear();
break;
}
@ -119,18 +128,24 @@ public class TransInoutService {
postOrders.get(i).setOrderId(orderId);
if (insertList.size() > 0) {
orderId = insertList.get(0).getOrderid();
warehouseService.insertWarehouses(new WarehousBeanUtils().tempsToEntitys(insertList));
Warehousetemp warehousetemp = insertList.get(0);
CommitRequest commitRequest = new CommitRequest();
commitRequest.setOrderId(warehousetemp.getOrderid());
List<Warehousetemp> warehousetemps = warehouseService.findTempByOrderId(commitRequest);
orderService.updateOrderStatus(orderId, "success");
List<Long> ids = new ArrayList<>();
for (Warehousetemp w : warehousetemps) {
ids.add(w.getId());
}
warehouseService.deleteTempWarehouses(ids);
orderId = insertList.get(0).getOrderId();
List<WarehouseEntity> warehouseEntities = insertList.stream().map(e -> {
WarehouseEntity warehouseEntity = new WarehouseEntity();
BeanUtils.copyProperties(e, warehouseEntity);
return warehouseEntity;
}).collect(Collectors.toList());
warehouseMdService.insertWarehouses(warehouseEntities);
//更新状态,成功
OrderMdEntity tempEntity2 = new OrderMdEntity();
tempEntity2.setOrderId(filterList.get(0).getOrderId());
tempEntity2.setStatus("success");
orderService.updateOrder(tempEntity2);
//删除零时表数据
DeleteRequest deleteRequest = new DeleteRequest();
deleteRequest.setOrderId(orderId);
warehouseTempMdService.deleteCode(deleteRequest);
insertList.clear();
}
}
@ -139,8 +154,10 @@ public class TransInoutService {
//生成对照表
for (int i = 0; i < postOrders.size(); i++) {
PostOrderRequest.PostOrder postOrder = postOrders.get(i);
List<WarehouseEntity> transData = warehouseService.findByReceiptId(postOrder.getOrderId());
new InoutUtils(udiUrl).generateConstrastDetail(udiInfoService, udiRelevanceService, myErpOrderService, transData);
WarehouseQueryRequest warehouseQueryRequest = new WarehouseQueryRequest();
warehouseQueryRequest.setOrderId(postOrder.getOrderId());
List<WarehouseEntity> transData = warehouseMdService.filterWarehouse(warehouseQueryRequest);
new InoutUtils(udiUrl).generateConstrastDetail(udiInfoService, udiRelevanceService, orderDetailMdService, transData);
}
}
@ -149,93 +166,55 @@ public class TransInoutService {
@Async
public void repeatCommit(CommitRequest commitRequest) {
List<Warehousetemp> warehousetempList = warehouseService.findTempByOrderId(commitRequest);
String orderId = commitRequest.getOrderId();
List<WarehousetempEntity> warehousetempList = warehouseTempMdService.findTempByOrderId(commitRequest.getOrderId());
if (warehousetempList != null && warehousetempList.size() > 0) {
String result;
List<Warehousetemp> insertList = new ArrayList<>();
List<WarehousetempEntity> insertList = new ArrayList<>();
for (int j = 0; j < warehousetempList.size(); j++) {
Warehousetemp warehousetemp = warehousetempList.get(j);
result = new InoutUtils().filterCode(warehouseService, warehousetemp, setupService);
WarehousetempEntity warehousetemp = warehousetempList.get(j);
result = new InoutUtils().filterCode(warehouseMdService, warehousetemp, setupService);
if (result == null) {
insertList.add(warehousetemp);
} else {
orderService.updateRemark(warehousetemp.getOrderid(), result);
OrderMdEntity tempEntity = new OrderMdEntity();
tempEntity.setOrderId(orderId);
tempEntity.setRemark(result);
orderService.updateOrder(tempEntity);
insertList.clear();
return;
}
}
if (insertList.size() > 0) {
warehouseService.insertWarehouses(new WarehousBeanUtils().tempsToEntitys(insertList));
orderService.updateOrderStatus(insertList.get(0).getOrderid(), "success");
List<Long> ids = new ArrayList<>();
for (Warehousetemp warehousetemp : insertList) {
ids.add(warehousetemp.getId());
}
warehouseService.deleteTempWarehouses(ids);
String orderId = insertList.get(0).getOrderid();
String type = insertList.get(0).getAction();
OrderFilterRequest orderFilterRequest = new OrderFilterRequest();
orderFilterRequest.setId(orderId);
OrderEntity orderEntity = orderService.findOne(orderFilterRequest);
String docidStr = orderEntity.getErpFk();
String[] docidArray;
List<String> docids = new ArrayList<>();
if (docidStr != null && docidStr.length() > 0) {
docidArray = docidStr.split(",");
for (int i = 0; i < docidArray.length; i++) {
docids.add(docidArray[i]);
}
}
if (docids == null || docids.size() == 0) {
FilterErpOrderRequest filterErpOrderRequest = new FilterErpOrderRequest();
filterErpOrderRequest.setOrderId(orderId);
docids = myErpOrderService.filterAllDocid(filterErpOrderRequest);
docids = getDocids(docids);
}
List<WarehouseEntity> datas = warehouseService.findByReceiptId(orderId);
new InoutUtils(udiUrl).generateConstrastDetail(udiInfoService, udiRelevanceService, myErpOrderService, datas);
}
} else {
return;
}
}
List<WarehouseEntity> warehouseEntities = insertList.stream().map(e -> {
WarehouseEntity warehouseEntity = new WarehouseEntity();
BeanUtils.copyProperties(e, warehouseEntity);
return warehouseEntity;
}).collect(Collectors.toList());
warehouseMdService.insertWarehouses(warehouseEntities);
public void updateErpOrderId(List<ErpOrderEntity> erpOrderEntities, String oldId, String newId) {
if (erpOrderEntities != null) {
List<ErpOrderEntity> inserts = new ArrayList<>();
for (ErpOrderEntity erpOrderEntity : erpOrderEntities) {
if (erpOrderEntity.getOrderIdFk() == null || erpOrderEntity.getOrderIdFk().equals(oldId)) {
erpOrderEntity.setOrderIdFk(newId);
inserts.add(erpOrderEntity);
}
}
myErpOrderService.insertErpOrders(inserts);
}
//更新状态,成功
OrderMdEntity tempEntity2 = new OrderMdEntity();
tempEntity2.setOrderId(orderId);
tempEntity2.setStatus("success");
orderService.updateOrder(tempEntity2);
}
public List<String> getDocids(List<String> ids) {
Map<String, String> filter = new HashMap<>();
List<String> docids = new ArrayList<>();
for (String id : ids) {
if (id.contains(",")) {
String[] dociArray = id.split(",");
if (dociArray != null && dociArray.length > 0) {
for (int i = 0; i < dociArray.length; i++) {
filter.put(dociArray[i], dociArray[i]);
}
//删除零时表数据
DeleteRequest deleteRequest = new DeleteRequest();
deleteRequest.setOrderId(orderId);
warehouseTempMdService.deleteCode(deleteRequest);
WarehouseQueryRequest warehouseQueryRequest = new WarehouseQueryRequest();
warehouseQueryRequest.setOrderId(orderId);
List<WarehouseEntity> transData = warehouseMdService.filterWarehouse(warehouseQueryRequest);
new InoutUtils(udiUrl).generateConstrastDetail(udiInfoService, udiRelevanceService, orderDetailMdService, transData);
}
} else {
filter.put(id, id);
}
return;
}
for (String docid : filter.keySet()) {
docids.add(docid);
}
return docids;
}
}

@ -19,7 +19,7 @@ public class DateUtil extends org.apache.commons.lang3.time.DateUtils {
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM/dd HH", "yyyy/MM",
"yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM.dd HH", "yyyy.MM",
"yyyy年MM月dd日", "yyyy年MM月dd日 HH时mm分ss秒", "yyyy年MM月dd日 HH时mm分", "yyyy年MM月dd日 HH时", "yyyy年MM月",
"yyyy"};
"yyyy", "yyyy-MM-dd'T'HH:mm:ss:sssZ"};
/**
* yyyy-MM-dd
@ -149,17 +149,42 @@ public class DateUtil extends org.apache.commons.lang3.time.DateUtils {
/**
* see to DateUtils#parsePatterns
*/
public static Date parseDate(Object str) {
public static Date parseDate(String str) {
if (str == null) {
return null;
}
String tempTime = str.replace("Z", "UTC");
try {
return parseDate(str.toString(), parsePatterns);
return parseDate(tempTime, parsePatterns);
} catch (ParseException e) {
return null;
}
}
public static Date convertTimeFormat(String sourceTime) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");//注意格式化的表达式
sourceTime = sourceTime.replace("Z", " UTC");//注意是空格+UTC
Date resDate = null;
try {
resDate = format.parse(sourceTime);
} catch (ParseException e) {
e.printStackTrace();
}
return resDate;
}
public static Date dateToISODate(Date dateStr) {
Date parse = null;
try {
// 解析字符串时间
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
parse = format.parse(format.format(dateStr));
} catch (ParseException e) {
e.printStackTrace();
}
return parse;
}
/**
*

@ -1,21 +1,24 @@
# 生产环境
server.port=9995
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.jdbc-url=jdbc:mysql://127.0.0.1:3306/udims?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
spring.datasource.username=root
spring.datasource.password=mysql@2020
spring.datasource.password=123456
server.servlet.context-path=
spring.data.mongodb.database=udiwms
spring.data.mongodb.username=root
spring.data.mongodb.password=123456
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
logging.level.org.springframework.data.mongodb.core.MongoTemplate=debug
logging.level.com.glxp.udi.admin.dao=debug
# 跨域设置
cors.allowed-origins=*
cors.allowed-headers=Content-Type,ADMIN_ID,ADMIN_TOKEN
cors.allowed-methods=GET,POST,PUT,DELETE,PATCH,OPTIONS
cors.allowed-Credentials = true
cors.allowed-Credentials=true
#mips服务地址
UDIC_MIPSDOWNLOAD_URL = http://127.0.0.1:8080/UDIC_MIPSDL_Server
UDIC_MIPSDOWNLOAD_URL=http://127.0.0.1:8080/UDIC_MIPSDL_Server
UDI_SERVER_URL=http://127.0.0.1:8080/UDI_DL_Server
UCLOD_SERVER_URL=http://127.0.0.1:9997
#UDI_SERVER_URL=https://www.udims.com/UDI_DL_Server

@ -321,7 +321,7 @@
where nameCode = #{namecode,jdbcType=VARCHAR}
</update>
<!--<insert id="insertDrugs" parameterType="java.util.List">-->
<!--<insert id="insertDrugs" parameterType="java.utils.List">-->
<!--INSERT INTO druginfo-->
<!--(-->
<!--type,-->

@ -13,7 +13,7 @@
(action, mainAction,
code, corpOrderId, actor,
actDate, wrongCode, upperCorpOrderId,
fromCorpID, fromCorp, orderId,batchNo,produceDate,expireDate,serialNo,udi,count,type,oddCount,customerId)
fromCorpID, fromCorp, orderId,batchNo,produceDate,expireDate,serialNo,udi,count,customerId)
VALUES
<foreach collection="warehouseEntities" item="item" index="index"
separator=",">
@ -36,8 +36,6 @@
,#{item.serialNo}
,#{item.udi}
,#{item.count}
,#{item.type}
,#{item.oddCount}
,#{item.customerId}
)
</foreach>

@ -0,0 +1,92 @@
package com.glxp.udi.admin.util;
import com.glxp.udi.BaseApiAdminApplicationTest;
import com.glxp.udi.admin.entity.inout.WarehouseEntity;
import com.glxp.udi.admin.entity.inout.WarehousetempEntity;
import com.glxp.udi.admin.mongo.service.WarehouseMdService;
import com.glxp.udi.admin.mongo.service.WarehouseTempMdService;
import com.glxp.udi.admin.mongo.utils.PageResult;
import com.glxp.udi.admin.req.inout.WarehouseQueryRequest;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class MongoDbTest extends BaseApiAdminApplicationTest {
@Resource
private WarehouseTempMdService warehousetempService;
@Resource
private WarehouseMdService warehouseMdService;
private static final Logger log = LoggerFactory.getLogger(MongoDbTest.class);
@Test
public void insertTempWarehouses() {
List<WarehouseEntity> warehousetempEntityList = new ArrayList<>();
for (int i = 0; i < 100; i++) {
WarehouseEntity warehousetempEntity = new WarehouseEntity();
warehousetempEntity.setAction("1");
warehousetempEntity.setMainAction("1");
warehousetempEntity.setCode("1");
warehousetempEntity.setCorpOrderId("1");
warehousetempEntity.setActor("1");
warehousetempEntity.setActDate("1");
warehousetempEntity.setWrongCode(1);
warehousetempEntity.setUpperCorpOrderId("1");
warehousetempEntity.setFromCorpId("1");
warehousetempEntity.setFromCorp("1");
warehousetempEntity.setOrderId("1");
warehousetempEntity.setBatchNo("1");
warehousetempEntity.setProduceDate("1");
warehousetempEntity.setExpireDate("1");
warehousetempEntity.setSerialNo("1");
warehousetempEntity.setUdi("1");
warehousetempEntity.setType(1);
warehousetempEntity.setCount(1);
warehousetempEntity.setCustomerId(1l);
warehousetempEntityList.add(warehousetempEntity);
}
warehouseMdService.insertWarehouses(warehousetempEntityList);
}
@Test
public void deleteTempWarehouses() {
Set<String> ids = new HashSet<>();
ids.add("60d482458f9da70e386e9ef6");
ids.add("60d482f38f9da74c98219d2e");
// warehousetempService.deleteTempWarehouses(ids);
}
@Test
public void findTempByOrderId() {
List<WarehousetempEntity> warehousetempEntities = warehousetempService.findTempByOrderId("60d536408f9da749342ea53a");
log.info(warehousetempEntities.size() + "");
}
@Test
public void filterWarehouseByPage() {
WarehouseQueryRequest warehouseQueryRequest = new WarehouseQueryRequest();
warehouseQueryRequest.setCustomerId(110l);
warehouseQueryRequest.setOrderId("10");
warehouseQueryRequest.setPage(1);
warehouseQueryRequest.setLimit(10);
PageResult<WarehouseEntity> warehouseEntityPageResult = warehouseMdService.filterWarehouseByPage(warehouseQueryRequest);
List<WarehouseEntity> warehouseEntities = warehouseMdService.filterWarehouse(warehouseQueryRequest);
log.info(warehouseEntityPageResult.getTotal() + "");
}
@Test
public void updateWarehouse() {
warehouseMdService.updateUnit("110","123456","厦门片仔癀");
}
}

@ -27,6 +27,7 @@
<!--<tomcat.version>8.5.37</tomcat.version>-->
</properties>
<dependencyManagement>
<dependencies>
<!--公共模块-->

Loading…
Cancel
Save