Compare commits
10 Commits
liutao_bra
...
main
| Author | SHA1 | Date |
|---|---|---|
|
|
a86d70c0a6 | 9 hours ago |
|
|
5b7456c50a | 10 hours ago |
|
|
977a16e6c9 | 5 days ago |
|
|
bc9159c1ac | 1 week ago |
|
|
04cc023b4f | 1 week ago |
|
|
835fa5b271 | 1 week ago |
|
|
1b90a076fe | 2 weeks ago |
|
|
0bbac34d67 | 2 weeks ago |
|
|
9c46da356f | 2 weeks ago |
|
|
00681c954e | 2 weeks ago |
@ -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,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,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 "未知";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@ -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,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,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";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,96 @@
|
|||||||
|
package cn.iocoder.yudao.module.iot.framework.util;
|
||||||
|
|
||||||
|
// FormulaEvalUtils
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class FormulaEvalUtils {
|
||||||
|
|
||||||
|
private FormulaEvalUtils() {}
|
||||||
|
|
||||||
|
public static BigDecimal evalExpr(JSONObject node, Map<String, Object> vars) {
|
||||||
|
if (node == null) return BigDecimal.ZERO;
|
||||||
|
|
||||||
|
if (node.containsKey("field")) {
|
||||||
|
Object value = vars.get(node.getString("field"));
|
||||||
|
return toBigDecimal(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.containsKey("value")) {
|
||||||
|
return toBigDecimal(node.get("value"));
|
||||||
|
}
|
||||||
|
|
||||||
|
String op = node.getString("op");
|
||||||
|
BigDecimal left = evalExpr(node.getJSONObject("left"), vars);
|
||||||
|
BigDecimal right = evalExpr(node.getJSONObject("right"), vars);
|
||||||
|
return apply(left, right, op);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
public static BigDecimal evalStepArrayByCode(JSONArray steps, Map<String, Object> vars) {
|
||||||
|
if (steps == null || steps.isEmpty()) {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal result = null;
|
||||||
|
String pendingBigOp = null; // 上一步的 bigOperator
|
||||||
|
|
||||||
|
for (int i = 0; i < steps.size(); i++) {
|
||||||
|
JSONObject step = steps.getJSONObject(i);
|
||||||
|
if (step == null) continue;
|
||||||
|
|
||||||
|
String code = step.getString("code");
|
||||||
|
String operator = step.getString("operator");
|
||||||
|
Object valueObj = step.get("value");
|
||||||
|
|
||||||
|
BigDecimal codeValue = readCodeValue(code, vars);
|
||||||
|
BigDecimal value = toBigDecimal(valueObj);
|
||||||
|
BigDecimal current = apply(codeValue, value, operator); // A/B/C
|
||||||
|
|
||||||
|
if (result == null) {
|
||||||
|
result = current;
|
||||||
|
} else {
|
||||||
|
result = apply(result, current, pendingBigOp); // 用上一项的 bigOperator
|
||||||
|
}
|
||||||
|
|
||||||
|
pendingBigOp = step.getString("bigOperator"); // 留给下一轮使用
|
||||||
|
}
|
||||||
|
|
||||||
|
return result == null ? BigDecimal.ZERO : result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BigDecimal readCodeValue(String code, Map<String, Object> vars) {
|
||||||
|
if (StringUtils.isBlank(code) || vars == null) {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
return toBigDecimal(vars.get(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BigDecimal toBigDecimal(Object raw) {
|
||||||
|
if (raw == null || StringUtils.isBlank(String.valueOf(raw))) {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
return new BigDecimal(String.valueOf(raw));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BigDecimal apply(BigDecimal left, BigDecimal right, String op) {
|
||||||
|
if (StringUtils.isBlank(op)) {
|
||||||
|
return left;
|
||||||
|
}
|
||||||
|
switch (op) {
|
||||||
|
case "+": return left.add(right);
|
||||||
|
case "-": return left.subtract(right);
|
||||||
|
case "*": return left.multiply(right);
|
||||||
|
case "/":
|
||||||
|
if (right.compareTo(BigDecimal.ZERO) == 0) return BigDecimal.ZERO;
|
||||||
|
return left.divide(right, 6, RoundingMode.HALF_UP);
|
||||||
|
default: throw new IllegalArgumentException("Unsupported op: " + op);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue