416f8f1c 康伟

Merge remote-tracking branch 'origin/master'

2 个父辈 84ee12f3 60b2dcb5
......@@ -17,8 +17,14 @@
<artifactId>javassist</artifactId>
<version>3.21.0-GA</version>
</dependency>
<!-- 汉字转拼音 -->
<dependency>
<groupId>com.belerweb</groupId>
<artifactId>pinyin4j</artifactId>
<version>2.5.1</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>aliyun</id>
......@@ -37,5 +43,5 @@
</snapshots>
</repository>
</repositories>
</project>
\ No newline at end of file
</project>
......
......@@ -30,7 +30,7 @@
inner join sys_factory_device sfd on sfi.depart_id = sfd.depart_id
WHERE
1=1
and sd.depart_type in(3,4,5)
and sd.depart_type in(1,3,4,5)
<if test="departId!=null and departId!='' ">
and sfi.depart_id = #{departId}
</if>
......
package com.skua.tool.util;
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
public class ChineseToPinyin {
public static String toPinyin(String chinese) {
HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
format.setCaseType(HanyuPinyinCaseType.LOWERCASE);
format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
StringBuilder sb = new StringBuilder();
char[] chars = chinese.toCharArray();
for (char ch : chars) {
if (Character.isWhitespace(ch)) {
continue;
}
if (ch > 128) {
try {
String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(ch, format);
if (pinyinArray != null) {
sb.append(pinyinArray[0]);
} else {
sb.append(ch);
}
} catch (BadHanyuPinyinOutputFormatCombination e) {
e.printStackTrace();
}
} else {
sb.append(ch);
}
}
return sb.toString();
}
public static void main(String[] args) {
String chinese = "中文";
String pinyin = toPinyin(chinese);
System.out.println(pinyin); // zhongwen 或者 zhong wen 取决于HanyuPinyinToneType设置
}
}
......@@ -37,7 +37,6 @@ import com.google.common.collect.Sets;
import com.skua.core.context.SpringContextUtils;
import com.skua.core.util.ConvertUtils;
import com.skua.core.util.DateUtils;
import com.skua.core.util.chuanglan.HttpSenderMsg;
import com.skua.core.util.push.IPushService;
import com.skua.core.util.push.MessageEntity;
import com.skua.core.util.push.PushMessageFactory;
......@@ -581,7 +580,7 @@ public class RealTimeAlarmJob implements Job {
aliAlarm.setTime(date);
aliAlarm.setPhone(phone1);
//发送短信
HttpSenderMsg.sendMsg(prefix + date + "时" + departName + "采集数据" + content + suffix, phone1);
// HttpSenderMsg.sendMsg(prefix + date + "时" + departName + "采集数据" + content + suffix, phone1);
AliSmsUtil.sendLimitAlarmMsg(aliAlarm);//新版短息发送工具
log.info("短信发送成功手机号:" + phone1 + ",内容:" + content);
}
......
......@@ -141,25 +141,42 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService {
//获取当天同比数据map
Map<String,Object> tb = tbMap.get(DateUtils.formatAddTime(time,formatPattern,Calendar.YEAR,-1));
if(tb!=null&&tb.size()>0) {
double value = ConvertUtils.getDouble(map.get(index), 0);
double tb_value = 0;
if(index.contains("JSLL")||index.contains("CSLL")) {
tempMap.put(index+"_tb", DoubleOperaUtils.bigDecimalRound(ConvertUtils.getDouble(tb.get(realKey), 0.0), 2));
tb_value = DoubleOperaUtils.bigDecimalRound(ConvertUtils.getDouble(tb.get(realKey), 0.0), 2);
}else {
tempMap.put(index+"_tb", DoubleOperaUtils.bigDecimalRound(ConvertUtils.getDouble(tb.get(realKey), 0.0)/ConvertUtils.getDouble(tb.get(realKey+"_tag"), 1.0), 2));
tb_value = DoubleOperaUtils.bigDecimalRound(ConvertUtils.getDouble(tb.get(realKey), 0.0)/ConvertUtils.getDouble(tb.get(realKey+"_tag"), 1.0), 2);
}
tempMap.put(index+"_tb", tb_value);
//添加同比比例
if(tb_value==0) {
map.put(index+"_tb_rate", 0);
}else {
map.put(index+"_tb_rate", DoubleOperaUtils.bigDecimalRound((value - tb_value)/tb_value*100, 2));
}
}
}
if(!StringUtils.isEmpty(contrastType)&&contrastType.contains("hb")) {
//获取当天同比数据map
Map<String,Object> hb = hbMap.get(DateUtils.formatAddTime(time,formatPattern,Calendar.MONTH,-1));
if("hour".equals(granularity)) {
hb = hbMap.get(DateUtils.formatAddTime(time,formatPattern,Calendar.DAY_OF_YEAR,-1));
}
if(hb!=null&&hb.size()>0) {
double value = ConvertUtils.getDouble(map.get(index), 0);
double hb_value = 0;
if(index.contains("JSLL")||index.contains("CSLL")) {
tempMap.put(index+"_hb", DoubleOperaUtils.bigDecimalRound(ConvertUtils.getDouble(hb.get(realKey), 0.0), 2));
hb_value = DoubleOperaUtils.bigDecimalRound(ConvertUtils.getDouble(hb.get(realKey), 0.0), 2);
}else {
tempMap.put(index+"_hb", DoubleOperaUtils.bigDecimalRound(ConvertUtils.getDouble(hb.get(realKey), 0.0)/ConvertUtils.getDouble(hb.get(realKey+"_tag"), 1.0), 2));
hb_value = DoubleOperaUtils.bigDecimalRound(ConvertUtils.getDouble(hb.get(realKey), 0.0)/ConvertUtils.getDouble(hb.get(realKey+"_tag"), 1.0), 2);
}
tempMap.put(index+"_hb", hb_value);
//添加同比比例
if(hb_value==0) {
map.put(index+"_hb_rate", 0);
}else {
map.put(index+"_hb_rate", DoubleOperaUtils.bigDecimalRound((value - hb_value)/hb_value*100, 2));
}
}
}
......@@ -385,7 +402,15 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService {
Map<String,Object> tb = tbMap.get(DateUtils.formatAddTime(time,pattern,Calendar.YEAR,-1)+""+map.get("departId"));
if(tb!=null&&tb.size()>0) {
for(String key : indexArray) {
map.put(key+"_tb", tb.get(key));
double value = ConvertUtils.getDouble(map.get(key), 0);
double tb_value = ConvertUtils.getDouble(tb.get(key), 0);
map.put(key+"_tb", String.valueOf(tb_value));
//添加同比比例
if(tb_value==0) {
map.put(key+"_tb_rate", 0);
}else {
map.put(key+"_tb_rate", DoubleOperaUtils.bigDecimalRound((value - tb_value)/tb_value*100, 2));
}
}
}
}
......@@ -393,7 +418,15 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService {
Map<String,Object> hb = hbMap.get(DateUtils.formatAddTime(time,pattern,Calendar.MONTH,-1)+""+map.get("departId"));
if(hb!=null&&hb.size()>0) {
for(String key : indexArray) {
map.put(key+"_hb", hb.get(key));
double value = ConvertUtils.getDouble(map.get(key), 0);
double hb_value = ConvertUtils.getDouble(hb.get(key), 0);
map.put(key+"_hb", String.valueOf(hb_value));
//添加同比比例
if(hb_value==0) {
map.put(key+"_hb_rate", 0);
}else {
map.put(key+"_hb_rate", DoubleOperaUtils.bigDecimalRound((value - hb_value)/hb_value*100, 2));
}
}
}
}
......
......@@ -17,7 +17,7 @@
ifnull(a.cou,0) count,
b.item_text NAME
FROM
( SELECT item_text, item_value FROM sys_dict_item
( SELECT item_text, item_value, sort_order FROM sys_dict_item
WHERE dict_id = ( SELECT id FROM sys_dict WHERE dict_code = 'information_type' )
) b
left join
......@@ -31,7 +31,7 @@
GROUP BY fac_informationtype
) a
ON a.fac_informationtype = b.item_value
ORDER BY b.sort_order
</select>
<select id="flowStatistics" resultType="java.util.Map">
SELECT
......@@ -53,5 +53,5 @@
GROUP BY
b.create_time,b.handle_type
</select>
</mapper>
\ No newline at end of file
</mapper>
......
......@@ -351,7 +351,15 @@
ROUND( SUM( v.GFCZL ), 2 ) AS ybagfczl,
ROUND( SUM( v.WNL )*(1-AVG( v.WNHSL ))) AS jgnl,
ROUND( SUM( v.WFCSL ), 2 ) AS wxfwcsl,
ROUND( SUM( v.WFCZL ), 2 ) AS wxfwczl
ROUND( SUM( v.WFCZL ), 2 ) AS wxfwczl,
v2.jscodl,
v2.cscodl,
v2.jsadl,
v2.csadl,
v2.jstpl,
v2.cstpl,
v2.jstnl,
v2.cstnl
FROM
${dataViewName3} v
LEFT JOIN (
......@@ -359,6 +367,14 @@
LEFT ( v.time, 7 ) AS time,
ROUND( SUM( v.CSL )/10000, 2 ) AS sjwscll,
ROUND( AVG( v.CSL )/10000, 2 ) AS rwscll,
ROUND( SUM( IFNULL(v.JSCOD*v.JSL,0)/1000000 ), 2 ) AS jscodl,
ROUND( SUM( IFNULL(v.CSCOD*v.CSL,0)/1000000 ), 2 ) AS cscodl,
ROUND( SUM( IFNULL(v.CSTN*v.CSL,0)/1000000 ), 2 ) AS cstnl,
ROUND( SUM( IFNULL(v.JSZD*v.JSL,0)/1000000 ), 2 ) AS jstnl,
ROUND( SUM( IFNULL(v.JSZL*v.JSL,0)/1000000 ), 2 ) AS jstpl,
ROUND( SUM( IFNULL(v.CSZL*v.CSL,0)/1000000 ), 2 ) AS cstpl,
ROUND( SUM( IFNULL(v.JSAD*v.JSL,0)/1000000 ), 2 ) AS jsadl,
ROUND( SUM( IFNULL(v.CSAD*v.CSL,0)/1000000 ), 2 ) AS csadl,
count( v.id ) AS scsj
FROM
${dataViewName2} v
......@@ -396,7 +412,11 @@
ROUND( SUM( v.GFCZL ), 2 ) AS ybagfczl,
ROUND( SUM( v.WNL )*(1-AVG( v.WNHSL ))) AS jgnl,
ROUND( SUM( v.WFCSL ), 2 ) AS wxfwcsl,
ROUND( SUM( v.WFCZL ), 2 ) AS wxfwczl
ROUND( SUM( v.WFCZL ), 2 ) AS wxfwczl,
IFNULL(v2.jscodl-v2.cscodl,0) AS codxjl,
IFNULL(v2.jsadl-v2.csadl,0) AS adxjl,
IFNULL(v2.jstpl-v2.cstpl,0) AS tpxjl,
IFNULL(v2.jstnl-v2.cstnl,0) AS tnxjl
FROM
${dataViewName3} v
LEFT JOIN (
......@@ -404,6 +424,14 @@
LEFT ( v.time, 7 ) AS time,
ROUND( SUM( v.CSL )/10000, 2 ) AS sjwscll,
ROUND( AVG( v.CSL )/10000, 2 ) AS rwscll,
ROUND( SUM( IFNULL(v.JSCOD*v.JSL,0)/1000000 ), 2 ) AS jscodl,
ROUND( SUM( IFNULL(v.CSCOD*v.CSL,0)/1000000 ), 2 ) AS cscodl,
ROUND( SUM( IFNULL(v.CSTN*v.CSL,0)/1000000 ), 2 ) AS cstnl,
ROUND( SUM( IFNULL(v.JSZD*v.JSL,0)/1000000 ), 2 ) AS jstnl,
ROUND( SUM( IFNULL(v.JSZL*v.JSL,0)/1000000 ), 2 ) AS jstpl,
ROUND( SUM( IFNULL(v.CSZL*v.CSL,0)/1000000 ), 2 ) AS cstpl,
ROUND( SUM( IFNULL(v.JSAD*v.JSL,0)/1000000 ), 2 ) AS jsadl,
ROUND( SUM( IFNULL(v.CSAD*v.CSL,0)/1000000 ), 2 ) AS csadl,
count( v.id ) AS scsj
FROM
${dataViewName2} v
......@@ -423,25 +451,34 @@
<select id="getHjList" resultType="com.skua.modules.report.vo.JnhbReportDetailsHj">
SELECT
RIGHT(LEFT( v.time, 7 ),2) AS time,
v2.sjwscll,
v2.rwscll,
v2.scsj,
ROUND(v2.scsj*f.pro_scale,2) AS wsclnl,
ROUND( SUM( v.DLHJ ) / 10000, 2 ) AS dl,
ROUND( SUM( v.GFFDL ), 2 ) AS gffdl,
ROUND( SUM( v.QY ), 2 ) AS qy,
ROUND( SUM( v.HXT ), 2 ) AS hxtsyl,
ROUND( SUM( v.SH ), 2 ) AS shsyl,
ROUND( SUM( v.PAMRJ ), 2 ) AS xnjpam,
ROUND( SUM( v.PACGT ), 2 ) AS xnjpac,
ROUND( SUM( v.SCLPAMF+v.SCLPAMZ+v.PAMF+v.PAMZ ), 2 ) AS xnjqt,
ROUND( SUM( v.YSL ), 2 ) AS xssyl,
ROUND( SUM( v.WNL ), 2 ) AS ybgfcsl,
ROUND( AVG( v.WNHSL ), 2 ) AS wnhsl,
ROUND( SUM( v.GFCZL ), 2 ) AS ybagfczl,
ROUND( SUM( v.WNL )*(1-AVG( v.WNHSL ))) AS jgnl,
ROUND( SUM( v.WFCSL ), 2 ) AS wxfwcsl,
ROUND( SUM( v.WFCZL ), 2 ) AS wxfwczl
IFNULL(v2.sjwscll,0) AS sjwscll,
IFNULL(v2.rwscll,0) AS rwscll,
IFNULL(v2.scsj,0) AS scsj,
IFNULL(ROUND(v2.scsj*f.pro_scale,2),0) AS wsclnl,
IFNULL(ROUND( SUM( v.DLHJ ) / 10000, 2 ),0) AS dl,
IFNULL(ROUND( SUM( v.GFFDL ), 2 ),0) AS gffdl,
IFNULL(ROUND( SUM( v.QY ), 2 ),0) AS qy,
IFNULL(ROUND( SUM( v.HXT ), 2 ),0) AS hxtsyl,
IFNULL(ROUND( SUM( v.SH ), 2 ),0) AS shsyl,
IFNULL(ROUND( SUM( v.PAMRJ ), 2 ),0) AS xnjpam,
IFNULL(ROUND( SUM( v.PACGT ), 2 ),0) AS xnjpac,
IFNULL(ROUND( SUM( v.SCLPAMF+v.SCLPAMZ+v.PAMF+v.PAMZ ), 2 ),0) AS xnjqt,
IFNULL(ROUND( SUM( v.YSL ), 2 ),0) AS xssyl,
IFNULL(ROUND( SUM( v.WNL ), 2 ),0) AS ybgfcsl,
IFNULL(ROUND( AVG( v.WNHSL ), 2 ),0) AS wnhsl,
IFNULL(ROUND( SUM( v.GFCZL ), 2 ),0) AS ybagfczl,
IFNULL(ROUND( SUM( v.WNL )*(1-AVG( v.WNHSL ))),0) AS jgnl,
IFNULL(ROUND( SUM( v.WFCSL ), 2 ),0) AS wxfwcsl,
IFNULL(ROUND( SUM( v.WFCZL ), 2 ),0) AS wxfwczl,
'0' wsclsjnl,
'0' xnjhj,
'0' zhnyxfl,
'0' eyhtpfl,
'0' ybgfczl,
IFNULL(v2.jscodl-v2.cscodl,0) AS codxjl,
IFNULL(v2.jsadl-v2.csadl,0) AS adxjl,
IFNULL(v2.jstpl-v2.cstpl,0) AS tpxjl,
IFNULL(v2.jstnl-v2.cstnl,0) AS tnxjl
FROM
${dataViewName3} v
LEFT JOIN (
......@@ -449,6 +486,14 @@
LEFT ( v.time, 7 ) AS time,
ROUND( SUM( v.CSL )/10000, 2 ) AS sjwscll,
ROUND( AVG( v.CSL )/10000, 2 ) AS rwscll,
ROUND( SUM( IFNULL(v.JSCOD*v.JSL,0)/1000000 ), 2 ) AS jscodl,
ROUND( SUM( IFNULL(v.CSCOD*v.CSL,0)/1000000 ), 2 ) AS cscodl,
ROUND( SUM( IFNULL(v.CSTN*v.CSL,0)/1000000 ), 2 ) AS cstnl,
ROUND( SUM( IFNULL(v.JSZD*v.JSL,0)/1000000 ), 2 ) AS jstnl,
ROUND( SUM( IFNULL(v.JSZL*v.JSL,0)/1000000 ), 2 ) AS jstpl,
ROUND( SUM( IFNULL(v.CSZL*v.CSL,0)/1000000 ), 2 ) AS cstpl,
ROUND( SUM( IFNULL(v.JSAD*v.JSL,0)/1000000 ), 2 ) AS jsadl,
ROUND( SUM( IFNULL(v.CSAD*v.CSL,0)/1000000 ), 2 ) AS csadl,
count( v.id ) AS scsj
FROM
${dataViewName2} v
......
......@@ -11,6 +11,8 @@ import com.skua.modules.custom.mapper.FCustomReportDatasetMapper;
import com.skua.modules.custom.service.IFCustomReportDatasetService;
import com.skua.modules.custom.vo.DepartWeekReportVO;
import com.skua.modules.custom.vo.FCustomReportDatasetVO;
import java.text.DecimalFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
......@@ -20,6 +22,7 @@ import com.skua.modules.report.vo.*;
import com.skua.modules.report.vo.largeScreen.*;
import com.skua.tool.util.DateUtils;
import com.skua.tool.util.JSUtils;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
......@@ -235,16 +238,46 @@ public class FCustomReportDatasetServiceImpl extends ServiceImpl<FCustomReportDa
@Override
public Map<String, Object> jnhbReportDetails(String departId, String month) {
DecimalFormat df = new DecimalFormat("#.##");
Map<String, Object> map = new HashMap<>();
List<JnhbReportDetailsDy> dyList = new ArrayList<>();
List<JnhbReportDetailsJs> jsList = new ArrayList<>();
List<JnhbReportDetailsHj> hjList = new ArrayList<>();
String year = month.substring(0,4);
String dataViewName2 = ReportViewUtil.buildViewLike(ReportConstant.view2119,"CSL,JSZL,CSZL,JSCOD,CSCOD,JSAD,CSAD,JSZD,CSTN", departId, year);
String dataViewName2 = ReportViewUtil.buildViewLike(ReportConstant.view2119,"CSL,JSL,JSZL,CSZL,JSCOD,CSCOD,JSAD,CSAD,JSZD,CSTN", departId, year);
String dataViewName3 = ReportViewUtil.buildViewLike(ReportConstant.view3a24,"", departId, year);
dyList = mapper.getDyList(dataViewName2, dataViewName3, departId, year);
jsList = mapper.getJsList(dataViewName2, dataViewName3, departId, year);
hjList = mapper.getHjList(dataViewName2, dataViewName3, departId, year);
for (int i = 0; i < hjList.size(); i++) {
if(i > 0){
JnhbReportDetailsHj jnhbHj1 = hjList.get(i);
JnhbReportDetailsHj jnhbHj0 = hjList.get(i-1);
jnhbHj1.setWsclsjnl(df.format(Double.parseDouble(jnhbHj0.getWsclsjnl())+Double.parseDouble(jnhbHj1.getWsclsjnl())));
jnhbHj1.setScsj(df.format(Double.parseDouble(jnhbHj0.getScsj())+Double.parseDouble(jnhbHj1.getScsj())));
jnhbHj1.setDl(df.format(Double.parseDouble(jnhbHj0.getDl())+Double.parseDouble(jnhbHj1.getDl())));
jnhbHj1.setGffdl(df.format(Double.parseDouble(jnhbHj0.getGffdl())+Double.parseDouble(jnhbHj1.getGffdl())));
jnhbHj1.setQy(df.format(Double.parseDouble(jnhbHj0.getQy())+Double.parseDouble(jnhbHj1.getQy())));
jnhbHj1.setHxtsyl(df.format(Double.parseDouble(jnhbHj0.getHxtsyl())+Double.parseDouble(jnhbHj1.getHxtsyl())));
jnhbHj1.setShsyl(df.format(Double.parseDouble(jnhbHj0.getShsyl())+Double.parseDouble(jnhbHj1.getShsyl())));
jnhbHj1.setXnjpam(df.format(Double.parseDouble(jnhbHj0.getXnjpam())+Double.parseDouble(jnhbHj1.getXnjpam())));
jnhbHj1.setXnjpac(df.format(Double.parseDouble(jnhbHj0.getXnjpac())+Double.parseDouble(jnhbHj1.getXnjpac())));
jnhbHj1.setXnjqt(df.format(Double.parseDouble(jnhbHj0.getXnjqt())+Double.parseDouble(jnhbHj1.getXnjqt())));
jnhbHj1.setXnjhj(df.format(Double.parseDouble(jnhbHj0.getXnjhj())+Double.parseDouble(jnhbHj1.getXnjhj())));
jnhbHj1.setXssyl(df.format(Double.parseDouble(jnhbHj0.getXssyl())+Double.parseDouble(jnhbHj1.getXssyl())));
jnhbHj1.setJgnl(df.format(Double.parseDouble(jnhbHj0.getJgnl())+Double.parseDouble(jnhbHj1.getJgnl())));
jnhbHj1.setWxfwcsl(df.format(Double.parseDouble(jnhbHj0.getWxfwcsl())+Double.parseDouble(jnhbHj1.getWxfwcsl())));
jnhbHj1.setWxfwczl(df.format(Double.parseDouble(jnhbHj0.getWxfwczl())+Double.parseDouble(jnhbHj1.getWxfwczl())));
jnhbHj1.setZhnyxfl(df.format(Double.parseDouble(jnhbHj0.getZhnyxfl())+Double.parseDouble(jnhbHj1.getZhnyxfl())));
jnhbHj1.setEyhtpfl(df.format(Double.parseDouble(jnhbHj0.getEyhtpfl())+Double.parseDouble(jnhbHj1.getEyhtpfl())));
jnhbHj1.setYbgfcsl(df.format(Double.parseDouble(jnhbHj0.getYbgfcsl())+Double.parseDouble(jnhbHj1.getYbgfcsl())));
jnhbHj1.setYbgfczl(df.format(Double.parseDouble(jnhbHj0.getYbgfczl())+Double.parseDouble(jnhbHj1.getYbgfczl())));
jnhbHj1.setCodxjl(df.format(Double.parseDouble(jnhbHj0.getCodxjl())+Double.parseDouble(jnhbHj1.getCodxjl())));
jnhbHj1.setAdxjl(df.format(Double.parseDouble(jnhbHj0.getAdxjl())+Double.parseDouble(jnhbHj1.getAdxjl())));
jnhbHj1.setTpxjl(df.format(Double.parseDouble(jnhbHj0.getTpxjl())+Double.parseDouble(jnhbHj1.getTpxjl())));
jnhbHj1.setTnxjl(df.format(Double.parseDouble(jnhbHj0.getTnxjl())+Double.parseDouble(jnhbHj1.getTnxjl())));
}
}
map.put("zbtj",dyList);
map.put("zbfx",jsList);
map.put("zblj",hjList);
......
......@@ -56,7 +56,7 @@ public class ShiroConfig {
filterChainDefinitionMap.put("/sys/user/register", "anon");//用户注册
filterChainDefinitionMap.put("/sys/user/querySysUser", "anon");//根据手机号获取用户信息
filterChainDefinitionMap.put("/sys/user/phoneVerification", "anon");//用户忘记密码验证手机号
filterChainDefinitionMap.put("/sys/user/passwordChange", "anon");//用户更改密码
// filterChainDefinitionMap.put("/sys/user/passwordChange", "anon");//用户更改密码
filterChainDefinitionMap.put("/auth/2step-code", "anon");//登录验证码
filterChainDefinitionMap.put("/sys/common/view/**", "anon");//图片预览不限制token
filterChainDefinitionMap.put("/sys/common/download/**", "anon");//文件下载不限制token
......@@ -87,6 +87,7 @@ public class ShiroConfig {
filterChainDefinitionMap.put("/swagger**/**", "anon");
filterChainDefinitionMap.put("/webjars/**", "anon");
filterChainDefinitionMap.put("/v2/**", "anon");
filterChainDefinitionMap.put("/sys/init/**", "anon");
//暂时放开表维护的shiro权限
filterChainDefinitionMap.put("/v1/expert/expertInitConfig/**", "anon");
......
......@@ -38,7 +38,6 @@ import com.skua.core.util.ConvertUtils;
import com.skua.core.util.DateUtils;
import com.skua.core.util.JwtUtil;
import com.skua.core.util.PasswordUtil;
import com.skua.core.util.chuanglan.HttpSenderMsg;
import com.skua.core.util.encryption.AesEncryptUtil;
import com.skua.core.util.encryption.EncryptedString;
import com.skua.modules.shiro.vo.DefContants;
......@@ -494,7 +493,6 @@ public class LoginController {
return result;
}
aliCode.setType("register");
// b = HttpSenderMsg.sendMsg("注册验证码为:" + captcha, mobile);
} else {
//登录模式,校验用户有效性
SysUser sysUser = sysUserService.getUserByPhone(mobile);
......@@ -509,11 +507,9 @@ public class LoginController {
if (CommonConstant.SMS_TPL_TYPE_0.equals(smsmode)) {
//登录模板
aliCode.setType("login");
// b = HttpSenderMsg.sendMsg("登录验证码为:" + captcha, mobile);
} else if (CommonConstant.SMS_TPL_TYPE_2.equals(smsmode)) {
aliCode.setType("update");
//忘记密码模板
// b = HttpSenderMsg.sendMsg("验证码为:" + captcha, mobile);
aliCode.setType("update");
}
}
b = AliSmsUtil.sendCodeMsg(aliCode);
......
package com.skua.modules.system.controller;
import com.skua.core.api.vo.Result;
import com.skua.modules.system.service.ITestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@Api(tags = "初始化用户")
@Slf4j
@RestController
@RequestMapping("/sys/init")
public class TestController {
@Resource
private ITestService testService;
@GetMapping("/user")
@ApiOperation(value = "初始化用户")
public Result<?> batchInitUser(){
Result<?> result = new Result<>();
boolean ok = testService.batchInitUser();
result.setSuccess(ok);
return result;
}
}
package com.skua.modules.system.service;
public interface ITestService{
boolean batchInitUser();
}
package com.skua.modules.system.service.impl;
import com.skua.core.context.SpringContextUtils;
import com.skua.core.util.ConvertUtils;
import com.skua.core.util.DateUtils;
import com.skua.core.util.PasswordUtil;
import com.skua.modules.system.service.ITestService;
import com.skua.tool.util.ChineseToPinyin;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@Service
@Slf4j
public class TestServiceImpl implements ITestService {
@Override
public boolean batchInitUser() {
JdbcTemplate jdbcTemplate = (JdbcTemplate) SpringContextUtils.getBean("master");
String sql = "select * from sys_user_init ";
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
if(list.size() > 0){
for (Map<String,Object> map : list) {
String departId = map.get("depart_id").toString();
String realName = map.get("user_name").toString();
String userName = ChineseToPinyin.toPinyin(realName);
String phone = map.get("user_phone").toString();
String role = map.get("roles").toString();
String roles = "";
if(map.get("remark")!=null){
roles = map.get("remark").toString();
role = role +","+ roles;
}
role = "8cc3cf58677fc68e42e9e46ae2462a17," + role;
String userId = UUID.randomUUID().toString().replaceAll("-", "");
String salt = ConvertUtils.randomGen(8);
String password = PasswordUtil.encrypt(userName, "zhongye123.", salt);
String insertUserSql = "INSERT INTO sys_user_bak " +
"(id, username, realname, password, salt, phone, status, " +
"del_flag, activiti_sync, create_by, create_time, is_system_user,user_type) " +
"VALUES " +
"('"+userId+"', '"+userName+"', '"+realName+"', '"+password+"', '"+salt+"', '"+phone+"', 1, " +
"1, 1, 'admin', '"+ DateUtils.getDate("yyyy-MM-dd HH:mm:ss")+"', '0', '2')";
jdbcTemplate.execute(insertUserSql);
List<String> roleIdArray = Arrays.asList(role.split(","));
for (String roleId : roleIdArray) {
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
String insertRoleSql = "INSERT INTO sys_user_role " +
"(id, user_id, role_id) " +
"VALUES " +
"('"+uuid+"', '"+userId+"', '"+roleId+"')";
jdbcTemplate.execute(insertRoleSql);
}
String departUuid = UUID.randomUUID().toString().replaceAll("-", "");
String insertDepartSql = "INSERT INTO sys_user_depart " +
"(id, user_id, dep_id, dep_ids) " +
"VALUES " +
"('"+departUuid+"', '"+userId+"', '"+departId+"', '"+departId+"')";
jdbcTemplate.execute(insertDepartSql);
}
}
return false;
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!