From a4dee1002ed1a39b6a43c3b3120818f6f619d0b1 Mon Sep 17 00:00:00 2001 From: yangshb Date: Tue, 5 Mar 2024 17:08:22 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=B7=BB=E5=8A=A0mybatis=20SQL=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=89=93=E5=8D=B0=EF=BC=8C2.=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=9C=AA=E6=8E=92=E5=8D=95=E7=9A=84=E6=9D=BF?= =?UTF-8?q?=E6=9D=90=E7=94=9F=E4=BA=A7=E5=8D=95=E6=9D=BF=E6=9D=90=E5=88=86?= =?UTF-8?q?=E9=A1=B5=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/plan/PlanController.java | 2 +- .../controller/admin/plan/vo/OrderRespVO.java | 10 +- .../admin/plan/vo/PlanSaveReqVO.java | 1 - .../executor/dal/mysql/order/OrderMapper.java | 5 +- .../service/plan/PlanServiceImpl.java | 91 +++++++++++-------- .../src/main/resources/application-dev.yaml | 4 + .../src/main/resources/application-local.yaml | 4 + .../resources/mapper/order/OrderMapper.xml | 13 +-- .../src/main/resources/application-dev.yaml | 4 + .../src/main/resources/application-local.yaml | 4 + .../src/main/resources/application-dev.yaml | 4 + .../src/main/resources/application-local.yaml | 4 + 12 files changed, 96 insertions(+), 50 deletions(-) diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/PlanController.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/PlanController.java index 8daa49ee4..2cdda016c 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/PlanController.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/PlanController.java @@ -80,7 +80,7 @@ public class PlanController { } @GetMapping("getOrderPageByPlanId") - @Operation(summary = "获取生产单分页") + @Operation(summary = "获取未排单的板材生产单板材分页列表") @PreAuthorize("@ss.hasPermission('executor:plan:query')") public CommonResult> getOrderPage(@Valid OrderPageReqVO pageReqVO) { return success(planService.getOrderPage(pageReqVO)); diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/OrderRespVO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/OrderRespVO.java index a3062d88f..752c3d536 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/OrderRespVO.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/OrderRespVO.java @@ -34,7 +34,13 @@ public class OrderRespVO { @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) private Date deliveryDate; @Schema(description = "片数") - private Integer num; + private int num; @Schema(description = "平方") - private BigDecimal area; + private BigDecimal area = new BigDecimal("0"); + @Schema(description = "商品名称") + private String goodsName; + @Schema(description = "颜色") + private String color; + @Schema(description = "材质:颗粒板、欧松板、多层板、生态板、禾香板、密度板、实木、铝蜂窝板、铝塑板") + private String material; } \ No newline at end of file diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlanSaveReqVO.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlanSaveReqVO.java index 0b77b21bb..1ea3c629f 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlanSaveReqVO.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/controller/admin/plan/vo/PlanSaveReqVO.java @@ -15,7 +15,6 @@ public class PlanSaveReqVO { private Long id; @Schema(description = "排单号", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "排单号不能为空") private String planNo; @Schema(description = "排序优先级", requiredMode = Schema.RequiredMode.REQUIRED) diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/order/OrderMapper.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/order/OrderMapper.java index 0143e81b0..257d4121d 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/order/OrderMapper.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/dal/mysql/order/OrderMapper.java @@ -2,7 +2,9 @@ package com.cf.imes.module.executor.dal.mysql.order; import java.util.*; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Constants; import com.cf.imes.framework.common.pojo.PageResult; import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX; import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX; @@ -10,6 +12,7 @@ import com.cf.imes.module.executor.controller.admin.plan.vo.OrderPageReqVO; import com.cf.imes.module.executor.controller.admin.plan.vo.OrderRespVO; import com.cf.imes.module.executor.dal.dataobject.order.OrderDO; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * 生产单表 order_{N} Mapper @@ -40,5 +43,5 @@ public interface OrderMapper extends BaseMapperX { .orderByDesc(OrderDO::getId)); } - IPage selectOrderPage(IPage page, OrderPageReqVO pageReqVO); + IPage selectOrderPage(@Param("page") IPage page, @Param(Constants.WRAPPER) Wrapper wrapper); } diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plan/PlanServiceImpl.java b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plan/PlanServiceImpl.java index 6bce3208d..71075f027 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plan/PlanServiceImpl.java +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/java/com/cf/imes/module/executor/service/plan/PlanServiceImpl.java @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO; import com.cf.imes.framework.common.util.date.LocalDateTimeUtils; import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX; +import com.cf.imes.framework.mybatis.core.query.QueryWrapperX; import com.cf.imes.module.executor.dal.dataobject.goods.GoodsDO; import com.cf.imes.module.executor.dal.dataobject.order.OrderDO; import com.cf.imes.module.executor.dal.dataobject.orderItem.OrderItemDO; @@ -21,7 +22,9 @@ import com.cf.imes.module.executor.dal.mysql.planitem.PlanItemMapper; import com.cf.imes.module.executor.dal.mysql.planorder.PlanOrderMapper; import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper; import org.springframework.stereotype.Service; + import javax.annotation.Resource; + import org.springframework.validation.annotation.Validated; import org.springframework.transaction.annotation.Transactional; @@ -64,7 +67,7 @@ public class PlanServiceImpl implements PlanService { @Resource private OrderItemMapper orderItemMapper; - + @Resource private OrderMapper orderMapper; @@ -79,10 +82,10 @@ public class PlanServiceImpl implements PlanService { planMapper.insert(plan); Long planId = plan.getId(); List orderIds = createReqVO.getOrderIds(); - if(CollectionUtil.isNotEmpty(orderIds)) { + if (CollectionUtil.isNotEmpty(orderIds)) { ArrayList planOrderDOS = new ArrayList<>(); for (Long orderId : orderIds) { - planOrderDOS.add( PlanOrderDO.builder() + planOrderDOS.add(PlanOrderDO.builder() .planId(planId) .orderId(orderId) .build()); @@ -90,10 +93,10 @@ public class PlanServiceImpl implements PlanService { planOrderMapper.insertBatch(planOrderDOS); } List plateIds = createReqVO.getPlateIds(); - if(CollectionUtil.isNotEmpty(plateIds)) { + if (CollectionUtil.isNotEmpty(plateIds)) { ArrayList planItemDOS = new ArrayList<>(); for (Long plateId : plateIds) { - planItemDOS.add( PlanItemDO.builder() + planItemDOS.add(PlanItemDO.builder() .planId(planId) .itemId(plateId) .build()); @@ -118,10 +121,10 @@ public class PlanServiceImpl implements PlanService { planItemMapper.delete(new LambdaQueryWrapperX().eq(PlanItemDO::getPlanId, planId)); List orderIds = updateReqVO.getOrderIds(); - if(CollectionUtil.isNotEmpty(orderIds)) { + if (CollectionUtil.isNotEmpty(orderIds)) { ArrayList planOrderDOS = new ArrayList<>(); for (Long orderId : orderIds) { - planOrderDOS.add( PlanOrderDO.builder() + planOrderDOS.add(PlanOrderDO.builder() .planId(planId) .orderId(orderId) .build()); @@ -129,10 +132,10 @@ public class PlanServiceImpl implements PlanService { planOrderMapper.insertBatch(planOrderDOS); } List plateIds = updateReqVO.getPlateIds(); - if(CollectionUtil.isNotEmpty(plateIds)) { + if (CollectionUtil.isNotEmpty(plateIds)) { ArrayList planItemDOS = new ArrayList<>(); for (Long plateId : plateIds) { - planItemDOS.add( PlanItemDO.builder() + planItemDOS.add(PlanItemDO.builder() .planId(planId) .itemId(plateId) .build()); @@ -180,9 +183,9 @@ public class PlanServiceImpl implements PlanService { Set ids = planDOPageResult.getList().stream().map(e -> e.getId()).collect(Collectors.toSet()); List goodsDOS = goodsMapper.selectList(new LambdaQueryWrapperX().in(GoodsDO::getOrderNo, ids)); PageResult planRespVOPageResult = BeanUtils.toBean(planDOPageResult, PlanRespVO.class); - planRespVOPageResult.getList().stream().forEach(e->{ + planRespVOPageResult.getList().stream().forEach(e -> { e.setPlateInfoList(goodsDOS.stream() - .filter(f->Objects.equals(f.getOrderNo(), e.getId())) + .filter(f -> Objects.equals(f.getOrderNo(), e.getId())) .map(p -> PlateInfoVO.builder() .width(p.getWidth()) .height(p.getHeight()) @@ -197,42 +200,52 @@ public class PlanServiceImpl implements PlanService { @Override public PageResult getOrderPage(OrderPageReqVO pageReqVO) { PageDTO page = new PageDTO<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); - orderMapper.selectOrderPage(page, pageReqVO); - PageResult orderDOPageResult = orderMapper.selectPage(pageReqVO, new LambdaQueryWrapperX() + + QueryWrapperX queryWrapperX = new QueryWrapperX<>(); + queryWrapperX + .eqIfPresent("customer", pageReqVO.getConsignee()) + .eqIfPresent("address", pageReqVO.getConsigneeAddress()) + .eqIfPresent("custom_order_no", pageReqVO.getDefaultId()) + .betweenIfPresent("delivery_date" ,new Date[]{pageReqVO.getBeginDate(), pageReqVO.getEndDate()}) + .isNull("d.order_id") + ; + + LambdaQueryWrapperX wrapper = new LambdaQueryWrapperX() .eqIfPresent(OrderDO::getId, pageReqVO.getOrderId()) .eqIfPresent(OrderDO::getCustomer, pageReqVO.getConsignee()) .eqIfPresent(OrderDO::getAddress, pageReqVO.getConsigneeAddress()) .eqIfPresent(OrderDO::getCustomOrderNo, pageReqVO.getDefaultId()) .betweenIfPresent(OrderDO::getDeliveryDate, new Date[]{pageReqVO.getBeginDate(), pageReqVO.getEndDate()}) - ); - Set orderIds = orderDOPageResult.getList().stream().map(e -> e.getId()).collect(Collectors.toSet()); + ; - Set dataIds = orderItemMapper.selectList(new LambdaQueryWrapperX().in(OrderItemDO::getOrderId, orderIds)) + IPage orderDOPageResult = orderMapper.selectOrderPage(page, queryWrapperX); + if (CollectionUtil.isEmpty(orderDOPageResult.getRecords())) { + return new PageResult<>(); + } + //TODO 获取面积 +/* + Set orderIds = orderDOPageResult.getRecords().stream().map(e -> e.getOrderId()).collect(Collectors.toSet()); + + Set dataIds = orderItemMapper.selectList(new LambdaQueryWrapperX().notIn(OrderItemDO::getOrderId, orderIds)) .stream().map(e -> e.getDataId()).collect(Collectors.toSet()); - List plateDOS = plateMapper.selectList(new LambdaQueryWrapperX().in(PlateDO::getId, dataIds)); - - List list = orderDOPageResult.getList().stream().map(e -> { - List plateDOList = plateDOS.stream().filter(f -> Objects.equals(e.getOrganId(), e.getId())).collect(Collectors.toList()); - BigDecimal area = new BigDecimal("0"); - if(CollectionUtil.isNotEmpty(plateDOList)) { - for (PlateDO plateDO : plateDOList) { - area.add( plateDO.getWidth().multiply(plateDO.getHeight())); - } - } - area.setScale(2, RoundingMode.HALF_UP); - return OrderRespVO.builder() - .orderId(e.getId()) - .address(e.getAddress()) - .customer(e.getCustomer()) - .defineId(e.getCustomOrderNo()) - .deliveryDate(DateUtil.date(e.getDeliveryDate())) - .num(plateDOList.size()) - .area(area) - .build(); - } - ).collect(Collectors.toList()); - return new PageResult<>(list, orderDOPageResult.getTotal()); + if (CollectionUtil.isNotEmpty(dataIds)) { + List plateDOS = plateMapper.selectList(new LambdaQueryWrapperX().in(PlateDO::getId, dataIds)); + orderDOPageResult.getRecords().stream().forEach(e -> { + List plateDOList = plateDOS.stream().filter(f -> Objects.equals(e.getOrderId(), f.getId())).collect(Collectors.toList()); + BigDecimal area = new BigDecimal("0"); + if (CollectionUtil.isNotEmpty(plateDOList)) { + for (PlateDO plateDO : plateDOList) { + area.add(plateDO.getWidth().multiply(plateDO.getHeight())); + } + } + area.setScale(2, RoundingMode.HALF_UP); + e.setArea(area); + } + ); + }*/ + // return new PageResult<>(list, orderDOPageResult.getTotal()); + return new PageResult<>(orderDOPageResult.getRecords(), orderDOPageResult.getTotal()); } } \ No newline at end of file diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/application-dev.yaml b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/application-dev.yaml index 408ad18d3..396629487 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/application-dev.yaml +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/application-dev.yaml @@ -166,3 +166,7 @@ justauth: type: REDIS prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE:: timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟 + +mybatis-plus: + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #开启sql日志 \ No newline at end of file diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/application-local.yaml b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/application-local.yaml index 08f07aff4..9882bd664 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/application-local.yaml +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/application-local.yaml @@ -135,3 +135,7 @@ chenfeng: error-code: # 错误码相关配置项 enable: false demo: false # 关闭演示模式 + +mybatis-plus: + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #开启sql日志 \ No newline at end of file diff --git a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/order/OrderMapper.xml b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/order/OrderMapper.xml index 44f26832b..58c0a8029 100644 --- a/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/order/OrderMapper.xml +++ b/cf-module-prod-executor/cf-module-prod-executor-biz/src/main/resources/mapper/order/OrderMapper.xml @@ -2,13 +2,14 @@ - \ No newline at end of file diff --git a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/resources/application-dev.yaml b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/resources/application-dev.yaml index 5d8c4dfcc..cab696a4d 100644 --- a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/resources/application-dev.yaml +++ b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/resources/application-dev.yaml @@ -166,3 +166,7 @@ justauth: type: REDIS prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE:: timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟 + +mybatis-plus: + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #开启sql日志 \ No newline at end of file diff --git a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/resources/application-local.yaml b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/resources/application-local.yaml index 3593162a2..9d6697e2a 100644 --- a/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/resources/application-local.yaml +++ b/cf-module-prod-manage/cf-module-prod-manage-biz/src/main/resources/application-local.yaml @@ -133,3 +133,7 @@ chenfeng: error-code: # 错误码相关配置项 enable: false demo: false # 关闭演示模式 + +mybatis-plus: + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #开启sql日志 \ No newline at end of file diff --git a/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/resources/application-dev.yaml b/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/resources/application-dev.yaml index 5d8c4dfcc..cab696a4d 100644 --- a/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/resources/application-dev.yaml +++ b/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/resources/application-dev.yaml @@ -166,3 +166,7 @@ justauth: type: REDIS prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE:: timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟 + +mybatis-plus: + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #开启sql日志 \ No newline at end of file diff --git a/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/resources/application-local.yaml b/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/resources/application-local.yaml index 08f07aff4..9882bd664 100644 --- a/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/resources/application-local.yaml +++ b/cf-module-prod-plan/cf-module-prod-plan-biz/src/main/resources/application-local.yaml @@ -135,3 +135,7 @@ chenfeng: error-code: # 错误码相关配置项 enable: false demo: false # 关闭演示模式 + +mybatis-plus: + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #开启sql日志 \ No newline at end of file