|
@@ -55,6 +55,7 @@ import com.platform.dao.util.compare.FieldComparedUtils;
|
|
import com.platform.dao.vo.SysUserDeptVO;
|
|
import com.platform.dao.vo.SysUserDeptVO;
|
|
import com.platform.dao.vo.SysUserVO;
|
|
import com.platform.dao.vo.SysUserVO;
|
|
import com.platform.dao.vo.export.sb.ExportSbInfoVO;
|
|
import com.platform.dao.vo.export.sb.ExportSbInfoVO;
|
|
|
|
+import com.platform.dao.vo.export.sb.ExportYiBiaoSbInfoVO;
|
|
import com.platform.dao.vo.query.sb.SbChangeRecordVO;
|
|
import com.platform.dao.vo.query.sb.SbChangeRecordVO;
|
|
import com.platform.dao.vo.query.upms.SysDeptVO;
|
|
import com.platform.dao.vo.query.upms.SysDeptVO;
|
|
import com.platform.dao.vo.report.SbInfoTypeReportVO;
|
|
import com.platform.dao.vo.report.SbInfoTypeReportVO;
|
|
@@ -2841,6 +2842,241 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public String importYiBiaoListByUpdateALl(MultipartFile file) {
|
|
|
|
+ List<FirmProducer> producerList = firmProducerMapper.selectAll(); // 生产厂商
|
|
|
|
+ List<SbPosition> positionList = sbPositionMapper.selectAll(); // 设备位置
|
|
|
|
+ List<SbType> typeList = sbTypeMapper.selectAll(); // 设备类型集合
|
|
|
|
+ List<SbInfo> addList = new ArrayList<>(); // 待导入集合
|
|
|
|
+ List<SysUser> users = sysUserMapper.selectAll(); // 用户集合
|
|
|
|
+ List<String> addTypeList = new ArrayList<>();
|
|
|
|
+ try {
|
|
|
|
+ List<ExportYiBiaoSbInfoVO> list = ExcelUtil.importExcel(file.getInputStream(), ExportYiBiaoSbInfoVO.class, 1);
|
|
|
|
+ if (CollectionUtil.isNotEmpty(list)) {
|
|
|
|
+ int i = 2;
|
|
|
|
+ for (ExportYiBiaoSbInfoVO vo : list) {
|
|
|
|
+ i++;
|
|
|
|
+ // 如果有检定周期,就是需要检定
|
|
|
|
+ SbInfo tempInfo = BeanConverterUtil.copyObjectProperties(vo, SbInfo.class);
|
|
|
|
+// if (vo.getSeatNumber() == null) {
|
|
|
|
+// tempInfo.setSeatNumber(30);// 如果为空默认30天提醒
|
|
|
|
+// }
|
|
|
|
+ // 对必填字段进行判断
|
|
|
|
+ if (StringUtils.isBlank(vo.getPositionNo())) {
|
|
|
|
+ throw new BusinessException("第" + i + "行,位号为空,位号为必填项目,请填写;");// 编号为空,复制位号
|
|
|
|
+ }
|
|
|
|
+// if (vo.getIsFinancing() == 1 && StringUtils.isBlank(vo.getFinancingNo())) {
|
|
|
|
+// throw new BusinessException("第" + i + "行,是固定资产,但是资产编号为空,请填写;");// 编号为空,复制位号
|
|
|
|
+// }
|
|
|
|
+ if (StringUtils.isBlank(vo.getName())) {
|
|
|
|
+ throw new BusinessException("第" + i + "行,名称为空,请填写;");// 编号为空,复制位号
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(vo.getModel())) {
|
|
|
|
+ throw new BusinessException("第" + i + "行,型号为空,请填写;");// 编号为空,复制位号
|
|
|
|
+ }
|
|
|
|
+ if (vo.getDph()!=null&&vo.getDph().trim()!=""){
|
|
|
|
+ tempInfo.setDph(vo.getDph());
|
|
|
|
+ }
|
|
|
|
+ if (vo.getNo()!=null&&vo.getNo().trim()!=""){
|
|
|
|
+ tempInfo.setNo(vo.getNo());
|
|
|
|
+ }
|
|
|
|
+// if (vo.getLevel() == null || vo.getLevel() < 1 || vo.getLevel() > 3) {
|
|
|
|
+// throw new BusinessException("第" + i + "行,等级为空,A级请填1,B级填2,C级填3;");// 编号为空,复制位号
|
|
|
|
+// }
|
|
|
|
+// if (vo.getUseType() == null || vo.getUseType() < 3 || vo.getUseType() > 5) {
|
|
|
|
+// throw new BusinessException("第" + i + "行,自定义类型为空,生产设备请填3,计量设备填4,特种设备填5;");// 编号为空,复制位号
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+// if (vo.getIdentifyNo()!=null&&vo.getIdentifyNo().trim()!=""){
|
|
|
|
+// tempInfo.setIdentifyNo(vo.getIdentifyNo());
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// if (vo.getUseNo()!=null&&vo.getUseNo().trim()!=""){
|
|
|
|
+// tempInfo.setUseNo(vo.getUseNo());
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// if (vo.getSbCode()!=null&&vo.getSbCode().trim()!=""){
|
|
|
|
+// tempInfo.setSbCode(vo.getSbCode());
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// if (vo.getInstallUnit()!=null&&vo.getInstallUnit().trim()!=""){
|
|
|
|
+// tempInfo.setInstallUnit(vo.getInstallUnit());
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// if (vo.getExamResult()!=null&&vo.getExamResult().trim()!=""){
|
|
|
|
+// tempInfo.setExamResult(vo.getExamResult());
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// if (vo.getUsePosition()!=null&&vo.getUsePosition().trim()!=""){
|
|
|
|
+// tempInfo.setUsePosition(vo.getUsePosition());
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// if (vo.getUseType() == 4) {
|
|
|
|
+// tempInfo.setIsChild(1);
|
|
|
|
+// } else {
|
|
|
|
+// tempInfo.setIsChild(0);
|
|
|
|
+// }
|
|
|
|
+// if (vo.getStatus() == null || (vo.getStatus() != 1 && vo.getStatus() != 2 && vo.getStatus() != 7)) {
|
|
|
|
+// throw new BusinessException("第" + i + "行,状态为空或者状态不对,在库请填1,使用中填2,停用中填7");// 编号为空,复制位号
|
|
|
|
+// }
|
|
|
|
+ if (StringUtils.isBlank(vo.getCph())) {
|
|
|
|
+ tempInfo.setCph(vo.getPositionNo());// 编号为空,复制位号
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(vo.getPositionNo())) {
|
|
|
|
+ tempInfo.setPositionNo(vo.getPositionNo());// 编号为空,复制位号
|
|
|
|
+ }
|
|
|
|
+// if (StringUtils.isNotEmpty(vo.getPpNo())) {
|
|
|
|
+// tempInfo.setIsChild(1);
|
|
|
|
+// }
|
|
|
|
+// if (StringUtils.isNotEmpty(vo.getFinancingNo())) {
|
|
|
|
+// tempInfo.setIsFinancing(1);
|
|
|
|
+// }
|
|
|
|
+// if (vo.getCheckPeriod() != null) {
|
|
|
|
+// tempInfo.setIsMeasure(1);
|
|
|
|
+// }
|
|
|
|
+// if (vo.getCheckPeriod() != null) {
|
|
|
|
+// tempInfo.setIsMeasure(1);
|
|
|
|
+// }
|
|
|
|
+ if (vo.getCheckType()!=null){
|
|
|
|
+ if (vo.getCheckType() instanceof Integer&&(vo.getCheckType()==1||vo.getCheckType()==2)) {
|
|
|
|
+ tempInfo.setCheckType(vo.getCheckType());
|
|
|
|
+ }else {
|
|
|
|
+ throw new BusinessException("第" + i + "行,检定是否强检填写有误,请检查!");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (tempInfo.getIsMeasure() != null && tempInfo.getIsMeasure() == 1) {
|
|
|
|
+ if (tempInfo.getNextCheckDate() == null) {
|
|
|
|
+ if (tempInfo.getCheckDate() != null) {
|
|
|
|
+ if (tempInfo.getCheckPeriod() != null) {
|
|
|
|
+ tempInfo.setNextCheckDate(tempInfo.getCheckDate().plusMonths(tempInfo.getCheckPeriod()));
|
|
|
|
+ } else {
|
|
|
|
+ throw new BusinessException("需要检定的设备,检定周期必填");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ throw new BusinessException("需要检定的设备,检定日期必填");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 如果是仪表组,则是自检
|
|
|
|
+ if (StringUtils.isNotEmpty(vo.getDph()) && vo.getDph().equals("仪表组")) {
|
|
|
|
+ tempInfo.setIsSelf(YesNoEnum.YES.getValue());
|
|
|
|
+ } else {
|
|
|
|
+ tempInfo.setIsSelf(YesNoEnum.NO.getValue());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+// if (StringUtils.isNotBlank(vo.getTypeName())) { // 设备类型匹配
|
|
|
|
+// boolean findSbType = false;
|
|
|
|
+// for (SbType sbType : typeList) {
|
|
|
|
+// if (sbType.getName().equalsIgnoreCase(vo.getTypeName().trim())) {
|
|
|
|
+// tempInfo.setTypeId(sbType.getId());
|
|
|
|
+// findSbType = true;
|
|
|
|
+// break;
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// if (!findSbType) {
|
|
|
|
+// addTypeList.add(vo.getTypeName());
|
|
|
|
+// // throw new BusinessException("系统找不到该设备类型名称,请先添加设备类型, 设备类型名称" + vo.getTypeName());
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+ if (StringUtils.isNotBlank(vo.getPositionName())) { // 设备位置匹配
|
|
|
|
+ boolean findPosition = false;
|
|
|
|
+ for (SbPosition position : positionList) {
|
|
|
|
+ if (position.getName().equalsIgnoreCase(vo.getPositionName().trim())) {
|
|
|
|
+ tempInfo.setPositionId(position.getId());
|
|
|
|
+ findPosition = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!findPosition) {
|
|
|
|
+ throw new BusinessException("系统找不到位置名称,请先在基础配置中添加位置, 位置名称" + vo.getPositionName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // tempInfo.setProducerId(vo.getProducerName());
|
|
|
|
+ /*if(StringUtils.isNotBlank(vo.getProducerName())){ // 生产商匹配
|
|
|
|
+ boolean findProducer = false;
|
|
|
|
+ for (FirmProducer producer : producerList) {
|
|
|
|
+ if (producer.getName().equalsIgnoreCase(vo.getProducerName().trim())) {
|
|
|
|
+ tempInfo.setProducerId(producer.getId());
|
|
|
|
+ findProducer = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!findProducer) {
|
|
|
|
+ throw new BusinessException("找不到生产商,请先添加:" + vo.getProducerName());
|
|
|
|
+ }
|
|
|
|
+ }*/
|
|
|
|
+ /*if (StringUtils.isNotBlank(vo.getSaveUserName())) { // 使用人员
|
|
|
|
+ boolean findSaveUser = false;
|
|
|
|
+ for (SysUser user : users) {
|
|
|
|
+ if (user.getRealName().equalsIgnoreCase(vo.getSaveUserName().trim())) {
|
|
|
|
+ tempInfo.setSaveUser(user.getUserId());
|
|
|
|
+ findSaveUser = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!findSaveUser) {
|
|
|
|
+ throw new BusinessException("找不到使用人员,请先添加, 名称" + vo.getSaveUserName());
|
|
|
|
+ }
|
|
|
|
+ }*/
|
|
|
|
+ // 如果计量设备 且是需要检定
|
|
|
|
+// if (vo.getUseType() == SbUseType.BGCL.getValue() && vo.getIsMeasure() == YesNoEnum.YES.getValue()) {
|
|
|
|
+ SbInfo info = new SbInfo();
|
|
|
|
+ info.setId(vo.getId());
|
|
|
|
+ if (vo.getId()==null){
|
|
|
|
+ throw new BusinessException("第" + i + "行,id不可以为空!");
|
|
|
|
+ }
|
|
|
|
+ info = sbInfoMapper.selectOne(info);
|
|
|
|
+ if (info.getCheckDate() == null && vo.getNextCheckDate() == null) {
|
|
|
|
+ throw new BusinessException("上次和下次检定日期,不能全部为空");
|
|
|
|
+ }
|
|
|
|
+// if (vo.getNextCheckDate()!=null){
|
|
|
|
+// tempInfo.setNextCheckDate(vo.getNextCheckDate());
|
|
|
|
+// }
|
|
|
|
+// if (vo.getCheckPeriod() == null) {
|
|
|
|
+// throw new BusinessException("检定周期不能为空");
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+ // tempInfo.setId(IdGeneratorUtils.getObjectId());
|
|
|
|
+ // 检索自定义字段值
|
|
|
|
+// Class clazz = vo.getClass();
|
|
|
|
+// Field[] fields = clazz.getDeclaredFields();
|
|
|
|
+// StringBuilder paramList = new StringBuilder();
|
|
|
|
+// paramList.append("[");
|
|
|
|
+// for (Field field : fields) {
|
|
|
|
+// Method requestMethod = clazz.getMethod(getGetMethod(field.getName()));
|
|
|
|
+// Object requestVal = requestMethod.invoke(vo);
|
|
|
|
+// Excel excel = field.getAnnotation(Excel.class);
|
|
|
|
+// if (excel != null && excel.styleType() == 1 && requestVal != null) {
|
|
|
|
+// // 拼接自定义字符串
|
|
|
|
+// paramList.append("{\"name\":\"").append(excel.name()).append("\",");
|
|
|
|
+// paramList.append("\"content\":\"").append(requestVal).append("\"},");
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// String param = paramList.toString();
|
|
|
|
+// if (param.length() > 1) {
|
|
|
|
+// param = param.substring(0, param.length() - 1);
|
|
|
|
+// }
|
|
|
|
+// param += "]";
|
|
|
|
+// tempInfo.setParamList(param);
|
|
|
|
+ tempInfo.setUpdateUserName(SecurityUtils.getUserInfo().getUsername());
|
|
|
|
+ tempInfo.setUpdateUserId(SecurityUtils.getUserInfo().getUserId());
|
|
|
|
+ tempInfo.setUpdateTime(LocalDateTime.now());
|
|
|
|
+ addList.add(tempInfo);
|
|
|
|
+ mapper.updateByPrimaryKeySelective(tempInfo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (CollectionUtil.isNotEmpty(addTypeList)) {
|
|
|
|
+ throw new BusinessException(addTypeList.size() + "个设备类型名称找不到,请先添加:" + addTypeList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return "总计更新:" + (list.size());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ throw new BusinessException(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public MyVOPage<SbInfoVO> selectPageInfoForWarn(SbInfoDTO record, int pageNum, int pageSize) {
|
|
public MyVOPage<SbInfoVO> selectPageInfoForWarn(SbInfoDTO record, int pageNum, int pageSize) {
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
PageHelper.startPage(pageNum, pageSize);
|