From f6fd34f8a421908534e780b450057da26bd594fe Mon Sep 17 00:00:00 2001 From: x_z Date: Wed, 28 Sep 2022 21:45:30 +0800 Subject: [PATCH] =?UTF-8?q?1.=E8=B0=83=E6=95=B4=E5=88=A0=E9=99=A4=E4=B8=B4?= =?UTF-8?q?=E6=97=B6=E7=A0=81=E8=A1=A8=E6=95=B0=E6=8D=AE=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E5=BD=93=E5=8D=95=E6=8D=AE=E4=B8=8D=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=97=B6=EF=BC=8C=E5=88=A0=E9=99=A4=E5=8D=95?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/inout/WareHouseController.java | 33 ++++-------------- .../udi/admin/dao/inout/CodesTempDao.java | 8 +++++ .../udi/admin/dao/inout/OrderDetailDao.java | 8 +++++ .../inout/InvProductDetailService.java | 2 ++ .../service/inout/InvProductService.java | 2 ++ .../service/inout/OrderDetailService.java | 15 +++----- .../udi/admin/service/inout/OrderService.java | 2 ++ .../admin/service/inout/WarehouseService.java | 2 ++ .../service/inout/WarehouseTempService.java | 34 ++++++++++++++++++- .../mybatis/mapper/inout/CodesTempDao.xml | 4 +++ .../mybatis/mapper/inout/OrderDetailDao.xml | 24 +++++++++++++ 11 files changed, 96 insertions(+), 38 deletions(-) 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 44cc435..0669110 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 @@ -11,27 +11,24 @@ 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.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; import com.glxp.udi.admin.res.basic.BussinessTypResponse; import com.glxp.udi.admin.service.auth.AuthAdminService; -import com.glxp.udi.admin.service.inout.UdiInfoService; -import com.glxp.udi.admin.service.inout.WarehouseBussinessTypeService; -import com.glxp.udi.admin.service.inout.WarehouseUserService; +import com.glxp.udi.admin.service.inout.*; import com.glxp.udi.admin.thread.TransInoutService; import com.glxp.udi.admin.util.FilterUdiUtils; import com.glxp.udi.common.enums.ResultEnum; import com.glxp.udi.common.util.ResultVOUtils; import org.springframework.validation.BindingResult; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import javax.validation.Valid; -import java.util.Collections; import java.util.List; import java.util.Map; @@ -86,25 +83,7 @@ public class WareHouseController { @AuthRuleAnnotation("") @GetMapping("warehouse/inout/deleteCodesTempById") public BaseResponse deleteCodesTempById(String id) { - WarehousetempEntity warehousetemp = warehouseTempService.findTempById(id); - if (null == warehousetemp) { - return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); - } - - if (warehousetemp.getCount() != null && warehousetemp.getCount() > 1) { - warehousetemp.setCount(warehousetemp.getCount() - 1); - warehouseTempService.updateById(warehousetemp); - } else { - warehouseTempService.deleteTempWarehouses(Collections.singletonList(warehousetemp.getId())); - } - - List tempByOrderId = warehouseTempService.findTempByOrderId(warehousetemp.getOrderId()); - if (tempByOrderId.size() == 0) { - DeleteRequest deleteRequest = new DeleteRequest(); - deleteRequest.setOrderId(warehousetemp.getOrderId()); - warehouseTempService.deleteCode(deleteRequest); - } - return ResultVOUtils.success(); + return warehouseTempService.deleteCodesTempById(id); } /** 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 8f72507..aea8e98 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 @@ -51,4 +51,12 @@ public interface CodesTempDao extends BaseMapper { * @param orderId */ void updateActDateByOrderId(@Param("actDate") String actDate, @Param("orderId") String orderId); + + /** + * 根据单据号,统计临时码表数据 + * + * @param orderId + * @return + */ + int countByOrderId(@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 91d376c..0d4eb25 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 @@ -17,4 +17,12 @@ public interface OrderDetailDao extends BaseMapper { * @param id */ void deleteByOrderId(@Param("orderId") String orderId); + + /** + * 更新所有字段值 + * + * @param orderDetailEntity + */ + void update(OrderDetailEntity orderDetailEntity); + } diff --git a/src/main/java/com/glxp/udi/admin/service/inout/InvProductDetailService.java b/src/main/java/com/glxp/udi/admin/service/inout/InvProductDetailService.java index 3e9b403..c0aa89c 100644 --- a/src/main/java/com/glxp/udi/admin/service/inout/InvProductDetailService.java +++ b/src/main/java/com/glxp/udi/admin/service/inout/InvProductDetailService.java @@ -11,11 +11,13 @@ import com.glxp.udi.admin.entity.udid.UdiEntity; import com.glxp.udi.admin.req.inout.FilterInvProductDetailRequest; import com.glxp.udi.admin.util.FilterUdiUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.List; @Service +@Transactional(rollbackFor = Exception.class) public class InvProductDetailService { @Resource diff --git a/src/main/java/com/glxp/udi/admin/service/inout/InvProductService.java b/src/main/java/com/glxp/udi/admin/service/inout/InvProductService.java index 8d3e555..4d03474 100644 --- a/src/main/java/com/glxp/udi/admin/service/inout/InvProductService.java +++ b/src/main/java/com/glxp/udi/admin/service/inout/InvProductService.java @@ -9,11 +9,13 @@ import com.glxp.udi.admin.dao.inout.InvProductDao; import com.glxp.udi.admin.entity.inout.InvProductEntity; import com.glxp.udi.admin.req.inventory.FilterInvProductRequest; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.List; @Service +@Transactional(rollbackFor = Exception.class) public class InvProductService { @Resource diff --git a/src/main/java/com/glxp/udi/admin/service/inout/OrderDetailService.java b/src/main/java/com/glxp/udi/admin/service/inout/OrderDetailService.java index e5668b3..625ab00 100644 --- a/src/main/java/com/glxp/udi/admin/service/inout/OrderDetailService.java +++ b/src/main/java/com/glxp/udi/admin/service/inout/OrderDetailService.java @@ -9,11 +9,13 @@ 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.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.List; @Service +@Transactional(rollbackFor = Exception.class) public class OrderDetailService { @Resource @@ -41,15 +43,8 @@ public class OrderDetailService { public void updateOrderDetail(OrderDetailEntity orderDetailEntity) { UpdateWrapper updateWrapper = new UpdateWrapper<>(); - updateWrapper.setEntity(orderDetailEntity); - updateWrapper - .set("price", orderDetailEntity.getPrice()) - .set("firstSalesInvNo", orderDetailEntity.getFirstSalesInvNo()) - .set("secSalesInvNo", orderDetailEntity.getSecSalesInvNo()) - .set("secSalesListNo", orderDetailEntity.getSecSalesListNo()) - .set("invoiceDate", orderDetailEntity.getInvoiceDate()) - .eq("id", orderDetailEntity.getId()); - orderDetailDao.update(orderDetailEntity, updateWrapper); + updateWrapper.eq("id", orderDetailEntity.getId()); + orderDetailDao.update(orderDetailEntity); } public long statCount(String orderId) { @@ -70,7 +65,7 @@ public class OrderDetailService { .eq(StrUtil.isNotBlank(orderDetailRequest.getOrderIdFk()), "orderIdFk", orderDetailRequest.getOrderIdFk()) .eq(null != orderDetailRequest.getCustomerId(), "customerId", orderDetailRequest.getCustomerId()) .eq(StrUtil.isNotBlank(orderDetailRequest.getUuidFk()), "uuidFk", orderDetailRequest.getUuidFk()) - .eq(StrUtil.isNotBlank(orderDetailRequest.getRelId()),"relId", orderDetailRequest.getRelId()) + .eq(StrUtil.isNotBlank(orderDetailRequest.getRelId()), "relId", orderDetailRequest.getRelId()) .eq(StrUtil.isNotBlank(orderDetailRequest.getLotno()), "batchNo", orderDetailRequest.getLotno()); return wrapper; } diff --git a/src/main/java/com/glxp/udi/admin/service/inout/OrderService.java b/src/main/java/com/glxp/udi/admin/service/inout/OrderService.java index c3b919c..d6118cd 100644 --- a/src/main/java/com/glxp/udi/admin/service/inout/OrderService.java +++ b/src/main/java/com/glxp/udi/admin/service/inout/OrderService.java @@ -32,6 +32,7 @@ import com.glxp.udi.common.util.ResultVOUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.lang.reflect.Field; @@ -40,6 +41,7 @@ import java.util.stream.Collectors; @Slf4j @Service +@Transactional(rollbackFor = Exception.class) public class OrderService { @Lazy diff --git a/src/main/java/com/glxp/udi/admin/service/inout/WarehouseService.java b/src/main/java/com/glxp/udi/admin/service/inout/WarehouseService.java index 8fea0d7..adc5ae4 100644 --- a/src/main/java/com/glxp/udi/admin/service/inout/WarehouseService.java +++ b/src/main/java/com/glxp/udi/admin/service/inout/WarehouseService.java @@ -15,12 +15,14 @@ import com.glxp.udi.admin.req.inout.*; import com.glxp.udi.admin.req.inventory.FilterInvProductRequest; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.Collections; import java.util.List; @Service +@Transactional(rollbackFor = Exception.class) public class WarehouseService { @Lazy diff --git a/src/main/java/com/glxp/udi/admin/service/inout/WarehouseTempService.java b/src/main/java/com/glxp/udi/admin/service/inout/WarehouseTempService.java index c569214..8e0325d 100644 --- a/src/main/java/com/glxp/udi/admin/service/inout/WarehouseTempService.java +++ b/src/main/java/com/glxp/udi/admin/service/inout/WarehouseTempService.java @@ -5,22 +5,28 @@ 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.dao.inout.CodesTempDao; +import com.glxp.udi.admin.dao.inout.OrderDao; import com.glxp.udi.admin.entity.inout.WarehousetempEntity; import com.glxp.udi.admin.req.inout.DeleteRequest; import com.glxp.udi.admin.req.inout.WarehouseQueryRequest; +import com.glxp.udi.common.enums.ResultEnum; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.util.Collections; import java.util.List; @Service -@Transactional +@Transactional(rollbackFor = Exception.class) public class WarehouseTempService { @Resource private CodesTempDao codesTempDao; + @Resource + private OrderDao orderDao; public IPage filterWarehouseByPage(WarehouseQueryRequest warehouseQueryRequest) { QueryWrapper wrapper = buildCodesTempQueryWrapper(warehouseQueryRequest); @@ -82,4 +88,30 @@ public class WarehouseTempService { public void deleteCodes(List ids) { codesTempDao.deleteBatchIds(ids); } + + /** + * 删除临时码表数据 + * + * @param id + */ + public BaseResponse deleteCodesTempById(String id) { + WarehousetempEntity warehousetemp = findTempById(id); + if (null == warehousetemp) { + return com.glxp.udi.common.util.ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); + } + + if (warehousetemp.getCount() != null && warehousetemp.getCount() > 1) { + warehousetemp.setCount(warehousetemp.getCount() - 1); + updateById(warehousetemp); + } else { + deleteTempWarehouses(Collections.singletonList(id)); + } + + //判断此单据是否还存在条码,如果不存在,则直接删除此单据 + int count = codesTempDao.countByOrderId(warehousetemp.getOrderId()); + if (count == 0) { + orderDao.deleteById(warehousetemp.getOrderId()); + } + return com.glxp.udi.common.util.ResultVOUtils.success(); + } } diff --git a/src/main/resources/mybatis/mapper/inout/CodesTempDao.xml b/src/main/resources/mybatis/mapper/inout/CodesTempDao.xml index 48e6a91..13c4941 100644 --- a/src/main/resources/mybatis/mapper/inout/CodesTempDao.xml +++ b/src/main/resources/mybatis/mapper/inout/CodesTempDao.xml @@ -30,4 +30,8 @@ update io_codes_temp set actDate = #{actDate} where orderId = #{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 index 243cec5..6fa9fdc 100644 --- a/src/main/resources/mybatis/mapper/inout/OrderDetailDao.xml +++ b/src/main/resources/mybatis/mapper/inout/OrderDetailDao.xml @@ -7,4 +7,28 @@ from io_order_detail where orderIdFk = #{orderId} + + + update io_order_detail + set orderIdFk = #{orderIdFk}, + relId = #{relId}, + uuidFk = #{uuidFk}, + nameCode = #{nameCode}, + batchNo = #{batchNo}, + productName = #{productName}, + productCompany = #{productCompany}, + produceDate = #{produceDate}, + expireDate = #{expireDate}, + zczbhhzbapzbh = #{zczbhhzbapzbh}, + ggxh = #{ggxh}, + packRatio = #{packRatio}, + reCount = #{reCount}, + count = #{count}, + price = #{price}, + firstSalesInvNo = #{firstSalesInvNo}, + secSalesInvNo = #{secSalesInvNo}, + secSalesListNo = #{secSalesListNo}, + invoiceDate = #{invoiceDate} + where id = #{id} + \ No newline at end of file