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);
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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,61 +10,99 @@ import org.jeecgframework.poi.excel.annotation.Excel;
|
|||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 分类字典
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2019-05-29
|
||||
* @Date: 2019-05-29
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@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")
|
||||
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")
|
||||
private java.util.Date updateTime;
|
||||
/**所属部门*/
|
||||
private java.lang.String sysOrgCode;
|
||||
/**是否有子节点*/
|
||||
@Excel(name = "是否有子节点(1:有)", width = 15)
|
||||
private java.lang.String hasChild;
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@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")
|
||||
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")
|
||||
private java.util.Date updateTime;
|
||||
/**
|
||||
* 所属部门
|
||||
*/
|
||||
private java.lang.String sysOrgCode;
|
||||
/**
|
||||
* 是否有子节点
|
||||
*/
|
||||
@Excel(name = "是否有子节点(1:有)", width = 15)
|
||||
private java.lang.String hasChild;
|
||||
|
||||
/**租户ID*/
|
||||
private java.lang.Integer tenantId;
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private java.lang.Integer tenantId;
|
||||
|
||||
@Override
|
||||
public int compareTo(SysCategory o) {
|
||||
//比较条件我们定的是按照code的长度升序
|
||||
// <0:当前对象比传入对象小。
|
||||
// =0:当前对象等于传入对象。
|
||||
// >0:当前对象比传入对象大。
|
||||
int s = this.code.length() - o.code.length();
|
||||
return s;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SysCategory [code=" + code + ", name=" + name + "]";
|
||||
}
|
||||
/**
|
||||
* 子节点列表 - 非数据库字段
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<SysCategory> children;
|
||||
|
||||
@Override
|
||||
public int compareTo(SysCategory o) {
|
||||
//比较条件我们定的是按照code的长度升序
|
||||
// <0:当前对象比传入对象小。
|
||||
// =0:当前对象等于传入对象。
|
||||
// >0:当前对象比传入对象大。
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,126 +20,209 @@ import java.util.Objects;
|
|||
* <p>
|
||||
*
|
||||
* @Author Steve
|
||||
* @Since 2019-01-22
|
||||
* @Since 2019-01-22
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_depart")
|
||||
public class SysDepart implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**ID*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
/**父机构ID*/
|
||||
private String parentId;
|
||||
/**机构/部门名称*/
|
||||
@Excel(name="机构/部门名称",width=15)
|
||||
private String departName;
|
||||
/**英文名*/
|
||||
@Excel(name="英文名",width=15)
|
||||
private String departNameEn;
|
||||
/**缩写*/
|
||||
private String departNameAbbr;
|
||||
/**排序*/
|
||||
@Excel(name="排序",width=15)
|
||||
private Integer departOrder;
|
||||
/**描述*/
|
||||
@Excel(name="描述",width=15)
|
||||
private String description;
|
||||
/**机构类别 1=公司,2=组织机构,3=岗位*/
|
||||
@Excel(name="机构类别",width=15,dicCode="org_category")
|
||||
private String orgCategory;
|
||||
/**机构类型*/
|
||||
private String orgType;
|
||||
/**机构编码*/
|
||||
@Excel(name="机构编码",width=15)
|
||||
private String orgCode;
|
||||
/**业务平台类型*/
|
||||
@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")
|
||||
private Date operationStartTime;
|
||||
/**运营到期时间*/
|
||||
@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")
|
||||
private Date contractStartTime;
|
||||
/**合同到期时间*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
private Date contractEndTime;
|
||||
/**手机号*/
|
||||
@Excel(name="手机号",width=15)
|
||||
private String mobile;
|
||||
/**传真*/
|
||||
@Excel(name="传真",width=15)
|
||||
private String fax;
|
||||
/**地址*/
|
||||
@Excel(name="地址",width=15)
|
||||
private String address;
|
||||
/**备注*/
|
||||
@Excel(name="备注",width=15)
|
||||
private String memo;
|
||||
/**状态(1启用,0不启用)*/
|
||||
@Dict(dicCode = "depart_status")
|
||||
private String status;
|
||||
/**删除状态(0,正常,1已删除)*/
|
||||
@Dict(dicCode = "del_flag")
|
||||
private String delFlag;
|
||||
/**对接企业微信的ID*/
|
||||
private String qywxIdentifier;
|
||||
/**对接钉钉的部门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")
|
||||
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")
|
||||
private Date updateTime;
|
||||
/**租户ID*/
|
||||
private java.lang.Integer tenantId;
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
/**
|
||||
* 父机构ID
|
||||
*/
|
||||
private String parentId;
|
||||
/**
|
||||
* 机构/部门名称
|
||||
*/
|
||||
@Excel(name = "机构/部门名称", width = 15)
|
||||
private String departName;
|
||||
/**
|
||||
* 英文名
|
||||
*/
|
||||
@Excel(name = "英文名", width = 15)
|
||||
private String departNameEn;
|
||||
/**
|
||||
* 缩写
|
||||
*/
|
||||
private String departNameAbbr;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@Excel(name = "排序", width = 15)
|
||||
private Integer departOrder;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Excel(name = "描述", width = 15)
|
||||
private String description;
|
||||
/**
|
||||
* 机构类别 1=公司,2=组织机构,3=岗位
|
||||
*/
|
||||
@Excel(name = "机构类别", width = 15, dicCode = "org_category")
|
||||
private String orgCategory;
|
||||
/**
|
||||
* 机构类型
|
||||
*/
|
||||
private String orgType;
|
||||
/**
|
||||
* 机构编码
|
||||
*/
|
||||
@Excel(name = "机构编码", width = 15)
|
||||
private String orgCode;
|
||||
/**
|
||||
* 省份
|
||||
*/
|
||||
@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")
|
||||
private Date operationStartTime;
|
||||
/**
|
||||
* 运营到期时间
|
||||
*/
|
||||
@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")
|
||||
private Date contractStartTime;
|
||||
/**
|
||||
* 合同到期时间
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date contractEndTime;
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@Excel(name = "手机号", width = 15)
|
||||
private String mobile;
|
||||
/**
|
||||
* 传真
|
||||
*/
|
||||
@Excel(name = "传真", width = 15)
|
||||
private String fax;
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
@Excel(name = "地址", width = 15)
|
||||
private String address;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Excel(name = "备注", width = 15)
|
||||
private String memo;
|
||||
/**
|
||||
* 状态(1启用,0不启用)
|
||||
*/
|
||||
@Dict(dicCode = "depart_status")
|
||||
private String status;
|
||||
/**
|
||||
* 删除状态(0,正常,1已删除)
|
||||
*/
|
||||
@Dict(dicCode = "del_flag")
|
||||
private String delFlag;
|
||||
/**
|
||||
* 对接企业微信的ID
|
||||
*/
|
||||
private String qywxIdentifier;
|
||||
/**
|
||||
* 对接钉钉的部门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")
|
||||
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")
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private java.lang.Integer tenantId;
|
||||
|
||||
/**是否有叶子节点: 1是0否*/
|
||||
private Integer izLeaf;
|
||||
/**
|
||||
* 是否有叶子节点: 1是0否
|
||||
*/
|
||||
private Integer izLeaf;
|
||||
|
||||
/**各机构服务器后台接口地址*/
|
||||
private String serverUrl;
|
||||
/**
|
||||
* 各机构服务器后台接口地址
|
||||
*/
|
||||
private String serverUrl;
|
||||
/**
|
||||
* 各机构服务器后台接口地址
|
||||
*/
|
||||
private String picUrl;
|
||||
|
||||
//update-begin---author:wangshuai ---date:20200308 for:[JTC-119]在部门管理菜单下设置部门负责人,新增字段负责人ids和旧的负责人ids
|
||||
/**部门负责人的ids*/
|
||||
@TableField(exist = false)
|
||||
private String directorUserIds;
|
||||
/**旧的部门负责人的ids(用于比较删除和新增)*/
|
||||
@TableField(exist = false)
|
||||
/**
|
||||
* 部门负责人的ids
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String directorUserIds;
|
||||
/**
|
||||
* 旧的部门负责人的ids(用于比较删除和新增)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String oldDirectorUserIds;
|
||||
//update-end---author:wangshuai ---date:20200308 for:[JTC-119]新增字段负责人ids和旧的负责人ids
|
||||
|
||||
/**
|
||||
* 重写equals方法
|
||||
*/
|
||||
/**
|
||||
* 重写equals方法
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (!super.equals(o)) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
SysDepart depart = (SysDepart) o;
|
||||
return Objects.equals(id, depart.id) &&
|
||||
Objects.equals(parentId, depart.parentId) &&
|
||||
|
@ -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,
|
||||
delFlag, createBy, createTime, updateBy, updateTime, tenantId);
|
||||
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,10 +113,11 @@ public class SysDepartTreeModel implements Serializable{
|
|||
|
||||
/**
|
||||
* 将SysDepart对象转换成SysDepartTreeModel对象
|
||||
*
|
||||
* @param sysDepart
|
||||
*/
|
||||
public SysDepartTreeModel(SysDepart sysDepart) {
|
||||
this.key = sysDepart.getId();
|
||||
public SysDepartTreeModel(SysDepart sysDepart) {
|
||||
this.key = sysDepart.getId();
|
||||
this.value = sysDepart.getId();
|
||||
this.title = sysDepart.getDepartName();
|
||||
this.id = sysDepart.getId();
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -142,40 +163,40 @@ public class SysDepartTreeModel implements Serializable{
|
|||
}
|
||||
|
||||
public void setIsLeaf(boolean isleaf) {
|
||||
this.isLeaf = isleaf;
|
||||
this.isLeaf = isleaf;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
|
||||
public String getId() {
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -223,14 +244,14 @@ public class SysDepartTreeModel implements Serializable{
|
|||
}
|
||||
|
||||
public String getOrgCategory() {
|
||||
return orgCategory;
|
||||
}
|
||||
return orgCategory;
|
||||
}
|
||||
|
||||
public void setOrgCategory(String orgCategory) {
|
||||
this.orgCategory = orgCategory;
|
||||
}
|
||||
public void setOrgCategory(String orgCategory) {
|
||||
this.orgCategory = orgCategory;
|
||||
}
|
||||
|
||||
public String getOrgType() {
|
||||
public String getOrgType() {
|
||||
return orgType;
|
||||
}
|
||||
|
||||
|
@ -398,7 +419,8 @@ public class SysDepartTreeModel implements Serializable{
|
|||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public SysDepartTreeModel() { }
|
||||
public SysDepartTreeModel() {
|
||||
}
|
||||
|
||||
public String getDirectorUserIds() {
|
||||
return directorUserIds;
|
||||
|
@ -408,17 +430,49 @@ 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方法
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
SysDepartTreeModel model = (SysDepartTreeModel) o;
|
||||
return Objects.equals(id, model.id) &&
|
||||
Objects.equals(parentId, model.parentId) &&
|
||||
|
@ -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;
|
||||
|
@ -23,230 +24,240 @@ import java.util.stream.Collectors;
|
|||
/**
|
||||
* @Description: 分类字典
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2019-05-29
|
||||
* @Date: 2019-05-29
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCategory> implements ISysCategoryService {
|
||||
|
||||
@Override
|
||||
public void addSysCategory(SysCategory sysCategory) {
|
||||
String categoryCode = "";
|
||||
String categoryPid = ISysCategoryService.ROOT_PID_VALUE;
|
||||
String parentCode = null;
|
||||
if(oConvertUtils.isNotEmpty(sysCategory.getPid())){
|
||||
categoryPid = sysCategory.getPid();
|
||||
@Override
|
||||
public void addSysCategory(SysCategory sysCategory) {
|
||||
String categoryCode = "";
|
||||
String categoryPid = ISysCategoryService.ROOT_PID_VALUE;
|
||||
String parentCode = null;
|
||||
if (oConvertUtils.isNotEmpty(sysCategory.getPid())) {
|
||||
categoryPid = sysCategory.getPid();
|
||||
|
||||
//PID 不是根节点 说明需要设置父节点 hasChild 为1
|
||||
if(!ISysCategoryService.ROOT_PID_VALUE.equals(categoryPid)){
|
||||
SysCategory parent = baseMapper.selectById(categoryPid);
|
||||
parentCode = parent.getCode();
|
||||
if(parent!=null && !ISysCategoryService.HAS_CHILD.equals(parent.getHasChild())){
|
||||
parent.setHasChild(ISysCategoryService.HAS_CHILD);
|
||||
baseMapper.updateById(parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
//update-begin--Author:baihailong Date:20191209 for:分类字典编码规则生成器做成公用配置
|
||||
JSONObject formData = new JSONObject();
|
||||
formData.put("pid",categoryPid);
|
||||
categoryCode = (String) FillRuleUtil.executeRule(FillRuleConstant.CATEGORY,formData);
|
||||
//update-end--Author:baihailong Date:20191209 for:分类字典编码规则生成器做成公用配置
|
||||
sysCategory.setCode(categoryCode);
|
||||
sysCategory.setPid(categoryPid);
|
||||
baseMapper.insert(sysCategory);
|
||||
}
|
||||
//PID 不是根节点 说明需要设置父节点 hasChild 为1
|
||||
if (!ISysCategoryService.ROOT_PID_VALUE.equals(categoryPid)) {
|
||||
SysCategory parent = baseMapper.selectById(categoryPid);
|
||||
parentCode = parent.getCode();
|
||||
if (parent != null && !ISysCategoryService.HAS_CHILD.equals(parent.getHasChild())) {
|
||||
parent.setHasChild(ISysCategoryService.HAS_CHILD);
|
||||
baseMapper.updateById(parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
//update-begin--Author:baihailong Date:20191209 for:分类字典编码规则生成器做成公用配置
|
||||
JSONObject formData = new JSONObject();
|
||||
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())){
|
||||
sysCategory.setPid(ISysCategoryService.ROOT_PID_VALUE);
|
||||
}else{
|
||||
//如果当前节点父ID不为空 则设置父节点的hasChild 为1
|
||||
SysCategory parent = baseMapper.selectById(sysCategory.getPid());
|
||||
if(parent!=null && !ISysCategoryService.HAS_CHILD.equals(parent.getHasChild())){
|
||||
parent.setHasChild(ISysCategoryService.HAS_CHILD);
|
||||
baseMapper.updateById(parent);
|
||||
}
|
||||
}
|
||||
baseMapper.updateById(sysCategory);
|
||||
}
|
||||
@Override
|
||||
public void updateSysCategory(SysCategory sysCategory) {
|
||||
if (oConvertUtils.isEmpty(sysCategory.getPid())) {
|
||||
sysCategory.setPid(ISysCategoryService.ROOT_PID_VALUE);
|
||||
} else {
|
||||
//如果当前节点父ID不为空 则设置父节点的hasChild 为1
|
||||
SysCategory parent = baseMapper.selectById(sysCategory.getPid());
|
||||
if (parent != null && !ISysCategoryService.HAS_CHILD.equals(parent.getHasChild())) {
|
||||
parent.setHasChild(ISysCategoryService.HAS_CHILD);
|
||||
baseMapper.updateById(parent);
|
||||
}
|
||||
}
|
||||
baseMapper.updateById(sysCategory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeSelectModel> queryListByCode(String pcode) throws JeecgBootException{
|
||||
String pid = ROOT_PID_VALUE;
|
||||
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.size()>1) {
|
||||
throw new JeecgBootException("该编码【"+pcode+"】存在多个,请核实!");
|
||||
}
|
||||
pid = list.get(0).getId();
|
||||
}
|
||||
return baseMapper.queryListByPid(pid,null);
|
||||
}
|
||||
@Override
|
||||
public List<TreeSelectModel> queryListByCode(String pcode) throws JeecgBootException {
|
||||
String pid = ROOT_PID_VALUE;
|
||||
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.size() > 1) {
|
||||
throw new JeecgBootException("该编码【" + pcode + "】存在多个,请核实!");
|
||||
}
|
||||
pid = list.get(0).getId();
|
||||
}
|
||||
return baseMapper.queryListByPid(pid, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeSelectModel> queryListByPid(String pid) {
|
||||
if(oConvertUtils.isEmpty(pid)) {
|
||||
pid = ROOT_PID_VALUE;
|
||||
}
|
||||
return baseMapper.queryListByPid(pid,null);
|
||||
}
|
||||
@Override
|
||||
public List<TreeSelectModel> queryListByPid(String pid) {
|
||||
if (oConvertUtils.isEmpty(pid)) {
|
||||
pid = ROOT_PID_VALUE;
|
||||
}
|
||||
return baseMapper.queryListByPid(pid, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeSelectModel> queryListByPid(String pid, Map<String, String> condition) {
|
||||
if(oConvertUtils.isEmpty(pid)) {
|
||||
pid = ROOT_PID_VALUE;
|
||||
}
|
||||
return baseMapper.queryListByPid(pid,condition);
|
||||
}
|
||||
@Override
|
||||
public List<TreeSelectModel> queryAllCategories() {
|
||||
return baseMapper.queryAllCategories();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String queryIdByCode(String code) {
|
||||
return baseMapper.queryIdByCode(code);
|
||||
}
|
||||
@Override
|
||||
public List<TreeSelectModel> queryListByPid(String pid, Map<String, String> condition) {
|
||||
if (oConvertUtils.isEmpty(pid)) {
|
||||
pid = ROOT_PID_VALUE;
|
||||
}
|
||||
return baseMapper.queryListByPid(pid, condition);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteSysCategory(String ids) {
|
||||
String allIds = this.queryTreeChildIds(ids);
|
||||
String pids = this.queryTreePids(ids);
|
||||
//1.删除时将节点下所有子节点一并删除
|
||||
this.baseMapper.deleteBatchIds(Arrays.asList(allIds.split(",")));
|
||||
//2.将父节点中已经没有下级的节点,修改为没有子节点
|
||||
if(oConvertUtils.isNotEmpty(pids)){
|
||||
LambdaUpdateWrapper<SysCategory> updateWrapper = new UpdateWrapper<SysCategory>()
|
||||
.lambda()
|
||||
.in(SysCategory::getId,Arrays.asList(pids.split(",")))
|
||||
.set(SysCategory::getHasChild,"0");
|
||||
this.update(updateWrapper);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String queryIdByCode(String code) {
|
||||
return baseMapper.queryIdByCode(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询节点下所有子节点
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
private String queryTreeChildIds(String ids) {
|
||||
//获取id数组
|
||||
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){
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append(pidVal);
|
||||
this.getTreeChildIds(pidVal,sb);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteSysCategory(String ids) {
|
||||
String allIds = this.queryTreeChildIds(ids);
|
||||
String pids = this.queryTreePids(ids);
|
||||
//1.删除时将节点下所有子节点一并删除
|
||||
this.baseMapper.deleteBatchIds(Arrays.asList(allIds.split(",")));
|
||||
//2.将父节点中已经没有下级的节点,修改为没有子节点
|
||||
if (oConvertUtils.isNotEmpty(pids)) {
|
||||
LambdaUpdateWrapper<SysCategory> updateWrapper = new UpdateWrapper<SysCategory>()
|
||||
.lambda()
|
||||
.in(SysCategory::getId, Arrays.asList(pids.split(",")))
|
||||
.set(SysCategory::getHasChild, "0");
|
||||
this.update(updateWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询需修改标识的父节点ids
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
private String queryTreePids(String ids) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
//获取id数组
|
||||
String[] idArr = ids.split(",");
|
||||
for (String id : idArr) {
|
||||
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));
|
||||
List<SysCategory> dataList = this.baseMapper.selectList(queryWrapper);
|
||||
boolean flag = (dataList == null || dataList.size()==0) && !Arrays.asList(idArr).contains(metaPid)
|
||||
/**
|
||||
* 查询节点下所有子节点
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
private String queryTreeChildIds(String ids) {
|
||||
//获取id数组
|
||||
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) {
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append(pidVal);
|
||||
this.getTreeChildIds(pidVal, sb);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询需修改标识的父节点ids
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
private String queryTreePids(String ids) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
//获取id数组
|
||||
String[] idArr = ids.split(",");
|
||||
for (String id : idArr) {
|
||||
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));
|
||||
List<SysCategory> dataList = this.baseMapper.selectList(queryWrapper);
|
||||
boolean flag = (dataList == null || dataList.size() == 0) && !Arrays.asList(idArr).contains(metaPid)
|
||||
&& !sb.toString().contains(metaPid);
|
||||
if(flag){
|
||||
//如果当前节点原本有子节点 现在木有了,更新状态
|
||||
sb.append(metaPid).append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
if(sb.toString().endsWith(SymbolConstant.COMMA)){
|
||||
sb = sb.deleteCharAt(sb.length() - 1);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
if (flag) {
|
||||
//如果当前节点原本有子节点 现在木有了,更新状态
|
||||
sb.append(metaPid).append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sb.toString().endsWith(SymbolConstant.COMMA)) {
|
||||
sb = sb.deleteCharAt(sb.length() - 1);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归 根据父id获取子节点id
|
||||
* @param pidVal
|
||||
* @param sb
|
||||
* @return
|
||||
*/
|
||||
private StringBuffer getTreeChildIds(String pidVal,StringBuffer sb){
|
||||
LambdaQueryWrapper<SysCategory> queryWrapper = new LambdaQueryWrapper<>();
|
||||
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())){
|
||||
sb.append(",").append(category.getId());
|
||||
}
|
||||
this.getTreeChildIds(category.getId(), sb);
|
||||
}
|
||||
}
|
||||
return sb;
|
||||
}
|
||||
/**
|
||||
* 递归 根据父id获取子节点id
|
||||
*
|
||||
* @param pidVal
|
||||
* @param sb
|
||||
* @return
|
||||
*/
|
||||
private StringBuffer getTreeChildIds(String pidVal, StringBuffer sb) {
|
||||
LambdaQueryWrapper<SysCategory> queryWrapper = new LambdaQueryWrapper<>();
|
||||
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())) {
|
||||
sb.append(",").append(category.getId());
|
||||
}
|
||||
this.getTreeChildIds(category.getId(), sb);
|
||||
}
|
||||
}
|
||||
return sb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> loadDictItem(String ids) {
|
||||
return this.loadDictItem(ids, true);
|
||||
}
|
||||
@Override
|
||||
public List<String> loadDictItem(String ids) {
|
||||
return this.loadDictItem(ids, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> loadDictItem(String ids, boolean delNotExist) {
|
||||
String[] idArray = ids.split(",");
|
||||
LambdaQueryWrapper<SysCategory> query = new LambdaQueryWrapper<>();
|
||||
query.in(SysCategory::getId, Arrays.asList(idArray));
|
||||
// 查询数据
|
||||
List<SysCategory> list = super.list(query);
|
||||
// 取出name并返回
|
||||
List<String> textList;
|
||||
// update-begin--author:sunjianlei--date:20210514--for:新增delNotExist参数,设为false不删除数据库里不存在的key ----
|
||||
if (delNotExist) {
|
||||
textList = list.stream().map(SysCategory::getName).collect(Collectors.toList());
|
||||
} else {
|
||||
textList = new ArrayList<>();
|
||||
for (String id : idArray) {
|
||||
List<SysCategory> res = list.stream().filter(i -> id.equals(i.getId())).collect(Collectors.toList());
|
||||
textList.add(res.size() > 0 ? res.get(0).getName() : id);
|
||||
}
|
||||
}
|
||||
// update-end--author:sunjianlei--date:20210514--for:新增delNotExist参数,设为false不删除数据库里不存在的key ----
|
||||
return textList;
|
||||
}
|
||||
@Override
|
||||
public List<String> loadDictItem(String ids, boolean delNotExist) {
|
||||
String[] idArray = ids.split(",");
|
||||
LambdaQueryWrapper<SysCategory> query = new LambdaQueryWrapper<>();
|
||||
query.in(SysCategory::getId, Arrays.asList(idArray));
|
||||
// 查询数据
|
||||
List<SysCategory> list = super.list(query);
|
||||
// 取出name并返回
|
||||
List<String> textList;
|
||||
// update-begin--author:sunjianlei--date:20210514--for:新增delNotExist参数,设为false不删除数据库里不存在的key ----
|
||||
if (delNotExist) {
|
||||
textList = list.stream().map(SysCategory::getName).collect(Collectors.toList());
|
||||
} else {
|
||||
textList = new ArrayList<>();
|
||||
for (String id : idArray) {
|
||||
List<SysCategory> res = list.stream().filter(i -> id.equals(i.getId())).collect(Collectors.toList());
|
||||
textList.add(res.size() > 0 ? res.get(0).getName() : id);
|
||||
}
|
||||
}
|
||||
// update-end--author:sunjianlei--date:20210514--for:新增delNotExist参数,设为false不删除数据库里不存在的key ----
|
||||
return textList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> loadDictItemByNames(String names, boolean delNotExist) {
|
||||
List<String> nameList = Arrays.asList(names.split(SymbolConstant.COMMA));
|
||||
LambdaQueryWrapper<SysCategory> query = new LambdaQueryWrapper<>();
|
||||
query.select(SysCategory::getId, SysCategory::getName);
|
||||
query.in(SysCategory::getName, nameList);
|
||||
// 查询数据
|
||||
List<SysCategory> list = super.list(query);
|
||||
// 取出id并返回
|
||||
return nameList.stream().map(name -> {
|
||||
SysCategory res = list.stream().filter(i -> name.equals(i.getName())).findFirst().orElse(null);
|
||||
if (res == null) {
|
||||
return delNotExist ? null : name;
|
||||
}
|
||||
return res.getId();
|
||||
}).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
}
|
||||
@Override
|
||||
public List<String> loadDictItemByNames(String names, boolean delNotExist) {
|
||||
List<String> nameList = Arrays.asList(names.split(SymbolConstant.COMMA));
|
||||
LambdaQueryWrapper<SysCategory> query = new LambdaQueryWrapper<>();
|
||||
query.select(SysCategory::getId, SysCategory::getName);
|
||||
query.in(SysCategory::getName, nameList);
|
||||
// 查询数据
|
||||
List<SysCategory> list = super.list(query);
|
||||
// 取出id并返回
|
||||
return nameList.stream().map(name -> {
|
||||
SysCategory res = list.stream().filter(i -> name.equals(i.getName())).findFirst().orElse(null);
|
||||
if (res == null) {
|
||||
return delNotExist ? null : name;
|
||||
}
|
||||
return res.getId();
|
||||
}).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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