| | |
| | | import com.alibaba.excel.exception.ExcelDataConvertException; |
| | | import org.dromara.common.core.constant.CacheConstants; |
| | | import org.dromara.common.core.constant.Constants; |
| | | import org.dromara.common.core.constant.DictConstants; |
| | | import org.dromara.common.core.exception.ServiceException; |
| | | import org.dromara.common.core.service.DictService; |
| | | import org.dromara.common.core.utils.DateUtils; |
| | |
| | | this.dictService = SpringUtils.getBean(DictService.class); |
| | | this.isUpdateSupport = isUpdateSupport; |
| | | this.operUserId = LoginHelper.getUserId(); |
| | | this.unitDictMap = dictService.getAllDictByDictType(CacheConstants.EIMS_EQU_UNIT); |
| | | this.unitDictMap = dictService.getAllDictByDictType(DictConstants.EIMS_EQU_UNIT); |
| | | } |
| | | |
| | | @Override |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | // 如果资产编号为空则跳过此条数据 |
| | | if (StringUtils.isEmpty(equVo.getAssetNo())) { |
| | | return; |
| | | } |
| | | |
| | | |
| | | EimsEquBo equ = BeanUtil.toBean(equVo, EimsEquBo.class); |
| | | equ.setStatus(dictService.getDictValue(DictConstants.EIMS_EQU_STATUS,"正常")); |
| | | // 验证是否存在这个用户 |
| | | if (ObjectUtil.isNull(eimsEquVo)) { |
| | | EimsEquBo equ = BeanUtil.toBean(equVo, EimsEquBo.class); |
| | | |
| | | // TODO 校验 |
| | | //ValidatorUtils.validate(equ); |
| | | |
| | | //添加字段默认属性 |
| | | equ.setImportStatus(dictService.getDictValue(CacheConstants.EIMS_IMPORT_STATUS,"新导入")); |
| | | equ.setImportStatus(dictService.getDictValue(DictConstants.EIMS_IMPORT_STATUS,"新导入")); |
| | | equ.setCreateBy(operUserId); |
| | | equService.insertByBo(equ); |
| | | successNum++; |
| | | successMsg.append("<br/>").append(successNum).append("、设备 ").append(equ.getEquName()).append(" 导入成功"); |
| | | } else if (isUpdateSupport) { |
| | | equ.setEquId(eimsEquVo.getEquId()); |
| | | equService.updateByBo(equ); |
| | | equ.setImportStatus(dictService.getDictValue(DictConstants.EIMS_IMPORT_STATUS,"更新")); |
| | | // TODO 执行覆盖逻辑 |
| | | //successNum++; |
| | | //successMsg.append("<br/>").append(successNum).append("、设备 ").append(equ.getEquName()).append(" 更新成功"); |
| | | successNum++; |
| | | successMsg.append("<br/>").append(successNum).append("、设备 ").append(equ.getEquName()).append(" 更新成功"); |
| | | } else { |
| | | failureNum++; |
| | | failureMsg.append("<br/>").append(failureNum).append("、设备 ").append(eimsEquVo.getEquName()).append(eimsEquVo.getAssetNo()).append(" 已存在"); |
| | |
| | | if (exception instanceof ExcelDataConvertException) { |
| | | ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException) exception; |
| | | log.error("第{}行,第{}列解析异常,数据为:{}", excelDataConvertException.getRowIndex(), |
| | | excelDataConvertException.getColumnIndex(), excelDataConvertException.getCellData()); |
| | | excelDataConvertException.getColumnIndex(), excelDataConvertException.getCellData().getData()); |
| | | } |
| | | } |
| | | |