This commit is contained in:
磷叶 2024-12-18 18:06:28 +08:00
parent 07b369187f
commit 2fd4a707e7
33 changed files with 825 additions and 42 deletions

View File

@ -109,12 +109,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#end #end
</trim> </trim>
values values
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="i" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
#foreach($column in $columns) #foreach($column in $columns)
#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment) #if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
<if test="$column.javaField != null #if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">#{$column.javaField},</if> <if test="i.$column.javaField != null #if($column.javaType == 'String' && $column.required) and i.$column.javaField != ''#end">#{i.$column.javaField},</if>
<if test="$column.javaField == null #if($column.javaType == 'String' && $column.required) or $column.javaField == ''#end">default,</if> <if test="i.$column.javaField == null #if($column.javaType == 'String' && $column.required) or i.$column.javaField == ''#end">default,</if>
#end #end
#end #end
</trim> </trim>
@ -128,7 +128,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment) #if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
<foreach open="$column.columnName = CASE $pkColumn.columnName" collection="list" item="item" close="END,"> <foreach open="$column.columnName = CASE $pkColumn.columnName" collection="list" item="item" close="END,">
<choose> <choose>
<when test="item.$column.javaField != null #if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end"> <when test="item.$column.javaField != null #if($column.javaType == 'String' && $column.required) and item.$column.javaField != ''#end">
WHEN #{item.$pkColumn.columnName} THEN #{item.$column.javaField} WHEN #{item.$pkColumn.columnName} THEN #{item.$column.javaField}
</when> </when>
<otherwise> <otherwise>

View File

@ -49,4 +49,7 @@ public class Order extends BaseEntity
@Size(max = 50, message = "客户长度不能超过50个字符") @Size(max = 50, message = "客户长度不能超过50个字符")
private String customer; private String customer;
@Excel(name = "订单状态", readConverterExp = "1=拟定,2=已发布,3=完工")
@ApiModelProperty("订单状态")
private String status;
} }

View File

@ -22,4 +22,7 @@ public class OrderBO extends Order{
@Valid @Valid
private List<OrderProdBO> prodList; private List<OrderProdBO> prodList;
@ApiModelProperty("旧订单信息")
private OrderVO old;
} }

View File

@ -1,7 +1,11 @@
package com.ruoyi.bst.order.domain; package com.ruoyi.bst.order.domain;
import com.ruoyi.bst.orderProd.domain.OrderProdVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* @author wjh * @author wjh
* 2024/12/16 * 2024/12/16
@ -9,4 +13,7 @@ import lombok.Data;
@Data @Data
public class OrderVO extends Order{ public class OrderVO extends Order{
@ApiModelProperty("产品列表")
private List<OrderProdVO> prodList;
} }

View File

@ -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<String> canEdit() {
return asList(PROPOSED);
}
// 允许发布的列表
public static List<String> canRelease() {
return asList(PROPOSED);
}
// 允许完工的列表
public static List<String> canFinished() {
return asList(RELEASED);
}
// 允许删除的列表
public static List<String> canDel() {
return asList(PROPOSED);
}
public static List<String> asList(OrderStatus ...statuses) {
return CollectionUtils.map(OrderStatus::getStatus, statuses);
}
}

View File

@ -17,7 +17,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bo.remark, bo.remark,
bo.create_by, bo.create_by,
bo.create_time, bo.create_time,
bo.deleted bo.deleted,
bo.status
from bst_order bo from bst_order bo
</sql> </sql>
@ -29,6 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.createBy != null and query.createBy != ''"> and bo.create_by like concat('%', #{query.createBy}, '%')</if> <if test="query.createBy != null and query.createBy != ''"> and bo.create_by like concat('%', #{query.createBy}, '%')</if>
<if test="query.deleted != null "> and bo.deleted = #{query.deleted}</if> <if test="query.deleted != null "> and bo.deleted = #{query.deleted}</if>
<if test="query.deleted == null "> and bo.deleted = false</if> <if test="query.deleted == null "> and bo.deleted = false</if>
<if test="query.status != null and query.status != ''"> and status = #{query.status}</if>
${query.params.dataScope} ${query.params.dataScope}
</sql> </sql>
@ -56,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createBy != null">create_by,</if> <if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="deleted != null">deleted,</if> <if test="deleted != null">deleted,</if>
<if test="status != null and status != ''">`status`,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderNo != null and orderNo != ''">#{orderNo},</if> <if test="orderNo != null and orderNo != ''">#{orderNo},</if>
@ -67,6 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="deleted != null">#{deleted},</if> <if test="deleted != null">#{deleted},</if>
<if test="status != null and status != ''">#{status},</if>
</trim> </trim>
</insert> </insert>
@ -88,6 +92,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="data.createBy != null">create_by = #{data.createBy},</if> <if test="data.createBy != null">create_by = #{data.createBy},</if>
<if test="data.createTime != null">create_time = #{data.createTime},</if> <if test="data.createTime != null">create_time = #{data.createTime},</if>
<if test="data.deleted != null">deleted = #{data.deleted},</if> <if test="data.deleted != null">deleted = #{data.deleted},</if>
<if test="data.status != null and data.status != ''">`status` = #{data.status},</if>
</sql> </sql>
<delete id="deleteOrderById" parameterType="Long"> <delete id="deleteOrderById" parameterType="Long">

View File

@ -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<OrderVO> list, boolean assembleProcess);
default void assembleProdList(OrderVO vo, boolean assembleProcess) {
assembleProdList(Collections.singletonList(vo), assembleProcess);
}
}

View File

@ -11,12 +11,11 @@ public interface OrderConverter {
/** /**
* 新增时转为BO * 新增时转为BO
*
* @param data
* @param submit
* @param user
* @return
*/ */
OrderBO toBOByCreate(OrderBO data, boolean submit, SysUser user); OrderBO toBOByCreate(OrderBO data, boolean submit, SysUser user);
/**
* 修改时转为BO
*/
OrderBO toBOByUpdate(OrderBO order, Boolean submit, SysUser user);
} }

View File

@ -13,7 +13,7 @@ import java.util.List;
* @author ruoyi * @author ruoyi
* @date 2024-12-16 * @date 2024-12-16
*/ */
public interface IOrderService public interface OrderService
{ {
/** /**
* 查询生产订单 * 查询生产订单
@ -67,4 +67,9 @@ public interface IOrderService
* 新增 * 新增
*/ */
int addOrder(OrderBO order); int addOrder(OrderBO order);
/**
* 修改
*/
int editOrder(OrderBO order);
} }

View File

@ -1,6 +1,7 @@
package com.ruoyi.bst.order.service; package com.ruoyi.bst.order.service;
import com.ruoyi.bst.order.domain.OrderBO; import com.ruoyi.bst.order.domain.OrderBO;
import com.ruoyi.bst.order.domain.OrderVO;
/** /**
* @author wjh * @author wjh
@ -12,4 +13,10 @@ public interface OrderValidator {
* 新增修改前置校验 * 新增修改前置校验
*/ */
void checkBefore(OrderBO data); void checkBefore(OrderBO data);
/**
* 后校验
*/
void checkAfter(OrderVO vo);
} }

View File

@ -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<OrderVO> list, boolean assembleProcess) {
if (CollectionUtils.isEmptyElement(list)) {
return;
}
// 查询列表
OrderProdQuery query = new OrderProdQuery();
query.setOrderIds(CollectionUtils.map(list, OrderVO::getId));
List<OrderProdVO> prodList = orderProdService.selectOrderProdList(query);
// 拼接明细
if (assembleProcess) {
orderProdAssembler.assembleProcessList(prodList);
}
// 分组
Map<Long, List<OrderProdVO>> group = prodList.stream().collect(Collectors.groupingBy(OrderProdVO::getOrderId));
// 拼接
for (OrderVO vo : list) {
List<OrderProdVO> productList = group.get(vo.getId());
if (productList == null) {
productList = new ArrayList<>();
}
vo.setProdList(productList);
}
}
}

View File

@ -1,7 +1,9 @@
package com.ruoyi.bst.order.service.impl; package com.ruoyi.bst.order.service.impl;
import com.ruoyi.bst.order.domain.OrderBO; 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.OrderConverter;
import com.ruoyi.bst.order.service.OrderService;
import com.ruoyi.bst.orderProd.service.OrderProdConverter; import com.ruoyi.bst.orderProd.service.OrderProdConverter;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -17,6 +19,9 @@ public class OrderConverterImpl implements OrderConverter {
@Autowired @Autowired
private OrderProdConverter orderProdConverter; private OrderProdConverter orderProdConverter;
@Autowired
private OrderService orderService;
/** /**
* 新增时转为BO * 新增时转为BO
@ -39,9 +44,35 @@ public class OrderConverterImpl implements OrderConverter {
bo.setCustomer(data.getCustomer()); bo.setCustomer(data.getCustomer());
bo.setCreateBy(user.getNickName()); bo.setCreateBy(user.getNickName());
bo.setRemark(data.getRemark()); bo.setRemark(data.getRemark());
if (submit) {
bo.setStatus(OrderStatus.RELEASED.getStatus());
} else {
bo.setStatus(OrderStatus.PROPOSED.getStatus());
}
bo.setProdList(orderProdConverter.toBOListByCreate(data.getProdList())); bo.setProdList(orderProdConverter.toBOListByCreate(data.getProdList()));
return bo; 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;
}
} }

View File

@ -5,13 +5,16 @@ import com.ruoyi.bst.order.domain.OrderBO;
import com.ruoyi.bst.order.domain.OrderQuery; import com.ruoyi.bst.order.domain.OrderQuery;
import com.ruoyi.bst.order.domain.OrderVO; import com.ruoyi.bst.order.domain.OrderVO;
import com.ruoyi.bst.order.mapper.OrderMapper; 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.order.service.OrderValidator;
import com.ruoyi.bst.orderProd.domain.OrderProd; import com.ruoyi.bst.orderProd.domain.OrderProd;
import com.ruoyi.bst.orderProd.domain.OrderProdBO; import com.ruoyi.bst.orderProd.domain.OrderProdBO;
import com.ruoyi.bst.orderProd.domain.OrderProdVO; import com.ruoyi.bst.orderProd.domain.OrderProdVO;
import com.ruoyi.bst.orderProd.service.IOrderProdService; 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.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.DateUtils;
import com.ruoyi.common.utils.ServiceUtil; import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.common.utils.SnowFlakeUtil; import com.ruoyi.common.utils.SnowFlakeUtil;
@ -22,6 +25,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.support.TransactionTemplate; import org.springframework.transaction.support.TransactionTemplate;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 生产订单Service业务层处理 * 生产订单Service业务层处理
@ -30,7 +34,7 @@ import java.util.List;
* @date 2024-12-16 * @date 2024-12-16
*/ */
@Service @Service
public class OrderServiceImpl implements IOrderService public class OrderServiceImpl implements OrderService
{ {
@Autowired @Autowired
private OrderMapper orderMapper; private OrderMapper orderMapper;
@ -44,6 +48,9 @@ public class OrderServiceImpl implements IOrderService
@Autowired @Autowired
private TransactionTemplate transactionTemplate; private TransactionTemplate transactionTemplate;
@Autowired
private IProdProcessService prodProcessService;
/** /**
* 查询生产订单 * 查询生产订单
* *
@ -53,6 +60,9 @@ public class OrderServiceImpl implements IOrderService
@Override @Override
public OrderVO selectOrderById(Long id) public OrderVO selectOrderById(Long id)
{ {
if (id == null) {
return null;
}
return orderMapper.selectOrderById(id); return orderMapper.selectOrderById(id);
} }
@ -120,6 +130,7 @@ public class OrderServiceImpl implements IOrderService
@Override @Override
public int addOrder(OrderBO order) { public int addOrder(OrderBO order) {
// 前校验
orderValidator.checkBefore(order); orderValidator.checkBefore(order);
Integer result = transactionTemplate.execute(status -> { Integer result = transactionTemplate.execute(status -> {
@ -133,9 +144,40 @@ public class OrderServiceImpl implements IOrderService
this.batchUpdateProcessList(order); this.batchUpdateProcessList(order);
} }
// 后校验
OrderVO vo = this.selectOrderById(order.getId());
orderValidator.checkAfter(vo);
return insert; 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; return result == null ? 0 : result;
} }
@ -143,13 +185,38 @@ public class OrderServiceImpl implements IOrderService
if (bo == null || CollectionUtils.isEmptyElement(bo.getProdList())) { if (bo == null || CollectionUtils.isEmptyElement(bo.getProdList())) {
return 0; return 0;
} }
// 关联 // 关联产品ID
for (OrderProdBO prod : bo.getProdList()) { for (OrderProdBO prod : bo.getProdList()) {
for (ProdProcessBO process : prod.getProcessList()) { for (ProdProcessBO process : prod.getProcessList()) {
process.setOrderProdId(prod.getId()); process.setOrderProdId(prod.getId());
} }
} }
List<ProdProcessVO> oldList = prodProcessService.selectByOrderId(bo.getId());
List<ProdProcessBO> newList = bo.getProdList().stream().map(OrderProdBO::getProcessList).flatMap(List::stream).collect(Collectors.toList());
// 分离出新增修改删除的列表
DiffListVO<ProdProcessBO, ProdProcessVO> 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) { private int batchUpdateProdList(OrderBO bo) {
@ -157,7 +224,6 @@ public class OrderServiceImpl implements IOrderService
return 0; return 0;
} }
// 关联订单ID // 关联订单ID
for (OrderProd prod : bo.getProdList()) { for (OrderProd prod : bo.getProdList()) {
prod.setOrderId(bo.getId()); prod.setOrderId(bo.getId());
} }
@ -170,17 +236,17 @@ public class OrderServiceImpl implements IOrderService
int result = 0; int result = 0;
if (diff.getAddCount() > 0) { if (diff.getAddCount() > 0) {
int batchInsert = orderProdService.batchInsert(diff.getAddList()); int batchInsert = orderProdService.batchInsert(diff.getAddList());
ServiceUtil.assertion(batchInsert != diff.getAddCount(), "新增报表产量明细失败"); ServiceUtil.assertion(batchInsert != diff.getAddCount(), "新增产品明细失败");
result += batchInsert; result += batchInsert;
} }
if (diff.getUpdateCount() > 0) { if (diff.getUpdateCount() > 0) {
int update = orderProdService.batchUpdate(diff.getUpdateList()); int update = orderProdService.batchUpdate(diff.getUpdateList());
ServiceUtil.assertion(update != diff.getUpdateCount(), "修改报表产量明细失败"); ServiceUtil.assertion(update != diff.getUpdateCount(), "修改产品明细失败");
result += update; result += update;
} }
if (diff.getDelCount() > 0) { if (diff.getDelCount() > 0) {
int del = orderProdService.batchLogicDel(diff.getDelList()); int del = orderProdService.batchLogicDel(diff.getDelList());
ServiceUtil.assertion(del != diff.getDelCount(), "删除报表产量明细失败"); ServiceUtil.assertion(del != diff.getDelCount(), "删除产品明细失败");
result += del; result += del;
} }

View File

@ -1,10 +1,17 @@
package com.ruoyi.bst.order.service.impl; package com.ruoyi.bst.order.service.impl;
import com.ruoyi.bst.order.domain.OrderBO; 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.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.ServiceUtil;
import com.ruoyi.common.utils.collection.CollectionUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* @author wjh * @author wjh
* 2024/12/17 * 2024/12/17
@ -17,8 +24,60 @@ public class OrderValidatorImpl implements OrderValidator {
public void checkBefore(OrderBO data) { public void checkBefore(OrderBO data) {
ServiceUtil.assertion(data == null, "订单数据为空"); 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<ProdProcessBO> 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<OrderProdBO> 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 每个产品至少有一个结束的工序
} }
} }

View File

@ -33,8 +33,8 @@ public class OrderProd extends BaseEntity
@Excel(name = "加工类型", readConverterExp = "1=自加工,2=外加工") @Excel(name = "加工类型", readConverterExp = "1=自加工,2=外加工")
@ApiModelProperty("加工类型") @ApiModelProperty("加工类型")
@DictValid(type = DictType.ORDER_PROD_WORK_TYPE) @DictValid(type = DictType.ORDER_PROD_WORK_TYPE, message = "非法的产品加工类型")
@NotBlank(message = "加工类型不能为空", groups = {ValidGroup.Create.class}) @NotBlank(message = "产品加工类型不能为空", groups = {ValidGroup.Create.class})
private String workType; private String workType;
@Excel(name = "是否成品") @Excel(name = "是否成品")
@ -53,8 +53,8 @@ public class OrderProd extends BaseEntity
@Excel(name = "名称") @Excel(name = "名称")
@ApiModelProperty("名称") @ApiModelProperty("名称")
@Size(max = 50, message = "名称长度不能超过50个字符") @Size(max = 50, message = "产品名称长度不能超过50个字符")
@NotBlank(message = "名称不能为空", groups = {ValidGroup.Create.class}) @NotBlank(message = "产品名称不能为空", groups = {ValidGroup.Create.class})
private String name; private String name;
@Excel(name = "规格") @Excel(name = "规格")
@ -64,7 +64,12 @@ public class OrderProd extends BaseEntity
@Excel(name = "数量") @Excel(name = "数量")
@ApiModelProperty("数量") @ApiModelProperty("数量")
@Min(value = 1, message = "数量不能小于1") @Min(value = 1, message = "产品数量不能小于1")
@NotNull(message = "产品数量不能为空", groups = {ValidGroup.Create.class})
private BigDecimal num; private BigDecimal num;
@Excel(name = "排序")
@ApiModelProperty("排序")
private Integer sort;
} }

View File

@ -1,11 +1,18 @@
package com.ruoyi.bst.orderProd.domain; package com.ruoyi.bst.orderProd.domain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* @author wjh * @author wjh
* 2024/12/17 * 2024/12/17
*/ */
@Data @Data
public class OrderProdQuery extends OrderProdVO{ public class OrderProdQuery extends OrderProdVO{
@ApiModelProperty("订单ID列表")
private List<Long> orderIds;
} }

View File

@ -1,8 +1,11 @@
package com.ruoyi.bst.orderProd.domain; package com.ruoyi.bst.orderProd.domain;
import com.ruoyi.bst.prodProcess.domain.ProdProcessVO;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* @author wjh * @author wjh
* 2024/12/17 * 2024/12/17
@ -13,4 +16,7 @@ public class OrderProdVO extends OrderProd {
@ApiModelProperty("订单编号") @ApiModelProperty("订单编号")
private String orderNo; private String orderNo;
@ApiModelProperty("工序列表")
private List<ProdProcessVO> processList;
} }

View File

@ -20,6 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bop.remark, bop.remark,
bop.deleted, bop.deleted,
bop.create_time, bop.create_time,
bop.sort,
bo.order_no as order_no bo.order_no as order_no
from bst_order_prod bop from bst_order_prod bop
left join bst_order bo on bo.id = bop.order_id left join bst_order bo on bo.id = bop.order_id
@ -37,6 +38,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.deleted != null "> and bop.deleted = #{query.deleted}</if> <if test="query.deleted != null "> and bop.deleted = #{query.deleted}</if>
<if test="query.deleted == null "> and bop.deleted = false</if> <if test="query.deleted == null "> and bop.deleted = false</if>
<if test="query.orderNo != null and query.orderNo != ''"> and bo.order_no like concat('%', #{query.orderNo}, '%')</if> <if test="query.orderNo != null and query.orderNo != ''"> and bo.order_no like concat('%', #{query.orderNo}, '%')</if>
<if test="query.orderIds != null and query.orderIds.size() > 0">
and bop.order_id in
<foreach collection="query.orderIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
${query.params.dataScope} ${query.params.dataScope}
</sql> </sql>
@ -66,6 +73,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">remark,</if> <if test="remark != null">remark,</if>
<if test="deleted != null">deleted,</if> <if test="deleted != null">deleted,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="sort != null">sort,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderId != null">#{orderId},</if> <if test="orderId != null">#{orderId},</if>
@ -79,25 +87,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">#{remark},</if> <if test="remark != null">#{remark},</if>
<if test="deleted != null">#{deleted},</if> <if test="deleted != null">#{deleted},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="sort != null">#{sort},</if>
</trim> </trim>
</insert> </insert>
<insert id="batchInsert" useGeneratedKeys="true" keyProperty="id"> <insert id="batchInsert" useGeneratedKeys="true" keyProperty="id">
insert into bst_order_prod ( insert into bst_order_prod
<trim prefix="(" suffix=")" suffixOverrides=",">
order_id, order_id,
work_type, work_type,
is_end, is_end,
material_no, material_no,
picture, picture,
name, `name`,
spec, spec,
num, num,
remark, remark,
deleted, deleted,
create_time create_time,
) sort,
</trim>
values values
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="i" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="i.orderId != null">#{i.orderId},</if> <if test="i.orderId != null">#{i.orderId},</if>
<if test="i.orderId == null">default,</if> <if test="i.orderId == null">default,</if>
@ -121,6 +132,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="i.deleted == null">default,</if> <if test="i.deleted == null">default,</if>
<if test="i.createTime != null">#{i.createTime},</if> <if test="i.createTime != null">#{i.createTime},</if>
<if test="i.createTime == null">default,</if> <if test="i.createTime == null">default,</if>
<if test="i.sort != null ">#{i.sort},</if>
<if test="i.sort == null ">default,</if>
</trim> </trim>
</foreach> </foreach>
</insert> </insert>
@ -140,7 +153,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach> </foreach>
<foreach open="work_type = CASE id" collection="list" item="item" close="END,"> <foreach open="work_type = CASE id" collection="list" item="item" close="END,">
<choose> <choose>
<when test="item.workType != null and workType != ''"> <when test="item.workType != null and item.workType != ''">
WHEN #{item.id} THEN #{item.workType} WHEN #{item.id} THEN #{item.workType}
</when> </when>
<otherwise> <otherwise>
@ -238,6 +251,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</otherwise> </otherwise>
</choose> </choose>
</foreach> </foreach>
<foreach open="sort = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.sort != null ">
WHEN #{item.id} THEN #{item.sort}
</when>
<otherwise>
WHEN #{item.id} THEN `sort`
</otherwise>
</choose>
</foreach>
</trim> </trim>
where id in where id in
<foreach item="item" collection="list" open="(" separator="," close=")"> <foreach item="item" collection="list" open="(" separator="," close=")">
@ -269,12 +292,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="data.isEnd != null">is_end = #{data.isEnd},</if> <if test="data.isEnd != null">is_end = #{data.isEnd},</if>
<if test="data.materialNo != null">material_no = #{data.materialNo},</if> <if test="data.materialNo != null">material_no = #{data.materialNo},</if>
<if test="data.picture != null">picture = #{data.picture},</if> <if test="data.picture != null">picture = #{data.picture},</if>
<if test="data.name != null">name = #{data.name},</if> <if test="data.name != null">`name` = #{data.name},</if>
<if test="data.spec != null">spec = #{data.spec},</if> <if test="data.spec != null">spec = #{data.spec},</if>
<if test="data.num != null">num = #{data.num},</if> <if test="data.num != null">num = #{data.num},</if>
<if test="data.remark != null">remark = #{data.remark},</if> <if test="data.remark != null">remark = #{data.remark},</if>
<if test="data.deleted != null">deleted = #{data.deleted},</if> <if test="data.deleted != null">deleted = #{data.deleted},</if>
<if test="data.createTime != null">create_time = #{data.createTime},</if> <if test="data.createTime != null">create_time = #{data.createTime},</if>
<if test="data.sort != null">sort = #{data.sort},</if>
</sql> </sql>
<delete id="deleteOrderProdById" parameterType="Long"> <delete id="deleteOrderProdById" parameterType="Long">

View File

@ -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<OrderProdVO> list);
}

View File

@ -14,4 +14,9 @@ public interface OrderProdConverter {
* 新增时转为BO * 新增时转为BO
*/ */
List<OrderProdBO> toBOListByCreate(List<OrderProdBO> list); List<OrderProdBO> toBOListByCreate(List<OrderProdBO> list);
/**
* 修改时转为BO
*/
List<OrderProdBO> toBOListByUpdate(List<OrderProdBO> list);
} }

View File

@ -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<OrderProdVO> list) {
if (CollectionUtils.isEmptyElement(list)) {
return;
}
ProdProcessQuery query = new ProdProcessQuery();
query.setOrderProdIds(CollectionUtils.map(list, OrderProdVO::getId));
Map<Long, List<ProdProcessVO>> group = prodProcessService.selectProdProcessList(query)
.stream().collect(Collectors.groupingBy(ProdProcess::getOrderProdId));
for (OrderProdVO prod : list) {
List<ProdProcessVO> processList = group.get(prod.getId());
if (processList == null) {
processList = new ArrayList<>();
}
prod.setProcessList(processList);
}
}
}

View File

@ -37,10 +37,36 @@ public class OrderProdConverterImpl implements OrderProdConverter {
bo.setSpec(prod.getSpec()); bo.setSpec(prod.getSpec());
bo.setNum(prod.getNum()); bo.setNum(prod.getNum());
bo.setRemark(prod.getRemark()); bo.setRemark(prod.getRemark());
bo.setSort(prod.getSort());
bo.setProcessList(prodProcessConverter.toBOListByCreate(prod.getProcessList())); bo.setProcessList(prodProcessConverter.toBOListByCreate(prod.getProcessList()));
boList.add(bo); boList.add(bo);
} }
return boList; return boList;
} }
@Override
public List<OrderProdBO> toBOListByUpdate(List<OrderProdBO> list) {
if (CollectionUtils.isEmptyElement(list)) {
return Collections.emptyList();
}
List<OrderProdBO> 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;
}
} }

View File

@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -113,6 +114,10 @@ public class OrderProdServiceImpl implements IOrderProdService
if (CollectionUtils.isEmptyElement(list)) { if (CollectionUtils.isEmptyElement(list)) {
return 0; return 0;
} }
Date now = DateUtils.getNowDate();
for (OrderProd prod : list) {
prod.setCreateTime(now);
}
return orderProdMapper.batchInsert(list); return orderProdMapper.batchInsert(list);
} }

View File

@ -6,6 +6,7 @@ import com.ruoyi.common.core.validate.ValidGroup;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -34,8 +35,8 @@ public class ProdProcess extends BaseEntity
@Excel(name = "数量") @Excel(name = "数量")
@ApiModelProperty("数量") @ApiModelProperty("数量")
@NotNull(message = "数量不能为空", groups = {ValidGroup.Create.class}) @NotNull(message = "工序数量不能为空", groups = {ValidGroup.Create.class})
@Size(min = 1, message = "数量不能小于1") @Min(value = 1, message = "工序数量不能小于1")
private BigDecimal num; private BigDecimal num;
@Excel(name = "是否最终工序") @Excel(name = "是否最终工序")
@ -63,4 +64,7 @@ public class ProdProcess extends BaseEntity
@Size(max = 50, message = "盖子颜色长度不能超过50个字符") @Size(max = 50, message = "盖子颜色长度不能超过50个字符")
private String coverColor; private String coverColor;
@Excel(name = "排序")
@ApiModelProperty("排序")
private Integer sort;
} }

View File

@ -1,11 +1,18 @@
package com.ruoyi.bst.prodProcess.domain; package com.ruoyi.bst.prodProcess.domain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* @author wjh * @author wjh
* 2024/12/17 * 2024/12/17
*/ */
@Data @Data
public class ProdProcessQuery extends ProdProcessVO{ public class ProdProcessQuery extends ProdProcessVO{
@ApiModelProperty("订单产品ID列表")
private List<Long> orderProdIds;
} }

View File

@ -10,6 +10,9 @@ import lombok.Data;
@Data @Data
public class ProdProcessVO extends ProdProcess{ public class ProdProcessVO extends ProdProcess{
@ApiModelProperty("订单ID")
private Long orderId;
@ApiModelProperty("订单编号") @ApiModelProperty("订单编号")
private String orderNo; private String orderNo;

View File

@ -62,4 +62,16 @@ public interface ProdProcessMapper
* @return 结果 * @return 结果
*/ */
public int deleteProdProcessByIds(Long[] ids); public int deleteProdProcessByIds(Long[] ids);
int batchInsert(@Param("list") List<? extends ProdProcess> list);
/**
* 批量修改产品工序
*/
int batchUpdate(@Param("list") List<? extends ProdProcess> list);
/**
* 逻辑删除
*/
int logicDel(@Param("ids") List<Long> ids);
} }

View File

@ -20,6 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bpp.remark, bpp.remark,
bpp.create_time, bpp.create_time,
bpp.deleted, bpp.deleted,
bpp.sort,
bop.name as order_prod_name, bop.name as order_prod_name,
bo.order_no as order_no, bo.order_no as order_no,
sd.dept_name as dept_name sd.dept_name as dept_name
@ -44,6 +45,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.orderNo != null and query.orderNo != ''"> and bo.order_no like concat('%', #{query.orderNo}, '%')</if> <if test="query.orderNo != null and query.orderNo != ''"> and bo.order_no like concat('%', #{query.orderNo}, '%')</if>
<if test="query.orderProdName != null and query.orderProdName != ''"> and bop.name like concat('%', #{query.orderProdName}, '%')</if> <if test="query.orderProdName != null and query.orderProdName != ''"> and bop.name like concat('%', #{query.orderProdName}, '%')</if>
<if test="query.deptName != null and query.deptName != ''"> and sd.dept_name like concat('%', #{query.deptName}, '%')</if> <if test="query.deptName != null and query.deptName != ''"> and sd.dept_name like concat('%', #{query.deptName}, '%')</if>
<if test="query.orderId != null">and bop.order_id = #{query.orderId}</if>
<if test="query.orderProdIds != null and query.orderProdIds.size() > 0">
and bpp.order_prod_id in
<foreach collection="query.orderProdIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
${query.params.dataScope} ${query.params.dataScope}
</sql> </sql>
@ -56,7 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectProdProcessById" parameterType="Long" resultMap="ProdProcessResult"> <select id="selectProdProcessById" parameterType="Long" resultMap="ProdProcessResult">
<include refid="selectProdProcessVo"/> <include refid="selectProdProcessVo"/>
where id = #{id} where bpp.id = #{id}
</select> </select>
<insert id="insertProdProcess" parameterType="ProdProcess" useGeneratedKeys="true" keyProperty="id"> <insert id="insertProdProcess" parameterType="ProdProcess" useGeneratedKeys="true" keyProperty="id">
@ -73,6 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">remark,</if> <if test="remark != null">remark,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="deleted != null">deleted,</if> <if test="deleted != null">deleted,</if>
<if test="sort != null">sort,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderProdId != null">#{orderProdId},</if> <if test="orderProdId != null">#{orderProdId},</if>
@ -86,9 +95,187 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">#{remark},</if> <if test="remark != null">#{remark},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="deleted != null">#{deleted},</if> <if test="deleted != null">#{deleted},</if>
<if test="sort != null">#{sort},</if>
</trim> </trim>
</insert> </insert>
<insert id="batchInsert" parameterType="ProdProcess" useGeneratedKeys="true" keyProperty="id">
insert into bst_prod_process
<trim prefix="(" suffix=")" suffixOverrides=",">
order_prod_id,
dept_id,
num,
is_end,
handle_way,
effect,
color,
cover_color,
remark,
create_time,
deleted,
sort,
</trim>
values
<foreach collection="list" item="i" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="i.orderProdId != null ">#{i.orderProdId},</if>
<if test="i.orderProdId == null ">default,</if>
<if test="i.deptId != null ">#{i.deptId},</if>
<if test="i.deptId == null ">default,</if>
<if test="i.num != null ">#{i.num},</if>
<if test="i.num == null ">default,</if>
<if test="i.isEnd != null ">#{i.isEnd},</if>
<if test="i.isEnd == null ">default,</if>
<if test="i.handleWay != null ">#{i.handleWay},</if>
<if test="i.handleWay == null ">default,</if>
<if test="i.effect != null ">#{i.effect},</if>
<if test="i.effect == null ">default,</if>
<if test="i.color != null ">#{i.color},</if>
<if test="i.color == null ">default,</if>
<if test="i.coverColor != null ">#{i.coverColor},</if>
<if test="i.coverColor == null ">default,</if>
<if test="i.remark != null ">#{i.remark},</if>
<if test="i.remark == null ">default,</if>
<if test="i.createTime != null ">#{i.createTime},</if>
<if test="i.createTime == null ">default,</if>
<if test="i.deleted != null ">#{i.deleted},</if>
<if test="i.deleted == null ">default,</if>
<if test="i.sort != null ">#{i.sort},</if>
<if test="i.sort == null ">default,</if>
</trim>
</foreach>
</insert>
<update id="batchUpdate">
update bst_prod_process
<trim prefix="SET" suffixOverrides=",">
<foreach open="order_prod_id = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.orderProdId != null ">
WHEN #{item.id} THEN #{item.orderProdId}
</when>
<otherwise>
WHEN #{item.id} THEN `order_prod_id`
</otherwise>
</choose>
</foreach>
<foreach open="dept_id = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.deptId != null ">
WHEN #{item.id} THEN #{item.deptId}
</when>
<otherwise>
WHEN #{item.id} THEN `dept_id`
</otherwise>
</choose>
</foreach>
<foreach open="num = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.num != null ">
WHEN #{item.id} THEN #{item.num}
</when>
<otherwise>
WHEN #{item.id} THEN `num`
</otherwise>
</choose>
</foreach>
<foreach open="is_end = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.isEnd != null ">
WHEN #{item.id} THEN #{item.isEnd}
</when>
<otherwise>
WHEN #{item.id} THEN `is_end`
</otherwise>
</choose>
</foreach>
<foreach open="handle_way = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.handleWay != null ">
WHEN #{item.id} THEN #{item.handleWay}
</when>
<otherwise>
WHEN #{item.id} THEN `handle_way`
</otherwise>
</choose>
</foreach>
<foreach open="effect = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.effect != null ">
WHEN #{item.id} THEN #{item.effect}
</when>
<otherwise>
WHEN #{item.id} THEN `effect`
</otherwise>
</choose>
</foreach>
<foreach open="color = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.color != null ">
WHEN #{item.id} THEN #{item.color}
</when>
<otherwise>
WHEN #{item.id} THEN `color`
</otherwise>
</choose>
</foreach>
<foreach open="cover_color = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.coverColor != null ">
WHEN #{item.id} THEN #{item.coverColor}
</when>
<otherwise>
WHEN #{item.id} THEN `cover_color`
</otherwise>
</choose>
</foreach>
<foreach open="remark = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.remark != null ">
WHEN #{item.id} THEN #{item.remark}
</when>
<otherwise>
WHEN #{item.id} THEN `remark`
</otherwise>
</choose>
</foreach>
<foreach open="create_time = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.createTime != null ">
WHEN #{item.id} THEN #{item.createTime}
</when>
<otherwise>
WHEN #{item.id} THEN `create_time`
</otherwise>
</choose>
</foreach>
<foreach open="deleted = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.deleted != null ">
WHEN #{item.id} THEN #{item.deleted}
</when>
<otherwise>
WHEN #{item.id} THEN `deleted`
</otherwise>
</choose>
</foreach>
<foreach open="sort = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.sort != null ">
WHEN #{item.id} THEN #{item.sort}
</when>
<otherwise>
WHEN #{item.id} THEN `sort`
</otherwise>
</choose>
</foreach>
</trim>
where id in
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item.id}
</foreach>
</update>
<update id="updateProdProcess" parameterType="ProdProcess"> <update id="updateProdProcess" parameterType="ProdProcess">
update bst_prod_process update bst_prod_process
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
@ -97,6 +284,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{data.id} where id = #{data.id}
</update> </update>
<update id="logicDel">
update bst_prod_process
set deleted = true
where id in
<foreach item="item" collection="ids" open="(" separator="," close=")">
#{item}
</foreach>
and deleted = false
</update>
<sql id="updateColumns"> <sql id="updateColumns">
<if test="data.orderProdId != null">order_prod_id = #{data.orderProdId},</if> <if test="data.orderProdId != null">order_prod_id = #{data.orderProdId},</if>
<if test="data.deptId != null">dept_id = #{data.deptId},</if> <if test="data.deptId != null">dept_id = #{data.deptId},</if>
@ -109,6 +306,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="data.remark != null">remark = #{data.remark},</if> <if test="data.remark != null">remark = #{data.remark},</if>
<if test="data.createTime != null">create_time = #{data.createTime},</if> <if test="data.createTime != null">create_time = #{data.createTime},</if>
<if test="data.deleted != null">deleted = #{data.deleted},</if> <if test="data.deleted != null">deleted = #{data.deleted},</if>
<if test="data.sort != null">sort = #{data.sort},</if>
</sql> </sql>
<delete id="deleteProdProcessById" parameterType="Long"> <delete id="deleteProdProcessById" parameterType="Long">

View File

@ -61,4 +61,24 @@ public interface IProdProcessService
* @return 结果 * @return 结果
*/ */
public int deleteProdProcessById(Long id); public int deleteProdProcessById(Long id);
/**
* 根据订单ID查询列表
*/
List<ProdProcessVO> selectByOrderId(Long orderId);
/**
* 批量新增
*/
int batchInsert(List<? extends ProdProcess> list);
/**
* 批量修改
*/
int batchUpdate(List<? extends ProdProcess> list);
/**
* 批量删除
*/
int batchLogicDel(List<? extends ProdProcess> list);
} }

View File

@ -15,4 +15,8 @@ public interface ProdProcessConverter {
*/ */
List<ProdProcessBO> toBOListByCreate(List<ProdProcessBO> list); List<ProdProcessBO> toBOListByCreate(List<ProdProcessBO> list);
/**
* 修改时转为BO
*/
List<ProdProcessBO> toBOListByUpdate(List<ProdProcessBO> list);
} }

View File

@ -32,6 +32,32 @@ public class ProdProcessConverterImpl implements ProdProcessConverter {
bo.setEffect(process.getEffect()); bo.setEffect(process.getEffect());
bo.setColor(process.getColor()); bo.setColor(process.getColor());
bo.setCoverColor(process.getCoverColor()); bo.setCoverColor(process.getCoverColor());
bo.setSort(process.getSort());
boList.add(bo);
}
return boList;
}
@Override
public List<ProdProcessBO> toBOListByUpdate(List<ProdProcessBO> list) {
if (CollectionUtils.isEmptyElement(list)) {
return Collections.emptyList();
}
List<ProdProcessBO> 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); boList.add(bo);
} }

View File

@ -6,9 +6,12 @@ import com.ruoyi.bst.prodProcess.domain.ProdProcessVO;
import com.ruoyi.bst.prodProcess.mapper.ProdProcessMapper; import com.ruoyi.bst.prodProcess.mapper.ProdProcessMapper;
import com.ruoyi.bst.prodProcess.service.IProdProcessService; import com.ruoyi.bst.prodProcess.service.IProdProcessService;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.collection.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -95,4 +98,42 @@ public class ProdProcessServiceImpl implements IProdProcessService
{ {
return prodProcessMapper.deleteProdProcessById(id); return prodProcessMapper.deleteProdProcessById(id);
} }
@Override
public List<ProdProcessVO> 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<? extends ProdProcess> list) {
if (CollectionUtils.isEmptyElement(list)) {
return 0;
}
return prodProcessMapper.batchUpdate(list);
}
@Override
public int batchLogicDel(List<? extends ProdProcess> list) {
if (CollectionUtils.isEmptyElement(list)) {
return 0;
}
return prodProcessMapper.logicDel(CollectionUtils.map(list, ProdProcess::getId));
}
@Override
public int batchInsert(List<? extends ProdProcess> list) {
if (CollectionUtils.isEmptyElement(list)) {
return 0;
}
Date now = DateUtils.getNowDate();
for (ProdProcess process : list) {
process.setCreateTime(now);
}
return prodProcessMapper.batchInsert(list);
}
} }

View File

@ -3,8 +3,9 @@ package com.ruoyi.web.bst;
import com.ruoyi.bst.order.domain.OrderBO; import com.ruoyi.bst.order.domain.OrderBO;
import com.ruoyi.bst.order.domain.OrderQuery; import com.ruoyi.bst.order.domain.OrderQuery;
import com.ruoyi.bst.order.domain.OrderVO; 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.OrderConverter;
import com.ruoyi.bst.order.service.OrderService;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
@ -31,11 +32,14 @@ import java.util.List;
public class OrderController extends BaseController public class OrderController extends BaseController
{ {
@Autowired @Autowired
private IOrderService orderService; private OrderService orderService;
@Autowired @Autowired
private OrderConverter orderConverter; private OrderConverter orderConverter;
@Autowired
private OrderAssembler orderAssembler;
/** /**
* 查询生产订单列表 * 查询生产订单列表
*/ */
@ -69,7 +73,9 @@ public class OrderController extends BaseController
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long 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 @PostMapping
public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) OrderBO order, public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) OrderBO order,
@RequestParam(required = false, defaultValue = "false") Boolean submit) { @RequestParam(required = false, defaultValue = "false") Boolean submit) {
orderConverter.toBOByCreate(order, submit, getLoginUser().getUser()); OrderBO bo = orderConverter.toBOByCreate(order, submit, getLoginUser().getUser());
return toAjax(orderService.addOrder(order)); return toAjax(orderService.addOrder(bo));
} }
/** /**
@ -93,7 +99,8 @@ public class OrderController extends BaseController
public AjaxResult edit(@RequestBody @Validated(ValidGroup.Update.class) OrderBO order, public AjaxResult edit(@RequestBody @Validated(ValidGroup.Update.class) OrderBO order,
@RequestParam(required = false, defaultValue = "false") Boolean submit) @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));
} }
/** /**