Compare commits

...

76 Commits

Author SHA1 Message Date
liutao 3984fbe953 增加昨日的数据对比 4 days ago
liutao ab4d198ee2 能耗实体类 5 days ago
liutao 8546d1e67e 能源概览接口 5 days ago
HuangHuiKang 8fcf74187b feat:新增打印模板相关接口 6 days ago
HuangHuiKang 4b08408511 feat:优化app概况接口 7 days ago
HuangHuiKang 13183a6a2a feat:添加app质量概况接口 1 week ago
HuangHuiKang 1ea54b1f57 fix:修改产能报表 1 week ago
HuangHuiKang a7863b39b5 feat:添加产能报表相关接口 1 week ago
HuangHuiKang dbc47aa249 fix:优化产能时间 1 week ago
liutao 0af3e8757f Merge remote-tracking branch 'origin/main' 1 week ago
liutao 9585c9eb96 优化代码 1 week ago
liutao 719cfb797e 设备运行总览 1 week ago
liutao b85e6e7360 设备运行概览接口 2 weeks ago
HuangHuiKang 380a4a3bd1 fix:修改prod配置文件 2 weeks ago
liutao 5c1055b821 Merge remote-tracking branch 'origin/main' 2 weeks ago
HuangHuiKang 000aa526e8 fix:修改采集设备产能 2 weeks ago
HuangHuiKang 4dc54fcbc8 fix:添加报工产能回显 2 weeks ago
HuangHuiKang 5ca9c9112a fix:添加报工数、数据采集的产量排产的算法 2 weeks ago
HuangHuiKang 999dd4f12e Merge remote-tracking branch 'origin/main' into main
# Conflicts:
#	yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/DeviceService.java
#	yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/DeviceServiceImpl.java
3 weeks ago
liutao c40230913f 设备增加图片字段 3 weeks ago
必硕 b84682b9f4 Merge pull request '产品物料信息增加编码搜索条件' (#1) from ck into main
Reviewed-on: #1
3 weeks ago
ck-chenkang 564726280b 产品物料信息增加编码搜索条件 3 weeks ago
liutao a9a910ed8f 防止key为null的情况 3 weeks ago
liutao 77320d3da3 历史记录查询接口 3 weeks ago
HuangHuiKang b67ff2879c fix:优化采集设备分页查询接口 4 weeks ago
HuangHuiKang fcc3cf46c0 feat:新增库区和库位页面 4 weeks ago
HuangHuiKang ec455718f1 fix:app扫码查询相关接口添加编码过滤条件 4 weeks ago
HuangHuiKang c2ec3f0dbf fix:优化app统计报表查询速度 4 weeks ago
liutao 00f5b71f27 Merge remote-tracking branch 'origin/main' 4 weeks ago
liutao d85744aba4 增加单设备监控的查询接口 4 weeks ago
HuangHuiKang 728121dd77 fix:修复已知问题,添加修改计算损耗率。 4 weeks ago
liutao 15dc437e4e 增加查询采集设备的接口 4 weeks ago
HuangHuiKang 09a2c8458c fix:修复已知问题,修改添加检验模板关联产品 4 weeks ago
HuangHuiKang e6197fd60a fix:修复已知问题 4 weeks ago
HuangHuiKang 92feeb7f84 fix:修改生产整体概况返回 1 month ago
HuangHuiKang a8fb7cd262 feat:完成生产计划报表相关接口 1 month ago
HuangHuiKang ead8061756 feat:完成app统计报表 1 month ago
HuangHuiKang 6923984f8f feat:完成app统计报表 1 month ago
HuangHuiKang 29567d00af fix:修改redis 1 month ago
HuangHuiKang b31e3ede4f fix:产线列表返回采集设备名称 1 month ago
HuangHuiKang a6031a0c30 fix:1、修改生产计划入库时可选仓库。2、修改产线只能选择一对一的采集设备。 1 month ago
HuangHuiKang f804a95f24 fix:添加计划状态 1 month ago
HuangHuiKang 6d651523c3 fix:修改时间返回格式 1 month ago
HuangHuiKang a1db78fd3d fix:添加app-设备概况接口 1 month ago
HuangHuiKang c2bde1b2b9 fix:添加app-生产概况-任务统计 1 month ago
HuangHuiKang 7616b34052 fix:添加app-生产概况-产品时间筛选 1 month ago
HuangHuiKang 6185639d4a Merge remote-tracking branch 'origin/main' into main 1 month ago
liutao 90e5cd0654 去掉多余的规格型号 1 month ago
HuangHuiKang 0e54bd9035 feat:添加甘特图计划状态字段 1 month ago
HuangHuiKang dee985829f feat:报工记录添加勾选导出 1 month ago
HuangHuiKang 6030506c8b feat:添加app-首页报表-生产概况-产品统计 1 month ago
HuangHuiKang 5dd2d7fa59 feat:添加报工记录页面及修改甘特图返回 1 month ago
HuangHuiKang 4935872568 fix:修复任务单状态问题 1 month ago
liutao 75408b486b 增加查询条件 1 month ago
HuangHuiKang 5ab15ccca2 fix:修改任务单相关状态 1 month ago
HuangHuiKang 50a0b97572 fix:添加甘特图返回字段,修改bom物料信息取消合并 1 month ago
HuangHuiKang d4d3ad4f57 fix:修改物料信息单位限制 1 month ago
HuangHuiKang f5be8bc03a feat:生成甘特图添加生产时间安排以及是否跳过节假日条件 1 month ago
HuangHuiKang b19632ab32 fix:修改添加生产计划-已完工状态 1 month ago
HuangHuiKang c465299f08 feat:排产任务单汇总明细列表展示编辑关联设备 1 month ago
liutao 1a389d8df3 Merge remote-tracking branch 'origin/main' 1 month ago
liutao bf213b6da5 修改字段类型 1 month ago
HuangHuiKang 70936e690d feat:新增一件排产及甘特图功能模块 1 month ago
liutao bc85d4e924 导入功能实体 1 month ago
liutao 24f11f4deb Merge remote-tracking branch 'origin/main' 1 month ago
liutao e99d6e36c0 关键件增加图片上传 1 month ago
HuangHuiKang a86d70c0a6 feat:新增数据采集产能 1 month ago
liutao 5b7456c50a 实体类增加字段 1 month ago
HuangHuiKang 977a16e6c9 feat:新增排产功能模块相关字段,修改新增计划接口 2 months ago
liutao bc9159c1ac 大屏查询接口无携带租户编号 2 months ago
liutao 04cc023b4f 查询大屏接口取消拦截 2 months ago
HuangHuiKang 835fa5b271 fix:新增点位添加限制 2 months ago
HuangHuiKang 1b90a076fe feat:修改采集设备点位删除逻辑 2 months ago
liutao 0bbac34d67 Merge branch 'liutao_branch' 2 months ago
HuangHuiKang 9c46da356f feat:prod配置文件 2 months ago
HuangHuiKang 00681c954e feat:新增生成二维码功能 2 months ago

@ -70,10 +70,13 @@
<netty.version>4.1.113.Final</netty.version> <netty.version>4.1.113.Final</netty.version>
<mqtt.version>1.2.5</mqtt.version> <mqtt.version>1.2.5</mqtt.version>
<opc.version>0.6.9</opc.version> <opc.version>0.6.9</opc.version>
<qrcode.version>3.5.3</qrcode.version>
<!-- 三方云服务相关 --> <!-- 三方云服务相关 -->
<commons-io.version>2.17.0</commons-io.version> <commons-io.version>2.17.0</commons-io.version>
<commons-compress.version>1.27.1</commons-compress.version> <commons-compress.version>1.27.1</commons-compress.version>
<aws-java-sdk-s3.version>1.12.777</aws-java-sdk-s3.version> <aws-java-sdk-s3.version>1.12.777</aws-java-sdk-s3.version>
<s3.version>2.41.33</s3.version>
<justauth.version>1.0.8</justauth.version> <justauth.version>1.0.8</justauth.version>
<jimureport.version>1.7.8</jimureport.version> <jimureport.version>1.7.8</jimureport.version>
<weixin-java.version>4.6.0</weixin-java.version> <weixin-java.version>4.6.0</weixin-java.version>
@ -589,6 +592,17 @@
<version>${aws-java-sdk-s3.version}</version> <version>${aws-java-sdk-s3.version}</version>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>software.amazon.awssdk</groupId>-->
<!-- <artifactId>s3</artifactId>-->
<!-- <version>${s3.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>software.amazon.awssdk</groupId>-->
<!-- <artifactId>sts</artifactId>-->
<!-- <version>${s3.version}</version>-->
<!-- </dependency>-->
<dependency> <dependency>
<groupId>com.xingyuv</groupId> <groupId>com.xingyuv</groupId>
<artifactId>spring-boot-starter-justauth</artifactId> <!-- 社交登陆(例如说,个人微信、企业微信等等) --> <artifactId>spring-boot-starter-justauth</artifactId> <!-- 社交登陆(例如说,个人微信、企业微信等等) -->
@ -648,6 +662,16 @@
<artifactId>logback-classic</artifactId> <artifactId>logback-classic</artifactId>
<version>${logback.version}</version> <version>${logback.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>${qrcode.version}</version>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>${qrcode.version}</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>

@ -35,7 +35,7 @@ public interface GlobalErrorCodeConstants {
// ========== 自定义错误段 ========== // ========== 自定义错误段 ==========
ErrorCode REPEATED_REQUESTS = new ErrorCode(900, "重复请求,请稍后重试"); // 重复请求 ErrorCode REPEATED_REQUESTS = new ErrorCode(900, "重复请求,请稍后重试"); // 重复请求
ErrorCode DEMO_DENY = new ErrorCode(901, "演示模式,禁止写操作"); ErrorCode DEMO_DENY = new ErrorCode(901, "演示模式,禁止写操作");
ErrorCode DEVICE_CONTACT_MODEL_NOT_EXISTS = new ErrorCode(902, "查询不到该设备"); ErrorCode DEVICE_CONTACT_MODEL_NOT_EXISTS = new ErrorCode(902, "查询不到该点位");
ErrorCode UNKNOWN = new ErrorCode(999, "未知错误"); ErrorCode UNKNOWN = new ErrorCode(999, "未知错误");

@ -28,9 +28,12 @@ import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import org.springframework.web.multipart.MaxUploadSizeExceededException;
import org.springframework.web.multipart.MultipartException;
import org.springframework.web.servlet.NoHandlerFoundException; import org.springframework.web.servlet.NoHandlerFoundException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException; import javax.validation.ConstraintViolationException;
import javax.validation.ValidationException; import javax.validation.ValidationException;
@ -385,4 +388,90 @@ public class GlobalExceptionHandler {
return null; return null;
} }
/**
*
*/
@ExceptionHandler(MaxUploadSizeExceededException.class)
public CommonResult<String> handleMaxUploadSizeExceededException(
MaxUploadSizeExceededException e,
HttpServletRequest request,
HttpServletResponse response) {
log.error("文件上传大小超出限制: {}", request.getRequestURI(), e);
// 从异常信息中提取实际大小和限制大小
String errorMessage = extractSizeInfo(e);
return CommonResult.error(400,
String.format("文件大小超出限制。%s 请上传小于500MB的文件", errorMessage)
);
}
/**
* Multipart
*/
@ExceptionHandler(MultipartException.class)
public CommonResult<String> handleMultipartException(
MultipartException e,
HttpServletRequest request) {
log.error("文件上传异常: {}", request.getRequestURI(), e);
if (e.getMessage().contains("SizeLimitExceededException")) {
return CommonResult.error(400, "文件大小超出限制请上传小于500MB的文件");
} else if (e.getMessage().contains("FileSizeLimitExceededException")) {
return CommonResult.error(400, "单个文件大小超出限制请上传小于500MB的文件");
} else if (e.getMessage().contains("临时文件夹")) {
return CommonResult.error(400, "临时文件夹不可用,请检查磁盘空间");
}
return CommonResult.error(400, "文件上传失败:" + e.getMessage());
}
/**
*
*/
private String extractSizeInfo(MaxUploadSizeExceededException e) {
String message = e.getMessage();
try {
// 解析异常信息,提取大小数据
if (message.contains("exceeds the configured maximum")) {
// 格式: ... size (367254613) exceeds the configured maximum (104857600)
String sizePart = message.substring(message.indexOf("size (") + 6);
String actualSizeStr = sizePart.substring(0, sizePart.indexOf(")"));
String maxPart = message.substring(message.indexOf("maximum (") + 9);
String maxSizeStr = maxPart.substring(0, maxPart.indexOf(")"));
long actualSize = Long.parseLong(actualSizeStr);
long maxSize = Long.parseLong(maxSizeStr);
return String.format("实际大小: %s, 限制大小: %s",
formatFileSize(actualSize),
formatFileSize(maxSize)
);
}
} catch (Exception ex) {
log.error("解析文件大小信息失败", ex);
}
return "请检查文件大小";
}
/**
*
*/
private String formatFileSize(long size) {
if (size < 1024) {
return size + " B";
} else if (size < 1024 * 1024) {
return String.format("%.2f KB", size / 1024.0);
} else if (size < 1024 * 1024 * 1024) {
return String.format("%.2f MB", size / (1024.0 * 1024.0));
} else {
return String.format("%.2f GB", size / (1024.0 * 1024.0 * 1024.0));
}
}
} }

@ -0,0 +1,16 @@
package cn.iocoder.yudao.module.common.api.mold.enums;
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
/**
* ERP
* <p>
* erp 使 1-030-000-000
*/
public interface ErrorCodeConstants {
// ========== 二维码记录表1-030-100-000 ==========
ErrorCode RECORD_NOT_EXISTS = new ErrorCode(1_003_000_000, "通用二维码记录不存在。");
ErrorCode FAILED_TO_REGENERATE = new ErrorCode(1_003_000_001, "重新生成二维码/条形码错误。");
}

@ -16,6 +16,12 @@
<description>common 模块业务实现</description> <description>common 模块业务实现</description>
<dependencies> <dependencies>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-common</artifactId>
</dependency>
<!-- 模块自身 --> <!-- 模块自身 -->
<dependency> <dependency>
<groupId>cn.iocoder.boot</groupId> <groupId>cn.iocoder.boot</groupId>
@ -56,6 +62,14 @@
<groupId>cn.iocoder.boot</groupId> <groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-excel</artifactId> <artifactId>yudao-spring-boot-starter-excel</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

@ -16,7 +16,7 @@ public class MoldSaveReqVO {
private Long id; private Long id;
@Schema(description = "模具编码", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "模具编码", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "模具编码不能为空") // @NotEmpty(message = "模具编码不能为空")
private String code; private String code;
@Schema(description = "模具名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") @Schema(description = "模具名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")

@ -0,0 +1,122 @@
package cn.iocoder.yudao.module.common.controller.admin.qrcoderecord;
import cn.iocoder.yudao.module.common.controller.admin.qrcoderecord.vo.QrcodeRecordPageReqVO;
import cn.iocoder.yudao.module.common.controller.admin.qrcoderecord.vo.QrcodeRecordRespVO;
import cn.iocoder.yudao.module.common.controller.admin.qrcoderecord.vo.QrcodeRecordSaveReqVO;
import cn.iocoder.yudao.module.common.dal.dataobject.qrcoderecord.QrcodeRecordDO;
import cn.iocoder.yudao.module.common.service.qrcordrecord.QrcodeRecordService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
@Tag(name = "管理后台 - 通用二维码记录")
@RestController
@RequestMapping("/qrcode/record")
@Validated
public class QrcodeRecordController {
@Resource
private QrcodeRecordService qrcodeRecordService;
@PostMapping("/create")
@Operation(summary = "创建通用二维码记录")
@PreAuthorize("@ss.hasPermission('qrcode:record:create')")
public CommonResult<Long> createRecord(@Valid @RequestBody QrcodeRecordSaveReqVO createReqVO) {
return success(qrcodeRecordService.createRecord(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新通用二维码记录")
@PreAuthorize("@ss.hasPermission('qrcode:record:update')")
public CommonResult<Boolean> updateRecord(@Valid @RequestBody QrcodeRecordSaveReqVO updateReqVO) {
qrcodeRecordService.updateRecord(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除通用二维码记录")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('qrcode:record:delete')")
public CommonResult<Boolean> deleteRecord(@RequestParam("id") Long id) {
qrcodeRecordService.deleteRecord(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得通用二维码记录")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('qrcode:record:query')")
public CommonResult<QrcodeRecordRespVO> getRecord(@RequestParam("id") Long id) {
QrcodeRecordDO record = qrcodeRecordService.getRecord(id);
return success(BeanUtils.toBean(record, QrcodeRecordRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得通用二维码记录分页")
@PreAuthorize("@ss.hasPermission('qrcode:record:query')")
public CommonResult<PageResult<QrcodeRecordRespVO>> getRecordPage(@Valid QrcodeRecordPageReqVO pageReqVO) {
PageResult<QrcodeRecordDO> pageResult = qrcodeRecordService.getRecordPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, QrcodeRecordRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出通用二维码记录 Excel")
@PreAuthorize("@ss.hasPermission('qrcode:record:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportRecordExcel(@Valid QrcodeRecordPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<QrcodeRecordDO> list = qrcodeRecordService.getRecordPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "通用二维码记录.xls", "数据", QrcodeRecordRespVO.class,
BeanUtils.toBean(list, QrcodeRecordRespVO.class));
}
//TODO 扫二维码拉起app端,仍需app拉起连接地址。
// @GetMapping(value = "/scan", produces = "text/html;charset=UTF-8")
// @Operation(summary = "扫二维码拉起app端 ")
// @PermitAll
// public void scan(@RequestParam("type") String type,
// @RequestParam("id") Long id,
// @RequestParam(required=false) String code,
// HttpServletResponse response) throws IOException {
// String html = qrcodeRecordService.buildScanTransitHtml(type, id,code);
// response.setContentType("text/html;charset=UTF-8");
// response.getWriter().write(html);
// }
@GetMapping("/scan/resolve-id")
@Operation(summary = "扫二维码返回对应id ")
@PermitAll
public CommonResult<Map<String, Object>> resolveId(@RequestParam String type,
@RequestParam Long id,
@RequestParam String code) {
return success(qrcodeRecordService.resolveScanBizId(type, id, code));
}
}

@ -0,0 +1,59 @@
package cn.iocoder.yudao.module.common.controller.admin.qrcoderecord.vo;
import lombok.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 通用二维码记录分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class QrcodeRecordPageReqVO extends PageParam {
@Schema(description = "业务类型MOLD/PRODUCT/EQUIPMENT/PART/SPARE/WORK_ORDER", example = "2")
private String bizType;
@Schema(description = "业务ID", example = "31277")
private Long bizId;
@Schema(description = "业务编码")
private String bizCode;
@Schema(description = "二维码场景DETAIL/LABEL/TRACE")
private String qrScene;
@Schema(description = "二维码内容(扫码入口地址)")
private String qrContent;
@Schema(description = "二维码文件名", example = "芋艿")
private String fileName;
@Schema(description = "MinIO bucket名称", example = "王五")
private String bucketName;
@Schema(description = "MinIO对象路径", example = "赵六")
private String objectName;
@Schema(description = "二维码图片访问地址", example = "https://www.iocoder.cn")
private String qrcodeFileUrl;
@Schema(description = "文件MIME类型", example = "1")
private String mimeType;
@Schema(description = "文件大小(字节)")
private Long fileSize;
@Schema(description = "状态1-有效 0-失效", example = "1")
private Integer status;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "QR(二维码)/BARCODE(条形码)", example = "")
private String codeType;
}

@ -0,0 +1,73 @@
package cn.iocoder.yudao.module.common.controller.admin.qrcoderecord.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 通用二维码记录 Response VO")
@Data
@ExcelIgnoreUnannotated
public class QrcodeRecordRespVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "28938")
@ExcelProperty("主键ID")
private Long id;
@Schema(description = "业务类型MOLD/PRODUCT/EQUIPMENT/PART/SPARE/WORK_ORDER", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@ExcelProperty("业务类型MOLD/PRODUCT/EQUIPMENT/PART/SPARE/WORK_ORDER")
private String bizType;
@Schema(description = "业务ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "31277")
@ExcelProperty("业务ID")
private Long bizId;
@Schema(description = "业务编码")
@ExcelProperty("业务编码")
private String bizCode;
@Schema(description = "二维码场景DETAIL/LABEL/TRACE", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("二维码场景DETAIL/LABEL/TRACE")
private String qrScene;
@Schema(description = "二维码内容(扫码入口地址)", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("二维码内容(扫码入口地址)")
private String qrContent;
@Schema(description = "二维码文件名", example = "芋艿")
@ExcelProperty("二维码文件名")
private String fileName;
@Schema(description = "MinIO bucket名称", example = "王五")
@ExcelProperty("MinIO bucket名称")
private String bucketName;
@Schema(description = "MinIO对象路径", example = "赵六")
@ExcelProperty("MinIO对象路径")
private String objectName;
@Schema(description = "二维码图片访问地址", example = "https://www.iocoder.cn")
@ExcelProperty("二维码图片访问地址")
private String qrcodeFileUrl;
@Schema(description = "文件MIME类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@ExcelProperty("文件MIME类型")
private String mimeType;
@Schema(description = "文件大小(字节)")
@ExcelProperty("文件大小(字节)")
private Long fileSize;
@Schema(description = "状态1-有效 0-失效", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@ExcelProperty("状态1-有效 0-失效")
private Integer status;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "QR(二维码)/BARCODE(条形码)", example = "")
private String codeType;
}

@ -0,0 +1,61 @@
package cn.iocoder.yudao.module.common.controller.admin.qrcoderecord.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 通用二维码记录新增/修改 Request VO")
@Data
public class QrcodeRecordSaveReqVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "28938")
private Long id;
@Schema(description = "业务类型MOLD/PRODUCT/EQUIPMENT/PART/SPARE/WORK_ORDER", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotEmpty(message = "业务类型MOLD/PRODUCT/EQUIPMENT/PART/SPARE/WORK_ORDER不能为空")
private String bizType;
@Schema(description = "业务ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "31277")
@NotNull(message = "业务ID不能为空")
private Long bizId;
@Schema(description = "业务编码")
private String bizCode;
@Schema(description = "二维码场景DETAIL/LABEL/TRACE", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "二维码场景DETAIL/LABEL/TRACE不能为空")
private String qrScene;
@Schema(description = "二维码内容(扫码入口地址)", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "二维码内容(扫码入口地址)不能为空")
private String qrContent;
@Schema(description = "二维码文件名", example = "芋艿")
private String fileName;
@Schema(description = "MinIO bucket名称", example = "王五")
private String bucketName;
@Schema(description = "MinIO对象路径", example = "赵六")
private String objectName;
@Schema(description = "二维码图片访问地址", example = "https://www.iocoder.cn")
private String qrcodeFileUrl;
@Schema(description = "文件MIME类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotEmpty(message = "文件MIME类型不能为空")
private String mimeType;
@Schema(description = "文件大小(字节)")
private Long fileSize;
@Schema(description = "状态1-有效 0-失效", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "状态1-有效 0-失效不能为空")
private Integer status;
@Schema(description = "QR(二维码)/BARCODE(条形码)", example = "")
private String codeType;
}

@ -113,4 +113,16 @@ public class MoldDO extends BaseDO {
@TableField(exist = false) @TableField(exist = false)
private String moldType; private String moldType;
/**
*
*/
@TableField(exist = false)
private String qrcodeUrl;
/**
*
*/
@TableField(exist = false)
private String templateJson;
} }

@ -0,0 +1,81 @@
package cn.iocoder.yudao.module.common.dal.dataobject.qrcoderecord;
import lombok.*;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* DO
*
* @author
*/
@TableName("qrcode_record")
@KeySequence("qrcode_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class QrcodeRecordDO extends BaseDO {
/**
* ID
*/
@TableId
private Long id;
/**
* MOLD/PRODUCT/EQUIPMENT/PART/SPARE/WORK_ORDER
*/
private String bizType;
/**
* ID
*/
private Long bizId;
/**
*
*/
private String bizCode;
/**
* DETAIL/LABEL/TRACE
*/
private String qrScene;
/**
*
*/
private String qrContent;
/**
*
*/
private String fileName;
/**
* MinIO bucket
*/
private String bucketName;
/**
* MinIO
*/
private String objectName;
/**
* 访
*/
private String qrcodeFileUrl;
/**
* MIME
*/
private String mimeType;
/**
*
*/
private Long fileSize;
/**
* 1- 0-
*/
private Integer status;
/**
* QR()/BARCODE()
*/
private String codeType;
}

@ -78,4 +78,6 @@ public interface MoldMapper extends BaseMapperX<MoldDO> {
.eq(MoldDO::getBrandId, brandId) .eq(MoldDO::getBrandId, brandId)
.orderByDesc(MoldDO::getId)); .orderByDesc(MoldDO::getId));
} }
String selectPrintTemplate();
} }

@ -0,0 +1,36 @@
package cn.iocoder.yudao.module.common.dal.mysql.qrcoderecord;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.common.controller.admin.qrcoderecord.vo.QrcodeRecordPageReqVO;
import cn.iocoder.yudao.module.common.dal.dataobject.qrcoderecord.QrcodeRecordDO;
import org.apache.ibatis.annotations.Mapper;
/**
* Mapper
*
* @author
*/
@Mapper
public interface QrcodeRecordMapper extends BaseMapperX<QrcodeRecordDO> {
default PageResult<QrcodeRecordDO> selectPage(QrcodeRecordPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<QrcodeRecordDO>()
.eqIfPresent(QrcodeRecordDO::getBizType, reqVO.getBizType())
.eqIfPresent(QrcodeRecordDO::getBizId, reqVO.getBizId())
.eqIfPresent(QrcodeRecordDO::getBizCode, reqVO.getBizCode())
.eqIfPresent(QrcodeRecordDO::getQrScene, reqVO.getQrScene())
.eqIfPresent(QrcodeRecordDO::getQrContent, reqVO.getQrContent())
.likeIfPresent(QrcodeRecordDO::getFileName, reqVO.getFileName())
.likeIfPresent(QrcodeRecordDO::getBucketName, reqVO.getBucketName())
.likeIfPresent(QrcodeRecordDO::getObjectName, reqVO.getObjectName())
.eqIfPresent(QrcodeRecordDO::getQrcodeFileUrl, reqVO.getQrcodeFileUrl())
.eqIfPresent(QrcodeRecordDO::getMimeType, reqVO.getMimeType())
.eqIfPresent(QrcodeRecordDO::getFileSize, reqVO.getFileSize())
.eqIfPresent(QrcodeRecordDO::getStatus, reqVO.getStatus())
.betweenIfPresent(QrcodeRecordDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(QrcodeRecordDO::getId));
}
}

@ -0,0 +1,30 @@
package cn.iocoder.yudao.module.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum CodeTypeEnum {
QR("QR", "二维码"),
BARCODE("BARCODE", "条形码");
private final String code;
private final String desc;
public String getCode() {
return code;
}
public String getDesc() {
return desc;
}
public static CodeTypeEnum fromBarcodeType(Integer barcodeType) {
if (barcodeType == null) {
return null;
}
return Integer.valueOf(1).equals(barcodeType) ? BARCODE : QR;
}
}

@ -0,0 +1,28 @@
package cn.iocoder.yudao.module.common.enums;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum QrcodeBizTypeEnum {
PRODUCT("PRODUCTMATERIAL", "产品物料"),
EQUIPMENT("EQUIPMENT", "设备"),
KEY_PART("KEY_PART", "关键件"),
MOLD("MOLD", "模具"),
SPARE("SPARE", "备件");
private final String code;
private final String name;
public static QrcodeBizTypeEnum of(String code) {
for (QrcodeBizTypeEnum item : values()) {
if (item.code.equalsIgnoreCase(code)) {
return item;
}
}
return null;
}
}

@ -0,0 +1,9 @@
package cn.iocoder.yudao.module.common.handler;
public interface QrcodeBizHandler {
String getBizType();
boolean exists(Long id);
String buildDeepLink(Long id);
String buildH5Path(Long id);
}

@ -0,0 +1,83 @@
package cn.iocoder.yudao.module.common.service.qrcordrecord;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.common.controller.admin.qrcoderecord.vo.QrcodeRecordPageReqVO;
import cn.iocoder.yudao.module.common.controller.admin.qrcoderecord.vo.QrcodeRecordSaveReqVO;
import cn.iocoder.yudao.module.common.dal.dataobject.qrcoderecord.QrcodeRecordDO;
import cn.iocoder.yudao.module.common.enums.CodeTypeEnum;
import cn.iocoder.yudao.module.common.enums.QrcodeBizTypeEnum;
import org.springframework.transaction.annotation.Transactional;
import javax.validation.Valid;
import java.io.UnsupportedEncodingException;
import java.util.Map;
/**
* Service
*
* @author
*/
public interface QrcodeRecordService {
/**
*
*
* @param createReqVO
* @return
*/
Long createRecord(@Valid QrcodeRecordSaveReqVO createReqVO);
/**
*
*
* @param updateReqVO
*/
void updateRecord(@Valid QrcodeRecordSaveReqVO updateReqVO);
/**
*
*
* @param id
*/
void deleteRecord(Long id);
/**
*
*
* @param id
* @return
*/
QrcodeRecordDO getRecord(Long id);
/**
*
*
* @param pageReqVO
* @return
*/
PageResult<QrcodeRecordDO> getRecordPage(QrcodeRecordPageReqVO pageReqVO);
void generateOrRefresh(QrcodeBizTypeEnum bizType, Long bizId, String bizCode, String scene) throws UnsupportedEncodingException;
void generateOrRefreshBarcode(QrcodeBizTypeEnum bizType, Long bizId, String bizCode, String scene) throws UnsupportedEncodingException;
String buildScanTransitHtml(String type, Long id,String code);
String selectQrcodeUrlByIdAndCode(String code, Long id, String code1);
Map<String, Object> resolveScanBizId(String type, Long id, String code);
void deleteByBiz(QrcodeBizTypeEnum bizType, Long bizId);
void regenerateByCodeType(QrcodeBizTypeEnum bizType, Long bizId, String bizCode, String scene, String codeType)
throws UnsupportedEncodingException;
void generateOrRefresh(
QrcodeBizTypeEnum bizType,
Long bizId,
String bizCode,
String scene,
CodeTypeEnum codeType
) throws UnsupportedEncodingException;
}

@ -0,0 +1,605 @@
package cn.iocoder.yudao.module.common.service.qrcordrecord;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.module.common.controller.admin.qrcoderecord.vo.QrcodeRecordPageReqVO;
import cn.iocoder.yudao.module.common.controller.admin.qrcoderecord.vo.QrcodeRecordSaveReqVO;
import cn.iocoder.yudao.module.common.dal.dataobject.qrcoderecord.QrcodeRecordDO;
import cn.iocoder.yudao.module.common.dal.mysql.qrcoderecord.QrcodeRecordMapper;
import cn.iocoder.yudao.module.common.enums.CodeTypeEnum;
import cn.iocoder.yudao.module.common.enums.QrcodeBizTypeEnum;
import cn.iocoder.yudao.module.common.handler.QrcodeBizHandler;
import cn.iocoder.yudao.module.infra.api.file.FileApi;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.common.api.mold.enums.ErrorCodeConstants.RECORD_NOT_EXISTS;
/**
* Service
*
* @author
*/
@Service
@Validated
@Slf4j
public class QrcodeRecordServiceImpl implements QrcodeRecordService {
@Resource
private FileApi fileApi;
@Value("${yudao.qrcode.scan-base-url}")
private String scanBaseUrl;
@Value("${yudao.qrcode.width:300}")
private Integer width;
@Value("${yudao.qrcode.height:300}")
private Integer height;
@Value("${yudao.qrcode.default-bucket:common-qrcode}")
private String defaultBucket;
@Value("${yudao.qrcode.fail-url}")
private String failUrl;
@Value("${yudao.qrcode.scan-base-url}")
private String serverBaseUrl;
@Value("#{${yudao.qrcode.buckets:{}}}")
private Map<String, String> bucketMap = new HashMap<>();
@Resource
private QrcodeRecordMapper qrcodeRecordMapper;
private final Map<String, QrcodeBizHandler> handlerMap;
public QrcodeRecordServiceImpl(List<QrcodeBizHandler> handlers) {
this.handlerMap = handlers.stream()
.collect(Collectors.toMap(h -> h.getBizType().toUpperCase(), h -> h));
}
@Override
public Long createRecord(QrcodeRecordSaveReqVO createReqVO) {
// 插入
QrcodeRecordDO record = BeanUtils.toBean(createReqVO, QrcodeRecordDO.class);
qrcodeRecordMapper.insert(record);
// 返回
return record.getId();
}
@Override
public void updateRecord(QrcodeRecordSaveReqVO updateReqVO) {
// 校验存在
validateRecordExists(updateReqVO.getId());
// 更新
QrcodeRecordDO updateObj = BeanUtils.toBean(updateReqVO, QrcodeRecordDO.class);
qrcodeRecordMapper.updateById(updateObj);
}
@Override
public void deleteRecord(Long id) {
// 校验存在
validateRecordExists(id);
// 删除
qrcodeRecordMapper.deleteById(id);
}
private void validateRecordExists(Long id) {
if (qrcodeRecordMapper.selectById(id) == null) {
throw exception(RECORD_NOT_EXISTS);
}
}
@Override
public QrcodeRecordDO getRecord(Long id) {
return qrcodeRecordMapper.selectById(id);
}
@Override
public PageResult<QrcodeRecordDO> getRecordPage(QrcodeRecordPageReqVO pageReqVO) {
return qrcodeRecordMapper.selectPage(pageReqVO);
}
@Override
public void generateOrRefresh(QrcodeBizTypeEnum bizType, Long bizId, String bizCode, String scene) throws UnsupportedEncodingException {
if (bizType == null || bizId == null) {
throw new IllegalArgumentException("bizType 或 bizId 不能为空");
}
String qrScene = StrUtil.blankToDefault(scene, "DETAIL");
// 1. 幂等查询biz_type + biz_id + scene 唯一)
QrcodeRecordDO existed = qrcodeRecordMapper.selectOne(
new LambdaQueryWrapper<QrcodeRecordDO>()
.eq(QrcodeRecordDO::getBizType, bizType.getCode())
.eq(QrcodeRecordDO::getBizId, bizId)
.eq(QrcodeRecordDO::getBizCode,bizCode)
.eq(QrcodeRecordDO::getCodeType,"QR")
.eq(QrcodeRecordDO::getQrScene, qrScene)
.last("limit 1")
);
// 2. 组装二维码内容(统一扫码入口)
// String qrContent = "{\"type\":\"" + bizType.getCode()
// + "\",\"id\":" + bizId
// + (StrUtil.isNotBlank(bizCode) ? ",\"code\":\"" + bizCode + "\"" : "")
// + "}";
String qrContent = bizType.getCode() + "-" + bizId;
// 3. 生成二维码PNG
byte[] pngBytes = buildQrPng(qrContent, width, height);
// 4. 选择bucket + objectName
String bucket = resolveBucket(bizType); // 例如 yudao.qrcode.buckets.mold
String objectName = bizType.getCode().toLowerCase() + "/qr/" + LocalDate.now() + "/" + bizId + ".png";
String fileName = bizType.getCode().toLowerCase() + "_" + bizCode + ".png";
// 5. 上传文件(按你项目 FileApi 实际签名改)
// 如果支持bucket参数用这个
// FileRespDTO file = fileApi.createFile(bucket, objectName, "image/png", pngBytes);
// 默认上传
Map<String, String> file = fileApi.createFile(fileName, objectName, pngBytes);
String fileUrl = file.get("fileUrl");
// 6. upsert 记录
QrcodeRecordDO record = new QrcodeRecordDO();
record.setBizType(bizType.getCode());
record.setBizId(bizId);
record.setBizCode(bizCode);
record.setQrScene(qrScene);
record.setQrContent(qrContent);
record.setFileName(fileName);
record.setBucketName(bucket);
record.setObjectName(objectName);
record.setQrcodeFileUrl(fileUrl);
record.setMimeType("image/png");
record.setFileSize((long) pngBytes.length);
record.setStatus(1);
if (existed == null) {
qrcodeRecordMapper.insert(record);
} else {
record.setId(existed.getId());
qrcodeRecordMapper.updateById(record);
}
}
@Override
// @Transactional(rollbackFor = Exception.class)
public void generateOrRefreshBarcode(QrcodeBizTypeEnum bizType, Long bizId, String bizCode, String scene) throws UnsupportedEncodingException {
if (bizType == null || bizId == null) {
throw new IllegalArgumentException("bizType 或 bizId 不能为空");
}
String qrScene = StrUtil.blankToDefault(scene, "DETAIL");
QrcodeRecordDO existed = qrcodeRecordMapper.selectOne(
new LambdaQueryWrapper<QrcodeRecordDO>()
.eq(QrcodeRecordDO::getBizType, bizType.getCode())
.eq(QrcodeRecordDO::getBizId, bizId)
.eq(QrcodeRecordDO::getBizCode, bizCode)
.eq(QrcodeRecordDO::getCodeType, "BARCODE")
.eq(QrcodeRecordDO::getQrScene, qrScene)
.last("limit 1")
);
// String barcodeContent = "{\"type\":\"" + bizType.getCode()
// + "\",\"id\":" + bizId
// + (StrUtil.isNotBlank(bizCode) ? ",\"code\":\"" + bizCode + "\"" : "")
// + "}";
String barcodeContent = bizType.getCode() + "-" + bizId;
int barcodeWidth = 600;
int barcodeHeight = 180;
byte[] pngBytes = buildBarcodePng(barcodeContent, barcodeWidth, barcodeHeight);
String bucket = resolveBucket(bizType);
String objectName = bizType.getCode().toLowerCase() + "/barcode/" + LocalDate.now() + "/" + bizId + ".png";
String fileName = bizType.getCode().toLowerCase() + "_" + bizCode + "_barcode.png";
Map<String, String> file = fileApi.createFile(fileName, objectName, pngBytes);
String fileUrl = file.get("fileUrl");
QrcodeRecordDO record = new QrcodeRecordDO();
record.setBizType(bizType.getCode());
record.setBizId(bizId);
record.setBizCode(bizCode);
record.setCodeType("BARCODE");
record.setQrScene(qrScene);
record.setQrContent(barcodeContent);
record.setFileName(fileName);
record.setBucketName(bucket);
record.setObjectName(objectName);
record.setQrcodeFileUrl(fileUrl);
record.setMimeType("image/png");
record.setFileSize((long) pngBytes.length);
record.setStatus(1);
if (existed == null) {
qrcodeRecordMapper.insert(record);
} else {
record.setId(existed.getId());
qrcodeRecordMapper.updateById(record);
}
}
private byte[] buildBarcodePng(String content, int width, int height) {
try {
Map<EncodeHintType, Object> hints = new HashMap<>();
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
hints.put(EncodeHintType.MARGIN, 1);
BitMatrix matrix = new MultiFormatWriter().encode(content, BarcodeFormat.CODE_128, width, height, hints);
BufferedImage image = MatrixToImageWriter.toBufferedImage(matrix);
ByteArrayOutputStream os = new ByteArrayOutputStream();
ImageIO.write(image, "png", os);
return os.toByteArray();
} catch (Exception e) {
throw new RuntimeException("生成条形码失败", e);
}
}
@Override
public String buildScanTransitHtml(String type, Long id,String code) {
String fallback = normalizeUrl(StrUtil.blankToDefault(failUrl, "/"));
if (StrUtil.isBlank(type) || id == null) {
return buildRedirectHtml(fallback);
}
if (StrUtil.isBlank(code)) {
return buildRedirectHtml(fallback);
}
QrcodeRecordDO record = qrcodeRecordMapper.selectOne(
new LambdaQueryWrapper<QrcodeRecordDO>()
.eq(QrcodeRecordDO::getBizType, type.trim().toUpperCase())
.eq(QrcodeRecordDO::getBizId, id)
.eq(QrcodeRecordDO::getQrScene, "DETAIL")
.last("limit 1")
);
if (record == null || !StrUtil.equals(record.getBizCode(), code)) {
return buildRedirectHtml(fallback);
}
QrcodeBizHandler handler = handlerMap.get(type.trim().toUpperCase());
if (handler == null) {
return buildRedirectHtml(fallback);
}
try {
if (!handler.exists(id)) {
return buildRedirectHtml(fallback);
}
String target = StrUtil.blankToDefault(handler.buildDeepLink(id), handler.buildH5Path(id));
if (StrUtil.isBlank(target)) {
return buildRedirectHtml(fallback);
}
return buildRedirectHtml(normalizeUrl(target));
} catch (Exception e) {
return buildRedirectHtml(fallback);
}
}
@Override
public String selectQrcodeUrlByIdAndCode(String bizType, Long bizId, String bizCode) {
if (StrUtil.isBlank(bizType) || bizId == null || StrUtil.isBlank(bizCode)) {
return null;
}
QrcodeRecordDO record = qrcodeRecordMapper.selectOne(Wrappers.<QrcodeRecordDO>lambdaQuery()
.eq(QrcodeRecordDO::getBizType, bizType)
.eq(QrcodeRecordDO::getBizId, bizId)
.eq(QrcodeRecordDO::getBizCode, bizCode)
.eq(QrcodeRecordDO::getStatus, 1)
.last("limit 1"));
if (record == null || StrUtil.isBlank(record.getQrcodeFileUrl())) {
return null;
}
return record.getQrcodeFileUrl();
}
@Override
public Map<String, Object> resolveScanBizId(String type, Long id, String code) {
Map<String, Object> result = new HashMap<>();
if (StrUtil.isBlank(type) || id == null || StrUtil.isBlank(code)) {
return null;
}
QrcodeRecordDO record = qrcodeRecordMapper.selectOne(
new LambdaQueryWrapper<QrcodeRecordDO>()
.eq(QrcodeRecordDO::getBizType, type)
.eq(QrcodeRecordDO::getBizId, id)
.eq(QrcodeRecordDO::getBizCode,code)
.eq(QrcodeRecordDO::getQrScene, "DETAIL")
.last("limit 1")
);
if (record == null) {
return null;
}
QrcodeBizHandler handler = handlerMap.get(type.trim().toUpperCase());
if (handler == null) {
return null;
}
result.put("type", type);
result.put("id", id);
return result;
}
private String normalizeUrl(String url) {
if (StrUtil.isBlank(url)) {
return "/";
}
if (StrUtil.startWithAny(url, "http://", "https://", "besure://")) {
return url;
}
String base = StrUtil.blankToDefault(serverBaseUrl, "");
if (StrUtil.isBlank(base)) {
return url.startsWith("/") ? url : "/" + url;
}
return StrUtil.removeSuffix(base, "/") + "/" + StrUtil.removePrefix(url, "/");
}
private String buildRedirectHtml(String targetUrl) {
String safe = escapeHtml(StrUtil.blankToDefault(targetUrl, "/"));
return "<!doctype html><html><head><meta charset=\"UTF-8\">"
+ "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">"
+ "<meta http-equiv=\"Cache-Control\" content=\"no-store, no-cache, must-revalidate, max-age=0\">"
+ "<meta http-equiv=\"Pragma\" content=\"no-cache\">"
+ "<meta http-equiv=\"Expires\" content=\"0\">"
+ "<title>跳转中...</title></head><body>"
+ "<script>window.location.replace('" + safe + "');</script>"
+ "<noscript><a href=\"" + safe + "\">点击继续</a></noscript>"
+ "</body></html>";
}
private String escapeHtml(String s) {
return s.replace("&", "&amp;")
.replace("<", "&lt;")
.replace(">", "&gt;")
.replace("\"", "&quot;")
.replace("'", "&#39;");
}
private String resolveBucket(QrcodeBizTypeEnum bizType) {
if (bizType == null) {
return defaultBucket;
}
if (bucketMap == null || bucketMap.isEmpty()) {
return defaultBucket;
}
String bucket = bucketMap.get(bizType.getCode().toLowerCase());
return StrUtil.blankToDefault(bucket, defaultBucket);
}
private byte[] buildQrPng(String content, int width, int height) {
try {
Map<EncodeHintType, Object> hints = new HashMap<>();
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
hints.put(EncodeHintType.MARGIN, 1);
BitMatrix matrix = new MultiFormatWriter()
.encode(content, BarcodeFormat.QR_CODE, width, height, hints);
BufferedImage image = MatrixToImageWriter.toBufferedImage(matrix);
ByteArrayOutputStream os = new ByteArrayOutputStream();
ImageIO.write(image, "png", os);
return os.toByteArray();
} catch (Exception e) {
throw new RuntimeException("生成二维码失败", e);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteByBiz(QrcodeBizTypeEnum bizType, Long bizId) {
if (bizType == null || bizId == null) {
return;
}
List<QrcodeRecordDO> records = qrcodeRecordMapper.selectList(
Wrappers.<QrcodeRecordDO>lambdaQuery()
.eq(QrcodeRecordDO::getBizType, bizType.getCode())
.eq(QrcodeRecordDO::getBizId, bizId)
);
if (records == null || records.isEmpty()) {
return;
}
for (QrcodeRecordDO record : records) {
try {
String objectName = record.getObjectName();
if (StrUtil.isBlank(objectName)) {
continue;
}
// 通过 path(objectName) 找到 infra_file
Long id = fileApi.getFileByPath(objectName);
if (id == null) {
// 可选log.warn("未找到文件记录, qrcodeId={}, path={}", record.getId(), objectName);
continue;
}
// 用文件主键删除(会删存储+删infra_file记录
fileApi.deleteFile(id);
} catch (Exception e) {
// 你可按策略选择:继续 or 抛异常回滚
// 建议先打日志
log.warn("删除文件失败, qrcodeId={}, path={}", record.getId(), record.getObjectName(), e);
}
}
qrcodeRecordMapper.delete(
Wrappers.<QrcodeRecordDO>lambdaQuery()
.eq(QrcodeRecordDO::getBizType, bizType.getCode())
.eq(QrcodeRecordDO::getBizId, bizId)
);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void regenerateByCodeType(QrcodeBizTypeEnum bizType, Long bizId, String bizCode, String scene, String codeType)
throws UnsupportedEncodingException {
if (bizType == null || bizId == null) {
throw new IllegalArgumentException("bizType 或 bizId 不能为空");
}
String qrScene = StrUtil.blankToDefault(scene, "DETAIL");
String normalizedCodeType = StrUtil.blankToDefault(codeType, "QR").trim().toUpperCase();
if (!StrUtil.equalsAny(normalizedCodeType, "QR", "BARCODE")) {
throw new IllegalArgumentException("codeType 仅支持 QR 或 BARCODE");
}
// 1. 按业务唯一键 + 码类型查询
QrcodeRecordDO existed = qrcodeRecordMapper.selectOne(
new LambdaQueryWrapper<QrcodeRecordDO>()
.eq(QrcodeRecordDO::getBizType, bizType.getCode())
.eq(QrcodeRecordDO::getBizId, bizId)
.eq(QrcodeRecordDO::getBizCode, bizCode)
// .eq(QrcodeRecordDO::getCodeType, normalizedCodeType)
.eq(QrcodeRecordDO::getQrScene, qrScene)
.last("limit 1")
);
// 2. 组装内容
// String content = "{\"type\":\"" + bizType.getCode()
// + "\",\"id\":" + bizId
// + (StrUtil.isNotBlank(bizCode) ? ",\"code\":\"" + bizCode + "\"" : "")
// + "}";
String content = bizType.getCode() + "-" + bizId;
// 3. 生成图片(按类型)
byte[] pngBytes;
String objectDir;
String fileNameSuffix;
if (StrUtil.equals(normalizedCodeType, "BARCODE")) {
pngBytes = buildBarcodePng(content, 600, 180);
objectDir = "barcode";
fileNameSuffix = "_barcode.png";
} else {
pngBytes = buildQrPng(content, width, height);
objectDir = "qr";
fileNameSuffix = ".png";
}
// 4. 组织文件信息
String bucket = resolveBucket(bizType);
String objectName = bizType.getCode().toLowerCase() + "/" + objectDir + "/" + LocalDate.now() + "/" + bizId + ".png";
String fileName = bizType.getCode().toLowerCase() + "_" + StrUtil.blankToDefault(bizCode, String.valueOf(bizId)) + fileNameSuffix;
// 5. 如果已存在先删旧文件MinIO + infra_file
if (existed != null && StrUtil.isNotBlank(existed.getObjectName())) {
try {
Long fileId = fileApi.getFileByPath(existed.getObjectName());
if (fileId != null) {
fileApi.deleteFile(fileId);
}
} catch (Exception e) {
log.warn("删除旧二维码/条形码文件失败, qrcodeId={}, path={}", existed.getId(), existed.getObjectName(), e);
}
}
// 6. 上传新文件
Map<String, String> file = fileApi.createFile(fileName, objectName, pngBytes);
String fileUrl = file.get("fileUrl");
// 7. upsert 记录
QrcodeRecordDO record = new QrcodeRecordDO();
record.setBizType(bizType.getCode());
record.setBizId(bizId);
record.setBizCode(bizCode);
record.setCodeType(normalizedCodeType);
record.setQrScene(qrScene);
record.setQrContent(content);
record.setFileName(fileName);
record.setBucketName(bucket);
record.setObjectName(objectName);
record.setQrcodeFileUrl(fileUrl);
record.setMimeType("image/png");
record.setFileSize((long) pngBytes.length);
record.setStatus(1);
if (existed == null) {
qrcodeRecordMapper.insert(record);
} else {
record.setId(existed.getId());
qrcodeRecordMapper.updateById(record);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void generateOrRefresh(QrcodeBizTypeEnum bizType,
Long bizId,
String bizCode,
String scene,
CodeTypeEnum codeType) throws UnsupportedEncodingException {
if (codeType == null) {
log.info("codeType为空");
return;
}
if (codeType == CodeTypeEnum.BARCODE) {
generateOrRefreshBarcode(bizType, bizId, bizCode, scene);
} else {
generateOrRefresh(bizType, bizId, bizCode, scene);
}
}
}

@ -8,5 +8,10 @@
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/ 文档可见https://www.iocoder.cn/MyBatis/x-plugins/
--> -->
<select id="selectPrintTemplate" resultType="java.lang.String">
select template_json
from mes_print_template
where deleted = 0
and template_type = 4
</select>
</mapper> </mapper>

@ -16,9 +16,9 @@
mtm.task_time, mtm.task_time,
CONCAT( '(', su.username, ')', su.nickname) as operator CONCAT( '(', su.username, ')', su.nickname) as operator
from from
besure.mes_mold_ticket_results mtr mes_mold_ticket_results mtr
left join besure.mes_mold_ticket_management mtm on mtm.id = mtr.management_id left join mes_mold_ticket_management mtm on mtm.id = mtr.management_id
left join besure.system_users su on mtm.operator = su.id left join system_users su on mtm.operator = su.id
WHERE 1=1 WHERE 1=1
<!-- ID集合过滤 --> <!-- ID集合过滤 -->
<if test="ids != null and ids != ''"> <if test="ids != null and ids != ''">

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.common.dal.mysql.qrcoderecord.QrcodeRecordMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

@ -90,6 +90,12 @@ public interface ErrorCodeConstants {
// ========== ERP 仓库 1-030-400-000 ========== // ========== ERP 仓库 1-030-400-000 ==========
ErrorCode WAREHOUSE_NOT_EXISTS = new ErrorCode(1_030_400_000, "仓库不存在"); ErrorCode WAREHOUSE_NOT_EXISTS = new ErrorCode(1_030_400_000, "仓库不存在");
ErrorCode WAREHOUSE_NOT_ENABLE = new ErrorCode(1_030_400_001, "仓库({})未启用"); ErrorCode WAREHOUSE_NOT_ENABLE = new ErrorCode(1_030_400_001, "仓库({})未启用");
ErrorCode WAREHOUSE_AREA_CODE_EXISTS = new ErrorCode(1_030_400_002, "仓库库区编码不存在");
ErrorCode WAREHOUSE_AREA_DELETE_FAIL_EXISTS_LOCATION = new ErrorCode(1_030_400_003, "仓库库区删除失败,请先删除对应库位信息");
ErrorCode WAREHOUSE_AREA_NOT_EXISTS = new ErrorCode(1_030_400_004, "仓库库区不存在");
ErrorCode WAREHOUSE_LOCATION_CODE_EXISTS = new ErrorCode(1_030_400_005, "库位编码不存在");
ErrorCode WAREHOUSE_LOCATION_NOT_EXISTS = new ErrorCode(1_030_400_006, "库位不存在");
ErrorCode WAREHOUSE_LOCATION_WAREHOUSE_AREA_NOT_MATCH = new ErrorCode(1_030_400_007, "暂无匹配库位信息");
// ========== ERP 其它入库单 1-030-401-000 ========== // ========== ERP 其它入库单 1-030-401-000 ==========
ErrorCode STOCK_IN_NOT_EXISTS = new ErrorCode(1_030_401_000, "其它入库单不存在"); ErrorCode STOCK_IN_NOT_EXISTS = new ErrorCode(1_030_401_000, "其它入库单不存在");
@ -133,6 +139,11 @@ public interface ErrorCodeConstants {
// ========== ERP 产品 1-030-500-000 ========== // ========== ERP 产品 1-030-500-000 ==========
ErrorCode PRODUCT_NOT_EXISTS = new ErrorCode(1_030_500_000, "产品不存在"); ErrorCode PRODUCT_NOT_EXISTS = new ErrorCode(1_030_500_000, "产品不存在");
ErrorCode PRODUCT_NOT_ENABLE = new ErrorCode(1_030_500_001, "产品({})未启用"); ErrorCode PRODUCT_NOT_ENABLE = new ErrorCode(1_030_500_001, "产品({})未启用");
ErrorCode PRODUCT_CODE_EXISTS = new ErrorCode(1_030_500_002, "产品编码已存在");
ErrorCode PRODUCT_NAME_AND_STANDARD_EXISTS = new ErrorCode(1_030_500_003, "名称+规格已存在且不能重复");
ErrorCode PRODUCT_CODE_NOT_EXISTS = new ErrorCode(1_030_500_004, "产品编码不存在");
ErrorCode PRODUCT_DEVICE_REL_NOT_EXISTS = new ErrorCode(1_030_500_005, "产品-设备关联不存在");
ErrorCode PRODUCT_MOLD_REL_NOT_EXISTS = new ErrorCode(1_030_500_006, "产品-模具关联不存在");
// ========== ERP 产品分类 1-030-501-000 ========== // ========== ERP 产品分类 1-030-501-000 ==========
ErrorCode PRODUCT_CATEGORY_NOT_EXISTS = new ErrorCode(1_030_501_000, "产品分类不存在"); ErrorCode PRODUCT_CATEGORY_NOT_EXISTS = new ErrorCode(1_030_501_000, "产品分类不存在");

@ -1,5 +1,7 @@
package cn.iocoder.yudao.module.erp.controller.admin.autocode; package cn.iocoder.yudao.module.erp.controller.admin.autocode;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.module.erp.controller.admin.autocode.enums.ErpBarcodeTypeEnum;
import cn.iocoder.yudao.module.erp.controller.admin.autocode.util.AutoCodeUtil; import cn.iocoder.yudao.module.erp.controller.admin.autocode.util.AutoCodeUtil;
import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.Parameters;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -91,6 +93,16 @@ public class AutocodeRuleController {
HttpServletResponse response) throws IOException { HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<AutocodeRuleDO> list = autocodeRuleService.getAutocodeRulePage(pageReqVO).getList(); List<AutocodeRuleDO> list = autocodeRuleService.getAutocodeRulePage(pageReqVO).getList();
List<AutocodeRuleRespVO> autocodeRuleRespVOS = BeanUtils.toBean(list, AutocodeRuleRespVO.class);
if (CollUtil.isNotEmpty(autocodeRuleRespVOS)) {
for (AutocodeRuleRespVO respVO : autocodeRuleRespVOS) {
if (respVO.getBarcodeType()!=null){
respVO.setBarcodeTypeName(ErpBarcodeTypeEnum.getDescByType(respVO.getBarcodeType()));
}
}
}
// 导出 Excel // 导出 Excel
ExcelUtils.write(response, "编码规则.xls", "数据", AutocodeRuleRespVO.class, ExcelUtils.write(response, "编码规则.xls", "数据", AutocodeRuleRespVO.class,
BeanUtils.toBean(list, AutocodeRuleRespVO.class)); BeanUtils.toBean(list, AutocodeRuleRespVO.class));

@ -0,0 +1,40 @@
package cn.iocoder.yudao.module.erp.controller.admin.autocode.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
/**
* /
*/
@Getter
@AllArgsConstructor
public enum ErpBarcodeTypeEnum {
BARCODE(1, "条形码"),
QRCODE(2, "二维码"),
BOTH(3, "条形码+二维码");
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ErpBarcodeTypeEnum::getType).toArray();
private final Integer type;
private final String desc;
/**
*
*/
public static String getDescByType(Integer type) {
if (type == null) {
return "";
}
for (ErpBarcodeTypeEnum value : values()) {
if (value.getType().equals(type)) {
return value.getDesc();
}
}
return "未知";
}
}

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.erp.controller.admin.autocode.util;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
import cn.iocoder.yudao.module.common.enums.CodeTypeEnum;
import cn.iocoder.yudao.module.erp.controller.admin.autocode.vo.AutocodeRecordSaveReqVO; import cn.iocoder.yudao.module.erp.controller.admin.autocode.vo.AutocodeRecordSaveReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.autocode.AutocodePartDO; import cn.iocoder.yudao.module.erp.dal.dataobject.autocode.AutocodePartDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.autocode.AutocodeRecordDO; import cn.iocoder.yudao.module.erp.dal.dataobject.autocode.AutocodeRecordDO;
@ -184,4 +185,14 @@ public class AutoCodeUtil {
return autoCode; return autoCode;
} }
public CodeTypeEnum queryCodeType(String ruleCode) {
AutocodeRuleDO rule = iAutoCodeRuleService.getAutocodeRuleByRuleCode(ruleCode);
if (rule == null) {
return null;
}
return CodeTypeEnum.fromBarcodeType(rule.getBarcodeType());
}
} }

@ -46,4 +46,7 @@ public class AutocodeRulePageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime; private LocalDateTime[] createTime;
@Schema(description = "码类型条形码-1 二维码-2", example = "")
private Integer barcodeType;
} }

@ -27,6 +27,13 @@ public class AutocodeRuleRespVO {
@ExcelProperty("规则名称") @ExcelProperty("规则名称")
private String ruleName; private String ruleName;
@Schema(description = "码类型条形码-1 二维码-2", example = "")
private Integer barcodeType;
@Schema(description = "码类型", example = "")
@ExcelProperty("码类型")
private String barcodeTypeName;
@Schema(description = "描述") @Schema(description = "描述")
@ExcelProperty("描述") @ExcelProperty("描述")
private String ruleDesc; private String ruleDesc;

@ -45,4 +45,8 @@ public class AutocodeRuleSaveReqVO {
@Schema(description = "编码规则组成列表") @Schema(description = "编码规则组成列表")
private List<AutocodePartDO> autocodeParts; private List<AutocodePartDO> autocodeParts;
@Schema(description = "码类型条形码-1 二维码-2", example = "")
private Integer barcodeType;
} }

@ -27,6 +27,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List; import java.util.List;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
@ -143,7 +144,7 @@ public class MoldBrandController {
@PostMapping("/mold/create") @PostMapping("/mold/create")
@Operation(summary = "创建模具") @Operation(summary = "创建模具")
@PreAuthorize("@ss.hasPermission('erp:mold-brand:create')") @PreAuthorize("@ss.hasPermission('erp:mold-brand:create')")
public CommonResult<Long> createMold(@Valid @RequestBody MoldSaveReqVO createReqVO) { public CommonResult<Long> createMold(@Valid @RequestBody MoldSaveReqVO createReqVO) throws UnsupportedEncodingException {
return success(moldBrandService.createMold(createReqVO)); return success(moldBrandService.createMold(createReqVO));
} }
@ -166,10 +167,10 @@ public class MoldBrandController {
@GetMapping("/mold/get") @GetMapping("/mold/get")
@Operation(summary = "获得模具") @Operation(summary = "获得模具")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('erp:mold-brand:query')") @PreAuthorize("@ss.hasPermission('erp:mold-brand:query')")
public CommonResult<MoldDO> getMold(@RequestParam("id") Long id) { public CommonResult<MoldDO> getMold(@RequestParam(value = "id", required = false) Long id,
return success(moldBrandService.getMold(id)); @RequestParam(value = "code", required = false) String code) {
return success(moldBrandService.getMold(id, code));
} }
@GetMapping("/mold/export-excel") @GetMapping("/mold/export-excel")
@ -186,6 +187,15 @@ public class MoldBrandController {
ExcelUtils.write(response, "模具.xls", "数据", MoldRespVO.class, list); ExcelUtils.write(response, "模具.xls", "数据", MoldRespVO.class, list);
} }
@PostMapping("/regenerate-code")
public CommonResult<Boolean> regenerateCode(@RequestParam("id") Long id,
@RequestParam("code") String code) throws UnsupportedEncodingException {
moldBrandService.regenerateCode(id, code);
return success(true);
}
// ==================== 子表(模具产品) ==================== // ==================== 子表(模具产品) ====================
@GetMapping("/mold-brand-product/page") @GetMapping("/mold-brand-product/page")

@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.common.dal.dataobject.mold.MoldDO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.category.ErpProductCategoryListReqVO; import cn.iocoder.yudao.module.erp.controller.admin.product.vo.category.ErpProductCategoryListReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.*; import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.*;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductCategoryDO; import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductCategoryDO;
@ -15,6 +16,8 @@ import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductMapper;
import cn.iocoder.yudao.module.erp.framework.bean.ProductTypeEnum; import cn.iocoder.yudao.module.erp.framework.bean.ProductTypeEnum;
import cn.iocoder.yudao.module.erp.service.product.ErpProductCategoryService; import cn.iocoder.yudao.module.erp.service.product.ErpProductCategoryService;
import cn.iocoder.yudao.module.erp.service.product.ErpProductService; import cn.iocoder.yudao.module.erp.service.product.ErpProductService;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.Parameters;
@ -28,14 +31,17 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.MOLD_CODE_DUPLICATE;
@Tag(name = "管理后台 - ERP 产品") @Tag(name = "管理后台 - ERP 产品")
@RestController @RestController
@ -51,18 +57,20 @@ public class ErpProductController {
@PostMapping("/create") @PostMapping("/create")
@Operation(summary = "创建产品") @Operation(summary = "创建产品")
@PreAuthorize("@ss.hasPermission('erp:product:create')") @PreAuthorize("@ss.hasPermission('erp:product:create')")
public CommonResult<Long> createProduct(@Valid @RequestBody ProductSaveReqVO createReqVO) { public CommonResult<Long> createProduct(@Valid @RequestBody ProductSaveReqVO createReqVO) throws UnsupportedEncodingException {
ErpProductPageReqVO productPageReqVO = new ErpProductPageReqVO(); // ErpProductPageReqVO productPageReqVO = new ErpProductPageReqVO();
productPageReqVO.setName(createReqVO.getName()); // productPageReqVO.setName(createReqVO.getName());
productPageReqVO.setStandard(createReqVO.getStandard()); // productPageReqVO.setStandard(createReqVO.getStandard());
if (productMapper.selectProductExist(productPageReqVO)) { // if (productMapper.selectProductExist(productPageReqVO)) {
return error(400,"名称+规格不能重复"); // return error(400,"名称+规格不能重复");
} // }
productPageReqVO = new ErpProductPageReqVO(); // productPageReqVO = new ErpProductPageReqVO();
productPageReqVO.setCode(createReqVO.getBarCode());
if (!productMapper.selectProductCodeExist(productPageReqVO).getList().isEmpty()) { // productPageReqVO.setCode(createReqVO.getBarCode());
return error(400,"编码不能重复"); // if (!productMapper.selectProductCodeExist(productPageReqVO).getList().isEmpty()) {
} // return error(400,"编码不能重复");
// }
return success(productService.createProduct(createReqVO)); return success(productService.createProduct(createReqVO));
} }
@ -96,11 +104,10 @@ public class ErpProductController {
@GetMapping("/get") @GetMapping("/get")
@Operation(summary = "获得产品") @Operation(summary = "获得产品")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('erp:product:query')") @PreAuthorize("@ss.hasPermission('erp:product:query')")
public CommonResult<ErpProductRespVO> getProduct(@RequestParam("id") Long id) { public CommonResult<ErpProductRespVO> getProduct(@RequestParam(value = "id", required = false) Long id,
ErpProductDO product = productService.getProduct(id); @RequestParam(value = "code", required = false) String code) {
return success(BeanUtils.toBean(product, ErpProductRespVO.class)); return success(productService.getProduct(id, code));
} }
@GetMapping("/page") @GetMapping("/page")
@ -231,4 +238,12 @@ public class ErpProductController {
return success(productService.importProductList(list, updateSupport)); return success(productService.importProductList(list, updateSupport));
} }
@PostMapping("/regenerate-code")
public CommonResult<Boolean> regenerateCode(@RequestParam("id") Long id,
@RequestParam("code") String code) throws UnsupportedEncodingException {
productService.regenerateCode(id, code);
return success(true);
// s
}
} }

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.erp.controller.admin.product; package cn.iocoder.yudao.module.erp.controller.admin.product;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
@ -10,26 +11,33 @@ import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitPageReqVO; import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitPageReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitRespVO; import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitRespVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitSaveReqVO; import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitSaveReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitImportExcelVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO; import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO;
import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductUnitMapper; import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductUnitMapper;
import cn.iocoder.yudao.module.erp.service.product.ErpProductUnitService; import cn.iocoder.yudao.module.erp.service.product.ErpProductUnitService;
import cn.iocoder.yudao.module.system.enums.common.SexEnum;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays;
import java.util.List; import java.util.List;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.IMPORT_LIST_IS_EMPTY;
@Tag(name = "管理后台 - ERP 产品单位") @Tag(name = "管理后台 - ERP 产品单位")
@RestController @RestController
@ -92,7 +100,12 @@ public class ErpProductUnitController {
@Operation(summary = "获得产品单位精简列表", description = "只包含被开启的单位,主要用于前端的下拉选项") @Operation(summary = "获得产品单位精简列表", description = "只包含被开启的单位,主要用于前端的下拉选项")
public CommonResult<List<ErpProductUnitRespVO>> getProductUnitSimpleList() { public CommonResult<List<ErpProductUnitRespVO>> getProductUnitSimpleList() {
List<ErpProductUnitDO> list = productUnitService.getProductUnitListByStatus(CommonStatusEnum.ENABLE.getStatus()); List<ErpProductUnitDO> list = productUnitService.getProductUnitListByStatus(CommonStatusEnum.ENABLE.getStatus());
return success(convertList(list, unit -> new ErpProductUnitRespVO().setId(unit.getId()).setName(unit.getName()))); list.stream().forEach(item -> {
item.setValue(item.getId().toString());
item.setLabel(item.getName());
});
List<ErpProductUnitRespVO> erpProductUnitRespVOS = convertList(list, unit -> new ErpProductUnitRespVO().setId(unit.getId()).setName(unit.getName()).setValue(unit.getId().toString()).setLabel(unit.getName()));
return success(erpProductUnitRespVOS);
} }
@GetMapping("/export-excel") @GetMapping("/export-excel")
@ -124,4 +137,30 @@ public class ErpProductUnitController {
} }
@GetMapping("/get-import-template")
@Operation(summary = "获得导入单位模板")
public void importTemplate(HttpServletResponse response) throws IOException {
// 手动创建导出 demo
List<ErpProductUnitImportExcelVO> list = Arrays.asList(
ErpProductUnitImportExcelVO.builder().name("件").primaryFlag("N").primaryName("个").changeRate(0.02)
.status(CommonStatusEnum.ENABLE.getStatus()).build()
);
// 输出
ExcelUtils.write(response, "单位导入模板.xls", "单位列表", ErpProductUnitImportExcelVO.class, list);
}
@PostMapping("/import")
@Operation(summary = "导入单位")
@Parameters({
@Parameter(name = "file", description = "Excel 文件", required = true),
@Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true")
})
@PreAuthorize("@ss.hasPermission('system:user:import')")
public CommonResult<String> importExcel(@RequestParam("file") MultipartFile file,
@RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception {
List<ErpProductUnitImportExcelVO> list = ExcelUtils.read(file, ErpProductUnitImportExcelVO.class);
productUnitService.importUnitList(list, updateSupport);
return success("导入成功");
}
} }

@ -0,0 +1,26 @@
package cn.iocoder.yudao.module.erp.controller.admin.product.vo.product;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
@Schema(description = "管理后台 - ERP 产品列表 Request VO")
@Data
public class ErpProductListReqVO {
@Schema(description = "产品名称", example = "零件A")
private String name;
@Schema(description = "产品分类编号", example = "11161")
private Long categoryId;
@Schema(description = "产品编号", example = "11161")
private String code;
@Schema(description = "产品规格", example = "红色")
private String standard;
@Schema(description = "产品 id 集合")
private List<Long> ids;
}

@ -27,6 +27,9 @@ public class ErpProductPageReqVO extends PageParam {
@Schema(description = "产品编号", example = "11161") @Schema(description = "产品编号", example = "11161")
private String code; private String code;
@Schema(description = "产品编码", example = "P-001")
private String barCode;
@Schema(description = "产品规格", example = "红色") @Schema(description = "产品规格", example = "红色")
private String standard; private String standard;

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.erp.controller.admin.product.vo.product; package cn.iocoder.yudao.module.erp.controller.admin.product.vo.product;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
@ -7,11 +8,12 @@ import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
@Schema(description = "管理后台 - ERP 产品 Response VO") @Schema(description = "管理后台 - ERP 产品 Response VO")
@Data @Data
@ExcelIgnoreUnannotated @ExcelIgnoreUnannotated
public class ErpProductRespVO { public class ErpProductRespVO extends ErpProductDO {
@Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15672") @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15672")
@ExcelProperty("产品编号") @ExcelProperty("产品编号")
@ -21,6 +23,10 @@ public class ErpProductRespVO {
@ExcelProperty("产品名称") @ExcelProperty("产品名称")
private String name; private String name;
@Schema(description = "规格型号", example = "")
@ExcelProperty("规格型号")
private String deviceSpec;
@Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "X110") @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "X110")
@ExcelProperty("产品条码") @ExcelProperty("产品条码")
private String barCode; private String barCode;
@ -83,4 +89,22 @@ public class ErpProductRespVO {
@Schema(description = "预警库存", example = "161.87") @Schema(description = "预警库存", example = "161.87")
@ExcelProperty("预警库存") @ExcelProperty("预警库存")
private BigDecimal safetyNumber; private BigDecimal safetyNumber;
@Schema(description = "二维码地址", example = "")
private String qrcodeUrl;
//
// @Schema(description = "关联设备ID列表", example = "[11,15,23]")
// private List<Long> deviceIds;
//
// @Schema(description = "关联模具D列表", example = "[11,15,23]")
// private List<Long> moldIds;
@Schema(description = "打印模板Json", example = "")
private String templateJson;
@Schema(description = "关联设备列表")
private List<ProductRelationRespVO> devices;
@Schema(description = "关联模具列表")
private List<ProductRelationRespVO> molds;
} }

@ -0,0 +1,15 @@
package cn.iocoder.yudao.module.erp.controller.admin.product.vo.product;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class ProductRelationRespVO {
@Schema(description = "ID", example = "1")
private Long id;
@Schema(description = "名称", example = "设备A")
private String name;
}

@ -1,11 +1,13 @@
package cn.iocoder.yudao.module.erp.controller.admin.product.vo.product; package cn.iocoder.yudao.module.erp.controller.admin.product.vo.product;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List;
@Schema(description = "管理后台 - ERP 产品新增/修改 Request VO") @Schema(description = "管理后台 - ERP 产品新增/修改 Request VO")
@Data @Data
@ -18,8 +20,11 @@ public class ProductSaveReqVO {
@NotEmpty(message = "产品名称不能为空") @NotEmpty(message = "产品名称不能为空")
private String name; private String name;
@Schema(description = "规格型号", example = "")
private String deviceSpec;
@Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "X110") @Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "X110")
@NotEmpty(message = "产品条码不能为空") // @NotEmpty(message = "产品条码不能为空")
private String barCode; private String barCode;
@Schema(description = "产品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11161") @Schema(description = "产品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11161")
@ -57,4 +62,10 @@ public class ProductSaveReqVO {
@Schema(description = "预警库存", example = "161.87") @Schema(description = "预警库存", example = "161.87")
private BigDecimal safetyNumber; private BigDecimal safetyNumber;
@Schema(description = "关联设备ID列表", example = "[11,15,23]")
private List<Long> deviceIds;
@Schema(description = "关联模具D列表", example = "[11,15,23]")
private List<Long> moldIds;
} }

@ -0,0 +1,42 @@
package cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/**
* Excel VO
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = false) // 设置 chain = false避免用户导入有问题
public class ErpProductUnitImportExcelVO {
@ExcelProperty("单位名称")
private String name;
@ExcelProperty(value = "是否主单位", converter = DictConvert.class)
@DictFormat("primary_flag")
private String primaryFlag;
private Long primaryId;
@ExcelProperty("关联主单位")
private String primaryName;
@ExcelProperty("换算比例")
private Double changeRate;
@ExcelProperty(value ="单位状态", converter = DictConvert.class)
@DictFormat("common_status")
private Integer status;
}

@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.module.system.enums.DictTypeConstants; import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
@ -43,4 +44,7 @@ public class ErpProductUnitRespVO {
@ExcelProperty("创建时间") @ExcelProperty("创建时间")
private LocalDateTime createTime; private LocalDateTime createTime;
private String value;
private String label;
} }

@ -0,0 +1,96 @@
package cn.iocoder.yudao.module.erp.controller.admin.productdevicerel;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.erp.controller.admin.productdevicerel.vo.*;
import cn.iocoder.yudao.module.erp.dal.dataobject.productdevicerel.ProductDeviceRelDO;
import cn.iocoder.yudao.module.erp.service.productdevicerel.ProductDeviceRelService;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
@Tag(name = "管理后台 - 产品-设备关联")
@RestController
@RequestMapping("/erp/product-device-rel")
@Validated
public class ProductDeviceRelController {
@Resource
private ProductDeviceRelService productDeviceRelService;
@PostMapping("/create")
@Operation(summary = "创建产品-设备关联")
@PreAuthorize("@ss.hasPermission('erp:product-device-rel:create')")
public CommonResult<Long> createProductDeviceRel(@Valid @RequestBody ProductDeviceRelSaveReqVO createReqVO) {
return success(productDeviceRelService.createProductDeviceRel(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新产品-设备关联")
@PreAuthorize("@ss.hasPermission('erp:product-device-rel:update')")
public CommonResult<Boolean> updateProductDeviceRel(@Valid @RequestBody ProductDeviceRelSaveReqVO updateReqVO) {
productDeviceRelService.updateProductDeviceRel(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除产品-设备关联")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('erp:product-device-rel:delete')")
public CommonResult<Boolean> deleteProductDeviceRel(@RequestParam("id") Long id) {
productDeviceRelService.deleteProductDeviceRel(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得产品-设备关联")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('erp:product-device-rel:query')")
public CommonResult<ProductDeviceRelRespVO> getProductDeviceRel(@RequestParam("id") Long id) {
ProductDeviceRelDO productDeviceRel = productDeviceRelService.getProductDeviceRel(id);
return success(BeanUtils.toBean(productDeviceRel, ProductDeviceRelRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得产品-设备关联分页")
@PreAuthorize("@ss.hasPermission('erp:product-device-rel:query')")
public CommonResult<PageResult<ProductDeviceRelRespVO>> getProductDeviceRelPage(@Valid ProductDeviceRelPageReqVO pageReqVO) {
PageResult<ProductDeviceRelDO> pageResult = productDeviceRelService.getProductDeviceRelPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, ProductDeviceRelRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出产品-设备关联 Excel")
@PreAuthorize("@ss.hasPermission('erp:product-device-rel:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportProductDeviceRelExcel(@Valid ProductDeviceRelPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<ProductDeviceRelDO> list = productDeviceRelService.getProductDeviceRelPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "产品-设备关联.xls", "数据", ProductDeviceRelRespVO.class,
BeanUtils.toBean(list, ProductDeviceRelRespVO.class));
}
}

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.erp.controller.admin.productdevicerel.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 产品-设备关联分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductDeviceRelPageReqVO extends PageParam {
@Schema(description = "产品ID", example = "18574")
private Long productId;
@Schema(description = "设备ID", example = "21075")
private Long deviceId;
@Schema(description = "排序")
private Integer sort;
@Schema(description = "备注", example = "随便")
private String remark;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

@ -0,0 +1,39 @@
package cn.iocoder.yudao.module.erp.controller.admin.productdevicerel.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 产品-设备关联 Response VO")
@Data
@ExcelIgnoreUnannotated
public class ProductDeviceRelRespVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "28748")
@ExcelProperty("主键")
private Long id;
@Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "18574")
@ExcelProperty("产品ID")
private Long productId;
@Schema(description = "设备ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "21075")
@ExcelProperty("设备ID")
private Long deviceId;
@Schema(description = "排序")
@ExcelProperty("排序")
private Integer sort;
@Schema(description = "备注", example = "随便")
@ExcelProperty("备注")
private String remark;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

@ -0,0 +1,30 @@
package cn.iocoder.yudao.module.erp.controller.admin.productdevicerel.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import javax.validation.constraints.NotNull;
import java.util.*;
@Schema(description = "管理后台 - 产品-设备关联新增/修改 Request VO")
@Data
public class ProductDeviceRelSaveReqVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "28748")
private Long id;
@Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "18574")
@NotNull(message = "产品ID不能为空")
private Long productId;
@Schema(description = "设备ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "21075")
@NotNull(message = "设备ID不能为空")
private Long deviceId;
@Schema(description = "排序")
private Integer sort;
@Schema(description = "备注", example = "随便")
private String remark;
}

@ -0,0 +1,95 @@
package cn.iocoder.yudao.module.erp.controller.admin.productmoldrel;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.erp.controller.admin.productmoldrel.vo.*;
import cn.iocoder.yudao.module.erp.dal.dataobject.productmoldrel.ProductMoldRelDO;
import cn.iocoder.yudao.module.erp.service.productmoldrel.ProductMoldRelService;
@Tag(name = "管理后台 - 产品-模具关联")
@RestController
@RequestMapping("/erp/product-mold-rel")
@Validated
public class ProductMoldRelController {
@Resource
private ProductMoldRelService productMoldRelService;
@PostMapping("/create")
@Operation(summary = "创建产品-模具关联")
@PreAuthorize("@ss.hasPermission('erp:product-mold-rel:create')")
public CommonResult<Long> createProductMoldRel(@Valid @RequestBody ProductMoldRelSaveReqVO createReqVO) {
return success(productMoldRelService.createProductMoldRel(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新产品-模具关联")
@PreAuthorize("@ss.hasPermission('erp:product-mold-rel:update')")
public CommonResult<Boolean> updateProductMoldRel(@Valid @RequestBody ProductMoldRelSaveReqVO updateReqVO) {
productMoldRelService.updateProductMoldRel(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除产品-模具关联")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('erp:product-mold-rel:delete')")
public CommonResult<Boolean> deleteProductMoldRel(@RequestParam("id") Long id) {
productMoldRelService.deleteProductMoldRel(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得产品-模具关联")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('erp:product-mold-rel:query')")
public CommonResult<ProductMoldRelRespVO> getProductMoldRel(@RequestParam("id") Long id) {
ProductMoldRelDO productMoldRel = productMoldRelService.getProductMoldRel(id);
return success(BeanUtils.toBean(productMoldRel, ProductMoldRelRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得产品-模具关联分页")
@PreAuthorize("@ss.hasPermission('erp:product-mold-rel:query')")
public CommonResult<PageResult<ProductMoldRelRespVO>> getProductMoldRelPage(@Valid ProductMoldRelPageReqVO pageReqVO) {
PageResult<ProductMoldRelDO> pageResult = productMoldRelService.getProductMoldRelPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, ProductMoldRelRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出产品-模具关联 Excel")
@PreAuthorize("@ss.hasPermission('erp:product-mold-rel:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportProductMoldRelExcel(@Valid ProductMoldRelPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<ProductMoldRelDO> list = productMoldRelService.getProductMoldRelPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "产品-模具关联.xls", "数据", ProductMoldRelRespVO.class,
BeanUtils.toBean(list, ProductMoldRelRespVO.class));
}
}

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.erp.controller.admin.productmoldrel.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 产品-模具关联分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductMoldRelPageReqVO extends PageParam {
@Schema(description = "产品ID", example = "30420")
private Long productId;
@Schema(description = "模具ID", example = "243")
private Long moldId;
@Schema(description = "排序")
private Integer sort;
@Schema(description = "备注", example = "随便")
private String remark;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

@ -0,0 +1,39 @@
package cn.iocoder.yudao.module.erp.controller.admin.productmoldrel.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 产品-模具关联 Response VO")
@Data
@ExcelIgnoreUnannotated
public class ProductMoldRelRespVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "11772")
@ExcelProperty("主键")
private Long id;
@Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "30420")
@ExcelProperty("产品ID")
private Long productId;
@Schema(description = "模具ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "243")
@ExcelProperty("模具ID")
private Long moldId;
@Schema(description = "排序")
@ExcelProperty("排序")
private Integer sort;
@Schema(description = "备注", example = "随便")
@ExcelProperty("备注")
private String remark;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

@ -0,0 +1,29 @@
package cn.iocoder.yudao.module.erp.controller.admin.productmoldrel.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 产品-模具关联新增/修改 Request VO")
@Data
public class ProductMoldRelSaveReqVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "11772")
private Long id;
@Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "30420")
@NotNull(message = "产品ID不能为空")
private Long productId;
@Schema(description = "模具ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "243")
@NotNull(message = "模具ID不能为空")
private Long moldId;
@Schema(description = "排序")
private Integer sort;
@Schema(description = "备注", example = "随便")
private String remark;
}

@ -5,11 +5,11 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehousePageReqVO; import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehousePageReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehouseRespVO; import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehouseRespVO;
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehouseSaveReqVO; import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehouseSaveReqVO;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO;
import cn.iocoder.yudao.module.erp.service.stock.ErpWarehouseService; import cn.iocoder.yudao.module.erp.service.stock.ErpWarehouseService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@ -80,8 +80,7 @@ public class ErpWarehouseController {
@Parameter(name = "id", description = "编号", required = true, example = "1024") @Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('erp:warehouse:query')") @PreAuthorize("@ss.hasPermission('erp:warehouse:query')")
public CommonResult<ErpWarehouseRespVO> getWarehouse(@RequestParam("id") Long id) { public CommonResult<ErpWarehouseRespVO> getWarehouse(@RequestParam("id") Long id) {
ErpWarehouseDO warehouse = warehouseService.getWarehouse(id); return success(warehouseService.getWarehouseDetail(id));
return success(BeanUtils.toBean(warehouse, ErpWarehouseRespVO.class));
} }
@GetMapping("/page") @GetMapping("/page")

@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import cn.iocoder.yudao.module.erp.controller.admin.warehousearea.vo.WarehouseAreaRespVO;
import cn.iocoder.yudao.module.erp.controller.admin.warehouselocation.vo.WarehouseLocationRespVO;
import cn.iocoder.yudao.module.system.enums.DictTypeConstants; import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
@ -10,6 +12,7 @@ import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
@Schema(description = "管理后台 - ERP 仓库 Response VO") @Schema(description = "管理后台 - ERP 仓库 Response VO")
@Data @Data
@ -20,7 +23,7 @@ public class ErpWarehouseRespVO {
@ExcelProperty("仓库编号") @ExcelProperty("仓库编号")
private Long id; private Long id;
@Schema(description = "仓库名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") @Schema(description = "仓库名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "成品仓")
@ExcelProperty("仓库名称") @ExcelProperty("仓库名称")
private String name; private String name;
@ -32,11 +35,11 @@ public class ErpWarehouseRespVO {
@ExcelProperty("排序") @ExcelProperty("排序")
private Long sort; private Long sort;
@Schema(description = "备注", example = "随便") @Schema(description = "备注", example = "主仓")
@ExcelProperty("备注") @ExcelProperty("备注")
private String remark; private String remark;
@Schema(description = "负责人", example = "芋头") @Schema(description = "负责人", example = "张三")
@ExcelProperty("负责人") @ExcelProperty("负责人")
private String principal; private String principal;
@ -57,8 +60,23 @@ public class ErpWarehouseRespVO {
@ExcelProperty("是否默认") @ExcelProperty("是否默认")
private Boolean defaultStatus; private Boolean defaultStatus;
@Schema(description = "库区数量", example = "2")
@ExcelProperty("库区数量")
private Long areaCount;
@Schema(description = "库位数量", example = "10")
@ExcelProperty("库位数量")
private Long locationCount;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间") @ExcelProperty("创建时间")
private LocalDateTime createTime; private LocalDateTime createTime;
@Schema(description = "库区列表")
private List<WarehouseAreaRespVO> areaList;
@Schema(description = "库位列表")
private List<WarehouseLocationRespVO> locationList;
} }

@ -3,10 +3,10 @@ package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.validation.InEnum; import cn.iocoder.yudao.framework.common.validation.InEnum;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal; import java.math.BigDecimal;
@Schema(description = "管理后台 - ERP 仓库新增/修改 Request VO") @Schema(description = "管理后台 - ERP 仓库新增/修改 Request VO")
@ -16,7 +16,7 @@ public class ErpWarehouseSaveReqVO {
@Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11614") @Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11614")
private Long id; private Long id;
@Schema(description = "仓库名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") @Schema(description = "仓库名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "成品仓")
@NotEmpty(message = "仓库名称不能为空") @NotEmpty(message = "仓库名称不能为空")
private String name; private String name;
@ -27,10 +27,10 @@ public class ErpWarehouseSaveReqVO {
@NotNull(message = "排序不能为空") @NotNull(message = "排序不能为空")
private Long sort; private Long sort;
@Schema(description = "备注", example = "随便") @Schema(description = "备注", example = "主仓")
private String remark; private String remark;
@Schema(description = "负责人", example = "芋头") @Schema(description = "负责人", example = "张三")
private String principal; private String principal;
@Schema(description = "仓储费,单位:元", example = "13973") @Schema(description = "仓储费,单位:元", example = "13973")
@ -39,7 +39,7 @@ public class ErpWarehouseSaveReqVO {
@Schema(description = "搬运费,单位:元", example = "9903") @Schema(description = "搬运费,单位:元", example = "9903")
private BigDecimal truckagePrice; private BigDecimal truckagePrice;
@Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "开启状态不能为空") @NotNull(message = "开启状态不能为空")
@InEnum(CommonStatusEnum.class) @InEnum(CommonStatusEnum.class)
private Integer status; private Integer status;

@ -0,0 +1,114 @@
package cn.iocoder.yudao.module.erp.controller.admin.warehousearea;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehouseRespVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
import cn.iocoder.yudao.module.erp.controller.admin.warehousearea.vo.*;
import cn.iocoder.yudao.module.erp.dal.dataobject.warehousearea.WarehouseAreaDO;
import cn.iocoder.yudao.module.erp.service.warehousearea.WarehouseAreaService;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
@Tag(name = "管理后台 - ERP 库区信息")
@RestController
@RequestMapping("/erp/warehouse-area")
@Validated
public class WarehouseAreaController {
@Resource
private WarehouseAreaService warehouseAreaService;
@PostMapping("/create")
@Operation(summary = "创建ERP 库区信息")
@PreAuthorize("@ss.hasPermission('erp:warehouse-area:create')")
public CommonResult<Long> createWarehouseArea(@Valid @RequestBody WarehouseAreaSaveReqVO createReqVO) {
return success(warehouseAreaService.createWarehouseArea(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新ERP 库区信息")
@PreAuthorize("@ss.hasPermission('erp:warehouse-area:update')")
public CommonResult<Boolean> updateWarehouseArea(@Valid @RequestBody WarehouseAreaSaveReqVO updateReqVO) {
warehouseAreaService.updateWarehouseArea(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除ERP 库区信息")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('erp:warehouse-area:delete')")
public CommonResult<Boolean> deleteWarehouseArea(@RequestParam("id") Long id) {
warehouseAreaService.deleteWarehouseArea(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得ERP 库区信息")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('erp:warehouse-area:query')")
public CommonResult<WarehouseAreaRespVO> getWarehouseArea(@RequestParam("id") Long id) {
WarehouseAreaDO warehouseArea = warehouseAreaService.getWarehouseArea(id);
return success(BeanUtils.toBean(warehouseArea, WarehouseAreaRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得ERP 库区信息分页")
@PreAuthorize("@ss.hasPermission('erp:warehouse-area:query')")
public CommonResult<PageResult<WarehouseAreaRespVO>> getWarehouseAreaPage(@Valid WarehouseAreaPageReqVO pageReqVO) {
PageResult<WarehouseAreaDO> pageResult = warehouseAreaService.getWarehouseAreaPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, WarehouseAreaRespVO.class));
}
@GetMapping("/simple-list")
@Operation(summary = "获得库区精简列表", description = "只包含被开启的仓库库区,主要用于前端的下拉选项")
public CommonResult<List<WarehouseAreaRespVO>> getWarehouseSimpleList(@RequestParam(value = "warehouseId", required = false) Long warehouseId) {
List<WarehouseAreaDO> list = warehouseAreaService.getWarehouseListByStatusAndWarehouseId(CommonStatusEnum.ENABLE.getStatus(), warehouseId);
return success(convertList(list, area -> new WarehouseAreaRespVO()
.setId(area.getId())
.setWarehouseId(area.getWarehouseId())
.setAreaCode(area.getAreaCode())
.setAreaName(area.getAreaName())
.setStatus(area.getStatus())));
}
@GetMapping("/export-excel")
@Operation(summary = "导出ERP 库区信息 Excel")
@PreAuthorize("@ss.hasPermission('erp:warehouse-area:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportWarehouseAreaExcel(@Valid WarehouseAreaPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<WarehouseAreaDO> list = warehouseAreaService.getWarehouseAreaPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "ERP 库区信息.xls", "数据", WarehouseAreaRespVO.class,
BeanUtils.toBean(list, WarehouseAreaRespVO.class));
}
}

@ -0,0 +1,41 @@
package cn.iocoder.yudao.module.erp.controller.admin.warehousearea.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - ERP 库区信息分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class WarehouseAreaPageReqVO extends PageParam {
@Schema(description = "所属仓库id", example = "19404")
private Long warehouseId;
@Schema(description = "库区编码")
private String areaCode;
@Schema(description = "库区名称", example = "赵六")
private String areaName;
@Schema(description = "面积(平方米)")
private BigDecimal areaSize;
@Schema(description = "库区描述", example = "你说的对")
private String description;
@Schema(description = "开启状态", example = "2")
private Integer status;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

@ -0,0 +1,48 @@
package cn.iocoder.yudao.module.erp.controller.admin.warehousearea.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - ERP 库区信息 Response VO")
@Data
@ExcelIgnoreUnannotated
public class WarehouseAreaRespVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1157")
@ExcelProperty("id")
private Long id;
@Schema(description = "所属仓库id", requiredMode = Schema.RequiredMode.REQUIRED, example = "19404")
@ExcelProperty("所属仓库id")
private Long warehouseId;
@Schema(description = "库区编码", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("库区编码")
private String areaCode;
@Schema(description = "库区名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
@ExcelProperty("库区名称")
private String areaName;
@Schema(description = "面积(平方米)")
@ExcelProperty("面积(平方米)")
private BigDecimal areaSize;
@Schema(description = "库区描述", example = "你说的对")
@ExcelProperty("库区描述")
private String description;
@Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@ExcelProperty("开启状态")
private Integer status;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

@ -0,0 +1,38 @@
package cn.iocoder.yudao.module.erp.controller.admin.warehousearea.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
@Schema(description = "管理后台 - ERP 库区信息新增/修改 Request VO")
@Data
public class WarehouseAreaSaveReqVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1157")
private Long id;
@Schema(description = "所属仓库id", example = "19404")
private Long warehouseId;
@Schema(description = "库区编码", requiredMode = Schema.RequiredMode.REQUIRED)
// @NotEmpty(message = "库区编码不能为空")
private String areaCode;
@Schema(description = "库区名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "A区")
@NotEmpty(message = "库区名称不能为空")
private String areaName;
@Schema(description = "面积(平方米)")
private BigDecimal areaSize;
@Schema(description = "库区描述", example = "常温区")
private String description;
@Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "开启状态不能为空")
private Integer status;
}

@ -0,0 +1,110 @@
package cn.iocoder.yudao.module.erp.controller.admin.warehouselocation;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.erp.controller.admin.warehouselocation.vo.*;
import cn.iocoder.yudao.module.erp.dal.dataobject.warehouselocation.WarehouseLocationDO;
import cn.iocoder.yudao.module.erp.service.warehouselocation.WarehouseLocationService;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
@Tag(name = "管理后台 - ERP 库位信息")
@RestController
@RequestMapping("/erp/warehouse-location")
@Validated
public class WarehouseLocationController {
@Resource
private WarehouseLocationService warehouseLocationService;
@PostMapping("/create")
@Operation(summary = "创建ERP 库位信息")
@PreAuthorize("@ss.hasPermission('erp:warehouse-location:create')")
public CommonResult<Long> createWarehouseLocation(@Valid @RequestBody WarehouseLocationSaveReqVO createReqVO) {
return success(warehouseLocationService.createWarehouseLocation(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新ERP 库位信息")
@PreAuthorize("@ss.hasPermission('erp:warehouse-location:update')")
public CommonResult<Boolean> updateWarehouseLocation(@Valid @RequestBody WarehouseLocationSaveReqVO updateReqVO) {
warehouseLocationService.updateWarehouseLocation(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除ERP 库位信息")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('erp:warehouse-location:delete')")
public CommonResult<Boolean> deleteWarehouseLocation(@RequestParam("id") Long id) {
warehouseLocationService.deleteWarehouseLocation(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得ERP 库位信息")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('erp:warehouse-location:query')")
public CommonResult<WarehouseLocationRespVO> getWarehouseLocation(@RequestParam("id") Long id) {
WarehouseLocationDO warehouseLocation = warehouseLocationService.getWarehouseLocation(id);
return success(BeanUtils.toBean(warehouseLocation, WarehouseLocationRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得ERP 库位信息分页")
@PreAuthorize("@ss.hasPermission('erp:warehouse-location:query')")
public CommonResult<PageResult<WarehouseLocationRespVO>> getWarehouseLocationPage(@Valid WarehouseLocationPageReqVO pageReqVO) {
PageResult<WarehouseLocationDO> pageResult = warehouseLocationService.getWarehouseLocationPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, WarehouseLocationRespVO.class));
}
@GetMapping("/simple-list")
@Operation(summary = "获得ERP 库位信息精简列表", description = "只包含已启用的库位,主要用于前端下拉选项")
public CommonResult<List<WarehouseLocationRespVO>> getWarehouseLocationSimpleList() {
List<WarehouseLocationDO> list = warehouseLocationService.getWarehouseLocationListByStatus(CommonStatusEnum.ENABLE.getStatus());
return success(convertList(list, item -> new WarehouseLocationRespVO()
.setId(item.getId())
.setWarehouseId(item.getWarehouseId())
.setAreaId(item.getAreaId())
.setCode(item.getCode())
.setName(item.getName())
.setStatus(item.getStatus())));
}
@GetMapping("/export-excel")
@Operation(summary = "导出ERP 库位信息 Excel")
@PreAuthorize("@ss.hasPermission('erp:warehouse-location:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportWarehouseLocationExcel(@Valid WarehouseLocationPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<WarehouseLocationDO> list = warehouseLocationService.getWarehouseLocationPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "ERP 库位信息.xls", "数据", WarehouseLocationRespVO.class,
BeanUtils.toBean(list, WarehouseLocationRespVO.class));
}
}

@ -0,0 +1,59 @@
package cn.iocoder.yudao.module.erp.controller.admin.warehouselocation.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - ERP 库位信息分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class WarehouseLocationPageReqVO extends PageParam {
@Schema(description = "所属仓库ID", example = "19287")
private Long warehouseId;
@Schema(description = "所属库区ID", example = "513")
private Long areaId;
@Schema(description = "库位编码")
private String code;
@Schema(description = "库位名称", example = "张三")
private String name;
@Schema(description = "面积")
private BigDecimal areaSize;
@Schema(description = "最大载重量")
private BigDecimal maxLoadWeight;
@Schema(description = "库位位置X")
private Integer positionX;
@Schema(description = "库位位置Y")
private Integer positionY;
@Schema(description = "库位位置Z")
private Integer positionZ;
@Schema(description = "是否允许产品混放")
private Boolean allowProductMix;
@Schema(description = "是否允许批次混放")
private Boolean allowBatchMix;
@Schema(description = "开启状态", example = "1")
private Integer status;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

@ -0,0 +1,72 @@
package cn.iocoder.yudao.module.erp.controller.admin.warehouselocation.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - ERP 库位信息 Response VO")
@Data
@ExcelIgnoreUnannotated
public class WarehouseLocationRespVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "7300")
@ExcelProperty("id")
private Long id;
@Schema(description = "所属仓库ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "19287")
@ExcelProperty("所属仓库ID")
private Long warehouseId;
@Schema(description = "所属库区ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "513")
@ExcelProperty("所属库区ID")
private Long areaId;
@Schema(description = "库位编码", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("库位编码")
private String code;
@Schema(description = "库位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
@ExcelProperty("库位名称")
private String name;
@Schema(description = "面积")
@ExcelProperty("面积")
private BigDecimal areaSize;
@Schema(description = "最大载重量")
@ExcelProperty("最大载重量")
private BigDecimal maxLoadWeight;
@Schema(description = "库位位置X")
@ExcelProperty("库位位置X")
private Integer positionX;
@Schema(description = "库位位置Y")
@ExcelProperty("库位位置Y")
private Integer positionY;
@Schema(description = "库位位置Z")
@ExcelProperty("库位位置Z")
private Integer positionZ;
@Schema(description = "是否允许产品混放", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("是否允许产品混放")
private Boolean allowProductMix;
@Schema(description = "是否允许批次混放", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("是否允许批次混放")
private Boolean allowBatchMix;
@Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@ExcelProperty("开启状态")
private Integer status;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

@ -0,0 +1,59 @@
package cn.iocoder.yudao.module.erp.controller.admin.warehouselocation.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
@Schema(description = "管理后台 - ERP 库位信息新增/修改 Request VO")
@Data
public class WarehouseLocationSaveReqVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "7300")
private Long id;
@Schema(description = "所属仓库ID", example = "19287")
private Long warehouseId;
@Schema(description = "所属库区ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "513")
@NotNull(message = "所属库区ID不能为空")
private Long areaId;
@Schema(description = "库位编码", requiredMode = Schema.RequiredMode.REQUIRED)
// @NotEmpty(message = "库位编码不能为空")
private String code;
@Schema(description = "库位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "A-01-01")
@NotEmpty(message = "库位名称不能为空")
private String name;
@Schema(description = "面积")
private BigDecimal areaSize;
@Schema(description = "最大载重量")
private BigDecimal maxLoadWeight;
@Schema(description = "库位位置X")
private Integer positionX;
@Schema(description = "库位位置Y")
private Integer positionY;
@Schema(description = "库位位置Z")
private Integer positionZ;
@Schema(description = "是否允许产品混放", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "是否允许产品混放不能为空")
private Boolean allowProductMix;
@Schema(description = "是否允许批次混放", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "是否允许批次混放不能为空")
private Boolean allowBatchMix;
@Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "开启状态不能为空")
private Integer status;
}

@ -70,4 +70,10 @@ public class AutocodeRuleDO extends BaseDO {
*/ */
private Boolean isEnable; private Boolean isEnable;
/**
* -1 -2
*
*/
private Integer barcodeType;
} }

@ -1,9 +1,12 @@
package cn.iocoder.yudao.module.erp.dal.dataobject.product; package cn.iocoder.yudao.module.erp.dal.dataobject.product;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*; import lombok.*;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -32,6 +35,7 @@ public class ErpProductDO extends BaseDO {
* *
*/ */
private String name; private String name;
/** /**
* *
*/ */
@ -100,4 +104,10 @@ public class ErpProductDO extends BaseDO {
* *
*/ */
private BigDecimal safetyNumber; private BigDecimal safetyNumber;
/**
*
*/
@TableField(exist = false)
private String qrcodeUrl;
} }

@ -46,6 +46,10 @@ public class ErpProductUnitDO extends BaseDO {
/** /**
* *
*/ */
private Integer status;
private Integer status;
@TableField(exist = false)
private String value;
@TableField(exist = false)
private String label;
} }

@ -0,0 +1,47 @@
package cn.iocoder.yudao.module.erp.dal.dataobject.productdevicerel;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* - DO
*
* @author
*/
@TableName("erp_product_device_rel")
@KeySequence("erp_product_device_rel_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ProductDeviceRelDO extends BaseDO {
/**
*
*/
@TableId
private Long id;
/**
* ID
*/
private Long productId;
/**
* ID
*/
private Long deviceId;
/**
*
*/
private Integer sort;
/**
*
*/
private String remark;
}

@ -0,0 +1,47 @@
package cn.iocoder.yudao.module.erp.dal.dataobject.productmoldrel;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* - DO
*
* @author
*/
@TableName("erp_product_mold_rel")
@KeySequence("erp_product_mold_rel_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ProductMoldRelDO extends BaseDO {
/**
*
*/
@TableId
private Long id;
/**
* ID
*/
private Long productId;
/**
* ID
*/
private Long moldId;
/**
*
*/
private Integer sort;
/**
*
*/
private String remark;
}

@ -0,0 +1,56 @@
package cn.iocoder.yudao.module.erp.dal.dataobject.warehousearea;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* ERP DO
*
* @author
*/
@TableName("erp_warehouse_area")
@KeySequence("erp_warehouse_area_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WarehouseAreaDO extends BaseDO {
/**
* id
*/
@TableId
private Long id;
/**
* id
*/
private Long warehouseId;
/**
*
*/
private String areaCode;
/**
*
*/
private String areaName;
/**
* ()
*/
private BigDecimal areaSize;
/**
*
*/
private String description;
/**
*
*/
private Integer status;
}

@ -0,0 +1,81 @@
package cn.iocoder.yudao.module.erp.dal.dataobject.warehouselocation;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* ERP DO
*
* @author
*/
@TableName("erp_warehouse_location")
@KeySequence("erp_warehouse_location_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WarehouseLocationDO extends BaseDO {
/**
* id
*/
@TableId
private Long id;
/**
* ID
*/
private Long warehouseId;
/**
* ID
*/
private Long areaId;
/**
*
*/
private String code;
/**
*
*/
private String name;
/**
*
*/
private BigDecimal areaSize;
/**
*
*/
private BigDecimal maxLoadWeight;
/**
* X
*/
private Integer positionX;
/**
* Y
*/
private Integer positionY;
/**
* Z
*/
private Integer positionZ;
/**
*
*/
private Boolean allowProductMix;
/**
*
*/
private Boolean allowBatchMix;
/**
*
*/
private Integer status;
}

@ -5,11 +5,14 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductListReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductPageReqVO; import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductPageReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductRelationRespVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
@ -24,33 +27,52 @@ import java.util.List;
@Mapper @Mapper
public interface ErpProductMapper extends BaseMapperX<ErpProductDO> { public interface ErpProductMapper extends BaseMapperX<ErpProductDO> {
// 适配barCode和code两种情况
default String resolveCode(ErpProductPageReqVO reqVO){
String barCode = StringUtils.hasText(reqVO.getBarCode()) ? reqVO.getBarCode() : reqVO.getCode();
return barCode;
}
default PageResult<ErpProductDO> selectPage(ErpProductPageReqVO reqVO) { default PageResult<ErpProductDO> selectPage(ErpProductPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<ErpProductDO>() return selectPage(reqVO, new LambdaQueryWrapperX<ErpProductDO>()
.likeIfPresent(ErpProductDO::getName, reqVO.getName()) .likeIfPresent(ErpProductDO::getName, reqVO.getName())
.likeIfPresent(ErpProductDO::getBarCode, resolveCode(reqVO))
.eqIfPresent(ErpProductDO::getCategoryId, reqVO.getCategoryId()) .eqIfPresent(ErpProductDO::getCategoryId, reqVO.getCategoryId())
.betweenIfPresent(ErpProductDO::getCreateTime, reqVO.getCreateTime()) .betweenIfPresent(ErpProductDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(ErpProductDO::getId)); .orderByDesc(ErpProductDO::getId));
} }
default List<ErpProductDO> selectList(ErpProductListReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<ErpProductDO>()
.inIfPresent(ErpProductDO::getId, reqVO.getIds())
.likeIfPresent(ErpProductDO::getName, reqVO.getName())
.likeIfPresent(ErpProductDO::getBarCode, reqVO.getCode())
.eqIfPresent(ErpProductDO::getCategoryId, reqVO.getCategoryId())
.likeIfPresent(ErpProductDO::getStandard, reqVO.getStandard())
.orderByDesc(ErpProductDO::getId));
}
default PageResult<ErpProductDO> selectProductCodeExist(ErpProductPageReqVO reqVO) { default PageResult<ErpProductDO> selectProductCodeExist(ErpProductPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<ErpProductDO>() return selectPage(reqVO, new LambdaQueryWrapperX<ErpProductDO>()
.eqIfPresent(ErpProductDO::getName, reqVO.getName()) .eqIfPresent(ErpProductDO::getName, reqVO.getName())
.eqIfPresent(ErpProductDO::getBarCode, reqVO.getCode()) .eqIfPresent(ErpProductDO::getBarCode, resolveCode(reqVO))
.orderByAsc(ErpProductDO::getId)); .orderByAsc(ErpProductDO::getId));
} }
default Boolean selectProductExist(ErpProductPageReqVO reqVO) { default Boolean selectProductExist(ErpProductDO reqVO) {
LambdaQueryWrapperX<ErpProductDO> queryWrapper = (LambdaQueryWrapperX<ErpProductDO>) new LambdaQueryWrapperX<ErpProductDO>() if (!StringUtils.hasText(reqVO.getName()) || !StringUtils.hasText(reqVO.getStandard())) {
.orderByAsc(ErpProductDO::getId);
if (StringUtils.hasText(reqVO.getName()) && StringUtils.hasText(reqVO.getStandard())) {
// 组合查询name 和 standard 必须同时匹配
queryWrapper.eq(ErpProductDO::getName, reqVO.getName())
.eq(ErpProductDO::getStandard, reqVO.getStandard());
return !selectPage(reqVO, queryWrapper).getList().isEmpty();
}
return false; return false;
} }
// 直接使用 count 查询
Long count = selectCount(new LambdaQueryWrapper<ErpProductDO>()
.eq(ErpProductDO::getName, reqVO.getName())
.eq(ErpProductDO::getStandard, reqVO.getStandard()));
return count > 0;
}
default Long selectCountByCategoryId(Long categoryId) { default Long selectCountByCategoryId(Long categoryId) {
return selectCount(ErpProductDO::getCategoryId, categoryId); return selectCount(ErpProductDO::getCategoryId, categoryId);
} }
@ -83,5 +105,11 @@ public interface ErpProductMapper extends BaseMapperX<ErpProductDO> {
return selectList(new LambdaQueryWrapperX<ErpProductDO>().in(ErpProductDO::getName, names)); return selectList(new LambdaQueryWrapperX<ErpProductDO>().in(ErpProductDO::getName, names));
} }
List<ErpProductDO> selectListByIdsWithDeleted(@Param("ids") Collection<Long> ids);
List<ProductRelationRespVO> selectDevicesByProductId(@Param("productId") Long productId);
List<ProductRelationRespVO> selectMoldsByProductId(@Param("productId") Long productId);
String selectPrintTemplate(@Param("templateType") Integer templateType);
} }

@ -0,0 +1,31 @@
package cn.iocoder.yudao.module.erp.dal.mysql.productdevicerel;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.erp.dal.dataobject.productdevicerel.ProductDeviceRelDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.erp.controller.admin.productdevicerel.vo.*;
/**
* - Mapper
*
* @author
*/
@Mapper
public interface ProductDeviceRelMapper extends BaseMapperX<ProductDeviceRelDO> {
default PageResult<ProductDeviceRelDO> selectPage(ProductDeviceRelPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<ProductDeviceRelDO>()
.eqIfPresent(ProductDeviceRelDO::getProductId, reqVO.getProductId())
.eqIfPresent(ProductDeviceRelDO::getDeviceId, reqVO.getDeviceId())
.eqIfPresent(ProductDeviceRelDO::getSort, reqVO.getSort())
.eqIfPresent(ProductDeviceRelDO::getRemark, reqVO.getRemark())
.betweenIfPresent(ProductDeviceRelDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(ProductDeviceRelDO::getId));
}
}

@ -0,0 +1,32 @@
package cn.iocoder.yudao.module.erp.dal.mysql.productmoldrel;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.erp.dal.dataobject.productmoldrel.ProductMoldRelDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.erp.controller.admin.productmoldrel.vo.*;
/**
* - Mapper
*
* @author
*/
@Mapper
public interface ProductMoldRelMapper extends BaseMapperX<ProductMoldRelDO> {
default PageResult<ProductMoldRelDO> selectPage(ProductMoldRelPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<ProductMoldRelDO>()
.eqIfPresent(ProductMoldRelDO::getProductId, reqVO.getProductId())
.eqIfPresent(ProductMoldRelDO::getMoldId, reqVO.getMoldId())
.eqIfPresent(ProductMoldRelDO::getSort, reqVO.getSort())
.eqIfPresent(ProductMoldRelDO::getRemark, reqVO.getRemark())
.betweenIfPresent(ProductMoldRelDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(ProductMoldRelDO::getId));
}
}

@ -0,0 +1,53 @@
package cn.iocoder.yudao.module.erp.dal.mysql.warehousearea;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.erp.dal.dataobject.warehousearea.WarehouseAreaDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.erp.controller.admin.warehousearea.vo.*;
/**
* ERP Mapper
*
* @author
*/
@Mapper
public interface WarehouseAreaMapper extends BaseMapperX<WarehouseAreaDO> {
default PageResult<WarehouseAreaDO> selectPage(WarehouseAreaPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<WarehouseAreaDO>()
.eqIfPresent(WarehouseAreaDO::getWarehouseId, reqVO.getWarehouseId())
.eqIfPresent(WarehouseAreaDO::getAreaCode, reqVO.getAreaCode())
.likeIfPresent(WarehouseAreaDO::getAreaName, reqVO.getAreaName())
.eqIfPresent(WarehouseAreaDO::getAreaSize, reqVO.getAreaSize())
.eqIfPresent(WarehouseAreaDO::getDescription, reqVO.getDescription())
.eqIfPresent(WarehouseAreaDO::getStatus, reqVO.getStatus())
.betweenIfPresent(WarehouseAreaDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(WarehouseAreaDO::getId));
}
default WarehouseAreaDO selectByNo(String no) {
return selectOne(WarehouseAreaDO::getAreaCode, no);
}
default List<WarehouseAreaDO> selectListByStatus(Integer status) {
return selectList(WarehouseAreaDO::getStatus, status);
}
default List<WarehouseAreaDO> selectListByWarehouseId(Long warehouseId) {
return selectList(WarehouseAreaDO::getWarehouseId, warehouseId);
}
default void deleteByWarehouseId(Long warehouseId) {
delete(WarehouseAreaDO::getWarehouseId, warehouseId);
}
default Long selectCountByWarehouseId(Long warehouseId) {
return selectCount(WarehouseAreaDO::getWarehouseId, warehouseId);
}
}

@ -0,0 +1,61 @@
package cn.iocoder.yudao.module.erp.dal.mysql.warehouselocation;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.erp.dal.dataobject.warehouselocation.WarehouseLocationDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.erp.controller.admin.warehouselocation.vo.*;
/**
* ERP Mapper
*
* @author
*/
@Mapper
public interface WarehouseLocationMapper extends BaseMapperX<WarehouseLocationDO> {
default PageResult<WarehouseLocationDO> selectPage(WarehouseLocationPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<WarehouseLocationDO>()
.eqIfPresent(WarehouseLocationDO::getWarehouseId, reqVO.getWarehouseId())
.eqIfPresent(WarehouseLocationDO::getAreaId, reqVO.getAreaId())
.eqIfPresent(WarehouseLocationDO::getCode, reqVO.getCode())
.likeIfPresent(WarehouseLocationDO::getName, reqVO.getName())
.eqIfPresent(WarehouseLocationDO::getAreaSize, reqVO.getAreaSize())
.eqIfPresent(WarehouseLocationDO::getMaxLoadWeight, reqVO.getMaxLoadWeight())
.eqIfPresent(WarehouseLocationDO::getPositionX, reqVO.getPositionX())
.eqIfPresent(WarehouseLocationDO::getPositionY, reqVO.getPositionY())
.eqIfPresent(WarehouseLocationDO::getPositionZ, reqVO.getPositionZ())
.eqIfPresent(WarehouseLocationDO::getAllowProductMix, reqVO.getAllowProductMix())
.eqIfPresent(WarehouseLocationDO::getAllowBatchMix, reqVO.getAllowBatchMix())
.eqIfPresent(WarehouseLocationDO::getStatus, reqVO.getStatus())
.betweenIfPresent(WarehouseLocationDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(WarehouseLocationDO::getId));
}
default WarehouseLocationDO selectByNo(String no) {
return selectOne(WarehouseLocationDO::getCode, no);
}
default List<WarehouseLocationDO> selectListByWarehouseId(Long warehouseId) {
return selectList(WarehouseLocationDO::getWarehouseId, warehouseId);
}
default void deleteByWarehouseId(Long warehouseId) {
delete(WarehouseLocationDO::getWarehouseId, warehouseId);
}
default List<WarehouseLocationDO> selectListByStatus(Integer status) {
return selectList(WarehouseLocationDO::getStatus, status);
}
default List<WarehouseLocationDO> selectListByAreaId(Long areaId) {
return selectList(WarehouseLocationDO::getAreaId, areaId);
}
default Long selectCountByWarehouseId(Long warehouseId) {
return selectCount(WarehouseLocationDO::getWarehouseId, warehouseId);
}
}

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.erp.handler;
import cn.iocoder.yudao.module.common.dal.mysql.mold.MoldMapper;
import cn.iocoder.yudao.module.common.enums.QrcodeBizTypeEnum;
import cn.iocoder.yudao.module.common.handler.QrcodeBizHandler;
import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductMapper;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Component
public class ProductQrcodeBizHandler implements QrcodeBizHandler {
@Resource
private ErpProductMapper productMapper;
public String getBizType() {
return QrcodeBizTypeEnum.PRODUCT.getCode();
}
public boolean exists(Long id) { return productMapper.selectById(id) != null; }
public String buildDeepLink(Long id) {
// return "besure://mold/detail?id=" + id;
//TODO 替换成app连接
return "https://www.baidu.com";
}
public String buildH5Path(Long id) {
// return "/h5/mold/view?id=" + id;
//TODO 替换成app连接不存在页面
return "https://baike.baidu.com/item/%E6%98%9F%E5%BA%A7/8072715?fr=aladdin";
}
}

@ -12,6 +12,7 @@ import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.MoldBrandTreeRespVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductCategoryDO; import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductCategoryDO;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.UnsupportedEncodingException;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -96,7 +97,7 @@ public interface MoldBrandService {
* @param mold * @param mold
* @return * @return
*/ */
Long createMold(@Valid MoldSaveReqVO createReqVO); Long createMold(@Valid MoldSaveReqVO createReqVO) throws UnsupportedEncodingException;
/** /**
* *
@ -119,6 +120,8 @@ public interface MoldBrandService {
* @return * @return
*/ */
MoldDO getMold(Long id); MoldDO getMold(Long id);
MoldDO getMold(Long id, String code);
List<MoldDO> selectBy(MoldDO reqVO); List<MoldDO> selectBy(MoldDO reqVO);
// ==================== 子表(模具产品) ==================== // ==================== 子表(模具产品) ====================
@ -184,4 +187,6 @@ public interface MoldBrandService {
} }
List<MoldBrandTreeRespVO> getMoldBrandTree(); List<MoldBrandTreeRespVO> getMoldBrandTree();
void regenerateCode(Long id, String code) throws UnsupportedEncodingException;
} }

@ -15,6 +15,10 @@ import cn.iocoder.yudao.module.common.dal.dataobject.mold.MoldDO;
import cn.iocoder.yudao.module.common.dal.dataobject.moldrepair.MoldRepairDO; import cn.iocoder.yudao.module.common.dal.dataobject.moldrepair.MoldRepairDO;
import cn.iocoder.yudao.module.common.dal.dataobject.moldrepair.MoldRepairLineDO; import cn.iocoder.yudao.module.common.dal.dataobject.moldrepair.MoldRepairLineDO;
import cn.iocoder.yudao.module.common.dal.dataobject.moldticketresults.MoldTicketResultsDO; import cn.iocoder.yudao.module.common.dal.dataobject.moldticketresults.MoldTicketResultsDO;
import cn.iocoder.yudao.module.common.enums.CodeTypeEnum;
import cn.iocoder.yudao.module.common.enums.QrcodeBizTypeEnum;
import cn.iocoder.yudao.module.common.service.qrcordrecord.QrcodeRecordService;
import cn.iocoder.yudao.module.erp.controller.admin.autocode.util.AutoCodeUtil;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.MoldBrandTreeRespVO; import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.MoldBrandTreeRespVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO; import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO;
@ -29,18 +33,23 @@ import cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants;
import cn.iocoder.yudao.module.erp.service.product.ErpProductService; import cn.iocoder.yudao.module.erp.service.product.ErpProductService;
import cn.iocoder.yudao.module.erp.service.product.ErpProductUnitService; import cn.iocoder.yudao.module.erp.service.product.ErpProductUnitService;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
import static cn.iocoder.yudao.module.common.api.mold.enums.ErrorCodeConstants.FAILED_TO_REGENERATE;
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*;
/** /**
@ -50,6 +59,7 @@ import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*;
*/ */
@Service @Service
@Validated @Validated
@Slf4j
public class MoldBrandServiceImpl implements MoldBrandService { public class MoldBrandServiceImpl implements MoldBrandService {
@Resource @Resource
@ -66,6 +76,12 @@ public class MoldBrandServiceImpl implements MoldBrandService {
private ErpProductUnitService productUnitService; private ErpProductUnitService productUnitService;
@Resource @Resource
private ErpProductService productService; private ErpProductService productService;
@Resource
private QrcodeRecordService qrcodeService;
@Autowired
private AutoCodeUtil autoCodeUtil;
@Override @Override
public Long createMoldBrand(MoldBrandSaveReqVO createReqVO) { public Long createMoldBrand(MoldBrandSaveReqVO createReqVO) {
// 插入 // 插入
@ -173,19 +189,48 @@ public class MoldBrandServiceImpl implements MoldBrandService {
}); });
} }
@Override @Override
public Long createMold(MoldSaveReqVO createReqVO) { public Long createMold(MoldSaveReqVO createReqVO) throws UnsupportedEncodingException {
String Code = createReqVO.getCode(); String Code = createReqVO.getCode();
if (StrUtil.isBlank(Code)) { // if (StrUtil.isBlank(Code)) {
throw new ServiceException(ErrorCodeConstants.MOLD_CODE_EMPTY); // throw new ServiceException(ErrorCodeConstants.MOLD_CODE_EMPTY);
// }
// boolean exists = moldMapper.exists(
// new LambdaQueryWrapperX<MoldDO>().eq(MoldDO::getCode, Code)
// );
// if (exists) {
// throw new ServiceException(ErrorCodeConstants.MOLD_CODE_DUPLICATE);
// }
MoldDO mold = BeanUtils.toBean(createReqVO, MoldDO.class);
if (StringUtils.isBlank(Code)) {
mold.setCode(autoCodeUtil.genSerialCode("MOLD_CODE_GENERATE",null));
} else {
if (moldMapper.selectOne(Wrappers.<MoldDO>lambdaQuery().eq(MoldDO::getCode,Code)) != null) {
throw exception(MOLD_CODE_DUPLICATE);
} }
boolean exists = moldMapper.exists(
new LambdaQueryWrapperX<MoldDO>().eq(MoldDO::getCode, Code)
);
if (exists) {
throw new ServiceException(ErrorCodeConstants.MOLD_CODE_DUPLICATE);
} }
MoldDO mold = BeanUtils.toBean(createReqVO, MoldDO.class);
moldMapper.insert(mold); moldMapper.insert(mold);
CodeTypeEnum codeType = autoCodeUtil.queryCodeType("MOLD_CODE_GENERATE");
if (codeType==null){
log.warn("[创建模具]未配置码类型跳过生产ruleCode={}","MOLD_CODE_GENERATE");
return mold.getId();
}
qrcodeService.generateOrRefresh(
QrcodeBizTypeEnum.MOLD,
mold.getId(),
mold.getCode(),
"DETAIL",
codeType
);
return mold.getId(); return mold.getId();
} }
@ -201,12 +246,17 @@ public class MoldBrandServiceImpl implements MoldBrandService {
public void deleteMold(Long id) { public void deleteMold(Long id) {
// 校验存在 // 校验存在
validateMoldExists(id); validateMoldExists(id);
// 删除二维码/条形码
qrcodeService.deleteByBiz(QrcodeBizTypeEnum.MOLD, id);
// 删除 // 删除
moldMapper.deleteById(id); moldMapper.deleteById(id);
} }
@Override @Override
public MoldDO getMold(Long id) { public MoldDO getMold(Long id) {
validateMoldExists(id);
MoldDO moldDO = moldMapper.selectById(id); MoldDO moldDO = moldMapper.selectById(id);
Map<String,List<MoldRepairLineDO>> moldRepairDOMap=new HashMap<>(); Map<String,List<MoldRepairLineDO>> moldRepairDOMap=new HashMap<>();
@ -255,9 +305,33 @@ public class MoldBrandServiceImpl implements MoldBrandService {
if(CollectionUtils.isNotEmpty(moldRepairDOMap)){ if(CollectionUtils.isNotEmpty(moldRepairDOMap)){
moldDO.setRepairList(moldRepairDOMap); moldDO.setRepairList(moldRepairDOMap);
} }
String qrcodeUrl = qrcodeService.selectQrcodeUrlByIdAndCode(QrcodeBizTypeEnum.MOLD.getCode(),id,moldDO.getCode());
moldDO.setQrcodeUrl(qrcodeUrl);
return moldDO; return moldDO;
} }
@Override
public MoldDO getMold(Long id, String code) {
if (id != null) {
MoldDO mold = getMold(id);
if(mold != null ){
String template = moldMapper.selectPrintTemplate();
mold.setTemplateJson(template);
}
return mold;
}
if (StrUtil.isNotBlank(code)) {
MoldDO moldDO = moldMapper.selectOne(new LambdaQueryWrapperX<MoldDO>()
.like(MoldDO::getCode, code)
.orderByDesc(MoldDO::getId)
.last("LIMIT 1"));
if (moldDO == null) {
throw exception(MOLD_NOT_EXISTS);
}
return getMold(moldDO.getId());
}
throw exception(MOLD_NOT_EXISTS);
}
@Override @Override
public List<MoldDO> selectBy(MoldDO reqVO){ public List<MoldDO> selectBy(MoldDO reqVO){
return moldMapper.selectBy(reqVO); return moldMapper.selectBy(reqVO);
@ -353,6 +427,27 @@ public class MoldBrandServiceImpl implements MoldBrandService {
return buildMoldBrandTree(allMoldBrands); return buildMoldBrandTree(allMoldBrands);
} }
@Override
public void regenerateCode(Long id, String code) throws UnsupportedEncodingException {
if(moldMapper.selectById(id)==null){
throw exception(MOLD_BRAND_PRODUCT_NOT_EXISTS);
}
if(StringUtils.isBlank(code)){
throw exception(MOLD_CODE_EMPTY);
}
CodeTypeEnum codeGenerate = autoCodeUtil.queryCodeType("MOLD_CODE_GENERATE");
//
qrcodeService.regenerateByCodeType(
QrcodeBizTypeEnum.MOLD,
id,
code,
"DETAIL",
codeGenerate.getCode()
);
}
/** /**
* *
*/ */

@ -102,4 +102,8 @@ public interface MoldService {
List<MoldDO> getInTransitMoldAllList(); List<MoldDO> getInTransitMoldAllList();
List<MoldDO> getMoldListByStatus(Long status); List<MoldDO> getMoldListByStatus(Long status);
List<MoldDO> getMoldListByIds(Collection<Long> ids);
} }

@ -136,4 +136,11 @@ public class MoldServiceImpl implements MoldService {
.eqIfPresent(MoldDO::getStatus, status); .eqIfPresent(MoldDO::getStatus, status);
return moldMapper.selectList(queryWrapper); return moldMapper.selectList(queryWrapper);
} }
@Override
public List<MoldDO> getMoldListByIds(Collection<Long> ids) {
if (ids == null || ids.isEmpty()) {
return Collections.emptyList();
}
return moldMapper.selectBatchIds(ids); }
} }

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.erp.service.product;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductImportExcelVO; import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductImportExcelVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductImportRespVO; import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductImportRespVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductListReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductPageReqVO; import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductPageReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductSaveReqVO; import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductSaveReqVO;
@ -10,6 +11,7 @@ import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO; import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.UnsupportedEncodingException;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -30,7 +32,7 @@ public interface ErpProductService {
* @param createReqVO * @param createReqVO
* @return * @return
*/ */
Long createProduct(@Valid ProductSaveReqVO createReqVO); Long createProduct(@Valid ProductSaveReqVO createReqVO) throws UnsupportedEncodingException;
/** /**
* *
@ -60,7 +62,9 @@ public interface ErpProductService {
* @param id * @param id
* @return * @return
*/ */
ErpProductDO getProduct(Long id); ErpProductRespVO getProduct(Long id);
ErpProductRespVO getProduct(Long id, String code);
/** /**
* VO * VO
@ -134,4 +138,6 @@ public interface ErpProductService {
* @return * @return
*/ */
ErpProductImportRespVO importProductList(List<ErpProductImportExcelVO> importProducts, boolean isUpdateSupport); ErpProductImportRespVO importProductList(List<ErpProductImportExcelVO> importProducts, boolean isUpdateSupport);
void regenerateCode(Long id, String code) throws UnsupportedEncodingException;
} }

@ -7,22 +7,30 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.MapUtils; import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductImportExcelVO; import cn.iocoder.yudao.module.common.dal.dataobject.mold.MoldDO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductImportRespVO; import cn.iocoder.yudao.module.common.enums.CodeTypeEnum;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductPageReqVO; import cn.iocoder.yudao.module.common.enums.QrcodeBizTypeEnum;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; import cn.iocoder.yudao.module.common.service.qrcordrecord.QrcodeRecordService;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductSaveReqVO; import cn.iocoder.yudao.module.erp.controller.admin.autocode.util.AutoCodeUtil;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.*;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductCategoryDO; import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductCategoryDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO; import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.productdevicerel.ProductDeviceRelDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.productmoldrel.ProductMoldRelDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO; import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO;
import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductCategoryMapper; import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductCategoryMapper;
import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductMapper; import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductMapper;
import cn.iocoder.yudao.module.erp.dal.mysql.productdevicerel.ProductDeviceRelMapper;
import cn.iocoder.yudao.module.erp.dal.mysql.productmoldrel.ProductMoldRelMapper;
import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockMapper; import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpStockMapper;
import cn.iocoder.yudao.module.erp.service.stock.ErpStockService; import cn.iocoder.yudao.module.erp.service.stock.ErpStockService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.dao.DuplicateKeyException; import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -32,11 +40,13 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.validation.ConstraintViolationException; import javax.validation.ConstraintViolationException;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.UnsupportedEncodingException;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
@ -49,6 +59,7 @@ import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*;
*/ */
@Service @Service
@Validated @Validated
@Slf4j
public class ErpProductServiceImpl implements ErpProductService { public class ErpProductServiceImpl implements ErpProductService {
@Resource @Resource
@ -65,17 +76,50 @@ public class ErpProductServiceImpl implements ErpProductService {
@Resource @Resource
private ErpStockMapper erpStockMapper; private ErpStockMapper erpStockMapper;
@Resource
private ProductDeviceRelMapper productDeviceRelMapper;
@Resource
private ProductMoldRelMapper productMoldRelMapper;
@Resource @Resource
@Lazy // 延迟注入 @Lazy // 延迟注入
private ErpStockService erpStockService; private ErpStockService erpStockService;
@Resource
private QrcodeRecordService qrcodeService;
@Autowired
private AutoCodeUtil autoCodeUtil;
@Override @Override
public Long createProduct(ProductSaveReqVO createReqVO) { @Transactional(rollbackFor = Exception.class)
public Long createProduct(ProductSaveReqVO createReqVO) throws UnsupportedEncodingException {
String code = createReqVO.getBarCode();
boolean autoGeneratedCode = StringUtils.isBlank(code);
ErpProductDO product = BeanUtils.toBean(createReqVO, ErpProductDO.class);
if (productMapper.selectProductExist(product)) {
throw exception(PRODUCT_NAME_AND_STANDARD_EXISTS);
}
if (autoGeneratedCode) {
code = autoCodeUtil.genSerialCode("PRODUCT_CODE_GENERATE", null);
} else {
if (productMapper.selectOne(Wrappers.<ErpProductDO>lambdaQuery()
.eq(ErpProductDO::getBarCode, code)) != null) {
throw exception(PRODUCT_CODE_EXISTS);
}
}
// TODO 芋艿:校验分类 // TODO 芋艿:校验分类
// 插入 // 插入
ErpProductDO product = BeanUtils.toBean(createReqVO, ErpProductDO.class);
ErpProductCategoryDO productCategory = productCategoryMapper.selectById(product.getCategoryId()); ErpProductCategoryDO productCategory = productCategoryMapper.selectById(product.getCategoryId());
Long id = productCategory.getParentId(); Long id = productCategory.getParentId();
product.setSubCategoryName(productCategory.getName()); product.setSubCategoryName(productCategory.getName());
@ -85,12 +129,74 @@ public class ErpProductServiceImpl implements ErpProductService {
product.setCategoryId(id); product.setCategoryId(id);
id = productCategory.getParentId(); id = productCategory.getParentId();
} }
// 自动生成才拼接 分类编码-流水号;手工输入则原样保存
if (autoGeneratedCode) {
product.setBarCode(productCategory.getCode() + "-" + code);
} else {
product.setBarCode(code);
}
productMapper.insert(product); productMapper.insert(product);
//插入关联设备
List<Long> deviceIds = createReqVO.getDeviceIds();
if (CollUtil.isNotEmpty(deviceIds)) {
List<Long> distinctIds = deviceIds.stream().distinct().collect(Collectors.toList());
List<ProductDeviceRelDO> relList = distinctIds.stream()
.map(deviceId -> {
ProductDeviceRelDO rel = new ProductDeviceRelDO();
rel.setProductId(product.getId());
rel.setDeviceId(deviceId);
return rel;
})
.collect(Collectors.toList());
productDeviceRelMapper.insertBatch(relList);
}
// 插入关联模具
List<Long> moldIds = createReqVO.getMoldIds();
if (CollUtil.isNotEmpty(moldIds)) {
List<Long> distinctIds = moldIds.stream().distinct().collect(Collectors.toList());
List<ProductMoldRelDO> relList = distinctIds.stream()
.map(moldId -> {
ProductMoldRelDO rel = new ProductMoldRelDO();
rel.setProductId(product.getId());
rel.setMoldId(moldId);
return rel;
})
.collect(Collectors.toList());
productMoldRelMapper.insertBatch(relList);
}
// 生成二维码
CodeTypeEnum codeType = autoCodeUtil.queryCodeType("PRODUCT_CODE_GENERATE");
if (codeType==null){
log.warn("[创建产品物料]未配置码类型跳过生产ruleCode={}","PRODUCT_CODE_GENERATE");
return product.getId();
}
qrcodeService.generateOrRefresh(
QrcodeBizTypeEnum.PRODUCT,
product.getId(),
product.getBarCode(),
"DETAIL",
codeType
);
// 返回 // 返回
return product.getId(); return product.getId();
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void updateProduct(ProductSaveReqVO updateReqVO) { public void updateProduct(ProductSaveReqVO updateReqVO) {
// TODO 芋艿:校验分类 // TODO 芋艿:校验分类
// 校验存在 // 校验存在
@ -107,6 +213,49 @@ public class ErpProductServiceImpl implements ErpProductService {
id = productCategory.getParentId(); id = productCategory.getParentId();
} }
productMapper.updateById(updateObj); productMapper.updateById(updateObj);
// 先删除旧关联(推荐逻辑删;如果你们没做逻辑删,也可以物理删)
productDeviceRelMapper.delete(Wrappers.<ProductDeviceRelDO>lambdaQuery()
.eq(ProductDeviceRelDO::getProductId,updateObj.getId()));
// 再插入新关联
List<Long> deviceIds = updateReqVO.getDeviceIds();
if (CollUtil.isNotEmpty(deviceIds)) {
List<Long> distinctIds = deviceIds.stream().distinct().collect(Collectors.toList());
List<ProductDeviceRelDO> relList = distinctIds.stream()
.map(deviceId -> {
ProductDeviceRelDO rel = new ProductDeviceRelDO();
rel.setProductId(updateReqVO.getId());
rel.setDeviceId(deviceId);
return rel;
})
.collect(Collectors.toList());
productDeviceRelMapper.insertBatch(relList);
}
// 删除旧模具关联
productMoldRelMapper.delete(Wrappers.<ProductMoldRelDO>lambdaQuery()
.eq(ProductMoldRelDO::getProductId, updateObj.getId()));
// 新增模具关联
List<Long> moldIds = updateReqVO.getMoldIds();
if (CollUtil.isNotEmpty(moldIds)) {
List<Long> distinctIds = moldIds.stream().distinct().collect(Collectors.toList());
List<ProductMoldRelDO> relList = distinctIds.stream()
.map(moldId -> {
ProductMoldRelDO rel = new ProductMoldRelDO();
rel.setProductId(updateReqVO.getId());
rel.setMoldId(moldId);
return rel;
})
.collect(Collectors.toList());
productMoldRelMapper.insertBatch(relList);
}
} }
@Override @Override
@ -153,10 +302,61 @@ public class ErpProductServiceImpl implements ErpProductService {
} }
@Override @Override
public ErpProductDO getProduct(Long id) { public ErpProductRespVO getProduct(Long id) {
return productMapper.selectById(id); ErpProductDO product = productMapper.selectById(id);
if (product == null) {
return null;
}
String qrcodeUrl = qrcodeService.selectQrcodeUrlByIdAndCode(
QrcodeBizTypeEnum.PRODUCT.getCode(), id, product.getBarCode());
product.setQrcodeUrl(qrcodeUrl);
ErpProductRespVO respVO = BeanUtils.toBean(product, ErpProductRespVO.class);
respVO.setDevices(productMapper.selectDevicesByProductId(id));
respVO.setMolds(productMapper.selectMoldsByProductId(id));
//
// respVO.setDeviceIds(respVO.getDevices().stream()
// .map(ProductRelationRespVO::getId)
// .collect(Collectors.toList()));
// respVO.setMoldIds(respVO.getMolds().stream()
// .map(ProductRelationRespVO::getId)
// .collect(Collectors.toList()));
return respVO;
} }
@Override
public ErpProductRespVO getProduct(Long id, String code) {
if (id != null) {
ErpProductRespVO product = getProduct(id);
if (product != null) {
Integer templateType = 0;
if (product.getCategoryId() == 2 ) {
templateType = 1; // 打印模板产品值
} else if(product.getCategoryId() == 5){
templateType = 5; // 打印模板备件值
}
String template = productMapper.selectPrintTemplate(templateType);
product.setTemplateJson(template);
}
return product;
}
if (StringUtils.isNotBlank(code)) {
ErpProductDO product = productMapper.selectOne(new LambdaQueryWrapperX<ErpProductDO>()
.like(ErpProductDO::getBarCode, code)
.orderByDesc(ErpProductDO::getId)
.last("LIMIT 1"));
if (product == null) {
throw exception(PRODUCT_NOT_EXISTS);
}
}
throw exception(PRODUCT_NOT_EXISTS);
}
@Override @Override
public List<ErpProductRespVO> getProductVOListByStatus(Integer status,Integer categoryId) { public List<ErpProductRespVO> getProductVOListByStatus(Integer status,Integer categoryId) {
@ -178,7 +378,7 @@ public class ErpProductServiceImpl implements ErpProductService {
if (CollUtil.isEmpty(ids)) { if (CollUtil.isEmpty(ids)) {
return Collections.emptyList(); return Collections.emptyList();
} }
List<ErpProductDO> list = productMapper.selectBatchIds(ids); List<ErpProductDO> list = productMapper.selectListByIdsWithDeleted(ids);
return buildProductVOList(list); return buildProductVOList(list);
} }
@ -205,6 +405,9 @@ public class ErpProductServiceImpl implements ErpProductService {
subCategory -> product.setSubCategoryName(subCategory.getName())); subCategory -> product.setSubCategoryName(subCategory.getName()));
MapUtils.findAndThen(unitMap, product.getUnitId(), MapUtils.findAndThen(unitMap, product.getUnitId(),
unit -> product.setUnitName(unit.getName())); unit -> product.setUnitName(unit.getName()));
if (Boolean.TRUE.equals(product.getDeleted())) {
product.setName(product.getName() + "(已被删除)");
}
}); });
} }
@ -324,6 +527,26 @@ public class ErpProductServiceImpl implements ErpProductService {
return respVO; return respVO;
} }
@Override
public void regenerateCode(Long id, String code) throws UnsupportedEncodingException {
if(productMapper.selectById(id)==null){
throw exception(PRODUCT_NOT_EXISTS);
}
if(StringUtils.isBlank(code)){
throw exception(PRODUCT_CODE_NOT_EXISTS);
}
CodeTypeEnum moldCodeGenerate = autoCodeUtil.queryCodeType("PRODUCT_CODE_GENERATE");
//s
qrcodeService.regenerateByCodeType(
QrcodeBizTypeEnum.PRODUCT,
id,
code,
"DETAIL",
moldCodeGenerate.getCode()
);
}
private ErpProductDO convertToProductDO(ErpProductImportExcelVO importProduct) { private ErpProductDO convertToProductDO(ErpProductImportExcelVO importProduct) {
ErpProductDO productDO = BeanUtils.toBean(importProduct, ErpProductDO.class); ErpProductDO productDO = BeanUtils.toBean(importProduct, ErpProductDO.class);

@ -1,7 +1,9 @@
package cn.iocoder.yudao.module.erp.service.product; package cn.iocoder.yudao.module.erp.service.product;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitImportExcelVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitPageReqVO; import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitPageReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitRespVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitSaveReqVO; import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitSaveReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO; import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO;
@ -106,4 +108,6 @@ public interface ErpProductUnitService {
* @return * @return
*/ */
ErpProductUnitDO getProductUnitByName(String name); ErpProductUnitDO getProductUnitByName(String name);
void importUnitList(List<ErpProductUnitImportExcelVO> list, Boolean updateSupport);
} }

@ -1,9 +1,15 @@
package cn.iocoder.yudao.module.erp.service.product; package cn.iocoder.yudao.module.erp.service.product;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.exception.ErrorCode; import cn.iocoder.yudao.framework.common.exception.ErrorCode;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitImportExcelVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitPageReqVO; import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitPageReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitRespVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitSaveReqVO; import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitSaveReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO; import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO;
import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductUnitMapper; import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductUnitMapper;
@ -12,14 +18,17 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collection; import javax.validation.ConstraintViolationException;
import java.util.List; import java.util.*;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
/** /**
* ERP Service * ERP Service
@ -37,6 +46,7 @@ public class ErpProductUnitServiceImpl implements ErpProductUnitService {
@Lazy // 延迟加载,避免循环依赖 @Lazy // 延迟加载,避免循环依赖
private ErpProductService productService; private ErpProductService productService;
@Override @Override
public Long createProductUnit(ErpProductUnitSaveReqVO createReqVO) { public Long createProductUnit(ErpProductUnitSaveReqVO createReqVO) {
// 1. 校验名字唯一 // 1. 校验名字唯一
@ -130,10 +140,45 @@ public class ErpProductUnitServiceImpl implements ErpProductUnitService {
public ErpProductUnitDO getProductUnitByName(String name) { public ErpProductUnitDO getProductUnitByName(String name) {
return productUnitMapper.selectByName(name); return productUnitMapper.selectByName(name);
} }
@Override @Override
public List<ErpProductUnitDO> getProductUnitListByFlag() { public List<ErpProductUnitDO> getProductUnitListByFlag() {
QueryWrapper<ErpProductUnitDO> wrapper = new QueryWrapper<>(); QueryWrapper<ErpProductUnitDO> wrapper = new QueryWrapper<>();
wrapper.eq("primary_flag", "Y"); wrapper.eq("primary_flag", "Y");
return productUnitMapper.selectList(wrapper); return productUnitMapper.selectList(wrapper);
} }
@Override
@Transactional(rollbackFor = Exception.class) // 添加事务,异常则回滚所有导入
public void importUnitList(List<ErpProductUnitImportExcelVO> list, Boolean updateSupport) {
// 1.1 参数校验
if (CollUtil.isEmpty(list)) {
throw exception(IMPORT_LIST_IS_EMPTY);
}
// 1.2 查询主单位数据
QueryWrapper<ErpProductUnitDO> wrapper = new QueryWrapper<>();
wrapper.eq("primary_flag", "Y");
List<ErpProductUnitDO> erpProductUnitDOS = productUnitMapper.selectList(wrapper);
Map<String, List<ErpProductUnitDO>> map = erpProductUnitDOS.stream().filter(Objects::nonNull)
.collect(Collectors.groupingBy(
ErpProductUnitDO::getName,
Collectors.toList()
));
List<ErpProductUnitDO> erpProductUnitDOs = new ArrayList<>();
list.stream().forEach(importUser -> {
if(importUser.getPrimaryName()!=null){
List<ErpProductUnitDO> erpProductUnitDOS1 = map.get(importUser.getPrimaryName());
if (CollUtil.isEmpty(erpProductUnitDOS1)) {
importUser.setPrimaryId(null);
} else {
importUser.setPrimaryId(erpProductUnitDOS1.get(0).getId());
}
}
ErpProductUnitDO erpProductUnitDO = BeanUtils.toBean(importUser, ErpProductUnitDO.class);
erpProductUnitDOs.add(erpProductUnitDO);
});
CollUtil.isNotEmpty(erpProductUnitDOs);productUnitMapper.insertBatch(erpProductUnitDOs);
}
} }

@ -0,0 +1,57 @@
package cn.iocoder.yudao.module.erp.service.productdevicerel;
import java.util.*;
import cn.iocoder.yudao.module.erp.controller.admin.productdevicerel.vo.*;
import cn.iocoder.yudao.module.erp.dal.dataobject.productdevicerel.ProductDeviceRelDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import javax.validation.Valid;
/**
* - Service
*
* @author
*/
public interface ProductDeviceRelService {
/**
* -
*
* @param createReqVO
* @return
*/
Long createProductDeviceRel(@Valid ProductDeviceRelSaveReqVO createReqVO);
/**
* -
*
* @param updateReqVO
*/
void updateProductDeviceRel(@Valid ProductDeviceRelSaveReqVO updateReqVO);
/**
* -
*
* @param id
*/
void deleteProductDeviceRel(Long id);
/**
* -
*
* @param id
* @return -
*/
ProductDeviceRelDO getProductDeviceRel(Long id);
/**
* -
*
* @param pageReqVO
* @return -
*/
PageResult<ProductDeviceRelDO> getProductDeviceRelPage(ProductDeviceRelPageReqVO pageReqVO);
}

@ -0,0 +1,75 @@
package cn.iocoder.yudao.module.erp.service.productdevicerel;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import cn.iocoder.yudao.module.erp.controller.admin.productdevicerel.vo.*;
import cn.iocoder.yudao.module.erp.dal.dataobject.productdevicerel.ProductDeviceRelDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.erp.dal.mysql.productdevicerel.ProductDeviceRelMapper;
import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*;
/**
* - Service
*
* @author
*/
@Service
@Validated
public class ProductDeviceRelServiceImpl implements ProductDeviceRelService {
@Resource
private ProductDeviceRelMapper productDeviceRelMapper;
@Override
public Long createProductDeviceRel(ProductDeviceRelSaveReqVO createReqVO) {
// 插入
ProductDeviceRelDO productDeviceRel = BeanUtils.toBean(createReqVO, ProductDeviceRelDO.class);
productDeviceRelMapper.insert(productDeviceRel);
// 返回
return productDeviceRel.getId();
}
@Override
public void updateProductDeviceRel(ProductDeviceRelSaveReqVO updateReqVO) {
// 校验存在
validateProductDeviceRelExists(updateReqVO.getId());
// 更新
ProductDeviceRelDO updateObj = BeanUtils.toBean(updateReqVO, ProductDeviceRelDO.class);
productDeviceRelMapper.updateById(updateObj);
}
@Override
public void deleteProductDeviceRel(Long id) {
// 校验存在
validateProductDeviceRelExists(id);
// 删除
productDeviceRelMapper.deleteById(id);
}
private void validateProductDeviceRelExists(Long id) {
if (productDeviceRelMapper.selectById(id) == null) {
throw exception(PRODUCT_DEVICE_REL_NOT_EXISTS);
}
}
@Override
public ProductDeviceRelDO getProductDeviceRel(Long id) {
return productDeviceRelMapper.selectById(id);
}
@Override
public PageResult<ProductDeviceRelDO> getProductDeviceRelPage(ProductDeviceRelPageReqVO pageReqVO) {
return productDeviceRelMapper.selectPage(pageReqVO);
}
}

@ -0,0 +1,55 @@
package cn.iocoder.yudao.module.erp.service.productmoldrel;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.erp.controller.admin.productmoldrel.vo.*;
import cn.iocoder.yudao.module.erp.dal.dataobject.productmoldrel.ProductMoldRelDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
/**
* - Service
*
* @author
*/
public interface ProductMoldRelService {
/**
* -
*
* @param createReqVO
* @return
*/
Long createProductMoldRel(@Valid ProductMoldRelSaveReqVO createReqVO);
/**
* -
*
* @param updateReqVO
*/
void updateProductMoldRel(@Valid ProductMoldRelSaveReqVO updateReqVO);
/**
* -
*
* @param id
*/
void deleteProductMoldRel(Long id);
/**
* -
*
* @param id
* @return -
*/
ProductMoldRelDO getProductMoldRel(Long id);
/**
* -
*
* @param pageReqVO
* @return -
*/
PageResult<ProductMoldRelDO> getProductMoldRelPage(ProductMoldRelPageReqVO pageReqVO);
}

@ -0,0 +1,74 @@
package cn.iocoder.yudao.module.erp.service.productmoldrel;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import cn.iocoder.yudao.module.erp.controller.admin.productmoldrel.vo.*;
import cn.iocoder.yudao.module.erp.dal.dataobject.productmoldrel.ProductMoldRelDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.erp.dal.mysql.productmoldrel.ProductMoldRelMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*;
/**
* - Service
*
* @author
*/
@Service
@Validated
public class ProductMoldRelServiceImpl implements ProductMoldRelService {
@Resource
private ProductMoldRelMapper productMoldRelMapper;
@Override
public Long createProductMoldRel(ProductMoldRelSaveReqVO createReqVO) {
// 插入
ProductMoldRelDO productMoldRel = BeanUtils.toBean(createReqVO, ProductMoldRelDO.class);
productMoldRelMapper.insert(productMoldRel);
// 返回
return productMoldRel.getId();
}
@Override
public void updateProductMoldRel(ProductMoldRelSaveReqVO updateReqVO) {
// 校验存在
validateProductMoldRelExists(updateReqVO.getId());
// 更新
ProductMoldRelDO updateObj = BeanUtils.toBean(updateReqVO, ProductMoldRelDO.class);
productMoldRelMapper.updateById(updateObj);
}
@Override
public void deleteProductMoldRel(Long id) {
// 校验存在
validateProductMoldRelExists(id);
// 删除
productMoldRelMapper.deleteById(id);
}
private void validateProductMoldRelExists(Long id) {
if (productMoldRelMapper.selectById(id) == null) {
throw exception(PRODUCT_MOLD_REL_NOT_EXISTS);
}
}
@Override
public ProductMoldRelDO getProductMoldRel(Long id) {
return productMoldRelMapper.selectById(id);
}
@Override
public PageResult<ProductMoldRelDO> getProductMoldRelPage(ProductMoldRelPageReqVO pageReqVO) {
return productMoldRelMapper.selectPage(pageReqVO);
}
}

@ -91,7 +91,7 @@ public class ErpStockInServiceImpl implements ErpStockInService {
// 2.2 插入入库单项 // 2.2 插入入库单项
stockInItems.forEach(o -> { stockInItems.forEach(o -> {
o.setInId(stockIn.getId()); o.setInId(stockIn.getId());
// o.setCount(o.getCount()); o.setCount(o.getCount());
}); });
stockInItemMapper.insertBatch(stockInItems); stockInItemMapper.insertBatch(stockInItems);
// for (ErpStockInItemDO item : stockInItems) { // for (ErpStockInItemDO item : stockInItems) {

@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.common.controller.admin.mold.vo.MoldSaveReqVO; import cn.iocoder.yudao.module.common.controller.admin.mold.vo.MoldSaveReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO;
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutPageReqVO; import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutPageReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutSaveReqVO; import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutSaveReqVO;
import cn.iocoder.yudao.module.common.dal.dataobject.mold.MoldDO; import cn.iocoder.yudao.module.common.dal.dataobject.mold.MoldDO;
@ -151,9 +152,9 @@ public class ErpStockOutServiceImpl implements ErpStockOutService {
ErpStockRecordBizTypeEnum.OTHER_OUT.getType(), stockOutItem.getOutId(), stockOutItem.getId(), stockOut.getNo(),stockOut.getOutTime())); ErpStockRecordBizTypeEnum.OTHER_OUT.getType(), stockOutItem.getOutId(), stockOutItem.getId(), stockOut.getNo(),stockOut.getOutTime()));
} else { } else {
ErpProductDO productDO = productService.getProduct(stockOutItem.getProductId()); ErpProductRespVO product = productService.getProduct(stockOutItem.getProductId());
stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO( stockRecordService.createStockRecord(new ErpStockRecordCreateReqBO(
stockOutItem.getProductId(),productDO.getCategoryId(), stockOutItem.getWarehouseId(), count, stockOutItem.getProductId(),product.getCategoryId(), stockOutItem.getWarehouseId(), count,
ErpStockRecordBizTypeEnum.getTypeByName(stockOut.getOutType(),status), stockOutItem.getOutId(), stockOutItem.getId(), stockOut.getNo(),stockOut.getOutTime())); ErpStockRecordBizTypeEnum.getTypeByName(stockOut.getOutType(),status), stockOutItem.getOutId(), stockOutItem.getId(), stockOut.getNo(),stockOut.getOutTime()));
} }

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.erp.service.stock; package cn.iocoder.yudao.module.erp.service.stock;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehouseRespVO;
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehouseSaveReqVO; import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehouseSaveReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehousePageReqVO; import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehousePageReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO;
@ -58,6 +59,8 @@ public interface ErpWarehouseService {
*/ */
ErpWarehouseDO getWarehouse(Long id); ErpWarehouseDO getWarehouse(Long id);
ErpWarehouseRespVO getWarehouseDetail(Long id);
/** /**
* *
* *

@ -4,10 +4,17 @@ import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehouseSaveReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehousePageReqVO; import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehousePageReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehouseRespVO;
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehouseSaveReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.warehousearea.vo.WarehouseAreaRespVO;
import cn.iocoder.yudao.module.erp.controller.admin.warehouselocation.vo.WarehouseLocationRespVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO; import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.warehousearea.WarehouseAreaDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.warehouselocation.WarehouseLocationDO;
import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpWarehouseMapper; import cn.iocoder.yudao.module.erp.dal.mysql.stock.ErpWarehouseMapper;
import cn.iocoder.yudao.module.erp.dal.mysql.warehousearea.WarehouseAreaMapper;
import cn.iocoder.yudao.module.erp.dal.mysql.warehouselocation.WarehouseLocationMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -23,11 +30,6 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_NOT_ENABLE; import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_NOT_ENABLE;
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_NOT_EXISTS; import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_NOT_EXISTS;
/**
* ERP Service
*
* @author
*/
@Service @Service
@Validated @Validated
public class ErpWarehouseServiceImpl implements ErpWarehouseService { public class ErpWarehouseServiceImpl implements ErpWarehouseService {
@ -35,20 +37,22 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService {
@Resource @Resource
private ErpWarehouseMapper warehouseMapper; private ErpWarehouseMapper warehouseMapper;
@Resource
private WarehouseAreaMapper warehouseAreaMapper;
@Resource
private WarehouseLocationMapper warehouseLocationMapper;
@Override @Override
public Long createWarehouse(ErpWarehouseSaveReqVO createReqVO) { public Long createWarehouse(ErpWarehouseSaveReqVO createReqVO) {
// 插入
ErpWarehouseDO warehouse = BeanUtils.toBean(createReqVO, ErpWarehouseDO.class); ErpWarehouseDO warehouse = BeanUtils.toBean(createReqVO, ErpWarehouseDO.class);
warehouseMapper.insert(warehouse); warehouseMapper.insert(warehouse);
// 返回
return warehouse.getId(); return warehouse.getId();
} }
@Override @Override
public void updateWarehouse(ErpWarehouseSaveReqVO updateReqVO) { public void updateWarehouse(ErpWarehouseSaveReqVO updateReqVO) {
// 校验存在
validateWarehouseExists(updateReqVO.getId()); validateWarehouseExists(updateReqVO.getId());
// 更新
ErpWarehouseDO updateObj = BeanUtils.toBean(updateReqVO, ErpWarehouseDO.class); ErpWarehouseDO updateObj = BeanUtils.toBean(updateReqVO, ErpWarehouseDO.class);
warehouseMapper.updateById(updateObj); warehouseMapper.updateById(updateObj);
} }
@ -56,25 +60,22 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void updateWarehouseDefaultStatus(Long id, Boolean defaultStatus) { public void updateWarehouseDefaultStatus(Long id, Boolean defaultStatus) {
// 1. 校验存在
validateWarehouseExists(id); validateWarehouseExists(id);
// 2.1 如果开启,则需要关闭所有其它的默认
if (defaultStatus) { if (defaultStatus) {
ErpWarehouseDO warehouse = warehouseMapper.selectByDefaultStatus(); ErpWarehouseDO warehouse = warehouseMapper.selectByDefaultStatus();
if (warehouse != null) { if (warehouse != null) {
warehouseMapper.updateById(new ErpWarehouseDO().setId(warehouse.getId()).setDefaultStatus(false)); warehouseMapper.updateById(new ErpWarehouseDO().setId(warehouse.getId()).setDefaultStatus(false));
} }
} }
// 2.2 更新对应的默认状态
warehouseMapper.updateById(new ErpWarehouseDO().setId(id).setDefaultStatus(defaultStatus)); warehouseMapper.updateById(new ErpWarehouseDO().setId(id).setDefaultStatus(defaultStatus));
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void deleteWarehouse(Long id) { public void deleteWarehouse(Long id) {
// 校验存在
validateWarehouseExists(id); validateWarehouseExists(id);
// 删除 warehouseLocationMapper.deleteByWarehouseId(id);
warehouseAreaMapper.deleteByWarehouseId(id);
warehouseMapper.deleteById(id); warehouseMapper.deleteById(id);
} }
@ -89,6 +90,24 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService {
return warehouseMapper.selectById(id); return warehouseMapper.selectById(id);
} }
@Override
public ErpWarehouseRespVO getWarehouseDetail(Long id) {
ErpWarehouseDO warehouse = warehouseMapper.selectById(id);
if (warehouse == null) {
return null;
}
ErpWarehouseRespVO respVO = BeanUtils.toBean(warehouse, ErpWarehouseRespVO.class);
List<WarehouseAreaDO> areaList = warehouseAreaMapper.selectListByWarehouseId(id);
List<WarehouseLocationDO> locationList = warehouseLocationMapper.selectListByWarehouseId(id);
respVO.setAreaCount((long) areaList.size());
respVO.setLocationCount((long) locationList.size());
respVO.setAreaList(BeanUtils.toBean(areaList, WarehouseAreaRespVO.class));
respVO.setLocationList(BeanUtils.toBean(locationList, WarehouseLocationRespVO.class));
return respVO;
}
@Override @Override
public List<ErpWarehouseDO> validWarehouseList(Collection<Long> ids) { public List<ErpWarehouseDO> validWarehouseList(Collection<Long> ids) {
if (CollUtil.isEmpty(ids)) { if (CollUtil.isEmpty(ids)) {
@ -98,7 +117,7 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService {
Map<Long, ErpWarehouseDO> warehouseMap = convertMap(list, ErpWarehouseDO::getId); Map<Long, ErpWarehouseDO> warehouseMap = convertMap(list, ErpWarehouseDO::getId);
for (Long id : ids) { for (Long id : ids) {
ErpWarehouseDO warehouse = warehouseMap.get(id); ErpWarehouseDO warehouse = warehouseMap.get(id);
if (warehouseMap.get(id) == null) { if (warehouse == null) {
throw exception(WAREHOUSE_NOT_EXISTS); throw exception(WAREHOUSE_NOT_EXISTS);
} }
if (CommonStatusEnum.isDisable(warehouse.getStatus())) { if (CommonStatusEnum.isDisable(warehouse.getStatus())) {

@ -0,0 +1,59 @@
package cn.iocoder.yudao.module.erp.service.warehousearea;
import java.util.*;
import cn.iocoder.yudao.module.erp.controller.admin.warehousearea.vo.*;
import cn.iocoder.yudao.module.erp.dal.dataobject.warehousearea.WarehouseAreaDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import javax.validation.Valid;
/**
* ERP Service
*
* @author
*/
public interface WarehouseAreaService {
/**
* ERP
*
* @param createReqVO
* @return
*/
Long createWarehouseArea(@Valid WarehouseAreaSaveReqVO createReqVO);
/**
* ERP
*
* @param updateReqVO
*/
void updateWarehouseArea(@Valid WarehouseAreaSaveReqVO updateReqVO);
/**
* ERP
*
* @param id
*/
void deleteWarehouseArea(Long id);
/**
* ERP
*
* @param id
* @return ERP
*/
WarehouseAreaDO getWarehouseArea(Long id);
/**
* ERP
*
* @param pageReqVO
* @return ERP
*/
PageResult<WarehouseAreaDO> getWarehouseAreaPage(WarehouseAreaPageReqVO pageReqVO);
List<WarehouseAreaDO> getWarehouseListByStatus(Integer status);
List<WarehouseAreaDO> getWarehouseListByStatusAndWarehouseId(Integer status, Long warehouseId);
}

@ -0,0 +1,100 @@
package cn.iocoder.yudao.module.erp.service.warehousearea;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.erp.controller.admin.autocode.util.AutoCodeUtil;
import cn.iocoder.yudao.module.erp.controller.admin.warehousearea.vo.WarehouseAreaPageReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.warehousearea.vo.WarehouseAreaSaveReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.warehousearea.WarehouseAreaDO;
import cn.iocoder.yudao.module.erp.dal.mysql.warehousearea.WarehouseAreaMapper;
import cn.iocoder.yudao.module.erp.dal.mysql.warehouselocation.WarehouseLocationMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_AREA_CODE_EXISTS;
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_AREA_DELETE_FAIL_EXISTS_LOCATION;
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_AREA_NOT_EXISTS;
@Service
@Validated
public class WarehouseAreaServiceImpl implements WarehouseAreaService {
@Resource
private WarehouseAreaMapper warehouseAreaMapper;
@Resource
private WarehouseLocationMapper warehouseLocationMapper;
@Resource
private AutoCodeUtil autoCodeUtil;
@Override
public Long createWarehouseArea(WarehouseAreaSaveReqVO createReqVO) {
WarehouseAreaDO warehouseArea = BeanUtils.toBean(createReqVO, WarehouseAreaDO.class);
if (StringUtils.isEmpty(warehouseArea.getAreaCode())) {
warehouseArea.setAreaCode(autoCodeUtil.genSerialCode("RESERVOIR_AREA_GENERATE", null));
} else if (warehouseAreaMapper.selectByNo(warehouseArea.getAreaCode()) != null) {
throw exception(WAREHOUSE_AREA_CODE_EXISTS);
}
warehouseAreaMapper.insert(warehouseArea);
return warehouseArea.getId();
}
@Override
public void updateWarehouseArea(WarehouseAreaSaveReqVO updateReqVO) {
validateWarehouseAreaExists(updateReqVO.getId());
warehouseAreaMapper.updateById(BeanUtils.toBean(updateReqVO, WarehouseAreaDO.class));
}
@Override
public void deleteWarehouseArea(Long id) {
validateWarehouseAreaExists(id);
if (!warehouseLocationMapper.selectListByAreaId(id).isEmpty()) {
throw exception(WAREHOUSE_AREA_DELETE_FAIL_EXISTS_LOCATION);
}
warehouseAreaMapper.deleteById(id);
}
private void validateWarehouseAreaExists(Long id) {
if (warehouseAreaMapper.selectById(id) == null) {
throw exception(WAREHOUSE_AREA_NOT_EXISTS);
}
}
@Override
public WarehouseAreaDO getWarehouseArea(Long id) {
return warehouseAreaMapper.selectById(id);
}
@Override
public PageResult<WarehouseAreaDO> getWarehouseAreaPage(WarehouseAreaPageReqVO pageReqVO) {
return warehouseAreaMapper.selectPage(pageReqVO);
}
@Override
public List<WarehouseAreaDO> getWarehouseListByStatus(Integer status) {
return warehouseAreaMapper.selectListByStatus(status);
}
@Override
public List<WarehouseAreaDO> getWarehouseListByStatusAndWarehouseId(Integer status, Long warehouseId) {
List<WarehouseAreaDO> list = warehouseAreaMapper.selectListByStatus(status);
if (warehouseId == null) {
return list;
}
List<WarehouseAreaDO> result = new ArrayList<>();
for (WarehouseAreaDO item : list) {
if (warehouseId.equals(item.getWarehouseId())) {
result.add(item);
}
}
return result;
}
}

@ -0,0 +1,58 @@
package cn.iocoder.yudao.module.erp.service.warehouselocation;
import java.util.*;
import cn.iocoder.yudao.module.erp.controller.admin.warehouselocation.vo.*;
import cn.iocoder.yudao.module.erp.dal.dataobject.warehouselocation.WarehouseLocationDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import javax.validation.Valid;
/**
* ERP Service
*
* @author
*/
public interface WarehouseLocationService {
/**
* ERP
*
* @param createReqVO
* @return
*/
Long createWarehouseLocation(@Valid WarehouseLocationSaveReqVO createReqVO);
/**
* ERP
*
* @param updateReqVO
*/
void updateWarehouseLocation(@Valid WarehouseLocationSaveReqVO updateReqVO);
/**
* ERP
*
* @param id
*/
void deleteWarehouseLocation(Long id);
/**
* ERP
*
* @param id
* @return ERP
*/
WarehouseLocationDO getWarehouseLocation(Long id);
List<WarehouseLocationDO> getWarehouseLocationListByStatus(Integer status);
/**
* ERP
*
* @param pageReqVO
* @return ERP
*/
PageResult<WarehouseLocationDO> getWarehouseLocationPage(WarehouseLocationPageReqVO pageReqVO);
}

@ -0,0 +1,95 @@
package cn.iocoder.yudao.module.erp.service.warehouselocation;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.erp.controller.admin.autocode.util.AutoCodeUtil;
import cn.iocoder.yudao.module.erp.controller.admin.warehouselocation.vo.WarehouseLocationPageReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.warehouselocation.vo.WarehouseLocationSaveReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.warehousearea.WarehouseAreaDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.warehouselocation.WarehouseLocationDO;
import cn.iocoder.yudao.module.erp.dal.mysql.warehousearea.WarehouseAreaMapper;
import cn.iocoder.yudao.module.erp.dal.mysql.warehouselocation.WarehouseLocationMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_AREA_NOT_EXISTS;
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_LOCATION_CODE_EXISTS;
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_LOCATION_NOT_EXISTS;
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_LOCATION_WAREHOUSE_AREA_NOT_MATCH;
@Service
@Validated
public class WarehouseLocationServiceImpl implements WarehouseLocationService {
@Resource
private WarehouseLocationMapper warehouseLocationMapper;
@Resource
private WarehouseAreaMapper warehouseAreaMapper;
@Resource
private AutoCodeUtil autoCodeUtil;
@Override
public Long createWarehouseLocation(WarehouseLocationSaveReqVO createReqVO) {
validateWarehouseAreaMatch(createReqVO.getWarehouseId(), createReqVO.getAreaId());
WarehouseLocationDO warehouseLocation = BeanUtils.toBean(createReqVO, WarehouseLocationDO.class);
if (StringUtils.isEmpty(warehouseLocation.getCode())) {
warehouseLocation.setCode(autoCodeUtil.genSerialCode("RESERVOIR_AREA_GENERATE", null));
} else if (warehouseLocationMapper.selectByNo(warehouseLocation.getCode()) != null) {
throw exception(WAREHOUSE_LOCATION_CODE_EXISTS);
}
warehouseLocationMapper.insert(warehouseLocation);
return warehouseLocation.getId();
}
@Override
public void updateWarehouseLocation(WarehouseLocationSaveReqVO updateReqVO) {
validateWarehouseLocationExists(updateReqVO.getId());
validateWarehouseAreaMatch(updateReqVO.getWarehouseId(), updateReqVO.getAreaId());
warehouseLocationMapper.updateById(BeanUtils.toBean(updateReqVO, WarehouseLocationDO.class));
}
@Override
public void deleteWarehouseLocation(Long id) {
validateWarehouseLocationExists(id);
warehouseLocationMapper.deleteById(id);
}
private void validateWarehouseLocationExists(Long id) {
if (warehouseLocationMapper.selectById(id) == null) {
throw exception(WAREHOUSE_LOCATION_NOT_EXISTS);
}
}
private void validateWarehouseAreaMatch(Long warehouseId, Long areaId) {
WarehouseAreaDO area = warehouseAreaMapper.selectById(areaId);
if (area == null) {
throw exception(WAREHOUSE_AREA_NOT_EXISTS);
}
if (warehouseId == null || !warehouseId.equals(area.getWarehouseId())) {
throw exception(WAREHOUSE_LOCATION_WAREHOUSE_AREA_NOT_MATCH);
}
}
@Override
public WarehouseLocationDO getWarehouseLocation(Long id) {
return warehouseLocationMapper.selectById(id);
}
@Override
public List<WarehouseLocationDO> getWarehouseLocationListByStatus(Integer status) {
return warehouseLocationMapper.selectListByStatus(status);
}
@Override
public PageResult<WarehouseLocationDO> getWarehouseLocationPage(WarehouseLocationPageReqVO pageReqVO) {
return warehouseLocationMapper.selectPage(pageReqVO);
}
}

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="selectListByIdsWithDeleted" resultType="cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO">
SELECT id, name, bar_code, category_id, sub_category_id, sub_category_name, unit_id,
status, standard, remark, expiry_day, weight, purchase_price, sale_price,
min_price, safety_number, create_time, update_time, creator, updater, deleted
FROM erp_product
WHERE id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<select id="selectDevicesByProductId"
resultType="cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductRelationRespVO">
SELECT DISTINCT
rel.device_id AS id,
CASE
WHEN d.id IS NULL THEN CONCAT('设备[', rel.device_id, '](已被删除)')
WHEN d.deleted = b'1' THEN CONCAT(d.device_name, '(', d.device_code, ')(已被删除)')
ELSE CONCAT(d.device_name, '(', d.device_code, ')')
END AS name
FROM erp_product_device_rel rel
LEFT JOIN mes_device_ledger d ON rel.device_id = d.id
WHERE rel.product_id = #{productId}
AND rel.deleted = b'0'
</select>
<select id="selectMoldsByProductId"
resultType="cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductRelationRespVO">
SELECT DISTINCT
rel.mold_id AS id,
CASE
WHEN m.id IS NULL THEN CONCAT('模具[', rel.mold_id, ']【已删除】')
WHEN m.deleted = b'1' THEN CONCAT(m.name, '(', m.code, ')【已删除】')
ELSE CONCAT(m.name, '(', m.code, ')')
END AS name
FROM erp_product_mold_rel rel
LEFT JOIN erp_mold m ON rel.mold_id = m.id
WHERE rel.product_id = #{productId}
AND rel.deleted = b'0'
</select>
<select id="selectPrintTemplate" resultType="java.lang.String">
select template_json
from mes_print_template
where deleted = 0
and template_type = #{templateType}
</select>
</mapper>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.erp.dal.mysql.productdevicerel.ProductDeviceRelMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.erp.dal.mysql.productmoldrel.ProductMoldRelMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.erp.dal.mysql.warehousearea.WarehouseAreaMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.erp.dal.mysql.warehouselocation.WarehouseLocationMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

@ -40,4 +40,7 @@ public interface FileApi {
*/ */
Map<String,String> createFile(String name, String path, byte[] content); Map<String,String> createFile(String name, String path, byte[] content);
Long getFileByPath(String path);
void deleteFile(Long id) throws Exception;
} }

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.infra.api.file; package cn.iocoder.yudao.module.infra.api.file;
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
import cn.iocoder.yudao.module.infra.service.file.FileService; import cn.iocoder.yudao.module.infra.service.file.FileService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -24,4 +25,13 @@ public class FileApiImpl implements FileApi {
return fileService.createFile(name, path, content); return fileService.createFile(name, path, content);
} }
@Override
public Long getFileByPath(String path) {
return fileService.getFileByPath(path).getId();
}
@Override
public void deleteFile(Long id) throws Exception {
fileService.deleteFile(id);
}
} }

@ -23,6 +23,7 @@ public class SecurityConfiguration {
@Override @Override
public void customize(AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry registry) { public void customize(AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry registry) {
// Swagger 接口文档 // Swagger 接口文档
String aa="";
registry.requestMatchers("/v3/api-docs/**").permitAll() registry.requestMatchers("/v3/api-docs/**").permitAll()
.requestMatchers("/webjars/**").permitAll() .requestMatchers("/webjars/**").permitAll()
.requestMatchers("/swagger-ui.html").permitAll() .requestMatchers("/swagger-ui.html").permitAll()
@ -37,6 +38,40 @@ public class SecurityConfiguration {
.requestMatchers(adminSeverContextPath + "/**").permitAll(); .requestMatchers(adminSeverContextPath + "/**").permitAll();
// 文件读取 // 文件读取
registry.requestMatchers(buildAdminApi("/infra/file/*/get/**")).permitAll(); registry.requestMatchers(buildAdminApi("/infra/file/*/get/**")).permitAll();
//大屏跳转
registry.requestMatchers(buildAdminApi("/mes/plan/getProductPlans")).permitAll();
registry.requestMatchers(buildAdminApi("/mes/plan/getPlanCapacity")).permitAll();
registry.requestMatchers(buildAdminApi("/mes/plan/getWeekTrend")).permitAll();
registry.requestMatchers(buildAdminApi("/mes/plan/getLastSevenDaysCompletedCount")).permitAll();
registry.requestMatchers(buildAdminApi("/iot/device-operation-record/deviceOperationList")).permitAll();
registry.requestMatchers(buildAdminApi("/mes/plan/getLastDaysRate")).permitAll();
registry.requestMatchers(buildAdminApi("/mes/energy-type/list")).permitAll();
registry.requestMatchers(buildAdminApi("/mes/energy-device/latestSevenDaysStatistics")).permitAll();
registry.requestMatchers(buildAdminApi("/iot/device/getDeviceOperationalStatus")).permitAll();
registry.requestMatchers(buildAdminApi("/iot/device-warinning-record/getLastSevenHoursCount")).permitAll();
registry.requestMatchers(buildAdminApi("/mes/dashboard/getTaskStatistics")).permitAll();
registry.requestMatchers(buildAdminApi("/mes/dashboard/getAllTaskList")).permitAll();
registry.requestMatchers(buildAdminApi("/iot/device/device-attribute/batchList")).permitAll();
registry.requestMatchers(buildAdminApi("/mes/energy-device/lastEnergyStatistics")).permitAll();
registry.requestMatchers(buildAdminApi("/iot/device-warinning-record/getList")).permitAll();
} }
}; };

@ -65,4 +65,7 @@ public interface FileService {
*/ */
FilePresignedUrlRespVO getFilePresignedUrl(String path) throws Exception; FilePresignedUrlRespVO getFilePresignedUrl(String path) throws Exception;
FileDO getFileByPath(String path);
} }

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save