5 Commits

Author SHA1 Message Date
zc
6355059ee3 打印编码需求变更 2026-06-15 18:03:06 +08:00
zc
2c7e05cbad 打印编码需求变更 2026-06-15 15:36:16 +08:00
zc
9f56c47105 打印编码 2026-06-15 13:49:30 +08:00
zc
22c7963bf5 打印编码 2026-06-10 10:37:06 +08:00
zc
e932af0404 整箱导出优化 2026-05-07 16:02:16 +08:00
38 changed files with 824 additions and 381 deletions

View File

@@ -1,18 +0,0 @@
package top.wms.admin.common.config.mybatis;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
import top.wms.admin.common.constant.DataSourceContextHolder;
/**
* 动态数据源路由
*
* @author Admin
* @since 2024/12/22
*/
public class DynamicRoutingDataSource extends AbstractRoutingDataSource {
@Override
protected Object determineCurrentLookupKey() {
return DataSourceContextHolder.getDataSource();
}
}

View File

@@ -1,40 +0,0 @@
package top.wms.admin.common.constant;
/**
* 数据源上下文 Holder
*
* @author Admin
* @since 2024/12/22
*/
public class DataSourceContextHolder {
private static final ThreadLocal<String> CONTEXT_HOLDER = new ThreadLocal<>();
private DataSourceContextHolder() {
}
/**
* 设置数据源
*
* @param dataSource 数据源标识
*/
public static void setDataSource(String dataSource) {
CONTEXT_HOLDER.set(dataSource);
}
/**
* 获取数据源
*
* @return 数据源标识
*/
public static String getDataSource() {
return CONTEXT_HOLDER.get();
}
/**
* 清除数据源
*/
public static void clearDataSource() {
CONTEXT_HOLDER.remove();
}
}

View File

@@ -74,11 +74,6 @@ public class UserContext implements Serializable {
*/
private String clientId;
/**
* 数据源标识
*/
private String dataSource;
public UserContext(Set<String> permissions, Set<RoleContext> roles, Integer passwordExpirationDays) {
this.permissions = permissions;
this.setRoles(roles);
@@ -118,4 +113,4 @@ public class UserContext implements Serializable {
}
return this.pwdResetTime.plusDays(this.passwordExpirationDays).isBefore(LocalDateTime.now());
}
}
}

View File

@@ -1,30 +0,0 @@
package top.wms.admin.common.enums;
/**
* 数据源枚举
*
* @author Admin
* @since 2024/12/22
*/
public enum DataSourceEnum {
/**
* 主数据源
*/
WMS_TH("wms_th"),
/**
* 从数据源
*/
WMS_QL("wms_ql");
private final String value;
DataSourceEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
}

View File

@@ -8,7 +8,6 @@ import jakarta.servlet.http.HttpServletRequest;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;
import top.wms.admin.auth.model.req.LoginReq;
import top.wms.admin.common.constant.DataSourceContextHolder;
import top.wms.admin.common.context.RoleContext;
import top.wms.admin.common.context.UserContext;
import top.wms.admin.common.context.UserContextHolder;
@@ -92,14 +91,6 @@ public abstract class AbstractLoginHandler<T extends LoginReq> implements LoginH
userContext.setClientType(client.getClientType());
model.setExtra(CLIENT_ID, client.getClientId());
userContext.setClientId(client.getClientId());
// 设置数据源(如果用户未配置,则使用默认主库)
String dataSource = user.getDataSource();
if (dataSource == null || dataSource.isEmpty()) {
dataSource = "wms_th"; // 默认主库
}
userContext.setDataSource(dataSource);
DataSourceContextHolder.setDataSource(dataSource);
// 登录并缓存用户信息
StpUtil.login(userContext.getId(), model.setExtraData(BeanUtil.beanToMap(new UserExtraContext(SpringWebUtils
.getRequest()))));
@@ -117,4 +108,4 @@ public abstract class AbstractLoginHandler<T extends LoginReq> implements LoginH
// DeptDO dept = deptService.getById(user.getDeptId());
// CheckUtils.throwIfEqual(DisEnableStatusEnum.DISABLE, dept.getStatus(), "此账号所属部门已被禁用,如有疑问,请联系管理员");
}
}
}

View File

@@ -36,6 +36,11 @@ public class FullWorkOrderDO extends BaseDO {
*/
private String materialCode;
/**
* 打印物料编码
*/
private String encodingPrint;
/**
* 图片地址
*/

View File

@@ -46,6 +46,7 @@ public class FullWorkOrderReq implements Serializable {
private String materialCode;
/**
* /**
* 图片地址
*/
@Schema(description = "图片地址")

View File

@@ -26,6 +26,7 @@ import top.wms.admin.fullWorkOrder.model.req.FullWorkOrderInfoReq;
import top.wms.admin.fullWorkOrder.model.req.FullWorkOrderReq;
import top.wms.admin.fullWorkOrder.model.resp.FullWorkOrderResp;
import top.wms.admin.fullWorkOrder.service.FullWorkOrderService;
import top.wms.admin.material.mapper.MaterialInfoMapper;
import java.util.Date;
import java.util.List;
@@ -42,6 +43,8 @@ public class FullWorkOrderServiceImpl extends BaseServiceImpl<FullWorkOrderMappe
private final FullWorkOrderInfoMapper fullWorkOrderInfoMapper;
private final MaterialInfoMapper materialInfoMapper;
@Override
public PageResp<FullWorkOrderResp> page(FullWorkOrderQuery query, PageQuery pageQuery) {
QueryWrapper<FullWorkOrderDO> queryWrapper = new QueryWrapper<>();

View File

@@ -32,6 +32,11 @@ public class MaterialInfoDO extends BaseDO {
*/
private String encoding;
/**
* 打印物料编码
*/
private String encodingPrint;
/**
* 物料单位重量(g)
*/

View File

@@ -29,7 +29,7 @@ public class MaterialImportRowReq implements Serializable {
*/
@Schema(description = "物料编码")
@NotBlank(message = "物料编码不能为空")
@Length(max = 255, message = "物料编码长度不能超过 {max} 个字符")
@Length(max = 64, message = "物料编码长度不能超过 {max} 个字符")
private String encoding;
/**

View File

@@ -37,7 +37,7 @@ public class MaterialInfoReq implements Serializable {
*/
@Schema(description = "物料编码")
@NotBlank(message = "物料编码不能为空")
@Length(max = 255, message = "物料编码长度不能超过 {max} 个字符")
@Length(max = 64, message = "物料编码长度不能超过 {max} 个字符")
private String encoding;
/**

View File

@@ -0,0 +1,16 @@
package top.wms.admin.print.mapper;
import org.springframework.stereotype.Repository;
import top.continew.starter.data.mp.base.BaseMapper;
import top.wms.admin.print.model.entity.PrintInfoDO;
/**
* 打印记录 Mapper
*
* @author zc
* @since 2026/06/15 16:57
*/
@Repository
public interface PrintInfoMapper extends BaseMapper<PrintInfoDO> {
}

View File

@@ -0,0 +1,16 @@
package top.wms.admin.print.mapper;
import top.continew.starter.data.mp.base.BaseMapper;
import top.wms.admin.print.model.entity.PrintDO;
import org.springframework.stereotype.Repository;
/**
* 打印记录 Mapper
*
* @author zc
* @since 2026/06/15 16:57
*/
@Repository
public interface PrintMapper extends BaseMapper<PrintDO> {
}

View File

@@ -0,0 +1,68 @@
package top.wms.admin.print.model.entity;
import lombok.Data;
import com.baomidou.mybatisplus.annotation.TableName;
import top.wms.admin.common.model.entity.BaseDO;
import java.io.Serial;
/**
* 打印记录实体
*
* @author zc
* @since 2026/06/15 16:57
*/
@Data
@TableName("sys_print")
public class PrintDO extends BaseDO {
@Serial
private static final long serialVersionUID = 1L;
/**
* 物料编码
*/
private String encoding;
/**
* 打印编码
*/
private String encodingPrint;
/**
* 物料名称
*/
private String materialName;
/**
* 打印名称
*/
private String materialNamePrint;
/**
* 任务工单号
*/
private String orderNo;
/**
* 任务工单id
*/
private Long workerOrderId;
/**
* 批次
*/
private String batch;
/**
* 标签数量
*/
private Integer labelCount;
/**
* 打印类型 0明细标签打印 1整体标签打印
*/
private Integer labelType;
}

View File

@@ -0,0 +1,86 @@
package top.wms.admin.print.model.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 打印记录详情实体
*
* @author zc
* @since 2026/06/15 16:58
*/
@Data
@TableName("sys_print_info")
public class PrintInfoDO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
private Long id;
private Long printId;
/**
* 打印编码
*/
private String encodingPrint;
/**
* 检验签字
*/
private String inspectionSignature;
/**
* 标记号
*/
private String mark;
/**
* 打印名称
*/
private String materialNamePrint;
/**
* 包装签字
*/
private String packingSignature;
/**
* 生产日期
*/
private String productionDate;
/**
* 二维码数据
*/
private String qrCodeData;
/**
* 批次
*/
private String batch;
/**
* 标重
*/
private BigDecimal totalCalculatedWeight;
/**
* 数量
*/
private Integer totalCount;
/**
* 实重
*/
private BigDecimal totalWeight;
/**
* 任务工单ID
*/
private Long workerOrderId;
}

View File

@@ -0,0 +1,82 @@
package top.wms.admin.print.model.query;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
import top.continew.starter.data.core.annotation.Query;
import top.continew.starter.data.core.enums.QueryType;
import java.io.Serial;
import java.io.Serializable;
import java.time.*;
/**
* 打印记录查询条件
*
* @author zc
* @since 2026/06/15 16:57
*/
@Data
@Schema(description = "打印记录查询条件")
public class PrintQuery implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 打印编码
*/
@Schema(description = "打印编码")
@Query(type = QueryType.EQ)
private String encodingPrint;
/**
* 物料名称
*/
@Schema(description = "物料名称")
@Query(type = QueryType.EQ)
private String materialName;
/**
* 打印名称
*/
@Schema(description = "打印名称")
@Query(type = QueryType.EQ)
private String materialNamePrint;
/**
* 任务工单号
*/
@Schema(description = "任务工单号")
@Query(type = QueryType.EQ)
private String orderNo;
/**
* 任务工单id
*/
@Schema(description = "任务工单id")
@Query(type = QueryType.EQ)
private Long workerOrderId;
/**
* 批次
*/
@Schema(description = "批次")
@Query(type = QueryType.EQ)
private String batch;
/**
* 创建人
*/
@Schema(description = "创建人")
@Query(type = QueryType.EQ)
private Long createUser;
/**
* 创建时间
*/
@Schema(description = "创建时间")
@Query(type = QueryType.EQ)
private LocalDateTime createTime;
}

View File

@@ -0,0 +1,109 @@
package top.wms.admin.print.model.req;
import jakarta.validation.constraints.*;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
import org.hibernate.validator.constraints.Length;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 创建或修改打印记录详情参数
*
* @author zc
* @since 2026/06/15 17:03
*/
@Data
@Schema(description = "创建或修改打印记录详情参数")
public class PrintInfoReq implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 打印编码
*/
@Schema(description = "打印编码")
@Length(max = 255, message = "打印编码长度不能超过 {max} 个字符")
private String encodingPrint;
/**
* 检验签字
*/
@Schema(description = "检验签字")
@Length(max = 25, message = "检验签字长度不能超过 {max} 个字符")
private String inspectionSignature;
/**
* 标记号
*/
@Schema(description = "标记号")
@Length(max = 25, message = "标记号长度不能超过 {max} 个字符")
private String mark;
/**
* 打印名称
*/
@Schema(description = "打印名称")
@NotBlank(message = "打印名称不能为空")
@Length(max = 255, message = "打印名称长度不能超过 {max} 个字符")
private String materialNamePrint;
/**
* 包装签字
*/
@Schema(description = "包装签字")
@Length(max = 25, message = "包装签字长度不能超过 {max} 个字符")
private String packingSignature;
/**
* 生产日期
*/
@Schema(description = "生产日期")
@Length(max = 50, message = "生产日期长度不能超过 {max} 个字符")
private String productionDate;
/**
* 二维码数据
*/
@Schema(description = "二维码数据")
@Length(max = 500, message = "二维码数据长度不能超过 {max} 个字符")
private String qrCodeData;
/**
* 批次
*/
@Schema(description = "批次")
@NotBlank(message = "批次不能为空")
@Length(max = 255, message = "批次长度不能超过 {max} 个字符")
private String batch;
/**
* 标重
*/
@Schema(description = "标重")
private BigDecimal totalCalculatedWeight;
/**
* 数量
*/
@Schema(description = "数量")
private Integer totalCount;
/**
* 实重
*/
@Schema(description = "实重")
private BigDecimal totalWeight;
/**
* 任务工单ID
*/
@Schema(description = "任务工单ID")
private Long workerOrderId;
}

View File

@@ -0,0 +1,88 @@
package top.wms.admin.print.model.req;
import jakarta.validation.constraints.*;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
import top.wms.admin.print.model.entity.PrintInfoDO;
import java.io.Serial;
import java.io.Serializable;
import java.time.*;
import java.util.List;
/**
* 创建或修改打印记录参数
*
* @author zc
* @since 2026/06/15 17:04
*/
@Data
@Schema(description = "创建或修改打印记录参数")
public class PrintReq implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 物料编码
*/
@Schema(description = "物料编码")
private String encoding;
/**
* 打印编码
*/
@Schema(description = "打印编码")
private String encodingPrint;
/**
* 物料名称
*/
@Schema(description = "物料名称")
@NotBlank(message = "物料名称不能为空")
private String materialName;
/**
* 打印名称
*/
@Schema(description = "打印名称")
private String materialNamePrint;
/**
* 任务工单号
*/
@Schema(description = "任务工单号")
@NotBlank(message = "任务工单号不能为空")
private String orderNo;
/**
* 任务工单id
*/
@Schema(description = "任务工单id")
@NotNull(message = "任务工单id不能为空")
private Long workerOrderId;
/**
* 批次
*/
@Schema(description = "批次")
@NotBlank(message = "批次不能为空")
private String batch;
/**
* 标签数量
*/
@Schema(description = "标签数量")
private Integer labelCount;
/**
* 打印类型 0明细标签打印 1整体标签打印
*/
@Schema(description = "打印类型 0明细标签打印 1整体标签打印")
private Integer labelType;
private List<PrintInfoDO> printInfoList;
}

View File

@@ -0,0 +1,97 @@
package top.wms.admin.print.model.resp;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 打印记录详情信息
*
* @author zc
* @since 2026/06/15 17:08
*/
@Data
@Schema(description = "打印记录详情信息")
public class PrintInfoResp implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
private Long id;
/**
* 打印编码
*/
@Schema(description = "打印编码")
private String encodingPrint;
/**
* 检验签字
*/
@Schema(description = "检验签字")
private String inspectionSignature;
/**
* 标记号
*/
@Schema(description = "标记号")
private String mark;
/**
* 打印名称
*/
@Schema(description = "打印名称")
private String materialNamePrint;
/**
* 包装签字
*/
@Schema(description = "包装签字")
private String packingSignature;
/**
* 生产日期
*/
@Schema(description = "生产日期")
private String productionDate;
/**
* 二维码数据
*/
@Schema(description = "二维码数据")
private String qrCodeData;
/**
* 批次
*/
@Schema(description = "批次")
private String batch;
/**
* 标重
*/
@Schema(description = "标重")
private BigDecimal totalCalculatedWeight;
/**
* 数量
*/
@Schema(description = "数量")
private Integer totalCount;
/**
* 实重
*/
@Schema(description = "实重")
private BigDecimal totalWeight;
/**
* 任务工单ID
*/
@Schema(description = "任务工单ID")
private Long workerOrderId;
}

View File

@@ -0,0 +1,90 @@
package top.wms.admin.print.model.resp;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
import top.wms.admin.common.model.resp.BaseDetailResp;
import java.io.Serial;
import java.time.*;
/**
* 打印记录信息
*
* @author zc
* @since 2026/06/15 16:57
*/
@Data
@Schema(description = "打印记录信息")
public class PrintResp extends BaseDetailResp {
@Serial
private static final long serialVersionUID = 1L;
/**
* 物料编码
*/
@Schema(description = "物料编码")
private String encoding;
/**
* 打印编码
*/
@Schema(description = "打印编码")
private String encodingPrint;
/**
* 物料名称
*/
@Schema(description = "物料名称")
private String materialName;
/**
* 打印名称
*/
@Schema(description = "打印名称")
private String materialNamePrint;
/**
* 任务工单号
*/
@Schema(description = "任务工单号")
private String orderNo;
/**
* 任务工单id
*/
@Schema(description = "任务工单id")
private Long workerOrderId;
/**
* 批次
*/
@Schema(description = "批次")
private String batch;
/**
* 标签数量
*/
@Schema(description = "标签数量")
private Integer labelCount;
/**
* 打印类型 0明细标签打印 1整体标签打印
*/
@Schema(description = "打印类型 0明细标签打印 1整体标签打印")
private Integer labelType;
/**
* 修改人
*/
@Schema(description = "修改人")
private Long updateUser;
/**
* 修改时间
*/
@Schema(description = "修改时间")
private LocalDateTime updateTime;
}

View File

@@ -0,0 +1,20 @@
package top.wms.admin.print.service;
import top.continew.starter.extension.crud.service.BaseService;
import top.wms.admin.print.model.query.PrintQuery;
import top.wms.admin.print.model.req.PrintReq;
import top.wms.admin.print.model.resp.PrintInfoResp;
import top.wms.admin.print.model.resp.PrintResp;
import java.util.List;
/**
* 打印记录业务接口
*
* @author zc
* @since 2026/06/15 16:57
*/
public interface PrintService extends BaseService<PrintResp, PrintResp, PrintQuery, PrintReq> {
List<PrintInfoResp> getInfo(Long id);
}

View File

@@ -0,0 +1,51 @@
package top.wms.admin.print.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import top.continew.starter.extension.crud.service.BaseServiceImpl;
import top.wms.admin.print.mapper.PrintInfoMapper;
import top.wms.admin.print.mapper.PrintMapper;
import top.wms.admin.print.model.entity.PrintDO;
import top.wms.admin.print.model.entity.PrintInfoDO;
import top.wms.admin.print.model.query.PrintQuery;
import top.wms.admin.print.model.req.PrintReq;
import top.wms.admin.print.model.resp.PrintInfoResp;
import top.wms.admin.print.model.resp.PrintResp;
import top.wms.admin.print.service.PrintService;
import java.util.List;
import java.util.stream.Collectors;
/**
* 打印记录业务实现
*
* @author zc
* @since 2026/06/15 16:57
*/
@Service
@RequiredArgsConstructor
public class PrintServiceImpl extends BaseServiceImpl<PrintMapper, PrintDO, PrintResp, PrintResp, PrintQuery, PrintReq> implements PrintService {
private final PrintInfoMapper printInfoMapper;
@Override
public List<PrintInfoResp> getInfo(Long id) {
PrintDO printDO = baseMapper.selectById(id);
List<PrintInfoDO> printInfoRespList = printInfoMapper.selectList(new QueryWrapper<PrintInfoDO>()
.eq("worker_order_id", printDO.getWorkerOrderId()));
return BeanUtil.copyToList(printInfoRespList, PrintInfoResp.class);
}
@Override
public void afterAdd(PrintReq req, PrintDO printDO) {
printInfoMapper.insertBatch(req.getPrintInfoList()
.stream()
.peek(item -> item.setPrintId(printDO.getId()))
.collect(Collectors.toList()));
}
}

View File

@@ -92,9 +92,4 @@ public class UserDO extends BaseDO {
*/
@TableField(exist = false)
private Long equipmentId;
/**
* 数据源标识wms/wms_ql
*/
private String dataSource;
}
}

View File

@@ -93,12 +93,6 @@ public class UserReq implements Serializable {
@Schema(description = "状态", example = "1")
private DisEnableStatusEnum status;
/**
* 状态
*/
@Schema(description = "数据源")
private String dataSource;
/**
* 设备ID
*/

View File

@@ -116,12 +116,6 @@ public class UserDetailResp extends BaseDetailResp {
@Schema(description = "设备ID")
private Long equipmentId;
/**
* 数据源
*/
@Schema(description = "数据源")
private String dataSource;
@Override
public Boolean getDisabled() {
return this.getIsSystem() || Objects.equals(this.getId(), UserContextHolder.getUserId());

View File

@@ -81,12 +81,6 @@ public class UserResp extends BaseDetailResp {
@Schema(description = "描述", example = "张三描述信息")
private String description;
/**
* 状态
*/
@Schema(description = "数据源")
private String dataSource;
/**
* 角色名称列表
*/

View File

@@ -37,6 +37,11 @@ public class WorkOrderDO extends BaseDO {
*/
private Long materialId;
/**
* 打印物料编码
*/
private String encodingPrint;
/**
* 实际总重量
*/

View File

@@ -12,15 +12,8 @@
left join sys_user u on f.create_user = u.id
${ew.customSqlSegment}
</select>
<select id="selectFullWorkOrderExport" resultType="top.wms.admin.fullWorkOrder.model.resp.FullWorkOrderResp">
select
f.*,
m.material_name materialName,
u.username createUserString
from
sys_full_work_order f
left join sys_material_info m on f.material_code = m.encoding
left join sys_user u on f.create_user = u.id
${ew.customSqlSegment}
</select>
</mapper>

View File

@@ -22,8 +22,7 @@
t1.is_system,
t1.pwd_reset_time,
t1.dept_id,
t2.name AS deptName,
t1.data_source
t2.name AS deptName
FROM sys_user AS t1
LEFT JOIN sys_dept AS t2 ON t2.id = t1.dept_id
</sql>

View File

@@ -8,7 +8,6 @@ import lombok.extern.slf4j.Slf4j;
import org.dromara.x.file.storage.spring.EnableFileStorage;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -29,7 +28,7 @@ import top.continew.starter.web.model.R;
@EnableGlobalResponse
@EnableCrudRestController
@RestController
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@SpringBootApplication
@RequiredArgsConstructor
@EnableScheduling
public class WmsAdminApplication {
@@ -47,4 +46,4 @@ public class WmsAdminApplication {
return R.ok(projectProperties);
}
}
}

View File

@@ -1,110 +0,0 @@
package top.wms.admin.config;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import top.wms.admin.common.config.mybatis.DynamicRoutingDataSource;
import javax.sql.DataSource;
import java.util.HashMap;
import java.util.Map;
/**
* 动态数据源配置
*
* @author Admin
* @since 2024/12/22
*/
@Configuration
public class DynamicDataSourceConfig {
@Value("${spring.datasource.wms_th.url}")
private String wmsUrl;
@Value("${spring.datasource.wms_th.username}")
private String wmsUsername;
@Value("${spring.datasource.wms_th.password}")
private String wmsPassword;
@Value("${spring.datasource.wms_ql.url}")
private String wms_qlUrl;
@Value("${spring.datasource.wms_ql.username}")
private String wms_qlUsername;
@Value("${spring.datasource.wms_ql.password}")
private String wms_qlPassword;
/**
* 主数据源wms
*/
@Bean("wmsDataSource")
public DataSource wmsDataSource() {
HikariConfig config = new HikariConfig();
config.setDriverClassName("com.p6spy.engine.spy.P6SpyDriver");
config.setJdbcUrl(wmsUrl);
config.setUsername(wmsUsername);
config.setPassword(wmsPassword);
config.setMaximumPoolSize(20);
config.setConnectionTimeout(30000);
config.setIdleTimeout(600000);
config.setKeepaliveTime(30000);
config.setMaxLifetime(1800000);
return new HikariDataSource(config);
}
/**
* 从数据源wms_ql
*/
@Bean("wms_qlDataSource")
public DataSource wms_qlDataSource() {
HikariConfig config = new HikariConfig();
config.setDriverClassName("com.p6spy.engine.spy.P6SpyDriver");
config.setJdbcUrl(wms_qlUrl);
config.setUsername(wms_qlUsername);
config.setPassword(wms_qlPassword);
config.setMaximumPoolSize(20);
config.setConnectionTimeout(30000);
config.setIdleTimeout(600000);
config.setKeepaliveTime(30000);
config.setMaxLifetime(1800000);
return new HikariDataSource(config);
}
/**
* 动态数据源
*/
@Bean("dynamicDataSource")
@Primary
public DataSource dynamicDataSource(DataSource wmsDataSource, DataSource wms_qlDataSource) {
DynamicRoutingDataSource dynamicRoutingDataSource = new DynamicRoutingDataSource();
// 设置默认数据源
dynamicRoutingDataSource.setDefaultTargetDataSource(wmsDataSource);
// 设置数据源映射
Map<Object, Object> dataSourceMap = new HashMap<>();
dataSourceMap.put("wms_th", wmsDataSource);
dataSourceMap.put("wms_ql", wms_qlDataSource);
dynamicRoutingDataSource.setTargetDataSources(dataSourceMap);
// 必须调用此方法,否则首次获取数据源时会失败
dynamicRoutingDataSource.afterPropertiesSet();
return dynamicRoutingDataSource;
}
/**
* 事务管理器
*/
@Bean
public PlatformTransactionManager transactionManager(DataSource dynamicDataSource) {
return new DataSourceTransactionManager(dynamicDataSource);
}
}

View File

@@ -1,59 +0,0 @@
package top.wms.admin.config;
import cn.dev33.satoken.stp.StpUtil;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import top.wms.admin.common.constant.DataSourceContextHolder;
import top.wms.admin.common.context.UserContext;
import top.wms.admin.common.context.UserContextHolder;
/**
* 动态数据源拦截器
* 在每次请求时根据当前登录用户切换数据源
*
* @author Admin
* @since 2024/12/22
*/
@Component
public class DynamicDataSourceInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response,
Object handler) throws Exception {
String requestUri = request.getRequestURI();
// 认证相关接口始终使用主库wms确保用户验证和权限获取在主库进行
if (requestUri.contains("/auth/login") || requestUri.contains("/auth/user/info") || requestUri
.contains("/auth/user/route") || requestUri.contains("/auth/logout")) {
DataSourceContextHolder.setDataSource("wms_th");
return true;
}
// 如果用户已登录,从用户上下文获取数据源并设置
if (StpUtil.isLogin()) {
try {
UserContext userContext = UserContextHolder.getContext();
if (userContext != null && userContext.getDataSource() != null) {
DataSourceContextHolder.setDataSource(userContext.getDataSource());
}
} catch (Exception e) {
// 如果获取用户上下文失败,使用默认数据源
DataSourceContextHolder.clearDataSource();
}
}
return true;
}
@Override
public void afterCompletion(HttpServletRequest request,
HttpServletResponse response,
Object handler,
@Nullable Exception ex) throws Exception {
// 请求结束后清除数据源上下文
DataSourceContextHolder.clearDataSource();
}
}

View File

@@ -1,27 +0,0 @@
package top.wms.admin.config;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* WebMvc 配置
*
* @author Admin
* @since 2024/12/22
*/
@Configuration
@RequiredArgsConstructor
public class WebMvcConfig implements WebMvcConfigurer {
private final DynamicDataSourceInterceptor dynamicDataSourceInterceptor;
@Override
public void addInterceptors(InterceptorRegistry registry) {
// 注册动态数据源拦截器,优先级高于其他拦截器
registry.addInterceptor(dynamicDataSourceInterceptor)
.addPathPatterns("/**")
.excludePathPatterns("/error", "/doc.html", "/webjars/**", "/swagger-ui/**", "/swagger-resources/**", "/*/api-docs/**", "/favicon.ico");
}
}

View File

@@ -3,6 +3,7 @@ package top.wms.admin.controller.common;
import cn.dev33.satoken.annotation.SaIgnore;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.util.StrUtil;
import com.alicp.jetcache.anno.Cached;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
@@ -13,6 +14,7 @@ import org.dromara.x.file.storage.core.FileInfo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import top.wms.admin.common.constant.CacheConstants;
import top.wms.admin.common.util.PictureUtils;
import top.wms.admin.system.enums.OptionCategoryEnum;
import top.wms.admin.system.model.query.*;
@@ -143,6 +145,7 @@ public class CommonController {
@SaIgnore
@Operation(summary = "查询系统配置参数", description = "查询系统配置参数")
@GetMapping("/dict/option/site")
@Cached(key = "'SITE'", name = CacheConstants.OPTION_KEY_PREFIX)
public List<LabelValueResp<String>> listSiteOptionDict() {
OptionQuery optionQuery = new OptionQuery();
optionQuery.setCategory(OptionCategoryEnum.SITE.name());

View File

@@ -0,0 +1,37 @@
package top.wms.admin.controller.print;
import top.continew.starter.extension.crud.enums.Api;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;
import lombok.RequiredArgsConstructor;
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
import top.wms.admin.common.controller.BaseController;
import top.wms.admin.print.model.query.PrintQuery;
import top.wms.admin.print.model.req.PrintReq;
import top.wms.admin.print.model.resp.PrintInfoResp;
import top.wms.admin.print.model.resp.PrintResp;
import top.wms.admin.print.service.PrintService;
import java.util.List;
/**
* 打印记录管理 API
*
* @author zc
* @since 2026/06/15 16:57
*/
@Tag(name = "打印记录管理 API")
@RestController
@RequiredArgsConstructor
@CrudRequestMapping(value = "/print/print", api = {Api.PAGE, Api.ADD, Api.DELETE})
public class PrintController extends BaseController<PrintService, PrintResp, PrintResp, PrintQuery, PrintReq> {
@GetMapping("/{id}")
public List<PrintInfoResp> get(@PathVariable Long id) {
return baseService.getInfo(id);
}
}

View File

@@ -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;

View File

@@ -1,7 +1,7 @@
--- ### 项目配置
project:
# URL跨域配置默认放行此 URL第三方登录回调默认使用此 URL 为前缀,请注意更改为你实际的前端 URL
url: http://localhost:80
url: http://localhost:6609
--- ### 服务器配置
server:
@@ -16,37 +16,33 @@ spring:
--- ### 数据源配置
spring.datasource:
# 主数据源wms_th
wms_th:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
url: jdbc:p6spy:mysql://127.0.0.1:3306/wms_th?serverTimezone=Asia/Shanghai&useSSL=false&useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&autoReconnect=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: root
# password: root
password: SQLth7410!DD
# Hikari 连接池配置
hikari:
maximum-pool-size: 20
connection-timeout: 30000
idle-timeout: 600000
keepaliveTime: 30000
max-lifetime: 1800000
# 从数据源wms_ql
wms_ql:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
url: jdbc:p6spy:mysql://127.0.0.1:3306/wms_th?serverTimezone=Asia/Shanghai&useSSL=false&useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&autoReconnect=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
# url: jdbc:p6spy:mysql://127.0.0.1:3306/wms_ql?serverTimezone=Asia/Shanghai&useSSL=false&useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&autoReconnect=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: root
# password: root
password: SQLth7410!DD
# Hikari 连接池配置
hikari:
maximum-pool-size: 20
connection-timeout: 30000
idle-timeout: 600000
keepaliveTime: 30000
max-lifetime: 1800000
type: com.zaxxer.hikari.HikariDataSource
# 请务必提前创建好名为 wms_admin 的数据库,如果使用其他数据库名请注意同步修改 DB_NAME 配置
url: jdbc:p6spy:mysql://127.0.0.1:3306/wms?serverTimezone=Asia/Shanghai&useSSL=false&useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&autoReconnect=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: root
# password: root
password: test123$
# PostgreSQL 配置
# url: jdbc:p6spy:mysql://192.168.2.30:${DB_PORT:3306}/continew?serverTimezone=Asia/Shanghai&useSSL=true&useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&autoReconnect=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
# username: ${DB_USER:root}
# password: ${DB_PWD:SQLsql123}
# url: jdbc:p6spy:mysql://81.68.71.142:${DB_PORT:3306}/continew?serverTimezone=Asia/Shanghai&useSSL=true&useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&autoReconnect=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
# username: ${DB_USER:root}
# password: ${DB_PWD:MYsql12@}
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
# Hikari 连接池配置
hikari:
# 最大连接数量(默认 10根据实际环境调整
# 注意:当连接达到上限,并且没有空闲连接可用时,获取连接将在超时前阻塞最多 connectionTimeout 毫秒
maximum-pool-size: 20
# 获取连接超时时间(默认 30000 毫秒30 秒)
connection-timeout: 30000
# 空闲连接最大存活时间(默认 600000 毫秒10 分钟)
idle-timeout: 600000
# 保持连接活动的频率,以防止它被数据库或网络基础设施超时。该值必须小于 maxLifetime默认 0禁用
keepaliveTime: 30000
# 连接最大生存时间(默认 1800000 毫秒30 分钟)
max-lifetime: 1800000
## Liquibase 配置
spring.liquibase:
# 是否启用
@@ -64,7 +60,7 @@ spring.data:
# 端口(默认 6379
port: ${REDIS_PORT:6379}
# 密码(未设置密码时请注释掉)
password: ${REDIS_PWD:food}
# password: ${REDIS_PWD:redis2025}
# 数据库索引
database: ${REDIS_DB:0}
# 连接超时时间
@@ -157,12 +153,7 @@ logging:
continew-starter.web.cors:
enabled: true
# 配置允许跨域的域名
allowed-origins:
- ${project.url}
- http://127.0.0.1:80
- http://192.168.40.56:80
- http://10.126.126.3:80
- http://localhost:5173
allowed-origins: '*'
# 配置允许跨域的请求方式
allowed-methods: '*'
# 配置允许跨域的请求头