| | |
| | | return result; |
| | | } |
| | | |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | @Override |
| | | public void importPlans(MultipartFile file) { |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(!Constants.equalsInteger(user.getType(),Constants.USERTYPE.COM)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,您无权限进行该操作!"); |
| | | } |
| | | //解析excel |
| | | List<DeviceImportDTO> plansList = EasyExcelUtil.importExcel(file, 1, 1, DeviceImportDTO.class); |
| | | if(plansList == null || plansList.size()==0){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "导入数据内容有误!"); |
| | | } |
| | | |
| | | plansList.forEach(s->{ |
| | | |
| | | if (StringUtils.isBlank(s.getDeviceName()) |
| | | || s.getDeviceName().length() > 50 |
| | | || StringUtils.isBlank(s.getDepartName()) |
| | | || StringUtils.isBlank(s.getProcedureName()) |
| | | || StringUtils.isBlank(s.getProduceWarehouseLocationName()) |
| | | || StringUtils.isBlank(s.getFinishWarehouseLocationName())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"导入数据内容有误"); |
| | | } |
| | | }); |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | } |