|
|
@ -4,12 +4,16 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
import cn.hutool.core.util.ReflectUtil;
|
|
|
|
import cn.hutool.core.util.ReflectUtil;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
import com.glxp.udi.admin.common.res.BaseResponse;
|
|
|
|
import com.glxp.udi.admin.common.res.BaseResponse;
|
|
|
|
import com.glxp.udi.admin.constant.ConstantStatus;
|
|
|
|
import com.glxp.udi.admin.constant.ConstantStatus;
|
|
|
|
import com.glxp.udi.admin.constant.ConstantType;
|
|
|
|
import com.glxp.udi.admin.constant.ConstantType;
|
|
|
|
import com.glxp.udi.admin.constant.SystemParamConstant;
|
|
|
|
import com.glxp.udi.admin.constant.SystemParamConstant;
|
|
|
|
import com.glxp.udi.admin.dao.auth.CustomerInfoDao;
|
|
|
|
import com.glxp.udi.admin.dao.auth.CustomerInfoDao;
|
|
|
|
import com.glxp.udi.admin.dao.basic.BussinessTypeDao;
|
|
|
|
import com.glxp.udi.admin.dao.basic.BussinessTypeDao;
|
|
|
|
|
|
|
|
import com.glxp.udi.admin.dao.inout.OrderDao;
|
|
|
|
import com.glxp.udi.admin.dao.inout.UdiInfoDao;
|
|
|
|
import com.glxp.udi.admin.dao.inout.UdiInfoDao;
|
|
|
|
import com.glxp.udi.admin.dao.inout.UnitMaintainDao;
|
|
|
|
import com.glxp.udi.admin.dao.inout.UnitMaintainDao;
|
|
|
|
import com.glxp.udi.admin.dao.inventory.InvWarehouseDao;
|
|
|
|
import com.glxp.udi.admin.dao.inventory.InvWarehouseDao;
|
|
|
@ -17,19 +21,18 @@ import com.glxp.udi.admin.entity.auth.CustomerInfoEntity;
|
|
|
|
import com.glxp.udi.admin.entity.basic.BussinessTypeEntity;
|
|
|
|
import com.glxp.udi.admin.entity.basic.BussinessTypeEntity;
|
|
|
|
import com.glxp.udi.admin.entity.inout.*;
|
|
|
|
import com.glxp.udi.admin.entity.inout.*;
|
|
|
|
import com.glxp.udi.admin.entity.mongo.OrderMdEntity;
|
|
|
|
import com.glxp.udi.admin.entity.mongo.OrderMdEntity;
|
|
|
|
|
|
|
|
import com.glxp.udi.admin.entity.mongo.WarehouseMdEntity;
|
|
|
|
|
|
|
|
import com.glxp.udi.admin.entity.mongo.WarehousetempMdEntity;
|
|
|
|
import com.glxp.udi.admin.entity.param.SystemParamConfigEntity;
|
|
|
|
import com.glxp.udi.admin.entity.param.SystemParamConfigEntity;
|
|
|
|
import com.glxp.udi.admin.mongo.MongoDBName;
|
|
|
|
import com.glxp.udi.admin.mongo.MongoDBName;
|
|
|
|
import com.glxp.udi.admin.mongo.dao.OrderDao;
|
|
|
|
import com.glxp.udi.admin.mongo.dao.OrderMdDao;
|
|
|
|
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.DeleteRequest;
|
|
|
|
import com.glxp.udi.admin.req.inout.FilterErpOrderRequest;
|
|
|
|
import com.glxp.udi.admin.req.inout.FilterOrderDetailRequest;
|
|
|
|
import com.glxp.udi.admin.req.inout.OrderFilterRequest;
|
|
|
|
import com.glxp.udi.admin.req.inout.OrderFilterRequest;
|
|
|
|
import com.glxp.udi.admin.req.inventory.FilterInvProductRequest;
|
|
|
|
import com.glxp.udi.admin.req.inventory.FilterInvProductRequest;
|
|
|
|
import com.glxp.udi.admin.res.inout.OrderNoResult;
|
|
|
|
import com.glxp.udi.admin.res.inout.OrderNoResult;
|
|
|
|
import com.glxp.udi.admin.service.param.SystemParamConfigService;
|
|
|
|
import com.glxp.udi.admin.service.param.SystemParamConfigService;
|
|
|
|
import com.glxp.udi.admin.util.CustomUtil;
|
|
|
|
import com.glxp.udi.admin.util.CustomUtil;
|
|
|
|
import com.glxp.udi.admin.util.DateUtil;
|
|
|
|
|
|
|
|
import com.glxp.udi.common.util.ResultVOUtils;
|
|
|
|
import com.glxp.udi.common.util.ResultVOUtils;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
@ -46,7 +49,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
@Slf4j
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
public class OrderMdService {
|
|
|
|
public class OrderService {
|
|
|
|
|
|
|
|
|
|
|
|
@Lazy
|
|
|
|
@Lazy
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
@ -59,7 +62,7 @@ public class OrderMdService {
|
|
|
|
private WarehouseTempMdService warehouseTempMdService;
|
|
|
|
private WarehouseTempMdService warehouseTempMdService;
|
|
|
|
@Lazy
|
|
|
|
@Lazy
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private OrderDetailMdService orderDetailMdService;
|
|
|
|
private OrderDetailService orderDetailService;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private CustomerInfoDao customerInfoDao;
|
|
|
|
private CustomerInfoDao customerInfoDao;
|
|
|
@ -72,108 +75,70 @@ public class OrderMdService {
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private MongoTemplate mongoTemplate;
|
|
|
|
private MongoTemplate mongoTemplate;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private MongoPageHelper mongoPageHelper;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private BussinessTypeDao bussinessTypeDao;
|
|
|
|
private BussinessTypeDao bussinessTypeDao;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private OrderMdDao orderMdDao;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
private OrderDao orderDao;
|
|
|
|
private OrderDao orderDao;
|
|
|
|
|
|
|
|
|
|
|
|
public PageResult<OrderMdEntity> filterList(OrderFilterRequest orderFilterRequest) {
|
|
|
|
public IPage<OrderEntity> filterList(OrderFilterRequest orderFilterRequest) {
|
|
|
|
return orderDao.pageQuery(null, orderFilterRequest, orderFilterRequest.getPage(), orderFilterRequest.getLimit());
|
|
|
|
IPage<OrderEntity> page = new Page<>(orderFilterRequest.getPage(), orderFilterRequest.getLimit());
|
|
|
|
|
|
|
|
QueryWrapper<OrderEntity> wrapper = buildQueryWrapper(orderFilterRequest);
|
|
|
|
|
|
|
|
return orderDao.selectPage(page, wrapper);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 构造单据表查询条件
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param orderFilterRequest
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private static QueryWrapper<OrderEntity> buildQueryWrapper(OrderFilterRequest orderFilterRequest) {
|
|
|
|
|
|
|
|
QueryWrapper<OrderEntity> wrapper = new QueryWrapper<>();
|
|
|
|
|
|
|
|
wrapper.eq(StrUtil.isNotBlank(orderFilterRequest.getId()), "orderId", orderFilterRequest.getId())
|
|
|
|
|
|
|
|
.in(CollUtil.isNotEmpty(orderFilterRequest.getInvCodes()), "locStorageCode", orderFilterRequest.getInvCodes())
|
|
|
|
|
|
|
|
.le(StrUtil.isNotBlank(orderFilterRequest.getStartTime()), "actDate", orderFilterRequest.getStartTime())
|
|
|
|
|
|
|
|
.ge(StrUtil.isNotBlank(orderFilterRequest.getEndTime()), "actDate", orderFilterRequest.getEndTime())
|
|
|
|
|
|
|
|
.eq(StrUtil.isNotBlank(orderFilterRequest.getIsError()), "status", orderFilterRequest.getStatus())
|
|
|
|
|
|
|
|
.eq(StrUtil.isNotBlank(orderFilterRequest.getAction()), "action", orderFilterRequest.getAction())
|
|
|
|
|
|
|
|
.ne(StrUtil.isBlank(orderFilterRequest.getAction()), "action", orderFilterRequest.getAction())
|
|
|
|
|
|
|
|
.eq(StrUtil.isNotBlank(orderFilterRequest.getOrderId()), "orderId", orderFilterRequest.getOrderId())
|
|
|
|
|
|
|
|
.eq(StrUtil.isNotBlank(orderFilterRequest.getMainAction()), "mainAction", orderFilterRequest.getMainAction())
|
|
|
|
|
|
|
|
.eq(null != orderFilterRequest.getStatus(), "status", orderFilterRequest.getStatus())
|
|
|
|
|
|
|
|
.eq(StrUtil.isNotBlank(orderFilterRequest.getExportStatus()), "exportStatus", orderFilterRequest.getExportStatus())
|
|
|
|
|
|
|
|
.eq(null != orderFilterRequest.getCustomerId(), "customerId", orderFilterRequest.getCustomerId())
|
|
|
|
|
|
|
|
.eq(StrUtil.isNotBlank(orderFilterRequest.getCorpOrderId()), "corpOrderId", orderFilterRequest.getCorpOrderId())
|
|
|
|
|
|
|
|
.eq(null != orderFilterRequest.getReceiveStatus(), "receiveStatus", orderFilterRequest.getReceiveStatus());
|
|
|
|
|
|
|
|
return wrapper;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public OrderMdEntity findByOne(String orderId) {
|
|
|
|
public OrderEntity findByOne(String orderId) {
|
|
|
|
OrderFilterRequest orderFilterRequest = new OrderFilterRequest();
|
|
|
|
OrderFilterRequest orderFilterRequest = new OrderFilterRequest();
|
|
|
|
orderFilterRequest.setId(orderId);
|
|
|
|
orderFilterRequest.setId(orderId);
|
|
|
|
List<OrderMdEntity> orderMdEntities = findAll(orderFilterRequest);
|
|
|
|
List<OrderEntity> orderMdEntities = findAll(orderFilterRequest);
|
|
|
|
if (orderMdEntities != null && orderMdEntities.size() > 0) {
|
|
|
|
if (orderMdEntities != null && orderMdEntities.size() > 0) {
|
|
|
|
return orderMdEntities.get(0);
|
|
|
|
return orderMdEntities.get(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<OrderMdEntity> findAll(OrderFilterRequest orderFilterRequest) {
|
|
|
|
public List<OrderEntity> findAll(OrderFilterRequest orderFilterRequest) {
|
|
|
|
Query query = new Query();
|
|
|
|
QueryWrapper<OrderEntity> wrapper = buildQueryWrapper(orderFilterRequest);
|
|
|
|
if (orderFilterRequest.getId() != null && !orderFilterRequest.getId().isEmpty()) {
|
|
|
|
return orderDao.selectList(wrapper);
|
|
|
|
query.addCriteria(Criteria.where("orderId").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 (null != orderFilterRequest.getStatus()) {
|
|
|
|
|
|
|
|
query.addCriteria(Criteria.where("status").is(orderFilterRequest.getStatus()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (orderFilterRequest.getExportStatus() != null && !orderFilterRequest.getExportStatus().isEmpty()) {
|
|
|
|
|
|
|
|
query.addCriteria(Criteria.where("exportStatus").is(orderFilterRequest.getExportStatus()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StrUtil.isNotBlank(orderFilterRequest.getCorpOrderId())) {
|
|
|
|
|
|
|
|
query.addCriteria(Criteria.where("corpOrderId").is(orderFilterRequest.getCorpOrderId()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (orderFilterRequest.getReceiveStatus() != null) {
|
|
|
|
|
|
|
|
query.addCriteria(Criteria.where("receiveStatus").is(orderFilterRequest.getReceiveStatus()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return mongoTemplate.find(query, OrderMdEntity.class, MongoDBName.NAME_ORDER);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void updateOrder(OrderMdEntity orderMdEntity) {
|
|
|
|
public void updateOrder(OrderEntity orderEntity) {
|
|
|
|
Query query = new Query();
|
|
|
|
orderDao.updateById(orderEntity);
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
orderDao.update(query, null, orderMdEntity);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void deleteOrder(DeleteRequest deleteRequest) {
|
|
|
|
public void deleteOrder(DeleteRequest deleteRequest) {
|
|
|
|
Query query = new Query();
|
|
|
|
String orderId = StrUtil.isBlank(deleteRequest.getId()) ? deleteRequest.getOrderId() : deleteRequest.getId();
|
|
|
|
if (deleteRequest.getId() != null) {
|
|
|
|
orderDao.deleteById(orderId);
|
|
|
|
query.addCriteria(Criteria.where("id").is(deleteRequest.getId()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (deleteRequest.getOrderId() != null) {
|
|
|
|
|
|
|
|
query.addCriteria(Criteria.where("orderId").is(deleteRequest.getOrderId()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
orderDao.delete(query, null);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void insertOrder(OrderMdEntity orderMdEntity) {
|
|
|
|
public void insertOrder(OrderEntity orderEntity) {
|
|
|
|
orderDao.insert(orderMdEntity);
|
|
|
|
orderDao.insert(orderEntity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -183,10 +148,10 @@ public class OrderMdService {
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public long countByAction(String action) {
|
|
|
|
public long countByAction(String action) {
|
|
|
|
Query query = new Query();
|
|
|
|
|
|
|
|
if (StrUtil.isNotBlank(action)) {
|
|
|
|
if (StrUtil.isNotBlank(action)) {
|
|
|
|
query.addCriteria(Criteria.where("action").is(action));
|
|
|
|
QueryWrapper<OrderEntity> wrapper = new QueryWrapper<>();
|
|
|
|
return orderDao.count(query, null);
|
|
|
|
wrapper.eq(StrUtil.isNotBlank(action), "action", action);
|
|
|
|
|
|
|
|
orderDao.selectCount(wrapper);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -194,22 +159,22 @@ public class OrderMdService {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 补单
|
|
|
|
* 补单
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param orderMdEntity
|
|
|
|
* @param orderEntity
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public BaseResponse supplementOrder(OrderMdEntity orderMdEntity) {
|
|
|
|
public BaseResponse supplementOrder(OrderEntity orderEntity) {
|
|
|
|
//查询此单据是否可以补单
|
|
|
|
//查询此单据是否可以补单
|
|
|
|
String supplementTypeAction = bussinessTypeDao.selectSupplementTypeByAction(orderMdEntity.getAction());
|
|
|
|
String supplementTypeAction = bussinessTypeDao.selectSupplementTypeByAction(orderEntity.getAction());
|
|
|
|
if (StrUtil.isBlank(supplementTypeAction)) {
|
|
|
|
if (StrUtil.isBlank(supplementTypeAction)) {
|
|
|
|
return ResultVOUtils.error(500, "此类型单据不可补单");
|
|
|
|
return ResultVOUtils.error(500, "此类型单据不可补单");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//拷贝生成补单数据
|
|
|
|
//拷贝生成补单数据
|
|
|
|
OrderMdEntity supplementOrder = new OrderMdEntity();
|
|
|
|
OrderEntity supplementOrder = new OrderEntity();
|
|
|
|
BeanUtil.copyProperties(orderMdEntity, supplementOrder);
|
|
|
|
BeanUtil.copyProperties(orderEntity, supplementOrder);
|
|
|
|
//生成补单单号
|
|
|
|
//生成补单单号
|
|
|
|
String supplementOrderNo = "SM" + CustomUtil.getId();
|
|
|
|
String supplementOrderNo = "SM" + CustomUtil.getId();
|
|
|
|
supplementOrder.setSupplementNo(orderMdEntity.getOrderId());
|
|
|
|
supplementOrder.setSupplementNo(orderEntity.getOrderId());
|
|
|
|
supplementOrder.setOrderId(supplementOrderNo);
|
|
|
|
supplementOrder.setOrderId(supplementOrderNo);
|
|
|
|
supplementOrder.setCorpOrderId(CustomUtil.getId()); //生成一个新的来源ID
|
|
|
|
supplementOrder.setCorpOrderId(CustomUtil.getId()); //生成一个新的来源ID
|
|
|
|
|
|
|
|
|
|
|
@ -225,8 +190,8 @@ public class OrderMdService {
|
|
|
|
supplementOrder.setUploadStatus("0"); //设置上传状态为未上传
|
|
|
|
supplementOrder.setUploadStatus("0"); //设置上传状态为未上传
|
|
|
|
|
|
|
|
|
|
|
|
//修改往来单位及库存号
|
|
|
|
//修改往来单位及库存号
|
|
|
|
supplementOrder.setFromCorpId(orderMdEntity.getLocStorageCode());
|
|
|
|
supplementOrder.setFromCorpId(orderEntity.getLocStorageCode());
|
|
|
|
supplementOrder.setLocStorageCode(orderMdEntity.getFromCorpId());
|
|
|
|
supplementOrder.setLocStorageCode(orderEntity.getFromCorpId());
|
|
|
|
String name = invWarehouseDao.getNameByCode(supplementOrder.getFromCorpId());
|
|
|
|
String name = invWarehouseDao.getNameByCode(supplementOrder.getFromCorpId());
|
|
|
|
supplementOrder.setFromCorp(name);
|
|
|
|
supplementOrder.setFromCorp(name);
|
|
|
|
supplementOrder.setFromType("平衡补单");
|
|
|
|
supplementOrder.setFromType("平衡补单");
|
|
|
@ -237,10 +202,10 @@ public class OrderMdService {
|
|
|
|
supplementOrder.setAction(supplementType.getAction());
|
|
|
|
supplementOrder.setAction(supplementType.getAction());
|
|
|
|
|
|
|
|
|
|
|
|
//复制码表
|
|
|
|
//复制码表
|
|
|
|
List<WarehouseEntity> codes = warehouseMdService.findByOrderId(orderMdEntity.getOrderId());
|
|
|
|
List<WarehouseMdEntity> codes = warehouseMdService.findByOrderId(orderEntity.getOrderId());
|
|
|
|
List<WarehousetempEntity> supplementCodes = new ArrayList<>(codes.size());
|
|
|
|
List<WarehousetempMdEntity> supplementCodes = new ArrayList<>(codes.size());
|
|
|
|
codes.forEach(code -> {
|
|
|
|
codes.forEach(code -> {
|
|
|
|
WarehousetempEntity supplementCode = new WarehousetempEntity();
|
|
|
|
WarehousetempMdEntity supplementCode = new WarehousetempEntity();
|
|
|
|
BeanUtil.copyProperties(code, supplementCode);
|
|
|
|
BeanUtil.copyProperties(code, supplementCode);
|
|
|
|
supplementCode.setFromCorpId(supplementOrder.getFromCorpId());
|
|
|
|
supplementCode.setFromCorpId(supplementOrder.getFromCorpId());
|
|
|
|
supplementCode.setFromCorp(supplementOrder.getFromCorp());
|
|
|
|
supplementCode.setFromCorp(supplementOrder.getFromCorp());
|
|
|
@ -257,8 +222,8 @@ public class OrderMdService {
|
|
|
|
supplementOrder.setId(null);
|
|
|
|
supplementOrder.setId(null);
|
|
|
|
insertOrder(supplementOrder);
|
|
|
|
insertOrder(supplementOrder);
|
|
|
|
//更新配货单表对应的单据补单号
|
|
|
|
//更新配货单表对应的单据补单号
|
|
|
|
orderMdEntity.setSupplementNo(supplementOrderNo);
|
|
|
|
orderEntity.setSupplementNo(supplementOrderNo);
|
|
|
|
updateOrder(orderMdEntity);
|
|
|
|
updateOrder(orderEntity);
|
|
|
|
warehouseTempMdService.insertTempWarehouses(supplementCodes);
|
|
|
|
warehouseTempMdService.insertTempWarehouses(supplementCodes);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.error("补单数据插入失败", e);
|
|
|
|
log.error("补单数据插入失败", e);
|
|
|
@ -271,12 +236,11 @@ public class OrderMdService {
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public List<OrderMdEntity> getSupplementOrderBillNoList() {
|
|
|
|
public List<OrderEntity> getSupplementOrderBillNoList() {
|
|
|
|
//查询补单单号为空,且单据状态为已完成的单据
|
|
|
|
//查询补单单号为空,且单据状态为已完成的单据
|
|
|
|
Query query = new Query();
|
|
|
|
QueryWrapper<OrderEntity> wrapper = new QueryWrapper<>();
|
|
|
|
query.addCriteria(Criteria.where("supplementNo").is(null));
|
|
|
|
wrapper.isNull("supplementNo").eq("status", ConstantStatus.ORDER_STATUS_SUCCESS);
|
|
|
|
query.addCriteria(Criteria.where("status").is(ConstantStatus.ORDER_STATUS_SUCCESS));
|
|
|
|
return orderDao.selectList(wrapper);
|
|
|
|
return mongoTemplate.find(query, OrderMdEntity.class, MongoDBName.NAME_ORDER);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -285,7 +249,7 @@ public class OrderMdService {
|
|
|
|
* @param order
|
|
|
|
* @param order
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public boolean checkUpload(OrderMdEntity order) {
|
|
|
|
public boolean checkUpload(OrderEntity order) {
|
|
|
|
//查询此往来单位的本地单据类型
|
|
|
|
//查询此往来单位的本地单据类型
|
|
|
|
Integer count = unitMaintainDao.checkUpload(order.getCustomerId(), order.getAction());
|
|
|
|
Integer count = unitMaintainDao.checkUpload(order.getCustomerId(), order.getAction());
|
|
|
|
if (count > 0) {
|
|
|
|
if (count > 0) {
|
|
|
@ -302,14 +266,14 @@ public class OrderMdService {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public List<StockOrderPrintEntity> listOrderPrint(String orderId) {
|
|
|
|
public List<StockOrderPrintEntity> listOrderPrint(String orderId) {
|
|
|
|
List<StockOrderPrintEntity> list = new ArrayList<>(1);
|
|
|
|
List<StockOrderPrintEntity> list = new ArrayList<>(1);
|
|
|
|
OrderMdEntity orderMdEntity = findByOne(orderId);
|
|
|
|
OrderEntity orderEntity = findByOne(orderId);
|
|
|
|
if (null != orderMdEntity) {
|
|
|
|
if (null != orderEntity) {
|
|
|
|
//查询单据详情
|
|
|
|
//查询单据详情
|
|
|
|
FilterErpOrderRequest detailRequest = new FilterErpOrderRequest();
|
|
|
|
FilterOrderDetailRequest detailRequest = new FilterOrderDetailRequest();
|
|
|
|
detailRequest.setOrderId(orderId);
|
|
|
|
detailRequest.setOrderId(orderId);
|
|
|
|
|
|
|
|
|
|
|
|
List<OrderDetailEntity> erpOrderEntities = orderDetailMdService.filterOrderDetails(detailRequest);
|
|
|
|
List<OrderDetailEntity> erpOrderEntities = orderDetailService.filterOrderDetails(detailRequest);
|
|
|
|
CustomerInfoEntity customerInfoEntity = customerInfoDao.selectById(orderMdEntity.getCustomerId());
|
|
|
|
CustomerInfoEntity customerInfoEntity = customerInfoDao.selectById(orderEntity.getCustomerId());
|
|
|
|
String customerId = String.valueOf(customerInfoEntity.getCustomerId());
|
|
|
|
String customerId = String.valueOf(customerInfoEntity.getCustomerId());
|
|
|
|
erpOrderEntities.forEach(erpOrderEntity -> {
|
|
|
|
erpOrderEntities.forEach(erpOrderEntity -> {
|
|
|
|
//查询产品批次
|
|
|
|
//查询产品批次
|
|
|
@ -317,13 +281,13 @@ public class OrderMdService {
|
|
|
|
printEntity.setBatchNo(erpOrderEntity.getBatchNo()); //批次号
|
|
|
|
printEntity.setBatchNo(erpOrderEntity.getBatchNo()); //批次号
|
|
|
|
printEntity.setProductId(erpOrderEntity.getNameCode()); //产品ID
|
|
|
|
printEntity.setProductId(erpOrderEntity.getNameCode()); //产品ID
|
|
|
|
printEntity.setCorpId(customerId); //本企业ID
|
|
|
|
printEntity.setCorpId(customerId); //本企业ID
|
|
|
|
printEntity.setCorpName(orderMdEntity.getFromCorp()); //往来单位名称
|
|
|
|
printEntity.setCorpName(orderEntity.getFromCorp()); //往来单位名称
|
|
|
|
printEntity.setBillType(orderMdEntity.getAction()); //单据类型编码
|
|
|
|
printEntity.setBillType(orderEntity.getAction()); //单据类型编码
|
|
|
|
printEntity.setCount(String.valueOf(erpOrderEntity.getCount())); //数量
|
|
|
|
printEntity.setCount(String.valueOf(erpOrderEntity.getCount())); //数量
|
|
|
|
printEntity.setUnitIdFk(orderMdEntity.getFromCorpId());//往来单位ID
|
|
|
|
printEntity.setUnitIdFk(orderEntity.getFromCorpId());//往来单位ID
|
|
|
|
printEntity.setPrice(erpOrderEntity.getPrice());//金额
|
|
|
|
printEntity.setPrice(erpOrderEntity.getPrice());//金额
|
|
|
|
printEntity.setBillNo(orderMdEntity.getOrderId()); //单号
|
|
|
|
printEntity.setBillNo(orderEntity.getOrderId()); //单号
|
|
|
|
printEntity.setBilldate(orderMdEntity.getActDate()); //单据日期
|
|
|
|
printEntity.setBilldate(orderEntity.getActDate()); //单据日期
|
|
|
|
printEntity.setZczbhhzbapzbh(erpOrderEntity.getZczbhhzbapzbh()); //注册/备案证号
|
|
|
|
printEntity.setZczbhhzbapzbh(erpOrderEntity.getZczbhhzbapzbh()); //注册/备案证号
|
|
|
|
printEntity.setSpec(erpOrderEntity.getGgxh()); //规格型号
|
|
|
|
printEntity.setSpec(erpOrderEntity.getGgxh()); //规格型号
|
|
|
|
printEntity.setTitle(customerInfoEntity.getCompanyName()); //企业名称,单据抬头
|
|
|
|
printEntity.setTitle(customerInfoEntity.getCompanyName()); //企业名称,单据抬头
|
|
|
@ -332,12 +296,12 @@ public class OrderMdService {
|
|
|
|
invProductRequest.setBatchNo(erpOrderEntity.getBatchNo());
|
|
|
|
invProductRequest.setBatchNo(erpOrderEntity.getBatchNo());
|
|
|
|
invProductRequest.setRelIdFk(erpOrderEntity.getUuidFk());
|
|
|
|
invProductRequest.setRelIdFk(erpOrderEntity.getUuidFk());
|
|
|
|
invProductRequest.setCustomerId(customerId);
|
|
|
|
invProductRequest.setCustomerId(customerId);
|
|
|
|
invProductRequest.setInvCodes(Arrays.asList(orderMdEntity.getLocStorageCode()));
|
|
|
|
invProductRequest.setInvCodes(Arrays.asList(orderEntity.getLocStorageCode()));
|
|
|
|
invProductRequest.setPage(1);
|
|
|
|
invProductRequest.setPage(1);
|
|
|
|
invProductRequest.setLimit(100);
|
|
|
|
invProductRequest.setLimit(100);
|
|
|
|
UdiInfoEntity udiInfoEntity = udiInfoDao.findByUuid(erpOrderEntity.getUuidFk(), String.valueOf(orderMdEntity.getCustomerId()));
|
|
|
|
UdiInfoEntity udiInfoEntity = udiInfoDao.findByUuid(erpOrderEntity.getUuidFk(), String.valueOf(orderEntity.getCustomerId()));
|
|
|
|
printEntity.setManufactory(udiInfoEntity.getManufactory()); //生产厂家
|
|
|
|
printEntity.setManufactory(udiInfoEntity.getManufactory()); //生产厂家
|
|
|
|
printEntity.setLocInv(invWarehouseDao.getNameByCode(orderMdEntity.getLocStorageCode()));
|
|
|
|
printEntity.setLocInv(invWarehouseDao.getNameByCode(orderEntity.getLocStorageCode()));
|
|
|
|
printEntity.setProductName(erpOrderEntity.getProductName()); //产品名称
|
|
|
|
printEntity.setProductName(erpOrderEntity.getProductName()); //产品名称
|
|
|
|
printEntity.setProductDate(erpOrderEntity.getProduceDate()); //生产日期
|
|
|
|
printEntity.setProductDate(erpOrderEntity.getProduceDate()); //生产日期
|
|
|
|
printEntity.setExpireDate(erpOrderEntity.getExpireDate()); //失效日期
|
|
|
|
printEntity.setExpireDate(erpOrderEntity.getExpireDate()); //失效日期
|
|
|
@ -354,54 +318,54 @@ public class OrderMdService {
|
|
|
|
* @param unitMaintainEntity
|
|
|
|
* @param unitMaintainEntity
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public List<OrderMdEntity> findWaitUploadOrders(UnitMaintainEntity unitMaintainEntity) {
|
|
|
|
public List<OrderEntity> findWaitUploadOrders(UnitMaintainEntity unitMaintainEntity) {
|
|
|
|
Query query = new Query();
|
|
|
|
QueryWrapper<OrderEntity> wrapper = new QueryWrapper();
|
|
|
|
//查询已完成单据
|
|
|
|
//查询已完成单据
|
|
|
|
query.addCriteria(Criteria.where("status").is(ConstantStatus.ORDER_STATUS_SUCCESS))
|
|
|
|
wrapper.eq("status", ConstantStatus.ORDER_STATUS_SUCCESS)
|
|
|
|
//查询未上传单据
|
|
|
|
//查询未上传单据
|
|
|
|
.addCriteria(Criteria.where("uploadStatus").ne("1"))
|
|
|
|
.ne("uploadStatus", "1")
|
|
|
|
//客户ID
|
|
|
|
//客户ID
|
|
|
|
.addCriteria(Criteria.where("customerId").is(Long.valueOf(unitMaintainEntity.getCustomerId())))
|
|
|
|
.eq("customerId", unitMaintainEntity.getCustomerId())
|
|
|
|
//本地单据类型
|
|
|
|
//本地单据类型
|
|
|
|
.addCriteria(Criteria.where("action").is(unitMaintainEntity.getSourceAction()));
|
|
|
|
.eq("action", unitMaintainEntity.getSourceAction());
|
|
|
|
return orderDao.findList(query, null);
|
|
|
|
|
|
|
|
|
|
|
|
return orderDao.selectList(wrapper);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<OrderMdEntity> filterForDelete(String orderId) {
|
|
|
|
public List<OrderEntity> filterForDelete(String orderId) {
|
|
|
|
Query query = new Query();
|
|
|
|
QueryWrapper<OrderEntity> wrapper = new QueryWrapper<>();
|
|
|
|
query.addCriteria(Criteria.where("orderId").is(orderId));
|
|
|
|
wrapper.eq("orderId", orderId).eq("status", ConstantStatus.ORDER_STATUS_SUCCESS);
|
|
|
|
query.addCriteria(Criteria.where("status").is(ConstantStatus.ORDER_STATUS_SUCCESS)); //查询已完成单据
|
|
|
|
OrderEntity orderEntity = orderDao.selectOne(wrapper);
|
|
|
|
OrderMdEntity order = mongoTemplate.findOne(query, OrderMdEntity.class, MongoDBName.NAME_ORDER);
|
|
|
|
if (null == orderEntity) {
|
|
|
|
if (null == order) {
|
|
|
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return getAllOrder(order);
|
|
|
|
return getAllOrder(orderEntity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<OrderMdEntity> getAllOrder(OrderMdEntity orderMdEntity) {
|
|
|
|
public List<OrderEntity> getAllOrder(OrderEntity orderEntity) {
|
|
|
|
Set<String> orderIds = new HashSet<>();
|
|
|
|
Set<String> orderIds = new HashSet<>();
|
|
|
|
orderIds.add(orderMdEntity.getOrderId());
|
|
|
|
orderIds.add(orderEntity.getOrderId());
|
|
|
|
|
|
|
|
|
|
|
|
getLinkedOrderId(orderMdEntity.getOrderId(), orderIds);
|
|
|
|
getLinkedOrderId(orderEntity.getOrderId(), orderIds);
|
|
|
|
|
|
|
|
|
|
|
|
//去除查询参数的单据号
|
|
|
|
//去除查询参数的单据号
|
|
|
|
Iterator<String> iterator = orderIds.iterator();
|
|
|
|
Iterator<String> iterator = orderIds.iterator();
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
if (iterator.next().equals(orderMdEntity.getOrderId())) {
|
|
|
|
if (iterator.next().equals(orderEntity.getOrderId())) {
|
|
|
|
iterator.remove();
|
|
|
|
iterator.remove();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<OrderMdEntity> orders = new ArrayList<>();
|
|
|
|
List<OrderEntity> orders = new ArrayList<>();
|
|
|
|
orders.add(orderMdEntity);
|
|
|
|
orders.add(orderEntity);
|
|
|
|
|
|
|
|
|
|
|
|
//查询除本单以外的所有单据
|
|
|
|
//查询除本单以外的所有单据
|
|
|
|
if (CollUtil.isNotEmpty(orderIds)) {
|
|
|
|
if (CollUtil.isNotEmpty(orderIds)) {
|
|
|
|
Query query = new Query();
|
|
|
|
QueryWrapper<OrderEntity> wrapper = new QueryWrapper<>();
|
|
|
|
query.addCriteria(Criteria.where("orderId").in(orderIds));
|
|
|
|
wrapper.in("orderId", orderIds);
|
|
|
|
List<OrderMdEntity> orderMdEntities = mongoTemplate.find(query, OrderMdEntity.class, MongoDBName.NAME_ORDER);
|
|
|
|
List<OrderEntity> orderEntities = orderDao.selectList(wrapper);
|
|
|
|
orders.addAll(orderMdEntities);
|
|
|
|
orders.addAll(orderEntities);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return orders;
|
|
|
|
return orders;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -426,9 +390,7 @@ public class OrderMdService {
|
|
|
|
//通过单号获取此单据所有的单号字段值
|
|
|
|
//通过单号获取此单据所有的单号字段值
|
|
|
|
public List<String> getOneOrderById(String orderId) {
|
|
|
|
public List<String> getOneOrderById(String orderId) {
|
|
|
|
List<String> orderIds = new ArrayList<>();
|
|
|
|
List<String> orderIds = new ArrayList<>();
|
|
|
|
Query query = new Query();
|
|
|
|
OrderNoResult orderNo = orderDao.selectNos(orderId);
|
|
|
|
query.addCriteria(Criteria.where("orderId").is(orderId));
|
|
|
|
|
|
|
|
OrderNoResult orderNo = mongoTemplate.findOne(query, OrderNoResult.class, MongoDBName.NAME_ORDER);
|
|
|
|
|
|
|
|
if (orderNo == null) {
|
|
|
|
if (orderNo == null) {
|
|
|
|
return orderIds;
|
|
|
|
return orderIds;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -454,10 +416,8 @@ public class OrderMdService {
|
|
|
|
* @param orderId
|
|
|
|
* @param orderId
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public OrderMdEntity findById(String orderId) {
|
|
|
|
public OrderEntity findById(String orderId) {
|
|
|
|
Query query = new Query();
|
|
|
|
return orderDao.selectById(orderId);
|
|
|
|
query.addCriteria(Criteria.where("orderId").is(orderId));
|
|
|
|
|
|
|
|
return mongoTemplate.findOne(query, OrderMdEntity.class, MongoDBName.NAME_ORDER);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -467,20 +427,8 @@ public class OrderMdService {
|
|
|
|
* @param replicateNo
|
|
|
|
* @param replicateNo
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public boolean updateReplicateNo(String orderId, String replicateNo) {
|
|
|
|
public void updateReplicateNo(String orderId, String replicateNo) {
|
|
|
|
//构造查询条件
|
|
|
|
orderDao.updateReplicateNo(replicateNo, orderId);
|
|
|
|
Query query = new Query();
|
|
|
|
|
|
|
|
query.addCriteria(Criteria.where("orderId").is(orderId));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Update update = new Update();
|
|
|
|
|
|
|
|
update.set("replicateNo", replicateNo);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
mongoTemplate.updateMulti(query, update, MongoDBName.NAME_ORDER);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
log.error("更新 {} 单据的复制单据号失败", orderId, e);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -581,81 +529,11 @@ public class OrderMdService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void updateOrderInfo(String actDate, List<String> orderIds) {
|
|
|
|
public void updateOrderInfo(String actDate, List<String> orderIds) {
|
|
|
|
if (CollUtil.isNotEmpty(orderIds)) {
|
|
|
|
orderDao.updateActDate(actDate, orderIds);
|
|
|
|
//构造查询条件
|
|
|
|
|
|
|
|
Query query = new Query();
|
|
|
|
|
|
|
|
query.addCriteria(Criteria.where("orderId").in(orderIds));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Update update = new Update();
|
|
|
|
|
|
|
|
update.set("actDate", actDate);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
//更新单据表
|
|
|
|
|
|
|
|
mongoTemplate.updateMulti(query, update, OrderMdEntity.class, MongoDBName.NAME_ORDER);
|
|
|
|
|
|
|
|
//更新码表
|
|
|
|
|
|
|
|
mongoTemplate.updateMulti(query, update, WarehouseEntity.class, MongoDBName.NAME_CODE);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
log.error("更新单据时间异常", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void deleteById(String id) {
|
|
|
|
public void deleteById(String id) {
|
|
|
|
Query query = new Query();
|
|
|
|
orderDao.deleteById(id);
|
|
|
|
query.addCriteria(Criteria.where("id").is(id));
|
|
|
|
|
|
|
|
mongoTemplate.remove(query, OrderMdEntity.class, MongoDBName.NAME_ORDER);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public PageResult<OrderMdEntity> findByPage(OrderFilterRequest orderFilterRequest) {
|
|
|
|
|
|
|
|
Query query = new Query();
|
|
|
|
|
|
|
|
if (orderFilterRequest.getId() != null && !orderFilterRequest.getId().isEmpty()) {
|
|
|
|
|
|
|
|
query.addCriteria(Criteria.where("orderId").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 (null != orderFilterRequest.getStatus()) {
|
|
|
|
|
|
|
|
query.addCriteria(Criteria.where("status").is(orderFilterRequest.getStatus()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (orderFilterRequest.getExportStatus() != null && !orderFilterRequest.getExportStatus().isEmpty()) {
|
|
|
|
|
|
|
|
query.addCriteria(Criteria.where("exportStatus").is(orderFilterRequest.getExportStatus()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StrUtil.isNotBlank(orderFilterRequest.getCorpOrderId())) {
|
|
|
|
|
|
|
|
query.addCriteria(Criteria.where("corpOrderId").is(orderFilterRequest.getCorpOrderId()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (orderFilterRequest.getReceiveStatus() != null) {
|
|
|
|
|
|
|
|
query.addCriteria(Criteria.where("receiveStatus").is(orderFilterRequest.getReceiveStatus()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return mongoPageHelper.pageQuery(query, OrderMdEntity.class, orderFilterRequest.getPage(), orderFilterRequest.getLimit(), MongoDBName.NAME_ORDER);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|