50 changed files with 1457 additions and 14 deletions
@ -0,0 +1,49 @@ |
|||
package com.epmet.commons.tools.utils.net; |
|||
|
|||
import com.tencentcloudapi.ccc.v20200210.CccClient; |
|||
import com.tencentcloudapi.ccc.v20200210.models.CreateSDKLoginTokenRequest; |
|||
import com.tencentcloudapi.ccc.v20200210.models.CreateSDKLoginTokenResponse; |
|||
import com.tencentcloudapi.common.Credential; |
|||
import com.tencentcloudapi.common.exception.TencentCloudSDKException; |
|||
import com.tencentcloudapi.common.profile.ClientProfile; |
|||
import com.tencentcloudapi.common.profile.HttpProfile; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
|
|||
|
|||
@Slf4j |
|||
public class TCCCClientUtils { |
|||
|
|||
private static String SDKAPPID = "1400801042"; |
|||
|
|||
private static String USERID = "286388969@qq.com"; |
|||
|
|||
private static String SECRETID = "AKIDynW4oQr6ED0a2dIn6EC3wgFlDVjrqIbg"; |
|||
|
|||
private static String SECRETKEY = "ymRuDJI8mCRUUPFvQqCPQME0c2MbfaM2"; |
|||
|
|||
public static String getToken() { |
|||
try { |
|||
Credential cred = new Credential(SECRETID, SECRETKEY); |
|||
// 实例化一个http选项,可选的,没有特殊需求可以跳过
|
|||
HttpProfile httpProfile = new HttpProfile(); |
|||
httpProfile.setEndpoint("ccc.ap-shanghai.tencentcloudapi.com"); |
|||
// 实例化一个client选项,可选的,没有特殊需求可以跳过
|
|||
ClientProfile clientProfile = new ClientProfile(); |
|||
clientProfile.setHttpProfile(httpProfile); |
|||
// 实例化要请求产品的client对象,clientProfile是可选的
|
|||
CccClient client = new CccClient(cred, "", clientProfile); |
|||
// 实例化一个请求对象,每个接口都会对应一个request对象
|
|||
CreateSDKLoginTokenRequest req = new CreateSDKLoginTokenRequest(); |
|||
req.setSdkAppId(1400801042L); |
|||
req.setSeatUserId("286388969@qq.com"); |
|||
// 返回的resp是一个CreateSDKLoginTokenResponse的实例,与请求对象对应
|
|||
CreateSDKLoginTokenResponse resp = client.CreateSDKLoginToken(req); |
|||
// 输出json格式的字符串回包
|
|||
System.out.println(CreateSDKLoginTokenResponse.toJsonString(resp)); |
|||
return CreateSDKLoginTokenResponse.toJsonString(resp); |
|||
} catch (TencentCloudSDKException e) { |
|||
log.error(e.toString()); |
|||
return e.toString(); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,24 @@ |
|||
package com.epmet.controller.tccc; |
|||
|
|||
import com.epmet.commons.tools.utils.net.TCCCClientUtils; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
@Slf4j |
|||
@RestController |
|||
@RequestMapping("tccc") |
|||
public class TCCCAuthController { |
|||
|
|||
@RequestMapping("getTcccAuth") |
|||
public String getTcccAuth() { |
|||
try { |
|||
String tcccAuth = TCCCClientUtils.getToken(); |
|||
System.out.println(tcccAuth); |
|||
return tcccAuth; |
|||
} catch (Exception e) { |
|||
log.error(e.toString()); |
|||
return e.toString(); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,74 @@ |
|||
package com.epmet.dto; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
import lombok.Data; |
|||
|
|||
|
|||
/** |
|||
* 文章栏目表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-04-11 |
|||
*/ |
|||
@Data |
|||
public class CategoryDictDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 客户id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 分类栏目名称 |
|||
*/ |
|||
private String categoryName; |
|||
|
|||
/** |
|||
* 父栏目ID |
|||
*/ |
|||
private String pid; |
|||
|
|||
/** |
|||
* 排序 |
|||
*/ |
|||
private Integer sort; |
|||
|
|||
/** |
|||
* 删除标识 0.未删除 1.已删除 |
|||
*/ |
|||
private Integer delFlag; |
|||
|
|||
/** |
|||
* 乐观锁 |
|||
*/ |
|||
private Integer revision; |
|||
|
|||
/** |
|||
* 创建人 |
|||
*/ |
|||
private String createdBy; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createdTime; |
|||
|
|||
/** |
|||
* 更新人 |
|||
*/ |
|||
private String updatedBy; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
private Date updatedTime; |
|||
|
|||
} |
@ -0,0 +1,72 @@ |
|||
package com.epmet.controller; |
|||
|
|||
import com.epmet.commons.tools.aop.NoRepeatSubmit; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.commons.tools.validator.AssertUtils; |
|||
import com.epmet.commons.tools.validator.ValidatorUtils; |
|||
import com.epmet.commons.tools.validator.group.AddGroup; |
|||
import com.epmet.commons.tools.validator.group.UpdateGroup; |
|||
import com.epmet.commons.tools.validator.group.DefaultGroup; |
|||
import com.epmet.dto.CategoryDictDTO; |
|||
import com.epmet.service.CategoryDictService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
/** |
|||
* 文章栏目表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-04-11 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("categoryDict") |
|||
public class CategoryDictController { |
|||
|
|||
@Autowired |
|||
private CategoryDictService categoryDictService; |
|||
|
|||
@RequestMapping("list") |
|||
public Result<List<CategoryDictDTO>> list(@RequestParam Integer pageNo, @RequestParam Integer pageSize){ |
|||
List<CategoryDictDTO> list = categoryDictService.list(pageNo, pageSize); |
|||
return new Result<List<CategoryDictDTO>>().ok(list); |
|||
} |
|||
|
|||
@RequestMapping(value = "{id}",method = {RequestMethod.POST,RequestMethod.GET}) |
|||
public Result<CategoryDictDTO> get(@PathVariable("id") String id){ |
|||
CategoryDictDTO data = categoryDictService.get(id); |
|||
return new Result<CategoryDictDTO>().ok(data); |
|||
} |
|||
|
|||
@NoRepeatSubmit |
|||
@PostMapping("save") |
|||
public Result save(@RequestBody CategoryDictDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
categoryDictService.save(dto); |
|||
return new Result(); |
|||
} |
|||
|
|||
@NoRepeatSubmit |
|||
@PostMapping("update") |
|||
public Result update(@RequestBody CategoryDictDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
categoryDictService.update(dto); |
|||
return new Result(); |
|||
} |
|||
|
|||
@PostMapping("delete") |
|||
public Result delete(@RequestBody String[] ids){ |
|||
//效验数据
|
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
categoryDictService.delete(ids); |
|||
return new Result(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,16 @@ |
|||
package com.epmet.dao; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.entity.CategoryDictEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* 文章栏目表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-04-11 |
|||
*/ |
|||
@Mapper |
|||
public interface CategoryDictDao extends BaseDao<CategoryDictEntity> { |
|||
|
|||
} |
@ -0,0 +1,44 @@ |
|||
package com.epmet.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
|
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 文章栏目表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-04-11 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("category_dict") |
|||
public class CategoryDictEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 客户id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 分类栏目名称 |
|||
*/ |
|||
private String categoryName; |
|||
|
|||
/** |
|||
* 父栏目ID |
|||
*/ |
|||
private String pid; |
|||
|
|||
/** |
|||
* 排序 |
|||
*/ |
|||
private Integer sort; |
|||
|
|||
} |
@ -0,0 +1,88 @@ |
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.commons.mybatis.service.BaseService; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.dto.CategoryDictDTO; |
|||
import com.epmet.entity.CategoryDictEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 文章栏目表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-04-11 |
|||
*/ |
|||
public interface CategoryDictService extends BaseService<CategoryDictEntity> { |
|||
|
|||
/** |
|||
* 默认分页 |
|||
* |
|||
* @param params |
|||
* @return PageData<CategoryDictDTO> |
|||
* @author generator |
|||
* @date 2023-04-11 |
|||
*/ |
|||
PageData<CategoryDictDTO> page(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 默认查询 |
|||
* |
|||
* @param params |
|||
* @return java.util.List<CategoryDictDTO> |
|||
* @author generator |
|||
* @date 2023-04-11 |
|||
*/ |
|||
List<CategoryDictDTO> list(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 单条查询 |
|||
* |
|||
* @param id |
|||
* @return CategoryDictDTO |
|||
* @author generator |
|||
* @date 2023-04-11 |
|||
*/ |
|||
CategoryDictDTO get(String id); |
|||
|
|||
/** |
|||
* 默认保存 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2023-04-11 |
|||
*/ |
|||
void save(CategoryDictDTO dto); |
|||
|
|||
/** |
|||
* 默认更新 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2023-04-11 |
|||
*/ |
|||
void update(CategoryDictDTO dto); |
|||
|
|||
/** |
|||
* 批量删除 |
|||
* |
|||
* @param ids |
|||
* @return void |
|||
* @author generator |
|||
* @date 2023-04-11 |
|||
*/ |
|||
void delete(String[] ids); |
|||
|
|||
/** |
|||
* @description: 列表 |
|||
* @param pageNo: |
|||
* @param pageSize: |
|||
* @return java.util.List<com.epmet.dto.CategoryDictDTO> |
|||
* @author: WangXianZhang |
|||
* @date: 2023/4/11 7:06 PM |
|||
*/ |
|||
List<CategoryDictDTO> list(Integer pageNo, Integer pageSize); |
|||
} |
@ -0,0 +1,149 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.epmet.commons.tools.distributedlock.DistributedLock; |
|||
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|||
import com.epmet.commons.tools.exception.EpmetException; |
|||
import com.epmet.commons.tools.exception.ExceptionUtils; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.commons.tools.utils.ConvertUtils; |
|||
import com.epmet.commons.tools.constant.FieldConstant; |
|||
import com.epmet.commons.tools.utils.EpmetRequestHolder; |
|||
import com.epmet.dao.CategoryDictDao; |
|||
import com.epmet.dto.CategoryDictDTO; |
|||
import com.epmet.entity.CategoryDictEntity; |
|||
import com.epmet.service.CategoryDictService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.redisson.api.RLock; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 文章栏目表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-04-11 |
|||
*/ |
|||
@Service |
|||
public class CategoryDictServiceImpl extends BaseServiceImpl<CategoryDictDao, CategoryDictEntity> implements CategoryDictService { |
|||
|
|||
@Autowired |
|||
private DistributedLock distributedLock; |
|||
|
|||
@Override |
|||
public PageData<CategoryDictDTO> page(Map<String, Object> params) { |
|||
IPage<CategoryDictEntity> page = baseDao.selectPage( |
|||
getPage(params, FieldConstant.CREATED_TIME, false), |
|||
getWrapper(params) |
|||
); |
|||
return getPageData(page, CategoryDictDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<CategoryDictDTO> list(Map<String, Object> params) { |
|||
List<CategoryDictEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, CategoryDictDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<CategoryDictEntity> getWrapper(Map<String, Object> params){ |
|||
String id = (String)params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<CategoryDictEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public CategoryDictDTO get(String id) { |
|||
CategoryDictEntity entity = baseDao.selectById(id); |
|||
return ConvertUtils.sourceToTarget(entity, CategoryDictDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void save(CategoryDictDTO dto) { |
|||
String customerId = EpmetRequestHolder.getLoginUserCustomerId(); |
|||
|
|||
// 重名检查,客户下不能重名
|
|||
LambdaQueryWrapper<CategoryDictEntity> query = new LambdaQueryWrapper<>(); |
|||
query.eq(CategoryDictEntity::getCustomerId, customerId); |
|||
query.eq(CategoryDictEntity::getCategoryName, dto.getCategoryName()); |
|||
|
|||
// 加锁
|
|||
RLock lock = distributedLock.getLock("voice:categorydict"); |
|||
try { |
|||
if (baseDao.selectCount(query) > 0) { |
|||
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "栏目名称已存在"); |
|||
} |
|||
|
|||
dto.setCustomerId(customerId); |
|||
CategoryDictEntity entity = ConvertUtils.sourceToTarget(dto, CategoryDictEntity.class); |
|||
insert(entity); |
|||
|
|||
} catch (EpmetException ee) { |
|||
throw ee; |
|||
} catch (Exception e) { |
|||
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "【文章】新增文章栏目失败:" + ExceptionUtils.getErrorStackTrace(e)); |
|||
} finally { |
|||
// 解锁
|
|||
lock.unlock(); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(CategoryDictDTO dto) { |
|||
String customerId = EpmetRequestHolder.getLoginUserCustomerId(); |
|||
|
|||
// 重名检查,客户下不能重名
|
|||
LambdaQueryWrapper<CategoryDictEntity> query = new LambdaQueryWrapper<>(); |
|||
query.eq(CategoryDictEntity::getCustomerId, customerId); |
|||
query.eq(CategoryDictEntity::getCategoryName, dto.getCategoryName()); |
|||
|
|||
RLock lock = distributedLock.getLock("voice:categorydict"); |
|||
try { |
|||
CategoryDictEntity inDb = null; |
|||
// 能查询到一条数据,并且该条数据的ID不是当前修改的这条数据的ID,说明已存在同名的其他标签,该名字已被其他标签占用
|
|||
if ((inDb = baseDao.selectOne(query)) != null |
|||
&& !inDb.getId().equals(dto.getId())) { |
|||
|
|||
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "栏目名称已存在"); |
|||
} |
|||
|
|||
dto.setCustomerId(customerId); |
|||
CategoryDictEntity entity = ConvertUtils.sourceToTarget(dto, CategoryDictEntity.class); |
|||
updateById(entity); |
|||
|
|||
} catch (EpmetException ee) { |
|||
throw ee; |
|||
} catch (Exception e) { |
|||
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "【文章】新增文章栏目失败:" + ExceptionUtils.getErrorStackTrace(e)); |
|||
} finally { |
|||
// 解锁
|
|||
lock.unlock(); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
// 逻辑删除(@TableLogic 注解)
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
@Override |
|||
public List<CategoryDictDTO> list(Integer pageNo, Integer pageSize) { |
|||
List<CategoryDictEntity> list = baseDao.selectList(null); |
|||
return ConvertUtils.sourceToTarget(list, CategoryDictDTO.class); |
|||
} |
|||
} |
@ -0,0 +1,21 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.epmet.dao.CategoryDictDao"> |
|||
|
|||
<resultMap type="com.epmet.entity.CategoryDictEntity" id="categoryDictMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="customerId" column="CUSTOMER_ID"/> |
|||
<result property="categoryName" column="CATEGORY_NAME"/> |
|||
<result property="pid" column="PID"/> |
|||
<result property="sort" column="SORT"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
</resultMap> |
|||
|
|||
|
|||
</mapper> |
@ -0,0 +1,33 @@ |
|||
package com.epmet.resi.partymember.dto.partymember.result; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonIgnore; |
|||
import lombok.Data; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Collection; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @description: agencyId下的党组织活动数统计 |
|||
* @param null: |
|||
* @return |
|||
* @author: WangXianZhang |
|||
* @date: 2023/4/14 7:09 PM |
|||
*/ |
|||
@Data |
|||
public class LingShanScreenPartyActQtyStatsResultDTO { |
|||
|
|||
private String type; |
|||
|
|||
private Collection<StatsData> data; |
|||
|
|||
@Data |
|||
public static class StatsData { |
|||
@JsonIgnore |
|||
private String orgId; |
|||
private String name; |
|||
@JsonIgnore |
|||
private String actType; |
|||
private Integer value; |
|||
} |
|||
} |
@ -0,0 +1,15 @@ |
|||
package com.epmet.resi.partymember.dto.partymember.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* 灵山大屏,党建活动和数量 |
|||
*/ |
|||
@Data |
|||
public class LingShanScreenPartyActTypeAndQtyResultDTO { |
|||
|
|||
private String actTypeKey; |
|||
private String name; |
|||
private Integer value; |
|||
|
|||
} |
@ -0,0 +1,17 @@ |
|||
package com.epmet.resi.partymember.dto.partymember.result; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
/** |
|||
* 灵山大屏,党组织和数量dto |
|||
*/ |
|||
@Data |
|||
public class LingShanScreenPartyOrgCategoryResultDTO { |
|||
|
|||
private String partyOrgType; |
|||
private String name; |
|||
private Integer value; |
|||
|
|||
} |
@ -0,0 +1,60 @@ |
|||
package com.epmet.resi.partymember.dto.partymember.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 灵山大屏-党组织树 |
|||
*/ |
|||
@Data |
|||
public class LingShanScreenPartyOrgTreeResultDTO { |
|||
|
|||
// 中共青岛市即墨区委灵山街道工作委员会
|
|||
private String title; |
|||
|
|||
private List<PartyOrg> list; |
|||
|
|||
private Integer num; |
|||
|
|||
@Data |
|||
public static class PartyOrg { |
|||
|
|||
private String id; |
|||
private String pid; |
|||
private String name; |
|||
private Integer num; |
|||
private Integer orgType; |
|||
|
|||
/** |
|||
* 子级组织列表 |
|||
*/ |
|||
private List<PartyOrg> children = new ArrayList<>(); |
|||
|
|||
/** |
|||
* 党员列表 |
|||
*/ |
|||
private List<Partymember> list = new ArrayList<>();; |
|||
} |
|||
|
|||
/** |
|||
* @description: 党员信息 |
|||
*/ |
|||
@Data |
|||
public static class Partymember { |
|||
private String name; |
|||
private String gender; |
|||
private String age; |
|||
private String phone; |
|||
private String orgname; |
|||
private String photo; |
|||
private String remarks; |
|||
private Integer workStatus; |
|||
private Integer isDby; |
|||
private Integer isLhdy; |
|||
private Integer worknumber; |
|||
private Integer workEvent; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,120 @@ |
|||
package com.epmet.modules.partymember.controller; |
|||
|
|||
import com.epmet.commons.tools.enums.PartyOrgTypeEnum; |
|||
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|||
import com.epmet.commons.tools.exception.EpmetException; |
|||
import com.epmet.commons.tools.utils.DateUtils; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.modules.partymember.service.LingShanScreenService; |
|||
import com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyActQtyStatsResultDTO; |
|||
import com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyActTypeAndQtyResultDTO; |
|||
import com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyOrgCategoryResultDTO; |
|||
import com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyOrgTreeResultDTO; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
@RestController |
|||
@RequestMapping("lingshanScreen") |
|||
@Slf4j |
|||
public class LingShanScreenController { |
|||
|
|||
@Autowired |
|||
private LingShanScreenService lingShanScreenService; |
|||
|
|||
/** |
|||
* @description: 党建引领,党组织和数量 |
|||
* @param agencyId: 当前组织id |
|||
* @return com.epmet.commons.tools.utils.Result |
|||
* @author: WangXianZhang |
|||
* @date: 2023/4/14 10:57 AM |
|||
*/ |
|||
@GetMapping("partyOrgCategoryAndQuantity") |
|||
public Result<List<LingShanScreenPartyOrgCategoryResultDTO>> listPartyOrgCategoryAndQuantity(@RequestParam("agencyId") String agencyId) { |
|||
List<LingShanScreenPartyOrgCategoryResultDTO> l = lingShanScreenService.listPartyOrgCategoryAndQuantity(agencyId); |
|||
return new Result().ok(l); |
|||
} |
|||
|
|||
/** |
|||
* @description: 党建活动类型和数量 |
|||
* @param agencyId: 组织id |
|||
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyOrgCategoryResultDTO>> |
|||
* @author: WangXianZhang |
|||
* @date: 2023/4/14 12:03 PM |
|||
*/ |
|||
@GetMapping("partyActTypeAndQuantity") |
|||
public Result<List<LingShanScreenPartyActTypeAndQtyResultDTO>> partyActTypeAndQuantity(@RequestParam("agencyId") String agencyId) { |
|||
List<LingShanScreenPartyActTypeAndQtyResultDTO> l = lingShanScreenService.partyActTypeAndQuantity(agencyId); |
|||
return new Result().ok(l); |
|||
} |
|||
|
|||
/** |
|||
* @description: 党组织数(只到党支部,没有小组) |
|||
* @param agencyId: |
|||
* @return |
|||
* @author: WangXianZhang |
|||
* @date: 2023/4/14 1:00 PM |
|||
*/ |
|||
@GetMapping("partyOrgTree") |
|||
public Result<LingShanScreenPartyOrgTreeResultDTO> getPartyOrgTree(@RequestParam("agencyId") String agencyId) { |
|||
LingShanScreenPartyOrgTreeResultDTO l = lingShanScreenService.getPartyOrgTree(agencyId); |
|||
return new Result().ok(l); |
|||
} |
|||
|
|||
/** |
|||
* @description: 党员列表 |
|||
* @param partyOrgId: 党组织id |
|||
* @return |
|||
* @author: WangXianZhang |
|||
* @date: 2023/4/14 3:20 PM |
|||
*/ |
|||
@GetMapping("partymemberList") |
|||
public Result<List<LingShanScreenPartyOrgTreeResultDTO.Partymember>> partymemberList(@RequestParam("partyOrgId") String partyOrgId) { |
|||
List<LingShanScreenPartyOrgTreeResultDTO.Partymember> l = lingShanScreenService.partymemberListByPartyOrgId(partyOrgId); |
|||
return new Result().ok(l); |
|||
} |
|||
|
|||
/** |
|||
* @description: agencyId下的党组织活动数统计 |
|||
* @param agencyId: 行政组织id |
|||
* @return |
|||
* @author: WangXianZhang |
|||
* @date: 2023/4/14 7:07 PM |
|||
*/ |
|||
@GetMapping("partyActStats/actQtyOfPartyOrg") |
|||
public Result<List<LingShanScreenPartyActQtyStatsResultDTO>> actQtyOfPartyOrgStats(@RequestParam("agencyId") String agencyId, |
|||
@RequestParam("holdTimeStart") String holdTimeStartStr, |
|||
@RequestParam("holdTimeEnd") String holdTimeEndStr) { |
|||
|
|||
Date holdTimeStart; |
|||
Date holdTimeEnd; |
|||
try { |
|||
holdTimeStart = DateUtils.parse(holdTimeStartStr, DateUtils.DATE_TIME_PATTERN); |
|||
holdTimeEnd = DateUtils.parse(holdTimeEndStr, DateUtils.DATE_TIME_PATTERN); |
|||
} catch (Exception e) { |
|||
log.error("日期解析失败,请按指定格式传输:yyyy-MM-dd HH:mm:ss"); |
|||
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "日期解析失败"); |
|||
} |
|||
List<LingShanScreenPartyActQtyStatsResultDTO> l = lingShanScreenService.actQtyOfPartyOrgStats(agencyId, holdTimeStart, holdTimeEnd); |
|||
return new Result<List<LingShanScreenPartyActQtyStatsResultDTO>>().ok(l); |
|||
} |
|||
|
|||
/** |
|||
* @description: 大屏地图-党员数 |
|||
* @param agencyId: |
|||
* @return |
|||
* @author: WangXianZhang |
|||
* @date: 2023/4/17 1:54 PM |
|||
*/ |
|||
@GetMapping("partymemberQty") |
|||
public Result<Integer> getPartymemberQtyOfOrg(@RequestParam("agencyId") String agencyId) { |
|||
return new Result<Integer>().ok(lingShanScreenService.getPartymemberQtyOfOrg(agencyId)); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,68 @@ |
|||
package com.epmet.modules.partymember.service; |
|||
|
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyActQtyStatsResultDTO; |
|||
import com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyActTypeAndQtyResultDTO; |
|||
import com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyOrgCategoryResultDTO; |
|||
import com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyOrgTreeResultDTO; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
public interface LingShanScreenService { |
|||
/** |
|||
* @description: 党建引领,党组织和数量 |
|||
* @param agencyId: 组织id |
|||
* @return java.util.List<com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyOrgCategoryResultDTO> |
|||
* @author: WangXianZhang |
|||
* @date: 2023/4/14 11:02 AM |
|||
*/ |
|||
List<LingShanScreenPartyOrgCategoryResultDTO> listPartyOrgCategoryAndQuantity(String agencyId); |
|||
|
|||
/** |
|||
* @description: 党建活动类型和数量 |
|||
* @param agencyId: 组织id |
|||
* @return |
|||
* @author: WangXianZhang |
|||
* @date: 2023/4/14 12:05 PM |
|||
*/ |
|||
List<LingShanScreenPartyActTypeAndQtyResultDTO> partyActTypeAndQuantity(String agencyId); |
|||
|
|||
/** |
|||
* @description: |
|||
* @param agencyId: |
|||
* @return |
|||
* @author: WangXianZhang |
|||
* @date: 2023/4/14 1:09 PM |
|||
*/ |
|||
LingShanScreenPartyOrgTreeResultDTO getPartyOrgTree(String agencyId); |
|||
|
|||
/** |
|||
* @description: 党员列表 |
|||
* @param partyOrgId: |
|||
* @return |
|||
* @author: WangXianZhang |
|||
* @date: 2023/4/14 3:22 PM |
|||
*/ |
|||
List<LingShanScreenPartyOrgTreeResultDTO.Partymember> partymemberListByPartyOrgId(String partyOrgId); |
|||
|
|||
/** |
|||
* @description: agencyId下的党组织活动数统计 |
|||
* @param agencyId: |
|||
* @param holdTimeStart: |
|||
* @param holdTimeEnd: |
|||
* @return |
|||
* @author: WangXianZhang |
|||
* @date: 2023/4/14 7:27 PM |
|||
*/ |
|||
List<LingShanScreenPartyActQtyStatsResultDTO> actQtyOfPartyOrgStats(String agencyId, Date holdTimeStart, Date holdTimeEnd); |
|||
|
|||
/** |
|||
* @description: 大屏地图-党员数 |
|||
* @param agencyId: |
|||
* @return |
|||
* @author: WangXianZhang |
|||
* @date: 2023/4/17 1:55 PM |
|||
*/ |
|||
Integer getPartymemberQtyOfOrg(String agencyId); |
|||
} |
@ -0,0 +1,323 @@ |
|||
package com.epmet.modules.partymember.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.epmet.commons.tools.constant.ServiceConstant; |
|||
import com.epmet.commons.tools.enums.GenderEnum; |
|||
import com.epmet.commons.tools.enums.PartyOrgTypeEnum; |
|||
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|||
import com.epmet.commons.tools.exception.EpmetException; |
|||
import com.epmet.commons.tools.feign.ResultDataResolver; |
|||
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|||
import com.epmet.commons.tools.redis.common.CustomerResiUserRedis; |
|||
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |
|||
import com.epmet.commons.tools.redis.common.bean.IcResiUserInfoCache; |
|||
import com.epmet.commons.tools.utils.DateUtils; |
|||
import com.epmet.commons.tools.utils.EpmetRequestHolder; |
|||
import com.epmet.commons.tools.utils.PidUtils; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.feign.EpmetUserOpenFeignClient; |
|||
import com.epmet.modules.partyOrg.dao.IcPartyActDao; |
|||
import com.epmet.modules.partyOrg.dao.IcPartyActTypeDictDao; |
|||
import com.epmet.modules.partyOrg.dao.IcPartyOrgDao; |
|||
import com.epmet.modules.partyOrg.entity.IcPartyActTypeDictEntity; |
|||
import com.epmet.modules.partyOrg.entity.IcPartyOrgEntity; |
|||
import com.epmet.modules.partymember.dao.IcPartyMemberDao; |
|||
import com.epmet.modules.partymember.entity.IcPartyMemberEntity; |
|||
import com.epmet.modules.partymember.service.LingShanScreenService; |
|||
import com.epmet.resi.group.feign.ResiGroupOpenFeignClient; |
|||
import com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyActQtyStatsResultDTO; |
|||
import com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyActTypeAndQtyResultDTO; |
|||
import com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyOrgCategoryResultDTO; |
|||
import com.epmet.resi.partymember.dto.partymember.result.LingShanScreenPartyOrgTreeResultDTO; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.time.LocalDate; |
|||
import java.util.*; |
|||
import java.util.function.Function; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Service |
|||
public class LingShanScreenServiceImpl implements LingShanScreenService, ResultDataResolver { |
|||
|
|||
@Autowired |
|||
private IcPartyOrgDao icPartyOrgDao; |
|||
|
|||
@Autowired |
|||
private IcPartyActDao partyActDao; |
|||
|
|||
@Autowired |
|||
private IcPartyMemberDao icPartyMemberDao; |
|||
|
|||
@Autowired |
|||
private IcPartyActTypeDictDao partyActTypeDictDao; |
|||
|
|||
@Autowired |
|||
private ResiGroupOpenFeignClient groupOpenFeignClient; |
|||
|
|||
@Autowired |
|||
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|||
|
|||
@Override |
|||
public List<LingShanScreenPartyOrgCategoryResultDTO> listPartyOrgCategoryAndQuantity(String agencyId) { |
|||
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(agencyId); |
|||
if (agencyInfo == null) { |
|||
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询当前组织信息失败,agencyId:" + agencyId, "查询当前组织信息失败"); |
|||
} |
|||
|
|||
// 1.查询党组织
|
|||
List<LingShanScreenPartyOrgCategoryResultDTO> l = icPartyOrgDao |
|||
.listPartyOrgCategoryAndQuantity(EpmetRequestHolder.getLoginUserCustomerId(), agencyId, PidUtils.convertPid2OrgIdPath(agencyId, agencyInfo.getPids())); |
|||
|
|||
// 给组织类型名字赋值
|
|||
l.forEach(i -> { |
|||
PartyOrgTypeEnum partyOrgTypeEnum = PartyOrgTypeEnum.getEnumByCode(i.getPartyOrgType()); |
|||
if (partyOrgTypeEnum != null) { |
|||
i.setName(partyOrgTypeEnum.getName()); |
|||
} |
|||
}); |
|||
|
|||
// 2.查询党小组
|
|||
Integer groupQty = getResultDataOrReturnNull(groupOpenFeignClient.getPartyGroupQuantityByAgencyId(agencyId), ServiceConstant.RESI_GROUP_SERVER); |
|||
if (groupQty == null) { |
|||
logger.error("【灵山大屏】党建引领-查询党小组信息失败,agencyId:" + agencyId); |
|||
groupQty = 0; |
|||
} |
|||
|
|||
LingShanScreenPartyOrgCategoryResultDTO gq = new LingShanScreenPartyOrgCategoryResultDTO(); |
|||
gq.setName("党小组"); |
|||
gq.setPartyOrgType(null); |
|||
gq.setValue(groupQty); |
|||
l.add(gq); |
|||
|
|||
return l; |
|||
} |
|||
|
|||
@Override |
|||
public List<LingShanScreenPartyActTypeAndQtyResultDTO> partyActTypeAndQuantity(String agencyId) { |
|||
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(agencyId); |
|||
if (agencyInfo == null) { |
|||
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询当前组织信息失败,agencyId:" + agencyId, "查询当前组织信息失败"); |
|||
} |
|||
return partyActDao.getPartyActTypeAndQuantity(EpmetRequestHolder.getLoginUserCustomerId(), PidUtils.convertPid2OrgIdPath(agencyId, agencyInfo.getPids())); |
|||
} |
|||
|
|||
@Override |
|||
public LingShanScreenPartyOrgTreeResultDTO getPartyOrgTree(String agencyId) { |
|||
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(agencyId); |
|||
if (agencyInfo == null) { |
|||
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询当前组织信息失败,agencyId:" + agencyId, "查询当前组织信息失败"); |
|||
} |
|||
|
|||
String orgIdpath = PidUtils.convertPid2OrgIdPath(agencyId, agencyInfo.getPids()); |
|||
|
|||
// 1。查询组织
|
|||
// 先查党委以上级别的,含党委
|
|||
List<LingShanScreenPartyOrgTreeResultDTO.PartyOrg> l = icPartyOrgDao.getPartyOrgsLteDangwei(EpmetRequestHolder.getLoginUserCustomerId(), agencyId, orgIdpath); |
|||
// 再查党支部的。因为党委查询的时候使用pids和党支部的时候使用起来不一样,所以要分开
|
|||
List<LingShanScreenPartyOrgTreeResultDTO.PartyOrg> s = icPartyOrgDao.getPartyOrgsOfBranch(EpmetRequestHolder.getLoginUserCustomerId(), agencyId, orgIdpath); |
|||
|
|||
l.addAll(s); |
|||
|
|||
// 2.组装树了开始
|
|||
Map<String, LingShanScreenPartyOrgTreeResultDTO.PartyOrg> lMap = l.stream().collect(Collectors.toMap(e -> e.getId(), Function.identity())); |
|||
|
|||
// 树根组织的id
|
|||
String parentPartyOrgId = null; |
|||
// 最高的组织级别,用于找到树根。初始值给个100,大一点,不影响
|
|||
Integer maxLevel = 100; |
|||
// 将组织放入到父组织的children列表中
|
|||
for (Iterator<LingShanScreenPartyOrgTreeResultDTO.PartyOrg> it = l.iterator(); it.hasNext();) { |
|||
LingShanScreenPartyOrgTreeResultDTO.PartyOrg e = it.next(); |
|||
LingShanScreenPartyOrgTreeResultDTO.PartyOrg pOrg = lMap.get(e.getPid()); |
|||
|
|||
if (maxLevel > e.getOrgType()) { |
|||
maxLevel = e.getOrgType(); |
|||
parentPartyOrgId = e.getId(); |
|||
} |
|||
|
|||
if (pOrg != null) { |
|||
pOrg.getChildren().add(e); |
|||
// 修剪枝叶
|
|||
it.remove(); |
|||
} |
|||
} |
|||
|
|||
LingShanScreenPartyOrgTreeResultDTO.PartyOrg parentOrg = lMap.get(parentPartyOrgId); |
|||
LingShanScreenPartyOrgTreeResultDTO r = new LingShanScreenPartyOrgTreeResultDTO(); |
|||
r.setTitle(parentOrg.getName()); |
|||
r.setNum(parentOrg.getNum()); |
|||
r.setList(parentOrg.getChildren()); |
|||
return r; |
|||
} |
|||
|
|||
@Override |
|||
public List<LingShanScreenPartyOrgTreeResultDTO.Partymember> partymemberListByPartyOrgId(String partyOrgId) { |
|||
IcPartyOrgEntity partyOrg = icPartyOrgDao.selectById(partyOrgId); |
|||
LambdaQueryWrapper<IcPartyMemberEntity> query = null; |
|||
if (partyOrg == null) { |
|||
String baseErrorMsg = "【灵山大屏】党组织下的党员列表-未找到党组织信息。"; |
|||
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), String.format(baseErrorMsg + "partyOrgId:" + partyOrg), baseErrorMsg); |
|||
} else if (Integer.valueOf(partyOrg.getPartyOrgType()) >= 4) { |
|||
// 0省委,1市委,2区委,3党工委,4党委,5支部。党委以上,除了支部
|
|||
query = new LambdaQueryWrapper<>(); |
|||
query.eq(IcPartyMemberEntity::getOrgPids, PidUtils.convertPid2OrgIdPath(partyOrgId, partyOrg.getOrgPids())); |
|||
query.eq(IcPartyMemberEntity::getCustomerId, EpmetRequestHolder.getLoginUserCustomerId()); |
|||
} else { |
|||
// 5支部
|
|||
query = new LambdaQueryWrapper<>(); |
|||
query.eq(IcPartyMemberEntity::getOrgPids, partyOrg.getOrgPids()); |
|||
query.eq(IcPartyMemberEntity::getCustomerId, EpmetRequestHolder.getLoginUserCustomerId()); |
|||
} |
|||
|
|||
List<IcPartyMemberEntity> l = icPartyMemberDao.selectList(query); |
|||
|
|||
// 党员列表转化为需要的dto返回
|
|||
return l.stream().map(e -> { |
|||
// 查询支部
|
|||
IcPartyOrgEntity branch = icPartyOrgDao.selectById(e.getSszb()); |
|||
// 查询居民信息,用于显示年龄
|
|||
IcResiUserInfoCache resiInfo = CustomerResiUserRedis.getIcResiUserInfo(e.getIcResiUser()); |
|||
|
|||
LingShanScreenPartyOrgTreeResultDTO.Partymember t = new LingShanScreenPartyOrgTreeResultDTO.Partymember(); |
|||
|
|||
String birthDay; |
|||
if (resiInfo != null |
|||
&& StringUtils.isNotBlank(birthDay = resiInfo.getBirthday())) { |
|||
Date birthday = DateUtils.parse(birthDay, DateUtils.DATE_PATTERN); |
|||
Calendar ci = Calendar.getInstance(); |
|||
ci.setTime(birthday); |
|||
int birthYear = ci.get(Calendar.YEAR); |
|||
t.setAge((LocalDate.now().getYear() - birthYear) + ""); |
|||
} |
|||
|
|||
t.setName(e.getName()); |
|||
Integer gender = e.getGender(); |
|||
t.setGender(gender != null ? GenderEnum.getName(gender.toString()) : "未知"); |
|||
t.setOrgname(branch != null ? branch.getPartyOrgName() : null); |
|||
t.setPhone(e.getMobile()); |
|||
t.setRemarks(e.getRemark()); |
|||
t.setPhoto(e.getHeadPhoto()); |
|||
// t.setIsDby();
|
|||
// t.setIsLhdy();
|
|||
// t.setWorkStatus();
|
|||
// t.setWorknumber();
|
|||
// t.setWorkEvent();
|
|||
return t; |
|||
}).collect(Collectors.toList()); |
|||
} |
|||
|
|||
/** |
|||
* @description: 这个方法其实有更容易实现,更容易阅读和理解的方式。循环活动类型,每个活动类型都查询一次统计数据即可。 |
|||
* 但是前期追求更少次数的数据库调用以提升效率,越写越复杂,既然已经这样了也懒得改了,就这样吧。 |
|||
* 如果后面有人感觉维护不了了,直接按照上述方式重写就行了,不要犹豫,不要徘徊,很容易改,没有暗雷!!! |
|||
* @param agencyId: 行政组织id |
|||
* @return |
|||
* @author: WangXianZhang |
|||
* @date: 2023/4/14 11:33 PM |
|||
*/ |
|||
@Override |
|||
public List<LingShanScreenPartyActQtyStatsResultDTO> actQtyOfPartyOrgStats(String agencyId, Date holdTimeStart, Date holdTimeEnd) { |
|||
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(agencyId); |
|||
if (agencyInfo == null) { |
|||
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询当前组织信息失败,agencyId:" + agencyId, "查询当前组织信息失败"); |
|||
} |
|||
|
|||
// String orgIdpath = PidUtils.convertPid2OrgIdPath(agencyId, agencyInfo.getPids());
|
|||
|
|||
// 先查当前党组织信息
|
|||
LambdaQueryWrapper<IcPartyOrgEntity> currentPartyOrgQuery = new LambdaQueryWrapper<>(); |
|||
currentPartyOrgQuery.eq(IcPartyOrgEntity::getAgencyId, agencyId); |
|||
currentPartyOrgQuery.orderByAsc(IcPartyOrgEntity::getPartyOrgType); |
|||
currentPartyOrgQuery.last(" limit 1 "); |
|||
|
|||
IcPartyOrgEntity currentPartyOrg = icPartyOrgDao.selectOne(currentPartyOrgQuery); |
|||
|
|||
if (currentPartyOrg == null) { |
|||
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "未找到党组织信息"); |
|||
} |
|||
|
|||
// ----------------------------要重写的话,上面建议保留噢,只重写下面就可以了,淦---------------------------------
|
|||
|
|||
// 找出当前党组织的下级党组织(全部),及其对应的活动数量
|
|||
List<LingShanScreenPartyActQtyStatsResultDTO.StatsData> l = partyActDao.actQtyOfPartyOrgStats(currentPartyOrg.getId(), holdTimeStart, holdTimeEnd); |
|||
|
|||
// 将结果遍历,分成2个纬度,分别建立地址引用
|
|||
// Map<actType, Map<orgId, LingShanScreenPartyActQtyStatsResultDTO.StatsData>>
|
|||
Map<String, Map<String, LingShanScreenPartyActQtyStatsResultDTO.StatsData>> orgDimMap = new HashMap<>(); |
|||
HashMap<String, String> orgIdAndName = new HashMap<>(); |
|||
|
|||
l.forEach(e -> { |
|||
orgIdAndName.put(e.getOrgId(), e.getName()); |
|||
String actType = e.getActType(); |
|||
if (StringUtils.isNotBlank(actType)) { |
|||
// 不为空,说明该类型有活动数据
|
|||
Map<String, LingShanScreenPartyActQtyStatsResultDTO.StatsData> m = orgDimMap.get(actType); |
|||
if (m == null) { |
|||
m = new HashMap<>(); |
|||
orgDimMap.put(actType, m); |
|||
} |
|||
m.put(e.getOrgId(), e); |
|||
} |
|||
}); |
|||
|
|||
// 所有的活动类型,并且建立字典,供后续使用
|
|||
LambdaQueryWrapper<IcPartyActTypeDictEntity> actTypeQuery = new LambdaQueryWrapper<>(); |
|||
actTypeQuery.eq(IcPartyActTypeDictEntity::getCustomerId, EpmetRequestHolder.getLoginUserCustomerId()); |
|||
List<IcPartyActTypeDictEntity> actTypes = partyActTypeDictDao.selectList(actTypeQuery); |
|||
|
|||
Map<String, String> actTypeKeyAndName = actTypes.stream().collect(Collectors.toMap(IcPartyActTypeDictEntity::getTypeKey, IcPartyActTypeDictEntity::getTypeName)); |
|||
|
|||
// 二维遍历,外层活动类型,内层组织id。确保两个维度的坐标都是全的(哪怕value=0)
|
|||
for (IcPartyActTypeDictEntity actType : actTypes) { |
|||
// 补全外层活动类型
|
|||
Map<String, LingShanScreenPartyActQtyStatsResultDTO.StatsData> orgIdAndStats = orgDimMap.get(actType.getTypeKey()); |
|||
if (orgIdAndStats == null) { |
|||
orgIdAndStats = new HashMap<>(); |
|||
orgDimMap.put(actType.getTypeKey(), orgIdAndStats); |
|||
} |
|||
|
|||
// 为活动类型补全组织列表(没有活动的组织赋值0)
|
|||
for (Map.Entry<String, String> entry : orgIdAndName.entrySet()) { |
|||
String orgId = entry.getKey(); |
|||
LingShanScreenPartyActQtyStatsResultDTO.StatsData statsData = orgIdAndStats.get(orgId); |
|||
if (statsData == null) { |
|||
LingShanScreenPartyActQtyStatsResultDTO.StatsData e = new LingShanScreenPartyActQtyStatsResultDTO.StatsData(); |
|||
e.setOrgId(orgId); |
|||
e.setName(entry.getValue()); |
|||
e.setValue(0); |
|||
e.setActType(actType.getTypeKey()); |
|||
orgIdAndStats.put(orgId, e); |
|||
} |
|||
} |
|||
} |
|||
|
|||
// 将结果map转化为list,返回
|
|||
ArrayList<LingShanScreenPartyActQtyStatsResultDTO> rl = new ArrayList<>(); |
|||
|
|||
orgDimMap.forEach((actType, orgStatsMap) -> { |
|||
LingShanScreenPartyActQtyStatsResultDTO re = new LingShanScreenPartyActQtyStatsResultDTO(); |
|||
re.setType(actTypeKeyAndName.get(actType)); |
|||
re.setData(orgStatsMap.values()); |
|||
rl.add(re); |
|||
}); |
|||
|
|||
return rl; |
|||
} |
|||
|
|||
@Override |
|||
public Integer getPartymemberQtyOfOrg(String agencyId) { |
|||
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(agencyId); |
|||
if (agencyInfo == null) { |
|||
logger.error("getPartymemberQtyOfOrg查询组织信息失败agencyId:{}", agencyId); |
|||
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询当前组织信息失败,agencyId:" + agencyId, "查询当前组织信息失败"); |
|||
} |
|||
|
|||
LambdaQueryWrapper<IcPartyMemberEntity> query = new LambdaQueryWrapper<>(); |
|||
query.likeRight(IcPartyMemberEntity::getAgencyPids, PidUtils.convertPid2OrgIdPath(agencyId, agencyInfo.getPids())) |
|||
.or() |
|||
.eq(IcPartyMemberEntity::getAgencyId, agencyId); |
|||
return icPartyMemberDao.selectCount(query); |
|||
} |
|||
} |
Loading…
Reference in new issue