优化工单导出
This commit is contained in:
@@ -40,4 +40,11 @@ public interface WorkOrderMapper extends BaseMapper<WorkOrderDO> {
|
||||
*/
|
||||
List<WorkOrderInfoResp> getDetail(Long id);
|
||||
|
||||
/**
|
||||
* 导出任务工单列表
|
||||
*
|
||||
* @param queryWrapper 查询参数
|
||||
* @return 任务工单列表
|
||||
*/
|
||||
List<WorkOrderResp> selectExport(@Param(Constants.WRAPPER) QueryWrapper<WorkOrderDO> queryWrapper);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package top.wms.admin.weighManage.model.resp;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 任务工单导出信息(扁平化,包含主表和子表字段)
|
||||
*
|
||||
* @author zc
|
||||
* @since 2026/04/16
|
||||
*/
|
||||
@Data
|
||||
public class WorkOrderExportResp {
|
||||
|
||||
@ExcelProperty(value = "人员卡号", order = 1)
|
||||
private String cardNo;
|
||||
|
||||
@ExcelProperty(value = "工单编号", order = 2)
|
||||
private String orderNo;
|
||||
|
||||
@ExcelProperty(value = "标题", order = 3)
|
||||
private String title;
|
||||
|
||||
@ExcelProperty(value = "物料名称", order = 4)
|
||||
private String materialName;
|
||||
|
||||
@ExcelProperty(value = "物料编码", order = 5)
|
||||
private String encoding;
|
||||
|
||||
@ExcelProperty(value = "单位重量", order = 6)
|
||||
private BigDecimal unitWeight;
|
||||
|
||||
@ExcelProperty(value = "物料直径", order = 7)
|
||||
private Double materialSpec;
|
||||
|
||||
@ExcelProperty(value = "图片地址", order = 8)
|
||||
private String photoUrl;
|
||||
|
||||
@ExcelProperty(value = "标准总重量(g)", order = 11)
|
||||
private BigDecimal totalCalculatedWeight;
|
||||
|
||||
@ExcelProperty(value = "实际总重量(g)", order = 12)
|
||||
private BigDecimal totalWeight;
|
||||
|
||||
@ExcelProperty(value = "总数量", order = 13)
|
||||
private Integer totalCount;
|
||||
|
||||
@ExcelProperty(value = "输入数量", order = 14)
|
||||
private Integer quantity;
|
||||
|
||||
@ExcelProperty(value = "标准重量(g)", order = 15)
|
||||
private BigDecimal calculatedWeight;
|
||||
|
||||
@ExcelProperty(value = "称重数量", order = 16)
|
||||
private Integer weightQuantity;
|
||||
|
||||
@ExcelProperty(value = "称重重量(g)", order = 17)
|
||||
private BigDecimal weight;
|
||||
|
||||
@ExcelProperty(value = "图片地址", order = 18)
|
||||
private String imgUrl;
|
||||
|
||||
@ExcelProperty(value = "批次", order = 9)
|
||||
private String infoBatch;
|
||||
|
||||
@ExcelProperty(value = "标记号", order = 10)
|
||||
private String infoMark;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package top.wms.admin.weighManage.model.resp;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -34,9 +35,10 @@ public class WorkOrderInfoResp {
|
||||
private Long materialId;
|
||||
|
||||
/**
|
||||
* 物料主键id
|
||||
* 物料名称
|
||||
*/
|
||||
@Schema(description = "物料主键id")
|
||||
@Schema(description = "物料名称")
|
||||
@ExcelProperty(value = "物料名称", order = 1)
|
||||
private String materialName;
|
||||
|
||||
/**
|
||||
@@ -49,40 +51,48 @@ public class WorkOrderInfoResp {
|
||||
* 物料数量
|
||||
*/
|
||||
@Schema(description = "物料数量")
|
||||
@ExcelProperty(value = "输入数量", order = 2)
|
||||
private Integer quantity;
|
||||
/**
|
||||
* 计算重量
|
||||
*/
|
||||
@Schema(description = "计算重量")
|
||||
@ExcelProperty(value = "标准重量(g)", order = 3)
|
||||
private BigDecimal calculatedWeight;
|
||||
|
||||
/**
|
||||
* 称重数量
|
||||
*/
|
||||
@Schema(description = "称重数量")
|
||||
@ExcelProperty(value = "称重数量", order = 4)
|
||||
private Integer weightQuantity;
|
||||
|
||||
/**
|
||||
* 称重重量
|
||||
*/
|
||||
@Schema(description = "称重重量")
|
||||
@ExcelProperty(value = "称重重量(g)", order = 5)
|
||||
private BigDecimal weight;
|
||||
|
||||
/**
|
||||
* 计算重量
|
||||
*/
|
||||
@Schema(description = "计算重量")
|
||||
private BigDecimal calculatedWeight;
|
||||
|
||||
/**
|
||||
* 抓拍的图片
|
||||
*/
|
||||
@Schema(description = "抓拍的图片")
|
||||
@ExcelProperty(value = "图片地址", order = 6)
|
||||
private String imgUrl;
|
||||
|
||||
/**
|
||||
* 批次
|
||||
*/
|
||||
@Schema(description = "批次")
|
||||
@ExcelProperty(value = "批次", order = 7)
|
||||
private String batch;
|
||||
|
||||
/**
|
||||
* 标记号
|
||||
*/
|
||||
@Schema(description = "标记号")
|
||||
@ExcelProperty(value = "标记号", order = 8)
|
||||
private String mark;
|
||||
|
||||
/**
|
||||
* 称重数量
|
||||
*/
|
||||
private Integer weightQuantity;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package top.wms.admin.weighManage.model.resp;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@@ -28,88 +30,104 @@ public class WorkOrderResp extends BaseDetailResp {
|
||||
* 卡号
|
||||
*/
|
||||
@Schema(description = "卡号")
|
||||
@ExcelProperty(value = "人员卡号", order = 1)
|
||||
private String cardNo;
|
||||
|
||||
/**
|
||||
* 工单编号
|
||||
*/
|
||||
@Schema(description = "工单编号")
|
||||
@ExcelProperty(value = "工单编号", order = 2)
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
@Schema(description = "标题")
|
||||
@ExcelProperty(value = "标题", order = 3)
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 物料主键id
|
||||
*/
|
||||
@Schema(description = "物料主键id")
|
||||
@ExcelIgnore
|
||||
private Long materialId;
|
||||
|
||||
/**
|
||||
* 物料名称
|
||||
*/
|
||||
@Schema(description = "物料名称")
|
||||
@ExcelProperty(value = "物料名称", order = 4)
|
||||
private String materialName;
|
||||
|
||||
/**
|
||||
* 物料编码
|
||||
*/
|
||||
@Schema(description = "物料编码")
|
||||
@ExcelProperty(value = "物料编码", order = 5)
|
||||
private String encoding;
|
||||
|
||||
/**
|
||||
* 物料单位重量
|
||||
*/
|
||||
@Schema(description = "物料单位重量")
|
||||
@ExcelProperty(value = "单位重量", order = 6)
|
||||
private BigDecimal unitWeight;
|
||||
|
||||
/**
|
||||
* 物料直径
|
||||
*/
|
||||
@Schema(description = "物料直径")
|
||||
@ExcelProperty(value = "物料直径", order = 7)
|
||||
private Double materialSpec;
|
||||
|
||||
/**
|
||||
* 物料图片
|
||||
*/
|
||||
@Schema(description = "物料图片")
|
||||
@ExcelProperty(value = "图片地址", order = 8)
|
||||
private String photoUrl;
|
||||
|
||||
/**
|
||||
* 计算总重量(标重)
|
||||
*/
|
||||
@Schema(description = "计算总重量(标重)")
|
||||
@ExcelProperty(value = "标准总重量(g)", order = 9)
|
||||
private BigDecimal totalCalculatedWeight;
|
||||
|
||||
/**
|
||||
* 实际总重量
|
||||
*/
|
||||
@Schema(description = "实际总重量")
|
||||
@ExcelProperty(value = "实际总重量(g)", order = 10)
|
||||
private BigDecimal totalWeight;
|
||||
|
||||
/**
|
||||
* 总数量
|
||||
*/
|
||||
@Schema(description = "总数量")
|
||||
@ExcelProperty(value = "总数量", order = 11)
|
||||
private int totalCount;
|
||||
|
||||
/**
|
||||
* 任务工单详情信息列表
|
||||
*/
|
||||
@Schema(description = "任务工单详情信息列表")
|
||||
@ExcelProperty(value = "任务工单详情信息列表", order = 12)
|
||||
private List<WorkOrderInfoResp> workOrderInfos;
|
||||
|
||||
/**
|
||||
* 批次
|
||||
*/
|
||||
@Schema(description = "批次")
|
||||
@ExcelProperty(value = "批次", order = 12)
|
||||
private String batch;
|
||||
|
||||
/**
|
||||
* 标记号
|
||||
*/
|
||||
@Schema(description = "标记号")
|
||||
@ExcelProperty(value = "标记号", order = 13)
|
||||
private String mark;
|
||||
}
|
||||
@@ -8,13 +8,16 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import top.continew.starter.core.validation.CheckUtils;
|
||||
import top.continew.starter.extension.crud.model.query.PageQuery;
|
||||
import top.continew.starter.extension.crud.model.query.SortQuery;
|
||||
import top.continew.starter.extension.crud.model.resp.PageResp;
|
||||
import top.continew.starter.extension.crud.service.BaseServiceImpl;
|
||||
import top.continew.starter.file.excel.util.ExcelUtils;
|
||||
import top.wms.admin.common.context.UserContextHolder;
|
||||
import top.wms.admin.material.mapper.MaterialInfoMapper;
|
||||
import top.wms.admin.material.model.entity.MaterialInfoDO;
|
||||
@@ -25,6 +28,9 @@ import top.wms.admin.weighManage.mapper.WorkOrderMapper;
|
||||
import top.wms.admin.weighManage.model.entity.WorkOrderDO;
|
||||
import top.wms.admin.weighManage.model.entity.WorkOrderInfoDO;
|
||||
import top.wms.admin.weighManage.model.query.WorkOrderQuery;
|
||||
import top.wms.admin.weighManage.model.resp.WorkOrderExportResp;
|
||||
import top.wms.admin.weighManage.model.resp.WorkOrderInfoResp;
|
||||
import top.wms.admin.weighManage.model.resp.WorkOrderResp;
|
||||
import top.wms.admin.weighManage.model.req.WorkOrderInfoReq;
|
||||
import top.wms.admin.weighManage.model.req.WorkOrderReq;
|
||||
import top.wms.admin.weighManage.model.resp.WorkOrderInfoResp;
|
||||
@@ -32,10 +38,8 @@ import top.wms.admin.weighManage.model.resp.WorkOrderResp;
|
||||
import top.wms.admin.weighManage.service.WorkOrderService;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 任务工单信息业务实现
|
||||
@@ -73,6 +77,55 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
|
||||
return PageResp.build(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void export(WorkOrderQuery query, SortQuery sortQuery, HttpServletResponse response) {
|
||||
QueryWrapper<WorkOrderDO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.like(StrUtil.isNotBlank(query.getMaterialName()), "m.material_name", query.getMaterialName());
|
||||
queryWrapper.eq(null != query.getOrderNo(), "w.order_no", query.getOrderNo());
|
||||
queryWrapper.eq(StrUtil.isNotBlank(query.getBatch()), "w.batch", query.getBatch());
|
||||
queryWrapper.eq(StrUtil.isNotBlank(query.getUserName()), "u.username", query.getUserName());
|
||||
queryWrapper.eq(StrUtil.isNotBlank(query.getCarNo()), "u.card_no", query.getCarNo());
|
||||
queryWrapper.eq(StrUtil.isNotBlank(query.getEncoding()), "m.encoding", query.getEncoding());
|
||||
queryWrapper.ge(null != query.getStartDate(), "w.create_time", query.getStartDate());
|
||||
queryWrapper.le(null != query.getEndDate(), "w.create_time", query.getEndDate());
|
||||
queryWrapper.orderByDesc("w.id");
|
||||
List<WorkOrderResp> workOrders = baseMapper.selectExport(queryWrapper);
|
||||
Map<Long, List<WorkOrderInfoResp>> collect = new HashMap<>();
|
||||
if (CollUtil.isNotEmpty(workOrders)) {
|
||||
List<Long> ids = workOrders.stream().map(WorkOrderResp::getId).collect(Collectors.toList());
|
||||
List<WorkOrderInfoDO> workOrderInfos = workOrderInfoMapper.selectList(new QueryWrapper<WorkOrderInfoDO>()
|
||||
.in("work_order_id", ids));
|
||||
List<WorkOrderInfoResp> workOrderInfoResps = BeanUtil.copyToList(workOrderInfos, WorkOrderInfoResp.class);
|
||||
collect = workOrderInfoResps.stream().collect(Collectors.groupingBy(WorkOrderInfoResp::getWorkOrderId));
|
||||
}
|
||||
List<WorkOrderExportResp> exportList = new ArrayList<>();
|
||||
for (WorkOrderResp workOrder : workOrders) {
|
||||
List<WorkOrderInfoResp> infos = collect.get(workOrder.getId());
|
||||
|
||||
WorkOrderExportResp mainExport = new WorkOrderExportResp();
|
||||
BeanUtil.copyProperties(workOrder, mainExport);
|
||||
mainExport.setInfoBatch(workOrder.getBatch());
|
||||
mainExport.setInfoMark(workOrder.getMark());
|
||||
exportList.add(mainExport);
|
||||
|
||||
if (CollUtil.isNotEmpty(infos)) {
|
||||
for (WorkOrderInfoResp info : infos) {
|
||||
WorkOrderExportResp infoExport = new WorkOrderExportResp();
|
||||
infoExport.setOrderNo(workOrder.getOrderNo());
|
||||
infoExport.setQuantity(info.getQuantity());
|
||||
infoExport.setCalculatedWeight(info.getCalculatedWeight());
|
||||
infoExport.setWeightQuantity(info.getWeightQuantity());
|
||||
infoExport.setWeight(info.getWeight());
|
||||
infoExport.setImgUrl(info.getImgUrl());
|
||||
infoExport.setInfoBatch(info.getBatch());
|
||||
infoExport.setInfoMark(info.getMark());
|
||||
exportList.add(infoExport);
|
||||
}
|
||||
}
|
||||
}
|
||||
ExcelUtils.export(exportList, "任务工单导出", WorkOrderExportResp.class, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkOrderResp getDetail(Long id) {
|
||||
WorkOrderDO workOrderDO = baseMapper.selectById(id);
|
||||
|
||||
@@ -26,4 +26,19 @@
|
||||
where wi.work_order_id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectExport" resultType="top.wms.admin.weighManage.model.resp.WorkOrderResp">
|
||||
select
|
||||
w.*,
|
||||
m.material_name,
|
||||
m.encoding,
|
||||
m.photo_url,
|
||||
m.unit_weight,
|
||||
u.card_no,
|
||||
u.username createUserString
|
||||
from sys_work_order w
|
||||
left join sys_material_info m on w.material_id = m.id
|
||||
left join sys_user u on w.create_user = u.id
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -28,9 +28,9 @@ import java.util.regex.Pattern;
|
||||
public class AHDZCConnect {
|
||||
|
||||
//老设备(只能跑jar包的)
|
||||
private static final String PORT_NAME = "COM12";
|
||||
// private static final String PORT_NAME = "COM12";
|
||||
//新设备(环境齐全的)
|
||||
// private static final String PORT_NAME = "COM13";
|
||||
private static final String PORT_NAME = "COM13";
|
||||
private static final int BAUD_RATE = 9600;
|
||||
private static final int DATA_BITS = 8;
|
||||
private static final int STOP_BITS = 1;
|
||||
|
||||
Reference in New Issue
Block a user