mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
bug1454修改
This commit is contained in:
+1
-1
@@ -159,7 +159,7 @@ public class PlateManageController {
|
||||
@RequestParam(value = "organId") Long organId,
|
||||
HttpServletResponse response) throws Exception {
|
||||
ExcelReadUtil excelReadUtil = new ExcelReadUtil();
|
||||
PlateExcelListener listener = new PlateExcelListener();
|
||||
PlateExcelListener listener = new PlateExcelListener(updateSupport, plateService);
|
||||
List<PlateImportExcelVO> list = excelReadUtil.read(file, PlateImportExcelVO.class, listener);
|
||||
|
||||
// 判断文件是否导入成功
|
||||
|
||||
+6
-6
@@ -42,12 +42,12 @@ public class PlateImportExcelVO {
|
||||
|
||||
@ExcelProperty("宽度")
|
||||
@ColumnWidth(10)
|
||||
@NotEmpty(message = "宽度不能为空")
|
||||
// @NotEmpty(message = "宽度不能为空")
|
||||
private String width;
|
||||
|
||||
@ExcelProperty("高度")// float(8,3)
|
||||
@ExcelProperty("长度")// float(8,3)
|
||||
@ColumnWidth(10)
|
||||
@NotEmpty(message = "高度不能为空")
|
||||
// @NotEmpty(message = "长度不能为空")
|
||||
private String height;
|
||||
|
||||
@ExcelProperty("*厚度")
|
||||
@@ -56,18 +56,18 @@ public class PlateImportExcelVO {
|
||||
private String thickness;
|
||||
|
||||
@ExcelProperty("规格")
|
||||
@NotEmpty(message = "规格不能为空")
|
||||
// @NotEmpty(message = "规格不能为空")
|
||||
private String spec;
|
||||
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ExcelProperty("品牌")
|
||||
@NotEmpty(message = "品牌不能为空")
|
||||
// @NotEmpty(message = "品牌不能为空")
|
||||
private String brand;
|
||||
|
||||
@ExcelProperty("价格")
|
||||
@NotEmpty(message = "价格不能为空")
|
||||
// @NotEmpty(message = "价格不能为空")
|
||||
private String price;
|
||||
|
||||
@ExcelProperty("上传结果")
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public class PlateRespVO {
|
||||
private Double width;
|
||||
|
||||
@Schema(description = "高度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("高度")
|
||||
@ExcelProperty("长度")
|
||||
private Double height;
|
||||
|
||||
@Schema(description = "厚度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
|
||||
+2
-2
@@ -101,8 +101,8 @@ public interface PlateGoodMapper extends BaseMapperX<PlateGoodDO> {
|
||||
.in(PlateGoodDO::getGoodsId, goodsId));
|
||||
}
|
||||
|
||||
default PlateGoodDO selectByGoodID(String goodId , Long organId) {
|
||||
return selectOne(PlateGoodDO::getGoodsId, goodId, PlateGoodDO::getOrganId, organId);
|
||||
default PlateGoodDO selectByGoodID(String goodId , Long organId, boolean deleted) {
|
||||
return selectOne(PlateGoodDO::getGoodsId, goodId, PlateGoodDO::getOrganId, organId, PlateGoodDO::getDeleted, deleted);
|
||||
}
|
||||
|
||||
default PageResult<PlateGoodDO> selectPage(PlatePageReqVO reqVO) {
|
||||
|
||||
+39
-8
@@ -1,9 +1,12 @@
|
||||
package com.cf.imes.module.executor.service.manage.plate;
|
||||
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.cf.imes.framework.dict.core.util.DictFrameworkUtils;
|
||||
import com.cf.imes.module.executor.controller.admin.manage.plate.vo.plate.PlateImportExcelVO;
|
||||
import com.cf.imes.module.executor.enums.DictTypeConstants;
|
||||
import com.cf.imes.module.executor.util.file.ExcelListener;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -23,6 +26,15 @@ public final class PlateExcelListener<T> extends ExcelListener<PlateImportExcelV
|
||||
|
||||
private Map<Integer, String> valueMap = new HashMap<>();
|
||||
|
||||
private boolean updateSupport; // 是否更新
|
||||
|
||||
private PlateManageService plateManageService;
|
||||
|
||||
public PlateExcelListener(boolean updateSupport, PlateManageService plateManageService) {
|
||||
this.updateSupport = updateSupport;
|
||||
this.plateManageService = plateManageService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 每解析一行都会回调invoke()方法
|
||||
*
|
||||
@@ -35,14 +47,19 @@ public final class PlateExcelListener<T> extends ExcelListener<PlateImportExcelV
|
||||
data.setResult("板材【*】信息请填写完整");
|
||||
this.flag = false;
|
||||
}
|
||||
checkData(data.getHeight(),"高度",data);
|
||||
checkData(data.getHeight(),"长度",data);
|
||||
checkData(data.getWidth(),"宽度",data);
|
||||
setIfInvalid(data.getThickness(),"厚度",data);
|
||||
checkData(data.getThickness(),"厚度",data);
|
||||
if (data.getPrice() == null || data.getPrice().equals("")) {
|
||||
data.setPrice("0");
|
||||
}
|
||||
checkData(data.getPrice(),"价格",data);
|
||||
checkTexture(data.getTexture(),"纹理",data);
|
||||
// 判断goodsID是否重复
|
||||
if (!updateSupport) {
|
||||
checkGoodsId(data.getGoodsId(),"物料编号",data);
|
||||
}
|
||||
// 字段长度判断
|
||||
checkLength(data.getGoodsId(),"物料编号",data,32);
|
||||
checkLength(data.getGoodsName(),"物料名称",data,64);
|
||||
@@ -59,12 +76,26 @@ public final class PlateExcelListener<T> extends ExcelListener<PlateImportExcelV
|
||||
}
|
||||
|
||||
// 错误判断
|
||||
private void checkData(String valueCheck, String head, PlateImportExcelVO data) {
|
||||
// 长宽厚、价格判断非空
|
||||
// goodsId存在判断
|
||||
private void checkGoodsId(String valueCheck, String head, PlateImportExcelVO data) {
|
||||
if (valueCheck != null && !valueCheck.equals("")) {
|
||||
String value = valueCheck.trim();
|
||||
if (plateManageService.getPlateGoods(value) != null) {
|
||||
this.flag = false;
|
||||
data.setResult(data.getResult() + "," + head + "信息重复");
|
||||
}
|
||||
}
|
||||
}
|
||||
// 非空判断
|
||||
private void setIfInvalid(String valueCheck, String head, PlateImportExcelVO data) {
|
||||
if (valueCheck == null || valueCheck.equals("")) {
|
||||
this.flag = false;
|
||||
data.setResult(data.getResult() + "," + head + "信息缺少");
|
||||
} else {
|
||||
}
|
||||
}
|
||||
private void checkData(String valueCheck, String head, PlateImportExcelVO data) {
|
||||
// 长宽厚、价格判断非空
|
||||
if (valueCheck != null && !valueCheck.equals("")) {
|
||||
try {
|
||||
if (!data.checkPrecision(Double.valueOf(valueCheck))) {
|
||||
data.setResult(data.getResult() + "," + head + "数据有误");
|
||||
@@ -81,13 +112,13 @@ public final class PlateExcelListener<T> extends ExcelListener<PlateImportExcelV
|
||||
|
||||
if (valueCheck != null && !valueCheck.equals("")) {
|
||||
String value = valueCheck.trim();
|
||||
if (!value.equals("有") && !value.equals("无")) {
|
||||
|
||||
String dictData = DictFrameworkUtils.parseDictDataValue(DictTypeConstants.PLATE_TEXTURE_TYPE, value);
|
||||
if (StringUtils.isEmpty(dictData)) {
|
||||
this.flag = false;
|
||||
data.setResult(data.getResult() + "," + head + "信息有误");
|
||||
} else if (value.equals("有")) {
|
||||
data.setTexture("有");
|
||||
} else {
|
||||
data.setTexture("无");
|
||||
data.setTexture(dictData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -53,10 +53,10 @@ public interface PlateManageService {
|
||||
/**
|
||||
* 获得板材信息表 plate_{N}
|
||||
*
|
||||
* @param id 编号
|
||||
* @param goodsId 编号
|
||||
* @return 板材信息表 plate_{N}
|
||||
*/
|
||||
PlateGoodDO getPlateGoods(String id, Long organId);
|
||||
PlateGoodDO getPlateGoods(String goodsId);
|
||||
|
||||
/**
|
||||
* 获得板材信息表 plate_{N}分页
|
||||
|
||||
+4
-3
@@ -139,8 +139,9 @@ public class PlateManageServiceImpl implements PlateManageService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlateGoodDO getPlateGoods(String id, Long organId) {
|
||||
return plateGoodMapper.selectByGoodID(id, organId);
|
||||
public PlateGoodDO getPlateGoods(String id) {
|
||||
Long organId = getOrganId(BASE_PLATE_QUERY_PERMISSION, getLoginUser().getId(), null);
|
||||
return plateGoodMapper.selectByGoodID(id, organId , false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -375,7 +376,7 @@ public class PlateManageServiceImpl implements PlateManageService {
|
||||
|
||||
// 当前组织中板材是否存在
|
||||
private void validateGoodExists(String goodsId, Long organId) {
|
||||
if (plateGoodMapper.selectByGoodID(goodsId, organId) != null) {
|
||||
if (plateGoodMapper.selectByGoodID(goodsId, organId, false) != null) {
|
||||
throw exception(ErrorCodeConstants.PLATE_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
BIN
Binary file not shown.
Reference in New Issue
Block a user