导出入库列表、进度逻辑修改

This commit is contained in:
磷叶 2025-02-25 17:00:52 +08:00
parent 6e3b303195
commit 65c0d94643
9 changed files with 60 additions and 43 deletions

View File

@ -8,4 +8,6 @@ package com.ruoyi.common.constant;
public class DictType {
// 订单产品加工类型
public static final String ORDER_PROD_WORK_TYPE = "order_prod_work_type";
// 入库状态
public static final String STORE_STATUS = "store_status";
}

View File

@ -2,6 +2,7 @@ package com.ruoyi.common.utils.collection;
import com.ruoyi.common.utils.DateUtils;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.*;
import java.util.function.Function;
@ -209,4 +210,12 @@ public class CollectionUtils extends org.springframework.util.CollectionUtils {
return result;
}
/**
* 计算集合中BigDecimal的和
*/
public static <T> BigDecimal sumDecimal(Collection<T> collection, Function<T, BigDecimal> decimalMapper) {
return collection.stream().map(decimalMapper).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
}
}

View File

@ -27,6 +27,9 @@ public class OrderVO extends Order{
@ApiModelProperty("最终工序有效清点数")
private BigDecimal storeNum;
@ApiModelProperty("总数量")
private BigDecimal totalNum;
@ApiModelProperty("进度")
public BigDecimal getProgress() {
if (this.storeNum == null || this.getNum() == null) {
@ -34,6 +37,6 @@ public class OrderVO extends Order{
}
return this.storeNum
.multiply(new BigDecimal(100))
.divide(this.getNum(), 2, RoundingMode.HALF_UP);
.divide(this.getTotalNum(), 2, RoundingMode.HALF_UP);
}
}

View File

@ -10,11 +10,9 @@ import com.ruoyi.common.utils.collection.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
@ -71,22 +69,11 @@ public class OrderAssemblerImpl implements OrderAssembler {
if (CollectionUtils.isEmptyElement(list)) {
return;
}
OrderProdQuery query = new OrderProdQuery();
query.setOrderIds(CollectionUtils.map(list, OrderVO::getId));
query.setIsEnd(true);
List<OrderProdVO> processList = orderProdService.selectOrderProdList(query);
orderProdAssembler.assembleProgress(processList);
for (OrderVO order : list) {
OrderProdVO prod = processList.stream().filter(item -> Objects.equals(item.getOrderId(), order.getId())).findFirst().orElse(null);
if (prod == null) {
order.setReportNum(BigDecimal.ZERO);
order.setStoreNum(BigDecimal.ZERO);
} else {
order.setFinalProdId(prod.getId());
order.setReportNum(prod.getReportNum());
order.setStoreNum(prod.getStoreNum());
}
order.setTotalNum(CollectionUtils.sumDecimal(order.getProdList(), OrderProdVO::getNum));
order.setReportNum(CollectionUtils.sumDecimal(order.getProdList(), OrderProdVO::getReportNum));
order.setStoreNum(CollectionUtils.sumDecimal(order.getProdList(), OrderProdVO::getStoreNum));
}
}
}

View File

@ -20,13 +20,13 @@ import com.ruoyi.bst.prodProcess.service.IProdProcessService;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.collection.CollectionUtils;
import com.ruoyi.common.utils.collection.DiffListVO;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.dept.domain.SysDeptQuery;
import com.ruoyi.system.dept.domain.SysDeptVO;
import com.ruoyi.system.dept.service.ISysDeptService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.support.TransactionTemplate;
@ -237,7 +237,9 @@ public class OrderServiceImpl implements OrderService
ServiceUtil.assertion(old == null, "待完工的订单不存在");
ServiceUtil.assertion(!OrderStatus.canFinished().contains(old.getStatus()), "当前订单状态不允许完工");
orderAssembler.assembleProgress(Collections.singletonList(old));
List<OrderVO> list = Collections.singletonList(old);
orderAssembler.assembleProdList(list, false, true);
orderAssembler.assembleProgress(list);
ServiceUtil.assertion(old.getProgress().compareTo(new BigDecimal("100")) < 0, "当前订单进度:%s%%暂不满足完工条件100%%", old.getProgress());
// 更新订单状态
@ -281,7 +283,10 @@ public class OrderServiceImpl implements OrderService
String way = handleWayList.get(i).trim();
SysDeptVO dept = depts.stream()
.filter(deptItem -> {
List<String> deptProcess = Arrays.asList(deptItem.getProcess().split(","));
List<String> deptProcess = new ArrayList<>();
if (StringUtils.hasText(deptItem.getProcess())) {
deptProcess = Arrays.asList(deptItem.getProcess().split(","));
}
return Objects.equals(deptItem.getDeptName(), way) || deptProcess.contains(way);
})
.findFirst().orElse(null);
@ -306,6 +311,7 @@ public class OrderServiceImpl implements OrderService
return data;
} catch (Exception e) {
e.printStackTrace();
throw new ServiceException(e.getMessage());
}
}

View File

@ -1,6 +1,7 @@
package com.ruoyi.bst.store.domain;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.constant.DictType;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.core.validate.ValidGroup;
import io.swagger.annotations.ApiModelProperty;
@ -11,6 +12,7 @@ import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.sql.Date;
import java.time.LocalDateTime;
/**
@ -24,46 +26,52 @@ public class Store extends BaseEntity
{
private static final long serialVersionUID = 1L;
@Excel(name = "ID", type = Excel.Type.EXPORT, sort = 1)
private Long id;
@Excel(name = "工序ID")
@ApiModelProperty("工序ID")
@NotNull(message = "工序不允许为空", groups = {ValidGroup.Create.class})
private Long processId;
@Excel(name = "上报数量")
@Excel(name = "上报数量", sort = 7)
@ApiModelProperty("上报数量")
@NotNull(message = "上报数量不允许为空", groups = {ValidGroup.Create.class})
@Min(value = 1, message = "上报数量不能小于1")
private BigDecimal num;
@Excel(name = "入库数量")
@ApiModelProperty("入库数量")
@Excel(name = "清点数量", sort = 8)
@ApiModelProperty("清点数量")
private BigDecimal storeNum;
@Excel(name = "上报人ID")
@ApiModelProperty("上报人ID")
private Long createId;
@Excel(name = "状态", readConverterExp = "1=待清点,2=已清点")
@Excel(name = "上报人", sort = 9)
@ApiModelProperty("上报人")
private String createBy;
@Excel(name = "状态", dictType = DictType.STORE_STATUS, comboReadDict = true, sort = 6)
@ApiModelProperty("状态")
private String status;
@Excel(name = "入库人ID")
@ApiModelProperty("入库人ID")
private Long storeUserId;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "入库时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("入库时间")
private LocalDateTime storeTime;
@Excel(name = "入库人名称")
@ApiModelProperty("入库人名称")
@Excel(name = "清点人", sort = 12)
@ApiModelProperty("清点人")
private String storeBy;
@Excel(name = "备注")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "清点时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 13)
@ApiModelProperty("清点时间")
private LocalDateTime storeTime;
@Excel(name = "备注", sort = 11)
@Size(max = 200, message = "备注长度不能超过200个字符")
private String remark;
@Excel(name = "上报时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 10)
@ApiModelProperty("上报时间")
private Date createTime;
}

View File

@ -1,5 +1,6 @@
package com.ruoyi.bst.store.domain;
import com.ruoyi.common.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -14,18 +15,22 @@ public class StoreVO extends Store{
private Long orderId;
@ApiModelProperty("订单编号")
@Excel(name = "订单编号", type = Excel.Type.EXPORT, sort = 2)
private String orderNo;
@ApiModelProperty("产品名称")
@Excel(name = "产品名称", type = Excel.Type.EXPORT, sort = 3)
private String prodName;
@ApiModelProperty("工序部门名称")
@ApiModelProperty("工序名称")
@Excel(name = "工序名称", type = Excel.Type.EXPORT, sort = 4)
private String processDeptName;
@ApiModelProperty("工序部门ID")
private Long processDeptId;
@ApiModelProperty("是否最终工序")
@Excel(name = "是否最终工序", type = Excel.Type.EXPORT, readConverterExp = "false=否,true=是", sort = 5)
private Boolean processIsEnd;
@ApiModelProperty("负责工序")

View File

@ -52,13 +52,9 @@ public class OrderController extends BaseController
startPage();
startOrderBy();
List<OrderVO> list = orderService.selectOrderList(query);
orderAssembler.assembleProgress(list);
if (query.getNeedProd() != null && query.getNeedProd()) {
orderAssembler.assembleProdList(list,
query.getNeedProcess() != null && query.getNeedProcess(),
query.getNeedProdProgress() != null && query.getNeedProdProgress());
}
orderAssembler.assembleProdList(list, true, true);
orderAssembler.assembleProgress(list);
return getDataTable(list);
}
@ -84,7 +80,7 @@ public class OrderController extends BaseController
{
OrderVO vo = orderService.selectOrderById(id);
List<OrderVO> list = Collections.singletonList(vo);
orderAssembler.assembleProdList(list, true, false);
orderAssembler.assembleProdList(list, true, true);
orderAssembler.assembleProgress(list);
return success(vo);
}

View File

@ -60,6 +60,7 @@ public class StoreController extends BaseController
@PostMapping("/export")
public void export(HttpServletResponse response, StoreQuery query)
{
startPage();
List<StoreVO> list = storeService.selectStoreList(query);
ExcelUtil<StoreVO> util = new ExcelUtil<StoreVO>(StoreVO.class);
util.exportExcel(response, list, "入库数据");