@@ -14,6 +14,16 @@ | |||
<dependencies> | |||
<dependency> | |||
<groupId>org.apache.poi</groupId> | |||
<artifactId>poi</artifactId> | |||
<version>5.2.2</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.poi</groupId> | |||
<artifactId>poi-ooxml</artifactId> | |||
<version>5.2.2</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>com.google.guava</groupId> | |||
<artifactId>guava</artifactId> | |||
</dependency> | |||
@@ -149,6 +159,13 @@ | |||
<groupId>com.ningdatech</groupId> | |||
<artifactId>nd-file-starter</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>com.kingbase8</groupId> | |||
<artifactId>kingbase8-8.6.0</artifactId> | |||
<version>8.6.0</version> | |||
<scope>system</scope> | |||
<systemPath>${basedir}/src/lib/kingbase8-8.6.0.jar</systemPath> | |||
</dependency> | |||
</dependencies> | |||
<!-- 打包 --> | |||
<!--配置环境的profile--> | |||
@@ -0,0 +1,287 @@ | |||
package com.ningdatech.kqapi.scheduler.utils; | |||
import java.io.File; | |||
import java.io.FileInputStream; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.util.*; | |||
import org.apache.poi.hssf.usermodel.HSSFCell; | |||
import org.apache.poi.hssf.usermodel.HSSFWorkbook; | |||
import org.apache.poi.ss.usermodel.*; | |||
import org.apache.poi.xssf.usermodel.XSSFWorkbook; | |||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException; | |||
import org.apache.poi.ss.util.CellRangeAddress; | |||
import org.springframework.web.multipart.MultipartFile; | |||
public class ExcelUtil { | |||
public static void main(String[] args) { | |||
ExcelUtil excelUtil = new ExcelUtil(); | |||
//读取excel数据 | |||
List<Map<String, String>> result = excelUtil.readExcelToObj("C:\\Users\\miracle\\Desktop\\合并单元格.xlsx"); | |||
for (Map<String, String> map : result) { | |||
System.out.println(map); | |||
} | |||
} | |||
/** | |||
* 读取excel数据 | |||
* | |||
* @param path | |||
*/ | |||
public List<Map<String, String>> readExcelToObj(String path) { | |||
Workbook wb; | |||
List<Map<String, String>> result = null; | |||
try { | |||
wb = WorkbookFactory.create(new File(path)); | |||
result = readExcel(wb, 0, 1, 0); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} | |||
return result; | |||
} | |||
/** | |||
* 读取excel数据 | |||
* | |||
* @param file | |||
*/ | |||
public List<Map<String, String>> readExcelToObj(MultipartFile file) { | |||
Workbook wb; | |||
List<Map<String, String>> result = null; | |||
try { | |||
wb = WorkbookFactory.create(file.getInputStream()); | |||
result = readExcel(wb, 0, 1, 0); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} | |||
return result; | |||
} | |||
/** | |||
* 读取excel文件 | |||
* | |||
* @param wb | |||
* @param sheetIndex sheet页下标:从0开始 | |||
* @param startReadLine 开始读取的行:从0开始 | |||
* @param tailLine 去除最后读取的行 | |||
*/ | |||
private List<Map<String, String>> readExcel(Workbook wb, int sheetIndex, int startReadLine, int tailLine) { | |||
Sheet sheet = wb.getSheetAt(sheetIndex); | |||
Row row; | |||
List<Map<String, String>> result = new ArrayList<Map<String, String>>(); | |||
for (int i = startReadLine; i < sheet.getLastRowNum() - tailLine + 1; i++) { | |||
row = sheet.getRow(i); | |||
Map<String, String> map = new HashMap<String, String>(); | |||
for (Cell c : row) { | |||
String returnStr = ""; | |||
boolean isMerge = isMergedRegion(sheet, i, c.getColumnIndex()); | |||
//判断是否具有合并单元格 | |||
if (isMerge) { | |||
String rs = getMergedRegionValue(sheet, row.getRowNum(), c.getColumnIndex()); | |||
returnStr = rs; | |||
} else { | |||
//设置单元格类型 | |||
c.setCellType(CellType.STRING); | |||
returnStr = c.getRichStringCellValue().getString(); | |||
} | |||
map.put(c.getColumnIndex() + "", returnStr); | |||
} | |||
result.add(map); | |||
// System.out.println(); | |||
} | |||
return result; | |||
} | |||
/** | |||
* 获取合并单元格的值 | |||
* | |||
* @param sheet | |||
* @param row | |||
* @param column | |||
* @return | |||
*/ | |||
public String getMergedRegionValue(Sheet sheet, int row, int column) { | |||
int sheetMergeCount = sheet.getNumMergedRegions(); | |||
for (int i = 0; i < sheetMergeCount; i++) { | |||
CellRangeAddress ca = sheet.getMergedRegion(i); | |||
int firstColumn = ca.getFirstColumn(); | |||
int lastColumn = ca.getLastColumn(); | |||
int firstRow = ca.getFirstRow(); | |||
int lastRow = ca.getLastRow(); | |||
if (row >= firstRow && row <= lastRow) { | |||
if (column >= firstColumn && column <= lastColumn) { | |||
Row fRow = sheet.getRow(firstRow); | |||
Cell fCell = fRow.getCell(firstColumn); | |||
return getCellValue(fCell); | |||
} | |||
} | |||
} | |||
return null; | |||
} | |||
/** | |||
* 判断合并了行 | |||
* | |||
* @param sheet | |||
* @param row | |||
* @param column | |||
* @return | |||
*/ | |||
private boolean isMergedRow(Sheet sheet, int row, int column) { | |||
int sheetMergeCount = sheet.getNumMergedRegions(); | |||
for (int i = 0; i < sheetMergeCount; i++) { | |||
CellRangeAddress range = sheet.getMergedRegion(i); | |||
int firstColumn = range.getFirstColumn(); | |||
int lastColumn = range.getLastColumn(); | |||
int firstRow = range.getFirstRow(); | |||
int lastRow = range.getLastRow(); | |||
if (row == firstRow && row == lastRow) { | |||
if (column >= firstColumn && column <= lastColumn) { | |||
return true; | |||
} | |||
} | |||
} | |||
return false; | |||
} | |||
/** | |||
* 判断指定的单元格是否是合并单元格 | |||
* | |||
* @param sheet | |||
* @param row 行下标 | |||
* @param column 列下标 | |||
* @return | |||
*/ | |||
private boolean isMergedRegion(Sheet sheet, int row, int column) { | |||
int sheetMergeCount = sheet.getNumMergedRegions(); | |||
for (int i = 0; i < sheetMergeCount; i++) { | |||
CellRangeAddress range = sheet.getMergedRegion(i); | |||
int firstColumn = range.getFirstColumn(); | |||
int lastColumn = range.getLastColumn(); | |||
int firstRow = range.getFirstRow(); | |||
int lastRow = range.getLastRow(); | |||
if (row >= firstRow && row <= lastRow) { | |||
if (column >= firstColumn && column <= lastColumn) { | |||
return true; | |||
} | |||
} | |||
} | |||
return false; | |||
} | |||
/** | |||
* 判断sheet页中是否含有合并单元格 | |||
* | |||
* @param sheet | |||
* @return | |||
*/ | |||
private boolean hasMerged(Sheet sheet) { | |||
return sheet.getNumMergedRegions() > 0 ? true : false; | |||
} | |||
/** | |||
* 合并单元格 | |||
* | |||
* @param sheet | |||
* @param firstRow 开始行 | |||
* @param lastRow 结束行 | |||
* @param firstCol 开始列 | |||
* @param lastCol 结束列 | |||
*/ | |||
private void mergeRegion(Sheet sheet, int firstRow, int lastRow, int firstCol, int lastCol) { | |||
sheet.addMergedRegion(new CellRangeAddress(firstRow, lastRow, firstCol, lastCol)); | |||
} | |||
/** | |||
* 获取单元格的值 | |||
* | |||
* @param cell | |||
* @return | |||
*/ | |||
public String getCellValue(Cell cell) { | |||
if (cell == null) { | |||
return ""; | |||
} | |||
if (cell.getCellType() == CellType.STRING) { | |||
return cell.getStringCellValue(); | |||
} else if (cell.getCellType() == CellType.BOOLEAN) { | |||
return String.valueOf(cell.getBooleanCellValue()); | |||
} else if (cell.getCellType() == CellType.FORMULA) { | |||
return cell.getCellFormula(); | |||
} else if (cell.getCellType() == CellType.NUMERIC) { | |||
return String.valueOf(cell.getNumericCellValue()); | |||
} | |||
return ""; | |||
} | |||
/** | |||
* 从excel读取内容 | |||
*/ | |||
public static void readContent(String fileName) { | |||
boolean isE2007 = false; //判断是否是excel2007格式 | |||
if (fileName.endsWith("xlsx")) | |||
isE2007 = true; | |||
try { | |||
InputStream input = new FileInputStream(fileName); //建立输入流 | |||
Workbook wb = null; | |||
//根据文件格式(2003或者2007)来初始化 | |||
if (isE2007) { | |||
wb = new XSSFWorkbook(input); | |||
} else { | |||
wb = new HSSFWorkbook(input); | |||
} | |||
Sheet sheet = wb.getSheetAt(0); //获得第一个表单 | |||
Iterator<Row> rows = sheet.rowIterator(); //获得第一个表单的迭代器 | |||
while (rows.hasNext()) { | |||
Row row = rows.next(); //获得行数据 | |||
System.out.println("Row #" + row.getRowNum()); //获得行号从0开始 | |||
Iterator<Cell> cells = row.cellIterator(); //获得第一行的迭代器 | |||
while (cells.hasNext()) { | |||
Cell cell = cells.next(); | |||
System.out.println("Cell #" + cell.getColumnIndex()); | |||
switch (cell.getCellType()) { //根据cell中的类型来输出数据 | |||
case NUMERIC: | |||
System.out.println(cell.getNumericCellValue()); | |||
break; | |||
case STRING: | |||
System.out.println(cell.getStringCellValue()); | |||
break; | |||
case BOOLEAN: | |||
System.out.println(cell.getBooleanCellValue()); | |||
break; | |||
case FORMULA: | |||
System.out.println(cell.getCellFormula()); | |||
break; | |||
default: | |||
System.out.println("unsuported sell type=======" + cell.getCellType()); | |||
break; | |||
} | |||
} | |||
} | |||
} catch (IOException ex) { | |||
ex.printStackTrace(); | |||
} | |||
} | |||
} |
@@ -7,6 +7,8 @@ import org.springframework.security.core.session.SessionRegistryImpl; | |||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | |||
import org.springframework.security.crypto.password.PasswordEncoder; | |||
import java.security.SecureRandom; | |||
/** | |||
* <p> | |||
* AuthBeanConfig | |||
@@ -12,38 +12,11 @@ public enum AuthTypeEnum { | |||
/** | |||
* 手机 + 密码的认证方式 | |||
*/ | |||
PHONE_PASSWORD("phone_password"), | |||
PHONE_PASSWORD, | |||
/** | |||
* 子账号 账号 + 密码的认证方式 | |||
*/ | |||
ACCOUNT_PASSWORD("account_password"); | |||
ACCOUNT_PASSWORD; | |||
private final String key; | |||
AuthTypeEnum(String key) { | |||
this.key = key; | |||
} | |||
public static boolean contains(String key) { | |||
for (AuthTypeEnum value : AuthTypeEnum.values()) { | |||
if (key.equals(value.getKey())) { | |||
return true; | |||
} | |||
} | |||
return false; | |||
} | |||
public String getKey() { | |||
return key; | |||
} | |||
public static AuthTypeEnum of(String key) { | |||
for (AuthTypeEnum value : AuthTypeEnum.values()) { | |||
if (key.equals(value.getKey())) { | |||
return value; | |||
} | |||
} | |||
throw new IllegalArgumentException(String.format("无效的AuthTypeEnum:%s", key)); | |||
} | |||
} |
@@ -30,8 +30,8 @@ public class UserAuthLoginFacade { | |||
private final IUserAuthService userAuthService; | |||
private final IUserInfoService userInfoService; | |||
private static final List<String> AUTH_TYPES = Arrays.asList(AuthTypeEnum.ACCOUNT_PASSWORD.getKey(), | |||
AuthTypeEnum.PHONE_PASSWORD.getKey()); | |||
private static final List<AuthTypeEnum> AUTH_TYPES = Arrays.asList(AuthTypeEnum.ACCOUNT_PASSWORD, | |||
AuthTypeEnum.PHONE_PASSWORD); | |||
public UserInfoBO queryUserInfoInPasswordAuth(String username) { | |||
@@ -2,11 +2,11 @@ package com.ningdatech.kqapi.zzsfw.controller; | |||
import com.ningdatech.kqapi.admin.model.vo.WebMatterDetailVO; | |||
import com.ningdatech.kqapi.common.exception.BizException; | |||
import com.ningdatech.kqapi.zzsfw.manage.MatterManage; | |||
import com.ningdatech.kqapi.zzsfw.model.dto.KqZzsfwMattersDeduplicateDTO; | |||
import com.ningdatech.kqapi.zzsfw.model.dto.KqZzsfwMenuDTO; | |||
import com.ningdatech.kqapi.zzsfw.model.vo.MatterTopVO; | |||
import com.ningdatech.kqapi.zzsfw.model.vo.TreeVO; | |||
import com.ningdatech.kqapi.zzsfw.manage.MatterManage; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.validation.annotation.Validated; | |||
@@ -19,7 +19,7 @@ import java.util.Objects; | |||
/** | |||
* <p> | |||
* 前端控制器 | |||
* 前端控制器 | |||
* </p> | |||
* | |||
* @author ZPF | |||
@@ -51,15 +51,15 @@ public class KqZzsfwMenuController { | |||
@GetMapping("/departments") | |||
public List<TreeVO> getDepartments(@RequestParam(required = false) String windowName, | |||
@RequestParam(required = false) String zoneName) { | |||
return matterManage.getDepartments(zoneName,windowName); | |||
return matterManage.getDepartments(zoneName, windowName); | |||
} | |||
@GetMapping("/matter-list") | |||
public List<WebMatterDetailVO> matterList(@RequestParam(required = false) String windowName, | |||
@RequestParam(required = false) String zoneName, | |||
@RequestParam(required = false) String department, | |||
@RequestParam(required = false) Integer type) { | |||
return matterManage.matterList(zoneName,windowName,department,type); | |||
@RequestParam(required = false) String zoneName, | |||
@RequestParam(required = false) String department, | |||
@RequestParam(required = false) Integer type) { | |||
return matterManage.matterList(zoneName, windowName, department, type); | |||
} | |||
@GetMapping("/matter/{id}") | |||
@@ -108,6 +108,7 @@ public class KqZzsfwMenuController { | |||
/** | |||
* 4-10 改动的几个问题 到时候 线上直接改了 | |||
* | |||
* @return | |||
*/ | |||
@GetMapping("/update-4-10") | |||
@@ -116,9 +117,19 @@ public class KqZzsfwMenuController { | |||
} | |||
@PostMapping("/initOldData") | |||
public void initOldData(){ | |||
public void initOldData() { | |||
matterManage.initOldData(); | |||
} | |||
@PostMapping("/importGovService") | |||
public void importGovService(MultipartFile file) { | |||
matterManage.importGovService(file); | |||
} | |||
@PostMapping("/importAddedService") | |||
public void importAddedService(MultipartFile file) { | |||
matterManage.importAddedService(file); | |||
} | |||
} | |||
@@ -18,6 +18,7 @@ import com.ningdatech.kqapi.admin.model.vo.MatterDetailDTO; | |||
import com.ningdatech.kqapi.admin.model.vo.WebMatterDetailVO; | |||
import com.ningdatech.kqapi.admin.service.IWindowService; | |||
import com.ningdatech.kqapi.admin.service.IZoneService; | |||
import com.ningdatech.kqapi.scheduler.utils.ExcelUtil; | |||
import com.ningdatech.kqapi.zzsfw.constants.ZzsfwMenuConstant; | |||
import com.ningdatech.kqapi.zzsfw.enumeration.ItemTypeEnum; | |||
import com.ningdatech.kqapi.zzsfw.model.dto.KqZzsfwMattersDeduplicateDTO; | |||
@@ -30,7 +31,6 @@ import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMatterDeduplicateService; | |||
import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMenuService; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.apache.commons.compress.utils.Lists; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.apache.poi.ss.usermodel.CellType; | |||
import org.apache.poi.ss.usermodel.Row; | |||
@@ -568,4 +568,43 @@ public class MatterManage { | |||
}); | |||
}); | |||
} | |||
@Transactional(rollbackFor = Exception.class) | |||
public void importAddedService(MultipartFile file) { | |||
// 服务专区 序号 服务窗口 牵头部门(服务机构) 服务事项 服务内容 服务流程 咨询电话 | |||
ExcelUtil util = new ExcelUtil(); | |||
List<Map<String, String>> maps = util.readExcelToObj(file); | |||
List<KqZzsfwMenu> menus = maps.stream().map(w -> { | |||
KqZzsfwMenu menu = new KqZzsfwMenu(); | |||
menu.setWindow(w.get("2")); | |||
menu.setSort(Integer.parseInt(w.get("1"))); | |||
menu.setDepartment(w.get("3")); | |||
menu.setItemName(w.get("4")); | |||
menu.setServiceContent(w.get("5")); | |||
menu.setServiceProcess(w.get("6")); | |||
menu.setTelephone(w.get("7")); | |||
menu.setZoneName(w.get("0")); | |||
menu.setType(ItemTypeEnum.ADDED.getCode()); | |||
return menu; | |||
}).collect(Collectors.toList()); | |||
menuService.saveBatch(menus); | |||
} | |||
@Transactional(rollbackFor = Exception.class) | |||
public void importGovService(MultipartFile file) { | |||
ExcelUtil util = new ExcelUtil(); | |||
List<Map<String, String>> maps = util.readExcelToObj(file); | |||
List<KqZzsfwMenu> menus = maps.stream().map(w -> { | |||
KqZzsfwMenu menu = new KqZzsfwMenu(); | |||
menu.setWindow(w.get("1")); | |||
menu.setSort(Integer.parseInt(w.get("3"))); | |||
menu.setDepartment(w.get("2")); | |||
menu.setItemName(w.get("4")); | |||
menu.setZoneName(w.get("0")); | |||
menu.setType(GOV.getCode()); | |||
return menu; | |||
}).collect(Collectors.toList()); | |||
menuService.saveBatch(menus); | |||
} | |||
} |
@@ -47,6 +47,7 @@ public class KqZzsfwMenu implements Serializable { | |||
private String zoneName; | |||
@ApiModelProperty("窗口") | |||
@TableField("\"window\"") | |||
private String window; | |||
@ApiModelProperty("部门") | |||
@@ -1,5 +1,5 @@ | |||
server: | |||
port: 33061 | |||
port: 8000 | |||
servlet: | |||
context-path: /kq | |||
shutdown: graceful | |||
@@ -18,10 +18,10 @@ spring: | |||
timeout: 864000 | |||
redis: | |||
timeout: 5000 | |||
host: 47.98.125.47 | |||
port: 26379 | |||
host: 127.0.0.1 | |||
port: 6379 | |||
database: 7 | |||
password: Ndkj1234 | |||
password: Ndkj1234! | |||
jedis: | |||
pool: | |||
max-active: 200 | |||
@@ -46,10 +46,10 @@ spring: | |||
ddl-auto: update | |||
datasource: | |||
type: com.zaxxer.hikari.HikariDataSource | |||
driver-class-name: com.mysql.cj.jdbc.Driver | |||
url: ENC(gtE4OUrpgtFsh6B3aLiSp2sVSX1BYDET9Uii/wRP2RboRK0NDaYu1S7Vx30cHXFE7vecQzY1UbrSFW/BaWJvQ3XJxfDiaUxdrIDND5e+DMTjx1pUkfS8/RbXHQDE+QoOVZV1UKEtdq+khr32tlQXqkTnzmZGuZjctVmjdQxUnmI2YNpoeNlIAkDXiaCvcVYc) | |||
username: root | |||
password: Nd@20231116 | |||
driverClassName: com.kingbase8.Driver | |||
url: jdbc:kingbase8://10.75.42.167:33060/kq_added_project?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8 | |||
username: SYSTEM | |||
password: Kqvdsj@159260 | |||
# 数据源 | |||
hikari: | |||
@@ -79,8 +79,8 @@ mybatis-plus: | |||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl | |||
global-config: | |||
db-config: | |||
logic-delete-value: true | |||
logic-not-delete-value: false | |||
logic-delete-value: 1 | |||
logic-not-delete-value: 0 | |||
logic-delete-field: deleted | |||
logging: | |||
config: classpath:logback-spring.xml | |||
@@ -103,12 +103,13 @@ nd: | |||
file: | |||
storage-type: ALI_OSS | |||
ali: | |||
protocol: https:// | |||
bucket: devplat | |||
urlPrefix: oss-cn-hangzhou.aliyuncs.com | |||
endpoint: oss-cn-hangzhou.aliyuncs.com | |||
accessKeyId: LTAI4GL7uypycnBjiRn55rMG | |||
accessKeySecret: qwYC7bW9bkStsko7qkLVnToAzj0Y98 | |||
protocol: http:// | |||
bucket: kqqfzx-295 | |||
urlPrefix: oss0eab-cn-shaoxing-sxdx-d01-a.ops.dxdtsxzwy.com | |||
endpoint: oss0eab-cn-shaoxing-sxdx-d01-a.ops.dxdtsxzwy.com | |||
accessKeyId: WMoHzuT3XMjySNxx | |||
accessKeySecret: xBJCTRrJJbh1fNDG9uYxCXZzOhQs83 | |||
# 日志文件配置 | |||
log: | |||
path: ./logs | |||
@@ -27,16 +27,6 @@ | |||
<dependencyManagement> | |||
<dependencies> | |||
<!--<dependency> | |||
<groupId>org.apache.poi</groupId> | |||
<artifactId>poi</artifactId> | |||
<version>5.2.2</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.poi</groupId> | |||
<artifactId>poi-ooxml</artifactId> | |||
<version>5.2.2</version> | |||
</dependency>--> | |||
<dependency> | |||
<groupId>com.alibaba</groupId> | |||
<artifactId>fastjson</artifactId> | |||