mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-14 13:42:07 +08:00
Merge branch 'main' into 'LiuZt'
# Conflicts: # cf-module-system/cf-module-system-api/src/main/java/com/cf/imes/module/system/enums/ErrorCodeConstants.java # cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/process/ProcessGroupService.java # cf-module-system/cf-module-system-biz/src/test/java/com/cf/imes/module/system/service/process/GroupServiceImplTest.java
This commit is contained in:
+23
@@ -0,0 +1,23 @@
|
||||
package com.cf.imes.module.manage.api.plate;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.module.manage.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME) // TODO 晨丰:fallbackFactory =
|
||||
@Tag(name = "RPC 服务 - 多组织")
|
||||
public interface PlateApi {
|
||||
|
||||
String PREFIX = ApiConstants.PREFIX + "/plate";
|
||||
|
||||
@GetMapping(PREFIX +"/get")
|
||||
@Operation(summary = "获得板材信息表")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
CommonResult<Boolean> getPlate(@RequestParam("id") Long id);
|
||||
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.cf.imes.module.manage.api.plate;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.module.manage.dal.dataobject.plate.PlateDO;
|
||||
import com.cf.imes.module.manage.service.plate.PlateService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||
|
||||
public class PlateServiceImpl implements PlateApi{
|
||||
|
||||
@Resource
|
||||
private PlateService plateService;
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> getPlate(Long id) {
|
||||
PlateDO plateDO = plateService.getPlate(id);
|
||||
if (plateDO == null) {
|
||||
return success(false);
|
||||
}
|
||||
return success(true);
|
||||
}
|
||||
}
|
||||
+30
-14
@@ -1,6 +1,7 @@
|
||||
package com.cf.imes.module.manage.controller.admin.plate;
|
||||
|
||||
import com.cf.imes.module.manage.controller.admin.plate.vo.plate.*;
|
||||
import com.cf.imes.module.manage.service.plate.PlateExcelUtil;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -58,10 +59,14 @@ public class PlateController {
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除板材信息表 plate_{N}")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "编号", required = true),
|
||||
@Parameter(name = "organId", description = "板材所属组织ID")
|
||||
})
|
||||
@PreAuthorize("@ss.hasPermission('manage:plate:delete')")
|
||||
public CommonResult<Boolean> deletePlate(@RequestParam("id") Long id) {
|
||||
plateService.deletePlate(id);
|
||||
public CommonResult<Boolean> deletePlate(@RequestParam("id") Long id,
|
||||
@RequestParam(value = "organId",required = false) Long organId) {
|
||||
plateService.deletePlate(id,organId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@@ -97,30 +102,41 @@ public class PlateController {
|
||||
|
||||
@GetMapping("/get-import-template")
|
||||
@Operation(summary = "获得导入用户模板")
|
||||
@PreAuthorize("@ss.hasPermission('manage:plate:export')")
|
||||
public void importTemplate(HttpServletResponse response) throws IOException {
|
||||
// 手动创建导出 demo
|
||||
List<PlateImportExcelVO> list = Arrays.asList(
|
||||
PlateImportExcelVO.builder().goodsId(Long.parseLong("23112371")).goodsName("xixih").material("颗粒板").width(1212.3)
|
||||
.thickness(0.2).price(33333.2).brand("SexEnum.MALE.getSex()").spec("大厂").remark("测试").build(),
|
||||
PlateImportExcelVO.builder().goodsId(Long.parseLong("23112372")).goodsName("2L").material("yuanma@cf.com").width(21.6)
|
||||
.thickness(5.3).price(333.555).brand("kkkkkk").spec("大厂").remark("测试").build()
|
||||
PlateImportExcelVO.builder().goodsId("SP1123456").goodsName("xixih").material("颗粒板").width(String.valueOf(1212.3)).height(String.valueOf(12131.6))
|
||||
.thickness(String.valueOf(0.2)).brand("鹅厂").spec("大厂").remark("测试").price(String.valueOf(33333.2)).color("黑色").build(),
|
||||
PlateImportExcelVO.builder().goodsId("SP1123457").goodsName("2L").material("yuanma@cf.com").width(String.valueOf(21.6)).height(String.valueOf(12231.6))
|
||||
.thickness(String.valueOf(5.3)).brand("kkkkkk").spec("大厂").remark("测试").price(String.valueOf(333.555)).color("黑色").build()
|
||||
);
|
||||
// 输出
|
||||
ExcelUtils.write(response, "板材导入模板.xls", "板材列表", PlateImportExcelVO.class, list);
|
||||
ExcelUtils.write(response, "板材导入模板.xlsx", "板材列表", PlateImportExcelVO.class, list);
|
||||
}
|
||||
|
||||
@PostMapping("/import")
|
||||
@Operation(summary = "导入板材")
|
||||
@Parameters({
|
||||
@Parameter(name = "file", description = "Excel 文件", required = true),
|
||||
@Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true")
|
||||
@Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true"),
|
||||
@Parameter(name = "organId", description = "板材所属组织ID")
|
||||
})
|
||||
@PreAuthorize("@ss.hasPermission('manage:plate:import')")
|
||||
public CommonResult<PlateImportRespVO> importExcel(@RequestParam("file") MultipartFile file,
|
||||
@RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception {
|
||||
List<PlateImportExcelVO> list = ExcelUtils.read(file, PlateImportExcelVO.class);
|
||||
return success(plateService.importPlateList(list, updateSupport));
|
||||
// return null;
|
||||
public void importExcel(@RequestParam("file") MultipartFile file,
|
||||
@RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport,
|
||||
@RequestParam(value = "organId") Long organId,
|
||||
HttpServletResponse response) throws Exception {
|
||||
PlateExcelUtil plateExcelUtil = new PlateExcelUtil();
|
||||
List<PlateImportExcelVO> list = plateExcelUtil.read(file, PlateImportExcelVO.class);
|
||||
|
||||
// 判断文件是否导入成功
|
||||
if (!plateExcelUtil.getFlag())
|
||||
ExcelUtils.write(response, "板材导入模板.xlsx", "板材列表", PlateImportExcelVO.class, list);
|
||||
else
|
||||
plateService.importPlateList(list, updateSupport, organId);// 成功,批量导入
|
||||
|
||||
plateExcelUtil.clear();
|
||||
}
|
||||
|
||||
}
|
||||
+55
-10
@@ -1,16 +1,14 @@
|
||||
package com.cf.imes.module.manage.controller.admin.plate.vo.plate;
|
||||
|
||||
import com.cf.imes.framework.excel.core.annotations.DictFormat;
|
||||
import com.cf.imes.framework.excel.core.convert.DictConvert;
|
||||
import com.cf.imes.module.system.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
/**
|
||||
* 用户 Excel 导入 VO
|
||||
@@ -22,34 +20,81 @@ import java.time.LocalDateTime;
|
||||
@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题
|
||||
public class PlateImportExcelVO {
|
||||
|
||||
@ExcelProperty("客户的商品编号")
|
||||
private Long goodsId;
|
||||
@ExcelProperty("商品编号")
|
||||
@NotEmpty(message = "商品编号不能为空")
|
||||
private String goodsId;
|
||||
|
||||
@ExcelProperty("商品名称")
|
||||
@NotEmpty(message = "商品名称不能为空")
|
||||
private String goodsName;
|
||||
|
||||
@ExcelProperty("材质:颗粒板、欧松板、多层板、生态板、禾香板、密度板、实木、铝蜂窝板、铝塑板")
|
||||
@ExcelProperty("材质")
|
||||
@NotEmpty(message = "材质不能为空")
|
||||
private String material;
|
||||
|
||||
@ExcelProperty("颜色")
|
||||
@NotEmpty(message = "颜色不能为空")
|
||||
private String color;
|
||||
|
||||
@ExcelProperty("宽度")
|
||||
private Double width;
|
||||
@NotEmpty(message = "宽度不能为空")
|
||||
private String width;
|
||||
|
||||
@ExcelProperty("高度")// float(8,3)
|
||||
@NotEmpty(message = "高度不能为空")
|
||||
private String height;
|
||||
|
||||
@ExcelProperty("厚度")
|
||||
private Double thickness;
|
||||
@NotEmpty(message = "厚度不能为空")
|
||||
private String thickness;
|
||||
|
||||
@ExcelProperty("价格")
|
||||
private Double price;
|
||||
@NotEmpty(message = "价格不能为空")
|
||||
private String price;
|
||||
|
||||
@ExcelProperty("品牌")
|
||||
@NotEmpty(message = "品牌不能为空")
|
||||
private String brand;
|
||||
|
||||
@ExcelProperty("规格")
|
||||
@NotEmpty(message = "规格不能为空")
|
||||
private String spec;
|
||||
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ExcelProperty("上传结果")
|
||||
private String result;
|
||||
|
||||
public boolean isValidGoods() {
|
||||
return !(goodsId == null || goodsId.isEmpty() || goodsName == null || goodsName.isEmpty() || material == null ||
|
||||
material.isEmpty() || color == null || color.isEmpty() || width == null ||width.isEmpty() || height == null ||
|
||||
height.isEmpty() || height == null ||thickness.isEmpty() || brand == null || brand.isEmpty() || spec == null || spec.isEmpty());
|
||||
}
|
||||
|
||||
// 数据长度判断
|
||||
public boolean checkPrecision(Double number) {
|
||||
if (number == null) {
|
||||
return false;
|
||||
}
|
||||
// 将浮点数转换成字符串
|
||||
String numberStr = Double.toString(number);
|
||||
|
||||
// 分割整数部分和小数部分
|
||||
String[] parts = numberStr.split("\\.");
|
||||
String integerPart = parts[0];
|
||||
String decimalPart = parts.length > 1 ? parts[1] : "";
|
||||
|
||||
// 检查整数部分位数
|
||||
if (integerPart.length() > 5) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查小数部分位数
|
||||
if (decimalPart.length() > 3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+7
-6
@@ -1,7 +1,7 @@
|
||||
package com.cf.imes.module.manage.controller.admin.plate.vo.plate;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
@@ -15,10 +15,10 @@ import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH
|
||||
@ToString(callSuper = true)
|
||||
public class PlatePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "客户的商品编号", example = "9822")
|
||||
private Long goodsId;
|
||||
@Schema(description = "客户的商品编号", example = "1")
|
||||
private String goodsId;
|
||||
|
||||
@Schema(description = "商品名称", example = "李四")
|
||||
@Schema(description = "商品名称", example = "赵六")
|
||||
private String goodsName;
|
||||
|
||||
@Schema(description = "材质:颗粒板、欧松板、多层板、生态板、禾香板、密度板、实木、铝蜂窝板、铝塑板")
|
||||
@@ -36,7 +36,7 @@ public class PlatePageReqVO extends PageParam {
|
||||
@Schema(description = "厚度")
|
||||
private Double thickness;
|
||||
|
||||
@Schema(description = "价格", example = "20204")
|
||||
@Schema(description = "价格", example = "3380")
|
||||
private Double price;
|
||||
|
||||
@Schema(description = "品牌")
|
||||
@@ -45,11 +45,12 @@ public class PlatePageReqVO extends PageParam {
|
||||
@Schema(description = "规格")
|
||||
private String spec;
|
||||
|
||||
@Schema(description = "备注", example = "你猜")
|
||||
@Schema(description = "备注", example = "随便")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
private Long organId;
|
||||
}
|
||||
+12
-13
@@ -2,9 +2,7 @@ package com.cf.imes.module.manage.controller.admin.plate.vo.plate;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@@ -13,20 +11,20 @@ import com.alibaba.excel.annotation.*;
|
||||
@ExcelIgnoreUnannotated
|
||||
public class PlateRespVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "4399")
|
||||
@ExcelProperty("主键")
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelIgnore
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "客户的商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9822")
|
||||
@ExcelProperty("客户的商品编号")
|
||||
private Long goodsId;
|
||||
@Schema(description = "客户的商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("商品编号")
|
||||
private String goodsId;
|
||||
|
||||
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
||||
@ExcelProperty("商品名称")
|
||||
private String goodsName;
|
||||
|
||||
@Schema(description = "材质:颗粒板、欧松板、多层板、生态板、禾香板、密度板、实木、铝蜂窝板、铝塑板", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("材质:颗粒板、欧松板、多层板、生态板、禾香板、密度板、实木、铝蜂窝板、铝塑板")
|
||||
@ExcelProperty("材质")
|
||||
private String material;
|
||||
|
||||
@Schema(description = "颜色", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@@ -45,7 +43,7 @@ public class PlateRespVO {
|
||||
@ExcelProperty("厚度")
|
||||
private Double thickness;
|
||||
|
||||
@Schema(description = "价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "20204")
|
||||
@Schema(description = "价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "3380")
|
||||
@ExcelProperty("价格")
|
||||
private Double price;
|
||||
|
||||
@@ -57,12 +55,13 @@ public class PlateRespVO {
|
||||
@ExcelProperty("规格")
|
||||
private String spec;
|
||||
|
||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜")
|
||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
@ExcelIgnore
|
||||
private LocalDateTime createTime;
|
||||
|
||||
private Long organId;
|
||||
}
|
||||
+8
-8
@@ -9,14 +9,14 @@ import javax.validation.constraints.NotNull;
|
||||
@Data
|
||||
public class PlateSaveReqVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "4399")
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "客户的商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9822")
|
||||
@NotNull(message = "客户的商品编号不能为空")
|
||||
private Long goodsId;
|
||||
@Schema(description = "客户的商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotEmpty(message = "客户的商品编号不能为空")
|
||||
private String goodsId;
|
||||
|
||||
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
||||
@NotEmpty(message = "商品名称不能为空")
|
||||
private String goodsName;
|
||||
|
||||
@@ -40,7 +40,7 @@ public class PlateSaveReqVO {
|
||||
@NotNull(message = "厚度不能为空")
|
||||
private Double thickness;
|
||||
|
||||
@Schema(description = "价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "20204")
|
||||
@Schema(description = "价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "3380")
|
||||
@NotNull(message = "价格不能为空")
|
||||
private Double price;
|
||||
|
||||
@@ -52,8 +52,8 @@ public class PlateSaveReqVO {
|
||||
@NotEmpty(message = "规格不能为空")
|
||||
private String spec;
|
||||
|
||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜")
|
||||
@NotEmpty(message = "备注不能为空")
|
||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便")
|
||||
private String remark;
|
||||
|
||||
private Long organId;
|
||||
}
|
||||
+13
-11
@@ -4,6 +4,8 @@ import lombok.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
@@ -14,19 +16,19 @@ import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH
|
||||
@ToString(callSuper = true)
|
||||
public class RemainPlatePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "排单 ID", example = "9338")
|
||||
@Schema(description = "排单 ID", example = "16628")
|
||||
private Long planId;
|
||||
|
||||
@Schema(description = "初始排单 ID", example = "20444")
|
||||
@Schema(description = "初始排单 ID", example = "6628")
|
||||
private Long initPlanId;
|
||||
|
||||
@Schema(description = "余料板状态,0未使用,1使用中,2已使用", example = "2")
|
||||
@Schema(description = "余料板状态,0未使用,1使用中,2已使用", example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "商品 ID", example = "5748")
|
||||
private Long goodsId;
|
||||
@Schema(description = "商品 ID", example = "7425")
|
||||
private String goodsId;
|
||||
|
||||
@Schema(description = "商品名", example = "李四")
|
||||
@Schema(description = "商品名", example = "晨丰")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "材料")
|
||||
@@ -36,13 +38,13 @@ public class RemainPlatePageReqVO extends PageParam {
|
||||
private String color;
|
||||
|
||||
@Schema(description = "宽度")
|
||||
private Double width;
|
||||
private BigDecimal width;
|
||||
|
||||
@Schema(description = "长度")
|
||||
private Double length;
|
||||
private BigDecimal length;
|
||||
|
||||
@Schema(description = "厚度")
|
||||
private Double thickness;
|
||||
private BigDecimal thickness;
|
||||
|
||||
@Schema(description = "品牌")
|
||||
private String brand;
|
||||
@@ -53,10 +55,10 @@ public class RemainPlatePageReqVO extends PageParam {
|
||||
@Schema(description = "仓库名")
|
||||
private String store;
|
||||
|
||||
@Schema(description = "数量", example = "24524")
|
||||
@Schema(description = "数量", example = "18318")
|
||||
private Integer count;
|
||||
|
||||
@Schema(description = "备注", example = "你猜")
|
||||
@Schema(description = "备注", example = "随便")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "轮廊数据,Json 串")
|
||||
|
||||
+13
-12
@@ -3,6 +3,7 @@ package com.cf.imes.module.manage.controller.admin.plate.vo.remain;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@@ -11,27 +12,27 @@ import com.alibaba.excel.annotation.*;
|
||||
@ExcelIgnoreUnannotated
|
||||
public class RemainPlateRespVO {
|
||||
|
||||
@Schema(description = "余料板 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "349")
|
||||
@Schema(description = "余料板 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "16470")
|
||||
@ExcelProperty("余料板 ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "排单 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "9338")
|
||||
@Schema(description = "排单 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "16628")
|
||||
@ExcelProperty("排单 ID")
|
||||
private Long planId;
|
||||
|
||||
@Schema(description = "初始排单 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "20444")
|
||||
@Schema(description = "初始排单 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "6628")
|
||||
@ExcelProperty("初始排单 ID")
|
||||
private Long initPlanId;
|
||||
|
||||
@Schema(description = "余料板状态,0未使用,1使用中,2已使用", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@Schema(description = "余料板状态,0未使用,1使用中,2已使用", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("余料板状态,0未使用,1使用中,2已使用")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "商品 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "5748")
|
||||
@Schema(description = "商品 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "7425")
|
||||
@ExcelProperty("商品 ID")
|
||||
private Long goodsId;
|
||||
private String goodsId;
|
||||
|
||||
@Schema(description = "商品名", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||
@Schema(description = "商品名", requiredMode = Schema.RequiredMode.REQUIRED, example = "晨丰")
|
||||
@ExcelProperty("商品名")
|
||||
private String name;
|
||||
|
||||
@@ -45,15 +46,15 @@ public class RemainPlateRespVO {
|
||||
|
||||
@Schema(description = "宽度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("宽度")
|
||||
private Double width;
|
||||
private BigDecimal width;
|
||||
|
||||
@Schema(description = "长度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("长度")
|
||||
private Double length;
|
||||
private BigDecimal length;
|
||||
|
||||
@Schema(description = "厚度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("厚度")
|
||||
private Double thickness;
|
||||
private BigDecimal thickness;
|
||||
|
||||
@Schema(description = "品牌", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("品牌")
|
||||
@@ -67,11 +68,11 @@ public class RemainPlateRespVO {
|
||||
@ExcelProperty("仓库名")
|
||||
private String store;
|
||||
|
||||
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "24524")
|
||||
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "18318")
|
||||
@ExcelProperty("数量")
|
||||
private Integer count;
|
||||
|
||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜")
|
||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
+14
-13
@@ -4,31 +4,32 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Schema(description = "管理后台 - 生产单余料板表 order_remain_plate_{N}新增/修改 Request VO")
|
||||
@Data
|
||||
public class RemainPlateSaveReqVO {
|
||||
|
||||
@Schema(description = "余料板 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "349")
|
||||
@Schema(description = "余料板 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "16470")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "排单 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "9338")
|
||||
@Schema(description = "排单 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "16628")
|
||||
@NotNull(message = "排单 ID不能为空")
|
||||
private Long planId;
|
||||
|
||||
@Schema(description = "初始排单 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "20444")
|
||||
@Schema(description = "初始排单 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "6628")
|
||||
@NotNull(message = "初始排单 ID不能为空")
|
||||
private Long initPlanId;
|
||||
|
||||
@Schema(description = "余料板状态,0未使用,1使用中,2已使用", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@Schema(description = "余料板状态,0未使用,1使用中,2已使用", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "余料板状态,0未使用,1使用中,2已使用不能为空")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "商品 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "5748")
|
||||
@NotNull(message = "商品 ID不能为空")
|
||||
private Long goodsId;
|
||||
@Schema(description = "商品 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "7425")
|
||||
@NotEmpty(message = "商品 ID不能为空")
|
||||
private String goodsId;
|
||||
|
||||
@Schema(description = "商品名", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||
@Schema(description = "商品名", requiredMode = Schema.RequiredMode.REQUIRED, example = "晨丰")
|
||||
@NotEmpty(message = "商品名不能为空")
|
||||
private String name;
|
||||
|
||||
@@ -42,15 +43,15 @@ public class RemainPlateSaveReqVO {
|
||||
|
||||
@Schema(description = "宽度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "宽度不能为空")
|
||||
private Double width;
|
||||
private BigDecimal width;
|
||||
|
||||
@Schema(description = "长度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "长度不能为空")
|
||||
private Double length;
|
||||
private BigDecimal length;
|
||||
|
||||
@Schema(description = "厚度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "厚度不能为空")
|
||||
private Double thickness;
|
||||
private BigDecimal thickness;
|
||||
|
||||
@Schema(description = "品牌", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "品牌不能为空")
|
||||
@@ -64,11 +65,11 @@ public class RemainPlateSaveReqVO {
|
||||
@NotEmpty(message = "仓库名不能为空")
|
||||
private String store;
|
||||
|
||||
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "24524")
|
||||
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "18318")
|
||||
@NotNull(message = "数量不能为空")
|
||||
private Integer count;
|
||||
|
||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜")
|
||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便")
|
||||
@NotEmpty(message = "备注不能为空")
|
||||
private String remark;
|
||||
|
||||
|
||||
+7
-4
@@ -1,9 +1,7 @@
|
||||
package com.cf.imes.module.manage.dal.dataobject.plate;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
@@ -30,7 +28,7 @@ public class PlateDO extends BaseDO {
|
||||
/**
|
||||
* 客户的商品编号
|
||||
*/
|
||||
private Long goodsId;
|
||||
private String goodsId;
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
@@ -72,4 +70,9 @@ public class PlateDO extends BaseDO {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 组织id
|
||||
*/
|
||||
private Long organId;
|
||||
|
||||
}
|
||||
+7
-5
@@ -4,12 +4,14 @@ import lombok.*;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 生产单余料板表 order_remain_plate_{N} DO
|
||||
*
|
||||
* @author 晨丰科技
|
||||
*/
|
||||
@TableName("order_remain_plate_n")
|
||||
@TableName("order_remain_plate")
|
||||
@KeySequence("order_remain_plate_n_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@@ -39,7 +41,7 @@ public class RemainPlateDO extends BaseDO {
|
||||
/**
|
||||
* 商品 ID
|
||||
*/
|
||||
private Long goodsId;
|
||||
private String goodsId;
|
||||
/**
|
||||
* 商品名
|
||||
*/
|
||||
@@ -55,15 +57,15 @@ public class RemainPlateDO extends BaseDO {
|
||||
/**
|
||||
* 宽度
|
||||
*/
|
||||
private Double width;
|
||||
private BigDecimal width;
|
||||
/**
|
||||
* 长度
|
||||
*/
|
||||
private Double length;
|
||||
private BigDecimal length;
|
||||
/**
|
||||
* 厚度
|
||||
*/
|
||||
private Double thickness;
|
||||
private BigDecimal thickness;
|
||||
/**
|
||||
* 品牌
|
||||
*/
|
||||
|
||||
+8
-4
@@ -6,6 +6,7 @@ import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.module.manage.controller.admin.plate.vo.plate.PlatePageReqVO;
|
||||
import com.cf.imes.module.manage.dal.dataobject.plate.PlateDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 板材信息表 plate_{N} Mapper
|
||||
@@ -15,8 +16,8 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
@Mapper
|
||||
public interface PlateMapper extends BaseMapperX<PlateDO> {
|
||||
|
||||
default PlateDO selectByGoodID(Long goodId) {
|
||||
return selectOne(PlateDO::getGoodsId, goodId);
|
||||
default PlateDO selectByGoodID(String goodId , Long organId) {
|
||||
return selectOne(PlateDO::getGoodsId, goodId, PlateDO::getOrganId, organId);
|
||||
}
|
||||
|
||||
default PageResult<PlateDO> selectPage(PlatePageReqVO reqVO) {
|
||||
@@ -28,12 +29,15 @@ public interface PlateMapper extends BaseMapperX<PlateDO> {
|
||||
.eqIfPresent(PlateDO::getWidth, reqVO.getWidth())
|
||||
.eqIfPresent(PlateDO::getHeight, reqVO.getHeight())
|
||||
.eqIfPresent(PlateDO::getThickness, reqVO.getThickness())
|
||||
.eqIfPresent(PlateDO::getPrice, reqVO.getPrice())
|
||||
.eqIfPresent(PlateDO::getOrganId, reqVO.getOrganId())
|
||||
.eqIfPresent(PlateDO::getBrand, reqVO.getBrand())
|
||||
.eqIfPresent(PlateDO::getSpec, reqVO.getSpec())
|
||||
.eqIfPresent(PlateDO::getRemark, reqVO.getRemark())
|
||||
.eqIfPresent(PlateDO::getPrice, reqVO.getPrice())
|
||||
.eqIfPresent(PlateDO::getOrganId, reqVO.getOrganId())
|
||||
.betweenIfPresent(PlateDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(PlateDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
PlateDO selectOneById(@Param("id") Long id, @Param("organId") Long organId);
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,10 +1,11 @@
|
||||
package com.cf.imes.module.manage.framework.rpc.config;
|
||||
|
||||
import com.cf.imes.module.system.api.organ.OrganApi;
|
||||
import com.cf.imes.module.system.api.user.AdminUserApi;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableFeignClients(clients = AdminUserApi.class)
|
||||
@EnableFeignClients(clients = {AdminUserApi.class, OrganApi.class})
|
||||
public class RpcConfiguration {
|
||||
}
|
||||
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
package com.cf.imes.module.manage.service.plate;
|
||||
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.event.AnalysisEventListener;
|
||||
import com.cf.imes.module.manage.controller.admin.plate.vo.plate.PlateImportExcelVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
public final class PlateExcelListener<T> extends AnalysisEventListener<PlateImportExcelVO> {
|
||||
|
||||
/**
|
||||
* 自定义用于暂时存储data
|
||||
* 可以通过实例获取该值
|
||||
*/
|
||||
private List<PlateImportExcelVO> datas = new ArrayList<>();
|
||||
|
||||
private boolean flag = true;
|
||||
|
||||
private Map<Integer, String> valueMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 每解析一行都会回调invoke()方法
|
||||
*
|
||||
* @param data 读取后的数据对象
|
||||
* @param context 内容
|
||||
*/
|
||||
@Override
|
||||
public void invoke(PlateImportExcelVO data, AnalysisContext context) {
|
||||
if (!data.isValidGoods()) {//返回false,表示商品信息无效;否则返回true,表示商品信息有效
|
||||
data.setResult("商品关键信息缺少");
|
||||
this.flag = false;
|
||||
}
|
||||
checkData(data.getHeight(),"高度",data);
|
||||
checkData(data.getWidth(),"宽度",data);
|
||||
checkData(data.getThickness(),"厚度",data);
|
||||
checkData(data.getPrice(),"价格",data);
|
||||
if (data.getResult() != null)
|
||||
data.setResult(data.getResult().replace("null,", ""));
|
||||
valueMap.put(context.getCurrentRowNum(), data.getResult());
|
||||
datas.add(data);
|
||||
}
|
||||
|
||||
// 错误判断
|
||||
private void checkData(String valueCheck, String head, PlateImportExcelVO data) {
|
||||
// 长宽厚、价格判断非空
|
||||
if (valueCheck == null || valueCheck.equals("")) {
|
||||
this.flag = false;
|
||||
data.setResult(data.getResult() + "," + head + "信息缺少");
|
||||
} else {
|
||||
try {
|
||||
if (!data.checkPrecision(Double.valueOf(valueCheck))) {
|
||||
data.setResult(data.getResult() + "," + head + "数据有误");
|
||||
this.flag = false;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
this.flag = false;
|
||||
data.setResult(data.getResult() + "," + head + "需要填写数字");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取完后操作
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
@Override
|
||||
public void doAfterAllAnalysed(AnalysisContext context) {
|
||||
if (this.flag)
|
||||
log.info("PlateExcelListener 所有数据读取完成");
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回数据
|
||||
*
|
||||
* @return 返回读取的数据集合
|
||||
**/
|
||||
public List<PlateImportExcelVO> getDatas() {
|
||||
return datas;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回读取结果
|
||||
*
|
||||
* @return 是否读取成功
|
||||
**/
|
||||
public boolean getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回错误信息
|
||||
*
|
||||
* @return String
|
||||
**/
|
||||
public Map<Integer, String> getValueMap() {
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package com.cf.imes.module.manage.service.plate;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.ExcelWriter;
|
||||
import com.alibaba.excel.write.metadata.WriteSheet;
|
||||
import com.cf.imes.module.manage.controller.admin.plate.vo.plate.PlateImportExcelVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class PlateExcelUtil {
|
||||
|
||||
private String value;
|
||||
|
||||
private PlateExcelListener<PlateImportExcelVO> excelListener = new PlateExcelListener<>();
|
||||
|
||||
public List<PlateImportExcelVO> read(MultipartFile file, Class<PlateImportExcelVO> head) throws IOException {
|
||||
|
||||
if (file.isEmpty()) {
|
||||
value = "文件为空";
|
||||
throw new IOException("文件为空");
|
||||
} else if (!(file.getOriginalFilename().endsWith(".xlsx") || file.getOriginalFilename().endsWith(".xls"))) {
|
||||
value = "文件格式不正确";
|
||||
throw new IOException("文件格式不正确");
|
||||
} else if (file.getSize() > 1024 * 1024 * 10) {
|
||||
value = "文件大小超过 10M";
|
||||
throw new IOException("文件大小超过 10M");
|
||||
} else if (file.getSize() == 0) {
|
||||
value = "文件大小为 0";
|
||||
throw new IOException("文件大小为 0");
|
||||
} else {
|
||||
EasyExcel.read(file.getInputStream(), PlateImportExcelVO.class, excelListener)
|
||||
.autoCloseStream(true) // 不要自动关闭,交给 Servlet 自己处理
|
||||
.headRowNumber(1).sheet(0).doRead();
|
||||
//获取读取的数据
|
||||
List<PlateImportExcelVO> list = excelListener.getDatas();
|
||||
|
||||
if (excelListener.getValueMap().size() > 0)
|
||||
excelListener.getValueMap().forEach((k, v) -> {
|
||||
list.get(k - 1).setResult(v);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getFlag() {
|
||||
return excelListener.getFlag();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
excelListener.getDatas().clear();
|
||||
}
|
||||
|
||||
public Map<Integer, String> getValueMap() {
|
||||
return excelListener.getValueMap();
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -38,7 +38,7 @@ public interface PlateService {
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deletePlate(Long id);
|
||||
void deletePlate(Long id,Long organId);
|
||||
|
||||
/**
|
||||
* 获得板材信息表 plate_{N}
|
||||
@@ -63,6 +63,6 @@ public interface PlateService {
|
||||
* @param isUpdateSupport 是否支持更新
|
||||
* @return 导入结果
|
||||
*/
|
||||
PlateImportRespVO importPlateList(List<PlateImportExcelVO> importUsers, boolean isUpdateSupport);
|
||||
PlateImportRespVO importPlateList(List<PlateImportExcelVO> importUsers, boolean isUpdateSupport , Long organId);
|
||||
|
||||
}
|
||||
+62
-32
@@ -3,10 +3,13 @@ package com.cf.imes.module.manage.service.plate;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.cf.imes.framework.common.exception.ServiceException;
|
||||
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.module.manage.controller.admin.plate.vo.plate.PlateImportExcelVO;
|
||||
import com.cf.imes.module.manage.controller.admin.plate.vo.plate.PlateImportRespVO;
|
||||
import com.cf.imes.module.manage.controller.admin.plate.vo.plate.PlatePageReqVO;
|
||||
import com.cf.imes.module.manage.controller.admin.plate.vo.plate.PlateSaveReqVO;
|
||||
import com.cf.imes.module.system.api.organ.OrganApi;
|
||||
import com.cf.imes.module.system.enums.ErrorCodeConstants;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -15,7 +18,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.*;
|
||||
|
||||
import com.cf.imes.module.manage.dal.dataobject.plate.PlateDO;
|
||||
import com.cf.imes.framework.datapermission.core.util.DataPermissionUtils;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
|
||||
@@ -38,34 +40,49 @@ public class PlateServiceImpl implements PlateService {
|
||||
@Resource
|
||||
private PlateMapper plateMapper;
|
||||
|
||||
@Resource
|
||||
private OrganApi organApi;
|
||||
|
||||
@Override
|
||||
public Long createPlate(PlateSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
PlateDO plate = BeanUtils.toBean(createReqVO, PlateDO.class);
|
||||
plateMapper.insert(plate);
|
||||
if (createReqVO.getOrganId() != null && createReqVO.getOrganId() != 0 ){
|
||||
validateOrganExists(createReqVO.getOrganId());
|
||||
validateGoodExists(createReqVO.getGoodsId(), createReqVO.getOrganId());
|
||||
plate.setOrganId(OrganContextHolder.getOrganId());
|
||||
}
|
||||
plateMapper.insert(plate);// 组织id未传输
|
||||
// 返回
|
||||
return plate.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePlate(PlateSaveReqVO updateReqVO) {
|
||||
// 更新 判断是否有组织id
|
||||
if (updateReqVO.getOrganId() == null || updateReqVO.getOrganId() == 0){
|
||||
updateReqVO.setOrganId(OrganContextHolder.getOrganId());
|
||||
}else {
|
||||
validateOrganExists(updateReqVO.getOrganId());
|
||||
}
|
||||
// 校验存在
|
||||
validatePlateExists(updateReqVO.getId());
|
||||
// 更新
|
||||
validatePlateExists(updateReqVO.getId(), updateReqVO.getOrganId());
|
||||
PlateDO updateObj = BeanUtils.toBean(updateReqVO, PlateDO.class);
|
||||
plateMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePlate(Long id) {
|
||||
public void deletePlate(Long id,Long organId) {
|
||||
if (organId == null || organId == 0){
|
||||
organId = OrganContextHolder.getOrganId();
|
||||
}
|
||||
// 校验存在
|
||||
validatePlateExists(id);
|
||||
validatePlateExists(id,organId);
|
||||
// 删除
|
||||
plateMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validatePlateExists(Long id) {
|
||||
if (plateMapper.selectById(id) == null) {
|
||||
private void validatePlateExists(Long id,Long organId) {
|
||||
if (plateMapper.selectOneById(id,organId) == null) {
|
||||
throw exception(PLATE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
@@ -77,38 +94,33 @@ public class PlateServiceImpl implements PlateService {
|
||||
|
||||
@Override
|
||||
public PageResult<PlateDO> getPlatePage(PlatePageReqVO pageReqVO) {
|
||||
if (pageReqVO.getOrganId() == null || pageReqVO.getOrganId() == 0){
|
||||
pageReqVO.setOrganId(OrganContextHolder.getOrganId());
|
||||
}
|
||||
return plateMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
|
||||
private void validatePlateForCreateOrUpdate(PlateImportExcelVO importPlate) {
|
||||
// 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确
|
||||
DataPermissionUtils.executeIgnore(() -> {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class) // 添加事务,异常则回滚所有导入
|
||||
public PlateImportRespVO importPlateList(List<PlateImportExcelVO> importPlates, boolean isUpdateSupport) {
|
||||
public PlateImportRespVO importPlateList(List<PlateImportExcelVO> importPlates, boolean isUpdateSupport , Long organId) {
|
||||
if (CollUtil.isEmpty(importPlates)) {
|
||||
throw ServiceExceptionUtil.exception(ErrorCodeConstants.PLATE_IMPORT_LIST_IS_EMPTY);
|
||||
}
|
||||
validateOrganExists(organId);
|
||||
PlateImportRespVO respVO = PlateImportRespVO.builder().createPlateNames(new ArrayList<>())
|
||||
.updatePlateNames(new ArrayList<>()).failurePlateNames(new LinkedHashMap<>()).build();
|
||||
// 批量插入集合
|
||||
List<PlateDO> insertList = new ArrayList<>();
|
||||
// 批量更新集合
|
||||
List<PlateDO> updateList = new ArrayList<>();
|
||||
importPlates.forEach(importPlate -> {
|
||||
// 校验,判断是否有不符合的原因 校验全部是否为空
|
||||
try {
|
||||
validatePlateForCreateOrUpdate(importPlate);
|
||||
} catch (ServiceException ex) {
|
||||
respVO.getFailurePlateNames().put(importPlate.getGoodsName() , ex.getMessage());
|
||||
return;
|
||||
}
|
||||
// 判断如果不存在,在进行插入
|
||||
PlateDO existPlate = plateMapper.selectByGoodID(importPlate.getGoodsId());
|
||||
PlateDO existPlate = plateMapper.selectByGoodID(importPlate.getGoodsId(), organId);
|
||||
if (existPlate == null) {
|
||||
plateMapper.insert(BeanUtils.toBean(importPlate, PlateDO.class));
|
||||
respVO.getCreatePlateNames().add(importPlate.getGoodsName());
|
||||
insertList.add(BeanUtils.toBean(importPlate, PlateDO.class).setOrganId(organId));
|
||||
// plateMapper.insert(BeanUtils.toBean(importPlate, PlateDO.class).setOrganId(organId));
|
||||
// respVO.getCreatePlateNames().add(importPlate.getGoodsName());
|
||||
return;
|
||||
}
|
||||
// 如果存在,判断是否允许更新
|
||||
@@ -116,15 +128,33 @@ public class PlateServiceImpl implements PlateService {
|
||||
respVO.getFailurePlateNames().put(importPlate.getGoodsName(), ErrorCodeConstants.PLATE_EXISTS.getMsg());
|
||||
return;
|
||||
}
|
||||
PlateDO updateUser = BeanUtils.toBean(importPlate, PlateDO.class);
|
||||
updateUser.setId(existPlate.getId());
|
||||
plateMapper.updateById(updateUser);
|
||||
respVO.getUpdatePlateNames().add(importPlate.getGoodsName());
|
||||
PlateDO plateDO = BeanUtils.toBean(importPlate, PlateDO.class).setOrganId(organId).setId(existPlate.getId());
|
||||
updateList.add(plateDO);
|
||||
// plateMapper.updateById(plateDO);
|
||||
// respVO.getUpdatePlateNames().add(importPlate.getGoodsName());
|
||||
});
|
||||
// 批量插入,批量更新
|
||||
if (insertList.size() > 0 && insertList != null) {
|
||||
plateMapper.insertBatch(insertList);
|
||||
}
|
||||
if (updateList.size() > 0 && updateList != null) {
|
||||
plateMapper.updateBatch(updateList);
|
||||
}
|
||||
return respVO;
|
||||
}
|
||||
|
||||
private void validateOrganExists(Long organId) {
|
||||
CommonResult<Boolean> index = organApi.validOrgan(organId);
|
||||
if (!index.isSuccess()) {
|
||||
throw exception(ErrorCodeConstants.ORGAN_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 当前组织中板材是否存在
|
||||
private void validateGoodExists(String goodsId ,Long organId) {
|
||||
if (plateMapper.selectByGoodID(goodsId ,organId) != null){
|
||||
throw exception(ErrorCodeConstants.PLATE_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -151,7 +151,7 @@ chenfeng:
|
||||
organ: # 多组织相关配置项
|
||||
enable: true
|
||||
ignore-urls:
|
||||
- /admin-api/manage/test
|
||||
- /rpc-api/**
|
||||
ignore-tables:
|
||||
- test
|
||||
sms-code: # 短信验证码相关的配置项
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<?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="com.cf.imes.module.manage.dal.mysql.plate.PlateMapper">
|
||||
|
||||
<select id="selectOneById" resultType="com.cf.imes.module.manage.dal.dataobject.plate.PlateDO">
|
||||
SELECT
|
||||
id,
|
||||
goods_id,
|
||||
organ_id,
|
||||
goods_name,
|
||||
material,
|
||||
color,
|
||||
width,
|
||||
height,
|
||||
thickness,
|
||||
brand,
|
||||
spec,
|
||||
remark,
|
||||
creator,
|
||||
create_time,
|
||||
updater,
|
||||
update_time,
|
||||
deleted,
|
||||
price
|
||||
FROM
|
||||
plate
|
||||
where organ_id = #{organId} and id = #{id} and deleted = 0
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user