1366 changed files with 75416 additions and 2938 deletions
@ -1,18 +1,56 @@ |
|||
package com.epmet.feign.fallback; |
|||
|
|||
import com.epmet.commons.tools.constant.ServiceConstant; |
|||
import com.epmet.commons.tools.dto.form.DictListFormDTO; |
|||
import com.epmet.commons.tools.dto.result.DictListResultDTO; |
|||
import com.epmet.commons.tools.dto.result.OptionResultDTO; |
|||
import com.epmet.commons.tools.utils.ModuleUtils; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dto.result.CorsConfigResultDTO; |
|||
import com.epmet.feign.EpmetAdminOpenFeignClient; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
//@Component
|
|||
public class EpmetAdminOpenFeignClientFallback implements EpmetAdminOpenFeignClient { |
|||
@Override |
|||
public Result<List<CorsConfigResultDTO>> list() { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "list", null); |
|||
return ModuleUtils.feignConError(ServiceConstant.EPMET_ADMIN_SERVER, "list", null); |
|||
} |
|||
|
|||
@Override |
|||
public Result<List<OptionResultDTO>> getEducationOption() { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPMET_ADMIN_SERVER, "getEducationOption", null); |
|||
} |
|||
|
|||
@Override |
|||
public Result<List<OptionResultDTO>> getHouseOption() { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPMET_ADMIN_SERVER, "getHouseOption", null); |
|||
} |
|||
|
|||
@Override |
|||
public Result<List<OptionResultDTO>> getNationOption() { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPMET_ADMIN_SERVER, "getNationOption", null); |
|||
} |
|||
|
|||
@Override |
|||
public Result<List<OptionResultDTO>> getNineSmallPlacesOption() { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPMET_ADMIN_SERVER, "getNineSmallPlacesOption", null); |
|||
} |
|||
|
|||
@Override |
|||
public Result<List<OptionResultDTO>> getRelationshipOption() { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPMET_ADMIN_SERVER, "getRelationshipOption", null); |
|||
} |
|||
|
|||
@Override |
|||
public Result<Map<String, String>> dictMap(String dictType) { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPMET_ADMIN_SERVER, "dictMap", dictType); |
|||
} |
|||
|
|||
@Override |
|||
public Result<List<DictListResultDTO>> dictList(DictListFormDTO formDTO) { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPMET_ADMIN_SERVER, "dictList", formDTO); |
|||
} |
|||
} |
|||
|
@ -0,0 +1,29 @@ |
|||
-- 1、增加字典类型 |
|||
INSERT INTO `epmet_admin`.`sys_dict_type` (`id`, `dict_type`, `dict_name`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (8, 'user_demand_status', '居民需求状态', '待处理:pending;已取消canceled;已派单:assigned;已接单:have_order;已完成:finished', 8, 1067246875800000001, '2021-11-18 16:29:58', 1067246875800000001, '2021-11-18 16:29:58'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_type` (`id`, `dict_type`, `dict_name`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (9, 'user_demand_report_type', '居民需求上报类型', '社区帮办:community;楼长帮办:building_caption;党员帮办:party;自身上报:self_help', 9, 1067246875800000001, '2021-11-18 16:29:58', 1067246875800000001, '2021-11-18 16:29:58'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_type` (`id`, `dict_type`, `dict_name`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (10, 'user_demand_service_type', '居民需求服务方类型', '服务方类型:志愿者:volunteer;社会组织:social_org;社区自组织:community_org;区域党建单位:party_unit;', 10, 1067246875800000001, '2021-11-18 16:29:58', 1067246875800000001, '2021-11-18 16:29:58'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_type` (`id`, `dict_type`, `dict_name`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (1000000000000000006, 'scale', '人员规模', '', 6, 1067246875800000001, '2021-11-18 16:29:58', 1067246875800000001, '2021-11-18 16:29:58'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_type` (`id`, `dict_type`, `dict_name`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (1000000000000000007, 'party_unit_type', '联建单位分类', '', 7, 1067246875800000001, '2021-11-18 16:29:58', 1067246875800000001, '2021-11-18 16:29:58'); |
|||
-- 2、增加字典数据 |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (1000000000000000200, 1000000000000000007, '楼宇党建', '0', '', 0, 1067246875800000001, '2020-03-08 16:29:58', 1067246875800000001, '2020-03-08 16:29:58'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (1000000000000000201, 1000000000000000007, '两新组织', '1', '', 1, 1067246875800000001, '2020-03-08 16:29:58', 1067246875800000001, '2020-03-08 16:29:58'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (1000000000000000202, 1000000000000000007, '区域单位党建', '2', '', 2, 1067246875800000001, '2020-03-08 16:29:58', 1067246875800000001, '2020-03-08 16:29:58'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (1000000000000000203, 1000000000000000007, '机关直属部门', '3', '', 3, 1067246875800000001, '2020-03-08 16:29:58', 1067246875800000001, '2020-03-08 16:29:58'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (1000000000000000204, 1000000000000000007, '其他', '4', '', 4, 1067246875800000001, '2020-03-08 16:29:58', 1067246875800000001, '2020-03-08 16:29:58'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (1000000000000000205, 8, '待处理', 'pending', '', 1, 1, '2021-11-23 14:00:59', 1, '2021-11-23 14:00:59'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (1000000000000000206, 8, '已取消', 'canceled', '', 2, 1, '2021-11-23 14:00:59', 1, '2021-11-23 14:00:59'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (1000000000000000207, 8, '已派单', 'assigned', '', 3, 1, '2021-11-23 14:00:59', 1, '2021-11-23 14:00:59'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (1000000000000000208, 8, '已接单', 'have_order', '', 4, 1, '2021-11-23 14:00:59', 1, '2021-11-23 14:00:59'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (1000000000000000209, 8, '已完成', 'finished', '', 5, 1, '2021-11-23 14:00:59', 1, '2021-11-23 14:00:59'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (1000000000000000210, 9, '社区帮办', 'community', '', 1, 1, '2021-11-23 14:03:22', 1, '2021-11-23 14:03:22'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (1000000000000000211, 9, '楼长帮办', 'building_caption', '', 2, 1, '2021-11-23 14:03:22', 1, '2021-11-23 14:03:22'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (1000000000000000212, 9, '党员帮办', 'party', '', 3, 1, '2021-11-23 14:03:22', 1, '2021-11-23 14:03:22'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (1000000000000000213, 10, '志愿者', 'volunteer', '', 1, 1, '2021-11-23 14:04:42', 1, '2021-11-23 14:04:42'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (1000000000000000214, 10, '社会组织', 'social_org', '', 2, 1, '2021-11-23 14:04:42', 1, '2021-11-23 14:04:42'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (1000000000000000215, 10, '社区自组织', 'community_org', '', 3, 1, '2021-11-23 14:04:42', 1, '2021-11-23 14:04:42'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (1000000000000000216, 10, '区域党建单位', 'party_unit', '', 4, 1, '2021-11-23 14:04:42', 1, '2021-11-23 14:04:42'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (2000000000000000000, 1000000000000000006, '10人以下', '0', '', 0, 1067246875800000001, '2021-11-18 16:29:58', 1067246875800000001, '2021-11-18 16:29:58'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (2000000000000000001, 1000000000000000006, '10-20人', '1', '', 1, 1067246875800000001, '2021-11-18 16:29:58', 1067246875800000001, '2021-11-18 16:29:58'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (2000000000000000002, 1000000000000000006, '21-40人', '2', '', 2, 1067246875800000001, '2021-11-18 16:29:58', 1067246875800000001, '2021-11-18 16:29:58'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (2000000000000000003, 1000000000000000006, '41-100人', '3', '', 3, 1067246875800000001, '2021-11-18 16:29:58', 1067246875800000001, '2021-11-18 16:29:58'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (2000000000000000004, 1000000000000000006, '100人以上', '4', '', 4, 1067246875800000001, '2021-11-18 16:29:58', 1067246875800000001, '2021-11-18 16:29:58'); |
@ -0,0 +1,9 @@ |
|||
-- 1、增加字典类型 |
|||
INSERT INTO `epmet_admin`.`sys_dict_type` (`id`, `dict_type`, `dict_name`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (1000000000000000011, 'age_group', '年龄范围', '', 11, 1067246875800000001, '2021-11-18 16:29:58', 1067246875800000001, '2021-11-18 16:29:58'); |
|||
|
|||
-- 2、增加字典数据 |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (1000000000000000230, 1000000000000000011, '50岁以下', '0', '', 0, 1, '2021-11-23 14:04:42', 1, '2021-11-23 14:04:42'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (1000000000000000231, 1000000000000000011, '50-59岁', '1', '', 1, 1, '2021-11-23 14:04:42', 1, '2021-11-23 14:04:42'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (1000000000000000232, 1000000000000000011, '60-69岁', '2', '', 2, 1, '2021-11-23 14:04:42', 1, '2021-11-23 14:04:42'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (1000000000000000233, 1000000000000000011, '70-79岁', '3', '', 3, 1, '2021-11-23 14:04:42', 1, '2021-11-23 14:04:42'); |
|||
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `remark`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES (1000000000000000234, 1000000000000000011, '80岁以上', '4', '', 4, 1, '2021-11-23 14:04:42', 1, '2021-11-23 14:04:42'); |
@ -0,0 +1,162 @@ |
|||
package com.epmet.controller; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import com.epmet.commons.tools.constant.AppClientConstant; |
|||
import com.epmet.commons.tools.constant.ServiceConstant; |
|||
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|||
import com.epmet.commons.tools.exception.RenException; |
|||
import com.epmet.commons.tools.feign.ResultDataResolver; |
|||
import com.epmet.commons.tools.redis.RedisKeys; |
|||
import com.epmet.commons.tools.redis.RedisUtils; |
|||
import com.epmet.commons.tools.security.password.PasswordUtils; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.commons.tools.validator.ValidatorUtils; |
|||
import com.epmet.dto.CustomerStaffDTO; |
|||
import com.epmet.dto.form.LoginByPassWordFormDTO; |
|||
import com.epmet.dto.form.RootOrgListByStaffIdFormDTO; |
|||
import com.epmet.dto.result.StaffOrgsResultDTO; |
|||
import com.epmet.dto.result.UserTokenResultDTO; |
|||
import com.epmet.feign.EpmetUserFeignClient; |
|||
import com.epmet.feign.GovOrgOpenFeignClient; |
|||
import com.epmet.redis.CaptchaRedis; |
|||
import com.epmet.redis.IcLoginTicketCacheBean; |
|||
import com.epmet.service.IcLoginService; |
|||
import org.apache.commons.collections4.CollectionUtils; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.*; |
|||
|
|||
@RestController |
|||
@RequestMapping("ic") |
|||
public class IcLoinController implements ResultDataResolver { |
|||
|
|||
public static final long IC_LOGIN_TICKET_EXPIRE_SECONDS = 2 * 60l; |
|||
|
|||
@Autowired |
|||
private EpmetUserFeignClient epmetUserFeignClient; |
|||
|
|||
@Autowired |
|||
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|||
|
|||
@Autowired |
|||
private CaptchaRedis captchaRedis; |
|||
|
|||
@Autowired |
|||
private IcLoginService icLoginService; |
|||
|
|||
@Autowired |
|||
private RedisUtils redisUtils; |
|||
|
|||
/** |
|||
* @description 基层治理赋能平台-根据手机号密码获取组织列表 |
|||
* |
|||
* @param input |
|||
* @return |
|||
* @author wxz |
|||
* @date 2021.10.25 09:56:33 |
|||
*/ |
|||
@PostMapping("getmyorgsbypassword") |
|||
public Result<HashMap<String, Object>> getMyOrgsByPassword(@RequestBody LoginByPassWordFormDTO input) { |
|||
ValidatorUtils.validateEntity(input, LoginByPassWordFormDTO.IcGetOrgsByPwdGroup.class); |
|||
String captcha = input.getCaptcha(); |
|||
String mobile = input.getMobile(); |
|||
String password = input.getPassword(); |
|||
String uuid = input.getUuid(); |
|||
|
|||
// 图片验证码
|
|||
String captchaInCache = captchaRedis.getIcLoginCaptcha(uuid); |
|||
if (StringUtils.isBlank(captchaInCache) || !captcha.equals(captchaInCache)) { |
|||
throw new RenException(EpmetErrorCode.ERR10019.getCode()); |
|||
} |
|||
|
|||
// 获取用户信息
|
|||
Result<List<CustomerStaffDTO>> staffResult = epmetUserFeignClient.checkCustomerStaff(mobile); |
|||
List<CustomerStaffDTO> staffList = getResultDataOrThrowsException(staffResult, ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【基层治理平台登录】获取用户信息失败", null); |
|||
if (CollectionUtils.isEmpty(staffList)) { |
|||
throw new RenException(EpmetErrorCode.ERR10003.getCode()); |
|||
} |
|||
|
|||
CustomerStaffDTO staffInfo = staffList.get(0); |
|||
|
|||
if (!PasswordUtils.matches(password, staffInfo.getPassword())) { |
|||
throw new RenException(EpmetErrorCode.ERR10004.getCode()); |
|||
} |
|||
|
|||
String staffId = staffInfo.getUserId(); |
|||
|
|||
// 查询跟组织列表
|
|||
RootOrgListByStaffIdFormDTO orgListForm = new RootOrgListByStaffIdFormDTO(); |
|||
orgListForm.setStaffId(staffId); |
|||
Result<List<StaffOrgsResultDTO>> orgListResult = govOrgOpenFeignClient.getStaffOrgListByStaffId(orgListForm); |
|||
List<StaffOrgsResultDTO> orgs = getResultDataOrThrowsException(orgListResult, ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【基层治理平台登录】根据staffId查询所属客户跟组织列表失败", null); |
|||
|
|||
// 生成登录票据
|
|||
String ticket = UUID.randomUUID().toString().replace("-", ""); |
|||
IcLoginTicketCacheBean ticketCacheBean = new IcLoginTicketCacheBean(); |
|||
ticketCacheBean.setMobile(mobile); |
|||
ticketCacheBean.setStaffId(staffId); |
|||
cacheTicket(ticket, ticketCacheBean); |
|||
|
|||
HashMap<String, Object> resultMap = new HashMap<>(); |
|||
resultMap.put("staffId", staffId); |
|||
resultMap.put("ticket", ticket); |
|||
resultMap.put("orgs", orgs); |
|||
|
|||
return new Result<HashMap<String, Object>>().ok(resultMap); |
|||
} |
|||
|
|||
/** |
|||
* @description IC登录 |
|||
* |
|||
* @param input |
|||
* @return |
|||
* @author wxz |
|||
* @date 2021.10.25 21:14:22 |
|||
*/ |
|||
@PostMapping("login") |
|||
public Result<UserTokenResultDTO> login(@RequestBody LoginByPassWordFormDTO input) { |
|||
ValidatorUtils.validateEntity(input, LoginByPassWordFormDTO.IcLoginGroup.class); |
|||
String ticket = input.getTicket(); |
|||
String orgId = input.getRootAgencyId(); |
|||
String staffId = input.getStaffId(); |
|||
|
|||
// ticket校验
|
|||
IcLoginTicketCacheBean ticketCache = getTicketCache(ticket); |
|||
if (ticketCache == null || !ticketCache.getStaffId().equals(staffId)) { |
|||
// ticket&userId不对应
|
|||
throw new RenException(EpmetErrorCode.ERR10008.getCode()); |
|||
} |
|||
|
|||
UserTokenResultDTO tokenInfo = icLoginService.login(staffId, orgId); |
|||
return new Result<UserTokenResultDTO>().ok(tokenInfo); |
|||
} |
|||
|
|||
private void cacheTicket(String ticket, IcLoginTicketCacheBean cacheBean) { |
|||
Map<String, Object> stringObjectMap = BeanUtil.beanToMap(cacheBean, false, true); |
|||
redisUtils.hMSet(RedisKeys.loginTicket(AppClientConstant.APP_IC, ticket), stringObjectMap, IC_LOGIN_TICKET_EXPIRE_SECONDS); |
|||
} |
|||
|
|||
/** |
|||
* @description 从缓存中取出ticket,并删除 |
|||
* |
|||
* @param ticket |
|||
* @return |
|||
* @author wxz |
|||
* @date 2021.10.26 08:58:27 |
|||
*/ |
|||
private IcLoginTicketCacheBean getTicketCache(String ticket) { |
|||
String key = RedisKeys.loginTicket(AppClientConstant.APP_IC, ticket); |
|||
Map<String, Object> map = redisUtils.hGetAll(key); |
|||
if (CollectionUtils.sizeIsEmpty(map)) { |
|||
return null; |
|||
} |
|||
redisUtils.expire(key, 0); |
|||
return BeanUtil.mapToBean(map, IcLoginTicketCacheBean.class, false); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,9 @@ |
|||
package com.epmet.redis; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class IcLoginTicketCacheBean { |
|||
private String staffId; |
|||
private String mobile; |
|||
} |
@ -0,0 +1,9 @@ |
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.dto.result.UserTokenResultDTO; |
|||
|
|||
public interface IcLoginService { |
|||
|
|||
|
|||
UserTokenResultDTO login(String staffId, String orgId); |
|||
} |
@ -0,0 +1,177 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import com.epmet.auth.constants.AuthOperationConstants; |
|||
import com.epmet.commons.rocketmq.messages.LoginMQMsg; |
|||
import com.epmet.commons.tools.constant.AppClientConstant; |
|||
import com.epmet.commons.tools.constant.ServiceConstant; |
|||
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|||
import com.epmet.commons.tools.exception.RenException; |
|||
import com.epmet.commons.tools.feign.ResultDataResolver; |
|||
import com.epmet.commons.tools.redis.RedisKeys; |
|||
import com.epmet.commons.tools.redis.RedisUtils; |
|||
import com.epmet.commons.tools.security.dto.IcTokenDto; |
|||
import com.epmet.commons.tools.utils.CpUserDetailRedis; |
|||
import com.epmet.commons.tools.utils.IpUtils; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dto.CustomerAgencyDTO; |
|||
import com.epmet.dto.form.SystemMsgFormDTO; |
|||
import com.epmet.dto.result.UserTokenResultDTO; |
|||
import com.epmet.feign.EpmetMessageOpenFeignClient; |
|||
import com.epmet.feign.GovOrgOpenFeignClient; |
|||
import com.epmet.jwt.JwtTokenProperties; |
|||
import com.epmet.jwt.JwtTokenUtils; |
|||
import com.epmet.service.IcLoginService; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.context.request.RequestContextHolder; |
|||
import org.springframework.web.context.request.ServletRequestAttributes; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import java.util.*; |
|||
|
|||
@Service |
|||
@Slf4j |
|||
public class IcLoginServiceImpl implements IcLoginService, ResultDataResolver { |
|||
|
|||
@Autowired |
|||
private JwtTokenUtils jwtTokenUtils; |
|||
|
|||
@Autowired |
|||
private RedisUtils redisUtils; |
|||
|
|||
@Autowired |
|||
private CpUserDetailRedis cpUserDetailRedis; |
|||
|
|||
@Autowired |
|||
private JwtTokenProperties jwtTokenProperties; |
|||
|
|||
@Autowired |
|||
private EpmetMessageOpenFeignClient messageOpenFeignClient; |
|||
|
|||
@Autowired |
|||
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|||
|
|||
@Autowired |
|||
private ThirdLoginServiceImpl thirdLoginService; |
|||
|
|||
@Override |
|||
public UserTokenResultDTO login(String staffId, String orgId) { |
|||
String app = AppClientConstant.APP_IC; |
|||
String client = AppClientConstant.CLIENT_WEB; |
|||
|
|||
// 1.获取用户token
|
|||
String token = this.generateIcToken(staffId, app, client); |
|||
|
|||
Result<CustomerAgencyDTO> agencyResult = govOrgOpenFeignClient.getAgencyById(orgId); |
|||
CustomerAgencyDTO agencyInfo = getResultDataOrThrowsException(agencyResult, ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【IC平台登录】获取组织信息失败", null); |
|||
|
|||
// 2.缓存token
|
|||
cacheToken(app, client, staffId, token, orgId, agencyInfo.getCustomerId()); |
|||
|
|||
UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); |
|||
userTokenResultDTO.setToken(token); |
|||
userTokenResultDTO.setCustomerId(agencyInfo.getCustomerId()); |
|||
|
|||
//7.发送登录事件
|
|||
try { |
|||
sendLoginEvent(staffId, app, client); |
|||
} catch (RenException e) { |
|||
log.error(e.getInternalMsg()); |
|||
} catch (Exception e) { |
|||
log.error("【工作端workLogin登录】发送登录事件失败,程序继续执行。"); |
|||
} |
|||
|
|||
return userTokenResultDTO; |
|||
} |
|||
|
|||
/** |
|||
* @param staffId |
|||
* @return |
|||
* @description 生成Ic平台的Token |
|||
* @author wxz |
|||
* @date 2021.10.26 13:42:36 |
|||
*/ |
|||
private String generateIcToken(String staffId, String app, String client) { |
|||
Map<String, Object> map = new HashMap<>(); |
|||
map.put("app", app); |
|||
map.put("client", client); |
|||
map.put("userId", staffId); |
|||
String token = jwtTokenUtils.createToken(map); |
|||
return token; |
|||
} |
|||
|
|||
/** |
|||
* @param userId |
|||
* @param fromApp |
|||
* @param fromClient |
|||
* @return |
|||
* @description 发布登录时间 |
|||
* @author wxz |
|||
* @date 2021.10.26 13:45:59 |
|||
*/ |
|||
private void sendLoginEvent(String userId, String fromApp, String fromClient) { |
|||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
|||
|
|||
LoginMQMsg loginMQMsg = new LoginMQMsg(); |
|||
loginMQMsg.setUserId(userId); |
|||
loginMQMsg.setLoginTime(new Date()); |
|||
loginMQMsg.setIp(IpUtils.getIpAddr(request)); |
|||
loginMQMsg.setFromApp(fromApp); |
|||
loginMQMsg.setFromClient(fromClient); |
|||
|
|||
SystemMsgFormDTO form = new SystemMsgFormDTO(); |
|||
form.setMessageType(AuthOperationConstants.LOGIN); |
|||
form.setContent(loginMQMsg); |
|||
messageOpenFeignClient.sendSystemMsgByMQ(form); |
|||
} |
|||
|
|||
/** |
|||
* @description 缓存token到redis |
|||
* |
|||
* @param app |
|||
* @param client |
|||
* @param userId |
|||
* @param token |
|||
* @param rootAgencyId |
|||
* @return |
|||
* @author wxz |
|||
* @date 2021.10.26 14:19:07 |
|||
*/ |
|||
private void cacheToken(String app, |
|||
String client, |
|||
String userId, |
|||
String token, |
|||
String rootAgencyId, |
|||
String customerId) { |
|||
|
|||
IcTokenDto tokenDto = new IcTokenDto(); |
|||
int expire = jwtTokenProperties.getExpire(); |
|||
long expireTime = jwtTokenUtils.getExpiration(token).getTime(); |
|||
|
|||
tokenDto.setApp(app); |
|||
tokenDto.setClient(client); |
|||
tokenDto.setUserId(userId); |
|||
tokenDto.setToken(token); |
|||
tokenDto.setExpireTime(expireTime); |
|||
tokenDto.setRootAgencyId(rootAgencyId); |
|||
tokenDto.setCustomerId(customerId); |
|||
|
|||
//设置部门,网格,角色列表
|
|||
tokenDto.setDeptIdList(thirdLoginService.getDeptartmentIdList(userId)); |
|||
tokenDto.setGridIdList(thirdLoginService.getGridIdList(userId)); |
|||
CustomerAgencyDTO agency = thirdLoginService.getAgencyByStaffId(userId); |
|||
if (agency != null) { |
|||
tokenDto.setAgencyId(agency.getId()); |
|||
tokenDto.setRoleList(thirdLoginService.queryGovStaffRoles(userId, agency.getId())); |
|||
} |
|||
tokenDto.setOrgIdPath(thirdLoginService.getOrgIdPath(userId)); |
|||
|
|||
String key = RedisKeys.getCpUserKey(app, client, userId); |
|||
Map<String, Object> map = BeanUtil.beanToMap(tokenDto, false, true); |
|||
redisUtils.hMSet(key, map, expire); |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,13 @@ |
|||
package com.epmet.commons.rocketmq.constants; |
|||
|
|||
/** |
|||
* @Description MQ用户自定义属性 |
|||
* @author wxz |
|||
* @date 2021.10.14 15:47:03 |
|||
*/ |
|||
public interface MQUserPropertys { |
|||
|
|||
//阻塞消息label
|
|||
String BLOCKED_MSG_LABEL = "blockedMsgLabel"; |
|||
|
|||
} |
@ -0,0 +1,19 @@ |
|||
package com.epmet.commons.rocketmq.messages; |
|||
|
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 需求完成,如果服务方是区域化党建单位,重新计算这个单位的满意度,或者直接计算整个客户 |
|||
*/ |
|||
@Data |
|||
public class CalPartyUnitSatisfactionFormDTO implements Serializable { |
|||
public interface AddUserInternalGroup { |
|||
} |
|||
@NotBlank(message = "客户id不能为空",groups = AddUserInternalGroup.class) |
|||
private String customerId; |
|||
private String partyUnitId; |
|||
} |
@ -0,0 +1,23 @@ |
|||
package com.epmet.commons.rocketmq.messages; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Description |
|||
* @Author zhaoqifeng |
|||
* @Date 2021/10/18 16:24 |
|||
*/ |
|||
@Data |
|||
@AllArgsConstructor |
|||
public class DisputeProcessMQMsg implements Serializable { |
|||
private String customerId; |
|||
private List<String> projectId; |
|||
/** |
|||
* 操作类型【新增:add 修改删除:edit】 |
|||
*/ |
|||
private String type; |
|||
} |
@ -0,0 +1,20 @@ |
|||
package com.epmet.commons.rocketmq.messages; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 居民信息新增、修改推送MQ |
|||
* @author sun |
|||
*/ |
|||
@Data |
|||
public class IcResiUserAddMQMsg implements Serializable { |
|||
|
|||
//客户Id
|
|||
private String customerId; |
|||
//居民ID
|
|||
private String icResiUser; |
|||
|
|||
|
|||
} |
@ -0,0 +1,27 @@ |
|||
package com.epmet.commons.rocketmq.messages; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 组织、网格、人员中间库数据上报MQ |
|||
* @author sun |
|||
*/ |
|||
@Data |
|||
public class OrgOrStaffMQMsg implements Serializable { |
|||
|
|||
//客户Id
|
|||
private String customerId; |
|||
//组织、网格、人员Id
|
|||
private String orgId; |
|||
//数据类型【组织:agency 网格:grid 人员:staff】
|
|||
private String orgType; |
|||
//操作类型【组织新增:agency_create 组织变更:agency_change 网格新增:grid_create 网格变更:grid_change 人员新增:staff_create 人员变更:staff_change】
|
|||
private String type; |
|||
|
|||
|
|||
} |
@ -0,0 +1,21 @@ |
|||
package com.epmet.commons.rocketmq.messages; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* 用户巡查消息体 |
|||
* @author liujianjun |
|||
*/ |
|||
@Data |
|||
public class StaffPatrolMQMsg { |
|||
/** |
|||
* 客户Id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 巡查记录id |
|||
*/ |
|||
private String patrolId; |
|||
|
|||
} |
@ -0,0 +1,20 @@ |
|||
package com.epmet.commons.tools.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
|
|||
/** |
|||
* @Description 字典数据查询-接口入参 |
|||
* @Author sun |
|||
*/ |
|||
@Data |
|||
public class DictListFormDTO { |
|||
|
|||
/** |
|||
* 字典类型 |
|||
*/ |
|||
@NotBlank(message = "字典类型不能为空") |
|||
private String dictType; |
|||
|
|||
} |
@ -0,0 +1,17 @@ |
|||
package com.epmet.commons.tools.dto.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Description 字典数据查询-接口返参 |
|||
* @Author sun |
|||
*/ |
|||
@Data |
|||
public class DictListResultDTO implements Serializable { |
|||
private static final long serialVersionUID = 8618231166600518980L; |
|||
private String label; |
|||
private String value; |
|||
} |
@ -0,0 +1,19 @@ |
|||
package com.epmet.commons.tools.dto.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Description |
|||
* @Author zhaoqifeng |
|||
* @Date 2021/12/8 14:50 |
|||
*/ |
|||
@Data |
|||
public class OptionDataResultDTO implements Serializable { |
|||
private static final long serialVersionUID = 416877704759019210L; |
|||
private String label; |
|||
private String value; |
|||
private String code; |
|||
private String radio; |
|||
} |
@ -0,0 +1,22 @@ |
|||
package com.epmet.commons.tools.dto.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Description |
|||
* @Author zhaoqifeng |
|||
* @Date 2021/10/26 13:53 |
|||
*/ |
|||
@Data |
|||
public class OptionResultDTO implements Serializable { |
|||
private static final long serialVersionUID = 8618231166600518980L; |
|||
private String label; |
|||
private String value; |
|||
private String pValue; |
|||
private String sysDictDataId; |
|||
private List<OptionResultDTO> children; |
|||
private Boolean usableFlag; |
|||
} |
@ -0,0 +1,59 @@ |
|||
package com.epmet.commons.tools.enums; |
|||
|
|||
/** |
|||
* @author Administrator |
|||
*/ |
|||
public enum DictTypeEnum { |
|||
/** |
|||
* 环境变量枚举 |
|||
*/ |
|||
UN_KNOWN("un_know", "暂不清楚", 0), |
|||
NINE_SMALL_PLACES("nine_small_places", "九小场所", 1), |
|||
EDUCATION("education", "文化程度", 2), |
|||
NATION("nation", "民族", 3), |
|||
RELATIONSHIP("relationship", "与户主关系", 4), |
|||
HOUSE("house", "住房性质", 5), |
|||
SCALE("scale", "人员规模", 6), |
|||
PARTY_UNIT_TYPE("party_unit_type", "联建单位分类", 7), |
|||
GENDER("gender", "性别", 8), |
|||
USER_DEMAND_STATUS("user_demand_status", "居民需求状态",8), |
|||
USER_DEMAND_REPORT_TYPE("user_demand_report_type","居民需求上报类型",9), |
|||
USER_DEMAND_SERVICE_TYPE("user_demand_service_type","居民需求服务方类型",10), |
|||
AGE_GROUP("age_group", "年龄范围", 11), |
|||
; |
|||
|
|||
private final String code; |
|||
private final String name; |
|||
private final Integer sort; |
|||
|
|||
|
|||
|
|||
DictTypeEnum(String code, String name, Integer sort) { |
|||
this.code = code; |
|||
this.name = name; |
|||
this.sort = sort; |
|||
} |
|||
|
|||
public static DictTypeEnum getEnum(String code) { |
|||
DictTypeEnum[] values = DictTypeEnum.values(); |
|||
for (DictTypeEnum value : values) { |
|||
if (value.getCode().equals(code)) { |
|||
return value; |
|||
} |
|||
} |
|||
return DictTypeEnum.UN_KNOWN; |
|||
} |
|||
|
|||
|
|||
public String getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public String getName() { |
|||
return name; |
|||
} |
|||
|
|||
public Integer getSort(){ |
|||
return sort; |
|||
} |
|||
} |
@ -0,0 +1,53 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.epmet.commons.tools.enums; |
|||
|
|||
/** |
|||
* form表单 配置item类型 枚举 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 |
|||
*/ |
|||
public enum FormItemTypeEnum { |
|||
//枚举类型
|
|||
INPUT("input", "输入框"), |
|||
RADIO("radio", "单选框"), |
|||
CHECKBOX("checkbox", "复选框"), |
|||
SELECT("select", "下拉框"), |
|||
TEXTAREA("textarea", "文本域"), |
|||
CASCADER("cascader", "及联"), |
|||
DATE_PICKER("datepicker", "组织"), |
|||
UN_KNOWN("un_known", "不支持的类型"); |
|||
|
|||
private String code; |
|||
private String desc; |
|||
|
|||
FormItemTypeEnum(String value,String name) { |
|||
this.code = value; |
|||
this.desc = name; |
|||
} |
|||
|
|||
public static FormItemTypeEnum getEnum(String code) { |
|||
FormItemTypeEnum[] values = FormItemTypeEnum.values(); |
|||
for (FormItemTypeEnum value : values) { |
|||
if (value.getCode().equals(code)) { |
|||
return value; |
|||
} |
|||
} |
|||
return UN_KNOWN; |
|||
} |
|||
|
|||
public String getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public String getDesc() { |
|||
return desc; |
|||
} |
|||
} |
@ -0,0 +1,44 @@ |
|||
package com.epmet.commons.tools.enums; |
|||
|
|||
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|||
|
|||
public enum GenderEnum { |
|||
MAN("1", "男"), |
|||
WOMAN("2", "女"), |
|||
UN_KNOWN("0", "未知"); |
|||
|
|||
private String code; |
|||
private String name; |
|||
|
|||
|
|||
GenderEnum(String code, String name) { |
|||
this.code = code; |
|||
this.name = name; |
|||
} |
|||
|
|||
public static String getName(String code) { |
|||
GenderEnum[] genderEnums = values(); |
|||
for (GenderEnum genderEnum : genderEnums) { |
|||
if (genderEnum.getCode() == code) { |
|||
return genderEnum.getName(); |
|||
} |
|||
} |
|||
return EpmetErrorCode.SERVER_ERROR.getMsg(); |
|||
} |
|||
|
|||
public String getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public void setCode(String code) { |
|||
this.code = code; |
|||
} |
|||
|
|||
public String getName() { |
|||
return name; |
|||
} |
|||
|
|||
public void setName(String name) { |
|||
this.name = name; |
|||
} |
|||
} |
@ -0,0 +1,45 @@ |
|||
package com.epmet.commons.tools.enums; |
|||
|
|||
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|||
|
|||
public enum HouseTypeEnum { |
|||
//房屋类型,1楼房,2平房,3别墅
|
|||
LOUFANG("1", "楼房"), |
|||
PINGFANG("2", "平房"), |
|||
BIESHU("3", "别墅"); |
|||
|
|||
private String code; |
|||
private String name; |
|||
|
|||
|
|||
HouseTypeEnum(String code, String name) { |
|||
this.code = code; |
|||
this.name = name; |
|||
} |
|||
|
|||
public static String getName(String code) { |
|||
HouseTypeEnum[] houseTypeEnums = values(); |
|||
for (HouseTypeEnum houseTypeEnum : houseTypeEnums) { |
|||
if (houseTypeEnum.getCode() == code) { |
|||
return houseTypeEnum.getName(); |
|||
} |
|||
} |
|||
return EpmetErrorCode.SERVER_ERROR.getMsg(); |
|||
} |
|||
|
|||
public String getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public void setCode(String code) { |
|||
this.code = code; |
|||
} |
|||
|
|||
public String getName() { |
|||
return name; |
|||
} |
|||
|
|||
public void setName(String name) { |
|||
this.name = name; |
|||
} |
|||
} |
@ -0,0 +1,59 @@ |
|||
package com.epmet.commons.tools.enums; |
|||
|
|||
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|||
|
|||
/** |
|||
* @author Administrator |
|||
*/ |
|||
public enum PartyUnitTypeEnum { |
|||
//房屋类型,1楼房,2平房,3别墅
|
|||
LOUYU("0", "楼宇党建"), |
|||
ZUZHI("1", "两新组织"), |
|||
DANWEI("2", "区域单位党建"), |
|||
JIGUAN("3", "机关直属部门"), |
|||
QITA("4", "其他"); |
|||
private String code; |
|||
private String name; |
|||
|
|||
|
|||
PartyUnitTypeEnum(String code, String name) { |
|||
this.code = code; |
|||
this.name = name; |
|||
} |
|||
|
|||
public static String getName(String code) { |
|||
PartyUnitTypeEnum[] houseTypeEnums = values(); |
|||
for (PartyUnitTypeEnum houseTypeEnum : houseTypeEnums) { |
|||
if (houseTypeEnum.getCode() == code) { |
|||
return houseTypeEnum.getName(); |
|||
} |
|||
} |
|||
return EpmetErrorCode.SERVER_ERROR.getMsg(); |
|||
} |
|||
|
|||
public static String getCode(String name) { |
|||
PartyUnitTypeEnum[] houseTypeEnums = values(); |
|||
for (PartyUnitTypeEnum houseTypeEnum : houseTypeEnums) { |
|||
if (houseTypeEnum.getName().equals(name)) { |
|||
return houseTypeEnum.getCode(); |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
public String getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public void setCode(String code) { |
|||
this.code = code; |
|||
} |
|||
|
|||
public String getName() { |
|||
return name; |
|||
} |
|||
|
|||
public void setName(String name) { |
|||
this.name = name; |
|||
} |
|||
} |
@ -0,0 +1,58 @@ |
|||
package com.epmet.commons.tools.enums; |
|||
|
|||
/** |
|||
* @author Administrator |
|||
*/ |
|||
|
|||
public enum RelationshipEnum { |
|||
/** |
|||
* 环境变量枚举 |
|||
*/ |
|||
UN_KNOWN("0", "暂不清楚", 0), |
|||
SELF("1", "本人", 1), |
|||
spouse("2", "配偶", 2), |
|||
CHILD("3", "子女", 3), |
|||
PARENT("4", "父母", 4), |
|||
PARENT_IN_LAW("5", "岳父母或公婆", 5), |
|||
GRANDPARENT_IN_LAW("6", "祖父母", 6), |
|||
CHILD_IN_LAW("7", "媳婿", 7), |
|||
GRANDCHILD("8", "孙子女", 8), |
|||
BROTHER_AND_SISTER("9", "兄弟姐妹", 9), |
|||
OTHER("10", "其他", 10), |
|||
; |
|||
|
|||
private final String code; |
|||
private final String name; |
|||
private final Integer sort; |
|||
|
|||
|
|||
|
|||
RelationshipEnum(String code, String name, Integer sort) { |
|||
this.code = code; |
|||
this.name = name; |
|||
this.sort = sort; |
|||
} |
|||
|
|||
public static RelationshipEnum getEnum(String code) { |
|||
RelationshipEnum[] values = RelationshipEnum.values(); |
|||
for (RelationshipEnum value : values) { |
|||
if (value.getCode().equals(code)) { |
|||
return value; |
|||
} |
|||
} |
|||
return RelationshipEnum.UN_KNOWN; |
|||
} |
|||
|
|||
|
|||
public String getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public String getName() { |
|||
return name; |
|||
} |
|||
|
|||
public Integer getSort(){ |
|||
return sort; |
|||
} |
|||
} |
@ -0,0 +1,96 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* <p> |
|||
* https://www.renren.io
|
|||
* <p> |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.epmet.commons.tools.exception; |
|||
|
|||
|
|||
import com.epmet.commons.tools.constant.StrConstant; |
|||
import com.epmet.commons.tools.utils.MessageUtils; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
|
|||
/** |
|||
* Epmet产品 自定义异常 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 |
|||
*/ |
|||
public class EpmetException extends RuntimeException { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
/** |
|||
* desc:错误码 |
|||
*/ |
|||
protected int code; |
|||
/** |
|||
* 显示给客户的消息 |
|||
*/ |
|||
protected String msg; |
|||
/** |
|||
* 内部消息,用于服务之间传递错误信息,排错用 |
|||
*/ |
|||
protected String internalMsg; |
|||
|
|||
/** |
|||
* desc:指定错误码异常 外部异常内容为错误码对应的异常 |
|||
* @param code |
|||
*/ |
|||
public EpmetException(int code) { |
|||
this(code, StrConstant.EPMETY_STR); |
|||
} |
|||
|
|||
/** |
|||
* desc:指定内部错误消息的异常 外部异常内容为错误码对应的异常 |
|||
* @param code |
|||
* @param internalMsg |
|||
*/ |
|||
public EpmetException(int code, String internalMsg) { |
|||
super(internalMsg); |
|||
this.code = code; |
|||
if (StringUtils.isBlank(internalMsg)) { |
|||
this.internalMsg = EpmetErrorCode.getMsg(code); |
|||
if (StringUtils.isBlank(this.internalMsg)) { |
|||
this.internalMsg = MessageUtils.getMessage(code, internalMsg); |
|||
} |
|||
} else { |
|||
this.internalMsg = internalMsg; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* desc:指定错误码 内外部错误消息异常 |
|||
* @param code |
|||
* @param internalMsg |
|||
* @param externalMsg |
|||
*/ |
|||
public EpmetException(int code, String internalMsg, String externalMsg) { |
|||
this(code, internalMsg); |
|||
this.msg = externalMsg; |
|||
} |
|||
|
|||
/** |
|||
* desc:指定内部消息异常 外部错误码及消息为8000,服务器开小差 |
|||
* @param internalMsg |
|||
*/ |
|||
public EpmetException(String internalMsg) { |
|||
super(internalMsg); |
|||
this.code = EpmetErrorCode.SERVER_ERROR.getCode(); |
|||
this.internalMsg = internalMsg; |
|||
} |
|||
|
|||
public int getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public String getMsg() { |
|||
return msg; |
|||
} |
|||
|
|||
public String getInternalMsg() { |
|||
return internalMsg; |
|||
} |
|||
} |
@ -0,0 +1,35 @@ |
|||
package com.epmet.commons.tools.feign; |
|||
|
|||
import feign.RequestInterceptor; |
|||
import feign.RequestTemplate; |
|||
import org.springframework.web.context.request.RequestAttributes; |
|||
import org.springframework.web.context.request.RequestContextHolder; |
|||
import org.springframework.web.context.request.ServletRequestAttributes; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import java.util.Enumeration; |
|||
|
|||
|
|||
public class EpmetBaseRequestInterceptor implements RequestInterceptor { |
|||
|
|||
@Override |
|||
public void apply(RequestTemplate template) { |
|||
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); |
|||
if (requestAttributes == null) { |
|||
return; |
|||
} |
|||
|
|||
HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest(); |
|||
Enumeration<String> headerNames = request.getHeaderNames(); |
|||
if (headerNames != null) { |
|||
while (headerNames.hasMoreElements()) { |
|||
String name = headerNames.nextElement(); |
|||
Enumeration<String> values = request.getHeaders(name); |
|||
while (values.hasMoreElements()) { |
|||
String value = values.nextElement(); |
|||
template.header(name, value); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,93 @@ |
|||
package com.epmet.commons.tools.redis.common; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import com.alibaba.fastjson.JSON; |
|||
import com.epmet.commons.tools.exception.RenException; |
|||
import com.epmet.commons.tools.feign.CommonAggFeignClient; |
|||
import com.epmet.commons.tools.redis.RedisKeys; |
|||
import com.epmet.commons.tools.redis.RedisUtils; |
|||
import com.epmet.commons.tools.redis.common.bean.*; |
|||
import com.epmet.commons.tools.utils.ConvertUtils; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.util.CollectionUtils; |
|||
|
|||
import javax.annotation.PostConstruct; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2021/11/5 2:29 下午 |
|||
* @DESC |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
public class CustomerOrgRedis { |
|||
|
|||
@Autowired |
|||
private RedisUtils redisUtils; |
|||
|
|||
@Autowired |
|||
private CommonAggFeignClient commonAggFeignClient; |
|||
|
|||
private static CustomerOrgRedis customerOrgRedis; |
|||
private static final String ROLE_MAP_KEY = "roleMap"; |
|||
|
|||
@PostConstruct |
|||
public void init() { |
|||
customerOrgRedis = this; |
|||
customerOrgRedis.redisUtils = this.redisUtils; |
|||
customerOrgRedis.commonAggFeignClient = this.commonAggFeignClient; |
|||
} |
|||
|
|||
/** |
|||
* @Description 获取网格信息 |
|||
* @param gridId |
|||
* @author zxc |
|||
* @date 2021/11/5 3:12 下午 |
|||
*/ |
|||
public static GridInfoCache getGridInfo(String gridId){ |
|||
String key = RedisKeys.getGridInfoKey(gridId); |
|||
Map<String, Object> grid = customerOrgRedis.redisUtils.hGetAll(key); |
|||
if (!CollectionUtils.isEmpty(grid)) { |
|||
return ConvertUtils.mapToEntity(grid, GridInfoCache.class); |
|||
} |
|||
Result<GridInfoCache> gridInfoResult = customerOrgRedis.commonAggFeignClient.getGridInfo(gridId); |
|||
if (!gridInfoResult.success()){ |
|||
throw new RenException("查询网格信息失败..."); |
|||
} |
|||
if (null == gridInfoResult.getData()){ |
|||
throw new RenException("没有此网格信息..."); |
|||
} |
|||
Map<String, Object> map = BeanUtil.beanToMap(gridInfoResult.getData(), false, true); |
|||
customerOrgRedis.redisUtils.hMSet(key, map); |
|||
return gridInfoResult.getData(); |
|||
} |
|||
|
|||
/** |
|||
* @Description 获取组织信息 |
|||
* @param agencyId |
|||
* @author zxc |
|||
* @date 2021/11/5 3:12 下午 |
|||
*/ |
|||
public static AgencyInfoCache getAgencyInfo(String agencyId){ |
|||
String key = RedisKeys.getAgencyByIdKey(agencyId); |
|||
Map<String, Object> agency = customerOrgRedis.redisUtils.hGetAll(key); |
|||
if (!CollectionUtils.isEmpty(agency)) { |
|||
return ConvertUtils.mapToEntity(agency, AgencyInfoCache.class); |
|||
} |
|||
Result<AgencyInfoCache> agencyInfoResult = customerOrgRedis.commonAggFeignClient.getAgencyInfo(agencyId); |
|||
if (!agencyInfoResult.success()){ |
|||
throw new RenException("查询组织信息失败..."); |
|||
} |
|||
if (null == agencyInfoResult.getData()){ |
|||
throw new RenException("没有此组织信息..."); |
|||
} |
|||
Map<String, Object> map = BeanUtil.beanToMap(agencyInfoResult.getData(), false, true); |
|||
customerOrgRedis.redisUtils.hMSet(key, map); |
|||
return agencyInfoResult.getData(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,142 @@ |
|||
package com.epmet.commons.tools.redis.common.bean; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2021/11/5 2:45 下午 |
|||
* @DESC |
|||
*/ |
|||
@Data |
|||
public class AgencyInfoCache implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -1332373159954084159L; |
|||
|
|||
/** |
|||
* ID |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 客户ID |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 上级组织机构ID |
|||
*/ |
|||
private String pid; |
|||
|
|||
/** |
|||
* 所有上级组织机构ID(以英文:隔开) |
|||
*/ |
|||
private String pids; |
|||
|
|||
/** |
|||
* 所有上级名称,以-连接 |
|||
*/ |
|||
private String allParentName; |
|||
|
|||
/** |
|||
* 组织名称 |
|||
*/ |
|||
private String organizationName; |
|||
|
|||
/** |
|||
* 机关级别(社区级:community, |
|||
乡(镇、街道)级:street, |
|||
区县级: district, |
|||
市级: city |
|||
省级:province) 机关级别(社区级:community,乡(镇、街道)级:street,区县级: district,市级: city省级:province) |
|||
*/ |
|||
private String level; |
|||
|
|||
/** |
|||
* 地区编码 |
|||
*/ |
|||
private String areaCode; |
|||
|
|||
/** |
|||
* 删除标识 |
|||
*/ |
|||
private String delFlag; |
|||
|
|||
/** |
|||
* 乐观锁 |
|||
*/ |
|||
private Integer revision; |
|||
|
|||
/** |
|||
* 创建人 |
|||
*/ |
|||
private String createdBy; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createdTime; |
|||
|
|||
/** |
|||
* 更新人 |
|||
*/ |
|||
private String updatedBy; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
private Date updatedTime; |
|||
|
|||
/** |
|||
* 总人数 |
|||
*/ |
|||
private Integer totalUser; |
|||
|
|||
/** |
|||
* 省 |
|||
*/ |
|||
private String province; |
|||
|
|||
/** |
|||
* 市 |
|||
*/ |
|||
private String city; |
|||
|
|||
/** |
|||
* 区县 |
|||
*/ |
|||
private String district; |
|||
|
|||
/** |
|||
* 当前组织的上级行政地区编码add0204;举例平阴县对应的是济南市3701 |
|||
*/ |
|||
private String parentAreaCode; |
|||
|
|||
/** |
|||
* 街道 |
|||
*/ |
|||
private String street; |
|||
|
|||
/** |
|||
* 社区 |
|||
*/ |
|||
private String community; |
|||
|
|||
/** |
|||
* 坐标区域 |
|||
*/ |
|||
private String coordinates; |
|||
|
|||
|
|||
/** |
|||
* 中心位置经度 |
|||
*/ |
|||
private String longitude; |
|||
|
|||
/** |
|||
* 中心位置纬度 |
|||
*/ |
|||
private String latitude; |
|||
} |
@ -0,0 +1,116 @@ |
|||
package com.epmet.commons.tools.redis.common.bean; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2021/11/5 2:24 下午 |
|||
* @DESC |
|||
*/ |
|||
@Data |
|||
public class GridInfoCache implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -6159429894486235267L; |
|||
|
|||
|
|||
/** |
|||
* ID 唯一标识 |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 客户ID |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 网格名称 |
|||
*/ |
|||
private String gridName; |
|||
|
|||
/** 组织-网格 */ |
|||
private String gridNamePath; |
|||
|
|||
/** |
|||
* 中心位置经度 |
|||
*/ |
|||
private String longitude; |
|||
|
|||
/** |
|||
* 中心位置纬度 |
|||
*/ |
|||
private String latitude; |
|||
|
|||
/** |
|||
* 所属地区码(所属组织地区码) |
|||
*/ |
|||
private String areaCode; |
|||
|
|||
/** |
|||
* 删除标识:0.未删除 1.已删除 |
|||
*/ |
|||
private Integer delFlag; |
|||
|
|||
/** |
|||
* 乐观锁 |
|||
*/ |
|||
private Integer revision; |
|||
|
|||
/** |
|||
* 创建人 |
|||
*/ |
|||
private String createdBy; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createdTime; |
|||
|
|||
/** |
|||
* 更新人 |
|||
*/ |
|||
private String updatedBy; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
private Date updatedTime; |
|||
|
|||
/** |
|||
* 管辖区域 |
|||
*/ |
|||
private String manageDistrict; |
|||
|
|||
/** |
|||
* 当前网格总人数 |
|||
*/ |
|||
private Integer totalUser; |
|||
|
|||
/** |
|||
* 所属组织机构ID(customer_organization.id) |
|||
*/ |
|||
private String pid; |
|||
|
|||
/** |
|||
* 所有上级组织ID |
|||
*/ |
|||
private String pids; |
|||
|
|||
/** |
|||
* 所属组织机构名 |
|||
*/ |
|||
private String agencyName; |
|||
|
|||
/** |
|||
* 所有上级组织名 |
|||
*/ |
|||
private String allParentName; |
|||
|
|||
/** |
|||
* 坐标区域 |
|||
*/ |
|||
private String coordinates; |
|||
} |
@ -0,0 +1,81 @@ |
|||
package com.epmet.commons.tools.security.dto; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
import java.util.List; |
|||
import java.util.Set; |
|||
|
|||
/** |
|||
* @Description ic平台token |
|||
* @author wxz |
|||
* @date 2021.10.26 13:58:03 |
|||
*/ |
|||
@Data |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
public class IcTokenDto extends BaseTokenDto { |
|||
|
|||
/** |
|||
* 当前登录的组织id(顶级) |
|||
*/ |
|||
private String rootAgencyId; |
|||
|
|||
/** |
|||
* 当前用户所属的机关单位id |
|||
*/ |
|||
private String agencyId; |
|||
|
|||
/** |
|||
* 当前网格对应的组织结构id的全路径用:隔开 |
|||
*/ |
|||
private String orgIdPath; |
|||
|
|||
/** |
|||
* 当前所在网格id |
|||
*/ |
|||
private String gridId; |
|||
|
|||
/*** |
|||
* 所在网格列表 |
|||
*/ |
|||
private Set<String> gridIdList; |
|||
|
|||
/** |
|||
* 部门id列表 |
|||
*/ |
|||
private Set<String> deptIdList; |
|||
|
|||
/** |
|||
* 功能权限列表,实际上是gov_staff => staff_role => role_operation查询到的operationKey |
|||
*/ |
|||
private Set<String> permissions; |
|||
|
|||
/** |
|||
* 角色ID列表 |
|||
*/ |
|||
private List<GovTokenDto.Role> roleList; |
|||
|
|||
/** |
|||
* 过期时间戳 |
|||
*/ |
|||
private Long expireTime; |
|||
|
|||
@Data |
|||
public static class Role { |
|||
|
|||
private String id; |
|||
private String roleKey; |
|||
private String roleName; |
|||
|
|||
public Role() { |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
return JSON.toJSONString(this); |
|||
} |
|||
} |
@ -0,0 +1,276 @@ |
|||
package com.epmet.commons.tools.utils; |
|||
|
|||
import cn.afterturn.easypoi.excel.ExcelExportUtil; |
|||
import cn.afterturn.easypoi.excel.ExcelImportUtil; |
|||
import cn.afterturn.easypoi.excel.entity.ExportParams; |
|||
import cn.afterturn.easypoi.excel.entity.ImportParams; |
|||
import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
|||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; |
|||
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.apache.poi.ss.usermodel.Workbook; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.io.File; |
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
import java.net.URLEncoder; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.NoSuchElementException; |
|||
|
|||
public class ExcelPoiUtils { |
|||
/** |
|||
* excel 导出 |
|||
* |
|||
* @param list 数据列表 |
|||
* @param fileName 导出时的excel名称 |
|||
* @param response |
|||
*/ |
|||
public static void exportExcel(List<Map<String, Object>> list, String fileName, HttpServletResponse response) throws IOException { |
|||
defaultExport(list, fileName, response); |
|||
} |
|||
|
|||
/** |
|||
* 默认的 excel 导出 |
|||
* |
|||
* @param list 数据列表 |
|||
* @param fileName 导出时的excel名称 |
|||
* @param response |
|||
*/ |
|||
private static void defaultExport(List<Map<String, Object>> list, String fileName, HttpServletResponse response) throws IOException { |
|||
//把数据添加到excel表格中
|
|||
Workbook workbook = ExcelExportUtil.exportExcel(list, ExcelType.HSSF); |
|||
downLoadExcel(fileName, response, workbook); |
|||
} |
|||
|
|||
/** |
|||
* excel 导出 |
|||
* |
|||
* @param list 数据列表 |
|||
* @param pojoClass pojo类型 |
|||
* @param fileName 导出时的excel名称 |
|||
* @param response |
|||
* @param exportParams 导出参数(标题、sheet名称、是否创建表头,表格类型) |
|||
*/ |
|||
private static void defaultExport(List<?> list, Class<?> pojoClass, String fileName, HttpServletResponse response, ExportParams exportParams) throws IOException { |
|||
//把数据添加到excel表格中
|
|||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, pojoClass, list); |
|||
downLoadExcel(fileName, response, workbook); |
|||
} |
|||
|
|||
/** |
|||
* excel 导出 |
|||
* |
|||
* @param list 数据列表 |
|||
* @param pojoClass pojo类型 |
|||
* @param fileName 导出时的excel名称 |
|||
* @param exportParams 导出参数(标题、sheet名称、是否创建表头,表格类型) |
|||
* @param response |
|||
*/ |
|||
public static void exportExcel(List<?> list, Class<?> pojoClass, String fileName, ExportParams exportParams, HttpServletResponse response) throws IOException { |
|||
defaultExport(list, pojoClass, fileName, response, exportParams); |
|||
} |
|||
|
|||
/** |
|||
* excel 导出 |
|||
* |
|||
* @param list 数据列表 |
|||
* @param title 表格内数据标题 |
|||
* @param sheetName sheet名称 |
|||
* @param pojoClass pojo类型 |
|||
* @param fileName 导出时的excel名称 |
|||
* @param response |
|||
*/ |
|||
public static void exportExcel(List<?> list, String title, String sheetName, Class<?> pojoClass, String fileName, HttpServletResponse response) throws IOException { |
|||
defaultExport(list, pojoClass, fileName, response, new ExportParams(title, sheetName, ExcelType.XSSF)); |
|||
} |
|||
|
|||
|
|||
|
|||
/** |
|||
* excel 导出 |
|||
* |
|||
* @param list 数据列表 |
|||
* @param title 表格内数据标题 |
|||
* @param sheetName sheet名称 |
|||
* @param pojoClass pojo类型 |
|||
* @param fileName 导出时的excel名称 |
|||
* @param isCreateHeader 是否创建表头 |
|||
* @param response |
|||
*/ |
|||
public static void exportExcel(List<?> list, String title, String sheetName, Class<?> pojoClass, String fileName, boolean isCreateHeader, HttpServletResponse response) throws IOException { |
|||
ExportParams exportParams = new ExportParams(title, sheetName, ExcelType.XSSF); |
|||
exportParams.setCreateHeadRows(isCreateHeader); |
|||
defaultExport(list, pojoClass, fileName, response, exportParams); |
|||
} |
|||
/** |
|||
* 根据模板生成excel后导出 |
|||
* @param templatePath 模板路径 |
|||
* @param map 数据集合 |
|||
* @param fileName 文件名 |
|||
* @param response |
|||
* @throws IOException |
|||
*/ |
|||
public static void exportExcel(TemplateExportParams templatePath, Map<String, Object> map, String fileName, HttpServletResponse response) throws IOException { |
|||
Workbook workbook = ExcelExportUtil.exportExcel(templatePath, map); |
|||
downLoadExcel(fileName, response, workbook); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* excel下载 |
|||
* |
|||
* @param fileName 下载时的文件名称 |
|||
* @param response |
|||
* @param workbook excel数据 |
|||
*/ |
|||
private static void downLoadExcel(String fileName, HttpServletResponse response, Workbook workbook) throws IOException { |
|||
try { |
|||
response.setCharacterEncoding("UTF-8"); |
|||
response.setHeader("content-Type", "application/vnd.ms-excel"); |
|||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName + ".xlsx", "UTF-8")); |
|||
workbook.write(response.getOutputStream()); |
|||
} catch (Exception e) { |
|||
throw new IOException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
/** |
|||
* excel 导入 |
|||
* |
|||
* @param file excel文件 |
|||
* @param pojoClass pojo类型 |
|||
* @param <T> |
|||
* @return |
|||
*/ |
|||
public static <T> List<T> importExcel(MultipartFile file, Class<T> pojoClass) throws IOException { |
|||
return importExcel(file, 1, 1, pojoClass); |
|||
} |
|||
|
|||
/** |
|||
* excel 导入 |
|||
* |
|||
* @param filePath excel文件路径 |
|||
* @param titleRows 表格内数据标题行 |
|||
* @param headerRows 表头行 |
|||
* @param pojoClass pojo类型 |
|||
* @param <T> |
|||
* @return |
|||
*/ |
|||
public static <T> List<T> importExcel(String filePath, Integer titleRows, Integer headerRows, Class<T> pojoClass) throws IOException { |
|||
if (StringUtils.isBlank(filePath)) { |
|||
return null; |
|||
} |
|||
ImportParams params = new ImportParams(); |
|||
params.setTitleRows(titleRows); |
|||
params.setHeadRows(headerRows); |
|||
params.setNeedSave(true); |
|||
params.setSaveUrl("/tmp/excel/"); |
|||
try { |
|||
return ExcelImportUtil.importExcel(new File(filePath), pojoClass, params); |
|||
} catch (NoSuchElementException e) { |
|||
throw new IOException("模板不能为空"); |
|||
} catch (Exception e) { |
|||
throw new IOException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* excel 导入 |
|||
* |
|||
* @param file 上传的文件 |
|||
* @param titleRows 表格内数据标题行 |
|||
* @param headerRows 表头行 |
|||
* @param pojoClass pojo类型 |
|||
* @param <T> |
|||
* @return |
|||
*/ |
|||
public static <T> List<T> importExcel(MultipartFile file, Integer titleRows, Integer headerRows, Class<T> pojoClass) throws IOException { |
|||
if (file == null) { |
|||
return null; |
|||
} |
|||
try { |
|||
return importExcel(file.getInputStream(), titleRows, headerRows, pojoClass); |
|||
} catch (Exception e) { |
|||
throw new IOException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* excel 导入 |
|||
* |
|||
* @param inputStream 文件输入流 |
|||
* @param titleRows 表格内数据标题行 |
|||
* @param headerRows 表头行 |
|||
* @param pojoClass pojo类型 |
|||
* @param <T> |
|||
* @return |
|||
*/ |
|||
public static <T> List<T> importExcel(InputStream inputStream, Integer titleRows, Integer headerRows, Class<T> pojoClass) throws IOException { |
|||
if (inputStream == null) { |
|||
return null; |
|||
} |
|||
ImportParams params = new ImportParams(); |
|||
params.setTitleRows(titleRows); |
|||
params.setHeadRows(headerRows); |
|||
params.setSaveUrl("/tmp/excel/"); |
|||
params.setNeedSave(true); |
|||
try { |
|||
return ExcelImportUtil.importExcel(inputStream, pojoClass, params); |
|||
} catch (NoSuchElementException e) { |
|||
throw new IOException("excel文件不能为空"); |
|||
} catch (Exception e) { |
|||
throw new IOException(e.getMessage()); |
|||
} |
|||
} |
|||
/** |
|||
* excel 导入,有错误信息 |
|||
* |
|||
* @param file 上传的文件 |
|||
* @param pojoClass pojo类型 |
|||
* @param <T> |
|||
* @return |
|||
*/ |
|||
public static <T> ExcelImportResult<T> importExcelMore(MultipartFile file,Integer titleRows, Integer headerRows, Class<T> pojoClass) throws IOException { |
|||
if (file == null) { |
|||
return null; |
|||
} |
|||
try { |
|||
return importExcelMore(file.getInputStream(), titleRows, headerRows, pojoClass); |
|||
} catch (Exception e) { |
|||
throw new IOException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* excel 导入 |
|||
* |
|||
* @param inputStream 文件输入流 |
|||
* @param pojoClass pojo类型 |
|||
* @param <T> |
|||
* @return |
|||
*/ |
|||
private static <T> ExcelImportResult<T> importExcelMore(InputStream inputStream,Integer titleRows, Integer headerRows, Class<T> pojoClass) throws IOException { |
|||
if (inputStream == null) { |
|||
return null; |
|||
} |
|||
ImportParams params = new ImportParams(); |
|||
params.setTitleRows(titleRows);//表格内数据标题行
|
|||
params.setHeadRows(headerRows);//表头行
|
|||
params.setSaveUrl("/tmp/excel/"); |
|||
params.setNeedSave(true); |
|||
params.setNeedVerify(true); |
|||
try { |
|||
return ExcelImportUtil.importExcelMore(inputStream, pojoClass, params); |
|||
} catch (NoSuchElementException e) { |
|||
throw new IOException("excel文件不能为空"); |
|||
} catch (Exception e) { |
|||
throw new IOException(e.getMessage()); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,31 @@ |
|||
package com.epmet.commons.tools.utils; |
|||
|
|||
import cn.afterturn.easypoi.handler.inter.IExcelDataModel; |
|||
import cn.afterturn.easypoi.handler.inter.IExcelModel; |
|||
|
|||
public class ExcelVerifyInfo implements IExcelModel, IExcelDataModel { |
|||
|
|||
private String errorMsg; |
|||
|
|||
private int rowNum; |
|||
|
|||
@Override |
|||
public Integer getRowNum() { |
|||
return rowNum; |
|||
} |
|||
|
|||
@Override |
|||
public void setRowNum(Integer rowNum) { |
|||
this.rowNum = rowNum; |
|||
} |
|||
|
|||
@Override |
|||
public String getErrorMsg() { |
|||
return errorMsg; |
|||
} |
|||
|
|||
@Override |
|||
public void setErrorMsg(String errorMsg) { |
|||
this.errorMsg = errorMsg; |
|||
} |
|||
} |
@ -0,0 +1,21 @@ |
|||
package com.epmet.dataaggre.dto.datastats.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Description 项目月数据-接口返参 |
|||
* @Auth sun |
|||
*/ |
|||
@Data |
|||
public class FactAgencyProjectMonthResultDTO implements Serializable { |
|||
private static final long serialVersionUID = 466974582608407121L; |
|||
//组织Id
|
|||
private String agencyId; |
|||
//月维度Id
|
|||
private String monthId; |
|||
//当月项目总数 【当前组织及下级前一月新增项目数】
|
|||
private Integer projectIncr = 0; |
|||
|
|||
} |
@ -0,0 +1,35 @@ |
|||
package com.epmet.dataaggre.dto.datastats.result; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonIgnore; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* @Description 项目总数-接口返参 |
|||
* @Auth sun |
|||
*/ |
|||
@Data |
|||
public class FactAgencyProjectResultDTO implements Serializable { |
|||
private static final long serialVersionUID = 466974582608407121L; |
|||
@JsonIgnore |
|||
BigDecimal bi = new BigDecimal(0); |
|||
//组织Id
|
|||
private String agencyId; |
|||
//组织名称
|
|||
private String dateId; |
|||
//月维度Id
|
|||
private String monthId; |
|||
//项目总数
|
|||
private Integer projectTotal = 0; |
|||
//处理中项目数
|
|||
private Integer pendingTotal = 0; |
|||
//处理中项目占比
|
|||
private String pendingRatio = "0%"; |
|||
//已结案中项目数
|
|||
private Integer closedTotal = 0; |
|||
//已结案中项目占比
|
|||
private String closedRatio = "0%"; |
|||
|
|||
} |
@ -0,0 +1,16 @@ |
|||
package com.epmet.dataaggre.dto.epmetuser; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @Description TODO |
|||
* @Author yinzuomei |
|||
* @Date 2021/10/27 4:26 下午 |
|||
*/ |
|||
@Data |
|||
public class IcFormResColumnDTO { |
|||
private String tableName; |
|||
private String columnName; |
|||
private String label; |
|||
} |
|||
|
@ -0,0 +1,93 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.dataaggre.dto.govissue; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
|
|||
/** |
|||
* 议题项目分类字典 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2020-12-08 |
|||
*/ |
|||
@Data |
|||
public class IssueProjectCategoryDictDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 主键 |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 客户id, 产品默认default |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 上级分类ID 顶级此列存储0 |
|||
*/ |
|||
private String pid; |
|||
|
|||
/** |
|||
* 所有上级分类ID,用逗号分开 |
|||
*/ |
|||
private String pids; |
|||
|
|||
/** |
|||
* 上级分类编码 |
|||
*/ |
|||
private String parentCategoryCode; |
|||
|
|||
/** |
|||
* 分类编码,分类编码+customer_id唯一 |
|||
*/ |
|||
private String categoryCode; |
|||
|
|||
/** |
|||
* 分类名称 |
|||
*/ |
|||
private String categoryName; |
|||
|
|||
/** |
|||
* 分类类别1,2,3,4.... |
|||
*/ |
|||
private String categoryType; |
|||
|
|||
/** |
|||
* 排序 |
|||
*/ |
|||
private Integer sort; |
|||
|
|||
/** |
|||
* 是否禁用(enable:启用 disable:禁用) |
|||
*/ |
|||
private String isDisable; |
|||
|
|||
/** |
|||
* 颜色 |
|||
*/ |
|||
private String color; |
|||
|
|||
|
|||
} |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue