Merge branch 'master' of http://local.gunshiiot.com:10000/xjm/fxkh-txl-service
Conflicts: src/main/resources/application.ymlmaster
commit
4ce1539457
25
sql/data.sql
25
sql/data.sql
|
|
@ -2,16 +2,19 @@
|
||||||
DELETE FROM FXKH_TXL.ORGANIZATION;
|
DELETE FROM FXKH_TXL.ORGANIZATION;
|
||||||
SET IDENTITY_INSERT FXKH_TXL.ORGANIZATION ON;
|
SET IDENTITY_INSERT FXKH_TXL.ORGANIZATION ON;
|
||||||
insert into "FXKH_TXL"."ORGANIZATION"("ID", "NAME") VALUES
|
insert into "FXKH_TXL"."ORGANIZATION"("ID", "NAME") VALUES
|
||||||
('1','湖北省防汛抗旱指挥部成员' ),
|
('1','国家防汛抗旱总指挥部办公室' ),
|
||||||
('2','国家防汛抗旱总指挥部办公室(应急部防汛抗旱司)' ),
|
('2','长江防汛抗旱总指挥部办公室' ),
|
||||||
('3','长江委水旱灾害防御局' ),
|
('3','省防办' ),
|
||||||
('4','湖北省省直机关有关单位和部队联系处(室)' ),
|
('4','省防指成员单位' ),
|
||||||
('5','湖北省应急管理厅机关' ),
|
('5','市、州、县防指(防办)' ),
|
||||||
('6','湖北省水利厅' ),
|
('6','湖北省大型水库安全管理责任人' ),
|
||||||
('7','市、州、县防指(防办)' ),
|
('7','湖北省3级及以上河道堤防防汛行政责任人名单' ),
|
||||||
('8','有关单位' ),
|
('8','湖北省蓄滞洪区防汛行政责任人名单' ),
|
||||||
('9','省应急管理厅机关常用电话' );
|
('9','湖北省湖堤堤防防汛行政责任人名单' ),
|
||||||
|
('10','湖北省重点排涝泵站责任人名单' ),
|
||||||
|
('11','湖北省大中型涵闸防汛责任人名单' );
|
||||||
SET IDENTITY_INSERT FXKH_TXL.ORGANIZATION Off;
|
SET IDENTITY_INSERT FXKH_TXL.ORGANIZATION Off;
|
||||||
|
COMMIT;
|
||||||
|
|
||||||
insert into "FXKH_TXL"."USERS"("USERNAME", "PASSWORD", "SALT", "ROLE", "AB_ID")
|
insert into "FXKH_TXL"."USERS"("USERNAME", "PASSWORD", "SALT", "ROLE", "AB_ID")
|
||||||
VALUES ('superadmin','0d36b3ff219df5a7f7d2d3961588f50c','3517548df1ac46198dbfec4f1176ec93','99',0)
|
VALUES ('superadmin','0d36b3ff219df5a7f7d2d3961588f50c','3517548df1ac46198dbfec4f1176ec93','99',0)
|
||||||
|
|
@ -28,6 +31,10 @@ insert into "FXKH_TXL"."ADDRESS_BOOK"("NAME", "PHONE", "ORGANIZATION", "POSITION
|
||||||
|
|
||||||
comment on column "FXKH_TXL"."AB_INFO"."ADCD" is '行政区划';
|
comment on column "FXKH_TXL"."AB_INFO"."ADCD" is '行政区划';
|
||||||
|
|
||||||
|
alter table "FXKH_TXL"."ADDRESS_BOOK" add column("OPENID" VARCHAR(50));
|
||||||
|
|
||||||
|
comment on column "FXKH_TXL"."ADDRESS_BOOK"."OPENID" is 'openid';
|
||||||
|
|
||||||
alter table "FXKH_TXL"."ADDRESS_BOOK" add column("IS_PASS" TINYINT default (FALSE));
|
alter table "FXKH_TXL"."ADDRESS_BOOK" add column("IS_PASS" TINYINT default (FALSE));
|
||||||
|
|
||||||
comment on column "FXKH_TXL"."ADDRESS_BOOK"."IS_PASS" is '是否放行, 放行:true,拦截:false';
|
comment on column "FXKH_TXL"."ADDRESS_BOOK"."IS_PASS" is '是否放行, 放行:true,拦截:false';
|
||||||
|
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
||||||
package com.whdc.config;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.springframework.data.redis.cache.RedisCache;
|
|
||||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
|
||||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
|
||||||
import org.springframework.data.redis.cache.RedisCacheWriter;
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
import java.time.Duration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Description:
|
|
||||||
* Created by XuSan on 2024/6/3.
|
|
||||||
*
|
|
||||||
* @author XuSan
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
|
||||||
public class CustomRedisCacheManager extends RedisCacheManager {
|
|
||||||
|
|
||||||
|
|
||||||
public CustomRedisCacheManager(RedisCacheWriter cacheWriter, RedisCacheConfiguration defaultCacheConfiguration) {
|
|
||||||
super(cacheWriter, defaultCacheConfiguration);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 针对@Cacheable设置缓存过期时间
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* @param cacheConfig
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
protected RedisCache createRedisCache(String name, RedisCacheConfiguration cacheConfig) {
|
|
||||||
String[] array = StringUtils.delimitedListToStringArray(name, "#");
|
|
||||||
name = array[0];
|
|
||||||
// 解析TTL
|
|
||||||
if (array.length > 1) {
|
|
||||||
long ttl = Long.parseLong(array[1]);
|
|
||||||
cacheConfig = cacheConfig.entryTtl(Duration.ofSeconds(ttl)); // 注意单位我此处用的是秒,而非毫秒
|
|
||||||
}
|
|
||||||
return super.createRedisCache(name, cacheConfig);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.whdc.controller;
|
||||||
|
|
||||||
|
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.whdc.exception.MyException;
|
import com.whdc.exception.MyException;
|
||||||
import com.whdc.model.dto.AddressBootDto;
|
import com.whdc.model.dto.AddressBootDto;
|
||||||
|
|
@ -30,17 +31,19 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.DigestUtils;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Map;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.whdc.model.MyConstant.REDIS_KEY;
|
import static com.whdc.model.MyConstant.REDIS_KEY;
|
||||||
|
import static com.whdc.service.impl.AdinfoServiceImpl.TREE_ALL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xusan
|
* @author xusan
|
||||||
|
|
@ -403,7 +406,6 @@ public class AddressBookController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "设置白名单")
|
@ApiOperation(value = "设置白名单")
|
||||||
@PostMapping(value = "setWhitelists")
|
@PostMapping(value = "setWhitelists")
|
||||||
public ResultJson setWhitelists(@RequestBody @Validated(Update.class) AddressBook model) {
|
public ResultJson setWhitelists(@RequestBody @Validated(Update.class) AddressBook model) {
|
||||||
|
|
@ -472,8 +474,6 @@ public class AddressBookController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// List<Versions> list = versionsService.lambdaQuery()
|
// List<Versions> list = versionsService.lambdaQuery()
|
||||||
// .eq(Versions::getAbId, model.getId())
|
// .eq(Versions::getAbId, model.getId())
|
||||||
// .list();
|
// .list();
|
||||||
|
|
@ -544,13 +544,15 @@ public class AddressBookController {
|
||||||
adnm = "";
|
adnm = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
List<AdcdTree> tree = adinfoService.tree(null, null);
|
List<AdcdTree> tree = adinfoService.tree(TREE_ALL, TREE_ALL);
|
||||||
|
|
||||||
if (CollectionUtils.isEmpty(tree)) {
|
if (CollectionUtils.isEmpty(tree)) {
|
||||||
throw new MyException("当前行政区划不存在");
|
throw new MyException("当前行政区划不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<AddressBook> addressBooks = service.lambdaQuery().isNotNull(AddressBook::getAdcd)
|
// List<AddressBook> addressBooks = service.lambdaQuery().isNotNull(AddressBook::getAdcd)
|
||||||
|
// .list();
|
||||||
|
List<AddressBook> addressBooks = service.lambdaQuery().likeLeft(AddressBook::getAdcd, "000000000")
|
||||||
.list();
|
.list();
|
||||||
|
|
||||||
if (CollectionUtils.isEmpty(addressBooks)) {
|
if (CollectionUtils.isEmpty(addressBooks)) {
|
||||||
|
|
@ -565,21 +567,21 @@ public class AddressBookController {
|
||||||
String finalAdnm = adnm;
|
String finalAdnm = adnm;
|
||||||
for (int i = 0; i < tree.size(); i++) {
|
for (int i = 0; i < tree.size(); i++) {
|
||||||
AdcdTree t = tree.get(i);
|
AdcdTree t = tree.get(i);
|
||||||
String adcd = t.getAdcd();
|
// String adcd = t.getAdcd();
|
||||||
String cityAdnm = t.getAdnm();
|
String cityAdnm = t.getAdnm();
|
||||||
List<AddressBook> books = abMap.get(adcd);
|
// List<AddressBook> books = abMap.get(adcd);
|
||||||
if (CollectionUtils.isEmpty(books)) {
|
// if (CollectionUtils.isEmpty(books)) {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
books.forEach(b -> {
|
// books.forEach(b -> {
|
||||||
if (StringUtils.isNotBlank(finalAdnm)) {
|
// if (StringUtils.isNotBlank(finalAdnm)) {
|
||||||
if (cityAdnm.equals(finalAdnm)) {
|
// if (cityAdnm.equals(finalAdnm)) {
|
||||||
data.add(new ExcelABVo(cityAdnm, cityAdnm, b.getName(), b.getPosition(), b.getPhone()));
|
// data.add(new ExcelABVo(cityAdnm, cityAdnm, b.getName(), b.getPosition(), b.getPhone()));
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
data.add(new ExcelABVo(cityAdnm, cityAdnm, b.getName(), b.getPosition(), b.getPhone()));
|
// data.add(new ExcelABVo(cityAdnm, cityAdnm, b.getName(), b.getPosition(), b.getPhone()));
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
List<AdcdTree> children = t.getChildren();
|
List<AdcdTree> children = t.getChildren();
|
||||||
if (CollectionUtils.isNotEmpty(children)) {
|
if (CollectionUtils.isNotEmpty(children)) {
|
||||||
|
|
@ -604,7 +606,6 @@ public class AddressBookController {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
;
|
|
||||||
|
|
||||||
if (CollectionUtils.isEmpty(data)) {
|
if (CollectionUtils.isEmpty(data)) {
|
||||||
throw new MyException("当前行政区划责任人为空");
|
throw new MyException("当前行政区划责任人为空");
|
||||||
|
|
@ -615,4 +616,129 @@ public class AddressBookController {
|
||||||
response);
|
response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "解析文件数据")
|
||||||
|
@PostMapping(value = "getExcelData")
|
||||||
|
public ResultJson<List<ExcelABVo>> getExcelData(MultipartFile file) {
|
||||||
|
|
||||||
|
List<ExcelABVo> appends = ExcelCommon.importExcel(file, 0, 1, ExcelABVo.class);
|
||||||
|
return ResultJson.ok(appends);
|
||||||
|
}
|
||||||
|
@ApiOperation(value = "行政区划联系人导入")
|
||||||
|
@PostMapping(value = "uploadExcel")
|
||||||
|
public ResultJson uploadExcel(MultipartFile file) {
|
||||||
|
|
||||||
|
List<ExcelABVo> appends = ExcelCommon.importExcel(file, 0, 1, ExcelABVo.class);
|
||||||
|
|
||||||
|
if (CollectionUtils.isEmpty(appends)) {
|
||||||
|
throw new MyException("文件为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<String> set = appends.stream().map(vo -> vo.getName() + "_" + vo.getPhone()).collect(Collectors.toSet());
|
||||||
|
if (set.size() != appends.size()){
|
||||||
|
throw new MyException("联系人重复");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<AdcdTree> tree = adinfoService.tree(TREE_ALL, TREE_ALL);
|
||||||
|
|
||||||
|
List<AddressBook> abs = Lists.newArrayList();
|
||||||
|
|
||||||
|
appends.forEach(vo -> {
|
||||||
|
String phone = vo.getPhone();
|
||||||
|
String name = vo.getName();
|
||||||
|
String position = vo.getPosition();
|
||||||
|
String city = vo.getCity();
|
||||||
|
String county = vo.getCounty();
|
||||||
|
AddressBook e = new AddressBook();
|
||||||
|
e.setName(name)
|
||||||
|
.setPhone(phone)
|
||||||
|
.setAdcd(getAdcd(tree, city, county))
|
||||||
|
.setPosition(position);
|
||||||
|
abs.add(e);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 原数据删除
|
||||||
|
removeAdcd();
|
||||||
|
|
||||||
|
|
||||||
|
if (!service.saveBatch(abs)) {
|
||||||
|
throw new MyException("表格数据新增失败");
|
||||||
|
}
|
||||||
|
List<User> users = Lists.newArrayList();
|
||||||
|
List<AbUdR> abUdRs = Lists.newArrayList();
|
||||||
|
|
||||||
|
AtomicReference<Integer> sort = new AtomicReference<>(0);
|
||||||
|
// 新增关联数据
|
||||||
|
abs.forEach(a -> {
|
||||||
|
String phone = a.getPhone();
|
||||||
|
if (StringUtils.isNotBlank(phone)){
|
||||||
|
User user = new User();
|
||||||
|
String salt = UUID.randomUUID().toString().replaceAll("-", "");
|
||||||
|
user
|
||||||
|
.setUsername(phone)
|
||||||
|
.setAbId(a.getId())
|
||||||
|
.setRole("1")
|
||||||
|
.setSalt(salt)
|
||||||
|
.setPassword(DigestUtils.md5DigestAsHex((salt + "Fxkh@123456").getBytes()));
|
||||||
|
users.add(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
AbUdR au = new AbUdR();
|
||||||
|
Integer i = sort.get() + 1;
|
||||||
|
au.setType("1")
|
||||||
|
.setAdId(a.getId())
|
||||||
|
.setDictId(a.getAdcd().replaceFirst("000000", ""))
|
||||||
|
.setSort(i);
|
||||||
|
abUdRs.add(au);
|
||||||
|
sort.set(i);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!userService.saveBatch(users)) {
|
||||||
|
throw new MyException("用户数据新增失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!abUdRService.saveBatch(abUdRs)) {
|
||||||
|
throw new MyException("关联数据新增失败");
|
||||||
|
}
|
||||||
|
return ResultJson.ok("数据新增成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getAdcd(List<AdcdTree> tree, String city, String county) {
|
||||||
|
for (AdcdTree a : tree) {
|
||||||
|
if (a.getAdnm().equals(city)) {
|
||||||
|
List<AdcdTree> children = a.getChildren();
|
||||||
|
if (a.getAdnm().equals(county)) {
|
||||||
|
county = "市本级";
|
||||||
|
}
|
||||||
|
for (AdcdTree b : children) {
|
||||||
|
if (b.getAdnm().equals(county)) {
|
||||||
|
return b.getAdcd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new MyException("当前市行政区划匹配失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void removeAdcd() {
|
||||||
|
List<AddressBook> addressBooks = service.lambdaQuery().likeLeft(AddressBook::getAdcd, "000000000")
|
||||||
|
.list();
|
||||||
|
boolean r1 = service.removeBatchByIds(addressBooks);
|
||||||
|
if (!r1) {
|
||||||
|
throw new MyException("通讯录数据删除失败");
|
||||||
|
}
|
||||||
|
List<Integer> abIds = addressBooks.stream().map(AddressBook::getId).collect(Collectors.toList());
|
||||||
|
LambdaQueryWrapper<AbUdR> aurQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
aurQueryWrapper.in(AbUdR::getAdId, abIds);
|
||||||
|
boolean remove1 = abUdRService.remove(aurQueryWrapper);
|
||||||
|
if (!remove1) {
|
||||||
|
throw new MyException("关联数据删除失败");
|
||||||
|
}
|
||||||
|
LambdaQueryWrapper<User> userQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
userQueryWrapper.in(User::getAbId, abIds);
|
||||||
|
boolean remove2 = userService.remove(userQueryWrapper);
|
||||||
|
if (!remove2) {
|
||||||
|
throw new MyException("用户账号删除失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static com.whdc.service.impl.AdinfoServiceImpl.TREE_ALL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xusan
|
* @author xusan
|
||||||
* @date 2024-05-11
|
* @date 2024-05-11
|
||||||
|
|
@ -60,7 +62,7 @@ public class AdinfoController {
|
||||||
String adcdOradnm) {
|
String adcdOradnm) {
|
||||||
|
|
||||||
|
|
||||||
List<AdcdTree> list = service.tree(null, null);
|
List<AdcdTree> list = service.tree(TREE_ALL, TREE_ALL);
|
||||||
// 查询全部标识
|
// 查询全部标识
|
||||||
if ("all".equals(adcdOradnm)) {
|
if ("all".equals(adcdOradnm)) {
|
||||||
return ResultJson.ok(list);
|
return ResultJson.ok(list);
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,26 @@ public class UserController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation(value = "wxOpenid登录", notes = "登录后,从 tokenInfo 中获取 token 相关信息。headers[tokenName] = tokenValue ")
|
||||||
|
@GetMapping("wxLogin/{openid}")
|
||||||
|
public ResultJson<LoginVo> getWxLogin(@PathVariable("openid") String openid) throws InvocationTargetException, IllegalAccessException {
|
||||||
|
LoginVo loginVo = service.wxLogin(openid);
|
||||||
|
|
||||||
|
if (loginVo == null || loginVo.getId() == null) {
|
||||||
|
return ResultJson.error("登录失败");
|
||||||
|
} else {
|
||||||
|
StpUtil.login(loginVo.getId()); // 使用 user id 登录
|
||||||
|
// 获取 Token 相关参数
|
||||||
|
loginVo.setTokenInfo(new AuthToken(StpUtil.getTokenInfo()));
|
||||||
|
|
||||||
|
// 更新最后登录时间
|
||||||
|
service.updateLastDate(loginVo.getId());
|
||||||
|
|
||||||
|
return ResultJson.ok(loginVo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "查询登录状态")
|
@ApiOperation(value = "查询登录状态")
|
||||||
@PostMapping("isLogin")
|
@PostMapping("isLogin")
|
||||||
public ResultJson<AuthToken> isLogin() {
|
public ResultJson<AuthToken> isLogin() {
|
||||||
|
|
@ -165,16 +185,16 @@ public class UserController {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ApiOperation(value = "修改密码")
|
@ApiOperation(value = "修改密码")
|
||||||
// @PostMapping(value = "updatePw")
|
@PostMapping(value = "updatePw")
|
||||||
public ResultJson updatePwd(@RequestBody UserDto dto) {
|
public ResultJson updatePwd(@RequestBody UserDto dto) {
|
||||||
|
|
||||||
return service.updatePwd(dto);
|
return service.updatePwd(dto);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ApiOperation(value = "忘记密码")
|
@ApiOperation(value = "忘记密码")
|
||||||
// @GetMapping(value = "forgotPassword/{username}")
|
@GetMapping(value = "forgotPassword/{username}")
|
||||||
public ResultJson updatePwd(@PathVariable("username") String username) {
|
public ResultJson updatePwd(@PathVariable("username") String username) {
|
||||||
User one = service.lambdaQuery().eq(User::getUsername, username)
|
User one = service.lambdaQuery().eq(User::getUsername, username)
|
||||||
.one();
|
.one();
|
||||||
|
|
@ -192,16 +212,16 @@ public class UserController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// @ApiOperation(value = "发送验证码")
|
@ApiOperation(value = "发送验证码")
|
||||||
// @GetMapping(value = "pushCode/{phone}")
|
@GetMapping(value = "pushCode/{phone}")
|
||||||
public ResultJson pushCode(@PathVariable("phone") String phone) {
|
public ResultJson pushCode(@PathVariable("phone") String phone) {
|
||||||
|
|
||||||
return ResultJson.ok(service.pushCode(phone));
|
return ResultJson.ok(service.pushCode(phone));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ApiOperation(value = "手机验证码登录")
|
@ApiOperation(value = "手机验证码登录")
|
||||||
// @GetMapping(value = "loginByCode/{phone}/{code}")
|
@GetMapping(value = "loginByCode/{phone}/{code}")
|
||||||
public ResultJson loginByCode(@PathVariable("phone") String phone,@PathVariable("code") String code) throws InvocationTargetException, IllegalAccessException {
|
public ResultJson loginByCode(@PathVariable("phone") String phone,@PathVariable("code") String code) throws InvocationTargetException, IllegalAccessException {
|
||||||
|
|
||||||
LoginVo loginVo = service.loginByCode(phone, code.toUpperCase());
|
LoginVo loginVo = service.loginByCode(phone, code.toUpperCase());
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.whdc.model.MyConstant.REDIS_KEY;
|
import static com.whdc.model.MyConstant.REDIS_KEY;
|
||||||
|
import static com.whdc.service.impl.AdinfoServiceImpl.TREE_ALL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description:
|
* Description:
|
||||||
|
|
@ -241,6 +242,13 @@ public class WarningController {
|
||||||
vo.setAdnm(publishUnit.replace("气象台", ""));
|
vo.setAdnm(publishUnit.replace("气象台", ""));
|
||||||
String adnm = publishUnit.replace("气象台", "");
|
String adnm = publishUnit.replace("气象台", "");
|
||||||
|
|
||||||
|
if ("恩施州".equals(adnm)){
|
||||||
|
adnm = "恩施土家族苗族自治州";
|
||||||
|
}
|
||||||
|
if ("武汉经济技术开发区".equals(adnm)){
|
||||||
|
adnm = "经济技术开发区(汉南区)";
|
||||||
|
}
|
||||||
|
|
||||||
String adcd = adinfoService.getAdcdByAdnm(adnm);
|
String adcd = adinfoService.getAdcdByAdnm(adnm);
|
||||||
if (StringUtils.isNotBlank(adcd)){
|
if (StringUtils.isNotBlank(adcd)){
|
||||||
vo.setAddressBooks(addressBookService.getListByAdnm(adcd));
|
vo.setAddressBooks(addressBookService.getListByAdnm(adcd));
|
||||||
|
|
@ -390,7 +398,7 @@ public class WarningController {
|
||||||
|
|
||||||
// 进行行政区划匹配
|
// 进行行政区划匹配
|
||||||
if (CollectionUtils.isNotEmpty(voList)) {
|
if (CollectionUtils.isNotEmpty(voList)) {
|
||||||
List<AdcdTree> tree = adinfoService.tree(null, null);
|
List<AdcdTree> tree = adinfoService.tree(TREE_ALL, TREE_ALL);
|
||||||
Map<String, List<WarningHistoryListVo>> areaMap = voList.stream()
|
Map<String, List<WarningHistoryListVo>> areaMap = voList.stream()
|
||||||
.collect(Collectors
|
.collect(Collectors
|
||||||
.groupingBy(WarningHistoryListVo::getEffectArea, Collectors.toList()));
|
.groupingBy(WarningHistoryListVo::getEffectArea, Collectors.toList()));
|
||||||
|
|
|
||||||
|
|
@ -22,4 +22,6 @@ public interface AddressBookMapper extends BaseMapper<AddressBook> {
|
||||||
List<AddressBook> getListByAdnm(@Param("adcd") String adcd);
|
List<AddressBook> getListByAdnm(@Param("adcd") String adcd);
|
||||||
AddressBookVo getVoById(@Param("id") Integer id);
|
AddressBookVo getVoById(@Param("id") Integer id);
|
||||||
|
|
||||||
|
AddressBookVo getVoByOpenid(@Param("id") String id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -106,4 +106,8 @@ public class AddressBook extends Model<AddressBook> implements Serializable {
|
||||||
@ApiModelProperty(value = "是否放行, 放行:true,拦截:false")
|
@ApiModelProperty(value = "是否放行, 放行:true,拦截:false")
|
||||||
private Boolean isPass;
|
private Boolean isPass;
|
||||||
|
|
||||||
|
@TableField("OPENID")
|
||||||
|
@ApiModelProperty(value = "openid")
|
||||||
|
private String openid;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -30,6 +30,9 @@ public class LoginVo implements Serializable {
|
||||||
@ApiModelProperty(value = "姓名")
|
@ApiModelProperty(value = "姓名")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "vx openid")
|
||||||
|
private String openid;
|
||||||
|
|
||||||
@ApiModelProperty(value = "token 信息")
|
@ApiModelProperty(value = "token 信息")
|
||||||
private AuthToken tokenInfo;
|
private AuthToken tokenInfo;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@ public interface IUserService extends IService<User> {
|
||||||
|
|
||||||
LoginVo wxLogin(VxLoginDto obj);
|
LoginVo wxLogin(VxLoginDto obj);
|
||||||
|
|
||||||
|
LoginVo wxLogin(String openid);
|
||||||
|
|
||||||
boolean register(User entity);
|
boolean register(User entity);
|
||||||
|
|
||||||
User getRole(Integer id);
|
User getRole(Integer id);
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ import static com.whdc.model.MyConstant.REDIS_KEY;
|
||||||
public class AdinfoServiceImpl extends ServiceImpl<AdinfoMapper, Adinfo> implements IAdinfoService {
|
public class AdinfoServiceImpl extends ServiceImpl<AdinfoMapper, Adinfo> implements IAdinfoService {
|
||||||
|
|
||||||
public static final String ADINFO_REDIS_KEY = REDIS_KEY + "adinfo";
|
public static final String ADINFO_REDIS_KEY = REDIS_KEY + "adinfo";
|
||||||
|
public static final String TREE_ALL = REDIS_KEY + "tree_all";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<Adinfo> page(Adinfo dto) {
|
public IPage<Adinfo> page(Adinfo dto) {
|
||||||
|
|
@ -57,9 +58,15 @@ public class AdinfoServiceImpl extends ServiceImpl<AdinfoMapper, Adinfo> impleme
|
||||||
* @param adcd
|
* @param adcd
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
// @Cacheable(cacheNames = {REDIS_KEY}, key = "getMethodName()", condition = "#adcd", unless = "false", cacheResolver = "redisExpireCacheResolver")
|
// @Cacheable(cacheNames = {ADINFO_REDIS_KEY}, key = "getMethodName()", condition = "#adcd + #adnm", unless = "false")
|
||||||
public List<AdcdTree> tree(String adcd, String adnm) {
|
public List<AdcdTree> tree(String adcd, String adnm) {
|
||||||
|
|
||||||
|
if (TREE_ALL.equals(adcd)){
|
||||||
|
adcd = null;
|
||||||
|
}
|
||||||
|
if (TREE_ALL.equals(adnm)){
|
||||||
|
adnm = null;
|
||||||
|
}
|
||||||
List<Adinfo> list = treeList(adcd, adnm);
|
List<Adinfo> list = treeList(adcd, adnm);
|
||||||
|
|
||||||
if (CollectionUtils.isNotEmpty(list)){
|
if (CollectionUtils.isNotEmpty(list)){
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.whdc.mapper.OrganizationMapper;
|
import com.whdc.mapper.OrganizationMapper;
|
||||||
import com.whdc.model.entity.Organization;
|
import com.whdc.model.entity.Organization;
|
||||||
import com.whdc.model.entity.UnitDict;
|
import com.whdc.model.entity.UnitDict;
|
||||||
import com.whdc.model.vo.AdcdTree;
|
|
||||||
import com.whdc.service.IAdinfoService;
|
import com.whdc.service.IAdinfoService;
|
||||||
import com.whdc.service.IOrganizationService;
|
import com.whdc.service.IOrganizationService;
|
||||||
import com.whdc.service.IUnitDictService;
|
import com.whdc.service.IUnitDictService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
@ -18,6 +18,8 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static com.whdc.service.impl.AdinfoServiceImpl.TREE_ALL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 服务实现类
|
* 服务实现类
|
||||||
|
|
@ -48,17 +50,21 @@ public class OrganizationServiceImpl extends ServiceImpl<OrganizationMapper, Org
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Organization> findByUserId(String userId,String adcd) {
|
public List<Organization> findByUserId(String userId,String adcd) {
|
||||||
|
if (StringUtils.isBlank(adcd)){
|
||||||
|
adcd = TREE_ALL;
|
||||||
|
}
|
||||||
List<Organization> organizations = baseMapper.findByUserId(userId);
|
List<Organization> organizations = baseMapper.findByUserId(userId);
|
||||||
|
|
||||||
List<UnitDict> list = unitDictService.findByUserId(userId);
|
List<UnitDict> list = unitDictService.findByUserId(userId);
|
||||||
|
|
||||||
Map<Integer, List<UnitDict>> collect = list.stream().collect(Collectors.groupingBy(UnitDict::getOId));
|
Map<Integer, List<UnitDict>> collect = list.stream().collect(Collectors.groupingBy(UnitDict::getOId));
|
||||||
|
String finalAdcd = adcd;
|
||||||
organizations.forEach(organization -> {
|
organizations.forEach(organization -> {
|
||||||
List<UnitDict> unitDicts = collect.get(organization.getId());
|
List<UnitDict> unitDicts = collect.get(organization.getId());
|
||||||
organization.setUnitDicts(unitDicts);
|
organization.setUnitDicts(unitDicts);
|
||||||
String name = organization.getName();
|
String name = organization.getName();
|
||||||
if (name.contains("市") && name.contains("县")){
|
if (name.contains("市") && name.contains("县")){
|
||||||
organization.setAdinfoList(adinfoService.tree(adcd, adcd));
|
organization.setAdinfoList(adinfoService.tree(finalAdcd, finalAdcd));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -159,17 +159,81 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
||||||
User sysUser = findByLoginName(phone);
|
User sysUser = findByLoginName(phone);
|
||||||
|
|
||||||
if (sysUser == null) {
|
if (sysUser == null) {
|
||||||
throw new MyException("用户名或密码错误");
|
throw new MyException("当前手机号未注册");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LoginVo out = new LoginVo();
|
LoginVo out = new LoginVo();
|
||||||
BeanUtils.copyProperties(sysUser, out);
|
BeanUtils.copyProperties(sysUser, out);
|
||||||
|
|
||||||
AddressBookVo book = addressBookMapper.getVoById(sysUser.getAbId());
|
AddressBookVo book = addressBookMapper.getVoById(sysUser.getAbId());
|
||||||
if (Objects.nonNull(book)) {
|
if (Objects.nonNull(book)) {
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(book.getOpenid())){
|
||||||
|
|
||||||
|
System.out.println("openid1:"+sysUser.getAbId());
|
||||||
|
System.out.println("openid2:"+openid);
|
||||||
|
System.out.println("openid3:"+book.getOpenid());
|
||||||
|
|
||||||
|
if(!openid.equals(book.getOpenid())){
|
||||||
|
throw new MyException("当前手机号已绑定其他账号,请先解绑!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
book.setOpenid(openid);
|
||||||
|
if (!book.updateById()) {
|
||||||
|
throw new MyException("openid保存失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!book.getIsPass()){
|
if (!book.getIsPass()){
|
||||||
throw new MyException("当前账号无法登录,请联系上级管理员!");
|
throw new MyException("当前账号无法登录,请联系上级管理员!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
String adcd = book.getAdcd();
|
||||||
|
if (StringUtils.isNotBlank(adcd)) {
|
||||||
|
|
||||||
|
out.setAdlevel(2);
|
||||||
|
out.setAdcd(adcd.substring(0, 4));
|
||||||
|
|
||||||
|
}
|
||||||
|
out.setOpenid(openid);
|
||||||
|
out.setName(book.getName());
|
||||||
|
out.setOname(book.getOname());
|
||||||
|
if (StringUtils.isNotBlank(book.getAdnm())) {
|
||||||
|
out.setOname(book.getAdnm());
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
throw new MyException("该用户未绑定通讯录");
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LoginVo wxLogin(String openid) {
|
||||||
|
|
||||||
|
LoginVo out = new LoginVo();
|
||||||
|
|
||||||
|
AddressBookVo book = addressBookMapper.getVoByOpenid(openid);
|
||||||
|
if (Objects.nonNull(book)) {
|
||||||
|
|
||||||
|
User sysUser = findByLoginName(book.getPhone());
|
||||||
|
|
||||||
|
if (sysUser == null) {
|
||||||
|
throw new MyException("当前手机号未注册");
|
||||||
|
}
|
||||||
|
BeanUtils.copyProperties(sysUser, out);
|
||||||
|
|
||||||
|
if (!book.getIsPass()){
|
||||||
|
throw new MyException("当前账号无法登录,请联系上级管理员!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
String adcd = book.getAdcd();
|
String adcd = book.getAdcd();
|
||||||
if (StringUtils.isNotBlank(adcd)) {
|
if (StringUtils.isNotBlank(adcd)) {
|
||||||
|
|
||||||
|
|
@ -182,6 +246,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
||||||
if (StringUtils.isNotBlank(book.getAdnm())) {
|
if (StringUtils.isNotBlank(book.getAdnm())) {
|
||||||
out.setOname(book.getAdnm());
|
out.setOname(book.getAdnm());
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
throw new MyException("该用户未绑定通讯录");
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
|
|
||||||
|
|
@ -278,6 +344,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
||||||
throw new MyException("当前账号暂未注册");
|
throw new MyException("当前账号暂未注册");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!addressBook.getIsPass()){
|
||||||
|
throw new MyException("当前账号无法登录,请联系上级管理员!");
|
||||||
|
}
|
||||||
|
|
||||||
LoginVo out = new LoginVo();
|
LoginVo out = new LoginVo();
|
||||||
BeanUtils.copyProperties(sysUser, out);
|
BeanUtils.copyProperties(sysUser, out);
|
||||||
String adcd = addressBook.getAdcd();
|
String adcd = addressBook.getAdcd();
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,12 @@ spring:
|
||||||
datasource:
|
datasource:
|
||||||
type: com.alibaba.druid.pool.DruidDataSource
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
driver-class-name: dm.jdbc.driver.DmDriver
|
driver-class-name: dm.jdbc.driver.DmDriver
|
||||||
url: jdbc:dm://local.gunshiiot.com:5236?schema=FXKH_TXL
|
# url: jdbc:dm://10.0.41.113:5236?schema=FXKH_TXL
|
||||||
username: SYSDBA
|
# username: SYSDBA
|
||||||
password: SYSDBA001
|
# password: SYSDBA001
|
||||||
# url: jdbc:dm://10.42.6.247:5236?schema=FXKH_TXL
|
url: jdbc:dm://10.42.6.247:5236?schema=FXKH_TXL
|
||||||
# username: SHZH
|
username: SHZH
|
||||||
# password: Shzh_890
|
password: Shzh_890
|
||||||
druid:
|
druid:
|
||||||
initialSize: 5
|
initialSize: 5
|
||||||
minIdle: 5
|
minIdle: 5
|
||||||
|
|
@ -39,11 +39,11 @@ spring:
|
||||||
# Redis
|
# Redis
|
||||||
redis:
|
redis:
|
||||||
database: 5
|
database: 5
|
||||||
# host: 10.42.6.75
|
host: 10.42.6.75
|
||||||
host: 127.0.0.1
|
# host: 127.0.0.1
|
||||||
port: 6379
|
port: 6379
|
||||||
password:
|
# password:
|
||||||
# password: Whdc_890
|
password: Whdc_890
|
||||||
|
|
||||||
servlet:
|
servlet:
|
||||||
multipart:
|
multipart:
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<!-- AND AB.ADCD ${dto.v} #{dto.adcd}-->
|
<!-- AND AB.ADCD ${dto.v} #{dto.adcd}-->
|
||||||
<select id="page" resultType="com.whdc.model.vo.AddressBookVo">
|
<select id="page" resultType="com.whdc.model.vo.AddressBookVo">
|
||||||
SELECT
|
SELECT
|
||||||
AB.*,F.SORT FSORT,F.ID FCID,U.ROLE,F.TYPE FTYPE,IF(O.NAME IS NULL,UD.NAME,O.NAME) ONAME,A.ADNM
|
AB.*,F.SORT FSORT,F.ID FCID,U.ROLE,F.TYPE FTYPE,IF(UD.NAME IS NOT NULL,UD.NAME,O.NAME) ONAME,A.ADNM
|
||||||
FROM
|
FROM
|
||||||
ADDRESS_BOOK AB
|
ADDRESS_BOOK AB
|
||||||
LEFT JOIN FC F ON F.AB_ID = AB.ID AND F.USER_ID = #{dto.userId}
|
LEFT JOIN FC F ON F.AB_ID = AB.ID AND F.USER_ID = #{dto.userId}
|
||||||
|
|
@ -68,7 +68,7 @@
|
||||||
|
|
||||||
<select id="getVoById" resultType="com.whdc.model.vo.AddressBookVo">
|
<select id="getVoById" resultType="com.whdc.model.vo.AddressBookVo">
|
||||||
SELECT
|
SELECT
|
||||||
AB.*,IF(O.NAME IS NULL,UD.NAME,O.NAME) ONAME,A.ADNM
|
AB.*,IF(UD.NAME IS NOT NULL,UD.NAME,O.NAME) ONAME,A.ADNM
|
||||||
FROM
|
FROM
|
||||||
ADDRESS_BOOK AB
|
ADDRESS_BOOK AB
|
||||||
LEFT JOIN ORGANIZATION O ON AB.ORGANIZATION = O.ID
|
LEFT JOIN ORGANIZATION O ON AB.ORGANIZATION = O.ID
|
||||||
|
|
@ -78,4 +78,17 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<select id="getVoByOpenid" resultType="com.whdc.model.vo.AddressBookVo">
|
||||||
|
SELECT
|
||||||
|
AB.*,IF(UD.NAME IS NOT NULL,UD.NAME,O.NAME) ONAME,A.ADNM
|
||||||
|
FROM
|
||||||
|
ADDRESS_BOOK AB
|
||||||
|
LEFT JOIN ORGANIZATION O ON AB.ORGANIZATION = O.ID
|
||||||
|
LEFT JOIN UNIT_DICT UD ON AB.ORGANIZATION = UD.ID
|
||||||
|
LEFT JOIN ADINFO A ON AB.ADCD = A.ADCD
|
||||||
|
WHERE AB.OPENID = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue