Merge branch 'dev-cq-bug' of http://192.168.0.56:3000/bonus/cqdevicemgt into dev-cq-bug
This commit is contained in:
commit
b46f3e54b1
|
|
@ -161,74 +161,47 @@ public class ExcelServiceImpl implements ExcelService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void printLevel3Relation(Map<String, Map<String, List<MapType>>> level3Relation) {
|
private void printLevel3Relation(Map<String, Map<String, List<MapType>>> level3Relation) {
|
||||||
for (Map.Entry<String, Map<String, List<MapType>>> firstLevel : level3Relation.entrySet()) {
|
for (Map.Entry<String, Map<String, List<MapType>>> firstLevel : level3Relation.entrySet()) {
|
||||||
boolean outExist = true;
|
|
||||||
System.out.println("level_1: " + firstLevel.getKey());
|
System.out.println("level_1: " + firstLevel.getKey());
|
||||||
//TODO, sql查询:是否有此名字 + parentId=0, select * from ma_part_type where name=? and parent_id=0;
|
|
||||||
MaPartType maPartType_level1 = excelMapper.selectMa(firstLevel.getKey(),0);
|
MaPartType maPartType_level1 = excelMapper.selectMa(firstLevel.getKey(),0);
|
||||||
//TODO, 以上返回 maPartType_level1
|
|
||||||
if (Objects.nonNull(maPartType_level1)) {
|
if (Objects.nonNull(maPartType_level1)) {
|
||||||
loopInner(firstLevel, outExist,maPartType_level1.getPaId());
|
loopInner(firstLevel, maPartType_level1.getPaId());
|
||||||
} else {
|
} else {
|
||||||
//TODO, insert firstLevel, get id
|
|
||||||
MaPartType maPartType = new MaPartType();
|
MaPartType maPartType = new MaPartType();
|
||||||
maPartType.setPaName(firstLevel.getKey());
|
maPartType.setPaName(firstLevel.getKey());
|
||||||
maPartType.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString());
|
maPartType.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString());
|
||||||
maPartType.setParentId(0L);
|
maPartType.setParentId(0L);
|
||||||
maPartType.setLevel("1");
|
maPartType.setLevel("1");
|
||||||
excelMapper.insertPaName(maPartType);//如果第一层在数据库中查询不到则插入数据,并且读取到parent_id
|
excelMapper.insertPaName(maPartType);//如果第一层在数据库中查询不到则插入数据,并且读取到parent_id
|
||||||
outExist = outExist && false;
|
loopInner(firstLevel, maPartType.getPaId());
|
||||||
loopInner(firstLevel, outExist, maPartType.getPaId());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loopInner(Map.Entry<String, Map<String, List<MapType>>> firstLevel, boolean outExist, long firstLevelId) {
|
private void loopInner(Map.Entry<String, Map<String, List<MapType>>> firstLevel, long firstLevelId) {
|
||||||
for (Map.Entry<String, List<MapType>> secondLevel : firstLevel.getValue().entrySet()) {
|
for (Map.Entry<String, List<MapType>> secondLevel : firstLevel.getValue().entrySet()) {
|
||||||
System.out.println("\tlevel_2: " + secondLevel.getKey());
|
System.out.println("\tlevel_2: " + secondLevel.getKey());
|
||||||
//TODO, sql查询:是否有此名字 + parentId=firstLevelId, select * from ma_part_type where name=? and parent_id = firstLevelId;
|
|
||||||
MaPartType maPartType_level2 = excelMapper.selectMa(secondLevel.getKey(),firstLevelId);
|
MaPartType maPartType_level2 = excelMapper.selectMa(secondLevel.getKey(),firstLevelId);
|
||||||
//TODO, 以上返回 maPartType_level2
|
|
||||||
if (Objects.nonNull(maPartType_level2)) {
|
if (Objects.nonNull(maPartType_level2)) {
|
||||||
looplevel3(secondLevel, outExist, maPartType_level2.getPaId());
|
looplevel3(secondLevel, maPartType_level2.getPaId());
|
||||||
} else {
|
} else {
|
||||||
//TODO, insert firstLevel, get id
|
|
||||||
if (!outExist) {
|
|
||||||
MaPartType maPartType = new MaPartType();
|
MaPartType maPartType = new MaPartType();
|
||||||
maPartType.setPaName(secondLevel.getKey());
|
maPartType.setPaName(secondLevel.getKey());
|
||||||
maPartType.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString());
|
maPartType.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString());
|
||||||
maPartType.setParentId(firstLevelId);
|
maPartType.setParentId(firstLevelId);
|
||||||
maPartType.setLevel("2");
|
maPartType.setLevel("2");
|
||||||
excelMapper.insertPaName(maPartType);//如果第一层在数据库中查询不到则插入数据,并且读取到parent_id
|
excelMapper.insertPaName(maPartType);//如果第一层在数据库中查询不到则插入数据,并且读取到parent_id
|
||||||
outExist = outExist && false;
|
looplevel3(secondLevel, maPartType.getPaId());
|
||||||
looplevel3(secondLevel, outExist, maPartType.getPaId());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void looplevel3(Map.Entry<String, List<MapType>> secondLevel, boolean outExist, long secondLevelId) {
|
private void looplevel3(Map.Entry<String, List<MapType>> secondLevel, long secondLevelId) {
|
||||||
for (MapType thirdLevel : secondLevel.getValue()) {
|
for (MapType thirdLevel : secondLevel.getValue()) {
|
||||||
System.out.println("\t\tlevel_3: " + thirdLevel);
|
System.out.println("\t\tlevel_3: " + thirdLevel);
|
||||||
//TODO, sql查询:是否有此名字 + parentId=secondLevelId, select * from ma_part_type where name=? and parent_id = secondLevelId;
|
|
||||||
MaPartType maPartType_level3 = excelMapper.selectMa(thirdLevel.getPaName(),secondLevelId);
|
MaPartType maPartType_level3 = excelMapper.selectMa(thirdLevel.getPaName(),secondLevelId);
|
||||||
//TODO, 以上返回 maPartType_level3
|
if (Objects.isNull(maPartType_level3)) {
|
||||||
if (Objects.nonNull(maPartType_level3)) {
|
|
||||||
if (!outExist) {
|
|
||||||
//TODO insert
|
|
||||||
MaPartType maPartType = new MaPartType();
|
|
||||||
maPartType.setPaName(thirdLevel.getPaName());
|
|
||||||
maPartType.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString());
|
|
||||||
maPartType.setUnitId(thirdLevel.getUnitId());
|
|
||||||
maPartType.setBuyPrice(thirdLevel.getBuyPrice());
|
|
||||||
maPartType.setParentId(secondLevelId);
|
|
||||||
maPartType.setLevel("3");
|
|
||||||
excelMapper.insertPaName(maPartType);//如果第一层在数据库中查询不到则插入数据,并且读取到parent_id
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//TODO insert
|
|
||||||
MaPartType maPartType = new MaPartType();
|
MaPartType maPartType = new MaPartType();
|
||||||
maPartType.setPaName(thirdLevel.getPaName());
|
maPartType.setPaName(thirdLevel.getPaName());
|
||||||
maPartType.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString());
|
maPartType.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString());
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,9 @@ import com.bonus.sgzb.common.core.exception.ServiceException;
|
||||||
import com.bonus.sgzb.common.core.utils.GlobalConstants;
|
import com.bonus.sgzb.common.core.utils.GlobalConstants;
|
||||||
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.sgzb.common.redis.service.RedisService;
|
import com.bonus.sgzb.common.redis.service.RedisService;
|
||||||
|
import com.bonus.sgzb.system.api.domain.SysUser;
|
||||||
import com.bonus.sgzb.system.config.TencentSmsConfig;
|
import com.bonus.sgzb.system.config.TencentSmsConfig;
|
||||||
|
import com.bonus.sgzb.system.mapper.SysUserMapper;
|
||||||
import com.bonus.sgzb.system.service.ISysSmsService;
|
import com.bonus.sgzb.system.service.ISysSmsService;
|
||||||
import com.tencentcloudapi.common.Credential;
|
import com.tencentcloudapi.common.Credential;
|
||||||
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
||||||
|
|
@ -43,6 +45,8 @@ public class SysSmsServiceImpl implements ISysSmsService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
@Resource
|
||||||
|
private SysUserMapper sysUserMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private TencentSmsConfig tencentSmsConfig;
|
private TencentSmsConfig tencentSmsConfig;
|
||||||
|
|
@ -55,6 +59,7 @@ public class SysSmsServiceImpl implements ISysSmsService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验收通知短信
|
* 验收通知短信
|
||||||
|
*
|
||||||
* @param phone 手机号
|
* @param phone 手机号
|
||||||
* @param msg 内容
|
* @param msg 内容
|
||||||
* @return
|
* @return
|
||||||
|
|
@ -79,6 +84,7 @@ public class SysSmsServiceImpl implements ISysSmsService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录短信验证码
|
* 登录短信验证码
|
||||||
|
*
|
||||||
* @param phone 手机号
|
* @param phone 手机号
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -102,6 +108,7 @@ public class SysSmsServiceImpl implements ISysSmsService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送消息msg到手机
|
* 发送消息msg到手机
|
||||||
|
*
|
||||||
* @param phone 手机号码
|
* @param phone 手机号码
|
||||||
* @return AjaxResult对象
|
* @return AjaxResult对象
|
||||||
*/
|
*/
|
||||||
|
|
@ -128,6 +135,7 @@ public class SysSmsServiceImpl implements ISysSmsService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送验证码到手机
|
* 发送验证码到手机
|
||||||
|
*
|
||||||
* @param phone 手机号码
|
* @param phone 手机号码
|
||||||
* @return AjaxResult对象
|
* @return AjaxResult对象
|
||||||
*/
|
*/
|
||||||
|
|
@ -136,6 +144,11 @@ public class SysSmsServiceImpl implements ISysSmsService {
|
||||||
if (phone == null || phone.length() != UserConstants.PHONE_DEFAULT_LENGTH_LOGIN) {
|
if (phone == null || phone.length() != UserConstants.PHONE_DEFAULT_LENGTH_LOGIN) {
|
||||||
return AjaxResult.error("手机号格式错误,请输入11位数字号码");
|
return AjaxResult.error("手机号格式错误,请输入11位数字号码");
|
||||||
}
|
}
|
||||||
|
// 校验是否存在该手机号
|
||||||
|
SysUser sysUser = sysUserMapper.checkPhoneUnique(phone);
|
||||||
|
if (sysUser == null) {
|
||||||
|
return AjaxResult.error("该手机号未绑定用户,请重新确认");
|
||||||
|
}
|
||||||
String code = getSixBitCode();
|
String code = getSixBitCode();
|
||||||
// 校验验证码
|
// 校验验证码
|
||||||
if (code.length() != UserConstants.CODE_MIN_LENGTH_LOGIN) {
|
if (code.length() != UserConstants.CODE_MIN_LENGTH_LOGIN) {
|
||||||
|
|
@ -151,7 +164,8 @@ public class SysSmsServiceImpl implements ISysSmsService {
|
||||||
}
|
}
|
||||||
// 存储验证码至Redis中,键值为:code_15588886157 , 有效期5,时间颗粒度为MINUTES:分钟
|
// 存储验证码至Redis中,键值为:code_15588886157 , 有效期5,时间颗粒度为MINUTES:分钟
|
||||||
redisService.setCacheObject("code_" + phone, code, 5L, TimeUnit.MINUTES);
|
redisService.setCacheObject("code_" + phone, code, 5L, TimeUnit.MINUTES);
|
||||||
return success("手机号:" + phone + ",用户登录验证码:" + code + ",返回结果:" + body);
|
// return success("手机号:" + phone + ",用户登录验证码:" + code + ",返回结果:" + body);
|
||||||
|
return success("验证码发送成功:" + body);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return AjaxResult.error("发送失败:" + e.getMessage());
|
return AjaxResult.error("发送失败:" + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
@ -195,6 +209,7 @@ public class SysSmsServiceImpl implements ISysSmsService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 腾讯sms短信
|
* 腾讯sms短信
|
||||||
|
*
|
||||||
* @param mobilePhone
|
* @param mobilePhone
|
||||||
* @param templateId
|
* @param templateId
|
||||||
* @param args
|
* @param args
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue