diff --git a/src/main/java/com/glxp/udi/admin/controller/TestController.java b/src/main/java/com/glxp/udi/admin/controller/TestController.java index 3115a9a..02ede7d 100644 --- a/src/main/java/com/glxp/udi/admin/controller/TestController.java +++ b/src/main/java/com/glxp/udi/admin/controller/TestController.java @@ -2,19 +2,13 @@ package com.glxp.udi.admin.controller; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.glxp.udi.admin.dao.inout.UdiInfoDao; +import com.glxp.udi.admin.dao.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.mongo.dao.*; -import com.glxp.udi.admin.mongo.service.InvProductDetailService; -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 com.glxp.udi.admin.service.inout.OrderDetailService; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @@ -22,6 +16,9 @@ import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.util.List; +/** + * todo 正式上线完成数据迁移之后,删除此接口 + */ @Slf4j @RestController public class TestController { @@ -29,10 +26,6 @@ public class TestController { @Resource private OrderDetailService orderDetailService; @Resource - private InvProductService invProductService; - @Resource - private InvProductDetailService invProductDetailService; - @Resource private UdiInfoDao udiInfoDao; //mongodb dao @@ -51,71 +44,46 @@ public class TestController { //mysql dao @Resource - private com.glxp.udi.admin.dao.inout.OrderDao orderDao; + private OrderDao orderDao; @Resource - private com.glxp.udi.admin.dao.inout.OrderDetailDao orderDetailDao; + private OrderDetailDao orderDetailDao; @Resource - private com.glxp.udi.admin.dao.inout.CodesDao codesDao; + private CodesDao codesDao; @Resource - private com.glxp.udi.admin.dao.inout.CodesTempDao codesTempDao; + private CodesTempDao codesTempDao; @Resource - private com.glxp.udi.admin.dao.inout.InvProductDao invProductDao; + private InvProductDao invProductDao; @Resource - private com.glxp.udi.admin.dao.inout.InvProductDetailDao invProductDetailDao; + private InvProductDetailDao invProductDetailDao; + /** + * 填充relId产品ID关联字段值 + * + * @return + */ @GetMapping("/test/refreshOrderData") private String refreshOrderData() { try { - //刷新订单详情表的数据 - List erpOrderEntities = orderDetailService.filterOrderDetails(new FilterOrderDetailRequest()); - /*erpOrderEntities.forEach(orderDetail -> { - String orderId = orderDetail.getOrderIdFk(); - if (StrUtil.isNotBlank(orderId)) { - OrderMdEntity order = orderMdService.findByOne(orderId); - if (null != order) { - UdiInfoEntity udiInfoEntity = udiInfoDao.selectOne(new QueryWrapper().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 invProductEntities = invProductService.filterInvProductList(new FilterInvProductRequest()); - invProductEntities.forEach(invProductEntity -> { - UdiInfoEntity udiInfoEntity = udiInfoDao.selectOne(new QueryWrapper().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 warehouseEntities = codesDao.selectList(null); + warehouseEntities.forEach(code -> { + UdiInfoEntity udiInfoEntity = udiInfoDao.selectById(code.getRelId()); + code.setRelId(udiInfoEntity.getUuid()); + codesDao.updateById(code); }); - //刷新库存详情表数据 - List invProductDetailEntities = invProductDetailService.filterAllInvProduct(new FilterInvProductDetailRequest()); - invProductDetailEntities.forEach(invProductDetailEntity -> { - UdiInfoEntity udiInfoEntity = udiInfoDao.selectOne(new QueryWrapper().eq(StrUtil.isNotBlank(invProductDetailEntity.getProductIdFk()), "uuid", invProductDetailEntity.getProductIdFk()) - .eq(StrUtil.isNotBlank(invProductDetailEntity.getCustomerId()), "customerId", invProductDetailEntity.getCustomerId()) - ); - if (null != udiInfoEntity) { - invProductDetailEntity.setProductIdFk(String.valueOf(udiInfoEntity.getId())); - log.info("刷新库存详情"); - invProductDetailService.updateInvProduct(invProductDetailEntity); - } + //刷新临时码表 + List warehousetempEntities = codesTempDao.selectList(null); + warehousetempEntities.forEach(codesTemp -> { + UdiInfoEntity udiInfoEntity = udiInfoDao.selectById(codesTemp.getRelId()); + codesTemp.setRelId(udiInfoEntity.getUuid()); + codesTempDao.updateById(codesTemp); }); + return "success"; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); } return "error"; } @@ -148,6 +116,8 @@ public class TestController { BeanUtil.copyProperties(orderMdDetail, orderDetailEntity, "id"); orderDetailEntity.setBatchNo(orderMdDetail.getLotno()); orderDetailEntity.setProductName(orderMdDetail.getCoName()); + orderDetailEntity.setZczbhhzbapzbh(orderMdDetail.getAuthCode()); + orderDetailEntity.setGgxh(orderMdDetail.getPackSpec()); orderDetailDao.insert(orderDetailEntity); }); } @@ -159,6 +129,10 @@ public class TestController { codesList.forEach(code -> { WarehouseEntity warehouseEntity = new WarehouseEntity(); 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); }); } @@ -170,6 +144,7 @@ public class TestController { codesTempList.forEach(codesTemp -> { WarehousetempEntity warehousetempEntity = new WarehousetempEntity(); BeanUtil.copyProperties(codesTemp, warehousetempEntity, "id"); + warehousetempEntity.setNameCode(codesTemp.getUdi()); codesTempDao.insert(warehousetempEntity); }); } @@ -181,6 +156,9 @@ public class TestController { invList.forEach(inv -> { InvProductEntity invProductEntity = new InvProductEntity(); BeanUtil.copyProperties(inv, invProductEntity, "id"); + if (StrUtil.isNotBlank(inv.getProductionDate())) { + invProductEntity.setProductDate(inv.getProductionDate()); + } invProductDao.insert(invProductEntity); if (StrUtil.isNotBlank(invProductEntity.getId())) { //拷贝;临时码表的数据 @@ -190,8 +168,12 @@ public class TestController { if (CollUtil.isNotEmpty(invDetailList)) { invDetailList.forEach(invDetail -> { InvProductDetailEntity invProductDetailEntity = new InvProductDetailEntity(); - BeanUtil.copyProperties(inv, invProductDetailEntity, "id"); - invProductDetailEntity.setProductIdFk(invProductEntity.getId()); + BeanUtil.copyProperties(invDetail, invProductDetailEntity, "id"); + if (StrUtil.isNotBlank(invDetail.getProductionDate())) { + invProductDetailEntity.setProductDate(invDetail.getProductionDate()); + } + invProductDetailEntity.setProductIdFk(invDetail.getProductIdFk()); + invProductDetailEntity.setInvProductIdFk(invProductEntity.getId()); invProductDetailDao.insert(invProductDetailEntity); log.info("插入库存详情数据"); }); diff --git a/src/main/java/com/glxp/udi/admin/controller/basic/BussinessTypeController.java b/src/main/java/com/glxp/udi/admin/controller/basic/BussinessTypeController.java index cef116b..4fd995c 100644 --- a/src/main/java/com/glxp/udi/admin/controller/basic/BussinessTypeController.java +++ b/src/main/java/com/glxp/udi/admin/controller/basic/BussinessTypeController.java @@ -7,7 +7,7 @@ import com.glxp.udi.admin.common.res.BaseResponse; import com.glxp.udi.admin.constant.Constant; import com.glxp.udi.admin.entity.basic.BussinessTypeEntity; 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.BussinessTypeFilterRequest; import com.glxp.udi.admin.req.info.DeleteRequest; diff --git a/src/main/java/com/glxp/udi/admin/controller/inout/InvProductsController.java b/src/main/java/com/glxp/udi/admin/controller/inout/InvProductsController.java index bbece76..eb5bf3f 100644 --- a/src/main/java/com/glxp/udi/admin/controller/inout/InvProductsController.java +++ b/src/main/java/com/glxp/udi/admin/controller/inout/InvProductsController.java @@ -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.InvProductEntity; import com.glxp.udi.admin.entity.inout.UdiInfoEntity; -import com.glxp.udi.admin.mongo.service.InvProductDetailService; -import com.glxp.udi.admin.mongo.service.InvProductService; +import com.glxp.udi.admin.service.inout.InvProductDetailService; +import com.glxp.udi.admin.service.inout.InvProductService; import com.glxp.udi.admin.req.inout.DeleteRequest; import com.glxp.udi.admin.req.inout.FilterInvProductDetailRequest; import com.glxp.udi.admin.req.inout.FilterUdiInfoRequest; diff --git a/src/main/java/com/glxp/udi/admin/controller/inout/OrderController.java b/src/main/java/com/glxp/udi/admin/controller/inout/OrderController.java index 3b18c0d..f7d2510 100644 --- a/src/main/java/com/glxp/udi/admin/controller/inout/OrderController.java +++ b/src/main/java/com/glxp/udi/admin/controller/inout/OrderController.java @@ -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.info.PlatformEntity; import com.glxp.udi.admin.entity.inout.*; -import com.glxp.udi.admin.mongo.service.OrderDetailService; -import com.glxp.udi.admin.mongo.service.OrderService; -import com.glxp.udi.admin.mongo.service.WarehouseService; -import com.glxp.udi.admin.mongo.service.WarehouseTempService; +import com.glxp.udi.admin.service.inout.OrderDetailService; +import com.glxp.udi.admin.service.inout.OrderService; +import com.glxp.udi.admin.service.inout.WarehouseService; +import com.glxp.udi.admin.service.inout.WarehouseTempService; import com.glxp.udi.admin.req.inout.*; import com.glxp.udi.admin.res.PageSimpleResponse; import com.glxp.udi.admin.res.inout.OrderMdResponse; diff --git a/src/main/java/com/glxp/udi/admin/controller/inout/StockQRCodeTextController.java b/src/main/java/com/glxp/udi/admin/controller/inout/StockQRCodeTextController.java index 91a100f..e5c2a2d 100644 --- a/src/main/java/com/glxp/udi/admin/controller/inout/StockQRCodeTextController.java +++ b/src/main/java/com/glxp/udi/admin/controller/inout/StockQRCodeTextController.java @@ -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.param.SystemPDFModuleEntity; 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.inout.DeleteRequest; import com.glxp.udi.admin.req.inout.StockQRCodeTextFilterRequest; diff --git a/src/main/java/com/glxp/udi/admin/controller/inout/UdiRelevanceController.java b/src/main/java/com/glxp/udi/admin/controller/inout/UdiRelevanceController.java index fb4d208..49a4d95 100644 --- a/src/main/java/com/glxp/udi/admin/controller/inout/UdiRelevanceController.java +++ b/src/main/java/com/glxp/udi/admin/controller/inout/UdiRelevanceController.java @@ -7,8 +7,8 @@ import com.glxp.udi.admin.annotation.AuthRuleAnnotation; import com.glxp.udi.admin.common.res.BaseResponse; import com.glxp.udi.admin.entity.inout.UdiInfoEntity; import com.glxp.udi.admin.entity.inout.WarehouseEntity; -import com.glxp.udi.admin.mongo.service.InvProductService; -import com.glxp.udi.admin.mongo.service.WarehouseService; +import com.glxp.udi.admin.service.inout.InvProductService; +import com.glxp.udi.admin.service.inout.WarehouseService; import com.glxp.udi.admin.req.inout.DeleteRequest; import com.glxp.udi.admin.req.inout.FilterUdiInfoRequest; import com.glxp.udi.admin.req.inout.FilterWarehouseRequest; diff --git a/src/main/java/com/glxp/udi/admin/controller/inout/UdiTraceController.java b/src/main/java/com/glxp/udi/admin/controller/inout/UdiTraceController.java index 18059c2..abc527a 100644 --- a/src/main/java/com/glxp/udi/admin/controller/inout/UdiTraceController.java +++ b/src/main/java/com/glxp/udi/admin/controller/inout/UdiTraceController.java @@ -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.WarehouseEntity; import com.glxp.udi.admin.entity.udid.UdiEntity; -import com.glxp.udi.admin.mongo.service.InvProductDetailService; -import com.glxp.udi.admin.mongo.service.OrderService; -import com.glxp.udi.admin.mongo.service.WarehouseService; +import com.glxp.udi.admin.service.inout.InvProductDetailService; +import com.glxp.udi.admin.service.inout.OrderService; +import com.glxp.udi.admin.service.inout.WarehouseService; import com.glxp.udi.admin.req.inout.FilterInvProductDetailRequest; import com.glxp.udi.admin.req.inout.OrderFilterRequest; import com.glxp.udi.admin.req.inout.WarehouseQueryRequest; diff --git a/src/main/java/com/glxp/udi/admin/controller/inout/WareHouseController.java b/src/main/java/com/glxp/udi/admin/controller/inout/WareHouseController.java index 6d0b2bb..5e6611a 100644 --- a/src/main/java/com/glxp/udi/admin/controller/inout/WareHouseController.java +++ b/src/main/java/com/glxp/udi/admin/controller/inout/WareHouseController.java @@ -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.inout.*; import com.glxp.udi.admin.entity.udid.UdiEntity; -import com.glxp.udi.admin.mongo.service.OrderService; -import com.glxp.udi.admin.mongo.service.WarehouseService; -import com.glxp.udi.admin.mongo.service.WarehouseTempService; +import com.glxp.udi.admin.service.inout.OrderService; +import com.glxp.udi.admin.service.inout.WarehouseService; +import com.glxp.udi.admin.service.inout.WarehouseTempService; import com.glxp.udi.admin.req.inout.*; import com.glxp.udi.admin.req.inventory.FilterInvLinkDataRequest; import com.glxp.udi.admin.res.PageSimpleResponse; diff --git a/src/main/java/com/glxp/udi/admin/controller/inventory/InvWarehouseController.java b/src/main/java/com/glxp/udi/admin/controller/inventory/InvWarehouseController.java index eecf7f4..d427c88 100644 --- a/src/main/java/com/glxp/udi/admin/controller/inventory/InvWarehouseController.java +++ b/src/main/java/com/glxp/udi/admin/controller/inventory/InvWarehouseController.java @@ -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.inventory.InvWarehouseEntity; 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.inventory.FilterInvWarehouseRequest; import com.glxp.udi.admin.res.inventory.InvWarehouseExportResponse; diff --git a/src/main/java/com/glxp/udi/admin/dao/inout/CodesDao.java b/src/main/java/com/glxp/udi/admin/dao/inout/CodesDao.java index a25e57b..8f4895d 100644 --- a/src/main/java/com/glxp/udi/admin/dao/inout/CodesDao.java +++ b/src/main/java/com/glxp/udi/admin/dao/inout/CodesDao.java @@ -40,8 +40,16 @@ public interface CodesDao extends BaseMapper { /** * 更新总数 + * * @param count * @param id */ void updateCount(@Param("count") Integer count, @Param("id") String id); + + /** + * 根据单据号删除码详情 + * + * @param orderId + */ + void deleteByOrderId(@Param("orderId") String orderId); } diff --git a/src/main/java/com/glxp/udi/admin/dao/inout/CodesTempDao.java b/src/main/java/com/glxp/udi/admin/dao/inout/CodesTempDao.java index fb25d07..46f9ecf 100644 --- a/src/main/java/com/glxp/udi/admin/dao/inout/CodesTempDao.java +++ b/src/main/java/com/glxp/udi/admin/dao/inout/CodesTempDao.java @@ -23,15 +23,25 @@ public interface CodesTempDao extends BaseMapper { /** * 删除 + * * @param id * @param orderId */ void delete(@Param("id") String id, @Param("orderId") String orderId); /** + * 更新数量 * * @param id * @param count */ void updateCount(@Param("id") String id, @Param("count") Integer count); + + /** + * 根据单据号,删除关联数据 + * + * @param orderId + */ + void deleteByOrderId(@Param("orderId") String orderId); + } diff --git a/src/main/java/com/glxp/udi/admin/dao/inout/InvProductDetailDao.java b/src/main/java/com/glxp/udi/admin/dao/inout/InvProductDetailDao.java index 49bee81..49eed38 100644 --- a/src/main/java/com/glxp/udi/admin/dao/inout/InvProductDetailDao.java +++ b/src/main/java/com/glxp/udi/admin/dao/inout/InvProductDetailDao.java @@ -3,10 +3,28 @@ package com.glxp.udi.admin.dao.inout; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.glxp.udi.admin.entity.inout.InvProductDetailEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 库存详情表数据接口 */ @Mapper public interface InvProductDetailDao extends BaseMapper { + + /** + * 根据单据号查询库存详情 + * + * @param orderId + * @return + */ + List selectByOrderId(@Param("orderId") String orderId); + + /** + * 根据单据号删除库存详情 + * + * @param orderId + */ + void deleteByOrderId(@Param("orderId") String orderId); } diff --git a/src/main/java/com/glxp/udi/admin/dao/inout/OrderDetailDao.java b/src/main/java/com/glxp/udi/admin/dao/inout/OrderDetailDao.java index 55960e4..91d376c 100644 --- a/src/main/java/com/glxp/udi/admin/dao/inout/OrderDetailDao.java +++ b/src/main/java/com/glxp/udi/admin/dao/inout/OrderDetailDao.java @@ -3,10 +3,18 @@ package com.glxp.udi.admin.dao.inout; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.glxp.udi.admin.entity.inout.OrderDetailEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * 单据详情数据接口 */ @Mapper public interface OrderDetailDao extends BaseMapper { + + /** + * 根据订单号,删除关联的单据详情 + * + * @param id + */ + void deleteByOrderId(@Param("orderId") String orderId); } diff --git a/src/main/java/com/glxp/udi/admin/mongo/dao/CodesMdDao.java b/src/main/java/com/glxp/udi/admin/mongo/dao/CodesMdDao.java index 4911ebf..aa77843 100644 --- a/src/main/java/com/glxp/udi/admin/mongo/dao/CodesMdDao.java +++ b/src/main/java/com/glxp/udi/admin/mongo/dao/CodesMdDao.java @@ -144,8 +144,7 @@ public class CodesMdDao implements MongoBaseDao getCodesList() { - List all = mongoTemplate.findAll(WarehouseMdEntity.class, MongoDBName.NAME_ORDER); - return all; + return mongoTemplate.findAll(WarehouseMdEntity.class, MongoDBName.NAME_CODE); } } diff --git a/src/main/java/com/glxp/udi/admin/mongo/service/InvProductDetailService.java b/src/main/java/com/glxp/udi/admin/service/inout/InvProductDetailService.java similarity index 99% rename from src/main/java/com/glxp/udi/admin/mongo/service/InvProductDetailService.java rename to src/main/java/com/glxp/udi/admin/service/inout/InvProductDetailService.java index 8f7781e..3e9b403 100644 --- a/src/main/java/com/glxp/udi/admin/mongo/service/InvProductDetailService.java +++ b/src/main/java/com/glxp/udi/admin/service/inout/InvProductDetailService.java @@ -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.util.StrUtil; diff --git a/src/main/java/com/glxp/udi/admin/mongo/service/InvProductService.java b/src/main/java/com/glxp/udi/admin/service/inout/InvProductService.java similarity index 99% rename from src/main/java/com/glxp/udi/admin/mongo/service/InvProductService.java rename to src/main/java/com/glxp/udi/admin/service/inout/InvProductService.java index dd32f97..87cdc0c 100644 --- a/src/main/java/com/glxp/udi/admin/mongo/service/InvProductService.java +++ b/src/main/java/com/glxp/udi/admin/service/inout/InvProductService.java @@ -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.util.StrUtil; diff --git a/src/main/java/com/glxp/udi/admin/mongo/service/OrderDetailService.java b/src/main/java/com/glxp/udi/admin/service/inout/OrderDetailService.java similarity index 87% rename from src/main/java/com/glxp/udi/admin/mongo/service/OrderDetailService.java rename to src/main/java/com/glxp/udi/admin/service/inout/OrderDetailService.java index 142705f..c1b4f77 100644 --- a/src/main/java/com/glxp/udi/admin/mongo/service/OrderDetailService.java +++ b/src/main/java/com/glxp/udi/admin/service/inout/OrderDetailService.java @@ -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.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.req.inout.DeleteRequest; import com.glxp.udi.admin.req.inout.FilterOrderDetailRequest; -import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -16,8 +15,6 @@ import java.util.List; @Service public class OrderDetailService { - @Resource - private MongoTemplate mongoTemplate; @Resource private OrderDetailDao orderDetailDao; @@ -67,4 +64,15 @@ public class OrderDetailService { return wrapper; } + /** + * 根据单据号,查询单据详情数据 + * + * @param orderId + * @return + */ + public List findByOrderId(String orderId) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("orderIdFk", orderId); + return orderDetailDao.selectList(wrapper); + } } diff --git a/src/main/java/com/glxp/udi/admin/mongo/service/OrderService.java b/src/main/java/com/glxp/udi/admin/service/inout/OrderService.java similarity index 84% rename from src/main/java/com/glxp/udi/admin/mongo/service/OrderService.java rename to src/main/java/com/glxp/udi/admin/service/inout/OrderService.java index adf2f51..6c27946 100644 --- a/src/main/java/com/glxp/udi/admin/mongo/service/OrderService.java +++ b/src/main/java/com/glxp/udi/admin/service/inout/OrderService.java @@ -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.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.dao.auth.CustomerInfoDao; 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.UnitMaintainDao; +import com.glxp.udi.admin.dao.inout.*; import com.glxp.udi.admin.dao.inventory.InvWarehouseDao; import com.glxp.udi.admin.entity.auth.CustomerInfoEntity; import com.glxp.udi.admin.entity.basic.BussinessTypeEntity; 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.mongo.MongoDBName; import com.glxp.udi.admin.req.inout.DeleteRequest; import com.glxp.udi.admin.req.inout.FilterOrderDetailRequest; 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 lombok.extern.slf4j.Slf4j; 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 javax.annotation.Resource; @@ -60,7 +52,6 @@ public class OrderService { @Lazy @Resource private OrderDetailService orderDetailService; - @Resource private CustomerInfoDao customerInfoDao; @Resource @@ -70,11 +61,20 @@ public class OrderService { @Resource private InvWarehouseDao invWarehouseDao; @Resource - private MongoTemplate mongoTemplate; - @Resource private BussinessTypeDao bussinessTypeDao; @Resource 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 filterList(OrderFilterRequest orderFilterRequest) { IPage page = new Page<>(orderFilterRequest.getPage(), orderFilterRequest.getLimit()); @@ -435,24 +435,21 @@ public class OrderService { for (String id : ids) { log.info("开始删除单号为:" + id + "的单据"); //查询此单据 - Query queryOrder = Query.query(Criteria.where("orderId").is(id)); - OrderMdEntity order = mongoTemplate.findOne(queryOrder, OrderMdEntity.class, MongoDBName.NAME_ORDER); + OrderEntity order = orderDao.selectById(id); //判断此单据是否已经验收,如果未验收,则不需要删除库存 if (order.getStatus().equals(ConstantStatus.ORDER_STATUS_SUCCESS)) { //查询库存详情 - Query queryInvDetail = Query.query(Criteria.where("orderIdFk").is(id)); - List invProductDetailEntities = mongoTemplate.find(queryInvDetail, InvProductDetailEntity.class, MongoDBName.NAME_INV_PRODUCT_DETAIL); + List invProductDetailEntities = invProductDetailDao.selectByOrderId(id); Map> invProductDetailMap = invProductDetailEntities.stream().collect(Collectors.groupingBy(InvProductDetailEntity::getProductIdFk)); List invProductList = new ArrayList<>(invProductDetailMap.keySet().size()); for (InvProductDetailEntity invProductDetailEntity : invProductDetailEntities) { //查询库存 - Query queryInvProduct = Query.query(Criteria.where("relIdFk").is(invProductDetailEntity.getProductIdFk())) - .addCriteria(Criteria.where("locStorageCode").is(invProductDetailEntity.getLocStorageCode())); - if (StrUtil.isNotBlank(invProductDetailEntity.getBatchNo())) { - queryInvProduct.addCriteria(Criteria.where("batchNo").is(invProductDetailEntity.getBatchNo())); - } - InvProductEntity invProduct = mongoTemplate.findOne(queryInvProduct, InvProductEntity.class, MongoDBName.NAME_INV_PRODUCT); + QueryWrapper invWrapper = new QueryWrapper<>(); + invWrapper.eq("relIdFk", invProductDetailEntity.getProductIdFk()) + .eq("locStorageCode", invProductDetailEntity.getLocStorageCode()) + .eq(StrUtil.isNotBlank(invProductDetailEntity.getBatchNo()), "batchNo", invProductDetailEntity.getBatchNo()); + InvProductEntity invProduct = invProductDao.selectOne(invWrapper); if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) { //入库,在原有库存基础上减库存 int count = invProduct.getInCount() - invProductDetailEntity.getCount(); @@ -469,38 +466,30 @@ public class OrderService { //删除单据相关数据,更新库存 try { //删除库存详情 - mongoTemplate.remove(Query.query(Criteria.where("orderIdFk").is(id)), InvProductDetailEntity.class, MongoDBName.NAME_INV_PRODUCT_DETAIL); + invProductDetailDao.deleteByOrderId(id); //更新库存 for (InvProductEntity invProductEntity : invProductList) { //查询库存码详情,如果库存码详情为空,则删除此库存 - Query countQuery = Query.query(Criteria.where("productIdFk").is(invProductEntity.getRelIdFk())) - .addCriteria(Criteria.where("batchNo").is(invProductEntity.getBatchNo())) - .addCriteria(Criteria.where("locStorageCode").is(invProductEntity.getLocStorageCode())); - long count = mongoTemplate.count(countQuery, InvProductDetailEntity.class, MongoDBName.NAME_INV_PRODUCT_DETAIL); + QueryWrapper countQuery = new QueryWrapper<>(); + countQuery.eq("productIdFk", invProductEntity.getRelIdFk()) + .eq("batchNo", invProductEntity.getBatchNo()) + .eq("locStorageCode", invProductEntity.getLocStorageCode()); + long count = invProductDetailDao.selectCount(countQuery); if (count == 0) { //库存码详情为空,删除此库存 - Query query = new Query(); - query.addCriteria(Criteria.where("id").is(invProductEntity.getId())); - mongoTemplate.remove(query, InvProductEntity.class, MongoDBName.NAME_INV_PRODUCT); + invProductDao.deleteById(invProductEntity.getId()); } else { - Query query = new Query(); - query.addCriteria(Criteria.where("relIdFk").is(invProductEntity.getRelIdFk())); - 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); + //库存不为空,更新库存信息 + invProductDao.updateById(invProductEntity); } } //删除码详情 - 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) { log.error("删除单据失败", e); throw new RuntimeException("删除单据失败"); @@ -509,12 +498,11 @@ public class OrderService { //未验收单据,删除单据,单据详情,临时码表数据 try { //删除单据 - mongoTemplate.remove(queryOrder, OrderMdEntity.class, MongoDBName.NAME_ORDER); + orderDao.deleteById(id); //删除单据详情 - Query queryOrderDetail = Query.query(Criteria.where("orderIdFk").is(id)); - mongoTemplate.remove(queryOrderDetail, OrderDetailEntity.class, MongoDBName.NAME_ORDER_DETAIL); + orderDetailDao.deleteByOrderId(id); //删除临时码表 - mongoTemplate.remove(queryOrder, WarehouseEntity.class, MongoDBName.NAME_CODE_TEMP); + codesTempDao.deleteByOrderId(id); } catch (Exception e) { log.error("删除单据失败", e); throw new RuntimeException("删除单据失败"); diff --git a/src/main/java/com/glxp/udi/admin/mongo/service/WarehouseService.java b/src/main/java/com/glxp/udi/admin/service/inout/WarehouseService.java similarity index 99% rename from src/main/java/com/glxp/udi/admin/mongo/service/WarehouseService.java rename to src/main/java/com/glxp/udi/admin/service/inout/WarehouseService.java index 5a00d21..a5426e8 100644 --- a/src/main/java/com/glxp/udi/admin/mongo/service/WarehouseService.java +++ b/src/main/java/com/glxp/udi/admin/service/inout/WarehouseService.java @@ -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.util.StrUtil; diff --git a/src/main/java/com/glxp/udi/admin/mongo/service/WarehouseTempService.java b/src/main/java/com/glxp/udi/admin/service/inout/WarehouseTempService.java similarity index 98% rename from src/main/java/com/glxp/udi/admin/mongo/service/WarehouseTempService.java rename to src/main/java/com/glxp/udi/admin/service/inout/WarehouseTempService.java index 7bc1c79..3b803b5 100644 --- a/src/main/java/com/glxp/udi/admin/mongo/service/WarehouseTempService.java +++ b/src/main/java/com/glxp/udi/admin/service/inout/WarehouseTempService.java @@ -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.util.StrUtil; diff --git a/src/main/java/com/glxp/udi/admin/thread/InvProductsTrService.java b/src/main/java/com/glxp/udi/admin/thread/InvProductsTrService.java index eedce89..908b91a 100644 --- a/src/main/java/com/glxp/udi/admin/thread/InvProductsTrService.java +++ b/src/main/java/com/glxp/udi/admin/thread/InvProductsTrService.java @@ -5,11 +5,10 @@ import cn.hutool.core.util.StrUtil; import com.glxp.udi.admin.constant.ConstantStatus; import com.glxp.udi.admin.constant.TypeConstant; 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.OrderFilterRequest; 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 lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Lazy; diff --git a/src/main/java/com/glxp/udi/admin/thread/SubmitOrderToSpmsTask.java b/src/main/java/com/glxp/udi/admin/thread/SubmitOrderToSpmsTask.java index d747a83..c11ed54 100644 --- a/src/main/java/com/glxp/udi/admin/thread/SubmitOrderToSpmsTask.java +++ b/src/main/java/com/glxp/udi/admin/thread/SubmitOrderToSpmsTask.java @@ -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.WarehouseEntity; import com.glxp.udi.admin.entity.param.SystemParamConfigEntity; -import com.glxp.udi.admin.mongo.service.OrderDetailService; -import com.glxp.udi.admin.mongo.service.OrderService; -import com.glxp.udi.admin.mongo.service.WarehouseService; +import com.glxp.udi.admin.service.inout.OrderDetailService; +import com.glxp.udi.admin.service.inout.OrderService; +import com.glxp.udi.admin.service.inout.WarehouseService; import com.glxp.udi.admin.req.inout.FilterOrderDetailRequest; import com.glxp.udi.admin.req.inout.PostUdimsOrderDetailRequest; import com.glxp.udi.admin.req.inout.PostUdimsOrderRequest; diff --git a/src/main/java/com/glxp/udi/admin/thread/SupplementOrderTask.java b/src/main/java/com/glxp/udi/admin/thread/SupplementOrderTask.java index 077dd61..95bc5a2 100644 --- a/src/main/java/com/glxp/udi/admin/thread/SupplementOrderTask.java +++ b/src/main/java/com/glxp/udi/admin/thread/SupplementOrderTask.java @@ -6,9 +6,8 @@ import com.glxp.udi.admin.constant.SystemParamConstant; import com.glxp.udi.admin.dao.info.ScheduledDao; import com.glxp.udi.admin.entity.info.ScheduledEntity; 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.mongo.service.OrderService; +import com.glxp.udi.admin.service.inout.OrderService; import com.glxp.udi.admin.req.udidl.ScheduledRequest; import com.glxp.udi.admin.service.param.SystemParamConfigService; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/com/glxp/udi/admin/thread/TransInoutService.java b/src/main/java/com/glxp/udi/admin/thread/TransInoutService.java index 869eb7a..c3ca6a0 100644 --- a/src/main/java/com/glxp/udi/admin/thread/TransInoutService.java +++ b/src/main/java/com/glxp/udi/admin/thread/TransInoutService.java @@ -5,10 +5,10 @@ import cn.hutool.core.util.StrUtil; import com.glxp.udi.admin.constant.ConstantStatus; import com.glxp.udi.admin.entity.basic.BussinessTypeEntity; import com.glxp.udi.admin.entity.inout.*; -import com.glxp.udi.admin.mongo.service.OrderDetailService; -import com.glxp.udi.admin.mongo.service.OrderService; -import com.glxp.udi.admin.mongo.service.WarehouseService; -import com.glxp.udi.admin.mongo.service.WarehouseTempService; +import com.glxp.udi.admin.service.inout.OrderDetailService; +import com.glxp.udi.admin.service.inout.OrderService; +import com.glxp.udi.admin.service.inout.WarehouseService; +import com.glxp.udi.admin.service.inout.WarehouseTempService; import com.glxp.udi.admin.req.inout.OrderFilterRequest; import com.glxp.udi.admin.req.inout.PostOrderRequest; import com.glxp.udi.admin.service.basic.BussinessTypeService; diff --git a/src/main/java/com/glxp/udi/admin/thread/TransInoutTask.java b/src/main/java/com/glxp/udi/admin/thread/TransInoutTask.java index 3d6a987..189ad6e 100644 --- a/src/main/java/com/glxp/udi/admin/thread/TransInoutTask.java +++ b/src/main/java/com/glxp/udi/admin/thread/TransInoutTask.java @@ -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.inout.OrderEntity; 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.udidl.ScheduledRequest; import com.glxp.udi.admin.service.param.SystemParamConfigService; diff --git a/src/main/java/com/glxp/udi/admin/util/inout/InoutUtils.java b/src/main/java/com/glxp/udi/admin/util/inout/InoutUtils.java index a2cc07f..3ddb270 100644 --- a/src/main/java/com/glxp/udi/admin/util/inout/InoutUtils.java +++ b/src/main/java/com/glxp/udi/admin/util/inout/InoutUtils.java @@ -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.WarehousetempEntity; import com.glxp.udi.admin.entity.udid.UdiEntity; -import com.glxp.udi.admin.mongo.service.OrderDetailService; -import com.glxp.udi.admin.mongo.service.WarehouseService; +import com.glxp.udi.admin.service.inout.OrderDetailService; +import com.glxp.udi.admin.service.inout.WarehouseService; import com.glxp.udi.admin.req.inout.FilterWarehouseRequest; import com.glxp.udi.admin.service.info.SetupService; import com.glxp.udi.admin.service.inout.UdiInfoService; diff --git a/src/main/resources/mybatis/mapper/inout/CodesDao.xml b/src/main/resources/mybatis/mapper/inout/CodesDao.xml index b53a357..d792585 100644 --- a/src/main/resources/mybatis/mapper/inout/CodesDao.xml +++ b/src/main/resources/mybatis/mapper/inout/CodesDao.xml @@ -22,4 +22,7 @@ select * from io_codes where orderId = #{orderId} + + delete from io_codes where orderId = #{orderId} + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/inout/CodesTempDao.xml b/src/main/resources/mybatis/mapper/inout/CodesTempDao.xml index f8501cc..9702e9c 100644 --- a/src/main/resources/mybatis/mapper/inout/CodesTempDao.xml +++ b/src/main/resources/mybatis/mapper/inout/CodesTempDao.xml @@ -14,4 +14,7 @@ select * from io_codes_temp where orderId = #{orderId} + + delete from io_codes_temp where orderId = #{orderId} + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/inout/InvProductDao.xml b/src/main/resources/mybatis/mapper/inout/InvProductDao.xml new file mode 100644 index 0000000..c04bbf3 --- /dev/null +++ b/src/main/resources/mybatis/mapper/inout/InvProductDao.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/inout/InvProductDetailDao.xml b/src/main/resources/mybatis/mapper/inout/InvProductDetailDao.xml new file mode 100644 index 0000000..ffcffdd --- /dev/null +++ b/src/main/resources/mybatis/mapper/inout/InvProductDetailDao.xml @@ -0,0 +1,14 @@ + + + + + + + + delete from io_inv_product_detail where orderIdFk = #{orderId} + + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/inout/OrderDetailDao.xml b/src/main/resources/mybatis/mapper/inout/OrderDetailDao.xml new file mode 100644 index 0000000..8999a2d --- /dev/null +++ b/src/main/resources/mybatis/mapper/inout/OrderDetailDao.xml @@ -0,0 +1,8 @@ + + + + + + delete from io_order_detail where orderIdFk = #{orderId} + + \ No newline at end of file