Browse Source

积分审核相关

dev
zhaoqifeng 3 years ago
parent
commit
95fc72ad2c
  1. 20
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonUserFeignClient.java
  2. 24
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonUserFeignClientFallBackFactory.java
  3. 23
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonUserFeignClientFallback.java
  4. 90
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerResiUserRedis.java
  5. 11
      epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/PointApplyDTO.java
  6. 2
      epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/CommonPageUserFormDTO.java
  7. 44
      epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/PointApplyPageFormDTO.java
  8. 20
      epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/PointAuditFormDTO.java
  9. 43
      epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/PointAditiveRecordDailyDTO.java
  10. 21
      epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/PointAditiveRecordResultDTO.java
  11. 2
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/ApplyStatusEnum.java
  12. 20
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/PointApplyController.java
  13. 25
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/ResiPointController.java
  14. 16
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/PointAditiveRecordDao.java
  15. 24
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/PointApplyDao.java
  16. 12
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/PointAditiveRecordService.java
  17. 16
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/PointApplyService.java
  18. 65
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointAditiveRecordServiceImpl.java
  19. 121
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointApplyServiceImpl.java
  20. 23
      epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/PointAditiveRecordDao.xml
  21. 87
      epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/PointApplyDao.xml
  22. 6
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBaseInfoController.java
  23. 10
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBaseInfoService.java
  24. 15
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java

20
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonUserFeignClient.java

@ -0,0 +1,20 @@
package com.epmet.commons.tools.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.feign.fallback.CommonUserFeignClientFallBackFactory;
import com.epmet.commons.tools.redis.common.bean.ResiUserInfoCache;
import com.epmet.commons.tools.utils.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
/**
* @Author zqf
* @DateTime 2022/3/17 1:42 下午
* @DESC
*/
@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallbackFactory = CommonUserFeignClientFallBackFactory.class)
public interface CommonUserFeignClient {
@PostMapping("/epmetuser/userbaseinfo/getUserInfo/{userId}")
Result<ResiUserInfoCache> getUserInfo(@PathVariable("userId") String userId);
}

24
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonUserFeignClientFallBackFactory.java

@ -0,0 +1,24 @@
package com.epmet.commons.tools.feign.fallback;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.feign.CommonUserFeignClient;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @Author zqf
* @DateTime 2022/3/17 1:46 下午
* @DESC
*/
@Slf4j
@Component
public class CommonUserFeignClientFallBackFactory implements FallbackFactory<CommonUserFeignClient> {
private CommonUserFeignClientFallback fallback = new CommonUserFeignClientFallback();
@Override
public CommonUserFeignClient create(Throwable cause) {
log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause)));
return fallback;
}
}

23
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonUserFeignClientFallback.java

@ -0,0 +1,23 @@
package com.epmet.commons.tools.feign.fallback;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.feign.CommonUserFeignClient;
import com.epmet.commons.tools.redis.common.bean.ResiUserInfoCache;
import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import org.springframework.stereotype.Component;
/**
* 调用政府端权限
* @Author zqf
* @Description
* @Date 2020/4/24 11:17
**/
@Component
public class CommonUserFeignClientFallback implements CommonUserFeignClient {
@Override
public Result<ResiUserInfoCache> getUserInfo(String userId) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getUserInfo", userId);
}
}

90
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/CustomerResiUserRedis.java

@ -0,0 +1,90 @@
package com.epmet.commons.tools.redis.common;
import cn.hutool.core.bean.BeanUtil;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.feign.CommonUserFeignClient;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.redis.common.bean.ResiUserInfoCache;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.Nullable;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.Map;
/**
* 居民缓存通用类
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-04-22
*/
@Slf4j
@Component
public class CustomerResiUserRedis {
@Resource
private RedisUtils redisUtils;
@Resource
private CommonUserFeignClient commonUserFeignClient;
private static CustomerResiUserRedis customerResiUserRedis;
private static final String ROLE_MAP_KEY = "roleMap";
@PostConstruct
public void init() {
customerResiUserRedis = this;
customerResiUserRedis.redisUtils = this.redisUtils;
customerResiUserRedis.commonUserFeignClient = this.commonUserFeignClient;
}
/**
* desc: 获取居民缓存
*
* @param userId
* @return com.epmet.commons.tools.redis.common.bean.CustomerStaffInfoCache
* @author LiuJanJun
* @date 2021/8/19 10:29 下午
* @remark 此方法仅用于 获取某个工作人员的信息不用于获取客户下所有工作人员信息
*/
public static ResiUserInfoCache getUserBaseInfo(String userId) {
if (StringUtils.isBlank(userId)){
log.warn("getUserBaseInfo param is blank,userId:{}",userId);
return null;
}
String key = RedisKeys.getResiUserKey(userId);
Map<String, Object> map = customerResiUserRedis.redisUtils.hGetAll(key);
if (!CollectionUtils.isEmpty(map)) {
return ConvertUtils.mapToEntity(map, ResiUserInfoCache.class);
}
ResiUserInfoCache resultData = reloadStaffCache(userId, key);
if (resultData == null) {
return null;
}
return resultData;
}
@Nullable
private static ResiUserInfoCache reloadStaffCache(String userId, String key) {
Result<ResiUserInfoCache> result = customerResiUserRedis.commonUserFeignClient.getUserInfo(userId);
if (result == null || !result.success()) {
throw new RenException("获取居民信息失败");
}
ResiUserInfoCache resultData = result.getData();
if (null == resultData) {
log.warn("居民信息为空,userId:{}", userId);
return null;
}
Map<String, Object> map = BeanUtil.beanToMap(resultData, false, true);
customerResiUserRedis.redisUtils.hMSet(key, map);
return resultData;
}
}

11
epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/PointApplyDTO.java

@ -1,8 +1,11 @@
package com.epmet.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import java.util.List;
/**
@ -115,7 +118,7 @@ public class PointApplyDTO implements Serializable {
* 昵称
*/
private String nickname;
private String showName;
/**
* 性别;未知0男1女2
*/
@ -141,6 +144,9 @@ public class PointApplyDTO implements Serializable {
*/
private String remark;
private List<String> annexList;
private Integer pointValue;
/**
* 删除标识;0.未删除 1.已删除
*/
@ -159,6 +165,7 @@ public class PointApplyDTO implements Serializable {
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
private Date createdTime;
/**

2
epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/CommonPageUserFormDTO.java

@ -29,4 +29,6 @@ public class CommonPageUserFormDTO implements Serializable {
@NotBlank(message = "获取不到客户Id" , groups = PageUserGroup.class)
private String customerId;
private String categoryCode;
}

44
epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/PointApplyPageFormDTO.java

@ -0,0 +1,44 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.dto.form.PageFormDTO;
import lombok.Data;
import java.io.Serializable;
/**
* @Description
* @Author zhaoqifeng
* @Date 2022/6/15 14:57
*/
@Data
public class PointApplyPageFormDTO extends PageFormDTO implements Serializable {
private static final long serialVersionUID = -2274024797424706386L;
/**
* 姓名
*/
private String name;
/**
* 身份证
*/
private String idCard;
/**
* 手机号
*/
private String mobile;
/**
* 申请状态;0已提交1已驳回2已通过
*/
private String status;
/**
* 开始时间
*/
private String startTime;
/**
* 结束时间
*/
private String endTime;
private String categoryCode;
private String agencyId;
}

20
epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/PointAuditFormDTO.java

@ -0,0 +1,20 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Description
* @Author zhaoqifeng
* @Date 2022/6/15 15:18
*/
@Data
public class PointAuditFormDTO implements Serializable {
private static final long serialVersionUID = -2470114698294263404L;
private String id;
private String status;
private String remark;
private List<String> ids;
}

43
epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/PointAditiveRecordDailyDTO.java

@ -0,0 +1,43 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Description
* @Author zhaoqifeng
* @Date 2022/6/15 9:47
*/
@Data
public class PointAditiveRecordDailyDTO implements Serializable {
private static final long serialVersionUID = -239326201168528901L;
/**
* 日期yyyy-MM-dd
*/
private String dateStr;
/**
* 时间hh:mm
*/
private String timeStr;
/**
* 标题
*/
private String title;
/**
* 积分说明
*/
private String statement;
/**
* 积分值
*/
private String pointValue;
/**
* 业务主键
*/
private String businessId;
/**
* 业务类型 积分申请point_apply积分奖励point_reward积分扣罚point_fine积分花费point_cost驳回积分申请point_reject
*/
private String businessCode;
}

21
epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/PointAditiveRecordResultDTO.java

@ -0,0 +1,21 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Description
* @Author zhaoqifeng
* @Date 2022/6/15 9:46
*/
@Data
public class PointAditiveRecordResultDTO implements Serializable {
private static final long serialVersionUID = -1498111500078847600L;
/**
* 日期yyyy-MM-dd
*/
private String dateStr;
private List<PointAditiveRecordDailyDTO> recordList;
}

2
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/common/enu/ApplyStatusEnum.java

@ -9,7 +9,7 @@ import java.util.Objects;
public enum ApplyStatusEnum {
//审核状态
AUDITING("0", "未审核"),
REJECT("1", "未通过"),
REJECT("1", "已驳回"),
PASSED("2", "已通过");
private String code;

20
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/PointApplyController.java

@ -12,12 +12,12 @@ import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.PointApplyDTO;
import com.epmet.dto.form.PointApplyFormDTO;
import com.epmet.dto.form.PointApplyPageFormDTO;
import com.epmet.dto.form.PointAuditFormDTO;
import com.epmet.service.PointApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* 积分申请
@ -32,13 +32,13 @@ public class PointApplyController {
@Autowired
private PointApplyService pointApplyService;
@RequestMapping("page")
public Result<PageData<PointApplyDTO>> page(@RequestParam Map<String, Object> params){
PageData<PointApplyDTO> page = pointApplyService.page(params);
@RequestMapping("listall")
public Result<PageData<PointApplyDTO>> page(@RequestBody PointApplyPageFormDTO formDTO){
PageData<PointApplyDTO> page = pointApplyService.page(formDTO);
return new Result<PageData<PointApplyDTO>>().ok(page);
}
@RequestMapping(value = "{id}",method = {RequestMethod.POST,RequestMethod.GET})
@RequestMapping(value = "detail/{id}",method = {RequestMethod.POST,RequestMethod.GET})
public Result<PointApplyDTO> get(@PathVariable("id") String id){
PointApplyDTO data = pointApplyService.get(id);
return new Result<PointApplyDTO>().ok(data);
@ -81,4 +81,12 @@ public class PointApplyController {
return new Result();
}
@NoRepeatSubmit
@PostMapping("examine/submit")
public Result audit(@LoginUser TokenDto tokenDto, @RequestBody PointAuditFormDTO formDTO){
//效验数据
pointApplyService.audit(tokenDto, formDTO);
return new Result();
}
}

25
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/ResiPointController.java

@ -8,10 +8,7 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.service.PointVerificationLogService;
import com.epmet.service.UserPointActionLogService;
import com.epmet.service.UserPointStatisticalDailyService;
import com.epmet.service.UserPointTotalService;
import com.epmet.service.*;
import com.epmet.utils.ModuleConstant;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -20,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
@ -39,6 +37,8 @@ public class ResiPointController {
private PointVerificationLogService pointVerificationLogService;
@Autowired
private UserPointActionLogService pointActionLogService;
@Resource
private PointAditiveRecordService pointAditiveRecordService;
/**
* @Description 获取指定居民的积分信息
@ -237,5 +237,20 @@ public class ResiPointController {
return new Result<List<MyTotalPointResultDTO>>().ok(userPointTotalService.totalPoint(tokenDto));
}
/**
* 德育积分/党建积分的积分记录
*
* @Param dto
* @Param pageUserParam
* @Return {@link Result<List<PointAditiveRecordResultDTO>>}
* @Author zhaoqifeng
* @Date 2022/6/15 9:55
*/
@PostMapping("aditiverecordlist")
public Result<List<PointAditiveRecordResultDTO>> aditiveRecords(@LoginUser TokenDto dto,@RequestBody CommonPageUserFormDTO pageUserParam){
pageUserParam.setUserId(dto.getCustomerId());
pageUserParam.setUserId(dto.getUserId());
ValidatorUtils.validateEntity(pageUserParam, CommonPageUserFormDTO.PageUserGroup.class);
return new Result<List<PointAditiveRecordResultDTO>>().ok(pointAditiveRecordService.getRecords(pageUserParam));
}
}

16
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/PointAditiveRecordDao.java

@ -1,8 +1,12 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.result.PointAditiveRecordDailyDTO;
import com.epmet.entity.PointAditiveRecordEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 附加积分记录
@ -12,5 +16,15 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface PointAditiveRecordDao extends BaseDao<PointAditiveRecordEntity> {
/**
* 积分记录
*
* @Param customerId
* @Param categoryCode
* @Param subjectId
* @Return {@link List< PointAditiveRecordDailyDTO>}
* @Author zhaoqifeng
* @Date 2022/6/15 10:12
*/
List<PointAditiveRecordDailyDTO> selectRecordList(@Param("customerId") String customerId, @Param("categoryCode") String categoryCode, @Param("subjectId") String subjectId);
}

24
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/PointApplyDao.java

@ -1,8 +1,13 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.PointApplyDTO;
import com.epmet.dto.form.PointApplyPageFormDTO;
import com.epmet.entity.PointApplyEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 积分申请
@ -12,5 +17,24 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface PointApplyDao extends BaseDao<PointApplyEntity> {
/**
* 获取积分申请详情
*
* @Param id
* @Return {@link PointApplyDTO}
* @Author zhaoqifeng
* @Date 2022/6/15 14:31
*/
PointApplyDTO getDetail(@Param("id") String id);
/**
* 申请列表
* @Param formDTO
* @Return {@link List< PointApplyDTO>}
* @Author zhaoqifeng
* @Date 2022/6/15 15:01
*/
List<PointApplyDTO> getList(PointApplyPageFormDTO formDTO);
}

12
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/PointAditiveRecordService.java

@ -3,6 +3,8 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.PointAditiveRecordDTO;
import com.epmet.dto.form.CommonPageUserFormDTO;
import com.epmet.dto.result.PointAditiveRecordResultDTO;
import com.epmet.entity.PointAditiveRecordEntity;
import java.util.List;
@ -75,4 +77,14 @@ public interface PointAditiveRecordService extends BaseService<PointAditiveRecor
* @date 2022-06-14
*/
void delete(String[] ids);
/**
* 获取积分记录
*
* @Param formDTO
* @Return {@link List<PointAditiveRecordResultDTO>}
* @Author zhaoqifeng
* @Date 2022/6/15 9:55
*/
List<PointAditiveRecordResultDTO> getRecords(CommonPageUserFormDTO formDTO);
}

16
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/PointApplyService.java

@ -2,8 +2,11 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.dto.PointApplyDTO;
import com.epmet.dto.form.PointApplyFormDTO;
import com.epmet.dto.form.PointApplyPageFormDTO;
import com.epmet.dto.form.PointAuditFormDTO;
import com.epmet.entity.PointApplyEntity;
import java.util.List;
@ -25,7 +28,7 @@ public interface PointApplyService extends BaseService<PointApplyEntity> {
* @author generator
* @date 2022-06-14
*/
PageData<PointApplyDTO> page(Map<String, Object> params);
PageData<PointApplyDTO> page(PointApplyPageFormDTO formDTO);
/**
* 默认查询
@ -85,4 +88,15 @@ public interface PointApplyService extends BaseService<PointApplyEntity> {
* @Date 2022/6/14 14:14
*/
void submit(PointApplyFormDTO formDTO);
/**
* 审核
*
* @Param tokenDto
* @Param formDTO
* @Return
* @Author zhaoqifeng
* @Date 2022/6/15 15:20
*/
void audit(TokenDto tokenDto, PointAuditFormDTO formDTO);
}

65
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointAditiveRecordServiceImpl.java

@ -2,22 +2,34 @@ package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.common.CommonConstant;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
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.Result;
import com.epmet.dao.PointAditiveRecordDao;
import com.epmet.dto.PointAditiveRecordDTO;
import com.epmet.dto.form.CommonPageUserFormDTO;
import com.epmet.dto.result.*;
import com.epmet.entity.PointAditiveRecordEntity;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.service.PointAditiveRecordService;
import com.github.pagehelper.PageHelper;
import com.google.common.collect.Maps;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 附加积分记录
@ -28,6 +40,8 @@ import java.util.Map;
@Service
public class PointAditiveRecordServiceImpl extends BaseServiceImpl<PointAditiveRecordDao, PointAditiveRecordEntity> implements PointAditiveRecordService {
@Resource
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
@Override
public PageData<PointAditiveRecordDTO> page(Map<String, Object> params) {
@ -81,4 +95,51 @@ public class PointAditiveRecordServiceImpl extends BaseServiceImpl<PointAditiveR
baseDao.deleteBatchIds(Arrays.asList(ids));
}
/**
* 获取积分记录
*
* @param formDTO 入参
* @Return {@link List<PointAditiveRecordResultDTO>}
* @Author zhaoqifeng
* @Date 2022/6/15 9:55
*/
@Override
public List<PointAditiveRecordResultDTO> getRecords(CommonPageUserFormDTO formDTO) {
List<PointAditiveRecordResultDTO> list = new ArrayList<>();
String subjectId;
//如果申请类型为德育积分,需要获取用户所在房屋
if (CommonConstant.MORAL_EDUCATION.equals(formDTO.getCategoryCode())) {
Result<HomeInfoResultDTO> result = epmetUserOpenFeignClient.getHomeInfo();
if (!result.success() || null == result.getData()) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取居民所在家庭信息失败", "获取居民所在家庭信息失败");
}
if (StringUtils.isBlank(result.getData().getHouseId())) {
return list;
}
subjectId = result.getData().getHouseId();
} else {
subjectId = formDTO.getUserId();
}
PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize());
List<PointAditiveRecordDailyDTO> recordList = baseDao.selectRecordList(formDTO.getCustomerId(), formDTO.getCategoryCode(), subjectId);
if(CollectionUtils.isNotEmpty(recordList)){
Map<String,List<PointAditiveRecordDailyDTO>> map =
recordList.stream().collect(Collectors.groupingBy(PointAditiveRecordDailyDTO::getDateStr));
Map<String, List<PointAditiveRecordDailyDTO>> sortedMap = Maps.newLinkedHashMap();
map.entrySet().stream().sorted(Map.Entry.<String, List<PointAditiveRecordDailyDTO>>comparingByKey().reversed())
.forEachOrdered(e -> sortedMap.put(e.getKey(), e.getValue()));
sortedMap.forEach((key, value) -> {
PointAditiveRecordResultDTO o = new PointAditiveRecordResultDTO();
o.setDateStr(key);
o.setRecordList(value);
list.add(o);
});
}
return list;
}
}

121
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointApplyServiceImpl.java

@ -1,28 +1,40 @@
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.common.CommonConstant;
import com.epmet.common.enu.ApplyStatusEnum;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.enums.GenderEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerOrgRedis;
import com.epmet.commons.tools.redis.common.CustomerResiUserRedis;
import com.epmet.commons.tools.redis.common.bean.GridInfoCache;
import com.epmet.commons.tools.redis.common.bean.ResiUserInfoCache;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.PointAditiveCalcDao;
import com.epmet.dao.PointAditiveRecordDao;
import com.epmet.dao.PointAnnexDao;
import com.epmet.dao.PointApplyDao;
import com.epmet.dto.PointApplyDTO;
import com.epmet.dto.form.PointApplyFormDTO;
import com.epmet.dto.form.PointApplyPageFormDTO;
import com.epmet.dto.form.PointAuditFormDTO;
import com.epmet.dto.result.HomeInfoResultDTO;
import com.epmet.entity.PointAditiveCalcEntity;
import com.epmet.entity.PointAditiveRecordEntity;
import com.epmet.entity.PointAnnexEntity;
import com.epmet.entity.PointApplyEntity;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.service.PointApplyService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@ -47,14 +59,29 @@ public class PointApplyServiceImpl extends BaseServiceImpl<PointApplyDao, PointA
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
@Resource
private PointAnnexDao pointAnnexDao;
@Resource
private PointAditiveRecordDao pointAditiveRecordDao;
@Resource
private PointAditiveCalcDao pointAditiveCalcDao;
@Override
public PageData<PointApplyDTO> page(Map<String, Object> params) {
IPage<PointApplyEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, PointApplyDTO.class);
public PageData<PointApplyDTO> page(PointApplyPageFormDTO formDTO) {
PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize());
List<PointApplyDTO> list = baseDao.getList(formDTO);
PageInfo<PointApplyDTO> pageInfo = new PageInfo<>(list);
if (CollectionUtils.isNotEmpty(list)) {
list.forEach(item -> {
//获取居民信息
ResiUserInfoCache userInfo = CustomerResiUserRedis.getUserBaseInfo(item.getUserId());
if (null != userInfo) {
item.setHeadImgUrl(userInfo.getHeadImgUrl());
item.setGender(GenderEnum.getName(userInfo.getGender()));
item.setShowName(userInfo.getShowName());
item.setStatus(ApplyStatusEnum.getName(item.getStatus()));
}
});
}
return new PageData<>(list, pageInfo.getTotal());
}
@Override
@ -75,8 +102,18 @@ public class PointApplyServiceImpl extends BaseServiceImpl<PointApplyDao, PointA
@Override
public PointApplyDTO get(String id) {
PointApplyEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, PointApplyDTO.class);
PointApplyDTO dto = baseDao.getDetail(id);
if (null == dto) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "内容不存在", "内容不存在");
}
//获取居民信息
ResiUserInfoCache userInfo = CustomerResiUserRedis.getUserBaseInfo(dto.getUserId());
if (null == userInfo) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取居民信息失败", "获取居民信息失败");
}
dto.setHeadImgUrl(userInfo.getHeadImgUrl());
dto.setShowName(userInfo.getShowName());
return dto;
}
@Override
@ -128,10 +165,18 @@ public class PointApplyServiceImpl extends BaseServiceImpl<PointApplyDao, PointA
}
entity.setHouseId(result.getData().getHouseId());
}
//获取居民信息
ResiUserInfoCache userInfo = CustomerResiUserRedis.getUserBaseInfo(formDTO.getUserId());
if (null == userInfo) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取居民信息失败", "获取居民信息失败");
}
entity.setAgencyId(gridInfo.getPid());
entity.setAgencyPids(gridInfo.getPids());
entity.setStatus(ApplyStatusEnum.AUDITING.getCode());
entity.setName(userInfo.getName());
entity.setMobile(userInfo.getMobile());
entity.setIdCard(userInfo.getIdNum());
baseDao.insert(entity);
//保存附件
@ -150,4 +195,62 @@ public class PointApplyServiceImpl extends BaseServiceImpl<PointApplyDao, PointA
}
/**
* 审核
*
* @param tokenDto
* @param formDTO
* @Param tokenDto
* @Param formDTO
* @Return
* @Author zhaoqifeng
* @Date 2022/6/15 15:20
*/
@Override
public void audit(TokenDto tokenDto, PointAuditFormDTO formDTO) {
//更新审核状态
PointApplyEntity entity = ConvertUtils.sourceToTarget(formDTO, PointApplyEntity.class);
baseDao.updateById(entity);
String subjectId;
//获取积分申请信息
PointApplyDTO dto = get(formDTO.getId());
if (CommonConstant.MORAL_EDUCATION.equals(dto.getCategoryCode())) {
subjectId = dto.getHouseId();
} else {
subjectId = dto.getUserId();
}
//生成积分记录
PointAditiveRecordEntity record = new PointAditiveRecordEntity();
record.setCustomerId(tokenDto.getCustomerId());
record.setTitle(dto.getTitle());
record.setStatement(dto.getStatement());
record.setPointValue(dto.getPointValue());
record.setCategoryCode(dto.getCategoryCode());
record.setSubjectId(subjectId);
record.setBusinessId(dto.getId());
record.setBusinessCode(CommonConstant.POINT_APPLY);
pointAditiveRecordDao.insert(record);
//重新计算总分
LambdaQueryWrapper<PointAditiveCalcEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(PointAditiveCalcEntity::getCustomerId, tokenDto.getCustomerId());
wrapper.eq(PointAditiveCalcEntity::getSubjectId, subjectId);
wrapper.eq(PointAditiveCalcEntity::getCategoryCode, dto.getCategoryCode());
PointAditiveCalcEntity calc = pointAditiveCalcDao.selectOne(wrapper);
if (null != calc) {
calc.setUpdatedBy(null);
calc.setUpdatedTime(null);
calc.setTotal(calc.getTotal() + dto.getPointValue());
pointAditiveCalcDao.updateById(calc);
} else {
calc = new PointAditiveCalcEntity();
calc.setCustomerId(tokenDto.getCustomerId());
calc.setCategoryCode(dto.getCategoryCode());
calc.setSubjectId(subjectId);
calc.setSpend(NumConstant.ZERO);
calc.setTotal(dto.getPointValue());
pointAditiveCalcDao.insert(calc);
}
}
}

23
epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/PointAditiveRecordDao.xml

@ -20,6 +20,29 @@
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<select id="selectRecordList" resultType="com.epmet.dto.result.PointAditiveRecordDailyDTO">
SELECT
TITLE,
STATEMENT,
CASE
POINT_VALUE
WHEN POINT_VALUE > 0 THEN
concat( '+', pointValue ) ELSE POINT_VALUE
END AS POINT_VALUE,
BUSINESS_ID,
BUSINESS_CODE,
DATE_FORMAT( CREATED_TIME, '%Y-%m-%d' ) AS dateStr,
DATE_FORMAT( CREATED_TIME, '%H:%i' ) AS timeStr
FROM
point_aditive_record
WHERE
DEL_FLAG = '0'
AND SUBJECT_ID = #{subjectId}
AND CUSTOMER_ID = #{customerId}
AND CATEGORY_CODE = #{categoryCode}
ORDER BY
CREATED_TIME DESC
</select>
</mapper>

87
epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/PointApplyDao.xml

@ -37,5 +37,92 @@
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<resultMap id="DetailMap" type="com.epmet.dto.PointApplyDTO">
<id property="id" column="ID" />
<result property="gridId" column="GRID_ID"/>
<result property="title" column="TITLE"/>
<result property="statement" column="STATEMENT"/>
<result property="status" column="STATUS"/>
<result property="categoryCode" column="CATEGORY_CODE"/>
<result property="houseId" column="HOUSE_ID"/>
<result property="name" column="NAME"/>
<result property="idCard" column="ID_CARD"/>
<result property="mobile" column="MOBILE"/>
<result property="userId" column="USER_ID"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="ruleName" column="RULE_NAME"/>
<result property="pointValue" column="POINT"/>
<collection property="annexList" ofType="java.lang.String">
<result column="URL"/>
</collection>
</resultMap>
<select id="getDetail" resultMap="DetailMap">
SELECT
a.ID,
a.GRID_ID,
a.TITLE,
a.STATEMENT,
a.STATUS,
a.USER_ID,
a.NAME,
a.MOBILE,
a.ID_CARD,
a.CATEGORY_CODE,
a.HOUSE_ID,
a.CREATED_TIME,
b.RULE_NAME,
b.POINT,
c.URL
FROM
point_apply a
INNER JOIN point_rule b ON a.RULE_ID = b.ID AND a.CUSTOMER_ID = b.CUSTOMER_ID
LEFT JOIN point_annex c ON a.ID = c.BUSINESS_ID AND c.DEL_FLAG = 0
WHERE
a.DEL_FLAG = 0
AND a.ID = #{id}
ORDER BY c.URL ASC
</select>
<select id="getList" resultType="com.epmet.dto.PointApplyDTO">
SELECT
a.ID,
a.TITLE,
a.STATEMENT,
a.STATUS,
a.USER_ID,
a.NAME,
a.MOBILE,
a.ID_CARD,
a.CATEGORY_CODE,
a.CREATED_TIME,
b.RULE_NAME,
b.POINT
FROM
point_apply a
INNER JOIN point_rule b ON a.RULE_ID = b.ID AND a.CUSTOMER_ID = b.CUSTOMER_ID
WHERE
a.DEL_FLAG = 0
AND a.AGENCY_ID = #{agencyId}
AND a.CATEGORY_CODE = #{categoryCode}
<if test="name != null and name.trim() != ''">
AND a.NAME LIKE concat('%', #{name}, '%')
</if>
<if test="mobile != null and mobile.trim() != ''">
AND a.MOBILE LIKE concat('%', #{mobile}, '%')
</if>
<if test="idCard != null and idCard.trim() != ''">
AND a.ID_CARD LIKE concat('%', #{idCard}, '%')
</if>
<if test="status != null and status.trim() != ''">
AND a.STATUS = #{status}
</if>
<if test="startTime != null and startTime.trim() != ''">
AND DATE_FORMAT(a.CREATED_TIME,'%Y%m%d') <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime.trim() != ''">
AND DATE_FORMAT(a.CREATED_TIME,'%Y%m%d') <![CDATA[ <= ]]> #{endTime}
</if>
</select>
</mapper>

6
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBaseInfoController.java

@ -19,6 +19,7 @@ package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.bean.ResiUserInfoCache;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.commons.tools.utils.Result;
@ -215,5 +216,10 @@ public class UserBaseInfoController {
public Result<RegisterRelationDTO> resiRelationInfo(@RequestParam("userId")String userId){
return new Result<RegisterRelationDTO>().ok(userBaseInfoService.resiRelationInfo(userId));
}
@PostMapping("getUserInfo/{userId}")
public Result<ResiUserInfoCache> getUserInfo(@PathVariable("userId") String userId){
return new Result<ResiUserInfoCache>().ok(userBaseInfoService.getUserInfo(userId));
}
}

10
epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBaseInfoService.java

@ -19,6 +19,7 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.bean.ResiUserInfoCache;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.RegisterRelationDTO;
import com.epmet.dto.UserBaseInfoDTO;
@ -203,4 +204,13 @@ public interface UserBaseInfoService extends BaseService<UserBaseInfoEntity> {
* @date 2021/12/30 3:12 下午
*/
RegisterRelationDTO resiRelationInfo(String userId);
/**
* 获取用户缓存信息
* @Param userId
* @Return {@link UserBaseInfoResultDTO}
* @Author zhaoqifeng
* @Date 2022/6/15 16:09
*/
ResiUserInfoCache getUserInfo(String userId);
}

15
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java

@ -27,6 +27,7 @@ import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.bean.ResiUserInfoCache;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.*;
@ -504,4 +505,18 @@ public class UserBaseInfoServiceImpl extends BaseServiceImpl<UserBaseInfoDao, Us
public RegisterRelationDTO resiRelationInfo(String userId) {
return registerRelationDao.resiRelationInfo(userId);
}
/**
* 获取用户缓存信息
*
* @param userId
* @Param userId
* @Return {@link ResiUserInfoCache}
* @Author zhaoqifeng
* @Date 2022/6/15 16:09
*/
@Override
public ResiUserInfoCache getUserInfo(String userId) {
return ConvertUtils.sourceToTarget(userBaseInfoRedis.getUserInfo(userId), ResiUserInfoCache.class);
}
}

Loading…
Cancel
Save