|
@@ -29,6 +29,7 @@ import java.text.SimpleDateFormat;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class EquFrockTestRecordServiceImpl extends ServiceImpl<EquFrockTestRecordDao, EquFrockTestRecordDo> implements EquFrockTestRecordService {
|
|
public class EquFrockTestRecordServiceImpl extends ServiceImpl<EquFrockTestRecordDao, EquFrockTestRecordDo> implements EquFrockTestRecordService {
|
|
@@ -57,6 +58,8 @@ public class EquFrockTestRecordServiceImpl extends ServiceImpl<EquFrockTestRecor
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
SysUserVo currentUser = CommonUtils.getCurrentUser();
|
|
SysUserVo currentUser = CommonUtils.getCurrentUser();
|
|
Date date = new Date();
|
|
Date date = new Date();
|
|
|
|
+ String regex = "^(\\-|\\+)?\\d+(\\.\\d+)?$";//只能是数字
|
|
|
|
+ Pattern pattern = Pattern.compile(regex);
|
|
|
|
|
|
for (int i = 2; i <= lastRowNum; i++) {
|
|
for (int i = 2; i <= lastRowNum; i++) {
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
@@ -84,22 +87,22 @@ public class EquFrockTestRecordServiceImpl extends ServiceImpl<EquFrockTestRecor
|
|
String state = row.getCell(17) == null ? "" : row.getCell(17).toString().trim();
|
|
String state = row.getCell(17) == null ? "" : row.getCell(17).toString().trim();
|
|
String remark = row.getCell(18) == null ? "" : row.getCell(18).toString().trim();
|
|
String remark = row.getCell(18) == null ? "" : row.getCell(18).toString().trim();
|
|
if (StringUtils.isBlank(ownedfactory)) {
|
|
if (StringUtils.isBlank(ownedfactory)) {
|
|
- stringBuilder.append("所属工厂不能为空 ");
|
|
|
|
|
|
+ stringBuilder.append("所属工厂必填 ");
|
|
}
|
|
}
|
|
if (StringUtils.isBlank(frockname)) {
|
|
if (StringUtils.isBlank(frockname)) {
|
|
- stringBuilder.append("工装名称不能为空 ");
|
|
|
|
|
|
+ stringBuilder.append("工装名称必填 ");
|
|
}
|
|
}
|
|
if (StringUtils.isBlank(usedept)) {
|
|
if (StringUtils.isBlank(usedept)) {
|
|
- stringBuilder.append("使用车间不能为空 ");
|
|
|
|
|
|
+ stringBuilder.append("使用车间必填 ");
|
|
}
|
|
}
|
|
String testdate = "";
|
|
String testdate = "";
|
|
if (StringUtils.isBlank(exctestdate)) {
|
|
if (StringUtils.isBlank(exctestdate)) {
|
|
- stringBuilder.append("检定日期不能为空 ");
|
|
|
|
|
|
+ stringBuilder.append("检定日期必填 ");
|
|
} else {
|
|
} else {
|
|
testdate = dateFormat.format(DateUtils.importExcelFormatExcel((XSSFCell) row.getCell(6))).split(" ")[0];
|
|
testdate = dateFormat.format(DateUtils.importExcelFormatExcel((XSSFCell) row.getCell(6))).split(" ")[0];
|
|
}
|
|
}
|
|
if (StringUtils.isBlank(frocknum)) {
|
|
if (StringUtils.isBlank(frocknum)) {
|
|
- stringBuilder.append("工装编号不能为空 ");
|
|
|
|
|
|
+ stringBuilder.append("工装编号必填 ");
|
|
} else {
|
|
} else {
|
|
if (equFrockListDoList.stream().anyMatch(item -> item.getFrocknum().equals(frocknum))) {
|
|
if (equFrockListDoList.stream().anyMatch(item -> item.getFrocknum().equals(frocknum))) {
|
|
if (equFrockTestRecordDoList.stream().anyMatch(item -> item.getFrocknum().equals(frocknum) && item.getTestdate().toString().equals(exctestdate))) {
|
|
if (equFrockTestRecordDoList.stream().anyMatch(item -> item.getFrocknum().equals(frocknum) && item.getTestdate().toString().equals(exctestdate))) {
|
|
@@ -110,60 +113,40 @@ public class EquFrockTestRecordServiceImpl extends ServiceImpl<EquFrockTestRecor
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (StringUtils.isBlank(belongequname)) {
|
|
if (StringUtils.isBlank(belongequname)) {
|
|
- stringBuilder.append("工装所属不能为空 ");
|
|
|
|
|
|
+ stringBuilder.append("工装所属必填 ");
|
|
}
|
|
}
|
|
if (StringUtils.isBlank(state)) {
|
|
if (StringUtils.isBlank(state)) {
|
|
- stringBuilder.append("状态不能为空 ");
|
|
|
|
|
|
+ stringBuilder.append("状态必填 ");
|
|
}
|
|
}
|
|
- if (StringUtils.isNotBlank(diameter)) {
|
|
|
|
- diameter = StringUtil.formatDecimal(diameter);
|
|
|
|
- } else {
|
|
|
|
- stringBuilder.append("直径mm不能为空 ");
|
|
|
|
|
|
+ if (StringUtils.isBlank(diameter) || !pattern.matcher(diameter).matches()) {
|
|
|
|
+ stringBuilder.append("直径mm必填且只能为数字 ");
|
|
}
|
|
}
|
|
- if (StringUtils.isNotBlank(hs1)) {
|
|
|
|
- hs1 = StringUtil.formatDecimal(hs1);
|
|
|
|
- } else {
|
|
|
|
- stringBuilder.append("检测硬度值(HS1)不能为空 ");
|
|
|
|
|
|
+ if (StringUtils.isBlank(hs1) || !pattern.matcher(hs1).matches()) {
|
|
|
|
+ stringBuilder.append("检测硬度值(HS1)必填且只能为数字 ");
|
|
}
|
|
}
|
|
- if (StringUtils.isNotBlank(hs2)) {
|
|
|
|
- hs2 = StringUtil.formatDecimal(hs2);
|
|
|
|
- } else {
|
|
|
|
- stringBuilder.append("检测硬度值(HS2)不能为空 ");
|
|
|
|
|
|
+ if (StringUtils.isBlank(hs2) || !pattern.matcher(hs2).matches()) {
|
|
|
|
+ stringBuilder.append("检测硬度值(HS2)必填且只能为数字 ");
|
|
}
|
|
}
|
|
- if (StringUtils.isNotBlank(hs3)) {
|
|
|
|
- hs3 = StringUtil.formatDecimal(hs3);
|
|
|
|
- } else {
|
|
|
|
- stringBuilder.append("检测硬度值(HS3)不能为空 ");
|
|
|
|
|
|
+ if (StringUtils.isBlank(hs3) || !pattern.matcher(hs3).matches()) {
|
|
|
|
+ stringBuilder.append("检测硬度值(HS3)必填且只能为数字 ");
|
|
}
|
|
}
|
|
- if (StringUtils.isNotBlank(hs4)) {
|
|
|
|
- hs4 = StringUtil.formatDecimal(hs4);
|
|
|
|
- } else {
|
|
|
|
- stringBuilder.append("检测硬度值(HS4)不能为空 ");
|
|
|
|
|
|
+ if (StringUtils.isBlank(hs4) || !pattern.matcher(hs4).matches()) {
|
|
|
|
+ stringBuilder.append("检测硬度值(HS4)必填且只能为数字 ");
|
|
}
|
|
}
|
|
- if (StringUtils.isNotBlank(hs5)) {
|
|
|
|
- hs5 = StringUtil.formatDecimal(hs5);
|
|
|
|
- } else {
|
|
|
|
- stringBuilder.append("检测硬度值(HS5)不能为空 ");
|
|
|
|
|
|
+ if (StringUtils.isBlank(hs5) || !pattern.matcher(hs5).matches()) {
|
|
|
|
+ stringBuilder.append("检测硬度值(HS5)必填且只能为数字 ");
|
|
}
|
|
}
|
|
- if (StringUtils.isNotBlank(hs6)) {
|
|
|
|
- hs6 = StringUtil.formatDecimal(hs6);
|
|
|
|
- } else {
|
|
|
|
- stringBuilder.append("检测硬度值(HS6)不能为空 ");
|
|
|
|
|
|
+ if (StringUtils.isBlank(hs6) || !pattern.matcher(hs6).matches()) {
|
|
|
|
+ stringBuilder.append("检测硬度值(HS6)必填且只能为数字 ");
|
|
}
|
|
}
|
|
- if (StringUtils.isNotBlank(hs7)) {
|
|
|
|
- hs7 = StringUtil.formatDecimal(hs7);
|
|
|
|
- } else {
|
|
|
|
- stringBuilder.append("检测硬度值(HS7)不能为空 ");
|
|
|
|
|
|
+ if (StringUtils.isBlank(hs7) || !pattern.matcher(hs7).matches()) {
|
|
|
|
+ stringBuilder.append("检测硬度值(HS7)必填且只能为数字 ");
|
|
}
|
|
}
|
|
- if (StringUtils.isNotBlank(hs8)) {
|
|
|
|
- hs8 = StringUtil.formatDecimal(hs8);
|
|
|
|
- } else {
|
|
|
|
- stringBuilder.append("检测硬度值(HS8)不能为空 ");
|
|
|
|
|
|
+ if (StringUtils.isBlank(hs8) || !pattern.matcher(hs8).matches()) {
|
|
|
|
+ stringBuilder.append("检测硬度值(HS8)必填且只能为数字 ");
|
|
}
|
|
}
|
|
- if (StringUtils.isNotBlank(hs9)) {
|
|
|
|
- hs9 = StringUtil.formatDecimal(hs9);
|
|
|
|
- } else {
|
|
|
|
- stringBuilder.append("检测硬度值(HS9)不能为空 ");
|
|
|
|
|
|
+ if (StringUtils.isBlank(hs9) || !pattern.matcher(hs9).matches()) {
|
|
|
|
+ stringBuilder.append("检测硬度值(HS9)必填且只能为数字 ");
|
|
}
|
|
}
|
|
if (equFrockTestRecordDos.stream().anyMatch(item -> item.getFrocknum().equals(frocknum) && item.getTestdate().toString().equals(exctestdate))) {
|
|
if (equFrockTestRecordDos.stream().anyMatch(item -> item.getFrocknum().equals(frocknum) && item.getTestdate().toString().equals(exctestdate))) {
|
|
stringBuilder.append("工装编号" + frocknum + "、检定日期" + testdate + "数据重复");
|
|
stringBuilder.append("工装编号" + frocknum + "、检定日期" + testdate + "数据重复");
|
|
@@ -211,7 +194,7 @@ public class EquFrockTestRecordServiceImpl extends ServiceImpl<EquFrockTestRecor
|
|
} else {
|
|
} else {
|
|
if (equFrockTestRecordDos.size() > 0) {
|
|
if (equFrockTestRecordDos.size() > 0) {
|
|
if (equFrockTestRecordService.saveOrUpdateBatch(equFrockTestRecordDos)) {
|
|
if (equFrockTestRecordService.saveOrUpdateBatch(equFrockTestRecordDos)) {
|
|
- return R.ok();
|
|
|
|
|
|
+ return R.ok("上传成功");
|
|
} else {
|
|
} else {
|
|
return R.error("上传失败");
|
|
return R.error("上传失败");
|
|
}
|
|
}
|