1.完成数据库迁移,添加复制数据接口和刷新码表关联ID接口

master
x_z 3 years ago
parent 99c25cee34
commit fa7500b0f6

@ -2,19 +2,13 @@ package com.glxp.udi.admin.controller;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.glxp.udi.admin.dao.inout.*;
import com.glxp.udi.admin.dao.inout.UdiInfoDao;
import com.glxp.udi.admin.entity.inout.*; import com.glxp.udi.admin.entity.inout.*;
import com.glxp.udi.admin.entity.inout.WarehousetempEntity;
import com.glxp.udi.admin.entity.mongo.*; import com.glxp.udi.admin.entity.mongo.*;
import com.glxp.udi.admin.mongo.dao.*; import com.glxp.udi.admin.mongo.dao.*;
import com.glxp.udi.admin.mongo.service.InvProductDetailService; import com.glxp.udi.admin.service.inout.OrderDetailService;
import com.glxp.udi.admin.mongo.service.InvProductService;
import com.glxp.udi.admin.mongo.service.OrderDetailService;
import com.glxp.udi.admin.req.inout.FilterOrderDetailRequest;
import com.glxp.udi.admin.req.inout.FilterInvProductDetailRequest;
import com.glxp.udi.admin.req.inventory.FilterInvProductRequest;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -22,6 +16,9 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
/**
* todo 线
*/
@Slf4j @Slf4j
@RestController @RestController
public class TestController { public class TestController {
@ -29,10 +26,6 @@ public class TestController {
@Resource @Resource
private OrderDetailService orderDetailService; private OrderDetailService orderDetailService;
@Resource @Resource
private InvProductService invProductService;
@Resource
private InvProductDetailService invProductDetailService;
@Resource
private UdiInfoDao udiInfoDao; private UdiInfoDao udiInfoDao;
//mongodb dao //mongodb dao
@ -51,71 +44,46 @@ public class TestController {
//mysql dao //mysql dao
@Resource @Resource
private com.glxp.udi.admin.dao.inout.OrderDao orderDao; private OrderDao orderDao;
@Resource @Resource
private com.glxp.udi.admin.dao.inout.OrderDetailDao orderDetailDao; private OrderDetailDao orderDetailDao;
@Resource @Resource
private com.glxp.udi.admin.dao.inout.CodesDao codesDao; private CodesDao codesDao;
@Resource @Resource
private com.glxp.udi.admin.dao.inout.CodesTempDao codesTempDao; private CodesTempDao codesTempDao;
@Resource @Resource
private com.glxp.udi.admin.dao.inout.InvProductDao invProductDao; private InvProductDao invProductDao;
@Resource @Resource
private com.glxp.udi.admin.dao.inout.InvProductDetailDao invProductDetailDao; private InvProductDetailDao invProductDetailDao;
/**
* relIdID
*
* @return
*/
@GetMapping("/test/refreshOrderData") @GetMapping("/test/refreshOrderData")
private String refreshOrderData() { private String refreshOrderData() {
try { try {
//刷新订单详情表的数据 //刷新码详情数据
List<OrderDetailEntity> erpOrderEntities = orderDetailService.filterOrderDetails(new FilterOrderDetailRequest()); List<WarehouseEntity> warehouseEntities = codesDao.selectList(null);
/*erpOrderEntities.forEach(orderDetail -> { warehouseEntities.forEach(code -> {
String orderId = orderDetail.getOrderIdFk(); UdiInfoEntity udiInfoEntity = udiInfoDao.selectById(code.getRelId());
if (StrUtil.isNotBlank(orderId)) { code.setRelId(udiInfoEntity.getUuid());
OrderMdEntity order = orderMdService.findByOne(orderId); codesDao.updateById(code);
if (null != order) {
UdiInfoEntity udiInfoEntity = udiInfoDao.selectOne(new QueryWrapper<UdiInfoEntity>().eq(StrUtil.isNotBlank(orderDetail.getUuidFk()), "uuid", orderDetail.getUuidFk())
.eq(null != order.getCustomerId(), "customerId", order.getCustomerId())
.eq(StrUtil.isNotBlank(orderDetail.getPackSpec()), "ggxh", orderDetail.getPackSpec())
);
if (udiInfoEntity != null) {
orderDetail.setRelId(String.valueOf(udiInfoEntity.getId()));
log.info("刷新单据详情");
orderDetailMdService.updateOrderDetail(orderDetail);
}
}
}
});*/
//刷新库存表的数据
List<InvProductEntity> invProductEntities = invProductService.filterInvProductList(new FilterInvProductRequest());
invProductEntities.forEach(invProductEntity -> {
UdiInfoEntity udiInfoEntity = udiInfoDao.selectOne(new QueryWrapper<UdiInfoEntity>().eq(StrUtil.isNotBlank(invProductEntity.getRelIdFk()), "uuid", invProductEntity.getRelIdFk())
.eq(StrUtil.isNotBlank(invProductEntity.getCustomerId()), "customerId", invProductEntity.getCustomerId())
.eq(StrUtil.isNotBlank(invProductEntity.getGgxh()), "ggxh", invProductEntity.getGgxh())
);
if (null != udiInfoEntity) {
invProductEntity.setRelIdFk(String.valueOf(udiInfoEntity.getId()));
log.info("刷新库存");
invProductService.updateInvProduct(invProductEntity);
}
}); });
//刷新库存详情表数据 //刷新临时码表
List<InvProductDetailEntity> invProductDetailEntities = invProductDetailService.filterAllInvProduct(new FilterInvProductDetailRequest()); List<WarehousetempEntity> warehousetempEntities = codesTempDao.selectList(null);
invProductDetailEntities.forEach(invProductDetailEntity -> { warehousetempEntities.forEach(codesTemp -> {
UdiInfoEntity udiInfoEntity = udiInfoDao.selectOne(new QueryWrapper<UdiInfoEntity>().eq(StrUtil.isNotBlank(invProductDetailEntity.getProductIdFk()), "uuid", invProductDetailEntity.getProductIdFk()) UdiInfoEntity udiInfoEntity = udiInfoDao.selectById(codesTemp.getRelId());
.eq(StrUtil.isNotBlank(invProductDetailEntity.getCustomerId()), "customerId", invProductDetailEntity.getCustomerId()) codesTemp.setRelId(udiInfoEntity.getUuid());
); codesTempDao.updateById(codesTemp);
if (null != udiInfoEntity) {
invProductDetailEntity.setProductIdFk(String.valueOf(udiInfoEntity.getId()));
log.info("刷新库存详情");
invProductDetailService.updateInvProduct(invProductDetailEntity);
}
}); });
return "success"; return "success";
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); log.error(e.getMessage(), e);
} }
return "error"; return "error";
} }
@ -148,6 +116,8 @@ public class TestController {
BeanUtil.copyProperties(orderMdDetail, orderDetailEntity, "id"); BeanUtil.copyProperties(orderMdDetail, orderDetailEntity, "id");
orderDetailEntity.setBatchNo(orderMdDetail.getLotno()); orderDetailEntity.setBatchNo(orderMdDetail.getLotno());
orderDetailEntity.setProductName(orderMdDetail.getCoName()); orderDetailEntity.setProductName(orderMdDetail.getCoName());
orderDetailEntity.setZczbhhzbapzbh(orderMdDetail.getAuthCode());
orderDetailEntity.setGgxh(orderMdDetail.getPackSpec());
orderDetailDao.insert(orderDetailEntity); orderDetailDao.insert(orderDetailEntity);
}); });
} }
@ -159,6 +129,10 @@ public class TestController {
codesList.forEach(code -> { codesList.forEach(code -> {
WarehouseEntity warehouseEntity = new WarehouseEntity(); WarehouseEntity warehouseEntity = new WarehouseEntity();
BeanUtil.copyProperties(code, warehouseEntity, "id"); BeanUtil.copyProperties(code, warehouseEntity, "id");
String actDate = warehouseEntity.getActDate();
String date = DateUtil.parse(actDate).toString("yyyy-MM-dd HH:mm:ss");
warehouseEntity.setActDate(date);
warehouseEntity.setNameCode(code.getUdi());
codesDao.insert(warehouseEntity); codesDao.insert(warehouseEntity);
}); });
} }
@ -170,6 +144,7 @@ public class TestController {
codesTempList.forEach(codesTemp -> { codesTempList.forEach(codesTemp -> {
WarehousetempEntity warehousetempEntity = new WarehousetempEntity(); WarehousetempEntity warehousetempEntity = new WarehousetempEntity();
BeanUtil.copyProperties(codesTemp, warehousetempEntity, "id"); BeanUtil.copyProperties(codesTemp, warehousetempEntity, "id");
warehousetempEntity.setNameCode(codesTemp.getUdi());
codesTempDao.insert(warehousetempEntity); codesTempDao.insert(warehousetempEntity);
}); });
} }
@ -181,6 +156,9 @@ public class TestController {
invList.forEach(inv -> { invList.forEach(inv -> {
InvProductEntity invProductEntity = new InvProductEntity(); InvProductEntity invProductEntity = new InvProductEntity();
BeanUtil.copyProperties(inv, invProductEntity, "id"); BeanUtil.copyProperties(inv, invProductEntity, "id");
if (StrUtil.isNotBlank(inv.getProductionDate())) {
invProductEntity.setProductDate(inv.getProductionDate());
}
invProductDao.insert(invProductEntity); invProductDao.insert(invProductEntity);
if (StrUtil.isNotBlank(invProductEntity.getId())) { if (StrUtil.isNotBlank(invProductEntity.getId())) {
//拷贝;临时码表的数据 //拷贝;临时码表的数据
@ -190,8 +168,12 @@ public class TestController {
if (CollUtil.isNotEmpty(invDetailList)) { if (CollUtil.isNotEmpty(invDetailList)) {
invDetailList.forEach(invDetail -> { invDetailList.forEach(invDetail -> {
InvProductDetailEntity invProductDetailEntity = new InvProductDetailEntity(); InvProductDetailEntity invProductDetailEntity = new InvProductDetailEntity();
BeanUtil.copyProperties(inv, invProductDetailEntity, "id"); BeanUtil.copyProperties(invDetail, invProductDetailEntity, "id");
invProductDetailEntity.setProductIdFk(invProductEntity.getId()); if (StrUtil.isNotBlank(invDetail.getProductionDate())) {
invProductDetailEntity.setProductDate(invDetail.getProductionDate());
}
invProductDetailEntity.setProductIdFk(invDetail.getProductIdFk());
invProductDetailEntity.setInvProductIdFk(invProductEntity.getId());
invProductDetailDao.insert(invProductDetailEntity); invProductDetailDao.insert(invProductDetailEntity);
log.info("插入库存详情数据"); log.info("插入库存详情数据");
}); });

@ -7,7 +7,7 @@ import com.glxp.udi.admin.common.res.BaseResponse;
import com.glxp.udi.admin.constant.Constant; import com.glxp.udi.admin.constant.Constant;
import com.glxp.udi.admin.entity.basic.BussinessTypeEntity; import com.glxp.udi.admin.entity.basic.BussinessTypeEntity;
import com.glxp.udi.admin.entity.basic.CndidateRequest; import com.glxp.udi.admin.entity.basic.CndidateRequest;
import com.glxp.udi.admin.mongo.service.OrderService; import com.glxp.udi.admin.service.inout.OrderService;
import com.glxp.udi.admin.req.basic.BussinessLocalTypeFilterRequest; import com.glxp.udi.admin.req.basic.BussinessLocalTypeFilterRequest;
import com.glxp.udi.admin.req.basic.BussinessTypeFilterRequest; import com.glxp.udi.admin.req.basic.BussinessTypeFilterRequest;
import com.glxp.udi.admin.req.info.DeleteRequest; import com.glxp.udi.admin.req.info.DeleteRequest;

@ -10,8 +10,8 @@ import com.glxp.udi.admin.entity.auth.AuthAdmin;
import com.glxp.udi.admin.entity.inout.InvProductDetailEntity; import com.glxp.udi.admin.entity.inout.InvProductDetailEntity;
import com.glxp.udi.admin.entity.inout.InvProductEntity; import com.glxp.udi.admin.entity.inout.InvProductEntity;
import com.glxp.udi.admin.entity.inout.UdiInfoEntity; import com.glxp.udi.admin.entity.inout.UdiInfoEntity;
import com.glxp.udi.admin.mongo.service.InvProductDetailService; import com.glxp.udi.admin.service.inout.InvProductDetailService;
import com.glxp.udi.admin.mongo.service.InvProductService; import com.glxp.udi.admin.service.inout.InvProductService;
import com.glxp.udi.admin.req.inout.DeleteRequest; import com.glxp.udi.admin.req.inout.DeleteRequest;
import com.glxp.udi.admin.req.inout.FilterInvProductDetailRequest; import com.glxp.udi.admin.req.inout.FilterInvProductDetailRequest;
import com.glxp.udi.admin.req.inout.FilterUdiInfoRequest; import com.glxp.udi.admin.req.inout.FilterUdiInfoRequest;

@ -17,10 +17,10 @@ import com.glxp.udi.admin.entity.auth.AuthAdmin;
import com.glxp.udi.admin.entity.basic.BussinessTypeEntity; import com.glxp.udi.admin.entity.basic.BussinessTypeEntity;
import com.glxp.udi.admin.entity.info.PlatformEntity; import com.glxp.udi.admin.entity.info.PlatformEntity;
import com.glxp.udi.admin.entity.inout.*; import com.glxp.udi.admin.entity.inout.*;
import com.glxp.udi.admin.mongo.service.OrderDetailService; import com.glxp.udi.admin.service.inout.OrderDetailService;
import com.glxp.udi.admin.mongo.service.OrderService; import com.glxp.udi.admin.service.inout.OrderService;
import com.glxp.udi.admin.mongo.service.WarehouseService; import com.glxp.udi.admin.service.inout.WarehouseService;
import com.glxp.udi.admin.mongo.service.WarehouseTempService; import com.glxp.udi.admin.service.inout.WarehouseTempService;
import com.glxp.udi.admin.req.inout.*; import com.glxp.udi.admin.req.inout.*;
import com.glxp.udi.admin.res.PageSimpleResponse; import com.glxp.udi.admin.res.PageSimpleResponse;
import com.glxp.udi.admin.res.inout.OrderMdResponse; import com.glxp.udi.admin.res.inout.OrderMdResponse;

@ -14,7 +14,7 @@ import com.glxp.udi.admin.entity.inout.StockQRCodeTextEntity;
import com.glxp.udi.admin.entity.inventory.StockPrintTempEntity; import com.glxp.udi.admin.entity.inventory.StockPrintTempEntity;
import com.glxp.udi.admin.entity.param.SystemPDFModuleEntity; import com.glxp.udi.admin.entity.param.SystemPDFModuleEntity;
import com.glxp.udi.admin.entity.param.SystemPDFTemplateEntity; import com.glxp.udi.admin.entity.param.SystemPDFTemplateEntity;
import com.glxp.udi.admin.mongo.service.OrderService; import com.glxp.udi.admin.service.inout.OrderService;
import com.glxp.udi.admin.req.basic.FilterStockprintRequest; import com.glxp.udi.admin.req.basic.FilterStockprintRequest;
import com.glxp.udi.admin.req.inout.DeleteRequest; import com.glxp.udi.admin.req.inout.DeleteRequest;
import com.glxp.udi.admin.req.inout.StockQRCodeTextFilterRequest; import com.glxp.udi.admin.req.inout.StockQRCodeTextFilterRequest;

@ -7,8 +7,8 @@ import com.glxp.udi.admin.annotation.AuthRuleAnnotation;
import com.glxp.udi.admin.common.res.BaseResponse; import com.glxp.udi.admin.common.res.BaseResponse;
import com.glxp.udi.admin.entity.inout.UdiInfoEntity; import com.glxp.udi.admin.entity.inout.UdiInfoEntity;
import com.glxp.udi.admin.entity.inout.WarehouseEntity; import com.glxp.udi.admin.entity.inout.WarehouseEntity;
import com.glxp.udi.admin.mongo.service.InvProductService; import com.glxp.udi.admin.service.inout.InvProductService;
import com.glxp.udi.admin.mongo.service.WarehouseService; import com.glxp.udi.admin.service.inout.WarehouseService;
import com.glxp.udi.admin.req.inout.DeleteRequest; import com.glxp.udi.admin.req.inout.DeleteRequest;
import com.glxp.udi.admin.req.inout.FilterUdiInfoRequest; import com.glxp.udi.admin.req.inout.FilterUdiInfoRequest;
import com.glxp.udi.admin.req.inout.FilterWarehouseRequest; import com.glxp.udi.admin.req.inout.FilterWarehouseRequest;

@ -10,9 +10,9 @@ import com.glxp.udi.admin.entity.inout.OrderEntity;
import com.glxp.udi.admin.entity.inout.UdiInfoEntity; import com.glxp.udi.admin.entity.inout.UdiInfoEntity;
import com.glxp.udi.admin.entity.inout.WarehouseEntity; import com.glxp.udi.admin.entity.inout.WarehouseEntity;
import com.glxp.udi.admin.entity.udid.UdiEntity; import com.glxp.udi.admin.entity.udid.UdiEntity;
import com.glxp.udi.admin.mongo.service.InvProductDetailService; import com.glxp.udi.admin.service.inout.InvProductDetailService;
import com.glxp.udi.admin.mongo.service.OrderService; import com.glxp.udi.admin.service.inout.OrderService;
import com.glxp.udi.admin.mongo.service.WarehouseService; import com.glxp.udi.admin.service.inout.WarehouseService;
import com.glxp.udi.admin.req.inout.FilterInvProductDetailRequest; import com.glxp.udi.admin.req.inout.FilterInvProductDetailRequest;
import com.glxp.udi.admin.req.inout.OrderFilterRequest; import com.glxp.udi.admin.req.inout.OrderFilterRequest;
import com.glxp.udi.admin.req.inout.WarehouseQueryRequest; import com.glxp.udi.admin.req.inout.WarehouseQueryRequest;

@ -10,9 +10,9 @@ import com.glxp.udi.admin.constant.ConstantStatus;
import com.glxp.udi.admin.entity.auth.AuthAdmin; import com.glxp.udi.admin.entity.auth.AuthAdmin;
import com.glxp.udi.admin.entity.inout.*; import com.glxp.udi.admin.entity.inout.*;
import com.glxp.udi.admin.entity.udid.UdiEntity; import com.glxp.udi.admin.entity.udid.UdiEntity;
import com.glxp.udi.admin.mongo.service.OrderService; import com.glxp.udi.admin.service.inout.OrderService;
import com.glxp.udi.admin.mongo.service.WarehouseService; import com.glxp.udi.admin.service.inout.WarehouseService;
import com.glxp.udi.admin.mongo.service.WarehouseTempService; import com.glxp.udi.admin.service.inout.WarehouseTempService;
import com.glxp.udi.admin.req.inout.*; import com.glxp.udi.admin.req.inout.*;
import com.glxp.udi.admin.req.inventory.FilterInvLinkDataRequest; import com.glxp.udi.admin.req.inventory.FilterInvLinkDataRequest;
import com.glxp.udi.admin.res.PageSimpleResponse; import com.glxp.udi.admin.res.PageSimpleResponse;

@ -8,7 +8,7 @@ import com.glxp.udi.admin.entity.auth.AuthAdmin;
import com.glxp.udi.admin.entity.inout.WarehouseBussinessTypeEntity; import com.glxp.udi.admin.entity.inout.WarehouseBussinessTypeEntity;
import com.glxp.udi.admin.entity.inventory.InvWarehouseEntity; import com.glxp.udi.admin.entity.inventory.InvWarehouseEntity;
import com.glxp.udi.admin.entity.param.SystemParamConfigEntity; import com.glxp.udi.admin.entity.param.SystemParamConfigEntity;
import com.glxp.udi.admin.mongo.service.InvProductService; import com.glxp.udi.admin.service.inout.InvProductService;
import com.glxp.udi.admin.req.info.DeleteRequest; import com.glxp.udi.admin.req.info.DeleteRequest;
import com.glxp.udi.admin.req.inventory.FilterInvWarehouseRequest; import com.glxp.udi.admin.req.inventory.FilterInvWarehouseRequest;
import com.glxp.udi.admin.res.inventory.InvWarehouseExportResponse; import com.glxp.udi.admin.res.inventory.InvWarehouseExportResponse;

@ -40,8 +40,16 @@ public interface CodesDao extends BaseMapper<WarehouseEntity> {
/** /**
* *
*
* @param count * @param count
* @param id * @param id
*/ */
void updateCount(@Param("count") Integer count, @Param("id") String id); void updateCount(@Param("count") Integer count, @Param("id") String id);
/**
*
*
* @param orderId
*/
void deleteByOrderId(@Param("orderId") String orderId);
} }

@ -23,15 +23,25 @@ public interface CodesTempDao extends BaseMapper<WarehousetempEntity> {
/** /**
* *
*
* @param id * @param id
* @param orderId * @param orderId
*/ */
void delete(@Param("id") String id, @Param("orderId") String orderId); void delete(@Param("id") String id, @Param("orderId") String orderId);
/** /**
*
* *
* @param id * @param id
* @param count * @param count
*/ */
void updateCount(@Param("id") String id, @Param("count") Integer count); void updateCount(@Param("id") String id, @Param("count") Integer count);
/**
*
*
* @param orderId
*/
void deleteByOrderId(@Param("orderId") String orderId);
} }

@ -3,10 +3,28 @@ package com.glxp.udi.admin.dao.inout;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.glxp.udi.admin.entity.inout.InvProductDetailEntity; import com.glxp.udi.admin.entity.inout.InvProductDetailEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* *
*/ */
@Mapper @Mapper
public interface InvProductDetailDao extends BaseMapper<InvProductDetailEntity> { public interface InvProductDetailDao extends BaseMapper<InvProductDetailEntity> {
/**
*
*
* @param orderId
* @return
*/
List<InvProductDetailEntity> selectByOrderId(@Param("orderId") String orderId);
/**
*
*
* @param orderId
*/
void deleteByOrderId(@Param("orderId") String orderId);
} }

@ -3,10 +3,18 @@ package com.glxp.udi.admin.dao.inout;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.glxp.udi.admin.entity.inout.OrderDetailEntity; import com.glxp.udi.admin.entity.inout.OrderDetailEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/** /**
* *
*/ */
@Mapper @Mapper
public interface OrderDetailDao extends BaseMapper<OrderDetailEntity> { public interface OrderDetailDao extends BaseMapper<OrderDetailEntity> {
/**
*
*
* @param id
*/
void deleteByOrderId(@Param("orderId") String orderId);
} }

@ -144,8 +144,7 @@ public class CodesMdDao implements MongoBaseDao<WarehouseEntity, FilterWarehouse
} }
public List<WarehouseMdEntity> getCodesList() { public List<WarehouseMdEntity> getCodesList() {
List<WarehouseMdEntity> all = mongoTemplate.findAll(WarehouseMdEntity.class, MongoDBName.NAME_ORDER); return mongoTemplate.findAll(WarehouseMdEntity.class, MongoDBName.NAME_CODE);
return all;
} }
} }

@ -1,4 +1,4 @@
package com.glxp.udi.admin.mongo.service; package com.glxp.udi.admin.service.inout;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;

@ -1,4 +1,4 @@
package com.glxp.udi.admin.mongo.service; package com.glxp.udi.admin.service.inout;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;

@ -1,4 +1,4 @@
package com.glxp.udi.admin.mongo.service; package com.glxp.udi.admin.service.inout;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
@ -7,7 +7,6 @@ import com.glxp.udi.admin.dao.inout.OrderDetailDao;
import com.glxp.udi.admin.entity.inout.OrderDetailEntity; import com.glxp.udi.admin.entity.inout.OrderDetailEntity;
import com.glxp.udi.admin.req.inout.DeleteRequest; import com.glxp.udi.admin.req.inout.DeleteRequest;
import com.glxp.udi.admin.req.inout.FilterOrderDetailRequest; import com.glxp.udi.admin.req.inout.FilterOrderDetailRequest;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -16,8 +15,6 @@ import java.util.List;
@Service @Service
public class OrderDetailService { public class OrderDetailService {
@Resource
private MongoTemplate mongoTemplate;
@Resource @Resource
private OrderDetailDao orderDetailDao; private OrderDetailDao orderDetailDao;
@ -67,4 +64,15 @@ public class OrderDetailService {
return wrapper; return wrapper;
} }
/**
*
*
* @param orderId
* @return
*/
public List<OrderDetailEntity> findByOrderId(String orderId) {
QueryWrapper<OrderDetailEntity> wrapper = new QueryWrapper<>();
wrapper.eq("orderIdFk", orderId);
return orderDetailDao.selectList(wrapper);
}
} }

@ -1,4 +1,4 @@
package com.glxp.udi.admin.mongo.service; package com.glxp.udi.admin.service.inout;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
@ -13,16 +13,12 @@ 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.*;
import com.glxp.udi.admin.dao.inout.UdiInfoDao;
import com.glxp.udi.admin.dao.inout.UnitMaintainDao;
import com.glxp.udi.admin.dao.inventory.InvWarehouseDao; import com.glxp.udi.admin.dao.inventory.InvWarehouseDao;
import com.glxp.udi.admin.entity.auth.CustomerInfoEntity; 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.param.SystemParamConfigEntity; import com.glxp.udi.admin.entity.param.SystemParamConfigEntity;
import com.glxp.udi.admin.mongo.MongoDBName;
import com.glxp.udi.admin.req.inout.DeleteRequest; import com.glxp.udi.admin.req.inout.DeleteRequest;
import com.glxp.udi.admin.req.inout.FilterOrderDetailRequest; import com.glxp.udi.admin.req.inout.FilterOrderDetailRequest;
import com.glxp.udi.admin.req.inout.OrderFilterRequest; import com.glxp.udi.admin.req.inout.OrderFilterRequest;
@ -33,10 +29,6 @@ import com.glxp.udi.admin.util.CustomUtil;
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;
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 org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -60,7 +52,6 @@ public class OrderService {
@Lazy @Lazy
@Resource @Resource
private OrderDetailService orderDetailService; private OrderDetailService orderDetailService;
@Resource @Resource
private CustomerInfoDao customerInfoDao; private CustomerInfoDao customerInfoDao;
@Resource @Resource
@ -70,11 +61,20 @@ public class OrderService {
@Resource @Resource
private InvWarehouseDao invWarehouseDao; private InvWarehouseDao invWarehouseDao;
@Resource @Resource
private MongoTemplate mongoTemplate;
@Resource
private BussinessTypeDao bussinessTypeDao; private BussinessTypeDao bussinessTypeDao;
@Resource @Resource
private OrderDao orderDao; private OrderDao orderDao;
@Resource
private OrderDetailDao orderDetailDao;
@Resource
private CodesDao codesDao;
@Resource
private CodesTempDao codesTempDao;
@Resource
private InvProductDao invProductDao;
@Resource
private InvProductDetailDao invProductDetailDao;
public IPage<OrderEntity> filterList(OrderFilterRequest orderFilterRequest) { public IPage<OrderEntity> filterList(OrderFilterRequest orderFilterRequest) {
IPage<OrderEntity> page = new Page<>(orderFilterRequest.getPage(), orderFilterRequest.getLimit()); IPage<OrderEntity> page = new Page<>(orderFilterRequest.getPage(), orderFilterRequest.getLimit());
@ -435,24 +435,21 @@ public class OrderService {
for (String id : ids) { for (String id : ids) {
log.info("开始删除单号为:" + id + "的单据"); log.info("开始删除单号为:" + id + "的单据");
//查询此单据 //查询此单据
Query queryOrder = Query.query(Criteria.where("orderId").is(id)); OrderEntity order = orderDao.selectById(id);
OrderMdEntity order = mongoTemplate.findOne(queryOrder, OrderMdEntity.class, MongoDBName.NAME_ORDER);
//判断此单据是否已经验收,如果未验收,则不需要删除库存 //判断此单据是否已经验收,如果未验收,则不需要删除库存
if (order.getStatus().equals(ConstantStatus.ORDER_STATUS_SUCCESS)) { if (order.getStatus().equals(ConstantStatus.ORDER_STATUS_SUCCESS)) {
//查询库存详情 //查询库存详情
Query queryInvDetail = Query.query(Criteria.where("orderIdFk").is(id)); List<InvProductDetailEntity> invProductDetailEntities = invProductDetailDao.selectByOrderId(id);
List<InvProductDetailEntity> invProductDetailEntities = mongoTemplate.find(queryInvDetail, InvProductDetailEntity.class, MongoDBName.NAME_INV_PRODUCT_DETAIL);
Map<String, List<InvProductDetailEntity>> invProductDetailMap = invProductDetailEntities.stream().collect(Collectors.groupingBy(InvProductDetailEntity::getProductIdFk)); Map<String, List<InvProductDetailEntity>> invProductDetailMap = invProductDetailEntities.stream().collect(Collectors.groupingBy(InvProductDetailEntity::getProductIdFk));
List<InvProductEntity> invProductList = new ArrayList<>(invProductDetailMap.keySet().size()); List<InvProductEntity> invProductList = new ArrayList<>(invProductDetailMap.keySet().size());
for (InvProductDetailEntity invProductDetailEntity : invProductDetailEntities) { for (InvProductDetailEntity invProductDetailEntity : invProductDetailEntities) {
//查询库存 //查询库存
Query queryInvProduct = Query.query(Criteria.where("relIdFk").is(invProductDetailEntity.getProductIdFk())) QueryWrapper<InvProductEntity> invWrapper = new QueryWrapper<>();
.addCriteria(Criteria.where("locStorageCode").is(invProductDetailEntity.getLocStorageCode())); invWrapper.eq("relIdFk", invProductDetailEntity.getProductIdFk())
if (StrUtil.isNotBlank(invProductDetailEntity.getBatchNo())) { .eq("locStorageCode", invProductDetailEntity.getLocStorageCode())
queryInvProduct.addCriteria(Criteria.where("batchNo").is(invProductDetailEntity.getBatchNo())); .eq(StrUtil.isNotBlank(invProductDetailEntity.getBatchNo()), "batchNo", invProductDetailEntity.getBatchNo());
} InvProductEntity invProduct = invProductDao.selectOne(invWrapper);
InvProductEntity invProduct = mongoTemplate.findOne(queryInvProduct, InvProductEntity.class, MongoDBName.NAME_INV_PRODUCT);
if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) { if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) {
//入库,在原有库存基础上减库存 //入库,在原有库存基础上减库存
int count = invProduct.getInCount() - invProductDetailEntity.getCount(); int count = invProduct.getInCount() - invProductDetailEntity.getCount();
@ -469,38 +466,30 @@ public class OrderService {
//删除单据相关数据,更新库存 //删除单据相关数据,更新库存
try { try {
//删除库存详情 //删除库存详情
mongoTemplate.remove(Query.query(Criteria.where("orderIdFk").is(id)), InvProductDetailEntity.class, MongoDBName.NAME_INV_PRODUCT_DETAIL); invProductDetailDao.deleteByOrderId(id);
//更新库存 //更新库存
for (InvProductEntity invProductEntity : invProductList) { for (InvProductEntity invProductEntity : invProductList) {
//查询库存码详情,如果库存码详情为空,则删除此库存 //查询库存码详情,如果库存码详情为空,则删除此库存
Query countQuery = Query.query(Criteria.where("productIdFk").is(invProductEntity.getRelIdFk())) QueryWrapper<InvProductDetailEntity> countQuery = new QueryWrapper<>();
.addCriteria(Criteria.where("batchNo").is(invProductEntity.getBatchNo())) countQuery.eq("productIdFk", invProductEntity.getRelIdFk())
.addCriteria(Criteria.where("locStorageCode").is(invProductEntity.getLocStorageCode())); .eq("batchNo", invProductEntity.getBatchNo())
long count = mongoTemplate.count(countQuery, InvProductDetailEntity.class, MongoDBName.NAME_INV_PRODUCT_DETAIL); .eq("locStorageCode", invProductEntity.getLocStorageCode());
long count = invProductDetailDao.selectCount(countQuery);
if (count == 0) { if (count == 0) {
//库存码详情为空,删除此库存 //库存码详情为空,删除此库存
Query query = new Query(); invProductDao.deleteById(invProductEntity.getId());
query.addCriteria(Criteria.where("id").is(invProductEntity.getId()));
mongoTemplate.remove(query, InvProductEntity.class, MongoDBName.NAME_INV_PRODUCT);
} else { } else {
Query query = new Query(); //库存不为空,更新库存信息
query.addCriteria(Criteria.where("relIdFk").is(invProductEntity.getRelIdFk())); invProductDao.updateById(invProductEntity);
query.addCriteria(Criteria.where("batchNo").is(invProductEntity.getBatchNo()));
query.addCriteria(Criteria.where("locStorageCode").is(invProductEntity.getLocStorageCode()));
Update update = new Update();
update.set("inCount", invProductEntity.getInCount());
update.set("outCount", invProductEntity.getOutCount());
mongoTemplate.updateMulti(query, update, InvProductEntity.class, MongoDBName.NAME_INV_PRODUCT);
} }
} }
//删除码详情 //删除码详情
mongoTemplate.remove(queryOrder, WarehouseEntity.class, MongoDBName.NAME_CODE); codesDao.deleteByOrderId(id);
//删除单据详情 //删除单据详情
mongoTemplate.remove(queryInvDetail, OrderDetailEntity.class, MongoDBName.NAME_ORDER_DETAIL); orderDetailDao.deleteByOrderId(id);
//删除单据 //删除单据
mongoTemplate.remove(queryOrder, OrderMdEntity.class, MongoDBName.NAME_ORDER); orderDao.deleteById(id);
} catch (Exception e) { } catch (Exception e) {
log.error("删除单据失败", e); log.error("删除单据失败", e);
throw new RuntimeException("删除单据失败"); throw new RuntimeException("删除单据失败");
@ -509,12 +498,11 @@ public class OrderService {
//未验收单据,删除单据,单据详情,临时码表数据 //未验收单据,删除单据,单据详情,临时码表数据
try { try {
//删除单据 //删除单据
mongoTemplate.remove(queryOrder, OrderMdEntity.class, MongoDBName.NAME_ORDER); orderDao.deleteById(id);
//删除单据详情 //删除单据详情
Query queryOrderDetail = Query.query(Criteria.where("orderIdFk").is(id)); orderDetailDao.deleteByOrderId(id);
mongoTemplate.remove(queryOrderDetail, OrderDetailEntity.class, MongoDBName.NAME_ORDER_DETAIL);
//删除临时码表 //删除临时码表
mongoTemplate.remove(queryOrder, WarehouseEntity.class, MongoDBName.NAME_CODE_TEMP); codesTempDao.deleteByOrderId(id);
} catch (Exception e) { } catch (Exception e) {
log.error("删除单据失败", e); log.error("删除单据失败", e);
throw new RuntimeException("删除单据失败"); throw new RuntimeException("删除单据失败");

@ -1,4 +1,4 @@
package com.glxp.udi.admin.mongo.service; package com.glxp.udi.admin.service.inout;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;

@ -1,4 +1,4 @@
package com.glxp.udi.admin.mongo.service; package com.glxp.udi.admin.service.inout;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;

@ -5,11 +5,10 @@ import cn.hutool.core.util.StrUtil;
import com.glxp.udi.admin.constant.ConstantStatus; import com.glxp.udi.admin.constant.ConstantStatus;
import com.glxp.udi.admin.constant.TypeConstant; import com.glxp.udi.admin.constant.TypeConstant;
import com.glxp.udi.admin.entity.inout.*; import com.glxp.udi.admin.entity.inout.*;
import com.glxp.udi.admin.mongo.service.*;
import com.glxp.udi.admin.req.inout.FilterOrderDetailRequest; 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.inout.WarehouseQueryRequest; import com.glxp.udi.admin.req.inout.WarehouseQueryRequest;
import com.glxp.udi.admin.service.inout.UdiInfoService; import com.glxp.udi.admin.service.inout.*;
import com.glxp.udi.admin.util.inout.InoutUtils; import com.glxp.udi.admin.util.inout.InoutUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;

@ -16,9 +16,9 @@ import com.glxp.udi.admin.entity.inout.OrderEntity;
import com.glxp.udi.admin.entity.inout.UnitMaintainEntity; import com.glxp.udi.admin.entity.inout.UnitMaintainEntity;
import com.glxp.udi.admin.entity.inout.WarehouseEntity; import com.glxp.udi.admin.entity.inout.WarehouseEntity;
import com.glxp.udi.admin.entity.param.SystemParamConfigEntity; import com.glxp.udi.admin.entity.param.SystemParamConfigEntity;
import com.glxp.udi.admin.mongo.service.OrderDetailService; import com.glxp.udi.admin.service.inout.OrderDetailService;
import com.glxp.udi.admin.mongo.service.OrderService; import com.glxp.udi.admin.service.inout.OrderService;
import com.glxp.udi.admin.mongo.service.WarehouseService; import com.glxp.udi.admin.service.inout.WarehouseService;
import com.glxp.udi.admin.req.inout.FilterOrderDetailRequest; import com.glxp.udi.admin.req.inout.FilterOrderDetailRequest;
import com.glxp.udi.admin.req.inout.PostUdimsOrderDetailRequest; import com.glxp.udi.admin.req.inout.PostUdimsOrderDetailRequest;
import com.glxp.udi.admin.req.inout.PostUdimsOrderRequest; import com.glxp.udi.admin.req.inout.PostUdimsOrderRequest;

@ -6,9 +6,8 @@ import com.glxp.udi.admin.constant.SystemParamConstant;
import com.glxp.udi.admin.dao.info.ScheduledDao; import com.glxp.udi.admin.dao.info.ScheduledDao;
import com.glxp.udi.admin.entity.info.ScheduledEntity; import com.glxp.udi.admin.entity.info.ScheduledEntity;
import com.glxp.udi.admin.entity.inout.OrderEntity; import com.glxp.udi.admin.entity.inout.OrderEntity;
import com.glxp.udi.admin.entity.mongo.OrderMdEntity;
import com.glxp.udi.admin.entity.param.SystemParamConfigEntity; import com.glxp.udi.admin.entity.param.SystemParamConfigEntity;
import com.glxp.udi.admin.mongo.service.OrderService; import com.glxp.udi.admin.service.inout.OrderService;
import com.glxp.udi.admin.req.udidl.ScheduledRequest; import com.glxp.udi.admin.req.udidl.ScheduledRequest;
import com.glxp.udi.admin.service.param.SystemParamConfigService; import com.glxp.udi.admin.service.param.SystemParamConfigService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;

@ -5,10 +5,10 @@ import cn.hutool.core.util.StrUtil;
import com.glxp.udi.admin.constant.ConstantStatus; import com.glxp.udi.admin.constant.ConstantStatus;
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.mongo.service.OrderDetailService; import com.glxp.udi.admin.service.inout.OrderDetailService;
import com.glxp.udi.admin.mongo.service.OrderService; import com.glxp.udi.admin.service.inout.OrderService;
import com.glxp.udi.admin.mongo.service.WarehouseService; import com.glxp.udi.admin.service.inout.WarehouseService;
import com.glxp.udi.admin.mongo.service.WarehouseTempService; import com.glxp.udi.admin.service.inout.WarehouseTempService;
import com.glxp.udi.admin.req.inout.OrderFilterRequest; import com.glxp.udi.admin.req.inout.OrderFilterRequest;
import com.glxp.udi.admin.req.inout.PostOrderRequest; import com.glxp.udi.admin.req.inout.PostOrderRequest;
import com.glxp.udi.admin.service.basic.BussinessTypeService; import com.glxp.udi.admin.service.basic.BussinessTypeService;

@ -7,7 +7,7 @@ import com.glxp.udi.admin.dao.info.ScheduledDao;
import com.glxp.udi.admin.entity.info.ScheduledEntity; import com.glxp.udi.admin.entity.info.ScheduledEntity;
import com.glxp.udi.admin.entity.inout.OrderEntity; import com.glxp.udi.admin.entity.inout.OrderEntity;
import com.glxp.udi.admin.entity.param.SystemParamConfigEntity; import com.glxp.udi.admin.entity.param.SystemParamConfigEntity;
import com.glxp.udi.admin.mongo.service.OrderService; import com.glxp.udi.admin.service.inout.OrderService;
import com.glxp.udi.admin.req.inout.OrderFilterRequest; import com.glxp.udi.admin.req.inout.OrderFilterRequest;
import com.glxp.udi.admin.req.udidl.ScheduledRequest; import com.glxp.udi.admin.req.udidl.ScheduledRequest;
import com.glxp.udi.admin.service.param.SystemParamConfigService; import com.glxp.udi.admin.service.param.SystemParamConfigService;

@ -10,8 +10,8 @@ import com.glxp.udi.admin.entity.inout.UdiInfoEntity;
import com.glxp.udi.admin.entity.inout.WarehouseEntity; import com.glxp.udi.admin.entity.inout.WarehouseEntity;
import com.glxp.udi.admin.entity.inout.WarehousetempEntity; import com.glxp.udi.admin.entity.inout.WarehousetempEntity;
import com.glxp.udi.admin.entity.udid.UdiEntity; import com.glxp.udi.admin.entity.udid.UdiEntity;
import com.glxp.udi.admin.mongo.service.OrderDetailService; import com.glxp.udi.admin.service.inout.OrderDetailService;
import com.glxp.udi.admin.mongo.service.WarehouseService; import com.glxp.udi.admin.service.inout.WarehouseService;
import com.glxp.udi.admin.req.inout.FilterWarehouseRequest; import com.glxp.udi.admin.req.inout.FilterWarehouseRequest;
import com.glxp.udi.admin.service.info.SetupService; import com.glxp.udi.admin.service.info.SetupService;
import com.glxp.udi.admin.service.inout.UdiInfoService; import com.glxp.udi.admin.service.inout.UdiInfoService;

@ -22,4 +22,7 @@
select * from io_codes where orderId = #{orderId} select * from io_codes where orderId = #{orderId}
</select> </select>
<delete id="deleteByOrderId">
delete from io_codes where orderId = #{orderId}
</delete>
</mapper> </mapper>

@ -14,4 +14,7 @@
select * from io_codes_temp where orderId = #{orderId} select * from io_codes_temp where orderId = #{orderId}
</select> </select>
<delete id="deleteByOrderId">
delete from io_codes_temp where orderId = #{orderId}
</delete>
</mapper> </mapper>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.glxp.udi.admin.dao.inout.InvProductDao">
</mapper>

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.glxp.udi.admin.dao.inout.InvProductDetailDao">
<select id="selectByOrderId" resultType="com.glxp.udi.admin.entity.inout.InvProductDetailEntity">
select *
from io_inv_product_detail
where orderIdFk = #{orderId}
</select>
<delete id="deleteByOrderId">
delete from io_inv_product_detail where orderIdFk = #{orderId}
</delete>
</mapper>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.glxp.udi.admin.dao.inout.OrderDetailDao">
<delete id="deleteByOrderId">
delete from io_order_detail where orderIdFk = #{orderId}
</delete>
</mapper>
Loading…
Cancel
Save