|
@@ -1,6 +1,8 @@
|
|
|
package com.dragoninfo.dcuc.authweb.restcontroller.user.manager.utils;
|
|
|
|
|
|
|
|
|
+import com.dragoninfo.dcuc.auth.auth.entity.AuthOrgInfo;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.entity.AuthUserInfo;
|
|
|
import com.dragoninfo.dcuc.auth.auth.enumresources.YesNotEnum;
|
|
|
import com.dragoninfo.dcuc.authweb.util.UserUtils;
|
|
|
import com.dragoninfo.dcuc.user.entity.GovUserInfo;
|
|
@@ -793,4 +795,211 @@ public class ImpExcelUtils {
|
|
|
}
|
|
|
return govUserInfo;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户数据导入
|
|
|
+ * @param inputStream
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ * @throws NumberFormatException
|
|
|
+ */
|
|
|
+ public static List<AuthUserInfo> loadAuthUserInfo(InputStream inputStream) throws IOException, NumberFormatException {
|
|
|
+ List<AuthUserInfo> temp = new ArrayList();
|
|
|
+ //根据指定的文件输入流导入Excel从而产生Workbook对象
|
|
|
+ Workbook wb0 = new HSSFWorkbook(inputStream);
|
|
|
+ //获取Excel文档中的第一个表单
|
|
|
+ Sheet sht0 = wb0.getSheetAt(0);
|
|
|
+ //对Sheet中的每一行进行迭代
|
|
|
+ for (Row r : sht0) {
|
|
|
+ //如果当前行的行号(从0开始)未达到2(第三行)则从新循环
|
|
|
+ if (r.getRowNum() == 0) {
|
|
|
+ int cellNum = 0;
|
|
|
+ if (!r.getCell(cellNum++).getStringCellValue().equals("身份证号")) {
|
|
|
+ throw new NumberFormatException("缺少''身份证号''列!");
|
|
|
+ }
|
|
|
+ if (!r.getCell(cellNum++).getStringCellValue().equals("姓名")) {
|
|
|
+ throw new NumberFormatException("缺少''姓名''列!");
|
|
|
+ }
|
|
|
+ if (!r.getCell(cellNum++).getStringCellValue().equals("性别(表码)")) {
|
|
|
+ throw new NumberFormatException("缺少''性别(表码)''列!");
|
|
|
+ }
|
|
|
+ if (!r.getCell(cellNum++).getStringCellValue().equals("用户类型(表码)")) {
|
|
|
+ throw new NumberFormatException("缺少''用户类型(表码)''列!");
|
|
|
+ }
|
|
|
+ if (!r.getCell(cellNum++).getStringCellValue().equals("警号")) {
|
|
|
+ throw new NumberFormatException("缺少''警号''列!");
|
|
|
+ }
|
|
|
+ if (!r.getCell(cellNum++).getStringCellValue().equals("所属机构(机构名称)")) {
|
|
|
+ throw new NumberFormatException("缺少''所属机构(机构名称)''列!");
|
|
|
+ }
|
|
|
+ if (!r.getCell(cellNum++).getStringCellValue().equals("所属机构(机构代码)")) {
|
|
|
+ throw new NumberFormatException("缺少''所属机构(机构代码)''列!");
|
|
|
+ }
|
|
|
+ if (!r.getCell(cellNum++).getStringCellValue().equals("人员类型(表码)")) {
|
|
|
+ throw new NumberFormatException("缺少''人员类型(表码)''列!");
|
|
|
+ }
|
|
|
+ if (!r.getCell(cellNum++).getStringCellValue().equals("警种(表码)")) {
|
|
|
+ throw new NumberFormatException("缺少''警种(表码)''列!");
|
|
|
+ }
|
|
|
+ if (!r.getCell(cellNum++).getStringCellValue().equals("职级(表码)")) {
|
|
|
+ throw new NumberFormatException("缺少''职级(表码)''列!");
|
|
|
+ }
|
|
|
+ if (!r.getCell(cellNum++).getStringCellValue().equals("业务域(表码)")) {
|
|
|
+ throw new NumberFormatException("缺少''业务域(表码)''列!");
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //创建实体类
|
|
|
+ AuthUserInfo info = new AuthUserInfo();
|
|
|
+ if (r.getCell(0) == null || StringUtils.isBlank(r.getCell(0).getStringCellValue())){
|
|
|
+ throw new NumberFormatException("第" + (r.getRowNum() + 1) + "行''身份证号''为空!");
|
|
|
+ }
|
|
|
+ info.setIdcard(r.getCell(0).getStringCellValue());
|
|
|
+ if (r.getCell(1) == null || StringUtils.isBlank(r.getCell(1).getStringCellValue())){
|
|
|
+ throw new NumberFormatException("第" + (r.getRowNum() + 1) + "行''姓名''为空!");
|
|
|
+ }
|
|
|
+ info.setUserName(r.getCell(1).getStringCellValue());
|
|
|
+ if (r.getCell(2) == null || StringUtils.isBlank(r.getCell(2).getStringCellValue())){
|
|
|
+ throw new NumberFormatException("第" + (r.getRowNum() + 1) + "行''性别''为空!");
|
|
|
+ }
|
|
|
+ info.setSex(r.getCell(2).getStringCellValue());
|
|
|
+ if (r.getCell(3) == null || StringUtils.isBlank(r.getCell(3).getStringCellValue())){
|
|
|
+ throw new NumberFormatException("第" + (r.getRowNum() + 1) + "行''用户类型''为空!");
|
|
|
+ }
|
|
|
+ info.setUserType(r.getCell(3).getStringCellValue());
|
|
|
+ if (r.getCell(4) == null || StringUtils.isBlank(r.getCell(4).getStringCellValue())){
|
|
|
+ throw new NumberFormatException("第" + (r.getRowNum() + 1) + "行''警号''为空!");
|
|
|
+ }
|
|
|
+ info.setPoliceNumber(r.getCell(4).getStringCellValue());
|
|
|
+ if(info.getUserType().equals(UserTypeEnum.POLICE.getValue()) || info.getUserType().equals(UserTypeEnum.HELPER.getValue())){
|
|
|
+ //警员或辅警
|
|
|
+ if (r.getCell(6) == null || StringUtils.isBlank(r.getCell(6).getStringCellValue())){
|
|
|
+ throw new NumberFormatException("第" + (r.getRowNum() + 1) + "行''所属机构(机构名称)''为空!");
|
|
|
+ }
|
|
|
+ info.setOrgCode(r.getCell(6).getStringCellValue());
|
|
|
+ info.setOrgName(r.getCell(5).getStringCellValue());
|
|
|
+ }else {
|
|
|
+ //施工人员
|
|
|
+ info.setOrgCode("");
|
|
|
+ info.setOrgName("");
|
|
|
+ }
|
|
|
+ if (r.getCell(7) == null || StringUtils.isBlank(r.getCell(7).getStringCellValue())){
|
|
|
+ throw new NumberFormatException("第" + (r.getRowNum() + 1) + "行''人员类型''为空!");
|
|
|
+ }
|
|
|
+ info.setManType(r.getCell(7).getStringCellValue());
|
|
|
+ if (r.getCell(8) == null || StringUtils.isBlank(r.getCell(8).getStringCellValue())){
|
|
|
+ throw new NumberFormatException("第" + (r.getRowNum() + 1) + "行''警种''为空!");
|
|
|
+ }
|
|
|
+ info.setPoliceCategory(r.getCell(8).getStringCellValue());
|
|
|
+ if (r.getCell(9) == null || StringUtils.isBlank(r.getCell(9).getStringCellValue())){
|
|
|
+ throw new NumberFormatException("第" + (r.getRowNum() + 1) + "行''职级''为空!");
|
|
|
+ }
|
|
|
+ info.setTitle(r.getCell(9).getStringCellValue());
|
|
|
+ //todo 判断治安的业务域
|
|
|
+ if(info.getPoliceCategory().equals("02")){
|
|
|
+ if(r.getCell(10) == null || StringUtils.isBlank(r.getCell(10).getStringCellValue())){
|
|
|
+ throw new NumberFormatException("第" + (r.getRowNum() + 1) + "行''业务域(表码)''为空!");
|
|
|
+ }
|
|
|
+ info.setPoliceBusiness(r.getCell(10).getStringCellValue());
|
|
|
+ }
|
|
|
+ info.setDeleted(YesNotEnum.NO.getValue());
|
|
|
+ //警员归属默认广东省
|
|
|
+ temp.add(info);
|
|
|
+ }
|
|
|
+ inputStream.close();
|
|
|
+ return temp;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 机构数据导入
|
|
|
+ * @param inputStream
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ * @throws NumberFormatException
|
|
|
+ */
|
|
|
+ public static List<AuthOrgInfo> loadAuthOrgInfo(InputStream inputStream) throws IOException, NumberFormatException {
|
|
|
+ List<AuthOrgInfo> temp = new ArrayList();
|
|
|
+ //根据指定的文件输入流导入Excel从而产生Workbook对象
|
|
|
+ Workbook wb0 = new HSSFWorkbook(inputStream);
|
|
|
+ //获取Excel文档中的第一个表单
|
|
|
+ Sheet sht0 = wb0.getSheetAt(0);
|
|
|
+ //对Sheet中的每一行进行迭代
|
|
|
+ for (Row r : sht0) {
|
|
|
+ //如果当前行的行号(从0开始)未达到2(第三行)则从新循环
|
|
|
+ if (r.getRowNum() == 0) {
|
|
|
+ int cellNum = 0;
|
|
|
+ if (!r.getCell(cellNum++).getStringCellValue().equals("上级行政机构代码")) {
|
|
|
+ throw new NumberFormatException("缺少''上级行政机构代码''列!");
|
|
|
+ }
|
|
|
+ if (!r.getCell(cellNum++).getStringCellValue().equals("上级行政机构名称")) {
|
|
|
+ throw new NumberFormatException("缺少''上级行政机构名称''列!");
|
|
|
+ }
|
|
|
+ if (!r.getCell(cellNum++).getStringCellValue().equals("机构类型(表码)")) {
|
|
|
+ throw new NumberFormatException("缺少''机构类型(表码)''列!");
|
|
|
+ }
|
|
|
+ if (!r.getCell(cellNum++).getStringCellValue().equals("机构名称")) {
|
|
|
+ throw new NumberFormatException("缺少''机构名称''列!");
|
|
|
+ }
|
|
|
+ if (!r.getCell(cellNum++).getStringCellValue().equals("行政区划")) {
|
|
|
+ throw new NumberFormatException("缺少''行政区划''列!");
|
|
|
+ }
|
|
|
+ if (!r.getCell(cellNum++).getStringCellValue().equals("机构代码")) {
|
|
|
+ throw new NumberFormatException("缺少''机构代码''列!");
|
|
|
+ }
|
|
|
+ if (!r.getCell(cellNum++).getStringCellValue().equals("机构类别(表码)")) {
|
|
|
+ throw new NumberFormatException("缺少''机构类别(表码)''列!");
|
|
|
+ }
|
|
|
+ if (!r.getCell(cellNum++).getStringCellValue().equals("单位层级(表码)")) {
|
|
|
+ throw new NumberFormatException("缺少''单位层级(表码)''列!");
|
|
|
+ }
|
|
|
+ if (!r.getCell(cellNum++).getStringCellValue().equals("单位级别(表码)")) {
|
|
|
+ throw new NumberFormatException("缺少''单位级别(表码)''列!");
|
|
|
+ }
|
|
|
+ if (!r.getCell(cellNum++).getStringCellValue().equals("单位类别(表码)")) {
|
|
|
+ throw new NumberFormatException("缺少''单位类别(表码)''列!");
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //创建实体类
|
|
|
+ AuthOrgInfo info = new AuthOrgInfo();
|
|
|
+ info.setUpGovCode(r.getCell(0).getStringCellValue());
|
|
|
+ info.setUpGovName(r.getCell(1).getStringCellValue());
|
|
|
+ if (r.getCell(2) == null || StringUtils.isBlank(r.getCell(2).getStringCellValue())){
|
|
|
+ throw new NumberFormatException("第" + (r.getRowNum() + 1) + "行''机构类型(表码)''为空!");
|
|
|
+ }
|
|
|
+ info.setOrgKind(r.getCell(2).getStringCellValue());
|
|
|
+ if (r.getCell(3) == null || StringUtils.isBlank(r.getCell(3).getStringCellValue())){
|
|
|
+ throw new NumberFormatException("第" + (r.getRowNum() + 1) + "行''机构名称''为空!");
|
|
|
+ }
|
|
|
+ info.setFullName(r.getCell(3).getStringCellValue());
|
|
|
+ if (r.getCell(4) == null || StringUtils.isBlank(r.getCell(4).getStringCellValue())){
|
|
|
+ throw new NumberFormatException("第" + (r.getRowNum() + 1) + "行''行政区划''为空!");
|
|
|
+ }
|
|
|
+ info.setAreaCode(r.getCell(4).getStringCellValue());
|
|
|
+ if (r.getCell(5) == null || StringUtils.isBlank(r.getCell(5).getStringCellValue())){
|
|
|
+ throw new NumberFormatException("第" + (r.getRowNum() + 1) + "行''机构代码''为空!");
|
|
|
+ }
|
|
|
+ info.setOrgCode(r.getCell(5).getStringCellValue());
|
|
|
+ if (r.getCell(6) == null || StringUtils.isBlank(r.getCell(6).getStringCellValue())){
|
|
|
+ throw new NumberFormatException("第" + (r.getRowNum() + 1) + "行''机构类别(表码)''为空!");
|
|
|
+ }
|
|
|
+ info.setOrgType(r.getCell(6).getStringCellValue());
|
|
|
+ if (r.getCell(7) == null || StringUtils.isBlank(r.getCell(7).getStringCellValue())){
|
|
|
+ throw new NumberFormatException("第" + (r.getRowNum() + 1) + "行''单位层级(表码)''为空!");
|
|
|
+ }
|
|
|
+ info.setOrgLevel(r.getCell(7).getStringCellValue());
|
|
|
+ if(r.getCell(8) == null || StringUtils.isBlank(r.getCell(8).getStringCellValue())){
|
|
|
+ throw new NumberFormatException("第" + (r.getRowNum() + 1) + "行''单位级别(表码)''为空!");
|
|
|
+ }
|
|
|
+ info.setOrgRank(r.getCell(8).getStringCellValue());
|
|
|
+ if(r.getCell(9) == null || StringUtils.isBlank(r.getCell(9).getStringCellValue())){
|
|
|
+ throw new NumberFormatException("第" + (r.getRowNum() + 1) + "行''单位类别(表码)''为空!");
|
|
|
+ }
|
|
|
+ info.setUnitClass(r.getCell(8).getStringCellValue());
|
|
|
+ //警员归属默认广东省
|
|
|
+ temp.add(info);
|
|
|
+ }
|
|
|
+ inputStream.close();
|
|
|
+ return temp;
|
|
|
+ }
|
|
|
}
|