e9f290b5 张雷

增加初始化用户方法

1 个父辈 07dd7323
...@@ -17,8 +17,14 @@ ...@@ -17,8 +17,14 @@
17 <artifactId>javassist</artifactId> 17 <artifactId>javassist</artifactId>
18 <version>3.21.0-GA</version> 18 <version>3.21.0-GA</version>
19 </dependency> 19 </dependency>
20 <!-- 汉字转拼音 -->
21 <dependency>
22 <groupId>com.belerweb</groupId>
23 <artifactId>pinyin4j</artifactId>
24 <version>2.5.1</version>
25 </dependency>
20 </dependencies> 26 </dependencies>
21 27
22 <repositories> 28 <repositories>
23 <repository> 29 <repository>
24 <id>aliyun</id> 30 <id>aliyun</id>
...@@ -37,5 +43,5 @@ ...@@ -37,5 +43,5 @@
37 </snapshots> 43 </snapshots>
38 </repository> 44 </repository>
39 </repositories> 45 </repositories>
40
41 </project>
...\ No newline at end of file ...\ No newline at end of file
46
47 </project>
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
30 inner join sys_factory_device sfd on sfi.depart_id = sfd.depart_id 30 inner join sys_factory_device sfd on sfi.depart_id = sfd.depart_id
31 WHERE 31 WHERE
32 1=1 32 1=1
33 and sd.depart_type in(3,4,5) 33 and sd.depart_type in(1,3,4,5)
34 <if test="departId!=null and departId!='' "> 34 <if test="departId!=null and departId!='' ">
35 and sfi.depart_id = #{departId} 35 and sfi.depart_id = #{departId}
36 </if> 36 </if>
......
1 package com.skua.tool.util;
2
3 import net.sourceforge.pinyin4j.PinyinHelper;
4 import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
5 import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
6 import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
7 import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
8
9 public class ChineseToPinyin {
10 public static String toPinyin(String chinese) {
11 HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
12 format.setCaseType(HanyuPinyinCaseType.LOWERCASE);
13 format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
14
15 StringBuilder sb = new StringBuilder();
16 char[] chars = chinese.toCharArray();
17 for (char ch : chars) {
18 if (Character.isWhitespace(ch)) {
19 continue;
20 }
21 if (ch > 128) {
22 try {
23 String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(ch, format);
24 if (pinyinArray != null) {
25 sb.append(pinyinArray[0]);
26 } else {
27 sb.append(ch);
28 }
29 } catch (BadHanyuPinyinOutputFormatCombination e) {
30 e.printStackTrace();
31 }
32 } else {
33 sb.append(ch);
34 }
35 }
36 return sb.toString();
37 }
38
39 public static void main(String[] args) {
40 String chinese = "中文";
41 String pinyin = toPinyin(chinese);
42 System.out.println(pinyin); // zhongwen 或者 zhong wen 取决于HanyuPinyinToneType设置
43 }
44 }
...@@ -37,7 +37,6 @@ import com.google.common.collect.Sets; ...@@ -37,7 +37,6 @@ import com.google.common.collect.Sets;
37 import com.skua.core.context.SpringContextUtils; 37 import com.skua.core.context.SpringContextUtils;
38 import com.skua.core.util.ConvertUtils; 38 import com.skua.core.util.ConvertUtils;
39 import com.skua.core.util.DateUtils; 39 import com.skua.core.util.DateUtils;
40 import com.skua.core.util.chuanglan.HttpSenderMsg;
41 import com.skua.core.util.push.IPushService; 40 import com.skua.core.util.push.IPushService;
42 import com.skua.core.util.push.MessageEntity; 41 import com.skua.core.util.push.MessageEntity;
43 import com.skua.core.util.push.PushMessageFactory; 42 import com.skua.core.util.push.PushMessageFactory;
...@@ -581,7 +580,7 @@ public class RealTimeAlarmJob implements Job { ...@@ -581,7 +580,7 @@ public class RealTimeAlarmJob implements Job {
581 aliAlarm.setTime(date); 580 aliAlarm.setTime(date);
582 aliAlarm.setPhone(phone1); 581 aliAlarm.setPhone(phone1);
583 //发送短信 582 //发送短信
584 HttpSenderMsg.sendMsg(prefix + date + "时" + departName + "采集数据" + content + suffix, phone1); 583 // HttpSenderMsg.sendMsg(prefix + date + "时" + departName + "采集数据" + content + suffix, phone1);
585 AliSmsUtil.sendLimitAlarmMsg(aliAlarm);//新版短息发送工具 584 AliSmsUtil.sendLimitAlarmMsg(aliAlarm);//新版短息发送工具
586 log.info("短信发送成功手机号:" + phone1 + ",内容:" + content); 585 log.info("短信发送成功手机号:" + phone1 + ",内容:" + content);
587 } 586 }
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
17 ifnull(a.cou,0) count, 17 ifnull(a.cou,0) count,
18 b.item_text NAME 18 b.item_text NAME
19 FROM 19 FROM
20 ( SELECT item_text, item_value FROM sys_dict_item 20 ( SELECT item_text, item_value, sort_order FROM sys_dict_item
21 WHERE dict_id = ( SELECT id FROM sys_dict WHERE dict_code = 'information_type' ) 21 WHERE dict_id = ( SELECT id FROM sys_dict WHERE dict_code = 'information_type' )
22 ) b 22 ) b
23 left join 23 left join
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
31 GROUP BY fac_informationtype 31 GROUP BY fac_informationtype
32 ) a 32 ) a
33 ON a.fac_informationtype = b.item_value 33 ON a.fac_informationtype = b.item_value
34 34 ORDER BY b.sort_order
35 </select> 35 </select>
36 <select id="flowStatistics" resultType="java.util.Map"> 36 <select id="flowStatistics" resultType="java.util.Map">
37 SELECT 37 SELECT
...@@ -53,5 +53,5 @@ ...@@ -53,5 +53,5 @@
53 GROUP BY 53 GROUP BY
54 b.create_time,b.handle_type 54 b.create_time,b.handle_type
55 </select> 55 </select>
56
57 </mapper>
...\ No newline at end of file ...\ No newline at end of file
56
57 </mapper>
......
...@@ -370,7 +370,15 @@ ...@@ -370,7 +370,15 @@
370 ROUND( SUM( v.GFCZL ), 2 ) AS ybagfczl, 370 ROUND( SUM( v.GFCZL ), 2 ) AS ybagfczl,
371 ROUND( SUM( v.WNL )*(1-AVG( v.WNHSL ))) AS jgnl, 371 ROUND( SUM( v.WNL )*(1-AVG( v.WNHSL ))) AS jgnl,
372 ROUND( SUM( v.WFCSL ), 2 ) AS wxfwcsl, 372 ROUND( SUM( v.WFCSL ), 2 ) AS wxfwcsl,
373 ROUND( SUM( v.WFCZL ), 2 ) AS wxfwczl 373 ROUND( SUM( v.WFCZL ), 2 ) AS wxfwczl,
374 v2.jscodl,
375 v2.cscodl,
376 v2.jsadl,
377 v2.csadl,
378 v2.jstpl,
379 v2.cstpl,
380 v2.jstnl,
381 v2.cstnl
374 FROM 382 FROM
375 ${dataViewName3} v 383 ${dataViewName3} v
376 LEFT JOIN ( 384 LEFT JOIN (
...@@ -378,6 +386,14 @@ ...@@ -378,6 +386,14 @@
378 LEFT ( v.time, 7 ) AS time, 386 LEFT ( v.time, 7 ) AS time,
379 ROUND( SUM( v.CSL )/10000, 2 ) AS sjwscll, 387 ROUND( SUM( v.CSL )/10000, 2 ) AS sjwscll,
380 ROUND( AVG( v.CSL )/10000, 2 ) AS rwscll, 388 ROUND( AVG( v.CSL )/10000, 2 ) AS rwscll,
389 ROUND( SUM( IFNULL(v.JSCOD*v.JSL,0)/1000000 ), 2 ) AS jscodl,
390 ROUND( SUM( IFNULL(v.CSCOD*v.CSL,0)/1000000 ), 2 ) AS cscodl,
391 ROUND( SUM( IFNULL(v.CSTN*v.CSL,0)/1000000 ), 2 ) AS cstnl,
392 ROUND( SUM( IFNULL(v.JSZD*v.JSL,0)/1000000 ), 2 ) AS jstnl,
393 ROUND( SUM( IFNULL(v.JSZL*v.JSL,0)/1000000 ), 2 ) AS jstpl,
394 ROUND( SUM( IFNULL(v.CSZL*v.CSL,0)/1000000 ), 2 ) AS cstpl,
395 ROUND( SUM( IFNULL(v.JSAD*v.JSL,0)/1000000 ), 2 ) AS jsadl,
396 ROUND( SUM( IFNULL(v.CSAD*v.CSL,0)/1000000 ), 2 ) AS csadl,
381 count( v.id ) AS scsj 397 count( v.id ) AS scsj
382 FROM 398 FROM
383 ${dataViewName2} v 399 ${dataViewName2} v
......
...@@ -235,7 +235,7 @@ public class FCustomReportDatasetServiceImpl extends ServiceImpl<FCustomReportDa ...@@ -235,7 +235,7 @@ public class FCustomReportDatasetServiceImpl extends ServiceImpl<FCustomReportDa
235 List<JnhbReportDetailsJs> jsList = new ArrayList<>(); 235 List<JnhbReportDetailsJs> jsList = new ArrayList<>();
236 List<JnhbReportDetailsHj> hjList = new ArrayList<>(); 236 List<JnhbReportDetailsHj> hjList = new ArrayList<>();
237 String year = month.substring(0,4); 237 String year = month.substring(0,4);
238 String dataViewName2 = ReportViewUtil.buildViewLike(ReportConstant.view2119,"CSL,JSZL,CSZL,JSCOD,CSCOD,JSAD,CSAD,JSZD,CSTN", departId, year); 238 String dataViewName2 = ReportViewUtil.buildViewLike(ReportConstant.view2119,"CSL,JSL,JSZL,CSZL,JSCOD,CSCOD,JSAD,CSAD,JSZD,CSTN", departId, year);
239 String dataViewName3 = ReportViewUtil.buildViewLike(ReportConstant.view3a24,"", departId, year); 239 String dataViewName3 = ReportViewUtil.buildViewLike(ReportConstant.view3a24,"", departId, year);
240 dyList = mapper.getDyList(dataViewName2, dataViewName3, departId, year); 240 dyList = mapper.getDyList(dataViewName2, dataViewName3, departId, year);
241 jsList = mapper.getJsList(dataViewName2, dataViewName3, departId, year); 241 jsList = mapper.getJsList(dataViewName2, dataViewName3, departId, year);
......
...@@ -56,7 +56,7 @@ public class ShiroConfig { ...@@ -56,7 +56,7 @@ public class ShiroConfig {
56 filterChainDefinitionMap.put("/sys/user/register", "anon");//用户注册 56 filterChainDefinitionMap.put("/sys/user/register", "anon");//用户注册
57 filterChainDefinitionMap.put("/sys/user/querySysUser", "anon");//根据手机号获取用户信息 57 filterChainDefinitionMap.put("/sys/user/querySysUser", "anon");//根据手机号获取用户信息
58 filterChainDefinitionMap.put("/sys/user/phoneVerification", "anon");//用户忘记密码验证手机号 58 filterChainDefinitionMap.put("/sys/user/phoneVerification", "anon");//用户忘记密码验证手机号
59 filterChainDefinitionMap.put("/sys/user/passwordChange", "anon");//用户更改密码 59 // filterChainDefinitionMap.put("/sys/user/passwordChange", "anon");//用户更改密码
60 filterChainDefinitionMap.put("/auth/2step-code", "anon");//登录验证码 60 filterChainDefinitionMap.put("/auth/2step-code", "anon");//登录验证码
61 filterChainDefinitionMap.put("/sys/common/view/**", "anon");//图片预览不限制token 61 filterChainDefinitionMap.put("/sys/common/view/**", "anon");//图片预览不限制token
62 filterChainDefinitionMap.put("/sys/common/download/**", "anon");//文件下载不限制token 62 filterChainDefinitionMap.put("/sys/common/download/**", "anon");//文件下载不限制token
...@@ -87,6 +87,7 @@ public class ShiroConfig { ...@@ -87,6 +87,7 @@ public class ShiroConfig {
87 filterChainDefinitionMap.put("/swagger**/**", "anon"); 87 filterChainDefinitionMap.put("/swagger**/**", "anon");
88 filterChainDefinitionMap.put("/webjars/**", "anon"); 88 filterChainDefinitionMap.put("/webjars/**", "anon");
89 filterChainDefinitionMap.put("/v2/**", "anon"); 89 filterChainDefinitionMap.put("/v2/**", "anon");
90 filterChainDefinitionMap.put("/sys/init/**", "anon");
90 91
91 //暂时放开表维护的shiro权限 92 //暂时放开表维护的shiro权限
92 filterChainDefinitionMap.put("/v1/expert/expertInitConfig/**", "anon"); 93 filterChainDefinitionMap.put("/v1/expert/expertInitConfig/**", "anon");
......
...@@ -38,7 +38,6 @@ import com.skua.core.util.ConvertUtils; ...@@ -38,7 +38,6 @@ import com.skua.core.util.ConvertUtils;
38 import com.skua.core.util.DateUtils; 38 import com.skua.core.util.DateUtils;
39 import com.skua.core.util.JwtUtil; 39 import com.skua.core.util.JwtUtil;
40 import com.skua.core.util.PasswordUtil; 40 import com.skua.core.util.PasswordUtil;
41 import com.skua.core.util.chuanglan.HttpSenderMsg;
42 import com.skua.core.util.encryption.AesEncryptUtil; 41 import com.skua.core.util.encryption.AesEncryptUtil;
43 import com.skua.core.util.encryption.EncryptedString; 42 import com.skua.core.util.encryption.EncryptedString;
44 import com.skua.modules.shiro.vo.DefContants; 43 import com.skua.modules.shiro.vo.DefContants;
...@@ -494,7 +493,6 @@ public class LoginController { ...@@ -494,7 +493,6 @@ public class LoginController {
494 return result; 493 return result;
495 } 494 }
496 aliCode.setType("register"); 495 aliCode.setType("register");
497 // b = HttpSenderMsg.sendMsg("注册验证码为:" + captcha, mobile);
498 } else { 496 } else {
499 //登录模式,校验用户有效性 497 //登录模式,校验用户有效性
500 SysUser sysUser = sysUserService.getUserByPhone(mobile); 498 SysUser sysUser = sysUserService.getUserByPhone(mobile);
...@@ -509,11 +507,9 @@ public class LoginController { ...@@ -509,11 +507,9 @@ public class LoginController {
509 if (CommonConstant.SMS_TPL_TYPE_0.equals(smsmode)) { 507 if (CommonConstant.SMS_TPL_TYPE_0.equals(smsmode)) {
510 //登录模板 508 //登录模板
511 aliCode.setType("login"); 509 aliCode.setType("login");
512 // b = HttpSenderMsg.sendMsg("登录验证码为:" + captcha, mobile);
513 } else if (CommonConstant.SMS_TPL_TYPE_2.equals(smsmode)) { 510 } else if (CommonConstant.SMS_TPL_TYPE_2.equals(smsmode)) {
514 aliCode.setType("update");
515 //忘记密码模板 511 //忘记密码模板
516 // b = HttpSenderMsg.sendMsg("验证码为:" + captcha, mobile); 512 aliCode.setType("update");
517 } 513 }
518 } 514 }
519 b = AliSmsUtil.sendCodeMsg(aliCode); 515 b = AliSmsUtil.sendCodeMsg(aliCode);
......
1 package com.skua.modules.system.controller;
2
3 import com.skua.core.api.vo.Result;
4 import com.skua.modules.system.service.ITestService;
5 import io.swagger.annotations.Api;
6 import io.swagger.annotations.ApiOperation;
7 import lombok.extern.slf4j.Slf4j;
8 import org.springframework.web.bind.annotation.*;
9
10 import javax.annotation.Resource;
11
12 @Api(tags = "初始化用户")
13 @Slf4j
14 @RestController
15 @RequestMapping("/sys/init")
16 public class TestController {
17
18 @Resource
19 private ITestService testService;
20
21 @GetMapping("/user")
22 @ApiOperation(value = "初始化用户")
23 public Result<?> batchInitUser(){
24 Result<?> result = new Result<>();
25 boolean ok = testService.batchInitUser();
26 result.setSuccess(ok);
27 return result;
28 }
29 }
1 package com.skua.modules.system.service;
2
3 public interface ITestService{
4
5 boolean batchInitUser();
6
7 }
1 package com.skua.modules.system.service.impl;
2
3 import com.skua.core.context.SpringContextUtils;
4 import com.skua.core.util.ConvertUtils;
5 import com.skua.core.util.DateUtils;
6 import com.skua.core.util.PasswordUtil;
7 import com.skua.modules.system.service.ITestService;
8 import com.skua.tool.util.ChineseToPinyin;
9 import lombok.extern.slf4j.Slf4j;
10 import org.springframework.jdbc.core.JdbcTemplate;
11 import org.springframework.stereotype.Service;
12
13 import java.util.Arrays;
14 import java.util.List;
15 import java.util.Map;
16 import java.util.UUID;
17
18 @Service
19 @Slf4j
20 public class TestServiceImpl implements ITestService {
21
22 @Override
23 public boolean batchInitUser() {
24 JdbcTemplate jdbcTemplate = (JdbcTemplate) SpringContextUtils.getBean("master");
25 String sql = "select * from sys_user_init ";
26 List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
27 if(list.size() > 0){
28 for (Map<String,Object> map : list) {
29 String departId = map.get("depart_id").toString();
30 String realName = map.get("user_name").toString();
31 String userName = ChineseToPinyin.toPinyin(realName);
32 String phone = map.get("user_phone").toString();
33 String role = map.get("roles").toString();
34 String roles = "";
35 if(map.get("remark")!=null){
36 roles = map.get("remark").toString();
37 role = role +","+ roles;
38 }
39 role = "8cc3cf58677fc68e42e9e46ae2462a17," + role;
40 String userId = UUID.randomUUID().toString().replaceAll("-", "");
41
42 String salt = ConvertUtils.randomGen(8);
43 String password = PasswordUtil.encrypt(userName, "zhongye123.", salt);
44
45 String insertUserSql = "INSERT INTO sys_user_bak " +
46 "(id, username, realname, password, salt, phone, status, " +
47 "del_flag, activiti_sync, create_by, create_time, is_system_user,user_type) " +
48 "VALUES " +
49 "('"+userId+"', '"+userName+"', '"+realName+"', '"+password+"', '"+salt+"', '"+phone+"', 1, " +
50 "1, 1, 'admin', '"+ DateUtils.getDate("yyyy-MM-dd HH:mm:ss")+"', '0', '2')";
51 jdbcTemplate.execute(insertUserSql);
52
53 List<String> roleIdArray = Arrays.asList(role.split(","));
54 for (String roleId : roleIdArray) {
55 String uuid = UUID.randomUUID().toString().replaceAll("-", "");
56 String insertRoleSql = "INSERT INTO sys_user_role " +
57 "(id, user_id, role_id) " +
58 "VALUES " +
59 "('"+uuid+"', '"+userId+"', '"+roleId+"')";
60 jdbcTemplate.execute(insertRoleSql);
61 }
62
63 String departUuid = UUID.randomUUID().toString().replaceAll("-", "");
64 String insertDepartSql = "INSERT INTO sys_user_depart " +
65 "(id, user_id, dep_id, dep_ids) " +
66 "VALUES " +
67 "('"+departUuid+"', '"+userId+"', '"+departId+"', '"+departId+"')";
68 jdbcTemplate.execute(insertDepartSql);
69 }
70
71 }
72
73
74 return false;
75 }
76 }
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!