Merge branch 'master' of http://47.115.223.229:8888/yangjun/hldy_java_monomer
# Conflicts: # nursing-unit-system/nu-system-start/src/main/resources/application-dev.yml # nursing-unit-system/nu-system-start/src/main/resources/application-uat.yml
This commit is contained in:
commit
7161b4307e
|
@ -1,6 +1,7 @@
|
|||
package com.nu.modules.NuBizAdvisoryInfo.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nu.modules.NuBizAdvisoryInfo.entity.NuBizAdvisoryInfo;
|
||||
|
@ -57,6 +58,11 @@ public class H5ApiAdvisoryInfoController extends JeecgController<NuBizAdvisoryIn
|
|||
return Result.OK(nuBizAdvisoryInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取是否有注册信息
|
||||
* @param openId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/queryByOpenId")
|
||||
public Result<NuBizAdvisoryInfo> queryByOpenId(@RequestParam(name="openId",required=true) String openId) {
|
||||
QueryWrapper<NuBizAdvisoryInfo> queryWrapper = new QueryWrapper<>();
|
||||
|
@ -97,4 +103,47 @@ public class H5ApiAdvisoryInfoController extends JeecgController<NuBizAdvisoryIn
|
|||
}
|
||||
return Result.OK(nuBizAdvisoryInfo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取微信信息
|
||||
* @param openId
|
||||
* @param wechatName
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/queryWeixinInfo")
|
||||
public Result<NuBizAdvisoryInfo> queryByOpenId(@RequestParam(name="openId",required=true) String openId,@RequestParam(name="wechatName",required=true) String wechatName) {
|
||||
NuBizAdvisoryInfo nuBizAdvisoryInfo = nuBizAdvisoryInfoService.queryWeixinInfo(openId,wechatName);
|
||||
return Result.OK(nuBizAdvisoryInfo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据openId修改serverUrl
|
||||
* @param nuBizAdvisoryInfo
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value="修改咨询信息", notes="修改咨询信息")
|
||||
@RequestMapping(value = "/editNuBizAdvisoryInfo", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
public Result<String> editNuBizAdvisoryInfo(@RequestBody NuBizAdvisoryInfo nuBizAdvisoryInfo) {
|
||||
if(StringUtils.isEmpty(nuBizAdvisoryInfo.getOpenId())){
|
||||
return Result.error("填写openId");
|
||||
}
|
||||
if(StringUtils.isEmpty(nuBizAdvisoryInfo.getServerUrl())){
|
||||
return Result.error("填写微信名称");
|
||||
}
|
||||
QueryWrapper<NuBizAdvisoryInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("open_id",nuBizAdvisoryInfo.getOpenId());
|
||||
NuBizAdvisoryInfo nuBizAdvisoryInfoQuery = nuBizAdvisoryInfoService.getOne(queryWrapper);
|
||||
if(nuBizAdvisoryInfoQuery == null){
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
UpdateWrapper<NuBizAdvisoryInfo> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("open_id",nuBizAdvisoryInfo.getOpenId());
|
||||
updateWrapper.set("server_url",nuBizAdvisoryInfo.getServerUrl());
|
||||
nuBizAdvisoryInfoService.update(updateWrapper);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -11,4 +11,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
*/
|
||||
public interface INuBizAdvisoryInfoService extends IService<NuBizAdvisoryInfo> {
|
||||
|
||||
NuBizAdvisoryInfo queryWeixinInfo(String openId, String wechatName);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.nu.modules.NuBizAdvisoryInfo.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.nu.modules.NuBizAdvisoryInfo.entity.NuBizAdvisoryInfo;
|
||||
import com.nu.modules.NuBizAdvisoryInfo.mapper.NuBizAdvisoryInfoMapper;
|
||||
import com.nu.modules.NuBizAdvisoryInfo.service.INuBizAdvisoryInfoService;
|
||||
|
@ -16,4 +17,19 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
@Service
|
||||
public class NuBizAdvisoryInfoServiceImpl extends ServiceImpl<NuBizAdvisoryInfoMapper, NuBizAdvisoryInfo> implements INuBizAdvisoryInfoService {
|
||||
|
||||
@Override
|
||||
public NuBizAdvisoryInfo queryWeixinInfo(String openId, String wechatName) {
|
||||
QueryWrapper<NuBizAdvisoryInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("open_id",openId);
|
||||
queryWrapper.eq("wechat_name",wechatName);
|
||||
NuBizAdvisoryInfo nuBizAdvisoryInfo = baseMapper.selectOne(queryWrapper);
|
||||
//查询是否有微信注册信息,没有则创建
|
||||
if(nuBizAdvisoryInfo==null) {
|
||||
nuBizAdvisoryInfo = new NuBizAdvisoryInfo();
|
||||
nuBizAdvisoryInfo.setOpenId(openId);
|
||||
nuBizAdvisoryInfo.setWechatName(wechatName);
|
||||
baseMapper.insert(nuBizAdvisoryInfo);
|
||||
}
|
||||
return nuBizAdvisoryInfo;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,161 @@
|
|||
package com.nu.modules.weixin.controller;
|
||||
|
||||
import com.alibaba.cloud.commons.lang.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nu.modules.appversionconfig.entity.AppVersionConfig;
|
||||
import com.nu.modules.appversionconfig.service.IAppVersionConfigService;
|
||||
import com.nu.modules.weixin.utils.SignUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/weixin")
|
||||
@Slf4j
|
||||
public class WeixinController {
|
||||
@Value("${wechat.appId}")
|
||||
private String appId;
|
||||
|
||||
|
||||
@Value("${wechat.appSecret:}")
|
||||
private String appSecret;
|
||||
|
||||
// RestTemplate 用于发送 HTTP 请求
|
||||
private final RestTemplate restTemplate;
|
||||
|
||||
public WeixinController(RestTemplate restTemplate) {
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description 微信公众号服务器配置校验token
|
||||
* @author: liyinlong
|
||||
* @date 2019-05-09 9:38
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("微信公众号服务器配置校验token")
|
||||
@RequestMapping("/checkToken")
|
||||
public void checkToken(HttpServletRequest request,HttpServletResponse response){
|
||||
//token验证代码段
|
||||
try{
|
||||
log.info("请求已到达,开始校验token");
|
||||
if (StringUtils.isNotBlank(request.getParameter("signature"))) {
|
||||
String signature = request.getParameter("signature");
|
||||
String timestamp = request.getParameter("timestamp");
|
||||
String nonce = request.getParameter("nonce");
|
||||
String echostr = request.getParameter("echostr");
|
||||
log.info("signature[{}], timestamp[{}], nonce[{}], echostr[{}]", signature, timestamp, nonce, echostr);
|
||||
if (SignUtil.checkSignature(signature, timestamp, nonce)) {
|
||||
log.info("数据源为微信后台,将echostr[{}]返回!", echostr);
|
||||
response.getOutputStream().println(echostr);
|
||||
}
|
||||
}
|
||||
}catch (IOException e){
|
||||
log.error("校验出错");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/auth/callback")
|
||||
public String wxCallback(String code) {
|
||||
// 1. 用code换token
|
||||
// 2. 获取用户信息 return
|
||||
return "redirect:https://www.focusnu.com/wechat/thd/#/pages/index/callback";
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/wechat/callback")
|
||||
public Map<String,Object> callback(@RequestParam("code") String code, Model model) {
|
||||
String tokenUrl = String.format(
|
||||
"https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code",
|
||||
appId, appSecret, code
|
||||
);
|
||||
System.out.println(tokenUrl);
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
System.out.println("-------------------11111111111111111----------");
|
||||
String tokenResponse = restTemplate.getForObject(tokenUrl, String.class);
|
||||
System.out.println("-------------------22222222222222222----------"+tokenResponse);
|
||||
|
||||
JsonNode retJson = null;
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String accessToken = "";
|
||||
try {
|
||||
System.out.println("-------------------33333333333333----------");
|
||||
JsonNode tokenNode = objectMapper.readTree(tokenResponse);
|
||||
System.out.println("-------------------444444444444444----------"+tokenNode);
|
||||
accessToken = tokenNode.get("access_token").asText();
|
||||
System.out.println("-------------------55555555555555----------"+accessToken);
|
||||
String openId = tokenNode.get("openid").asText();
|
||||
System.out.println("-------------------666666666666666----------"+openId);
|
||||
|
||||
String userInfoUrl = String.format(
|
||||
"https://api.weixin.qq.com/sns/userinfo?access_token=%s&openid=%s&lang=zh_CN",
|
||||
accessToken, openId
|
||||
);
|
||||
System.out.println("-------------------777777777777777----------"+userInfoUrl);
|
||||
|
||||
String userInfoResponse = restTemplate.getForObject(userInfoUrl, String.class);
|
||||
System.out.println("-------------------888888888888888----------"+userInfoResponse);
|
||||
JsonNode userInfoNode = objectMapper.readTree(userInfoResponse);
|
||||
System.out.println("-------------------999999999999999----------"+userInfoNode);
|
||||
|
||||
model.addAttribute("openid", openId);
|
||||
System.out.println("-------------------999999999999999----------"+openId);
|
||||
model.addAttribute("nickname", userInfoNode.get("nickname").asText());
|
||||
model.addAttribute("headimgurl", userInfoNode.get("headimgurl").asText());
|
||||
model.addAttribute("code", code);
|
||||
retJson = userInfoNode;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
model.addAttribute("openid", "Error parsing JSON response");
|
||||
}
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("data",retJson);
|
||||
map.put("code",200);
|
||||
map.put("msg","success");
|
||||
map.put("accessToken",accessToken);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package com.nu.modules.weixin.utils;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class SignUtil {
|
||||
private static String token = "Blxc20250520";
|
||||
|
||||
/**
|
||||
* 校验签名
|
||||
* @param signature 签名
|
||||
* @param timestamp 时间戳
|
||||
* @param nonce 随机数
|
||||
* @return 布尔值
|
||||
*/
|
||||
public static boolean checkSignature(String signature,String timestamp,String nonce){
|
||||
String checktext = null;
|
||||
if (null != signature) {
|
||||
//对ToKen,timestamp,nonce 按字典排序
|
||||
String[] paramArr = new String[]{token,timestamp,nonce};
|
||||
Arrays.sort(paramArr);
|
||||
//将排序后的结果拼成一个字符串
|
||||
String content = paramArr[0].concat(paramArr[1]).concat(paramArr[2]);
|
||||
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-1");
|
||||
//对接后的字符串进行sha1加密
|
||||
byte[] digest = md.digest(content.toString().getBytes());
|
||||
checktext = byteToStr(digest);
|
||||
} catch (NoSuchAlgorithmException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
//将加密后的字符串与signature进行对比
|
||||
return checktext !=null ? checktext.equals(signature.toUpperCase()) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字节数组转化我16进制字符串
|
||||
* @param byteArrays 字符数组
|
||||
* @return 字符串
|
||||
*/
|
||||
private static String byteToStr(byte[] byteArrays){
|
||||
String str = "";
|
||||
for (int i = 0; i < byteArrays.length; i++) {
|
||||
str += byteToHexStr(byteArrays[i]);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字节转化为十六进制字符串
|
||||
* @param myByte 字节
|
||||
* @return 字符串
|
||||
*/
|
||||
private static String byteToHexStr(byte myByte) {
|
||||
char[] Digit = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
|
||||
char[] tampArr = new char[2];
|
||||
tampArr[0] = Digit[(myByte >>> 4) & 0X0F];
|
||||
tampArr[1] = Digit[myByte & 0X0F];
|
||||
String str = new String(tampArr);
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
|
@ -97,4 +97,22 @@ public class DocumentRecognitionApi {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 营业执照识别
|
||||
* @param file 图片文件
|
||||
*/
|
||||
@PostMapping("/businessLicense")
|
||||
public Result<String> recognizeBusinessLicense(
|
||||
@RequestParam("file") MultipartFile file) {
|
||||
|
||||
DocumentRecognitionUtils utils = new DocumentRecognitionUtils(accessKeyId, accessKeySecret);
|
||||
try (InputStream inputStream = file.getInputStream()) {
|
||||
String result = utils.recognizeBusinessLicense(inputStream);
|
||||
return Result.ok(result);
|
||||
} catch (Exception e) {
|
||||
return Result.error("营业执照识别失败: " + e.getMessage());
|
||||
} finally {
|
||||
utils.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,6 +108,7 @@ public class ShiroConfig {
|
|||
filterChainDefinitionMap.put("/sys/dict/getDictItems/**", "anon");//获取字典数据
|
||||
filterChainDefinitionMap.put("/sys/sysDepart/queryInstitutionsList", "anon");//授权接口排除
|
||||
filterChainDefinitionMap.put("/h5Api/nuBizAdvisoryInfo/**", "anon"); //授权接口排除
|
||||
filterChainDefinitionMap.put("/weixin/**", "anon"); //授权接口排除
|
||||
|
||||
|
||||
filterChainDefinitionMap.put("/sys/getLoginQrcode/**", "anon"); //登录二维码
|
||||
|
|
|
@ -34,6 +34,12 @@
|
|||
<artifactId>guava</artifactId>
|
||||
<version>33.4.8-jre</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>1.15.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -99,4 +99,19 @@ public class DocumentRecognitionUtils {
|
|||
RecognizeSocialSecurityCardVersionIIResponse response = future.get();
|
||||
return new Gson().toJson(response.getBody());
|
||||
}
|
||||
|
||||
/**
|
||||
* 识别营业执照
|
||||
* @param inputStream 图片输入流
|
||||
* @return 识别结果JSON字符串
|
||||
*/
|
||||
public String recognizeBusinessLicense(InputStream inputStream) throws Exception {
|
||||
RecognizeBusinessLicenseRequest request = RecognizeBusinessLicenseRequest.builder()
|
||||
.body(inputStream)
|
||||
.build();
|
||||
|
||||
CompletableFuture<RecognizeBusinessLicenseResponse> future = client.recognizeBusinessLicense(request);
|
||||
RecognizeBusinessLicenseResponse response = future.get();
|
||||
return new Gson().toJson(response.getBody());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,166 @@
|
|||
package com.nu.utils;
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.UUID;
|
||||
|
||||
public class RegionCodeProcessor {
|
||||
private static final String ROOT_ID = "1927641061017837570";
|
||||
private static final String CREATE_BY = "admin";
|
||||
private static final int TENANT_ID = 0;
|
||||
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
private static final String CURRENT_TIME = LocalDateTime.now().format(DATE_FORMAT);
|
||||
|
||||
private static final String INPUT_FILE = "D:\\downLoad\\行政区划代码.txt";
|
||||
private static final String OUTPUT_FILE = "D:\\downLoad\\region_inserts.sql";
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
List<Region> regions = readRegionsFromFile();
|
||||
Map<String, String> codeToIdMap = new HashMap<>();
|
||||
Map<String, List<Region>> parentCodeToChildrenMap = new HashMap<>();
|
||||
|
||||
// 处理省一级(编码后四位是0000的)
|
||||
for (Region region : regions) {
|
||||
if (region.code.endsWith("0000")) {
|
||||
region.pid = ROOT_ID;
|
||||
region.level = 2;
|
||||
codeToIdMap.put(region.code, region.id);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理市一级(编码后两位是00的)和省直辖县级行政单位
|
||||
for (Region region : regions) {
|
||||
if (region.code.endsWith("00") && !region.code.endsWith("0000")) {
|
||||
String parentCode = region.code.substring(0, 2) + "0000";
|
||||
region.pid = codeToIdMap.getOrDefault(parentCode, ROOT_ID);
|
||||
region.level = 3;
|
||||
codeToIdMap.put(region.code, region.id);
|
||||
} else if (region.name.equals("省直辖县级行政单位")) {
|
||||
String parentCode = region.code.substring(0, 2) + "0000";
|
||||
region.pid = codeToIdMap.getOrDefault(parentCode, ROOT_ID);
|
||||
region.level = 3;
|
||||
codeToIdMap.put(region.code, region.id);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理县一级(其他情况)
|
||||
for (Region region : regions) {
|
||||
if (region.pid == null) {
|
||||
if (region.code.endsWith("0000")) {
|
||||
continue; // 已经处理过的省一级
|
||||
}
|
||||
|
||||
// 尝试找市级父节点
|
||||
String cityCode = region.code.substring(0, 4) + "00";
|
||||
if (codeToIdMap.containsKey(cityCode)) {
|
||||
region.pid = codeToIdMap.get(cityCode);
|
||||
region.level = 4;
|
||||
} else {
|
||||
// 如果没有市级,则直接挂到省级下
|
||||
String provinceCode = region.code.substring(0, 2) + "0000";
|
||||
region.pid = codeToIdMap.getOrDefault(provinceCode, ROOT_ID);
|
||||
region.level = 3;
|
||||
}
|
||||
codeToIdMap.put(region.code, region.id);
|
||||
}
|
||||
}
|
||||
|
||||
// 构建父节点到子节点的映射
|
||||
for (Region region : regions) {
|
||||
if (!region.pid.equals(ROOT_ID)) {
|
||||
parentCodeToChildrenMap
|
||||
.computeIfAbsent(region.pid, k -> new ArrayList<>())
|
||||
.add(region);
|
||||
}
|
||||
}
|
||||
|
||||
// 生成SQL语句
|
||||
generateSqlFile(regions, parentCodeToChildrenMap);
|
||||
|
||||
System.out.println("SQL文件已生成到: " + OUTPUT_FILE);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static List<Region> readRegionsFromFile() throws IOException {
|
||||
List<Region> regions = new ArrayList<>();
|
||||
Pattern pattern = Pattern.compile("^\\d+");
|
||||
|
||||
// 使用明确的GBK编码读取文件(常见的中文编码)
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(
|
||||
new FileInputStream(INPUT_FILE), "GBK"))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
line = line.trim();
|
||||
if (line.isEmpty() || !pattern.matcher(line).find()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 处理行数据,考虑中文名称可能包含空格的情况
|
||||
String code = line.substring(0, 6).trim();
|
||||
String name = line.substring(6).trim();
|
||||
|
||||
// 处理特殊名称(如"省直辖县级行政单位")
|
||||
if (name.equals("省直辖县级行政单位")) {
|
||||
name = "省直辖县级行政单位";
|
||||
}
|
||||
|
||||
// 生成UUID作为ID
|
||||
String id = UUID.randomUUID().toString().replaceAll("-","");
|
||||
|
||||
regions.add(new Region(id, null, name, code));
|
||||
}
|
||||
}
|
||||
return regions;
|
||||
}
|
||||
|
||||
private static void generateSqlFile(List<Region> regions,
|
||||
Map<String, List<Region>> parentCodeToChildrenMap) throws IOException {
|
||||
// 使用UTF-8编码写入SQL文件
|
||||
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
|
||||
new FileOutputStream(OUTPUT_FILE), StandardCharsets.UTF_8))) {
|
||||
|
||||
// 先处理所有区域
|
||||
for (Region region : regions) {
|
||||
String hasChild = parentCodeToChildrenMap.containsKey(region.id) ? "1" : "0";
|
||||
|
||||
String sql = String.format(
|
||||
"INSERT INTO sys_category (id, pid, name, code, create_by, create_time, update_by, update_time, sys_org_code, has_child, tenant_id) " +
|
||||
"VALUES ('%s', '%s', '%s', '%s', '%s', '%s', NULL, NULL, NULL, '%s', %d);",
|
||||
region.id, region.pid, escapeSql(region.name), region.code,
|
||||
CREATE_BY, CURRENT_TIME, hasChild, TENANT_ID
|
||||
);
|
||||
|
||||
writer.write(sql);
|
||||
writer.newLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String escapeSql(String str) {
|
||||
if (str == null) {
|
||||
return "";
|
||||
}
|
||||
return str.replace("'", "''");
|
||||
}
|
||||
|
||||
static class Region {
|
||||
String id;
|
||||
String pid;
|
||||
String name;
|
||||
String code;
|
||||
int level;
|
||||
|
||||
public Region(String id, String pid, String name, String code) {
|
||||
this.id = id;
|
||||
this.pid = pid;
|
||||
this.name = name;
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
@Component
|
||||
|
@ -24,22 +24,26 @@ public class SafetyUtil {
|
|||
* @param secureKey 客户端传入的密钥(MD5 值)
|
||||
* @return true=验证通过,false=验证失败
|
||||
*/
|
||||
|
||||
public static boolean validateSecureKey(String secureKey) {
|
||||
if (secureKey == null || downloadkey == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 1. 获取当前日期(yyyyMMdd)
|
||||
String currentDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
// 获取当前时间(精确到分钟,格式为 yyyyMMddHHmm)
|
||||
String currentTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm"));
|
||||
// 获取前一分钟的时间(用于扩大验证窗口)
|
||||
String previousMinute = LocalDateTime.now().minusMinutes(1).format(DateTimeFormatter.ofPattern("yyyyMMddHHmm"));
|
||||
|
||||
// 2. 复杂混拼(固定规则)
|
||||
String mixedKey = complexMix(downloadkey, currentDate);
|
||||
|
||||
// 3. 计算 MD5
|
||||
// 验证当前时间的密钥
|
||||
String mixedKey = complexMix(downloadkey, currentTime);
|
||||
String md5Hash = calculateMD5(mixedKey);
|
||||
if (secureKey.equalsIgnoreCase(md5Hash)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 4. 比较 secureKey 是否匹配(忽略大小写)
|
||||
// 验证前一分钟的密钥(扩大验证窗口)
|
||||
mixedKey = complexMix(downloadkey, previousMinute);
|
||||
md5Hash = calculateMD5(mixedKey);
|
||||
return secureKey.equalsIgnoreCase(md5Hash);
|
||||
}
|
||||
|
||||
|
@ -54,7 +58,6 @@ public class SafetyUtil {
|
|||
* 进行倒序
|
||||
* 3.每 3个字符插入一个固定干扰符 '#'
|
||||
*/
|
||||
|
||||
private static String complexMix(String key, String date) {
|
||||
StringBuilder mixed = new StringBuilder();
|
||||
|
||||
|
@ -102,19 +105,22 @@ public class SafetyUtil {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取当前的安全密钥
|
||||
* 现在包含精确到分钟的时间信息(yyyyMMddHHmm)
|
||||
*/
|
||||
public static String getSecureKey() {
|
||||
if (downloadkey == null) {
|
||||
return "aaa";
|
||||
}
|
||||
|
||||
// 1. 获取当前日期(yyyyMMdd)
|
||||
String currentDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
// 获取当前时间(精确到分钟,格式为 yyyyMMddHHmm)
|
||||
String currentTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm"));
|
||||
|
||||
// 2. 复杂混拼(固定规则)
|
||||
String mixedKey = complexMix(downloadkey, currentDate);
|
||||
// 复杂混拼(固定规则)
|
||||
String mixedKey = complexMix(downloadkey, currentTime);
|
||||
|
||||
// 3. 计算 MD5 并返回
|
||||
// 计算 MD5 并返回
|
||||
return calculateMD5(mixedKey);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ import java.io.IOException;
|
|||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @Description: 分类字典
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2019-05-29
|
||||
|
@ -58,6 +58,7 @@ public class SysCategoryController {
|
|||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param sysCategory
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
|
@ -66,17 +67,14 @@ public class SysCategoryController {
|
|||
*/
|
||||
@GetMapping(value = "/rootList")
|
||||
public Result<IPage<SysCategory>> queryPageList(SysCategory sysCategory,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
if(oConvertUtils.isEmpty(sysCategory.getPid())){
|
||||
sysCategory.setPid("0");
|
||||
}
|
||||
Result<IPage<SysCategory>> result = new Result<IPage<SysCategory>>();
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
sysCategory.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(),0));
|
||||
if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) {
|
||||
sysCategory.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(), 0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -86,8 +84,8 @@ public class SysCategoryController {
|
|||
String name = sysCategory.getName();
|
||||
String code = sysCategory.getCode();
|
||||
//QueryWrapper<SysCategory> queryWrapper = new QueryWrapper<SysCategory>();
|
||||
if(StringUtils.isBlank(name)&&StringUtils.isBlank(code)){
|
||||
queryWrapper.eq("pid", sysCategory.getPid());
|
||||
if (StringUtils.isBlank(name) && StringUtils.isBlank(code)) {
|
||||
queryWrapper.eq("pid","0");
|
||||
}
|
||||
//--author:liusq---date:20211119 -----for: 分类字典页面查询条件配置--------end
|
||||
//--author:os_chengtgen---date:20190804 -----for:【vue3】 分类字典页面显示错误,issues:377--------end
|
||||
|
@ -100,15 +98,16 @@ public class SysCategoryController {
|
|||
}
|
||||
|
||||
@GetMapping(value = "/childList")
|
||||
public Result<List<SysCategory>> queryPageList(SysCategory sysCategory,HttpServletRequest req) {
|
||||
public Result<List<SysCategory>> queryPageList(SysCategory sysCategory, HttpServletRequest req) {
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) {
|
||||
sysCategory.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(), 0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
Result<List<SysCategory>> result = new Result<List<SysCategory>>();
|
||||
QueryWrapper<SysCategory> queryWrapper = QueryGenerator.initQueryWrapper(sysCategory, req.getParameterMap());
|
||||
queryWrapper.orderByAsc("code");
|
||||
List<SysCategory> list = sysCategoryService.list(queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(list);
|
||||
|
@ -118,6 +117,7 @@ public class SysCategoryController {
|
|||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param sysCategory
|
||||
* @return
|
||||
*/
|
||||
|
@ -128,24 +128,25 @@ public class SysCategoryController {
|
|||
sysCategoryService.addSysCategory(sysCategory);
|
||||
result.success("添加成功!");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
result.error500("操作失败");
|
||||
log.error(e.getMessage(), e);
|
||||
result.error500("编码重复!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param sysCategory
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/edit", method = { RequestMethod.PUT,RequestMethod.POST })
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<SysCategory> edit(@RequestBody SysCategory sysCategory) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
SysCategory sysCategoryEntity = sysCategoryService.getById(sysCategory.getId());
|
||||
if(sysCategoryEntity==null) {
|
||||
result.error500("未找到对应实体");
|
||||
}else {
|
||||
if (sysCategoryEntity == null) {
|
||||
result.error500("编码重复!");
|
||||
} else {
|
||||
sysCategoryService.updateSysCategory(sysCategory);
|
||||
result.success("修改成功!");
|
||||
}
|
||||
|
@ -154,16 +155,17 @@ public class SysCategoryController {
|
|||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<SysCategory> delete(@RequestParam(name="id",required=true) String id) {
|
||||
public Result<SysCategory> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
SysCategory sysCategory = sysCategoryService.getById(id);
|
||||
if(sysCategory==null) {
|
||||
if (sysCategory == null) {
|
||||
result.error500("未找到对应实体");
|
||||
}else {
|
||||
} else {
|
||||
this.sysCategoryService.deleteSysCategory(id);
|
||||
result.success("删除成功!");
|
||||
}
|
||||
|
@ -173,15 +175,16 @@ public class SysCategoryController {
|
|||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<SysCategory> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
public Result<SysCategory> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
if(ids==null || "".equals(ids.trim())) {
|
||||
if (ids == null || "".equals(ids.trim())) {
|
||||
result.error500("参数不识别!");
|
||||
}else {
|
||||
} else {
|
||||
this.sysCategoryService.deleteSysCategory(ids);
|
||||
result.success("删除成功!");
|
||||
}
|
||||
|
@ -190,16 +193,17 @@ public class SysCategoryController {
|
|||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<SysCategory> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
public Result<SysCategory> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
SysCategory sysCategory = sysCategoryService.getById(id);
|
||||
if(sysCategory==null) {
|
||||
if (sysCategory == null) {
|
||||
result.error500("未找到对应实体");
|
||||
}else {
|
||||
} else {
|
||||
result.setResult(sysCategory);
|
||||
result.setSuccess(true);
|
||||
}
|
||||
|
@ -215,7 +219,7 @@ public class SysCategoryController {
|
|||
public ModelAndView exportXls(HttpServletRequest request, SysCategory sysCategory) {
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) {
|
||||
sysCategory.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(), 0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
@ -227,9 +231,9 @@ public class SysCategoryController {
|
|||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
// 过滤选中数据
|
||||
String selections = request.getParameter("selections");
|
||||
if(oConvertUtils.isEmpty(selections)) {
|
||||
if (oConvertUtils.isEmpty(selections)) {
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
}else {
|
||||
} else {
|
||||
List<String> selectionList = Arrays.asList(selections.split(","));
|
||||
List<SysCategory> exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
|
||||
|
@ -238,7 +242,7 @@ public class SysCategoryController {
|
|||
mv.addObject(NormalExcelConstants.FILE_NAME, "分类字典列表");
|
||||
mv.addObject(NormalExcelConstants.CLASS, SysCategory.class);
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("分类字典列表数据", "导出人:"+user.getRealname(), "导出信息"));
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("分类字典列表数据", "导出人:" + user.getRealname(), "导出信息"));
|
||||
return mv;
|
||||
}
|
||||
|
||||
|
@ -250,7 +254,7 @@ public class SysCategoryController {
|
|||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) throws IOException{
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||
// 错误信息
|
||||
|
@ -267,19 +271,19 @@ public class SysCategoryController {
|
|||
List<SysCategory> listSysCategorys = ExcelImportUtil.importExcel(file.getInputStream(), SysCategory.class, params);
|
||||
//按照编码长度排序
|
||||
Collections.sort(listSysCategorys);
|
||||
log.info("排序后的list====>",listSysCategorys);
|
||||
log.info("排序后的list====>", listSysCategorys);
|
||||
for (int i = 0; i < listSysCategorys.size(); i++) {
|
||||
SysCategory sysCategoryExcel = listSysCategorys.get(i);
|
||||
String code = sysCategoryExcel.getCode();
|
||||
if(code.length()>3){
|
||||
String pCode = sysCategoryExcel.getCode().substring(0,code.length()-3);
|
||||
log.info("pCode====>",pCode);
|
||||
String pId=sysCategoryService.queryIdByCode(pCode);
|
||||
log.info("pId====>",pId);
|
||||
if(StringUtils.isNotBlank(pId)){
|
||||
if (code.length() > 3) {
|
||||
String pCode = sysCategoryExcel.getCode().substring(0, code.length() - 3);
|
||||
log.info("pCode====>", pCode);
|
||||
String pId = sysCategoryService.queryIdByCode(pCode);
|
||||
log.info("pId====>", pId);
|
||||
if (StringUtils.isNotBlank(pId)) {
|
||||
sysCategoryExcel.setPid(pId);
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
sysCategoryExcel.setPid("0");
|
||||
}
|
||||
try {
|
||||
|
@ -309,16 +313,15 @@ public class SysCategoryController {
|
|||
}
|
||||
}
|
||||
}
|
||||
return ImportExcelUtil.imporReturnRes(errorLines,successLines,errorMessage);
|
||||
return ImportExcelUtil.imporReturnRes(errorLines, successLines, errorMessage);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 加载单个数据 用于回显
|
||||
*/
|
||||
@RequestMapping(value = "/loadOne", method = RequestMethod.GET)
|
||||
public Result<SysCategory> loadOne(@RequestParam(name="field") String field,@RequestParam(name="val") String val) {
|
||||
public Result<SysCategory> loadOne(@RequestParam(name = "field") String field, @RequestParam(name = "val") String val) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
try {
|
||||
//update-begin-author:taoyan date:2022-5-6 for: issues/3663 sql注入问题
|
||||
|
@ -330,13 +333,13 @@ public class SysCategoryController {
|
|||
QueryWrapper<SysCategory> query = new QueryWrapper<SysCategory>();
|
||||
query.eq(field, val);
|
||||
List<SysCategory> ls = this.sysCategoryService.list(query);
|
||||
if(ls==null || ls.size()==0) {
|
||||
if (ls == null || ls.size() == 0) {
|
||||
result.setMessage("查询无果");
|
||||
result.setSuccess(false);
|
||||
}else if(ls.size()>1) {
|
||||
result.setMessage("查询数据异常,["+field+"]存在多个值:"+val);
|
||||
} else if (ls.size() > 1) {
|
||||
result.setMessage("查询数据异常,[" + field + "]存在多个值:" + val);
|
||||
result.setSuccess(false);
|
||||
}else {
|
||||
} else {
|
||||
result.setSuccess(true);
|
||||
result.setResult(ls.get(0));
|
||||
}
|
||||
|
@ -352,7 +355,7 @@ public class SysCategoryController {
|
|||
* 加载节点的子数据
|
||||
*/
|
||||
@RequestMapping(value = "/loadTreeChildren", method = RequestMethod.GET)
|
||||
public Result<List<TreeSelectModel>> loadTreeChildren(@RequestParam(name="pid") String pid) {
|
||||
public Result<List<TreeSelectModel>> loadTreeChildren(@RequestParam(name = "pid") String pid) {
|
||||
Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
|
||||
try {
|
||||
List<TreeSelectModel> ls = this.sysCategoryService.queryListByPid(pid);
|
||||
|
@ -370,12 +373,15 @@ public class SysCategoryController {
|
|||
* 加载一级节点/如果是同步 则所有数据
|
||||
*/
|
||||
@RequestMapping(value = "/loadTreeRoot", method = RequestMethod.GET)
|
||||
public Result<List<TreeSelectModel>> loadTreeRoot(@RequestParam(name="async") Boolean async,@RequestParam(name="pcode") String pcode) {
|
||||
public Result<List<TreeSelectModel>> loadTreeRoot(@RequestParam(name = "async") Boolean async, @RequestParam(name = "pcode") String pcode) {
|
||||
Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
|
||||
try {
|
||||
List<TreeSelectModel> ls = this.sysCategoryService.queryListByCode(pcode);
|
||||
if(!async) {
|
||||
loadAllCategoryChildren(ls);
|
||||
if (!async) {
|
||||
//框架自带傻逼for循环套sql 慎用 慢到想骂人 实测几百个非叶节点就已经爆炸了
|
||||
// loadAllCategoryChildren(ls);
|
||||
//一次sql查所有,系统代码处理循环生成树结构
|
||||
loadAllCategoryChildrenQO(ls);
|
||||
}
|
||||
result.setResult(ls);
|
||||
result.setSuccess(true);
|
||||
|
@ -393,32 +399,70 @@ public class SysCategoryController {
|
|||
private void loadAllCategoryChildren(List<TreeSelectModel> ls) {
|
||||
for (TreeSelectModel tsm : ls) {
|
||||
List<TreeSelectModel> temp = this.sysCategoryService.queryListByPid(tsm.getKey());
|
||||
if(temp!=null && temp.size()>0) {
|
||||
if (temp != null && temp.size() > 0) {
|
||||
tsm.setChildren(temp);
|
||||
loadAllCategoryChildren(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 只查询一次数据库,代码内容循环处理,避免for-sql
|
||||
*
|
||||
* @param ls
|
||||
*/
|
||||
private void loadAllCategoryChildrenQO(List<TreeSelectModel> ls) {
|
||||
// 1. 首先获取所有可能的pid值
|
||||
Set<String> pids = new HashSet<>();
|
||||
for (TreeSelectModel tsm : ls) {
|
||||
pids.add(tsm.getKey());
|
||||
}
|
||||
|
||||
// 2. 一次性查询所有可能需要的节点
|
||||
List<TreeSelectModel> allNodes = this.sysCategoryService.queryAllCategories();
|
||||
|
||||
// 3. 构建节点映射表
|
||||
Map<String, List<TreeSelectModel>> nodeMap = new HashMap<>();
|
||||
for (TreeSelectModel node : allNodes) {
|
||||
String parentId = node.getParentId();
|
||||
nodeMap.computeIfAbsent(parentId, k -> new ArrayList<>()).add(node);
|
||||
}
|
||||
|
||||
// 4. 递归构建树结构
|
||||
buildTree(ls, nodeMap);
|
||||
}
|
||||
|
||||
private void buildTree(List<TreeSelectModel> nodes, Map<String, List<TreeSelectModel>> nodeMap) {
|
||||
for (TreeSelectModel node : nodes) {
|
||||
String nodeKey = node.getKey();
|
||||
List<TreeSelectModel> children = nodeMap.get(nodeKey);
|
||||
if (children != null && !children.isEmpty()) {
|
||||
node.setChildren(children);
|
||||
buildTree(children, nodeMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验编码
|
||||
*
|
||||
* @param pid
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/checkCode")
|
||||
public Result<?> checkCode(@RequestParam(name="pid",required = false) String pid,@RequestParam(name="code",required = false) String code) {
|
||||
if(oConvertUtils.isEmpty(code)){
|
||||
public Result<?> checkCode(@RequestParam(name = "pid", required = false) String pid, @RequestParam(name = "code", required = false) String code) {
|
||||
if (oConvertUtils.isEmpty(code)) {
|
||||
return Result.error("错误,类型编码为空!");
|
||||
}
|
||||
if(oConvertUtils.isEmpty(pid)){
|
||||
if (oConvertUtils.isEmpty(pid)) {
|
||||
return Result.ok();
|
||||
}
|
||||
SysCategory parent = this.sysCategoryService.getById(pid);
|
||||
if(code.startsWith(parent.getCode())){
|
||||
if (code.startsWith(parent.getCode())) {
|
||||
return Result.ok();
|
||||
}else{
|
||||
return Result.error("编码不符合规范,须以\""+parent.getCode()+"\"开头!");
|
||||
} else {
|
||||
return Result.error("编码不符合规范,须以\"" + parent.getCode() + "\"开头!");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -426,27 +470,28 @@ public class SysCategoryController {
|
|||
|
||||
/**
|
||||
* 分类字典树控件 加载节点
|
||||
*
|
||||
* @param pid
|
||||
* @param pcode
|
||||
* @param condition
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/loadTreeData", method = RequestMethod.GET)
|
||||
public Result<List<TreeSelectModel>> loadDict(@RequestParam(name="pid",required = false) String pid,@RequestParam(name="pcode",required = false) String pcode, @RequestParam(name="condition",required = false) String condition) {
|
||||
public Result<List<TreeSelectModel>> loadDict(@RequestParam(name = "pid", required = false) String pid, @RequestParam(name = "pcode", required = false) String pcode, @RequestParam(name = "condition", required = false) String condition) {
|
||||
Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
|
||||
//pid如果传值了 就忽略pcode的作用
|
||||
if(oConvertUtils.isEmpty(pid)){
|
||||
if(oConvertUtils.isEmpty(pcode)){
|
||||
if (oConvertUtils.isEmpty(pid)) {
|
||||
if (oConvertUtils.isEmpty(pcode)) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("加载分类字典树参数有误.[null]!");
|
||||
return result;
|
||||
}else{
|
||||
if(ISysCategoryService.ROOT_PID_VALUE.equals(pcode)){
|
||||
} else {
|
||||
if (ISysCategoryService.ROOT_PID_VALUE.equals(pcode)) {
|
||||
pid = ISysCategoryService.ROOT_PID_VALUE;
|
||||
}else{
|
||||
} else {
|
||||
pid = this.sysCategoryService.queryIdByCode(pcode);
|
||||
}
|
||||
if(oConvertUtils.isEmpty(pid)){
|
||||
if (oConvertUtils.isEmpty(pid)) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("加载分类字典树参数有误.[code]!");
|
||||
return result;
|
||||
|
@ -454,10 +499,10 @@ public class SysCategoryController {
|
|||
}
|
||||
}
|
||||
Map<String, String> query = null;
|
||||
if(oConvertUtils.isNotEmpty(condition)) {
|
||||
if (oConvertUtils.isNotEmpty(condition)) {
|
||||
query = JSON.parseObject(condition, Map.class);
|
||||
}
|
||||
List<TreeSelectModel> ls = sysCategoryService.queryListByPid(pid,query);
|
||||
List<TreeSelectModel> ls = sysCategoryService.queryListByPid(pid, query);
|
||||
result.setSuccess(true);
|
||||
result.setResult(ls);
|
||||
return result;
|
||||
|
@ -488,25 +533,26 @@ public class SysCategoryController {
|
|||
|
||||
/**
|
||||
* [列表页面]加载分类字典数据 用于值的替换
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/loadAllData", method = RequestMethod.GET)
|
||||
public Result<List<DictModel>> loadAllData(@RequestParam(name="code",required = true) String code) {
|
||||
public Result<List<DictModel>> loadAllData(@RequestParam(name = "code", required = true) String code) {
|
||||
Result<List<DictModel>> result = new Result<List<DictModel>>();
|
||||
LambdaQueryWrapper<SysCategory> query = new LambdaQueryWrapper<SysCategory>();
|
||||
if(oConvertUtils.isNotEmpty(code) && !CATEGORY_ROOT_CODE.equals(code)){
|
||||
query.likeRight(SysCategory::getCode,code);
|
||||
if (oConvertUtils.isNotEmpty(code) && !CATEGORY_ROOT_CODE.equals(code)) {
|
||||
query.likeRight(SysCategory::getCode, code);
|
||||
}
|
||||
List<SysCategory> list = this.sysCategoryService.list(query);
|
||||
if(list==null || list.size()==0) {
|
||||
if (list == null || list.size() == 0) {
|
||||
result.setMessage("无数据,参数有误.[code]");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
List<DictModel> rdList = new ArrayList<DictModel>();
|
||||
for (SysCategory c : list) {
|
||||
rdList.add(new DictModel(c.getId(),c.getName()));
|
||||
rdList.add(new DictModel(c.getId(), c.getName()));
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(rdList);
|
||||
|
@ -515,6 +561,7 @@ public class SysCategoryController {
|
|||
|
||||
/**
|
||||
* 根据父级id批量查询子节点
|
||||
*
|
||||
* @param parentIds
|
||||
* @return
|
||||
*/
|
||||
|
|
|
@ -703,6 +703,7 @@ public class SysDepartController {
|
|||
map.put("id",depart.getId());
|
||||
map.put("departName",depart.getDepartName());
|
||||
map.put("serverUrl",depart.getServerUrl());
|
||||
map.put("picUrl",depart.getPicUrl());
|
||||
result.add(map);
|
||||
}
|
||||
return result;
|
||||
|
@ -724,4 +725,5 @@ public class SysDepartController {
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.jeecg.modules.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
@ -9,6 +10,7 @@ import org.jeecgframework.poi.excel.annotation.Excel;
|
|||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 分类字典
|
||||
|
@ -18,41 +20,69 @@ import java.io.Serializable;
|
|||
*/
|
||||
@Data
|
||||
@TableName("sys_category")
|
||||
public class SysCategory implements Serializable,Comparable<SysCategory>{
|
||||
public class SysCategory implements Serializable, Comparable<SysCategory> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**主键*/
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private java.lang.String id;
|
||||
/**父级节点*/
|
||||
/**
|
||||
* 父级节点
|
||||
*/
|
||||
private java.lang.String pid;
|
||||
/**类型名称*/
|
||||
/**
|
||||
* 类型名称
|
||||
*/
|
||||
@Excel(name = "类型名称", width = 15)
|
||||
private java.lang.String name;
|
||||
/**类型编码*/
|
||||
/**
|
||||
* 类型编码
|
||||
*/
|
||||
@Excel(name = "类型编码", width = 15)
|
||||
private java.lang.String code;
|
||||
/**创建人*/
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private java.lang.String createBy;
|
||||
/**创建日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
/**
|
||||
* 创建日期
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date createTime;
|
||||
/**更新人*/
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private java.lang.String updateBy;
|
||||
/**更新日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
/**
|
||||
* 更新日期
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date updateTime;
|
||||
/**所属部门*/
|
||||
/**
|
||||
* 所属部门
|
||||
*/
|
||||
private java.lang.String sysOrgCode;
|
||||
/**是否有子节点*/
|
||||
/**
|
||||
* 是否有子节点
|
||||
*/
|
||||
@Excel(name = "是否有子节点(1:有)", width = 15)
|
||||
private java.lang.String hasChild;
|
||||
|
||||
/**租户ID*/
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private java.lang.Integer tenantId;
|
||||
|
||||
/**
|
||||
* 子节点列表 - 非数据库字段
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<SysCategory> children;
|
||||
|
||||
@Override
|
||||
public int compareTo(SysCategory o) {
|
||||
//比较条件我们定的是按照code的长度升序
|
||||
|
@ -62,8 +92,17 @@ public class SysCategory implements Serializable,Comparable<SysCategory>{
|
|||
int s = this.code.length() - o.code.length();
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SysCategory [code=" + code + ", name=" + name + "]";
|
||||
}
|
||||
|
||||
public List<SysCategory> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<SysCategory> children) {
|
||||
this.children = children;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,101 +27,184 @@ import java.util.Objects;
|
|||
public class SysDepart implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**ID*/
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
/**父机构ID*/
|
||||
/**
|
||||
* 父机构ID
|
||||
*/
|
||||
private String parentId;
|
||||
/**机构/部门名称*/
|
||||
@Excel(name="机构/部门名称",width=15)
|
||||
/**
|
||||
* 机构/部门名称
|
||||
*/
|
||||
@Excel(name = "机构/部门名称", width = 15)
|
||||
private String departName;
|
||||
/**英文名*/
|
||||
@Excel(name="英文名",width=15)
|
||||
/**
|
||||
* 英文名
|
||||
*/
|
||||
@Excel(name = "英文名", width = 15)
|
||||
private String departNameEn;
|
||||
/**缩写*/
|
||||
/**
|
||||
* 缩写
|
||||
*/
|
||||
private String departNameAbbr;
|
||||
/**排序*/
|
||||
@Excel(name="排序",width=15)
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@Excel(name = "排序", width = 15)
|
||||
private Integer departOrder;
|
||||
/**描述*/
|
||||
@Excel(name="描述",width=15)
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Excel(name = "描述", width = 15)
|
||||
private String description;
|
||||
/**机构类别 1=公司,2=组织机构,3=岗位*/
|
||||
@Excel(name="机构类别",width=15,dicCode="org_category")
|
||||
/**
|
||||
* 机构类别 1=公司,2=组织机构,3=岗位
|
||||
*/
|
||||
@Excel(name = "机构类别", width = 15, dicCode = "org_category")
|
||||
private String orgCategory;
|
||||
/**机构类型*/
|
||||
/**
|
||||
* 机构类型
|
||||
*/
|
||||
private String orgType;
|
||||
/**机构编码*/
|
||||
@Excel(name="机构编码",width=15)
|
||||
/**
|
||||
* 机构编码
|
||||
*/
|
||||
@Excel(name = "机构编码", width = 15)
|
||||
private String orgCode;
|
||||
/**业务平台类型*/
|
||||
@Excel(name="业务平台类型",width=15)
|
||||
/**
|
||||
* 省份
|
||||
*/
|
||||
@Excel(name = "省份", width = 30)
|
||||
private String province;
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
@Excel(name = "城市", width = 30)
|
||||
private String city;
|
||||
/**
|
||||
* 区县
|
||||
*/
|
||||
@Excel(name = "区县", width = 30)
|
||||
private String district;
|
||||
/**
|
||||
* 业务平台类型
|
||||
*/
|
||||
@Excel(name = "业务平台类型", width = 15)
|
||||
@Dict(dicCode = "iz_test_site")
|
||||
private String platType;
|
||||
/**运营开始时间*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
/**
|
||||
* 运营开始时间
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date operationStartTime;
|
||||
/**运营到期时间*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
/**
|
||||
* 运营到期时间
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date operationEndTime;
|
||||
/**合同开始时间*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
/**
|
||||
* 合同开始时间
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date contractStartTime;
|
||||
/**合同到期时间*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
/**
|
||||
* 合同到期时间
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date contractEndTime;
|
||||
/**手机号*/
|
||||
@Excel(name="手机号",width=15)
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@Excel(name = "手机号", width = 15)
|
||||
private String mobile;
|
||||
/**传真*/
|
||||
@Excel(name="传真",width=15)
|
||||
/**
|
||||
* 传真
|
||||
*/
|
||||
@Excel(name = "传真", width = 15)
|
||||
private String fax;
|
||||
/**地址*/
|
||||
@Excel(name="地址",width=15)
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
@Excel(name = "地址", width = 15)
|
||||
private String address;
|
||||
/**备注*/
|
||||
@Excel(name="备注",width=15)
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Excel(name = "备注", width = 15)
|
||||
private String memo;
|
||||
/**状态(1启用,0不启用)*/
|
||||
/**
|
||||
* 状态(1启用,0不启用)
|
||||
*/
|
||||
@Dict(dicCode = "depart_status")
|
||||
private String status;
|
||||
/**删除状态(0,正常,1已删除)*/
|
||||
/**
|
||||
* 删除状态(0,正常,1已删除)
|
||||
*/
|
||||
@Dict(dicCode = "del_flag")
|
||||
private String delFlag;
|
||||
/**对接企业微信的ID*/
|
||||
/**
|
||||
* 对接企业微信的ID
|
||||
*/
|
||||
private String qywxIdentifier;
|
||||
/**对接钉钉的部门ID*/
|
||||
/**
|
||||
* 对接钉钉的部门ID
|
||||
*/
|
||||
private String dingIdentifier;
|
||||
/**创建人*/
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
/**创建日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
/**
|
||||
* 创建日期
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
/**更新人*/
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
/**更新日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
/**
|
||||
* 更新日期
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
/**租户ID*/
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private java.lang.Integer tenantId;
|
||||
|
||||
/**是否有叶子节点: 1是0否*/
|
||||
/**
|
||||
* 是否有叶子节点: 1是0否
|
||||
*/
|
||||
private Integer izLeaf;
|
||||
|
||||
/**各机构服务器后台接口地址*/
|
||||
/**
|
||||
* 各机构服务器后台接口地址
|
||||
*/
|
||||
private String serverUrl;
|
||||
/**
|
||||
* 各机构服务器后台接口地址
|
||||
*/
|
||||
private String picUrl;
|
||||
|
||||
//update-begin---author:wangshuai ---date:20200308 for:[JTC-119]在部门管理菜单下设置部门负责人,新增字段负责人ids和旧的负责人ids
|
||||
/**部门负责人的ids*/
|
||||
/**
|
||||
* 部门负责人的ids
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String directorUserIds;
|
||||
/**旧的部门负责人的ids(用于比较删除和新增)*/
|
||||
/**
|
||||
* 旧的部门负责人的ids(用于比较删除和新增)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String oldDirectorUserIds;
|
||||
//update-end---author:wangshuai ---date:20200308 for:[JTC-119]新增字段负责人ids和旧的负责人ids
|
||||
|
@ -151,6 +234,9 @@ public class SysDepart implements Serializable {
|
|||
Objects.equals(orgCategory, depart.orgCategory) &&
|
||||
Objects.equals(orgType, depart.orgType) &&
|
||||
Objects.equals(orgCode, depart.orgCode) &&
|
||||
Objects.equals(province, depart.province) &&
|
||||
Objects.equals(city, depart.city) &&
|
||||
Objects.equals(district, depart.district) &&
|
||||
Objects.equals(mobile, depart.mobile) &&
|
||||
Objects.equals(fax, depart.fax) &&
|
||||
Objects.equals(address, depart.address) &&
|
||||
|
@ -170,8 +256,8 @@ public class SysDepart implements Serializable {
|
|||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), id, parentId, departName,
|
||||
departNameEn, departNameAbbr, departOrder, description,orgCategory,
|
||||
orgType, orgCode, mobile, fax, address, memo, status,
|
||||
departNameEn, departNameAbbr, departOrder, description, orgCategory,
|
||||
orgType, orgCode, province, city, district, mobile, fax, address, memo, status,
|
||||
delFlag, createBy, createTime, updateBy, updateTime, tenantId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,4 +48,6 @@ public interface SysCategoryMapper extends BaseMapper<SysCategory> {
|
|||
@InterceptorIgnore(tenantLine = "true")
|
||||
@Select("SELECT code FROM sys_category WHERE ID = #{id}")
|
||||
SysCategory selectSysCategoryById(@Param("id") String id);
|
||||
|
||||
List<TreeSelectModel> queryAllCategories();
|
||||
}
|
||||
|
|
|
@ -32,6 +32,15 @@
|
|||
</if>
|
||||
</if>
|
||||
</select>
|
||||
<select id="queryAllCategories" resultType="org.jeecg.modules.system.model.TreeSelectModel">
|
||||
select code,
|
||||
name as "title",
|
||||
id as "key",
|
||||
(case when has_child = '1' then 0 else 1 end) as isLeaf,
|
||||
pid as parentId
|
||||
from sys_category
|
||||
order by code
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -18,17 +18,23 @@ import java.util.Objects;
|
|||
* @Author Steve
|
||||
* @Since 2019-01-22
|
||||
*/
|
||||
public class SysDepartTreeModel implements Serializable{
|
||||
public class SysDepartTreeModel implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 对应SysDepart中的id字段,前端数据树中的key*/
|
||||
/**
|
||||
* 对应SysDepart中的id字段,前端数据树中的key
|
||||
*/
|
||||
private String key;
|
||||
|
||||
/** 对应SysDepart中的id字段,前端数据树中的value*/
|
||||
/**
|
||||
* 对应SysDepart中的id字段,前端数据树中的value
|
||||
*/
|
||||
private String value;
|
||||
|
||||
/** 对应depart_name字段,前端数据树中的title*/
|
||||
/**
|
||||
* 对应depart_name字段,前端数据树中的title
|
||||
*/
|
||||
private String title;
|
||||
|
||||
|
||||
|
@ -57,6 +63,12 @@ public class SysDepartTreeModel implements Serializable{
|
|||
|
||||
private String orgCode;
|
||||
|
||||
private String province;
|
||||
|
||||
private String city;
|
||||
|
||||
private String district;
|
||||
|
||||
private Date operationStartTime;
|
||||
|
||||
private Date operationEndTime;
|
||||
|
@ -87,8 +99,12 @@ public class SysDepartTreeModel implements Serializable{
|
|||
|
||||
private Date updateTime;
|
||||
|
||||
private String picUrl;
|
||||
|
||||
//update-begin---author:wangshuai ---date:20200308 for:[JTC-119]在部门管理菜单下设置部门负责人,新增字段部门负责人ids
|
||||
/**部门负责人ids*/
|
||||
/**
|
||||
* 部门负责人ids
|
||||
*/
|
||||
private String directorUserIds;
|
||||
//update-end---author:wangshuai ---date:20200308 for:[JTC-119]在部门管理菜单下设置部门负责人,新增字段部门负责人ids
|
||||
|
||||
|
@ -97,6 +113,7 @@ public class SysDepartTreeModel implements Serializable{
|
|||
|
||||
/**
|
||||
* 将SysDepart对象转换成SysDepartTreeModel对象
|
||||
*
|
||||
* @param sysDepart
|
||||
*/
|
||||
public SysDepartTreeModel(SysDepart sysDepart) {
|
||||
|
@ -114,6 +131,9 @@ public class SysDepartTreeModel implements Serializable{
|
|||
this.orgCategory = sysDepart.getOrgCategory();
|
||||
this.orgType = sysDepart.getOrgType();
|
||||
this.orgCode = sysDepart.getOrgCode();
|
||||
this.province = sysDepart.getProvince();
|
||||
this.city = sysDepart.getCity();
|
||||
this.district = sysDepart.getDistrict();
|
||||
this.operationStartTime = sysDepart.getOperationStartTime();
|
||||
this.operationEndTime = sysDepart.getOperationEndTime();
|
||||
this.contractStartTime = sysDepart.getContractStartTime();
|
||||
|
@ -130,9 +150,10 @@ public class SysDepartTreeModel implements Serializable{
|
|||
this.updateBy = sysDepart.getUpdateBy();
|
||||
this.updateTime = sysDepart.getUpdateTime();
|
||||
this.directorUserIds = sysDepart.getDirectorUserIds();
|
||||
if(0 == sysDepart.getIzLeaf()){
|
||||
this.picUrl = sysDepart.getPicUrl();
|
||||
if (0 == sysDepart.getIzLeaf()) {
|
||||
this.isLeaf = false;
|
||||
}else{
|
||||
} else {
|
||||
this.isLeaf = true;
|
||||
}
|
||||
}
|
||||
|
@ -188,8 +209,8 @@ public class SysDepartTreeModel implements Serializable{
|
|||
}
|
||||
|
||||
public void setChildren(List<SysDepartTreeModel> children) {
|
||||
if (children==null){
|
||||
this.isLeaf=true;
|
||||
if (children == null) {
|
||||
this.isLeaf = true;
|
||||
}
|
||||
this.children = children;
|
||||
}
|
||||
|
@ -398,7 +419,8 @@ public class SysDepartTreeModel implements Serializable{
|
|||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public SysDepartTreeModel() { }
|
||||
public SysDepartTreeModel() {
|
||||
}
|
||||
|
||||
public String getDirectorUserIds() {
|
||||
return directorUserIds;
|
||||
|
@ -408,6 +430,38 @@ public class SysDepartTreeModel implements Serializable{
|
|||
this.directorUserIds = directorUserIds;
|
||||
}
|
||||
|
||||
public String getPicUrl() {
|
||||
return picUrl;
|
||||
}
|
||||
|
||||
public void setPicUrl(String picUrl) {
|
||||
this.picUrl = picUrl;
|
||||
}
|
||||
|
||||
public String getProvince() {
|
||||
return province;
|
||||
}
|
||||
|
||||
public void setProvince(String province) {
|
||||
this.province = province;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getDistrict() {
|
||||
return district;
|
||||
}
|
||||
|
||||
public void setDistrict(String district) {
|
||||
this.district = district;
|
||||
}
|
||||
|
||||
/**
|
||||
* 重写equals方法
|
||||
*/
|
||||
|
@ -431,6 +485,9 @@ public class SysDepartTreeModel implements Serializable{
|
|||
Objects.equals(orgCategory, model.orgCategory) &&
|
||||
Objects.equals(orgType, model.orgType) &&
|
||||
Objects.equals(orgCode, model.orgCode) &&
|
||||
Objects.equals(province, model.province) &&
|
||||
Objects.equals(city, model.city) &&
|
||||
Objects.equals(district, model.district) &&
|
||||
Objects.equals(operationStartTime, model.operationStartTime) &&
|
||||
Objects.equals(operationEndTime, model.operationEndTime) &&
|
||||
Objects.equals(contractStartTime, model.contractStartTime) &&
|
||||
|
@ -457,10 +514,10 @@ public class SysDepartTreeModel implements Serializable{
|
|||
public int hashCode() {
|
||||
|
||||
return Objects.hash(id, parentId, platType, departName, departNameEn, departNameAbbr,
|
||||
departOrder, description, orgCategory, orgType, orgCode,
|
||||
departOrder, description, orgCategory, orgType, orgCode, province, city, district,
|
||||
operationStartTime, operationEndTime, contractStartTime, contractEndTime,
|
||||
mobile, fax, address, memo, status, delFlag, qywxIdentifier,
|
||||
createBy, createTime, updateBy, updateTime, children,directorUserIds);
|
||||
createBy, createTime, updateBy, updateTime, children, directorUserIds);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -51,6 +51,8 @@ public interface ISysCategoryService extends IService<SysCategory> {
|
|||
*/
|
||||
public List<TreeSelectModel> queryListByPid(String pid);
|
||||
|
||||
public List<TreeSelectModel> queryAllCategories();
|
||||
|
||||
/**
|
||||
* 根据pid查询子节点集合,支持查询条件
|
||||
* @param pid
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jeecg.common.constant.FillRuleConstant;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
|
@ -34,14 +35,14 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
|
|||
String categoryCode = "";
|
||||
String categoryPid = ISysCategoryService.ROOT_PID_VALUE;
|
||||
String parentCode = null;
|
||||
if(oConvertUtils.isNotEmpty(sysCategory.getPid())){
|
||||
if (oConvertUtils.isNotEmpty(sysCategory.getPid())) {
|
||||
categoryPid = sysCategory.getPid();
|
||||
|
||||
//PID 不是根节点 说明需要设置父节点 hasChild 为1
|
||||
if(!ISysCategoryService.ROOT_PID_VALUE.equals(categoryPid)){
|
||||
if (!ISysCategoryService.ROOT_PID_VALUE.equals(categoryPid)) {
|
||||
SysCategory parent = baseMapper.selectById(categoryPid);
|
||||
parentCode = parent.getCode();
|
||||
if(parent!=null && !ISysCategoryService.HAS_CHILD.equals(parent.getHasChild())){
|
||||
if (parent != null && !ISysCategoryService.HAS_CHILD.equals(parent.getHasChild())) {
|
||||
parent.setHasChild(ISysCategoryService.HAS_CHILD);
|
||||
baseMapper.updateById(parent);
|
||||
}
|
||||
|
@ -49,22 +50,24 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
|
|||
}
|
||||
//update-begin--Author:baihailong Date:20191209 for:分类字典编码规则生成器做成公用配置
|
||||
JSONObject formData = new JSONObject();
|
||||
formData.put("pid",categoryPid);
|
||||
categoryCode = (String) FillRuleUtil.executeRule(FillRuleConstant.CATEGORY,formData);
|
||||
formData.put("pid", categoryPid);
|
||||
categoryCode = (String) FillRuleUtil.executeRule(FillRuleConstant.CATEGORY, formData);
|
||||
//update-end--Author:baihailong Date:20191209 for:分类字典编码规则生成器做成公用配置
|
||||
if (StringUtils.isBlank(sysCategory.getCode())) {
|
||||
sysCategory.setCode(categoryCode);
|
||||
}
|
||||
sysCategory.setPid(categoryPid);
|
||||
baseMapper.insert(sysCategory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSysCategory(SysCategory sysCategory) {
|
||||
if(oConvertUtils.isEmpty(sysCategory.getPid())){
|
||||
if (oConvertUtils.isEmpty(sysCategory.getPid())) {
|
||||
sysCategory.setPid(ISysCategoryService.ROOT_PID_VALUE);
|
||||
}else{
|
||||
} else {
|
||||
//如果当前节点父ID不为空 则设置父节点的hasChild 为1
|
||||
SysCategory parent = baseMapper.selectById(sysCategory.getPid());
|
||||
if(parent!=null && !ISysCategoryService.HAS_CHILD.equals(parent.getHasChild())){
|
||||
if (parent != null && !ISysCategoryService.HAS_CHILD.equals(parent.getHasChild())) {
|
||||
parent.setHasChild(ISysCategoryService.HAS_CHILD);
|
||||
baseMapper.updateById(parent);
|
||||
}
|
||||
|
@ -73,35 +76,40 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<TreeSelectModel> queryListByCode(String pcode) throws JeecgBootException{
|
||||
public List<TreeSelectModel> queryListByCode(String pcode) throws JeecgBootException {
|
||||
String pid = ROOT_PID_VALUE;
|
||||
if(oConvertUtils.isNotEmpty(pcode)) {
|
||||
if (oConvertUtils.isNotEmpty(pcode)) {
|
||||
List<SysCategory> list = baseMapper.selectList(new LambdaQueryWrapper<SysCategory>().eq(SysCategory::getCode, pcode));
|
||||
if(list==null || list.size() ==0) {
|
||||
throw new JeecgBootException("该编码【"+pcode+"】不存在,请核实!");
|
||||
if (list == null || list.size() == 0) {
|
||||
throw new JeecgBootException("该编码【" + pcode + "】不存在,请核实!");
|
||||
}
|
||||
if(list.size()>1) {
|
||||
throw new JeecgBootException("该编码【"+pcode+"】存在多个,请核实!");
|
||||
if (list.size() > 1) {
|
||||
throw new JeecgBootException("该编码【" + pcode + "】存在多个,请核实!");
|
||||
}
|
||||
pid = list.get(0).getId();
|
||||
}
|
||||
return baseMapper.queryListByPid(pid,null);
|
||||
return baseMapper.queryListByPid(pid, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeSelectModel> queryListByPid(String pid) {
|
||||
if(oConvertUtils.isEmpty(pid)) {
|
||||
if (oConvertUtils.isEmpty(pid)) {
|
||||
pid = ROOT_PID_VALUE;
|
||||
}
|
||||
return baseMapper.queryListByPid(pid,null);
|
||||
return baseMapper.queryListByPid(pid, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeSelectModel> queryAllCategories() {
|
||||
return baseMapper.queryAllCategories();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeSelectModel> queryListByPid(String pid, Map<String, String> condition) {
|
||||
if(oConvertUtils.isEmpty(pid)) {
|
||||
if (oConvertUtils.isEmpty(pid)) {
|
||||
pid = ROOT_PID_VALUE;
|
||||
}
|
||||
return baseMapper.queryListByPid(pid,condition);
|
||||
return baseMapper.queryListByPid(pid, condition);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -117,17 +125,18 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
|
|||
//1.删除时将节点下所有子节点一并删除
|
||||
this.baseMapper.deleteBatchIds(Arrays.asList(allIds.split(",")));
|
||||
//2.将父节点中已经没有下级的节点,修改为没有子节点
|
||||
if(oConvertUtils.isNotEmpty(pids)){
|
||||
if (oConvertUtils.isNotEmpty(pids)) {
|
||||
LambdaUpdateWrapper<SysCategory> updateWrapper = new UpdateWrapper<SysCategory>()
|
||||
.lambda()
|
||||
.in(SysCategory::getId,Arrays.asList(pids.split(",")))
|
||||
.set(SysCategory::getHasChild,"0");
|
||||
.in(SysCategory::getId, Arrays.asList(pids.split(",")))
|
||||
.set(SysCategory::getHasChild, "0");
|
||||
this.update(updateWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询节点下所有子节点
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
|
@ -136,13 +145,13 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
|
|||
String[] idArr = ids.split(",");
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (String pidVal : idArr) {
|
||||
if(pidVal != null){
|
||||
if(!sb.toString().contains(pidVal)){
|
||||
if(sb.toString().length() > 0){
|
||||
if (pidVal != null) {
|
||||
if (!sb.toString().contains(pidVal)) {
|
||||
if (sb.toString().length() > 0) {
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append(pidVal);
|
||||
this.getTreeChildIds(pidVal,sb);
|
||||
this.getTreeChildIds(pidVal, sb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -151,6 +160,7 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
|
|||
|
||||
/**
|
||||
* 查询需修改标识的父节点ids
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
|
@ -159,24 +169,24 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
|
|||
//获取id数组
|
||||
String[] idArr = ids.split(",");
|
||||
for (String id : idArr) {
|
||||
if(id != null){
|
||||
if (id != null) {
|
||||
SysCategory category = this.baseMapper.selectById(id);
|
||||
//根据id查询pid值
|
||||
String metaPid = category.getPid();
|
||||
//查询此节点上一级是否还有其他子节点
|
||||
LambdaQueryWrapper<SysCategory> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysCategory::getPid,metaPid);
|
||||
queryWrapper.notIn(SysCategory::getId,Arrays.asList(idArr));
|
||||
queryWrapper.eq(SysCategory::getPid, metaPid);
|
||||
queryWrapper.notIn(SysCategory::getId, Arrays.asList(idArr));
|
||||
List<SysCategory> dataList = this.baseMapper.selectList(queryWrapper);
|
||||
boolean flag = (dataList == null || dataList.size()==0) && !Arrays.asList(idArr).contains(metaPid)
|
||||
boolean flag = (dataList == null || dataList.size() == 0) && !Arrays.asList(idArr).contains(metaPid)
|
||||
&& !sb.toString().contains(metaPid);
|
||||
if(flag){
|
||||
if (flag) {
|
||||
//如果当前节点原本有子节点 现在木有了,更新状态
|
||||
sb.append(metaPid).append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
if(sb.toString().endsWith(SymbolConstant.COMMA)){
|
||||
if (sb.toString().endsWith(SymbolConstant.COMMA)) {
|
||||
sb = sb.deleteCharAt(sb.length() - 1);
|
||||
}
|
||||
return sb.toString();
|
||||
|
@ -184,17 +194,18 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
|
|||
|
||||
/**
|
||||
* 递归 根据父id获取子节点id
|
||||
*
|
||||
* @param pidVal
|
||||
* @param sb
|
||||
* @return
|
||||
*/
|
||||
private StringBuffer getTreeChildIds(String pidVal,StringBuffer sb){
|
||||
private StringBuffer getTreeChildIds(String pidVal, StringBuffer sb) {
|
||||
LambdaQueryWrapper<SysCategory> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysCategory::getPid,pidVal);
|
||||
queryWrapper.eq(SysCategory::getPid, pidVal);
|
||||
List<SysCategory> dataList = baseMapper.selectList(queryWrapper);
|
||||
if(dataList != null && dataList.size()>0){
|
||||
for(SysCategory category : dataList) {
|
||||
if(!sb.toString().contains(category.getId())){
|
||||
if (dataList != null && dataList.size() > 0) {
|
||||
for (SysCategory category : dataList) {
|
||||
if (!sb.toString().contains(category.getId())) {
|
||||
sb.append(",").append(category.getId());
|
||||
}
|
||||
this.getTreeChildIds(category.getId(), sb);
|
||||
|
|
|
@ -363,10 +363,19 @@ justauth:
|
|||
type: default
|
||||
prefix: 'demo::'
|
||||
timeout: 1h
|
||||
|
||||
#zmy
|
||||
aliyun:
|
||||
ocr:
|
||||
accessKeyId: LTAI5tMoCTt4sb9VQrcnZFsb
|
||||
accessKeySecret: pQBMT6TlUWgRfvvDnOu0IKVYXCfKee
|
||||
# accessKeyId: LTAI5tMoCTt4sb9VQrcnZFsb
|
||||
# accessKeySecret: pQBMT6TlUWgRfvvDnOu0IKVYXCfKee
|
||||
accessKeyId: LTAI5tJxmaqyXSG1T8Q6PSE9
|
||||
accessKeySecret: baBJyQOvph6dVugiSnx3tsiEuJeMy3
|
||||
#文件传输秘钥
|
||||
downloadkey: hP2K9Z!WLuj"M#8,
|
||||
|
||||
# 微信
|
||||
wechat:
|
||||
appId: wx8fc3e4305d2fbf0b
|
||||
appSecret: 3bf3dd4ec72f591432db6b28c2c044e5
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
server:
|
||||
port: 8082
|
||||
port: 8080
|
||||
tomcat:
|
||||
max-swallow-size: -1
|
||||
error:
|
||||
|
@ -7,7 +7,7 @@ server:
|
|||
include-stacktrace: ALWAYS
|
||||
include-message: ALWAYS
|
||||
servlet:
|
||||
context-path: /nursing-unit-nacos
|
||||
context-path: /nursing-unit
|
||||
compression:
|
||||
enabled: true
|
||||
min-response-size: 1024
|
||||
|
@ -362,6 +362,7 @@ justauth:
|
|||
type: default
|
||||
prefix: 'demo::'
|
||||
timeout: 1h
|
||||
|
||||
#zmy
|
||||
aliyun:
|
||||
ocr:
|
||||
|
@ -369,3 +370,8 @@ aliyun:
|
|||
accessKeySecret: pQBMT6TlUWgRfvvDnOu0IKVYXCfKee
|
||||
#文件传输秘钥
|
||||
downloadkey: hP2K9Z!WLuj"M#8,
|
||||
|
||||
# 微信
|
||||
wechat:
|
||||
appId: wx8fc3e4305d2fbf0b
|
||||
appSecret: 3bf3dd4ec72f591432db6b28c2c044e5
|
||||
|
|
Loading…
Reference in New Issue