diff --git a/nursing-unit-admin/nu-admin-biz/src/main/java/com/nu/modules/NuBizAdvisoryInfo/controller/H5ApiAdvisoryInfoController.java b/nursing-unit-admin/nu-admin-biz/src/main/java/com/nu/modules/NuBizAdvisoryInfo/controller/H5ApiAdvisoryInfoController.java index 203341f..c062c34 100644 --- a/nursing-unit-admin/nu-admin-biz/src/main/java/com/nu/modules/NuBizAdvisoryInfo/controller/H5ApiAdvisoryInfoController.java +++ b/nursing-unit-admin/nu-admin-biz/src/main/java/com/nu/modules/NuBizAdvisoryInfo/controller/H5ApiAdvisoryInfoController.java @@ -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 queryByOpenId(@RequestParam(name="openId",required=true) String openId) { QueryWrapper queryWrapper = new QueryWrapper<>(); @@ -97,4 +103,47 @@ public class H5ApiAdvisoryInfoController extends JeecgController 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 editNuBizAdvisoryInfo(@RequestBody NuBizAdvisoryInfo nuBizAdvisoryInfo) { + if(StringUtils.isEmpty(nuBizAdvisoryInfo.getOpenId())){ + return Result.error("填写openId"); + } + if(StringUtils.isEmpty(nuBizAdvisoryInfo.getServerUrl())){ + return Result.error("填写微信名称"); + } + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("open_id",nuBizAdvisoryInfo.getOpenId()); + NuBizAdvisoryInfo nuBizAdvisoryInfoQuery = nuBizAdvisoryInfoService.getOne(queryWrapper); + if(nuBizAdvisoryInfoQuery == null){ + return Result.error("未找到对应数据"); + } + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.eq("open_id",nuBizAdvisoryInfo.getOpenId()); + updateWrapper.set("server_url",nuBizAdvisoryInfo.getServerUrl()); + nuBizAdvisoryInfoService.update(updateWrapper); + return Result.OK("编辑成功!"); + } + + } diff --git a/nursing-unit-admin/nu-admin-biz/src/main/java/com/nu/modules/NuBizAdvisoryInfo/service/INuBizAdvisoryInfoService.java b/nursing-unit-admin/nu-admin-biz/src/main/java/com/nu/modules/NuBizAdvisoryInfo/service/INuBizAdvisoryInfoService.java index feedd64..f3bf965 100644 --- a/nursing-unit-admin/nu-admin-biz/src/main/java/com/nu/modules/NuBizAdvisoryInfo/service/INuBizAdvisoryInfoService.java +++ b/nursing-unit-admin/nu-admin-biz/src/main/java/com/nu/modules/NuBizAdvisoryInfo/service/INuBizAdvisoryInfoService.java @@ -11,4 +11,5 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface INuBizAdvisoryInfoService extends IService { + NuBizAdvisoryInfo queryWeixinInfo(String openId, String wechatName); } diff --git a/nursing-unit-admin/nu-admin-biz/src/main/java/com/nu/modules/NuBizAdvisoryInfo/service/impl/NuBizAdvisoryInfoServiceImpl.java b/nursing-unit-admin/nu-admin-biz/src/main/java/com/nu/modules/NuBizAdvisoryInfo/service/impl/NuBizAdvisoryInfoServiceImpl.java index d6765ec..e6a443a 100644 --- a/nursing-unit-admin/nu-admin-biz/src/main/java/com/nu/modules/NuBizAdvisoryInfo/service/impl/NuBizAdvisoryInfoServiceImpl.java +++ b/nursing-unit-admin/nu-admin-biz/src/main/java/com/nu/modules/NuBizAdvisoryInfo/service/impl/NuBizAdvisoryInfoServiceImpl.java @@ -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 implements INuBizAdvisoryInfoService { + @Override + public NuBizAdvisoryInfo queryWeixinInfo(String openId, String wechatName) { + QueryWrapper 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; + } } diff --git a/nursing-unit-admin/nu-admin-biz/src/main/java/com/nu/modules/weixin/controller/WeixinController.java b/nursing-unit-admin/nu-admin-biz/src/main/java/com/nu/modules/weixin/controller/WeixinController.java new file mode 100644 index 0000000..d6966b6 --- /dev/null +++ b/nursing-unit-admin/nu-admin-biz/src/main/java/com/nu/modules/weixin/controller/WeixinController.java @@ -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 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 map = new HashMap<>(); + map.put("data",retJson); + map.put("code",200); + map.put("msg","success"); + map.put("accessToken",accessToken); + + return map; + } + + + +} diff --git a/nursing-unit-admin/nu-admin-biz/src/main/java/com/nu/modules/weixin/utils/SignUtil.java b/nursing-unit-admin/nu-admin-biz/src/main/java/com/nu/modules/weixin/utils/SignUtil.java new file mode 100644 index 0000000..acadeb2 --- /dev/null +++ b/nursing-unit-admin/nu-admin-biz/src/main/java/com/nu/modules/weixin/utils/SignUtil.java @@ -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; + } + +} diff --git a/nursing-unit-api/src/main/java/com/nu/modules/documentrecognition/DocumentRecognitionApi.java b/nursing-unit-api/src/main/java/com/nu/modules/documentrecognition/DocumentRecognitionApi.java index 3d5e701..c50421d 100644 --- a/nursing-unit-api/src/main/java/com/nu/modules/documentrecognition/DocumentRecognitionApi.java +++ b/nursing-unit-api/src/main/java/com/nu/modules/documentrecognition/DocumentRecognitionApi.java @@ -97,4 +97,22 @@ public class DocumentRecognitionApi { } } + /** + * 营业执照识别 + * @param file 图片文件 + */ + @PostMapping("/businessLicense") + public Result 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(); + } + } } diff --git a/nursing-unit-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java b/nursing-unit-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java index c8bc1f2..4211e5c 100644 --- a/nursing-unit-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java +++ b/nursing-unit-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java @@ -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"); //登录二维码 diff --git a/nursing-unit-common/pom.xml b/nursing-unit-common/pom.xml index 5a129ff..5aa235e 100644 --- a/nursing-unit-common/pom.xml +++ b/nursing-unit-common/pom.xml @@ -34,6 +34,12 @@ guava 33.4.8-jre + + + org.jsoup + jsoup + 1.15.3 + diff --git a/nursing-unit-common/src/main/java/com/nu/modules/aliyun/documentrecognition/DocumentRecognitionUtils.java b/nursing-unit-common/src/main/java/com/nu/modules/aliyun/documentrecognition/DocumentRecognitionUtils.java index 4d54f0b..0b3a130 100644 --- a/nursing-unit-common/src/main/java/com/nu/modules/aliyun/documentrecognition/DocumentRecognitionUtils.java +++ b/nursing-unit-common/src/main/java/com/nu/modules/aliyun/documentrecognition/DocumentRecognitionUtils.java @@ -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 future = client.recognizeBusinessLicense(request); + RecognizeBusinessLicenseResponse response = future.get(); + return new Gson().toJson(response.getBody()); + } } diff --git a/nursing-unit-common/src/main/java/com/nu/utils/RegionCodeProcessor.java b/nursing-unit-common/src/main/java/com/nu/utils/RegionCodeProcessor.java new file mode 100644 index 0000000..402f221 --- /dev/null +++ b/nursing-unit-common/src/main/java/com/nu/utils/RegionCodeProcessor.java @@ -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 regions = readRegionsFromFile(); + Map codeToIdMap = new HashMap<>(); + Map> 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 readRegionsFromFile() throws IOException { + List 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 regions, + Map> 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; + } + } +} diff --git a/nursing-unit-common/src/main/java/com/nu/utils/SafetyUtil.java b/nursing-unit-common/src/main/java/com/nu/utils/SafetyUtil.java index 27c30f8..1ef7ffd 100644 --- a/nursing-unit-common/src/main/java/com/nu/utils/SafetyUtil.java +++ b/nursing-unit-common/src/main/java/com/nu/utils/SafetyUtil.java @@ -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); } } diff --git a/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/controller/SysCategoryController.java b/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/controller/SysCategoryController.java index 8824ffd..7554178 100644 --- a/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/controller/SysCategoryController.java +++ b/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/controller/SysCategoryController.java @@ -38,501 +38,548 @@ import java.io.IOException; import java.util.*; import java.util.stream.Collectors; - /** +/** * @Description: 分类字典 * @Author: jeecg-boot - * @Date: 2019-05-29 + * @Date: 2019-05-29 * @Version: V1.0 */ @RestController @RequestMapping("/sys/category") @Slf4j public class SysCategoryController { - @Autowired - private ISysCategoryService sysCategoryService; - - /** - * 分类编码0 - */ - private static final String CATEGORY_ROOT_CODE = "0"; - - /** - * 分页列表查询 - * @param sysCategory - * @param pageNo - * @param pageSize - * @param req - * @return - */ - @GetMapping(value = "/rootList") - public Result> queryPageList(SysCategory sysCategory, - @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> result = new Result>(); - //------------------------------------------------------------------------------------------------ - //是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】 - if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){ - sysCategory.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(),0)); - } - //------------------------------------------------------------------------------------------------ - - //--author:os_chengtgen---date:20190804 -----for: 分类字典页面显示错误,issues:377--------start - //--author:liusq---date:20211119 -----for: 【vue3】分类字典页面查询条件配置--------start - QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(sysCategory, req.getParameterMap()); - String name = sysCategory.getName(); - String code = sysCategory.getCode(); - //QueryWrapper queryWrapper = new QueryWrapper(); - if(StringUtils.isBlank(name)&&StringUtils.isBlank(code)){ - queryWrapper.eq("pid", sysCategory.getPid()); - } - //--author:liusq---date:20211119 -----for: 分类字典页面查询条件配置--------end - //--author:os_chengtgen---date:20190804 -----for:【vue3】 分类字典页面显示错误,issues:377--------end - - Page page = new Page(pageNo, pageSize); - IPage pageList = sysCategoryService.page(page, queryWrapper); - result.setSuccess(true); - result.setResult(pageList); - return result; - } - - @GetMapping(value = "/childList") - public Result> queryPageList(SysCategory sysCategory,HttpServletRequest req) { - //------------------------------------------------------------------------------------------------ - //是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】 - if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){ - sysCategory.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(), 0)); - } - //------------------------------------------------------------------------------------------------ - Result> result = new Result>(); - QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(sysCategory, req.getParameterMap()); - List list = sysCategoryService.list(queryWrapper); - result.setSuccess(true); - result.setResult(list); - return result; - } - - - /** - * 添加 - * @param sysCategory - * @return - */ - @PostMapping(value = "/add") - public Result add(@RequestBody SysCategory sysCategory) { - Result result = new Result(); - try { - sysCategoryService.addSysCategory(sysCategory); - result.success("添加成功!"); - } catch (Exception e) { - log.error(e.getMessage(),e); - result.error500("操作失败"); - } - return result; - } - - /** - * 编辑 - * @param sysCategory - * @return - */ - @RequestMapping(value = "/edit", method = { RequestMethod.PUT,RequestMethod.POST }) - public Result edit(@RequestBody SysCategory sysCategory) { - Result result = new Result(); - SysCategory sysCategoryEntity = sysCategoryService.getById(sysCategory.getId()); - if(sysCategoryEntity==null) { - result.error500("未找到对应实体"); - }else { - sysCategoryService.updateSysCategory(sysCategory); - result.success("修改成功!"); - } - return result; - } - - /** - * 通过id删除 - * @param id - * @return - */ - @DeleteMapping(value = "/delete") - public Result delete(@RequestParam(name="id",required=true) String id) { - Result result = new Result(); - SysCategory sysCategory = sysCategoryService.getById(id); - if(sysCategory==null) { - result.error500("未找到对应实体"); - }else { - this.sysCategoryService.deleteSysCategory(id); - result.success("删除成功!"); - } - - return result; - } - - /** - * 批量删除 - * @param ids - * @return - */ - @DeleteMapping(value = "/deleteBatch") - public Result deleteBatch(@RequestParam(name="ids",required=true) String ids) { - Result result = new Result(); - if(ids==null || "".equals(ids.trim())) { - result.error500("参数不识别!"); - }else { - this.sysCategoryService.deleteSysCategory(ids); - result.success("删除成功!"); - } - return result; - } - - /** - * 通过id查询 - * @param id - * @return - */ - @GetMapping(value = "/queryById") - public Result queryById(@RequestParam(name="id",required=true) String id) { - Result result = new Result(); - SysCategory sysCategory = sysCategoryService.getById(id); - if(sysCategory==null) { - result.error500("未找到对应实体"); - }else { - result.setResult(sysCategory); - result.setSuccess(true); - } - return result; - } - - /** - * 导出excel - * - * @param request - */ - @RequestMapping(value = "/exportXls") - public ModelAndView exportXls(HttpServletRequest request, SysCategory sysCategory) { - //------------------------------------------------------------------------------------------------ - //是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】 - if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){ - sysCategory.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(), 0)); - } - //------------------------------------------------------------------------------------------------ - - // Step.1 组装查询条件查询数据 - QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(sysCategory, request.getParameterMap()); - List pageList = sysCategoryService.list(queryWrapper); - // Step.2 AutoPoi 导出Excel - ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); - // 过滤选中数据 - String selections = request.getParameter("selections"); - if(oConvertUtils.isEmpty(selections)) { - mv.addObject(NormalExcelConstants.DATA_LIST, pageList); - }else { - List selectionList = Arrays.asList(selections.split(",")); - List exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList()); - mv.addObject(NormalExcelConstants.DATA_LIST, exportList); - } - //导出文件名称 - 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(), "导出信息")); - return mv; - } - - /** - * 通过excel导入数据 - * - * @param request - * @param response - * @return - */ - @RequestMapping(value = "/importExcel", method = RequestMethod.POST) - public Result importExcel(HttpServletRequest request, HttpServletResponse response) throws IOException{ - MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; - Map fileMap = multipartRequest.getFileMap(); - // 错误信息 - List errorMessage = new ArrayList<>(); - int successLines = 0, errorLines = 0; - for (Map.Entry entity : fileMap.entrySet()) { - // 获取上传文件对象 - MultipartFile file = entity.getValue(); - ImportParams params = new ImportParams(); - params.setTitleRows(2); - params.setHeadRows(1); - params.setNeedSave(true); - try { - List listSysCategorys = ExcelImportUtil.importExcel(file.getInputStream(), SysCategory.class, params); - //按照编码长度排序 - Collections.sort(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)){ - sysCategoryExcel.setPid(pId); - } - }else{ - sysCategoryExcel.setPid("0"); - } - try { - sysCategoryService.save(sysCategoryExcel); - successLines++; - } catch (Exception e) { - errorLines++; - String message = e.getMessage().toLowerCase(); - int lineNumber = i + 1; - // 通过索引名判断出错信息 - if (message.contains(CommonConstant.SQL_INDEX_UNIQ_CATEGORY_CODE)) { - errorMessage.add("第 " + lineNumber + " 行:分类编码已经存在,忽略导入。"); - } else { - errorMessage.add("第 " + lineNumber + " 行:未知错误,忽略导入"); - log.error(e.getMessage(), e); - } - } - } - } catch (Exception e) { - errorMessage.add("发生异常:" + e.getMessage()); - log.error(e.getMessage(), e); - } finally { - try { - file.getInputStream().close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - return ImportExcelUtil.imporReturnRes(errorLines,successLines,errorMessage); - } - - - - /** - * 加载单个数据 用于回显 - */ - @RequestMapping(value = "/loadOne", method = RequestMethod.GET) - public Result loadOne(@RequestParam(name="field") String field,@RequestParam(name="val") String val) { - Result result = new Result(); - try { - //update-begin-author:taoyan date:2022-5-6 for: issues/3663 sql注入问题 - boolean isClassField = ReflectHelper.isClassField(field, SysCategory.class); - if (!isClassField) { - return Result.error("字段无效,请检查!"); - } - //update-end-author:taoyan date:2022-5-6 for: issues/3663 sql注入问题 - QueryWrapper query = new QueryWrapper(); - query.eq(field, val); - List ls = this.sysCategoryService.list(query); - if(ls==null || ls.size()==0) { - result.setMessage("查询无果"); - result.setSuccess(false); - }else if(ls.size()>1) { - result.setMessage("查询数据异常,["+field+"]存在多个值:"+val); - result.setSuccess(false); - }else { - result.setSuccess(true); - result.setResult(ls.get(0)); - } - } catch (Exception e) { - e.printStackTrace(); - result.setMessage(e.getMessage()); - result.setSuccess(false); - } - return result; - } + @Autowired + private ISysCategoryService sysCategoryService; /** - * 加载节点的子数据 + * 分类编码0 + */ + private static final String CATEGORY_ROOT_CODE = "0"; + + /** + * 分页列表查询 + * + * @param sysCategory + * @param pageNo + * @param pageSize + * @param req + * @return + */ + @GetMapping(value = "/rootList") + public Result> queryPageList(SysCategory sysCategory, + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, + HttpServletRequest req) { + Result> result = new Result>(); + //------------------------------------------------------------------------------------------------ + //是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】 + if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) { + sysCategory.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(), 0)); + } + //------------------------------------------------------------------------------------------------ + + //--author:os_chengtgen---date:20190804 -----for: 分类字典页面显示错误,issues:377--------start + //--author:liusq---date:20211119 -----for: 【vue3】分类字典页面查询条件配置--------start + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(sysCategory, req.getParameterMap()); + String name = sysCategory.getName(); + String code = sysCategory.getCode(); + //QueryWrapper queryWrapper = new QueryWrapper(); + 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 + + Page page = new Page(pageNo, pageSize); + IPage pageList = sysCategoryService.page(page, queryWrapper); + result.setSuccess(true); + result.setResult(pageList); + return result; + } + + @GetMapping(value = "/childList") + public Result> queryPageList(SysCategory sysCategory, HttpServletRequest req) { + //------------------------------------------------------------------------------------------------ + //是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】 + if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) { + sysCategory.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(), 0)); + } + //------------------------------------------------------------------------------------------------ + Result> result = new Result>(); + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(sysCategory, req.getParameterMap()); + queryWrapper.orderByAsc("code"); + List list = sysCategoryService.list(queryWrapper); + result.setSuccess(true); + result.setResult(list); + return result; + } + + + /** + * 添加 + * + * @param sysCategory + * @return + */ + @PostMapping(value = "/add") + public Result add(@RequestBody SysCategory sysCategory) { + Result result = new Result(); + try { + sysCategoryService.addSysCategory(sysCategory); + result.success("添加成功!"); + } catch (Exception e) { + log.error(e.getMessage(), e); + result.error500("编码重复!"); + } + return result; + } + + /** + * 编辑 + * + * @param sysCategory + * @return + */ + @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) + public Result edit(@RequestBody SysCategory sysCategory) { + Result result = new Result(); + SysCategory sysCategoryEntity = sysCategoryService.getById(sysCategory.getId()); + if (sysCategoryEntity == null) { + result.error500("编码重复!"); + } else { + sysCategoryService.updateSysCategory(sysCategory); + result.success("修改成功!"); + } + return result; + } + + /** + * 通过id删除 + * + * @param id + * @return + */ + @DeleteMapping(value = "/delete") + public Result delete(@RequestParam(name = "id", required = true) String id) { + Result result = new Result(); + SysCategory sysCategory = sysCategoryService.getById(id); + if (sysCategory == null) { + result.error500("未找到对应实体"); + } else { + this.sysCategoryService.deleteSysCategory(id); + result.success("删除成功!"); + } + + return result; + } + + /** + * 批量删除 + * + * @param ids + * @return + */ + @DeleteMapping(value = "/deleteBatch") + public Result deleteBatch(@RequestParam(name = "ids", required = true) String ids) { + Result result = new Result(); + if (ids == null || "".equals(ids.trim())) { + result.error500("参数不识别!"); + } else { + this.sysCategoryService.deleteSysCategory(ids); + result.success("删除成功!"); + } + return result; + } + + /** + * 通过id查询 + * + * @param id + * @return + */ + @GetMapping(value = "/queryById") + public Result queryById(@RequestParam(name = "id", required = true) String id) { + Result result = new Result(); + SysCategory sysCategory = sysCategoryService.getById(id); + if (sysCategory == null) { + result.error500("未找到对应实体"); + } else { + result.setResult(sysCategory); + result.setSuccess(true); + } + return result; + } + + /** + * 导出excel + * + * @param request + */ + @RequestMapping(value = "/exportXls") + public ModelAndView exportXls(HttpServletRequest request, SysCategory sysCategory) { + //------------------------------------------------------------------------------------------------ + //是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】 + if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) { + sysCategory.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(), 0)); + } + //------------------------------------------------------------------------------------------------ + + // Step.1 组装查询条件查询数据 + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(sysCategory, request.getParameterMap()); + List pageList = sysCategoryService.list(queryWrapper); + // Step.2 AutoPoi 导出Excel + ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); + // 过滤选中数据 + String selections = request.getParameter("selections"); + if (oConvertUtils.isEmpty(selections)) { + mv.addObject(NormalExcelConstants.DATA_LIST, pageList); + } else { + List selectionList = Arrays.asList(selections.split(",")); + List exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList()); + mv.addObject(NormalExcelConstants.DATA_LIST, exportList); + } + //导出文件名称 + 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(), "导出信息")); + return mv; + } + + /** + * 通过excel导入数据 + * + * @param request + * @param response + * @return + */ + @RequestMapping(value = "/importExcel", method = RequestMethod.POST) + public Result importExcel(HttpServletRequest request, HttpServletResponse response) throws IOException { + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; + Map fileMap = multipartRequest.getFileMap(); + // 错误信息 + List errorMessage = new ArrayList<>(); + int successLines = 0, errorLines = 0; + for (Map.Entry entity : fileMap.entrySet()) { + // 获取上传文件对象 + MultipartFile file = entity.getValue(); + ImportParams params = new ImportParams(); + params.setTitleRows(2); + params.setHeadRows(1); + params.setNeedSave(true); + try { + List listSysCategorys = ExcelImportUtil.importExcel(file.getInputStream(), SysCategory.class, params); + //按照编码长度排序 + Collections.sort(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)) { + sysCategoryExcel.setPid(pId); + } + } else { + sysCategoryExcel.setPid("0"); + } + try { + sysCategoryService.save(sysCategoryExcel); + successLines++; + } catch (Exception e) { + errorLines++; + String message = e.getMessage().toLowerCase(); + int lineNumber = i + 1; + // 通过索引名判断出错信息 + if (message.contains(CommonConstant.SQL_INDEX_UNIQ_CATEGORY_CODE)) { + errorMessage.add("第 " + lineNumber + " 行:分类编码已经存在,忽略导入。"); + } else { + errorMessage.add("第 " + lineNumber + " 行:未知错误,忽略导入"); + log.error(e.getMessage(), e); + } + } + } + } catch (Exception e) { + errorMessage.add("发生异常:" + e.getMessage()); + log.error(e.getMessage(), e); + } finally { + try { + file.getInputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return ImportExcelUtil.imporReturnRes(errorLines, successLines, errorMessage); + } + + + /** + * 加载单个数据 用于回显 + */ + @RequestMapping(value = "/loadOne", method = RequestMethod.GET) + public Result loadOne(@RequestParam(name = "field") String field, @RequestParam(name = "val") String val) { + Result result = new Result(); + try { + //update-begin-author:taoyan date:2022-5-6 for: issues/3663 sql注入问题 + boolean isClassField = ReflectHelper.isClassField(field, SysCategory.class); + if (!isClassField) { + return Result.error("字段无效,请检查!"); + } + //update-end-author:taoyan date:2022-5-6 for: issues/3663 sql注入问题 + QueryWrapper query = new QueryWrapper(); + query.eq(field, val); + List ls = this.sysCategoryService.list(query); + if (ls == null || ls.size() == 0) { + result.setMessage("查询无果"); + result.setSuccess(false); + } else if (ls.size() > 1) { + result.setMessage("查询数据异常,[" + field + "]存在多个值:" + val); + result.setSuccess(false); + } else { + result.setSuccess(true); + result.setResult(ls.get(0)); + } + } catch (Exception e) { + e.printStackTrace(); + result.setMessage(e.getMessage()); + result.setSuccess(false); + } + return result; + } + + /** + * 加载节点的子数据 */ @RequestMapping(value = "/loadTreeChildren", method = RequestMethod.GET) - public Result> loadTreeChildren(@RequestParam(name="pid") String pid) { - Result> result = new Result>(); - try { - List ls = this.sysCategoryService.queryListByPid(pid); - result.setResult(ls); - result.setSuccess(true); - } catch (Exception e) { - e.printStackTrace(); - result.setMessage(e.getMessage()); - result.setSuccess(false); - } - return result; - } + public Result> loadTreeChildren(@RequestParam(name = "pid") String pid) { + Result> result = new Result>(); + try { + List ls = this.sysCategoryService.queryListByPid(pid); + result.setResult(ls); + result.setSuccess(true); + } catch (Exception e) { + e.printStackTrace(); + result.setMessage(e.getMessage()); + result.setSuccess(false); + } + return result; + } /** - * 加载一级节点/如果是同步 则所有数据 + * 加载一级节点/如果是同步 则所有数据 */ @RequestMapping(value = "/loadTreeRoot", method = RequestMethod.GET) - public Result> loadTreeRoot(@RequestParam(name="async") Boolean async,@RequestParam(name="pcode") String pcode) { - Result> result = new Result>(); - try { - List ls = this.sysCategoryService.queryListByCode(pcode); - if(!async) { - loadAllCategoryChildren(ls); - } - result.setResult(ls); - result.setSuccess(true); - } catch (Exception e) { - e.printStackTrace(); - result.setMessage(e.getMessage()); - result.setSuccess(false); - } - return result; - } + public Result> loadTreeRoot(@RequestParam(name = "async") Boolean async, @RequestParam(name = "pcode") String pcode) { + Result> result = new Result>(); + try { + List ls = this.sysCategoryService.queryListByCode(pcode); + if (!async) { + //框架自带傻逼for循环套sql 慎用 慢到想骂人 实测几百个非叶节点就已经爆炸了 +// loadAllCategoryChildren(ls); + //一次sql查所有,系统代码处理循环生成树结构 + loadAllCategoryChildrenQO(ls); + } + result.setResult(ls); + result.setSuccess(true); + } catch (Exception e) { + e.printStackTrace(); + result.setMessage(e.getMessage()); + result.setSuccess(false); + } + return result; + } /** - * 递归求子节点 同步加载用到 + * 递归求子节点 同步加载用到 */ - private void loadAllCategoryChildren(List ls) { - for (TreeSelectModel tsm : ls) { - List temp = this.sysCategoryService.queryListByPid(tsm.getKey()); - if(temp!=null && temp.size()>0) { - tsm.setChildren(temp); - loadAllCategoryChildren(temp); - } - } - } + private void loadAllCategoryChildren(List ls) { + for (TreeSelectModel tsm : ls) { + List temp = this.sysCategoryService.queryListByPid(tsm.getKey()); + if (temp != null && temp.size() > 0) { + tsm.setChildren(temp); + loadAllCategoryChildren(temp); + } + } + } - /** - * 校验编码 - * @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)){ - return Result.error("错误,类型编码为空!"); - } - if(oConvertUtils.isEmpty(pid)){ - return Result.ok(); - } - SysCategory parent = this.sysCategoryService.getById(pid); - if(code.startsWith(parent.getCode())){ - return Result.ok(); - }else{ - return Result.error("编码不符合规范,须以\""+parent.getCode()+"\"开头!"); - } + /** + * 只查询一次数据库,代码内容循环处理,避免for-sql + * + * @param ls + */ + private void loadAllCategoryChildrenQO(List ls) { + // 1. 首先获取所有可能的pid值 + Set pids = new HashSet<>(); + for (TreeSelectModel tsm : ls) { + pids.add(tsm.getKey()); + } - } + // 2. 一次性查询所有可能需要的节点 + List allNodes = this.sysCategoryService.queryAllCategories(); + + // 3. 构建节点映射表 + Map> 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 nodes, Map> nodeMap) { + for (TreeSelectModel node : nodes) { + String nodeKey = node.getKey(); + List 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)) { + return Result.error("错误,类型编码为空!"); + } + if (oConvertUtils.isEmpty(pid)) { + return Result.ok(); + } + SysCategory parent = this.sysCategoryService.getById(pid); + if (code.startsWith(parent.getCode())) { + return Result.ok(); + } else { + return Result.error("编码不符合规范,须以\"" + parent.getCode() + "\"开头!"); + } + + } - /** - * 分类字典树控件 加载节点 - * @param pid - * @param pcode - * @param condition - * @return - */ - @RequestMapping(value = "/loadTreeData", method = RequestMethod.GET) - public Result> loadDict(@RequestParam(name="pid",required = false) String pid,@RequestParam(name="pcode",required = false) String pcode, @RequestParam(name="condition",required = false) String condition) { - Result> result = new Result>(); - //pid如果传值了 就忽略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)){ - pid = ISysCategoryService.ROOT_PID_VALUE; - }else{ - pid = this.sysCategoryService.queryIdByCode(pcode); - } - if(oConvertUtils.isEmpty(pid)){ - result.setSuccess(false); - result.setMessage("加载分类字典树参数有误.[code]!"); - return result; - } - } - } - Map query = null; - if(oConvertUtils.isNotEmpty(condition)) { - query = JSON.parseObject(condition, Map.class); - } - List ls = sysCategoryService.queryListByPid(pid,query); - result.setSuccess(true); - result.setResult(ls); - return result; - } + /** + * 分类字典树控件 加载节点 + * + * @param pid + * @param pcode + * @param condition + * @return + */ + @RequestMapping(value = "/loadTreeData", method = RequestMethod.GET) + public Result> loadDict(@RequestParam(name = "pid", required = false) String pid, @RequestParam(name = "pcode", required = false) String pcode, @RequestParam(name = "condition", required = false) String condition) { + Result> result = new Result>(); + //pid如果传值了 就忽略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)) { + pid = ISysCategoryService.ROOT_PID_VALUE; + } else { + pid = this.sysCategoryService.queryIdByCode(pcode); + } + if (oConvertUtils.isEmpty(pid)) { + result.setSuccess(false); + result.setMessage("加载分类字典树参数有误.[code]!"); + return result; + } + } + } + Map query = null; + if (oConvertUtils.isNotEmpty(condition)) { + query = JSON.parseObject(condition, Map.class); + } + List ls = sysCategoryService.queryListByPid(pid, query); + result.setSuccess(true); + result.setResult(ls); + return result; + } - /** - * 分类字典控件数据回显[表单页面] - * - * @param ids - * @param delNotExist 是否移除不存在的项,默认为true,设为false如果某个key不存在数据库中,则直接返回key本身 - * @return - */ - @RequestMapping(value = "/loadDictItem", method = RequestMethod.GET) - public Result> loadDictItem(@RequestParam(name = "ids") String ids, @RequestParam(name = "delNotExist", required = false, defaultValue = "true") boolean delNotExist) { - Result> result = new Result<>(); - // 非空判断 - if (StringUtils.isBlank(ids)) { - result.setSuccess(false); - result.setMessage("ids 不能为空"); - return result; - } - // 查询数据 - List textList = sysCategoryService.loadDictItem(ids, delNotExist); - result.setSuccess(true); - result.setResult(textList); - return result; - } + /** + * 分类字典控件数据回显[表单页面] + * + * @param ids + * @param delNotExist 是否移除不存在的项,默认为true,设为false如果某个key不存在数据库中,则直接返回key本身 + * @return + */ + @RequestMapping(value = "/loadDictItem", method = RequestMethod.GET) + public Result> loadDictItem(@RequestParam(name = "ids") String ids, @RequestParam(name = "delNotExist", required = false, defaultValue = "true") boolean delNotExist) { + Result> result = new Result<>(); + // 非空判断 + if (StringUtils.isBlank(ids)) { + result.setSuccess(false); + result.setMessage("ids 不能为空"); + return result; + } + // 查询数据 + List textList = sysCategoryService.loadDictItem(ids, delNotExist); + result.setSuccess(true); + result.setResult(textList); + return result; + } - /** - * [列表页面]加载分类字典数据 用于值的替换 - * @param code - * @return - */ - @RequestMapping(value = "/loadAllData", method = RequestMethod.GET) - public Result> loadAllData(@RequestParam(name="code",required = true) String code) { - Result> result = new Result>(); - LambdaQueryWrapper query = new LambdaQueryWrapper(); - if(oConvertUtils.isNotEmpty(code) && !CATEGORY_ROOT_CODE.equals(code)){ - query.likeRight(SysCategory::getCode,code); - } - List list = this.sysCategoryService.list(query); - if(list==null || list.size()==0) { - result.setMessage("无数据,参数有误.[code]"); - result.setSuccess(false); - return result; - } - List rdList = new ArrayList(); - for (SysCategory c : list) { - rdList.add(new DictModel(c.getId(),c.getName())); - } - result.setSuccess(true); - result.setResult(rdList); - return result; - } + /** + * [列表页面]加载分类字典数据 用于值的替换 + * + * @param code + * @return + */ + @RequestMapping(value = "/loadAllData", method = RequestMethod.GET) + public Result> loadAllData(@RequestParam(name = "code", required = true) String code) { + Result> result = new Result>(); + LambdaQueryWrapper query = new LambdaQueryWrapper(); + if (oConvertUtils.isNotEmpty(code) && !CATEGORY_ROOT_CODE.equals(code)) { + query.likeRight(SysCategory::getCode, code); + } + List list = this.sysCategoryService.list(query); + if (list == null || list.size() == 0) { + result.setMessage("无数据,参数有误.[code]"); + result.setSuccess(false); + return result; + } + List rdList = new ArrayList(); + for (SysCategory c : list) { + rdList.add(new DictModel(c.getId(), c.getName())); + } + result.setSuccess(true); + result.setResult(rdList); + return result; + } - /** - * 根据父级id批量查询子节点 - * @param parentIds - * @return - */ - @GetMapping("/getChildListBatch") - public Result getChildListBatch(@RequestParam("parentIds") String parentIds) { - try { - QueryWrapper queryWrapper = new QueryWrapper<>(); - List parentIdList = Arrays.asList(parentIds.split(",")); - queryWrapper.in("pid", parentIdList); - List list = sysCategoryService.list(queryWrapper); - IPage pageList = new Page<>(1, 10, list.size()); - pageList.setRecords(list); - return Result.OK(pageList); - } catch (Exception e) { - log.error(e.getMessage(), e); - return Result.error("批量查询子节点失败:" + e.getMessage()); - } - } + /** + * 根据父级id批量查询子节点 + * + * @param parentIds + * @return + */ + @GetMapping("/getChildListBatch") + public Result getChildListBatch(@RequestParam("parentIds") String parentIds) { + try { + QueryWrapper queryWrapper = new QueryWrapper<>(); + List parentIdList = Arrays.asList(parentIds.split(",")); + queryWrapper.in("pid", parentIdList); + List list = sysCategoryService.list(queryWrapper); + IPage pageList = new Page<>(1, 10, list.size()); + pageList.setRecords(list); + return Result.OK(pageList); + } catch (Exception e) { + log.error(e.getMessage(), e); + return Result.error("批量查询子节点失败:" + e.getMessage()); + } + } } diff --git a/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/controller/SysDepartController.java b/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/controller/SysDepartController.java index d24b7a2..e1f6a21 100644 --- a/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/controller/SysDepartController.java +++ b/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/controller/SysDepartController.java @@ -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; } + } diff --git a/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/entity/SysCategory.java b/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/entity/SysCategory.java index 331d675..95ba24b 100644 --- a/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/entity/SysCategory.java +++ b/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/entity/SysCategory.java @@ -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{ +public class SysCategory implements Serializable, Comparable { 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 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 getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } } diff --git a/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/entity/SysDepart.java b/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/entity/SysDepart.java index e7b90c4..790a6f4 100644 --- a/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/entity/SysDepart.java +++ b/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/entity/SysDepart.java @@ -20,126 +20,209 @@ import java.util.Objects; *

* * @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); } } diff --git a/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/mapper/SysCategoryMapper.java b/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/mapper/SysCategoryMapper.java index 9086261..2d7cc31 100644 --- a/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/mapper/SysCategoryMapper.java +++ b/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/mapper/SysCategoryMapper.java @@ -48,4 +48,6 @@ public interface SysCategoryMapper extends BaseMapper { @InterceptorIgnore(tenantLine = "true") @Select("SELECT code FROM sys_category WHERE ID = #{id}") SysCategory selectSysCategoryById(@Param("id") String id); + + List queryAllCategories(); } diff --git a/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysCategoryMapper.xml b/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysCategoryMapper.xml index 741670c..e960322 100644 --- a/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysCategoryMapper.xml +++ b/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysCategoryMapper.xml @@ -32,6 +32,15 @@ + diff --git a/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/model/SysDepartTreeModel.java b/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/model/SysDepartTreeModel.java index 3c6c8ad..8736747 100644 --- a/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/model/SysDepartTreeModel.java +++ b/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/model/SysDepartTreeModel.java @@ -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 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); } } diff --git a/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/service/ISysCategoryService.java b/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/service/ISysCategoryService.java index bab896a..4a7f54c 100644 --- a/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/service/ISysCategoryService.java +++ b/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/service/ISysCategoryService.java @@ -51,6 +51,8 @@ public interface ISysCategoryService extends IService { */ public List queryListByPid(String pid); + public List queryAllCategories(); + /** * 根据pid查询子节点集合,支持查询条件 * @param pid diff --git a/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysCategoryServiceImpl.java b/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysCategoryServiceImpl.java index 5724db3..4894d7c 100644 --- a/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysCategoryServiceImpl.java +++ b/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysCategoryServiceImpl.java @@ -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 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 queryListByCode(String pcode) throws JeecgBootException{ - String pid = ROOT_PID_VALUE; - if(oConvertUtils.isNotEmpty(pcode)) { - List list = baseMapper.selectList(new LambdaQueryWrapper().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 queryListByCode(String pcode) throws JeecgBootException { + String pid = ROOT_PID_VALUE; + if (oConvertUtils.isNotEmpty(pcode)) { + List list = baseMapper.selectList(new LambdaQueryWrapper().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 queryListByPid(String pid) { - if(oConvertUtils.isEmpty(pid)) { - pid = ROOT_PID_VALUE; - } - return baseMapper.queryListByPid(pid,null); - } + @Override + public List queryListByPid(String pid) { + if (oConvertUtils.isEmpty(pid)) { + pid = ROOT_PID_VALUE; + } + return baseMapper.queryListByPid(pid, null); + } - @Override - public List queryListByPid(String pid, Map condition) { - if(oConvertUtils.isEmpty(pid)) { - pid = ROOT_PID_VALUE; - } - return baseMapper.queryListByPid(pid,condition); - } + @Override + public List queryAllCategories() { + return baseMapper.queryAllCategories(); + } - @Override - public String queryIdByCode(String code) { - return baseMapper.queryIdByCode(code); - } + @Override + public List queryListByPid(String pid, Map 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 updateWrapper = new UpdateWrapper() - .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 updateWrapper = new UpdateWrapper() + .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 queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(SysCategory::getPid,metaPid); - queryWrapper.notIn(SysCategory::getId,Arrays.asList(idArr)); - List 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 queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(SysCategory::getPid, metaPid); + queryWrapper.notIn(SysCategory::getId, Arrays.asList(idArr)); + List 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 queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(SysCategory::getPid,pidVal); - List 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 queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(SysCategory::getPid, pidVal); + List 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 loadDictItem(String ids) { - return this.loadDictItem(ids, true); - } + @Override + public List loadDictItem(String ids) { + return this.loadDictItem(ids, true); + } - @Override - public List loadDictItem(String ids, boolean delNotExist) { - String[] idArray = ids.split(","); - LambdaQueryWrapper query = new LambdaQueryWrapper<>(); - query.in(SysCategory::getId, Arrays.asList(idArray)); - // 查询数据 - List list = super.list(query); - // 取出name并返回 - List 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 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 loadDictItem(String ids, boolean delNotExist) { + String[] idArray = ids.split(","); + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.in(SysCategory::getId, Arrays.asList(idArray)); + // 查询数据 + List list = super.list(query); + // 取出name并返回 + List 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 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 loadDictItemByNames(String names, boolean delNotExist) { - List nameList = Arrays.asList(names.split(SymbolConstant.COMMA)); - LambdaQueryWrapper query = new LambdaQueryWrapper<>(); - query.select(SysCategory::getId, SysCategory::getName); - query.in(SysCategory::getName, nameList); - // 查询数据 - List 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 loadDictItemByNames(String names, boolean delNotExist) { + List nameList = Arrays.asList(names.split(SymbolConstant.COMMA)); + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.select(SysCategory::getId, SysCategory::getName); + query.in(SysCategory::getName, nameList); + // 查询数据 + List 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()); + } } diff --git a/nursing-unit-system/nu-system-start/src/main/resources/application-dev.yml b/nursing-unit-system/nu-system-start/src/main/resources/application-dev.yml index b65fd86..7b84e6d 100644 --- a/nursing-unit-system/nu-system-start/src/main/resources/application-dev.yml +++ b/nursing-unit-system/nu-system-start/src/main/resources/application-dev.yml @@ -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 + diff --git a/nursing-unit-system/nu-system-start/src/main/resources/application-uat.yml b/nursing-unit-system/nu-system-start/src/main/resources/application-uat.yml index 79b708d..7164931 100644 --- a/nursing-unit-system/nu-system-start/src/main/resources/application-uat.yml +++ b/nursing-unit-system/nu-system-start/src/main/resources/application-uat.yml @@ -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