diff --git a/common-ruoyi/ruoyi-generator/src/main/resources/vm/xml/mapper.xml.vm b/common-ruoyi/ruoyi-generator/src/main/resources/vm/xml/mapper.xml.vm index e93dba0..397bcc9 100644 --- a/common-ruoyi/ruoyi-generator/src/main/resources/vm/xml/mapper.xml.vm +++ b/common-ruoyi/ruoyi-generator/src/main/resources/vm/xml/mapper.xml.vm @@ -109,12 +109,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #end values - + #foreach($column in $columns) #if($column.columnName != $pkColumn.columnName || !$pkColumn.increment) - #{$column.javaField}, - default, + #{i.$column.javaField}, + default, #end #end @@ -128,7 +128,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #if($column.columnName != $pkColumn.columnName || !$pkColumn.increment) - + WHEN #{item.$pkColumn.columnName} THEN #{item.$column.javaField} diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/domain/Order.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/domain/Order.java index cd62dd8..94e696f 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/domain/Order.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/domain/Order.java @@ -49,4 +49,7 @@ public class Order extends BaseEntity @Size(max = 50, message = "客户长度不能超过50个字符") private String customer; + @Excel(name = "订单状态", readConverterExp = "1=拟定,2=已发布,3=完工") + @ApiModelProperty("订单状态") + private String status; } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/domain/OrderBO.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/domain/OrderBO.java index 0eaa592..196ac7c 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/domain/OrderBO.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/domain/OrderBO.java @@ -22,4 +22,7 @@ public class OrderBO extends Order{ @Valid private List prodList; + @ApiModelProperty("旧订单信息") + private OrderVO old; + } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/domain/OrderVO.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/domain/OrderVO.java index 3c6f697..62bfd6a 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/domain/OrderVO.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/domain/OrderVO.java @@ -1,7 +1,11 @@ package com.ruoyi.bst.order.domain; +import com.ruoyi.bst.orderProd.domain.OrderProdVO; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.List; + /** * @author wjh * 2024/12/16 @@ -9,4 +13,7 @@ import lombok.Data; @Data public class OrderVO extends Order{ + @ApiModelProperty("产品列表") + private List prodList; + } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/domain/enums/OrderStatus.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/domain/enums/OrderStatus.java new file mode 100644 index 0000000..b75d721 --- /dev/null +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/domain/enums/OrderStatus.java @@ -0,0 +1,47 @@ +package com.ruoyi.bst.order.domain.enums; + +import com.ruoyi.common.utils.collection.CollectionUtils; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.List; + +/** + * @author wjh + * 2024/12/18 + */ +@Getter +@AllArgsConstructor +public enum OrderStatus { + + PROPOSED("1", "拟定"), + RELEASED("2", "已发布"), + FINISHED("3", "完工"); + + private final String status; + private final String msg; + + // 允许修改的列表 + public static List canEdit() { + return asList(PROPOSED); + } + + // 允许发布的列表 + public static List canRelease() { + return asList(PROPOSED); + } + + // 允许完工的列表 + public static List canFinished() { + return asList(RELEASED); + } + + // 允许删除的列表 + public static List canDel() { + return asList(PROPOSED); + } + + public static List asList(OrderStatus ...statuses) { + return CollectionUtils.map(OrderStatus::getStatus, statuses); + } +} diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/mapper/OrderMapper.xml b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/mapper/OrderMapper.xml index 3183538..d7ca3fd 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/mapper/OrderMapper.xml +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/mapper/OrderMapper.xml @@ -17,7 +17,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" bo.remark, bo.create_by, bo.create_time, - bo.deleted + bo.deleted, + bo.status from bst_order bo @@ -29,6 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and bo.create_by like concat('%', #{query.createBy}, '%') and bo.deleted = #{query.deleted} and bo.deleted = false + and status = #{query.status} ${query.params.dataScope} @@ -56,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" create_by, create_time, deleted, + `status`, #{orderNo}, @@ -67,6 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{createBy}, #{createTime}, #{deleted}, + #{status}, @@ -88,6 +92,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" create_by = #{data.createBy}, create_time = #{data.createTime}, deleted = #{data.deleted}, + `status` = #{data.status}, diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/OrderAssembler.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/OrderAssembler.java new file mode 100644 index 0000000..3248085 --- /dev/null +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/OrderAssembler.java @@ -0,0 +1,24 @@ +package com.ruoyi.bst.order.service; + +import com.ruoyi.bst.order.domain.OrderVO; + +import java.util.Collections; +import java.util.List; + +/** + * @author wjh + * 2024/12/18 + */ +public interface OrderAssembler { + + /** + * 拼接产品列表 + * @param list 订单列表 + * @param assembleProcess 是否拼接工序 + */ + void assembleProdList(List list, boolean assembleProcess); + + default void assembleProdList(OrderVO vo, boolean assembleProcess) { + assembleProdList(Collections.singletonList(vo), assembleProcess); + } +} diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/OrderConverter.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/OrderConverter.java index 7fc1749..eb2b7f7 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/OrderConverter.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/OrderConverter.java @@ -11,12 +11,11 @@ public interface OrderConverter { /** * 新增时转为BO - * - * @param data - * @param submit - * @param user - * @return */ OrderBO toBOByCreate(OrderBO data, boolean submit, SysUser user); + /** + * 修改时转为BO + */ + OrderBO toBOByUpdate(OrderBO order, Boolean submit, SysUser user); } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/IOrderService.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/OrderService.java similarity index 93% rename from common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/IOrderService.java rename to common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/OrderService.java index 93bbf0d..c58f06f 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/IOrderService.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/OrderService.java @@ -13,7 +13,7 @@ import java.util.List; * @author ruoyi * @date 2024-12-16 */ -public interface IOrderService +public interface OrderService { /** * 查询生产订单 @@ -67,4 +67,9 @@ public interface IOrderService * 新增 */ int addOrder(OrderBO order); + + /** + * 修改 + */ + int editOrder(OrderBO order); } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/OrderValidator.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/OrderValidator.java index a57db49..45de0d1 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/OrderValidator.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/OrderValidator.java @@ -1,6 +1,7 @@ package com.ruoyi.bst.order.service; import com.ruoyi.bst.order.domain.OrderBO; +import com.ruoyi.bst.order.domain.OrderVO; /** * @author wjh @@ -12,4 +13,10 @@ public interface OrderValidator { * 新增,修改前置校验 */ void checkBefore(OrderBO data); + + /** + * 后校验 + */ + void checkAfter(OrderVO vo); + } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/impl/OrderAssemblerImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/impl/OrderAssemblerImpl.java new file mode 100644 index 0000000..7110331 --- /dev/null +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/impl/OrderAssemblerImpl.java @@ -0,0 +1,61 @@ +package com.ruoyi.bst.order.service.impl; + +import com.ruoyi.bst.order.domain.OrderVO; +import com.ruoyi.bst.order.service.OrderAssembler; +import com.ruoyi.bst.orderProd.domain.OrderProdQuery; +import com.ruoyi.bst.orderProd.domain.OrderProdVO; +import com.ruoyi.bst.orderProd.service.IOrderProdService; +import com.ruoyi.bst.orderProd.service.OrderProdAssembler; +import com.ruoyi.common.utils.collection.CollectionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @author wjh + * 2024/12/18 + */ +@Service +public class OrderAssemblerImpl implements OrderAssembler { + + @Autowired + private IOrderProdService orderProdService; + + @Autowired + private OrderProdAssembler orderProdAssembler; + + @Override + public void assembleProdList(List list, boolean assembleProcess) { + if (CollectionUtils.isEmptyElement(list)) { + return; + } + + // 查询列表 + OrderProdQuery query = new OrderProdQuery(); + query.setOrderIds(CollectionUtils.map(list, OrderVO::getId)); + List prodList = orderProdService.selectOrderProdList(query); + + // 拼接明细 + if (assembleProcess) { + orderProdAssembler.assembleProcessList(prodList); + } + + // 分组 + Map> group = prodList.stream().collect(Collectors.groupingBy(OrderProdVO::getOrderId)); + + // 拼接 + for (OrderVO vo : list) { + List productList = group.get(vo.getId()); + if (productList == null) { + productList = new ArrayList<>(); + } + vo.setProdList(productList); + } + + + } +} diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/impl/OrderConverterImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/impl/OrderConverterImpl.java index 896d65a..55056dd 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/impl/OrderConverterImpl.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/impl/OrderConverterImpl.java @@ -1,7 +1,9 @@ package com.ruoyi.bst.order.service.impl; import com.ruoyi.bst.order.domain.OrderBO; +import com.ruoyi.bst.order.domain.enums.OrderStatus; import com.ruoyi.bst.order.service.OrderConverter; +import com.ruoyi.bst.order.service.OrderService; import com.ruoyi.bst.orderProd.service.OrderProdConverter; import com.ruoyi.common.core.domain.entity.SysUser; import org.springframework.beans.factory.annotation.Autowired; @@ -17,6 +19,9 @@ public class OrderConverterImpl implements OrderConverter { @Autowired private OrderProdConverter orderProdConverter; + @Autowired + private OrderService orderService; + /** * 新增时转为BO @@ -39,9 +44,35 @@ public class OrderConverterImpl implements OrderConverter { bo.setCustomer(data.getCustomer()); bo.setCreateBy(user.getNickName()); bo.setRemark(data.getRemark()); - + if (submit) { + bo.setStatus(OrderStatus.RELEASED.getStatus()); + } else { + bo.setStatus(OrderStatus.PROPOSED.getStatus()); + } bo.setProdList(orderProdConverter.toBOListByCreate(data.getProdList())); return bo; } + + @Override + public OrderBO toBOByUpdate(OrderBO data, Boolean submit, SysUser user) { + if (data == null) { + return null; + } + + OrderBO bo = new OrderBO(); + bo.setId(data.getId()); + bo.setPicture(data.getPicture()); + bo.setDeliveryDate(data.getDeliveryDate()); + bo.setNum(data.getNum()); + bo.setCustomer(data.getCustomer()); + bo.setRemark(data.getRemark()); + if (submit) { + bo.setStatus(OrderStatus.RELEASED.getStatus()); + } + bo.setProdList(orderProdConverter.toBOListByUpdate(data.getProdList())); + bo.setOld(orderService.selectOrderById(data.getId())); + + return bo; + } } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/impl/OrderServiceImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/impl/OrderServiceImpl.java index 23bf9fc..7e8ff8c 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/impl/OrderServiceImpl.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/impl/OrderServiceImpl.java @@ -5,13 +5,16 @@ import com.ruoyi.bst.order.domain.OrderBO; import com.ruoyi.bst.order.domain.OrderQuery; import com.ruoyi.bst.order.domain.OrderVO; import com.ruoyi.bst.order.mapper.OrderMapper; -import com.ruoyi.bst.order.service.IOrderService; +import com.ruoyi.bst.order.service.OrderService; import com.ruoyi.bst.order.service.OrderValidator; import com.ruoyi.bst.orderProd.domain.OrderProd; import com.ruoyi.bst.orderProd.domain.OrderProdBO; import com.ruoyi.bst.orderProd.domain.OrderProdVO; import com.ruoyi.bst.orderProd.service.IOrderProdService; +import com.ruoyi.bst.prodProcess.domain.ProdProcess; import com.ruoyi.bst.prodProcess.domain.ProdProcessBO; +import com.ruoyi.bst.prodProcess.domain.ProdProcessVO; +import com.ruoyi.bst.prodProcess.service.IProdProcessService; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ServiceUtil; import com.ruoyi.common.utils.SnowFlakeUtil; @@ -22,6 +25,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.support.TransactionTemplate; import java.util.List; +import java.util.stream.Collectors; /** * 生产订单Service业务层处理 @@ -30,7 +34,7 @@ import java.util.List; * @date 2024-12-16 */ @Service -public class OrderServiceImpl implements IOrderService +public class OrderServiceImpl implements OrderService { @Autowired private OrderMapper orderMapper; @@ -44,6 +48,9 @@ public class OrderServiceImpl implements IOrderService @Autowired private TransactionTemplate transactionTemplate; + @Autowired + private IProdProcessService prodProcessService; + /** * 查询生产订单 * @@ -53,6 +60,9 @@ public class OrderServiceImpl implements IOrderService @Override public OrderVO selectOrderById(Long id) { + if (id == null) { + return null; + } return orderMapper.selectOrderById(id); } @@ -120,6 +130,7 @@ public class OrderServiceImpl implements IOrderService @Override public int addOrder(OrderBO order) { + // 前校验 orderValidator.checkBefore(order); Integer result = transactionTemplate.execute(status -> { @@ -133,9 +144,40 @@ public class OrderServiceImpl implements IOrderService this.batchUpdateProcessList(order); } + // 后校验 + OrderVO vo = this.selectOrderById(order.getId()); + orderValidator.checkAfter(vo); + return insert; }); + + return result == null ? 0 : result; + } + + @Override + public int editOrder(OrderBO order) { + // 前校验 + orderValidator.checkBefore(order); + + Integer result = transactionTemplate.execute(status -> { + int update = this.updateOrder(order); + + if (update == 1) { + // 批量更新产品明细 + this.batchUpdateProdList(order); + + // 批量更新工序明细 + this.batchUpdateProcessList(order); + } + + // 后校验 + OrderVO vo = this.selectOrderById(order.getId()); + orderValidator.checkAfter(vo); + + return update; + }); + return result == null ? 0 : result; } @@ -143,13 +185,38 @@ public class OrderServiceImpl implements IOrderService if (bo == null || CollectionUtils.isEmptyElement(bo.getProdList())) { return 0; } - // 关联 + // 关联产品ID for (OrderProdBO prod : bo.getProdList()) { for (ProdProcessBO process : prod.getProcessList()) { process.setOrderProdId(prod.getId()); } } + List oldList = prodProcessService.selectByOrderId(bo.getId()); + + List newList = bo.getProdList().stream().map(OrderProdBO::getProcessList).flatMap(List::stream).collect(Collectors.toList()); + + // 分离出新增、修改、删除的列表 + DiffListVO diff = CollectionUtils.convertToDiffList(newList, oldList, ProdProcess::getId); + + int result = 0; + if (diff.getAddCount() > 0) { + int batchInsert = prodProcessService.batchInsert(diff.getAddList()); + ServiceUtil.assertion(batchInsert != diff.getAddCount(), "新增工序明细失败"); + result += batchInsert; + } + if (diff.getUpdateCount() > 0) { + int update = prodProcessService.batchUpdate(diff.getUpdateList()); + ServiceUtil.assertion(update != diff.getUpdateCount(), "修改工序明细失败"); + result += update; + } + if (diff.getDelCount() > 0) { + int del = prodProcessService.batchLogicDel(diff.getDelList()); + ServiceUtil.assertion(del != diff.getDelCount(), "删除工序明细失败"); + result += del; + } + + return result; } private int batchUpdateProdList(OrderBO bo) { @@ -157,7 +224,6 @@ public class OrderServiceImpl implements IOrderService return 0; } // 关联订单ID - for (OrderProd prod : bo.getProdList()) { prod.setOrderId(bo.getId()); } @@ -170,17 +236,17 @@ public class OrderServiceImpl implements IOrderService int result = 0; if (diff.getAddCount() > 0) { int batchInsert = orderProdService.batchInsert(diff.getAddList()); - ServiceUtil.assertion(batchInsert != diff.getAddCount(), "新增报表产量明细失败"); + ServiceUtil.assertion(batchInsert != diff.getAddCount(), "新增产品明细失败"); result += batchInsert; } if (diff.getUpdateCount() > 0) { int update = orderProdService.batchUpdate(diff.getUpdateList()); - ServiceUtil.assertion(update != diff.getUpdateCount(), "修改报表产量明细失败"); + ServiceUtil.assertion(update != diff.getUpdateCount(), "修改产品明细失败"); result += update; } if (diff.getDelCount() > 0) { int del = orderProdService.batchLogicDel(diff.getDelList()); - ServiceUtil.assertion(del != diff.getDelCount(), "删除报表产量明细失败"); + ServiceUtil.assertion(del != diff.getDelCount(), "删除产品明细失败"); result += del; } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/impl/OrderValidatorImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/impl/OrderValidatorImpl.java index 209207c..c90241b 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/impl/OrderValidatorImpl.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/impl/OrderValidatorImpl.java @@ -1,10 +1,17 @@ package com.ruoyi.bst.order.service.impl; import com.ruoyi.bst.order.domain.OrderBO; +import com.ruoyi.bst.order.domain.OrderVO; +import com.ruoyi.bst.order.domain.enums.OrderStatus; import com.ruoyi.bst.order.service.OrderValidator; +import com.ruoyi.bst.orderProd.domain.OrderProdBO; +import com.ruoyi.bst.prodProcess.domain.ProdProcessBO; import com.ruoyi.common.utils.ServiceUtil; +import com.ruoyi.common.utils.collection.CollectionUtils; import org.springframework.stereotype.Service; +import java.util.List; + /** * @author wjh * 2024/12/17 @@ -17,8 +24,60 @@ public class OrderValidatorImpl implements OrderValidator { public void checkBefore(OrderBO data) { ServiceUtil.assertion(data == null, "订单数据为空"); - // TODO 至少要有一个结束的产品 + // 校验旧订单状态 + if (data.getId() != null) { + OrderVO old = data.getOld(); + ServiceUtil.assertion(old == null, "待修改的订单数据不存在"); + ServiceUtil.assertion(!OrderStatus.canEdit().contains(old.getStatus()), "订单当前状态不允许修改"); + + if (OrderStatus.RELEASED.getStatus().equals(data.getStatus())) { + ServiceUtil.assertion(!OrderStatus.canRelease().contains(old.getStatus()), "订单当前状态不允许发布"); + } + } + + // 有且仅有一个结束的产品 + boolean singleEndProd = this.hasSingleEndProd(data.getProdList()); + ServiceUtil.assertion(!singleEndProd, "订单中必须有且仅有一个产品为成品"); + + // 每个产品有且仅有一个结束的工序 + for (OrderProdBO prod : data.getProdList()) { + boolean singleEndProcess = this.hasSingleEndProcess(prod.getProcessList()); + ServiceUtil.assertion(!singleEndProcess, "产品【%s】校验失败:必须有且仅有一个工序作为产品最终工序", prod.getName()); + } + } + + private boolean hasSingleEndProcess(List processList) { + if (CollectionUtils.isEmptyElement(processList)) { + return false; + } + + int endCount = 0; + for (ProdProcessBO process : processList) { + if (process.getIsEnd() != null && process.getIsEnd()) { + endCount ++; + } + } + + return endCount == 1; + } + + private boolean hasSingleEndProd(List prodList) { + if (CollectionUtils.isEmptyElement(prodList)) { + return false; + } + + int endCount = 0; + for (OrderProdBO prod : prodList) { + if (prod.getIsEnd() != null && prod.getIsEnd()) { + endCount ++; + } + } + + return endCount == 1; + } + + @Override + public void checkAfter(OrderVO vo) { - // TODO 每个产品至少有一个结束的工序 } } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/domain/OrderProd.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/domain/OrderProd.java index a93f99f..d5e6b3c 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/domain/OrderProd.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/domain/OrderProd.java @@ -33,8 +33,8 @@ public class OrderProd extends BaseEntity @Excel(name = "加工类型", readConverterExp = "1=自加工,2=外加工") @ApiModelProperty("加工类型") - @DictValid(type = DictType.ORDER_PROD_WORK_TYPE) - @NotBlank(message = "加工类型不能为空", groups = {ValidGroup.Create.class}) + @DictValid(type = DictType.ORDER_PROD_WORK_TYPE, message = "非法的产品加工类型") + @NotBlank(message = "产品加工类型不能为空", groups = {ValidGroup.Create.class}) private String workType; @Excel(name = "是否成品") @@ -53,8 +53,8 @@ public class OrderProd extends BaseEntity @Excel(name = "名称") @ApiModelProperty("名称") - @Size(max = 50, message = "名称长度不能超过50个字符") - @NotBlank(message = "名称不能为空", groups = {ValidGroup.Create.class}) + @Size(max = 50, message = "产品名称长度不能超过50个字符") + @NotBlank(message = "产品名称不能为空", groups = {ValidGroup.Create.class}) private String name; @Excel(name = "规格") @@ -64,7 +64,12 @@ public class OrderProd extends BaseEntity @Excel(name = "数量") @ApiModelProperty("数量") - @Min(value = 1, message = "数量不能小于1") + @Min(value = 1, message = "产品数量不能小于1") + @NotNull(message = "产品数量不能为空", groups = {ValidGroup.Create.class}) private BigDecimal num; + @Excel(name = "排序") + @ApiModelProperty("排序") + private Integer sort; + } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/domain/OrderProdQuery.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/domain/OrderProdQuery.java index f376005..6cadf4d 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/domain/OrderProdQuery.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/domain/OrderProdQuery.java @@ -1,11 +1,18 @@ package com.ruoyi.bst.orderProd.domain; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.List; + /** * @author wjh * 2024/12/17 */ @Data public class OrderProdQuery extends OrderProdVO{ + + @ApiModelProperty("订单ID列表") + private List orderIds; + } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/domain/OrderProdVO.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/domain/OrderProdVO.java index 37f47e9..fde3b6c 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/domain/OrderProdVO.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/domain/OrderProdVO.java @@ -1,8 +1,11 @@ package com.ruoyi.bst.orderProd.domain; +import com.ruoyi.bst.prodProcess.domain.ProdProcessVO; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.List; + /** * @author wjh * 2024/12/17 @@ -13,4 +16,7 @@ public class OrderProdVO extends OrderProd { @ApiModelProperty("订单编号") private String orderNo; + @ApiModelProperty("工序列表") + private List processList; + } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/mapper/OrderProdMapper.xml b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/mapper/OrderProdMapper.xml index 7d4d5ee..3810325 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/mapper/OrderProdMapper.xml +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/mapper/OrderProdMapper.xml @@ -20,6 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" bop.remark, bop.deleted, bop.create_time, + bop.sort, bo.order_no as order_no from bst_order_prod bop left join bst_order bo on bo.id = bop.order_id @@ -37,6 +38,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and bop.deleted = #{query.deleted} and bop.deleted = false and bo.order_no like concat('%', #{query.orderNo}, '%') + + and bop.order_id in + + #{item} + + ${query.params.dataScope} @@ -66,6 +73,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" remark, deleted, create_time, + sort, #{orderId}, @@ -79,25 +87,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{remark}, #{deleted}, #{createTime}, + #{sort}, - insert into bst_order_prod ( + insert into bst_order_prod + order_id, work_type, is_end, material_no, picture, - name, + `name`, spec, num, remark, deleted, - create_time - ) + create_time, + sort, + values - + #{i.orderId}, default, @@ -121,6 +132,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" default, #{i.createTime}, default, + #{i.sort}, + default, @@ -140,7 +153,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + WHEN #{item.id} THEN #{item.workType} @@ -238,6 +251,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + WHEN #{item.id} THEN #{item.sort} + + + WHEN #{item.id} THEN `sort` + + + where id in @@ -269,12 +292,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" is_end = #{data.isEnd}, material_no = #{data.materialNo}, picture = #{data.picture}, - name = #{data.name}, + `name` = #{data.name}, spec = #{data.spec}, num = #{data.num}, remark = #{data.remark}, deleted = #{data.deleted}, create_time = #{data.createTime}, + sort = #{data.sort}, diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/service/OrderProdAssembler.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/service/OrderProdAssembler.java new file mode 100644 index 0000000..6653b29 --- /dev/null +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/service/OrderProdAssembler.java @@ -0,0 +1,18 @@ +package com.ruoyi.bst.orderProd.service; + +import com.ruoyi.bst.orderProd.domain.OrderProdVO; + +import java.util.List; + +/** + * @author wjh + * 2024/12/18 + */ +public interface OrderProdAssembler { + + /** + * 拼接工序列表 + */ + void assembleProcessList(List list); + +} diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/service/OrderProdConverter.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/service/OrderProdConverter.java index 146d22c..76b975f 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/service/OrderProdConverter.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/service/OrderProdConverter.java @@ -14,4 +14,9 @@ public interface OrderProdConverter { * 新增时,转为BO */ List toBOListByCreate(List list); + + /** + * 修改时,转为BO + */ + List toBOListByUpdate(List list); } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/service/impl/OrderProdAssemblerImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/service/impl/OrderProdAssemblerImpl.java new file mode 100644 index 0000000..1e6206e --- /dev/null +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/service/impl/OrderProdAssemblerImpl.java @@ -0,0 +1,48 @@ +package com.ruoyi.bst.orderProd.service.impl; + +import com.ruoyi.bst.orderProd.domain.OrderProdVO; +import com.ruoyi.bst.orderProd.service.OrderProdAssembler; +import com.ruoyi.bst.prodProcess.domain.ProdProcess; +import com.ruoyi.bst.prodProcess.domain.ProdProcessQuery; +import com.ruoyi.bst.prodProcess.domain.ProdProcessVO; +import com.ruoyi.bst.prodProcess.service.IProdProcessService; +import com.ruoyi.common.utils.collection.CollectionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @author wjh + * 2024/12/18 + */ +@Service +public class OrderProdAssemblerImpl implements OrderProdAssembler { + + @Autowired + private IProdProcessService prodProcessService; + + @Override + public void assembleProcessList(List list) { + if (CollectionUtils.isEmptyElement(list)) { + return; + } + + ProdProcessQuery query = new ProdProcessQuery(); + query.setOrderProdIds(CollectionUtils.map(list, OrderProdVO::getId)); + Map> group = prodProcessService.selectProdProcessList(query) + .stream().collect(Collectors.groupingBy(ProdProcess::getOrderProdId)); + + for (OrderProdVO prod : list) { + List processList = group.get(prod.getId()); + if (processList == null) { + processList = new ArrayList<>(); + } + prod.setProcessList(processList); + } + + } +} diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/service/impl/OrderProdConverterImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/service/impl/OrderProdConverterImpl.java index 47dbb7f..ceb0812 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/service/impl/OrderProdConverterImpl.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/service/impl/OrderProdConverterImpl.java @@ -37,10 +37,36 @@ public class OrderProdConverterImpl implements OrderProdConverter { bo.setSpec(prod.getSpec()); bo.setNum(prod.getNum()); bo.setRemark(prod.getRemark()); + bo.setSort(prod.getSort()); bo.setProcessList(prodProcessConverter.toBOListByCreate(prod.getProcessList())); boList.add(bo); } return boList; } + + @Override + public List toBOListByUpdate(List list) { + if (CollectionUtils.isEmptyElement(list)) { + return Collections.emptyList(); + } + List boList = new ArrayList<>(); + for (OrderProdBO prod : list) { + OrderProdBO bo = new OrderProdBO(); + bo.setId(prod.getId()); + bo.setWorkType(prod.getWorkType()); + bo.setIsEnd(prod.getIsEnd()); + bo.setMaterialNo(prod.getMaterialNo()); + bo.setPicture(prod.getPicture()); + bo.setName(prod.getName()); + bo.setSpec(prod.getSpec()); + bo.setNum(prod.getNum()); + bo.setRemark(prod.getRemark()); + bo.setSort(prod.getSort()); + bo.setProcessList(prodProcessConverter.toBOListByUpdate(prod.getProcessList())); + + boList.add(bo); + } + return boList; + } } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/service/impl/OrderProdServiceImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/service/impl/OrderProdServiceImpl.java index 4772bca..e2174bd 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/service/impl/OrderProdServiceImpl.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/service/impl/OrderProdServiceImpl.java @@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Collections; +import java.util.Date; import java.util.List; /** @@ -113,6 +114,10 @@ public class OrderProdServiceImpl implements IOrderProdService if (CollectionUtils.isEmptyElement(list)) { return 0; } + Date now = DateUtils.getNowDate(); + for (OrderProd prod : list) { + prod.setCreateTime(now); + } return orderProdMapper.batchInsert(list); } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/domain/ProdProcess.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/domain/ProdProcess.java index ef1a48c..c0a74ab 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/domain/ProdProcess.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/domain/ProdProcess.java @@ -6,6 +6,7 @@ import com.ruoyi.common.core.validate.ValidGroup; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import java.math.BigDecimal; @@ -34,8 +35,8 @@ public class ProdProcess extends BaseEntity @Excel(name = "数量") @ApiModelProperty("数量") - @NotNull(message = "数量不能为空", groups = {ValidGroup.Create.class}) - @Size(min = 1, message = "数量不能小于1") + @NotNull(message = "工序数量不能为空", groups = {ValidGroup.Create.class}) + @Min(value = 1, message = "工序数量不能小于1") private BigDecimal num; @Excel(name = "是否最终工序") @@ -63,4 +64,7 @@ public class ProdProcess extends BaseEntity @Size(max = 50, message = "盖子颜色长度不能超过50个字符") private String coverColor; + @Excel(name = "排序") + @ApiModelProperty("排序") + private Integer sort; } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/domain/ProdProcessQuery.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/domain/ProdProcessQuery.java index 910661d..1b7d9a7 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/domain/ProdProcessQuery.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/domain/ProdProcessQuery.java @@ -1,11 +1,18 @@ package com.ruoyi.bst.prodProcess.domain; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.List; + /** * @author wjh * 2024/12/17 */ @Data public class ProdProcessQuery extends ProdProcessVO{ + + @ApiModelProperty("订单产品ID列表") + private List orderProdIds; + } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/domain/ProdProcessVO.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/domain/ProdProcessVO.java index f8a9112..57aa9e7 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/domain/ProdProcessVO.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/domain/ProdProcessVO.java @@ -10,6 +10,9 @@ import lombok.Data; @Data public class ProdProcessVO extends ProdProcess{ + @ApiModelProperty("订单ID") + private Long orderId; + @ApiModelProperty("订单编号") private String orderNo; diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/mapper/ProdProcessMapper.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/mapper/ProdProcessMapper.java index 2f8622c..01a1a2a 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/mapper/ProdProcessMapper.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/mapper/ProdProcessMapper.java @@ -62,4 +62,16 @@ public interface ProdProcessMapper * @return 结果 */ public int deleteProdProcessByIds(Long[] ids); + + int batchInsert(@Param("list") List list); + + /** + * 批量修改产品工序 + */ + int batchUpdate(@Param("list") List list); + + /** + * 逻辑删除 + */ + int logicDel(@Param("ids") List ids); } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/mapper/ProdProcessMapper.xml b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/mapper/ProdProcessMapper.xml index a07490a..6fafd38 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/mapper/ProdProcessMapper.xml +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/mapper/ProdProcessMapper.xml @@ -20,6 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" bpp.remark, bpp.create_time, bpp.deleted, + bpp.sort, bop.name as order_prod_name, bo.order_no as order_no, sd.dept_name as dept_name @@ -44,6 +45,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and bo.order_no like concat('%', #{query.orderNo}, '%') and bop.name like concat('%', #{query.orderProdName}, '%') and sd.dept_name like concat('%', #{query.deptName}, '%') + and bop.order_id = #{query.orderId} + + and bpp.order_prod_id in + + #{item} + + ${query.params.dataScope} @@ -56,7 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -73,6 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" remark, create_time, deleted, + sort, #{orderProdId}, @@ -86,9 +95,187 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{remark}, #{createTime}, #{deleted}, + #{sort}, + + insert into bst_prod_process + + order_prod_id, + dept_id, + num, + is_end, + handle_way, + effect, + color, + cover_color, + remark, + create_time, + deleted, + sort, + + values + + + #{i.orderProdId}, + default, + #{i.deptId}, + default, + #{i.num}, + default, + #{i.isEnd}, + default, + #{i.handleWay}, + default, + #{i.effect}, + default, + #{i.color}, + default, + #{i.coverColor}, + default, + #{i.remark}, + default, + #{i.createTime}, + default, + #{i.deleted}, + default, + #{i.sort}, + default, + + + + + + update bst_prod_process + + + + + WHEN #{item.id} THEN #{item.orderProdId} + + + WHEN #{item.id} THEN `order_prod_id` + + + + + + + WHEN #{item.id} THEN #{item.deptId} + + + WHEN #{item.id} THEN `dept_id` + + + + + + + WHEN #{item.id} THEN #{item.num} + + + WHEN #{item.id} THEN `num` + + + + + + + WHEN #{item.id} THEN #{item.isEnd} + + + WHEN #{item.id} THEN `is_end` + + + + + + + WHEN #{item.id} THEN #{item.handleWay} + + + WHEN #{item.id} THEN `handle_way` + + + + + + + WHEN #{item.id} THEN #{item.effect} + + + WHEN #{item.id} THEN `effect` + + + + + + + WHEN #{item.id} THEN #{item.color} + + + WHEN #{item.id} THEN `color` + + + + + + + WHEN #{item.id} THEN #{item.coverColor} + + + WHEN #{item.id} THEN `cover_color` + + + + + + + WHEN #{item.id} THEN #{item.remark} + + + WHEN #{item.id} THEN `remark` + + + + + + + WHEN #{item.id} THEN #{item.createTime} + + + WHEN #{item.id} THEN `create_time` + + + + + + + WHEN #{item.id} THEN #{item.deleted} + + + WHEN #{item.id} THEN `deleted` + + + + + + + WHEN #{item.id} THEN #{item.sort} + + + WHEN #{item.id} THEN `sort` + + + + + where id in + + #{item.id} + + + update bst_prod_process @@ -97,6 +284,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{data.id} + + update bst_prod_process + set deleted = true + where id in + + #{item} + + and deleted = false + + order_prod_id = #{data.orderProdId}, dept_id = #{data.deptId}, @@ -109,6 +306,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" remark = #{data.remark}, create_time = #{data.createTime}, deleted = #{data.deleted}, + sort = #{data.sort}, diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/service/IProdProcessService.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/service/IProdProcessService.java index 26225c1..199fb1c 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/service/IProdProcessService.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/service/IProdProcessService.java @@ -61,4 +61,24 @@ public interface IProdProcessService * @return 结果 */ public int deleteProdProcessById(Long id); + + /** + * 根据订单ID查询列表 + */ + List selectByOrderId(Long orderId); + + /** + * 批量新增 + */ + int batchInsert(List list); + + /** + * 批量修改 + */ + int batchUpdate(List list); + + /** + * 批量删除 + */ + int batchLogicDel(List list); } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/service/ProdProcessConverter.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/service/ProdProcessConverter.java index 4ef8286..5382bb4 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/service/ProdProcessConverter.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/service/ProdProcessConverter.java @@ -15,4 +15,8 @@ public interface ProdProcessConverter { */ List toBOListByCreate(List list); + /** + * 修改时,转为BO + */ + List toBOListByUpdate(List list); } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/service/impl/ProdProcessConverterImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/service/impl/ProdProcessConverterImpl.java index 8c64648..678a015 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/service/impl/ProdProcessConverterImpl.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/service/impl/ProdProcessConverterImpl.java @@ -32,6 +32,32 @@ public class ProdProcessConverterImpl implements ProdProcessConverter { bo.setEffect(process.getEffect()); bo.setColor(process.getColor()); bo.setCoverColor(process.getCoverColor()); + bo.setSort(process.getSort()); + boList.add(bo); + } + + return boList; + } + + @Override + public List toBOListByUpdate(List list) { + if (CollectionUtils.isEmptyElement(list)) { + return Collections.emptyList(); + } + + List boList = new ArrayList<>(); + + for (ProdProcessBO process : list) { + ProdProcessBO bo = new ProdProcessBO(); + bo.setId(process.getId()); + bo.setDeptId(process.getDeptId()); + bo.setNum(process.getNum()); + bo.setIsEnd(process.getIsEnd()); + bo.setHandleWay(process.getHandleWay()); + bo.setEffect(process.getEffect()); + bo.setColor(process.getColor()); + bo.setCoverColor(process.getCoverColor()); + bo.setSort(process.getSort()); boList.add(bo); } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/service/impl/ProdProcessServiceImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/service/impl/ProdProcessServiceImpl.java index d423092..857e521 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/service/impl/ProdProcessServiceImpl.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/prodProcess/service/impl/ProdProcessServiceImpl.java @@ -6,9 +6,12 @@ import com.ruoyi.bst.prodProcess.domain.ProdProcessVO; import com.ruoyi.bst.prodProcess.mapper.ProdProcessMapper; import com.ruoyi.bst.prodProcess.service.IProdProcessService; import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.collection.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Collections; +import java.util.Date; import java.util.List; /** @@ -95,4 +98,42 @@ public class ProdProcessServiceImpl implements IProdProcessService { return prodProcessMapper.deleteProdProcessById(id); } + + @Override + public List selectByOrderId(Long orderId) { + if (orderId == null) { + return Collections.emptyList(); + } + ProdProcessQuery query = new ProdProcessQuery(); + query.setOrderId(orderId); + return this.selectProdProcessList(query); + } + + @Override + public int batchUpdate(List list) { + if (CollectionUtils.isEmptyElement(list)) { + return 0; + } + return prodProcessMapper.batchUpdate(list); + } + + @Override + public int batchLogicDel(List list) { + if (CollectionUtils.isEmptyElement(list)) { + return 0; + } + return prodProcessMapper.logicDel(CollectionUtils.map(list, ProdProcess::getId)); + } + + @Override + public int batchInsert(List list) { + if (CollectionUtils.isEmptyElement(list)) { + return 0; + } + Date now = DateUtils.getNowDate(); + for (ProdProcess process : list) { + process.setCreateTime(now); + } + return prodProcessMapper.batchInsert(list); + } } diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/bst/OrderController.java b/ruoyi-web/src/main/java/com/ruoyi/web/bst/OrderController.java index adbc22f..dbca7ec 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/bst/OrderController.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/bst/OrderController.java @@ -3,8 +3,9 @@ package com.ruoyi.web.bst; import com.ruoyi.bst.order.domain.OrderBO; import com.ruoyi.bst.order.domain.OrderQuery; import com.ruoyi.bst.order.domain.OrderVO; -import com.ruoyi.bst.order.service.IOrderService; +import com.ruoyi.bst.order.service.OrderAssembler; import com.ruoyi.bst.order.service.OrderConverter; +import com.ruoyi.bst.order.service.OrderService; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; @@ -31,11 +32,14 @@ import java.util.List; public class OrderController extends BaseController { @Autowired - private IOrderService orderService; + private OrderService orderService; @Autowired private OrderConverter orderConverter; + @Autowired + private OrderAssembler orderAssembler; + /** * 查询生产订单列表 */ @@ -69,7 +73,9 @@ public class OrderController extends BaseController @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { - return success(orderService.selectOrderById(id)); + OrderVO vo = orderService.selectOrderById(id); + orderAssembler.assembleProdList(vo, true); + return success(vo); } /** @@ -80,8 +86,8 @@ public class OrderController extends BaseController @PostMapping public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) OrderBO order, @RequestParam(required = false, defaultValue = "false") Boolean submit) { - orderConverter.toBOByCreate(order, submit, getLoginUser().getUser()); - return toAjax(orderService.addOrder(order)); + OrderBO bo = orderConverter.toBOByCreate(order, submit, getLoginUser().getUser()); + return toAjax(orderService.addOrder(bo)); } /** @@ -93,7 +99,8 @@ public class OrderController extends BaseController public AjaxResult edit(@RequestBody @Validated(ValidGroup.Update.class) OrderBO order, @RequestParam(required = false, defaultValue = "false") Boolean submit) { - return toAjax(orderService.updateOrder(order)); + OrderBO bo = orderConverter.toBOByUpdate(order, submit, getLoginUser().getUser()); + return toAjax(orderService.editOrder(bo)); } /**