Commit 19cd8109 by liangkaiping

copy

parent aedf5317
# point-project
积分
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.yizhi</groupId>
<artifactId>point-project</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cloud-point-api</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-common-api</artifactId>
<scope>provided</scope>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-system-api</artifactId>
<scope>provided</scope>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package com.yizhi.point.application.feign;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.point.application.vo.domain.MqPointParamVo;
import com.yizhi.point.application.vo.domain.PointActivityVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
/**
* 轮播
*
* @author HUIHUI.DUAN
* @date 2018/3/28 10:44
*/
@FeignClient(name = "point", contextId = "PointActivityFeignClients")
public interface PointActivityFeignClients {
@PostMapping("/manage/activity/insert")
Long insertDetail(@RequestBody PointActivityVo pointActivityVo);
@PostMapping("/manage/activity/delete")
Long deleteDetailById(@RequestBody PointActivityVo pointActivityVo);
@PostMapping("/manage/activity/update")
Long updateById(@RequestBody PointActivityVo pointActivityVo);
@PostMapping("/manage/activity/enabled")
Boolean pointUp(@RequestBody PointActivityVo pointActivityVo);
@PostMapping("/manage/activity/disabled")
Boolean pointDown(@RequestBody PointActivityVo pointActivityVo);
@GetMapping("/manage/activity/list")
Page<PointActivityVo> activityList(@RequestParam Map<String, Object> map);
@GetMapping("/manage/activity/getPointRecords")
List<MqPointParamVo> getPointRecords(@RequestParam("eventName") String eventName,
@RequestParam("activityId") Long activityId,
@RequestParam("companyId,") Long companyId,
@RequestParam("siteId") Long siteId);
}
package com.yizhi.point.application.feign;
import com.yizhi.point.application.vo.domain.PointDetailsVo;
import com.yizhi.point.application.vo.PointImportVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 轮播
*
* @author HUIHUI.DUAN
* @date 2018/3/28 10:44
*/
@FeignClient(name = "point", contextId = "PointDetailsFeignClients")
public interface PointDetailsFeignClients {
@GetMapping("/api/point/detail/pointList")
Map<String, Object> pointList(@RequestParam("year") String year,
@RequestParam(value = "type", required = false) String type,
@RequestParam("accountId") Long accountId,
@RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize, @RequestParam("companyId") Long companyId,
@RequestParam("siteId") Long siteId, @RequestParam("orgId") Long orgId);
@GetMapping("/api/point/detail/countList")
Integer queryPiont(@RequestParam("userId") Long userId, @RequestParam(value = "companyId", required = false) Long companyId,
@RequestParam("siteId") Long siteId, @RequestParam(name = "orgId", required = false) Long orgId);
/**
* 外部积分导入
*
* @param importVOList
* @return
*/
@PostMapping("/api/point/detail/pointImport")
boolean insertExternalPoint(@RequestBody List<PointImportVO> importVOList,
@RequestParam("companyId") Long companyId,
@RequestParam("siteId") Long siteId,
@RequestParam("orgId") Long orgId,
@RequestParam("accountId") Long accountId,
@RequestParam("accountName") String accountName);
/**
* 报表跑批积分
*
* @return
*/
@GetMapping("/api/point/detail/statisticsPoint")
List<PointDetailsVo> statisticsPoint();
/**
* 根据传入的accountID siteId 活动id 求得积分总和
*
* @param accountId
* @param siteId
* @param bizIds
* @return
*/
@GetMapping("/api/point/detail/getPointByCondition")
public Integer getPointByCondition(@RequestParam("accountId") Long accountId,
@RequestParam("siteId") Long siteId,
@RequestParam("bizIds") List<Long> bizIds);
/**
* 统计积分明细
*/
@GetMapping("/api/point/detail/sync/list")
List<PointDetailsVo> syncPointDetails(@RequestParam(name = "startDate",required = false) String startDate,
@RequestParam(name = "endDate",required = false) String endDate ,
@RequestParam(name = "companyId",required = false) Long companyId ,
@RequestParam(name = "siteId",required = false) Long siteId
);
}
package com.yizhi.point.application.feign;
import com.yizhi.point.application.vo.domain.PointVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
/**
* 积分设置
*
* @author HUIHUI.DUAN
* @date 2018/3/28 10:44
*/
@FeignClient(name = "point", contextId = "PointFeignClients")
public interface PointFeignClients {
@GetMapping("/manage/point/strategy/view")
PointVo pointList(@RequestParam("companyId") Long companyId, @RequestParam("siteId") Long siteId);
@PostMapping("/manage/point/strategy/update")
boolean updateList(@RequestBody PointVo point);
}
package com.yizhi.point.application.feign;
import com.yizhi.point.application.vo.domain.PointLevelVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* 轮播
* @author HUIHUI.DUAN
* @date 2018/3/28 10:44
*/
@FeignClient(name = "point", contextId = "PointLevelFeignClients")
public interface PointLevelFeignClients {
@PostMapping("/manage/point/level/insert")
Boolean inserts(@RequestBody PointLevelVo pointLevel);
@PostMapping("/manage/point/level/delete")
Boolean piontLevelDelete(@RequestParam("id") Long id);
@GetMapping("/manage/point/level/list")
List<PointLevelVo> levelList(@RequestParam("id") Long id);
@GetMapping("/manage/point/level/update")
Integer updateById1(@RequestBody PointLevelVo pointLevel);
}
package com.yizhi.point.application.feign;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.point.application.vo.PointDetailsVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(name = "point", contextId = "PointManageFeignClients")
public interface PointManageFeignClients {
@GetMapping("/manage/point/details/list")
Page<PointDetailsVO> getManagePointDetails(
@RequestParam(name = "activityId", required = false) Long activityId,
@RequestParam(name = "accountName", required = false) String accountName,
@RequestParam(name = "startTime", required = false) Long startTime, @RequestParam(name = "endTime", required = false) Long endTime,
@RequestParam(name = "pageNo", required = false) Integer pageNo, @RequestParam(name = "pageSize", required = false) Integer pageSize,
@RequestParam(name = "companyId", required = false) Long companyId, @RequestParam(name = "siteId", required = false) Long siteId);
@GetMapping("/manage/point/update/after")
public void updatePointDetailsChangeAfter(
@RequestParam(name = "siteId" ,required = false ) Long siteId,
@RequestParam(name = "accountId" ,required = false ) Long accountId);
}
package com.yizhi.point.application.feign;
import com.yizhi.point.application.vo.PointParamVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@FeignClient(name = "point", contextId = "PointRedisFeignClients")
public interface PointRedisFeignClients {
@PostMapping("/point/redis/add")
String addPointRedis(@RequestBody PointParamVO vo);
}
package com.yizhi.point.application.feign;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.point.application.vo.domain.PointDetailsVo;
import com.yizhi.point.application.vo.PointUserListVO;
import com.yizhi.point.application.vo.PointUserParamVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.sql.Timestamp;
import java.util.List;
import java.util.Map;
/**
* 轮播
*
* @author HUIHUI.DUAN
* @date 2018/3/28 10:44
*/
@FeignClient(name = "point", contextId = "PointUserFeignClients")
public interface PointUserFeignClients {
@GetMapping("/manage/point/user/countList")
Integer queryPiont(@RequestParam("userId") Long userId);
@GetMapping("/manage/point/user/rank/list")
Page<PointUserListVO> userRankList(@RequestBody PointUserParamVO vo);
@GetMapping("/manage/point/user/rank/list/export")
List<PointUserListVO> userRankListExport(@RequestBody PointUserParamVO vo);
@GetMapping("/manage/point/user/rank/list/startDate")
Timestamp getStartDate();
@GetMapping("/manage/point/user/point/acquire")
public Integer acquirePoint(@RequestParam(name = "accountId", required = true) Long accountId,
@RequestParam(name = "learnSourceId", required = true) Long learnSourceId,
@RequestParam(name = "createTime", required = true) String createTime);
@GetMapping("/manage/point/user/point/isHasPoint")
public boolean isHasPoint(@RequestParam("bizId") Long bizId, @RequestParam("accountId") Long accountId);
/**
* 报表获取业务积分记录,可获取所有,可根据业务id,accountId
*
* @param bizId
* @param accountId
* @param companyId
* @param siteId
* @param isRealTime
* @return
*/
@GetMapping("/manage/point/user/getReportPoints")
public List<PointDetailsVo> getReportPoints(@RequestParam(value = "bizId", required = false) Long bizId, @RequestParam(value = "accountId", required = false) Long accountId,
@RequestParam(value = "companyId", required = false) Long companyId, @RequestParam(value = "siteId", required = false) Long siteId,
@RequestParam(value = "isRealTime", required = true) boolean isRealTime);
/**
* 报表获取业务积分记录,可获取所有,可根据业务id,accountId
*
* @param bizId
* @param accountId
* @param isRealTime
* @return
*/
@GetMapping("/manage/point/user/getCourseReportPoints")
public List<PointDetailsVo> getCourseReportPoints(@RequestParam(value = "bizId", required = false) Long bizId, @RequestParam(value = "accountId", required = false) Long accountId,
@RequestParam(value = "isRealTime", required = true) boolean isRealTime);
/**
* 周期内用户获取的总积分
* @param accountId
* @param siteIds
* @param startDate
* @param endDate
* @return
*/
@GetMapping("/manage/point/user/totalPoint")
public Map<Long, Long> totalPoint( @RequestParam("siteIds") List<Long> siteIds,
@RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate);
}
package com.yizhi.point.application.vo;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* <p>
* 积分明细
* </p>
*
* @author bob123
* @since 2018-04-20
*/
@Data
@ApiModel(value = "PointDetailsVO", description = "积分详情")
public class PointDetailsVO{
@ApiModelProperty(value = "积分明细id")
private String id;
@ApiModelProperty(value = "时间")
private Date time;
@ApiModelProperty(value = "积分")
private Integer point;
@ApiModelProperty(value = "积分正负标识:0减 1加")
private Integer flag;
@ApiModelProperty(value = "学习活动类型")
@TableField("learn_type")
private String learnType;
@ApiModelProperty(value = "学习活动名称")
@TableField("learn_name")
private String learnName;
@ApiModelProperty(value = "学习活动来源")
@TableField("learn_source")
private String learnSource;
@ApiModelProperty(value = "月份")
private String month;
@ApiModelProperty(value = "学员")
private String accountId;
@ApiModelProperty(value = "学员姓名")
private String accountName;
@ApiModelProperty(value = "当前积分的总量")
private String amount;
@ApiModelProperty(value = "变动原因")
private String changeReason;
@ApiModelProperty(value = "变动前积分总量")
private Integer changeBefore;
@ApiModelProperty(value = "变动后积分总量")
private Integer changeAfter;
@ApiModelProperty(value = "公司ID")
@TableField("company_id")
private Long companyId;
@ApiModelProperty(value = "部门ID")
@TableField("org_id")
private Long orgId;
@ApiModelProperty(value = "站点ID")
@TableField("site_id")
private Long siteId;
}
package com.yizhi.point.application.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author Ding
* @className PointImportVO
* @description TODO
* @date 2019/3/28
**/
@Data
@ApiModel(value = "PointImportVO", description = "积分导入")
public class PointImportVO {
@ApiModelProperty("用户名")
private String name;
@ApiModelProperty("用户Id")
private Long accountId;
@ApiModelProperty("经验")
private Integer point;
@ApiModelProperty("导入说明")
private String description;
@ApiModelProperty("行数")
private Integer rowNumber;
}
package com.yizhi.point.application.vo;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.annotations.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "PointParamVO", description = "其他微服务配置 积分")
public class
PointParamVO implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
private String id;
@ApiModelProperty(value = "事件名称")
private String eventName;
@ApiModelProperty(value = "事件类型/学习活动类型, 枚举 统一传入 ActivityTypeEnum.类型")
private String activityType;
@ApiModelProperty(value = "学习活动来源")
private String activitySource;
@ApiModelProperty(value = "积分来源Id, 存放业务主键, 课程Id,调研Id,考试Id, 投票ID, 作业ID")
private Long sourceId;
@ApiModelProperty(value = "课程id")
private Long courseId;
@ApiModelProperty(value = "如果是考试,发送考试成绩")
private Integer score;
@ApiModelProperty(value = "积分规则 1按课程 2 按章节 3 按素材")
private Integer portRule;
@ApiModelProperty(value = "学习活动名称")
private String activityName;
@ApiModelProperty(value = "发放条件")
private String releaseCondition;
@ApiModelProperty(value = "发放规则")
private String releaseRules;
@ApiModelProperty(value = "积分数量, 正数 加积分, 负数减积分")
private Integer operatingPoint;
@ApiModelProperty(value = "积分活动创建时间")
private Date createPointTime;
@ApiModelProperty(value = "学员id")
private Long accountId;
@ApiModelProperty(value = "学员姓名")
private String accountName;
private Long siteId;
private Long orgId;
private Long companyId;
}
package com.yizhi.point.application.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "积分排名列表", description = "PointUserListVO")
public class PointUserListVO {
@ApiModelProperty("用户id")
private Long userId;
@ApiModelProperty("用户名")
private String userName;
@ApiModelProperty("姓名")
private String name;
@ApiModelProperty("所在部门id")
private Long orgId;
@ApiModelProperty("所在部门")
private String orgName;
@ApiModelProperty("所在组织架构")
private String orgNames;
@ApiModelProperty("邮箱")
private String email;
@ApiModelProperty("总积分")
private String totalPoint;
@ApiModelProperty("等级")
private String levelName;
@ApiModelProperty("用户状态")
private boolean accountState;
@ApiModelProperty("起始日期")
private String startDate;
}
package com.yizhi.point.application.vo;
import java.util.Date;
import java.util.List;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "PointUserParamVO", description = "积分排名")
public class PointUserParamVO {
@ApiModelProperty("用户名")
private String userName;
private String orgNameLike;
@ApiModelProperty("用户集合")
private List<Long> accountIds;
private Long siteId;
private Long companyId;
private Long orgId;
private Long accountId;
private Integer pageNo;
private Integer pageSize;
private List<Long> orgIds;
private boolean isAdmin;
private Date startAt;
private Date endAt;
}
package com.yizhi.point.application.vo;
import lombok.Data;
@Data
public class TotalPointVO {
private Long accountId;
private Long point;
}
package com.yizhi.point.application.vo.domain;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* mq消息
* </p>
*
* @author bob123
* @since 2018-05-08
*/
@Data
@ApiModel(value = "MqPointParamVo", description = "mq消息存储")
@TableName("mq_point_param")
public class MqPointParamVo extends Model<MqPointParamVo> {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
private String id;
@ApiModelProperty(value = "事件名称")
@TableField("event_name")
private String eventName;
@ApiModelProperty(value = "事件类型/学习活动类型, 枚举 统一传入 ActivityTypeEnum.类型")
@TableField("activity_type")
private String activityType;
@ApiModelProperty(value = "学习活动来源")
@TableField("activity_source")
private String activitySource;
@ApiModelProperty(value = "积分来源Id, 存放业务主键, 课程Id,调研Id,考试Id, 投票ID, 作业ID")
@TableField("source_id")
private Long sourceId;
@ApiModelProperty(value = "课程id")
@TableField("course_id")
private Long courseId;
@ApiModelProperty(value = "学习活动名称")
@TableField("activity_name")
private String activityName;
@ApiModelProperty(value = "发放条件")
@TableField("release_condition")
private String releaseCondition;
@ApiModelProperty(value = "发放规则")
@TableField("release_rules")
private String releaseRules;
@ApiModelProperty(value = "积分数量, 正数 加积分, 负数减积分")
@TableField("operating_point")
private Integer operatingPoint;
@ApiModelProperty(value = "积分活动创建时间")
@TableField("create_point_time")
private Date createPointTime;
@ApiModelProperty(value = "学员id")
@TableField("account_id")
private Long accountId;
@ApiModelProperty(value = "学员姓名")
@TableField("account_name")
private String accountName;
@TableField("site_id")
private Long siteId;
@TableField("org_id")
private Long orgId;
@TableField("company_id")
private Long companyId;
private Integer state;
@Override
protected Serializable pkVal() {
return this.id;
}
}
package com.yizhi.point.application.vo.domain;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 活动策略
* </p>
*
* @author bob123
* @since 2018-04-20
*/
@Data
@ApiModel(value = "PointActivityVo", description = "积分策略")
@TableName("point_activity")
public class PointActivityVo extends Model<PointActivityVo> {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "活动策略ID")
private Long id;
@ApiModelProperty(value = "活动策略名称")
@TableField("activity_name")
private String activityName;
@ApiModelProperty(value = "默认为1,不翻倍")
private Integer multiple;
@ApiModelProperty(value = "发放开始时间")
@TableField("start_time")
private Date startTime;
@ApiModelProperty(value = "发放结束时间")
@TableField("end_time")
private Date endTime;
@ApiModelProperty(value = "0删除 1草稿 2启用 3未启用")
private Integer state;
@ApiModelProperty(value = "创建时间")
@TableField("create_time")
private Date createTime;
@ApiModelProperty(value = "创建人")
@TableField("create_by_id")
private Long createById;
@ApiModelProperty(value = "创建人姓名")
@TableField("create_by_name")
private String createByName;
@ApiModelProperty(value = "修改时间")
@TableField("update_time")
private Date updateTime;
@ApiModelProperty(value = "修改人")
@TableField("update_by_id")
private Long updateById;
@ApiModelProperty(value = "修改人姓名")
@TableField("update_by_name")
private String updateByName;
@ApiModelProperty(value = "启用时间")
@TableField("enable_time")
private Date enableTime;
@ApiModelProperty(value = "启用人")
@TableField("enable_by_id")
private Long enableById;
@ApiModelProperty(value = "启用人姓名")
@TableField("enable_by_name")
private String enableByName;
@ApiModelProperty(value = "公司ID")
@TableField("company_id")
private Long companyId;
@ApiModelProperty(value = "部门ID")
@TableField("org_id")
private Long orgId;
@ApiModelProperty(value = "站点ID")
@TableField("site_id")
private Long siteId;
@Override
protected Serializable pkVal() {
return this.id;
}
}
package com.yizhi.point.application.vo.domain;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 积分明细
* </p>
*
* @author bob123
* @since 2018-04-20
*/
@Data
@ApiModel(value = "PointDetailsVo", description = "积分详情")
@TableName("point_details")
public class PointDetailsVo extends Model<PointDetailsVo> {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "积分明细ID")
private Long id;
@ApiModelProperty(value = "活动策略ID")
@TableField("activity_id")
private Long activityId;
// @ApiModelProperty(value = "事件名称")
// @TableField("event_name")
// private String eventName;
@ApiModelProperty(value = "时间")
private Date time;
@ApiModelProperty(value = "积分")
private Integer point;
@ApiModelProperty(value = "学员号")
@TableField("account_id")
private Long accountId;
@ApiModelProperty(value = "学习活动类型")
@TableField("learn_type")
private String learnType;
@ApiModelProperty(value = "学习活动名称")
@TableField("learn_name")
private String learnName;
@ApiModelProperty(value = "学习活动来源")
@TableField("learn_source")
private String learnSource;
@ApiModelProperty(value = "积分来源Id, 存放业务主键, 课程Id,调研Id,考试Id, 投票ID, 作业ID")
@TableField("learn_source_id")
private Long learnSourceId;
@ApiModelProperty(value = "课程id(如果是课程按章节发放)")
@TableField("course_id")
private Long courseId;
// @ApiModelProperty(value = "发放条件")
// @TableField("release_condition")
// private String releaseCondition;
//
// @ApiModelProperty(value = "发放规则")
// @TableField("release_rules")
// private String releaseRules;
@ApiModelProperty(value = "状态 0 删除, 1 未删除")
private Integer state;
@ApiModelProperty(value = "创建时间")
@TableField("create_time")
private Date createTime;
@ApiModelProperty(value = "创建人")
@TableField("create_by_id")
private Long createById;
@ApiModelProperty(value = "创建人姓名")
@TableField("create_by_name")
private String createByName;
@ApiModelProperty(value = "修改时间")
@TableField("update_time")
private Date updateTime;
@ApiModelProperty(value = "修改人")
@TableField("update_by_id")
private Long updateById;
@ApiModelProperty(value = "修改人姓名")
@TableField("update_by_name")
private String updateByName;
@ApiModelProperty(value = "公司ID")
@TableField("company_id")
private Long companyId;
@ApiModelProperty(value = "部门ID")
@TableField("org_id")
private Long orgId;
@ApiModelProperty(value = "站点ID")
@TableField("site_id")
private Long siteId;
@ApiModelProperty(value = "积分活动翻倍的倍数")
@TableField("multiple")
private Integer multiple;
@ApiModelProperty(value = "变动原因")
private String changeReason;
@ApiModelProperty(value = "变动前积分总量")
private Integer changeBefore;
@ApiModelProperty(value = "变动后积分总量")
private Integer changeAfter;
@Override
protected Serializable pkVal() {
return this.id;
}
}
package com.yizhi.point.application.vo.domain;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 积分等级
* </p>
*
* @author bob123
* @since 2018-04-20
*/
@Data
@ApiModel(value = "PointLevelVo", description = "积分等级")
@TableName("point_level")
public class PointLevelVo extends Model<PointLevelVo> {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "积分等级ID")
private Long id;
@ApiModelProperty(value = "等级序号")
@TableField("level_no")
private Integer levelNo;
@ApiModelProperty(value = "等级名称")
@TableField("level_name")
private String levelName;
@ApiModelProperty(value = "分值区间开始")
@TableField("start_score")
private Integer startScore;
@ApiModelProperty(value = "分值区间结束")
@TableField("end_score")
private Integer endScore;
@ApiModelProperty(value = "状态 0删除 1有效")
private Integer state;
@ApiModelProperty(value = "创建时间")
@TableField("create_time")
private Date createTime;
@ApiModelProperty(value = "创建人")
@TableField("create_by_id")
private Long createById;
@ApiModelProperty(value = "创建人姓名")
@TableField("create_by_name")
private String createByName;
@ApiModelProperty(value = "修改时间")
@TableField("update_time")
private Date updateTime;
@ApiModelProperty(value = "修改人")
@TableField("update_by_id")
private Long updateById;
@ApiModelProperty(value = "修改人姓名")
@TableField("update_by_name")
private String updateByName;
@ApiModelProperty(value = "公司ID")
@TableField("company_id")
private Long companyId;
@ApiModelProperty(value = "部门ID")
@TableField("org_id")
private Long orgId;
@ApiModelProperty(value = "站点ID")
@TableField("site_id")
private Long siteId;
@Override
protected Serializable pkVal() {
return this.id;
}
}
package com.yizhi.point.application.vo.domain;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 学员积分
* </p>
*
* @author bob123
* @since 2018-04-20
*/
@Data
@ApiModel(value = "PointUserVo", description = "用户积分")
@TableName("point_user")
public class PointUserVo extends Model<PointUserVo> {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "外键")
@TableField("user_id")
private Long userId;
@ApiModelProperty(value = "总积分")
@TableField("total_point")
private Integer totalPoint;
@ApiModelProperty(value = "未使用积分")
@TableField("unused_point")
private Integer unusedPoint;
@ApiModelProperty(value = "状态 0 删除, 1 未删除")
private Integer state;
@ApiModelProperty(value = "创建时间")
@TableField("create_time")
private Date createTime;
@ApiModelProperty(value = "创建人")
@TableField("create_by_id")
private Long createById;
@ApiModelProperty(value = "创建人姓名")
@TableField("create_by_name")
private String createByName;
@ApiModelProperty(value = "修改时间")
@TableField("update_time")
private Date updateTime;
@ApiModelProperty(value = "修改人")
@TableField("update_by_id")
private Long updateById;
@ApiModelProperty(value = "修改人姓名")
@TableField("update_by_name")
private String updateByName;
@ApiModelProperty(value = "公司ID")
@TableField("company_id")
private Long companyId;
@ApiModelProperty(value = "部门ID")
@TableField("org_id")
private Long orgId;
@ApiModelProperty(value = "站点ID")
@TableField("site_id")
private Long siteId;
@Override
protected Serializable pkVal() {
return this.id;
}
}
package com.yizhi.point.application.vo.domain;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 积分设置
* </p>
*
* @author bob123
* @since 2018-04-20
*/
@Data
@ApiModel(value = "PointVo", description = "积分")
@TableName("point")
public class PointVo extends Model<PointVo> {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "积分策略ID")
private Long id;
@ApiModelProperty(value = "积分单位")
private String unit;
@ApiModelProperty(value = "是否启用 0:未启用 1 启用")
private Integer state;
@ApiModelProperty(value = "创建时间")
@TableField("create_time")
private Date createTime;
@ApiModelProperty(value = "创建人")
@TableField("create_by_id")
private Long createById;
@ApiModelProperty(value = "创建人姓名")
@TableField("create_by_name")
private String createByName;
@ApiModelProperty(value = "修改时间")
@TableField("update_time")
private Date updateTime;
@ApiModelProperty(value = "修改人")
@TableField("update_by_id")
private Long updateById;
@ApiModelProperty(value = "修改人姓名")
@TableField("update_by_name")
private String updateByName;
@ApiModelProperty(value = "启用时间")
@TableField("enable_time")
private Date enableTime;
@ApiModelProperty(value = "启用人")
@TableField("enable_by_id")
private Long enableById;
@ApiModelProperty(value = "启用人姓名")
@TableField("enable_by_name")
private String enableByName;
@ApiModelProperty(value = "公司ID")
@TableField("company_id")
private Long companyId;
@ApiModelProperty(value = "部门ID")
@TableField("org_id")
private Long orgId;
@ApiModelProperty(value = "站点ID")
@TableField("site_id")
private Long siteId;
@Override
protected Serializable pkVal() {
return this.id;
}
}
/.apt_generated/
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<parent>
<groupId>com.yizhi</groupId>
<artifactId>point-project</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cloud-point</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-point-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-system-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-newMessage-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-custom-project-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-orm</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-util</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-common-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
<version>3.5.0</version>
</dependency>
<!--redisson 需要用到netty的jar 包-->
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.7.Final</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-spring-web</artifactId>-->
<!-- <version>2.7.0</version>-->
<!-- </dependency>-->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
package com.yizhi.application;
import org.hibernate.annotations.Entity;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
@SpringBootApplication
@EnableCaching
@EnableDiscoveryClient
@EnableFeignClients(basePackages = {"com.yizhi"})
@ComponentScan(basePackages = {"com.yizhi"})
@EnableJpaAuditing
@EnableJpaRepositories
public class PointApplication {
public static void main(String[] args) {
SpringApplication.run(PointApplication.class, args);
}
}
package com.yizhi.application;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class SwaggerConfig extends WebMvcConfigurerAdapter {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("考试-积分")
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.fulan.application"))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("积分")
//版本
.version("1.0")
.build();
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("docs.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
package com.yizhi.application.constant;
public enum PointChangeReasonConstant {
CREDITEXAMDONE("CreditExamDone", "考试阅卷通过"),
CREDITCOURSEDONE1("CreditCourseDone1", "课程学习完成"),
CREDITEXAMPASSED("CreditExamPassed", "考试通过"),
CREDITRESEARCHDONE("CreditResearchDone", "调研通过"),
CREDITCOURSECHAPTERDONE("CreditCourseChapterDone", "课程章节完成"),
CREDITASSIGNMENTPASSED("CreditAssignmentPassed", "作业通过"),
CREDITQUIZPASSED("CreditQuizPassed", "课程章节测验通过"),
CREDITOFFLINEDONE("CreditOfflineDone", "线下课程通过"),
CREDITCOURSEDONE2("CreditCourseDone2", "课程学习完成"),
CREDITEXTERNALIMPORT("CreditExternalImport", "外部导入积分"),
CREDITTRAININGPROJECTDONE("CreditTrainingProjectDone", "学习项目通过"),
CREDITCASELIBRARYDONE("CreditCaseLibraryDone", "案例活动审核通过"),
CREDITFORUMINVITATION("CreditForumInvitation", "发布论坛帖子发放积分"),
CREDITFORUMCOMMENT("CreditForumComment", "发布论坛回复发放积分"),
CREDITCALENDARDONE("CreditClendarDone", "签到打卡成功"),
CREDITSIGNDONE("CreditSignDone", "项目签到成功");
// key
private String key;
// value
private String value;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
PointChangeReasonConstant(String key, String value) {
this.key = key;
this.value = value;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
}
package com.yizhi.application.constant;
public enum PointConditionEnum {
COURSEISSUE("按课程发放"), CHAPTERISSUE("按课程发放"), METERIAL("按素材发放"),
POINTISSUE("按分数段发放"), EXAMPOINTISSUE("按考试得分发放相应积分"), RESEARCHISSUE("提交调研发放"),
VOTEISSUE("提交投票发放"), ASSIGNMENTISSUE("提交投票发放");
private String key;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
private PointConditionEnum(String key) {
this.key = key;
}
}
package com.yizhi.application.constant;
/**
* 站点常量
*/
public interface PointConstant {
}
package com.yizhi.application.constant;
public enum PointEventEnum {
/**
* 课程
*/
POINTCOURSE("pointCourse"),
/**
* 考试
*/
POINTEXAM("pointExam"),
/**
* 调研
*/
POINTRESEARCH("pointResearch"),
/**
* 投票
*/
POINTVOTE("pointVote"),
/**
* 作业
*/
POINTASSIGNMENT("pointTassgnment"),
/**
* 测验
*/
POINTCOURSETEST("pointCourseTest"),
/**
* 线下课程
*/
POINTOFFLINECOURSE("pointOfflineCourse"),
/**
* 培训项目
*/
POINTTRAININGPROJECT("pointTrainingProject"),
/**
* 案例活动
*/
POINTCASELIBRARY("pointCaseLibrary"),
/**
* 签到打卡
*/
POINTSIGN("pointSign"),
/**
*
*/
POINTFORUM("pointForum"),
/**
*
*/
POINTPROJECTSIGN("pointProjectSign"),
CHAPPRACTICE("practiceChat");
private String key;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
private PointEventEnum(String key) {
this.key = key;
}
}
package com.yizhi.application.controller;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.application.domain.MqPointParam;
import com.yizhi.application.domain.PointActivity;
import com.yizhi.application.orm.util.DomainConverter;
import com.yizhi.application.service.MqPointParamService;
import com.yizhi.application.service.PointActivityService;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.point.application.vo.domain.MqPointParamVo;
import com.yizhi.point.application.vo.domain.PointActivityVo;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* <p>
* 活动策略 前端控制器
* </p>
*
* @author bob123
* @since 2018-04-20
*/
@Api(tags = "活动策略 管理端", description = "活动策略 管理端")
@RestController
@RequestMapping("/manage/activity")
public class PointActivityController {
private static final Logger LOG = LoggerFactory.getLogger(PointActivityController.class);
@Autowired
PointActivityService pointActivityService;
@Autowired
IdGenerator idGenerator;
@Autowired
MqPointParamService mqPointParamService;
@Autowired
DomainConverter domainConverter;
@PostMapping("/insert")
Long insertDetail(@RequestBody PointActivityVo pointActivityVo) {
if (null == pointActivityVo) {
return null;
}
PointActivity pointActivity1 = new PointActivity();
BeanUtils.copyProperties(pointActivityVo, pointActivity1);
return pointActivityService.insertDetail(pointActivity1);
}
@PostMapping("/update")
Long updateById(@RequestBody PointActivityVo pointActivityVo) {
if (null == pointActivityVo) {
return null;
}
PointActivity pointActivity1 = new PointActivity();;
BeanUtils.copyProperties(pointActivityVo, pointActivity1);
Boolean isOk = pointActivityService.updateById(pointActivity1);
if (isOk) {
return pointActivityVo.getId();
}
return null;
}
@PostMapping("/delete")
Long deleteDetailById(@RequestBody PointActivityVo pointActivityVo) {
if (null == pointActivityVo) {
return null;
}
PointActivity pointActivity1 = new PointActivity();
BeanUtils.copyProperties(pointActivityVo, pointActivity1);
Long i = pointActivityService.deleteDetailById(pointActivity1);
return i;
}
@PostMapping("/enabled")
Boolean bannerUp(@RequestBody PointActivityVo pointActivityVo) {
if (null == pointActivityVo) {
return false;
}
PointActivity pointActivity1 = new PointActivity();
BeanUtils.copyProperties(pointActivityVo, pointActivity1);
return pointActivityService.pointUp(pointActivity1.getId(), pointActivity1.getUpdateById(), pointActivity1.getUpdateByName());
}
@PostMapping("/disabled")
Boolean bannerDown(@RequestBody PointActivityVo pointActivityVo) {
if (null == pointActivityVo) {
return false;
}
PointActivity pointActivity1 = new PointActivity();
BeanUtils.copyProperties(pointActivityVo, pointActivity1);
return pointActivityService.pointDown(pointActivity1.getId(), pointActivity1.getUpdateById(), pointActivity1.getUpdateByName());
}
@GetMapping("/list")
public Page<PointActivityVo> activityList(@RequestParam Map<String, Object> map) {
Page<PointActivity> list = null;
Page<PointActivityVo> list2 = null;
if (null == map) {
return null;
}
try {
Integer pageNo = Integer.valueOf((String) map.get("pageNo"));
Integer pageSize = Integer.valueOf((String) map.get("pageSize"));
Page<PointActivity> page = new Page<PointActivity>(pageNo, pageSize);
list = pointActivityService.activityList(page, map);
list2 = new Page<>(pageNo, pageSize);
List<PointActivity> records = list.getRecords();
List<PointActivityVo> list1 = domainConverter.toDOList(records, PointActivity.class);
BeanUtils.copyProperties(list, list2);
list2.setRecords(list1);
} catch (Exception e) {
LOG.error("服务出错。", e);
}
return list2;
}
@GetMapping("/getPointRecords")
List<MqPointParamVo> getPointRecords(String eventName, Long activityId, Long companyId, Long siteId) {
MqPointParam mqPointParam = new MqPointParam();
mqPointParam.setEventName(eventName);
mqPointParam.setSourceId(activityId);
mqPointParam.setCompanyId(companyId);
mqPointParam.setSiteId(siteId);
mqPointParam.setState(1);
EntityWrapper<MqPointParam> entityWrapper = new EntityWrapper<>(mqPointParam);
entityWrapper.groupBy("account_id");
List<MqPointParam> list = mqPointParamService.selectList(entityWrapper);
List<MqPointParamVo> list2 = null;
BeanUtils.copyProperties(list, list2);
return list2;
}
}
package com.yizhi.application.controller;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.yizhi.application.domain.Point;
import com.yizhi.application.service.PointDetailsService;
import com.yizhi.application.service.PointService;
import com.yizhi.point.application.vo.PointDetailsVO;
import com.yizhi.point.application.vo.domain.PointVo;
import com.yizhi.system.application.system.remote.AccountClient;
import com.yizhi.system.application.vo.AccountVO;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.plugins.Page;
import io.swagger.annotations.Api;
/**
* <p>
* 积分设置 前端控制器
* </p>
*
* @author bob123
* @since 2018-04-20
*/
@Api(tags="积分 管理端", description="积分 管理端")
@RestController
@RequestMapping("/manage/point")
public class PointController {
private static final Logger LOG = LoggerFactory.getLogger(PointController.class);
@Autowired
PointService pointService;
@Autowired
PointDetailsService pointDetailsService;
@Autowired
AccountClient accountClient;
@GetMapping("/strategy/view")
public PointVo pointList(@RequestParam(name = "companyId",required = false)Long companyId,
@RequestParam(name = "siteId",required = false) Long siteId){
Point point = pointService.pointList(companyId, siteId);
PointVo point1 = new PointVo();
BeanUtils.copyProperties(point, point1);
return point1;
}
@PostMapping("/strategy/update")
public boolean pointList(@RequestBody Point point){
return pointService.updateList(point);
}
@GetMapping("/details/list")
Page<PointDetailsVO> getManagePointDetails(
@RequestParam(name = "activityId", required = false) Long activityId,
@RequestParam(name = "accountName", required = false) String accountName,
@RequestParam(name = "startTime", required = false) Long startTime, @RequestParam(name = "endTime", required = false) Long endTime,
@RequestParam(name = "pageNo", required = false) Integer pageNo, @RequestParam(name = "pageSize", required = false) Integer pageSize,
@RequestParam(name = "companyId", required = false) Long companyId, @RequestParam(name = "siteId", required = false) Long siteId){
List<Long> accountIds = new ArrayList<Long>();
try{
if(!StringUtils.isBlank(accountName)){
List<AccountVO> accountVOs = accountClient.fuzzySearchAccountByName(accountName, companyId);
if(accountVOs == null || accountVOs.size() == 0){
LOG.info("积分服务获取用户调用:AccountClient.fuzzySearchAccountByName 搜索不到 " + accountName + "的用户信息");
}
for(AccountVO item : accountVOs){
accountIds.add(item.getId());
}
}
} catch(Exception e){
LOG.error("积分服务获取用户调用:AccountClient.fuzzySearchAccountByName错误" + e.getMessage());
e.printStackTrace();
}
Page<PointDetailsVO> page = null;
if((accountIds != null && accountIds.size() > 0) || StringUtils.isBlank(accountName)){
Date startDate = null;
if (null != startTime) {
startDate = new Date(startTime);
}
Date endDate = null;
if (null != endTime) {
endDate = new Date(endTime);
}
page = pointDetailsService.getManagePointDetails(pageNo, pageSize, activityId, accountIds,
startDate, endDate, companyId, siteId);
List<PointDetailsVO> dtlIds = page.getRecords();
AccountVO accountVO = null;
String name = "";
for(PointDetailsVO dtl : dtlIds){
try{
accountVO = accountClient.findById(Long.valueOf(dtl.getAccountId()));
name = accountVO.getName();
} catch(Exception e){
LOG.info("积分服务获取用户信息报错:" + e.getMessage());
name = "--";
e.printStackTrace();
}
dtl.setAccountName(name);
}
} else {
page = new Page<PointDetailsVO>(pageNo, pageSize);
page.setTotal(0);
}
return page;
}
@GetMapping("/update/after")
public void updatePointDetailsChangeAfter(
@RequestParam(name = "siteId" ,required = false ) Long siteId,
@RequestParam(name = "accountId" ,required = false ) Long accountId) {
pointDetailsService.updateChangeAfter(accountId,siteId);
}
}
package com.yizhi.application.controller;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.yizhi.application.domain.PointDetails;
import com.yizhi.application.service.PointDetailsService;
import com.yizhi.point.application.vo.PointImportVO;
import com.yizhi.point.application.vo.domain.PointDetailsVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
/**
* <p>
* 积分明细 前端控制器
* </p>
*
* @author bob123
* @since 2018-04-20
*/
@Api(tags = "我的积分 学员端", description = "我的积分 学员端")
@RestController
@RequestMapping("/api/point/detail")
public class PointDetailsController {
private static final Logger LOG = LoggerFactory.getLogger(PointDetailsController.class);
@Autowired
PointDetailsService pointDetailsService;
@GetMapping("/pointList")
public Map<String, Object> pointList(@RequestParam("year") String year,
@RequestParam(value = "type", required = false) String type,
@RequestParam("accountId") Long accountId,
@RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize, @RequestParam("companyId") Long companyId,
@RequestParam("siteId") Long siteId, @RequestParam("orgId") Long orgId) {
return pointDetailsService.pointList(year, type, accountId, pageNo, pageSize, companyId, siteId, orgId);
}
@GetMapping("/countList")
public Integer queryPiont(@RequestParam(name = "userId", required = false) Long userId, @RequestParam(name = "companyId", required = false) Long companyId,
@RequestParam("siteId") Long siteId, @RequestParam(name = "orgId", required = false) Long orgId) {
return pointDetailsService.queryPiont(userId, companyId, siteId, orgId);
}
@PostMapping("/pointImport")
boolean insertExternalPoint(@RequestBody List<PointImportVO> importVOList,
@RequestParam("companyId") Long companyId,
@RequestParam("siteId") Long siteId,
@RequestParam("orgId") Long orgId,
@RequestParam("accountId") Long accountId,
@RequestParam("accountName") String accountName) {
return pointDetailsService.pointImport(importVOList, companyId, siteId, orgId, accountId, accountName);
}
@GetMapping("/statisticsPoint")
List<PointDetailsVo> statisticsPoint() {
List<PointDetails> pointDetails = pointDetailsService.statisticsPoint();
List<PointDetailsVo> list = new ArrayList<>();
for (PointDetails s:pointDetails
) {
PointDetailsVo pointLevelVo =new PointDetailsVo();
BeanUtils.copyProperties(s,pointLevelVo);
list.add(pointLevelVo);
}
return list;
}
@GetMapping("/getPointByCondition")
public Integer getPointByCondition(@RequestParam("accountId") Long accountId,
@RequestParam("siteId") Long siteId,
@RequestParam("bizIds") List<Long> bizIds) {
return pointDetailsService.getPointByCondition(accountId, siteId, bizIds);
}
/**
* 统计积分明细
*/
@GetMapping("/sync/list")
public List<PointDetailsVo> syncPointDetails(@RequestParam(name = "startDate",required = false) String startDate,
@RequestParam(name = "endDate",required = false) String endDate ,
@RequestParam(name = "companyId",required = false) Long companyId ,
@RequestParam(name = "siteId",required = false) Long siteId
){
DateTime yesterday = DateUtil.yesterday();
Date startTime = DateUtil.beginOfDay(yesterday);
Date endTime = DateUtil.endOfDay(yesterday);
if (!StringUtils.isEmpty(startDate)){
startTime = DateUtil.parse(startDate, "yyyy-MM-dd HH:mm:ss");
}
if (!StringUtils.isEmpty(endDate)){
endTime = DateUtil.parse(endDate, "yyyy-MM-dd HH:mm:ss");
}
return pointDetailsService.syncPointDetails(startTime,endTime,companyId,siteId);
}
}
package com.yizhi.application.controller;
import java.util.ArrayList;
import java.util.List;
import com.yizhi.application.domain.PointLevel;
import com.yizhi.application.service.PointLevelService;
import com.yizhi.point.application.vo.domain.PointLevelVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
/**
* <p>
* 积分等级 前端控制器
* </p>
*
* @author bob123
* @since 2018-04-20
*/
@Api(tags="积分等级 管理端", description="积分等级 管理端")
@RestController
@RequestMapping("/manage/point/level")
public class PointLevelController {
@Autowired
PointLevelService pointLevelService;
@PostMapping("/insert")
Boolean inserts(@RequestBody com.yizhi.application.domain.PointLevel pointLevel){
return pointLevelService.inserts(pointLevel);
}
@GetMapping("/update")
Integer updateById(com.yizhi.application.domain.PointLevel pointLevel) {
return pointLevelService.updateById1(pointLevel);
}
@PostMapping("/delete")
Boolean piontLevelDelete(@RequestParam Long id) {
return pointLevelService.piontLevelDelete(id);
}
@GetMapping("/list")
public List<PointLevelVo> levelList(
@RequestParam Long id){
List<PointLevel> pointLevels = pointLevelService.levelList(id);
List<PointLevelVo> pointLevels1 = new ArrayList<>();
for (PointLevel s:pointLevels
) {
PointLevelVo pointLevelVo =new PointLevelVo();
BeanUtils.copyProperties(s,pointLevelVo);
pointLevels1.add(pointLevelVo);
}
return pointLevels1;
}
}
package com.yizhi.application.controller;
import com.yizhi.application.domain.MqPointParam;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.application.redis.RedisUtils;
import com.yizhi.application.service.MqPointParamService;
import com.yizhi.point.application.vo.PointParamVO;
import org.springframework.beans.BeanUtils;
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.RestController;
@RestController
public class PointRedisController {
@Autowired
RedisUtils redisUtils;
@Autowired
private IdGenerator idGenerator;
@Autowired
private MqPointParamService mqPointParamService;
@PostMapping("/point/redis/add")
public String addPointRedis(@RequestBody PointParamVO vo) {
String key = idGenerator.generate().toString();
vo.setId(key);
boolean boo = redisUtils.set(key, vo, 10800L);
if(boo){
MqPointParam mqPointParam = new MqPointParam();
BeanUtils.copyProperties(vo, mqPointParam);
mqPointParam.setState(1);
mqPointParamService.insert(mqPointParam);
return key;
}
return null;
}
}
package com.yizhi.application.controller;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.yizhi.application.domain.PointDetails;
import com.yizhi.application.service.PointDetailsService;
import com.yizhi.application.service.PointUserService;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.point.application.vo.PointUserListVO;
import com.yizhi.point.application.vo.PointUserParamVO;
import com.yizhi.point.application.vo.domain.PointDetailsVo;
import com.yizhi.system.application.system.remote.ReportClient;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.plugins.Page;
import io.swagger.annotations.Api;
/**
* <p>
* 学员积分 前端控制器
* </p>
*
* @author bob123
* @since 2018-04-20
*/
@Api(tags = "学员积分 管理端", description = "学员积分 管理端")
@RestController
@RequestMapping("/manage/point/user")
public class PointUserController {
@Autowired
PointUserService pointUserService;
@Autowired
PointDetailsService pointDetailsService;
@Autowired
ReportClient reportClient;
@GetMapping("/countList")
public Integer queryPiont(@RequestParam(name = "userId", required = false) Long userId) {
RequestContext res = ContextHolder.get();
return pointUserService.queryPiont(userId, res.getCompanyId(), res.getSiteId());
}
@GetMapping("/rank/list")
public Page<PointUserListVO> userRankList(@RequestBody PointUserParamVO vo) {
return pointUserService.userRankList(vo);
}
@GetMapping("/rank/list/export")
public List<PointUserListVO> userRankListExport(@RequestBody PointUserParamVO vo) {
return pointUserService.userRankListExport(vo);
}
@GetMapping("/rank/list/startDate")
public Timestamp getStartDate() {
return pointUserService.getStartDate();
}
@GetMapping("/point/acquire")
public Integer acquirePoint(@RequestParam(name = "accountId", required = true) Long accountId,
@RequestParam(name = "learnSourceId", required = true) Long learnSourceId,
@RequestParam(name = "createTime", required = true) String createTime) {
return pointUserService.acquirePoint(accountId, learnSourceId, createTime);
}
@GetMapping("/point/isHasPoint")
public boolean isHasPoint(@RequestParam("bizId") Long bizId, @RequestParam("accountId") Long accountId) {
com.yizhi.application.domain.PointDetails pointDetails = new com.yizhi.application.domain.PointDetails();
pointDetails.setLearnSourceId(bizId);
pointDetails.setAccountId(accountId);
pointDetails.setState(1);
List<com.yizhi.application.domain.PointDetails> pointDetailsList = pointDetailsService.selectList(new EntityWrapper<>(pointDetails));
if (CollectionUtils.isNotEmpty(pointDetailsList)) {
return true;
} else {
return false;
}
}
/**
* 报表获取业务积分记录,可获取所有,可根据业务id,accountId
*
* @param bizId
* @param accountId
* @param companyId
* @param siteId
* @return
*/
@GetMapping("/getReportPoints")
public List<PointDetailsVo> getReportPoints(@RequestParam(value = "bizId", required = false) Long bizId, @RequestParam(value = "accountId", required = false) Long accountId,
@RequestParam(value = "companyId", required = false) Long companyId, @RequestParam(value = "siteId", required = false) Long siteId,
@RequestParam(value = "isRealTime", required = true) boolean isRealTime) {
List<PointDetailsVo> pointDetailsVo2 = new ArrayList<>();
List<PointDetails> reportPoints = pointDetailsService.getReportPoints(bizId, accountId, companyId, siteId, isRealTime);
for (PointDetails d:reportPoints
) {
PointDetailsVo p=new PointDetailsVo();
BeanUtils.copyProperties(d,p);
pointDetailsVo2.add(p);
}
return pointDetailsVo2;
}
/**
* 报表获取业务积分记录,可获取所有,可根据业务id,accountId
*
* @param bizId
* @param accountId
* @param isRealTime
* @return
*/
@GetMapping("/getCourseReportPoints")
public List<PointDetailsVo> getCourseReportPoints(@RequestParam(value = "bizId", required = false) Long bizId, @RequestParam(value = "accountId", required = false) Long accountId,
@RequestParam(value = "isRealTime", required = true) boolean isRealTime) {
List<PointDetails> courseReportPoints = pointDetailsService.getCourseReportPoints(bizId, accountId, isRealTime);
List<PointDetailsVo> pointDetailsVo2 = new ArrayList<>();;
for (PointDetails d:courseReportPoints
) {
PointDetailsVo p=new PointDetailsVo();
BeanUtils.copyProperties(d,p);
pointDetailsVo2.add(p);
}
return pointDetailsVo2;
}
@GetMapping("/totalPoint")
public Map<Long, Long> totalPoint( @RequestParam("siteIds") List<Long> siteIds,
@RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate) {
return pointUserService.totalPoint(siteIds, startDate, endDate);
}
}
package com.yizhi.application.domain;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* mq消息
* </p>
*
* @author bob123
* @since 2018-05-08
*/
@Data
@ApiModel(value = "MqPointParamVo", description = "mq消息存储")
@TableName("mq_point_param")
public class MqPointParam extends Model<MqPointParam> {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
private String id;
@ApiModelProperty(value = "事件名称")
@TableField("event_name")
private String eventName;
@ApiModelProperty(value = "事件类型/学习活动类型, 枚举 统一传入 ActivityTypeEnum.类型")
@TableField("activity_type")
private String activityType;
@ApiModelProperty(value = "学习活动来源")
@TableField("activity_source")
private String activitySource;
@ApiModelProperty(value = "积分来源Id, 存放业务主键, 课程Id,调研Id,考试Id, 投票ID, 作业ID")
@TableField("source_id")
private Long sourceId;
@ApiModelProperty(value = "课程id")
@TableField("course_id")
private Long courseId;
@ApiModelProperty(value = "学习活动名称")
@TableField("activity_name")
private String activityName;
@ApiModelProperty(value = "发放条件")
@TableField("release_condition")
private String releaseCondition;
@ApiModelProperty(value = "发放规则")
@TableField("release_rules")
private String releaseRules;
@ApiModelProperty(value = "积分数量, 正数 加积分, 负数减积分")
@TableField("operating_point")
private Integer operatingPoint;
@ApiModelProperty(value = "积分活动创建时间")
@TableField("create_point_time")
private Date createPointTime;
@ApiModelProperty(value = "学员id")
@TableField("account_id")
private Long accountId;
@ApiModelProperty(value = "学员姓名")
@TableField("account_name")
private String accountName;
@TableField("site_id")
private Long siteId;
@TableField("org_id")
private Long orgId;
@TableField("company_id")
private Long companyId;
private Integer state;
@Override
protected Serializable pkVal() {
return this.id;
}
}
package com.yizhi.application.domain;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 积分设置
* </p>
*
* @author bob123
* @since 2018-04-20
*/
@Data
@ApiModel(value = "PointVo", description = "积分")
@TableName("point")
public class Point extends Model<Point> {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "积分策略ID")
private Long id;
@ApiModelProperty(value = "积分单位")
private String unit;
@ApiModelProperty(value = "是否启用 0:未启用 1 启用")
private Integer state;
@ApiModelProperty(value = "创建时间")
@TableField("create_time")
private Date createTime;
@ApiModelProperty(value = "创建人")
@TableField("create_by_id")
private Long createById;
@ApiModelProperty(value = "创建人姓名")
@TableField("create_by_name")
private String createByName;
@ApiModelProperty(value = "修改时间")
@TableField("update_time")
private Date updateTime;
@ApiModelProperty(value = "修改人")
@TableField("update_by_id")
private Long updateById;
@ApiModelProperty(value = "修改人姓名")
@TableField("update_by_name")
private String updateByName;
@ApiModelProperty(value = "启用时间")
@TableField("enable_time")
private Date enableTime;
@ApiModelProperty(value = "启用人")
@TableField("enable_by_id")
private Long enableById;
@ApiModelProperty(value = "启用人姓名")
@TableField("enable_by_name")
private String enableByName;
@ApiModelProperty(value = "公司ID")
@TableField("company_id")
private Long companyId;
@ApiModelProperty(value = "部门ID")
@TableField("org_id")
private Long orgId;
@ApiModelProperty(value = "站点ID")
@TableField("site_id")
private Long siteId;
@Override
protected Serializable pkVal() {
return this.id;
}
}
package com.yizhi.application.domain;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 活动策略
* </p>
*
* @author bob123
* @since 2018-04-20
*/
@Data
@ApiModel(value = "PointActivityVo", description = "积分策略")
@TableName("point_activity")
public class PointActivity extends Model<PointActivity> {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "活动策略ID")
private Long id;
@ApiModelProperty(value = "活动策略名称")
@TableField("activity_name")
private String activityName;
@ApiModelProperty(value = "默认为1,不翻倍")
private Integer multiple;
@ApiModelProperty(value = "发放开始时间")
@TableField("start_time")
private Date startTime;
@ApiModelProperty(value = "发放结束时间")
@TableField("end_time")
private Date endTime;
@ApiModelProperty(value = "0删除 1草稿 2启用 3未启用")
private Integer state;
@ApiModelProperty(value = "创建时间")
@TableField("create_time")
private Date createTime;
@ApiModelProperty(value = "创建人")
@TableField("create_by_id")
private Long createById;
@ApiModelProperty(value = "创建人姓名")
@TableField("create_by_name")
private String createByName;
@ApiModelProperty(value = "修改时间")
@TableField("update_time")
private Date updateTime;
@ApiModelProperty(value = "修改人")
@TableField("update_by_id")
private Long updateById;
@ApiModelProperty(value = "修改人姓名")
@TableField("update_by_name")
private String updateByName;
@ApiModelProperty(value = "启用时间")
@TableField("enable_time")
private Date enableTime;
@ApiModelProperty(value = "启用人")
@TableField("enable_by_id")
private Long enableById;
@ApiModelProperty(value = "启用人姓名")
@TableField("enable_by_name")
private String enableByName;
@ApiModelProperty(value = "公司ID")
@TableField("company_id")
private Long companyId;
@ApiModelProperty(value = "部门ID")
@TableField("org_id")
private Long orgId;
@ApiModelProperty(value = "站点ID")
@TableField("site_id")
private Long siteId;
@Override
protected Serializable pkVal() {
return this.id;
}
}
package com.yizhi.application.domain;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.context.annotation.Primary;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 积分明细
* </p>
*
* @author bob123
* @since 2018-04-20
*/
@Data
@ApiModel(value = "PointDetailsVo", description = "积分详情")
@TableName("point_details")
@Entity
public class PointDetails extends Model<PointDetails> {
private static final long serialVersionUID = 1L;
@Id
@ApiModelProperty(value = "积分明细ID")
private Long id;
@ApiModelProperty(value = "活动策略ID")
@TableField("activity_id")
private Long activityId;
// @ApiModelProperty(value = "事件名称")
// @TableField("event_name")
// private String eventName;
@ApiModelProperty(value = "时间")
private Date time;
@ApiModelProperty(value = "变动前积分总量")
private Integer changeBefore;
@ApiModelProperty(value = "积分")
private Integer point;
@ApiModelProperty(value = "变动后积分总量")
private Integer changeAfter;
@ApiModelProperty(value = "学员号")
@TableField("account_id")
private Long accountId;
@ApiModelProperty(value = "学习活动类型")
@TableField("learn_type")
private String learnType;
@ApiModelProperty(value = "学习活动名称")
@TableField("learn_name")
private String learnName;
@ApiModelProperty(value = "学习活动来源")
@TableField("learn_source")
private String learnSource;
@ApiModelProperty(value = "积分来源Id, 存放业务主键, 课程Id,调研Id,考试Id, 投票ID, 作业ID")
@TableField("learn_source_id")
private Long learnSourceId;
@ApiModelProperty(value = "课程id(如果是课程按章节发放)")
@TableField("course_id")
private Long courseId;
// @ApiModelProperty(value = "发放条件")
// @TableField("release_condition")
// private String releaseCondition;
//
// @ApiModelProperty(value = "发放规则")
// @TableField("release_rules")
// private String releaseRules;
@ApiModelProperty(value = "状态 0 删除, 1 未删除")
private Integer state;
@ApiModelProperty(value = "创建时间")
@TableField("create_time")
private Date createTime;
@ApiModelProperty(value = "创建人")
@TableField("create_by_id")
private Long createById;
@ApiModelProperty(value = "创建人姓名")
@TableField("create_by_name")
private String createByName;
@ApiModelProperty(value = "修改时间")
@TableField("update_time")
private Date updateTime;
@ApiModelProperty(value = "修改人")
@TableField("update_by_id")
private Long updateById;
@ApiModelProperty(value = "修改人姓名")
@TableField("update_by_name")
private String updateByName;
@ApiModelProperty(value = "公司ID")
@TableField("company_id")
private Long companyId;
@ApiModelProperty(value = "部门ID")
@TableField("org_id")
private Long orgId;
@ApiModelProperty(value = "站点ID")
@TableField("site_id")
private Long siteId;
@ApiModelProperty(value = "积分活动翻倍的倍数")
@TableField("multiple")
private Integer multiple;
@Override
protected Serializable pkVal() {
return this.id;
}
}
package com.yizhi.application.domain;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 积分等级
* </p>
*
* @author bob123
* @since 2018-04-20
*/
@Data
@ApiModel(value = "PointLevelVo", description = "积分等级")
@TableName("point_level")
public class PointLevel extends Model<PointLevel> {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "积分等级ID")
private Long id;
@ApiModelProperty(value = "等级序号")
@TableField("level_no")
private Integer levelNo;
@ApiModelProperty(value = "等级名称")
@TableField("level_name")
private String levelName;
@ApiModelProperty(value = "分值区间开始")
@TableField("start_score")
private Integer startScore;
@ApiModelProperty(value = "分值区间结束")
@TableField("end_score")
private Integer endScore;
@ApiModelProperty(value = "状态 0删除 1有效")
private Integer state;
@ApiModelProperty(value = "创建时间")
@TableField("create_time")
private Date createTime;
@ApiModelProperty(value = "创建人")
@TableField("create_by_id")
private Long createById;
@ApiModelProperty(value = "创建人姓名")
@TableField("create_by_name")
private String createByName;
@ApiModelProperty(value = "修改时间")
@TableField("update_time")
private Date updateTime;
@ApiModelProperty(value = "修改人")
@TableField("update_by_id")
private Long updateById;
@ApiModelProperty(value = "修改人姓名")
@TableField("update_by_name")
private String updateByName;
@ApiModelProperty(value = "公司ID")
@TableField("company_id")
private Long companyId;
@ApiModelProperty(value = "部门ID")
@TableField("org_id")
private Long orgId;
@ApiModelProperty(value = "站点ID")
@TableField("site_id")
private Long siteId;
@Override
protected Serializable pkVal() {
return this.id;
}
}
package com.yizhi.application.domain;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 学员积分
* </p>
*
* @author bob123
* @since 2018-04-20
*/
@Data
@ApiModel(value = "PointUserVo", description = "用户积分")
@TableName("point_user")
public class PointUser extends Model<PointUser> {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "外键")
@TableField("user_id")
private Long userId;
@ApiModelProperty(value = "总积分")
@TableField("total_point")
private Integer totalPoint;
@ApiModelProperty(value = "未使用积分")
@TableField("unused_point")
private Integer unusedPoint;
@ApiModelProperty(value = "状态 0 删除, 1 未删除")
private Integer state;
@ApiModelProperty(value = "创建时间")
@TableField("create_time")
private Date createTime;
@ApiModelProperty(value = "创建人")
@TableField("create_by_id")
private Long createById;
@ApiModelProperty(value = "创建人姓名")
@TableField("create_by_name")
private String createByName;
@ApiModelProperty(value = "修改时间")
@TableField("update_time")
private Date updateTime;
@ApiModelProperty(value = "修改人")
@TableField("update_by_id")
private Long updateById;
@ApiModelProperty(value = "修改人姓名")
@TableField("update_by_name")
private String updateByName;
@ApiModelProperty(value = "公司ID")
@TableField("company_id")
private Long companyId;
@ApiModelProperty(value = "部门ID")
@TableField("org_id")
private Long orgId;
@ApiModelProperty(value = "站点ID")
@TableField("site_id")
private Long siteId;
@Override
protected Serializable pkVal() {
return this.id;
}
}
package com.yizhi.application.listener;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
@Component
public class CreateQueues {
@Bean
public Queue voteQueue(){
return new Queue("vote");
}
@Bean
public Queue researchQueue(){
return new Queue("research");
}
@Bean
public Queue examQueue(){
return new Queue("exam");
}
@Bean
public Queue courseQueue(){
return new Queue("course");
}
@Bean
public Queue assignmentQueue(){
return new Queue("assignment");
}
@Bean
public Queue courseTestQueue(){
return new Queue("courseTest");
}
@Bean
public Queue offlineCourseQueue(){
return new Queue("offlineCourse");
}
}
package com.yizhi.application.listener;
import com.yizhi.application.constant.PointEventEnum;
import com.yizhi.application.domain.MqPointParam;
import com.yizhi.application.domain.Point;
import com.yizhi.application.domain.PointActivity;
import com.yizhi.application.domain.PointDetails;
import com.yizhi.application.domain.PointUser;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.application.redis.RedisUtils;
import com.yizhi.application.util.PointEvenSendMessage;
import com.yizhi.core.application.cache.distributedlock.impl.RedisDistributedLock;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.core.application.task.AbstractTaskHandler;
import com.yizhi.core.application.task.TaskExecutor;
import com.yizhi.message.application.enums.EvenType;
import com.yizhi.message.application.vo.TaskVo;
import com.yizhi.point.application.vo.PointParamVO;
import com.yizhi.application.service.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.stream.Collectors;
@Component
@Transactional
public class PointListener {
private static final Logger LOGGER = LoggerFactory.getLogger(PointListener.class);
@Autowired
private RedisUtils redisUtils;
@Autowired
private IdGenerator idGenerator;
@Autowired
private PointService pointService;
@Autowired
private PointDetailsService pointDetailsService;
@Autowired
private PointUserService pointUserService;
@Autowired
private PointActivityService pointActivityService;
@Autowired
private MqPointParamService mqPointParamService;
@Autowired
private TaskExecutor taskExecutor;
@Autowired
private PointEvenSendMessage pointEvenSendMessage;
@Autowired
private RedisDistributedLock redisDistributedLock;
/*
* static { RedissonManager.init(null, "1"); }
*/
@RabbitListener(queues = "course")
public void processCourse(String pointId) {
LOGGER.info("------------处理消息course-----------------");
handPoint(pointId);
}
@RabbitListener(queues = "research")
public void processResearch(String pointId) {
LOGGER.info("------------处理消息research-----------------");
handPoint(pointId);
}
@RabbitListener(queues = "exam")
public void processExam(String pointId) {
LOGGER.info("------------处理消息exam-----------------");
handPoint(pointId);
}
@RabbitListener(queues = "vote")
public void processVote(String pointId) {
LOGGER.info("------------处理消息vote-----------------");
handPoint(pointId);
}
@RabbitListener(queues = "assignment")
public void processAssignment(String pointId) {
LOGGER.info("------------处理消息assignment-----------------");
handPoint(pointId);
}
@RabbitListener(queues = "courseTest")
public void processCourseTest(String pointId) {
LOGGER.info("------------处理消息courseTest-----------------");
handPoint(pointId);
}
@RabbitListener(queues = "practiceChat")
public void processPractice(String pointId) {
LOGGER.info("------------处理消息Practice-----------------");
handPoint(pointId);
}
@RabbitListener(queues = "offlineCourse")
public void processOfflineCourse(String pointId) {
LOGGER.info("------------处理消息offlineCourse-----------------");
handPoint(pointId);
}
@RabbitListener(queues = "trainingProject")
public void processTrainingProject(String pointId) {
LOGGER.info("------------处理消息trainingProject-----------------");
handPoint(pointId);
}
@RabbitListener(queues = "caseLibrary")
public void processCaseLibrary(String pointId) {
LOGGER.info("------------处理消息caseLibrary-----------------");
handPoint(pointId);
}
@RabbitListener(queues = "sign")
public void processSign(String pointId) {
LOGGER.info("------------处理消息sign-----------------");
handPoint(pointId);
}
@RabbitListener(queues = "forum")
public void processForum(String pointId) {
LOGGER.info("------------处理消息sign-----------------");
handPoint(pointId);
}
@RabbitListener(queues = "projectSign")
public void processProjectSign(String pointId) {
LOGGER.info("------------处理消息projectSign-----------------");
handPoint(pointId);
}
// 处理积分
public boolean handPoint(String pointId) {
// TODO("积分重构")
PointParamVO vo = (PointParamVO) redisUtils.get(pointId);
if (vo == null) {
LOGGER.info("消息ID{}获取不到缓存信息");
return false;
}
String lockName = "pointOperate_sourceId:" + vo.getSourceId() + "_accountId:" + vo.getAccountId();
try {
if (null == pointId) {
LOGGER.info("积分MQId为空");
return false;
}
LOGGER.info("开始处理消息ID{},业务ID{} 的积分", pointId, vo.getSourceId());
Map<String, Object> map = new HashMap<String, Object>();
map.put("learn_source_id", vo.getSourceId());
map.put("account_id", vo.getAccountId());
List<PointDetails> selectByMap = pointDetailsService.selectByMap(map);
String eventName = vo.getEventName();
if (vo.getOperatingPoint() == null && vo.getOperatingPoint() == 0) {
LOGGER.info("不产生0或空的积分,学员ID{},业务单据{}", vo.getAccountId(), vo.getSourceId());
return false;
}
if (eventName.equals(PointEventEnum.POINTCOURSE.getKey())) { // 课程
if (selectByMap.size() == 0 || selectByMap == null) {
addHandPoint(pointId, vo);
}
} else if (eventName.equals(PointEventEnum.POINTEXAM.getKey())) { // 考试
if (selectByMap.size() == 0 || selectByMap == null) {
addHandPoint(pointId, vo);
} else {
addExamPoint(pointId, vo, selectByMap);
}
} else if (eventName.equals(PointEventEnum.POINTRESEARCH.getKey())) { // 调研
if (selectByMap.size() == 0 || selectByMap == null) {
addHandPoint(pointId, vo);
}
} else if (eventName.equals(PointEventEnum.POINTVOTE.getKey())) { // 投票
if (selectByMap.size() == 0 || selectByMap == null) {
addHandPoint(pointId, vo);
}
} else if (eventName.equals(PointEventEnum.POINTASSIGNMENT.getKey())) { // 作业
if (selectByMap.size() == 0 || selectByMap == null) {
addHandPoint(pointId, vo);
}
} else if (eventName.equals(PointEventEnum.POINTCOURSETEST.getKey())) { // 测验
if (selectByMap.size() == 0 || selectByMap == null) {
addHandPoint(pointId, vo);
}
} else if (eventName.equals(PointEventEnum.POINTOFFLINECOURSE.getKey())) { // 线下课程
// 获得对应的记录以及积分,多则补总积分,少则减积分,并删除这条记录,添加导入的记录
addCoursePoint(pointId, vo, selectByMap);
} else if (eventName.equals(PointEventEnum.POINTTRAININGPROJECT.getKey())) { // 培训项目
if (selectByMap.size() == 0 || selectByMap == null) {
addHandPoint(pointId, vo);
}
/**
* 案例活动
*/
} else if (eventName.equals(PointEventEnum.POINTCASELIBRARY.getKey())) {
if (selectByMap.size() == 0 || selectByMap == null) {
addHandPoint(pointId, vo);
}
/**
* 签到打卡
*/
} else if (eventName.equals(PointEventEnum.POINTSIGN.getKey())) {
if (selectByMap.size() == 0 || selectByMap == null) {
addHandPoint(pointId, vo);
}
/**
* 论坛发贴/评论
*/
} else if (eventName.equals(PointEventEnum.POINTFORUM.getKey())) {
if (selectByMap.size() == 0 || selectByMap == null) {
addHandPoint(pointId, vo);
}
/**
* 项目签到
*/
} else if (eventName.equals(PointEventEnum.POINTPROJECTSIGN.getKey())) {
if (selectByMap.size() == 0 || selectByMap == null) {
addHandPoint(pointId, vo);
}
/**
* 智能演练
*/
} else if (eventName.equals(PointEventEnum.CHAPPRACTICE.getKey())) {
if (selectByMap.size() == 0 || selectByMap == null) {
addHandPoint(pointId, vo);
}
}
try {
redisUtils.remove(pointId);
} catch (Exception e) {
LOGGER.error("删除积分缓存失败{}", pointId);
e.printStackTrace();
}
LOGGER.info("完成处理消息ID{},业务ID{} 的积分", pointId, vo.getSourceId());
} catch (Exception e) {
LOGGER.error("添加积分异常消息ID{}, 业务单据ID{},异常信息{}", pointId, vo.getSourceId(), e);
// e.printStackTrace();
} finally {
// 一直报错,所以先不释放锁
// pointOperate_sourceId:1764362179454753_accountId:607873925574006底层解锁发生异常{}
//redis.clients.jedis.exceptions.JedisDataException: value sent to redis cannot be null
// redisDistributedLock.releaseLock(lockName);
LOGGER.info("释放reids锁" + lockName);
}
return true;
}
// 线下课程
public boolean addCoursePoint(String pointId, PointParamVO vo, List<PointDetails> selectByMap) {
PointDetails pd = new PointDetails();
Integer point = vo.getOperatingPoint();
if (!CollectionUtils.isEmpty(selectByMap)) {
PointDetails pointDetail = selectByMap.get(0);
vo.setOperatingPoint(vo.getOperatingPoint() - pointDetail.getPoint());
// 删除旧的记录
pointDetailsService.deleteById(pointDetail.getId());
}
Integer pointCount = pointDetailsService.getPointCountByAccountId(vo.getAccountId(), vo.getCompanyId(), vo.getSiteId());//导入用户在point_detail的总积分
// 添加新的记录
pd.setId(idGenerator.generate());
pd.setChangeBefore(pointCount);
pd.setPoint(point);
pd.setChangeAfter(pointCount + point);
pd.setActivityId(null);
pd.setTime(vo.getCreatePointTime());
pd.setMultiple(1);
pd.setAccountId(vo.getAccountId());
pd.setLearnName(vo.getActivityName());
pd.setLearnSource("线下课程学习记录");
pd.setLearnSourceId(vo.getSourceId());
pd.setLearnType(vo.getActivityType());
pd.setState(1);
pd.setCreateById(vo.getAccountId());
pd.setCreateByName(vo.getAccountName());
pd.setCreateTime(vo.getCreatePointTime());
pd.setOrgId(vo.getOrgId());
pd.setCompanyId(vo.getCompanyId());
pd.setSiteId(vo.getSiteId());
pointDetailsService.insert(pd);
// 计算个人总积分
addPoint(pointId, vo.getAccountId(), vo.getOperatingPoint(), vo.getAccountName(), vo.getOrgId(),
vo.getCompanyId(), vo.getSiteId(), vo.getCreatePointTime(), vo.getActivityType());
return true;
}
// 考试
@SuppressWarnings("unchecked")
public boolean addExamPoint(String pointId, PointParamVO vo, List<PointDetails> selectByMap) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("site_id", vo.getSiteId());
map.put("company_id", vo.getCompanyId());
List<Point> selectByMap1 = pointService.selectByMap(map);
if (selectByMap1 == null || selectByMap1.size() == 0) {
return true;
}
Integer state = selectByMap1.get(0).getState();
if (state == 0) {
return true;
}
selectByMap.sort((PointDetails p1, PointDetails p2) -> p1.getTime().compareTo(p2.getTime()));
Integer point = 0;
Integer activityPoint = 0;
// 某个活动对应的获取的总积分
Integer totalActivityPoint = 0;
Map<Long, Integer> pointDetailsMap = new HashMap<Long, Integer>(6);
List<PointDetails> list = selectByMap.stream()
.collect(Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(PointDetails::getTime))),
ArrayList::new));
List<PointActivity> activities = pointActivityService.getPointActivity(vo.getCreatePointTime(),
vo.getCompanyId(), vo.getSiteId());
for (PointDetails pd : list) {
if (pointDetailsMap.get(pd.getActivityId()) == null) {
totalActivityPoint = pd.getPoint();
} else {
totalActivityPoint = pointDetailsMap.get(pd.getActivityId()) + pd.getPoint();
}
pointDetailsMap.put(pd.getActivityId(), totalActivityPoint);
if (pd.getPoint() == null) {
pd.setPoint(0);
}
point += pd.getPoint();
}
if (vo.getOperatingPoint() == null) {
LOGGER.info("积分消息ID{},业务ID{} 积分为空", pointId, vo.getSourceId());
vo.setOperatingPoint(0);
}
// 将要新增的获取积分明细
PointDetails pd;
// 将要新增的获取积分明细列表
List<PointDetails> pdList = new ArrayList<PointDetails>(10);
Integer pointCount = pointDetailsService.getPointCountByAccountId(vo.getAccountId(), vo.getCompanyId(), vo.getSiteId());//导入用户在point_detail的总积分
// 没有翻倍
if (CollectionUtils.isEmpty(activities)) {
if (vo.getOperatingPoint() > point) {
pd = new PointDetails();
pd.setId(idGenerator.generate());
pd.setTime(vo.getCreatePointTime());
pd.setChangeBefore(pointCount);
pd.setPoint(vo.getOperatingPoint() - point);
pd.setChangeAfter(pointCount + vo.getOperatingPoint() - point);
pd.setMultiple(1);
pd.setAccountId(vo.getAccountId());
pd.setLearnName(vo.getActivityName());
pd.setLearnSource(vo.getActivitySource());
pd.setLearnSourceId(vo.getSourceId());
pd.setLearnType(vo.getActivityType());
pd.setState(1);
pd.setCreateById(vo.getAccountId());
pd.setCreateByName(vo.getAccountName());
pd.setCreateTime(vo.getCreatePointTime());
pd.setOrgId(vo.getOrgId());
pd.setCompanyId(vo.getCompanyId());
pd.setSiteId(vo.getSiteId());
pointDetailsService.insert(pd);
}
} else {
for (PointActivity pointActivity : activities) {
boolean add = false;
pd = new PointDetails();
if (pointDetailsMap.get(pointActivity.getId()) == null) {
// 1.新增的活动,将新增的积分添加进pointDetails
activityPoint = vo.getOperatingPoint() * pointActivity.getMultiple();
pd.setChangeBefore(pointCount);
pd.setPoint(activityPoint);
pd.setChangeAfter(pointCount + activityPoint);
add = true;
} else {
totalActivityPoint = pointDetailsMap.get(pointActivity.getId());
activityPoint = vo.getOperatingPoint() * pointActivity.getMultiple();
if (activityPoint > totalActivityPoint) {
add = true;
pd.setChangeBefore(pointCount);
pd.setPoint(activityPoint - totalActivityPoint);
pd.setChangeAfter(pointCount + activityPoint - totalActivityPoint);
}
}
if (add) {
pd.setId(idGenerator.generate());
pd.setMultiple(pointActivity.getMultiple());
pd.setActivityId(pointActivity.getId());
pd.setTime(vo.getCreatePointTime());
pd.setAccountId(vo.getAccountId());
pd.setLearnName(vo.getActivityName());
pd.setLearnSource(vo.getActivitySource());
pd.setLearnSourceId(vo.getSourceId());
pd.setLearnType(vo.getActivityType());
pd.setState(1);
pd.setCreateById(vo.getAccountId());
pd.setCreateByName(vo.getAccountName());
pd.setCreateTime(vo.getCreatePointTime());
pd.setOrgId(vo.getOrgId());
pd.setCompanyId(vo.getCompanyId());
pd.setSiteId(vo.getSiteId());
pdList.add(pd);
}
}
if (pdList.size() > 0) {
pointDetailsService.insertBatch(pdList);
}
}
addPoint(pointId, vo.getAccountId(), point, vo.getAccountName(), vo.getOrgId(), vo.getCompanyId(),
vo.getSiteId(), vo.getCreatePointTime(), vo.getActivityType());
return true;
}
// 处理服务积分
public boolean addHandPoint(String pointId, PointParamVO vo) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("site_id", vo.getSiteId());
map.put("company_id", vo.getCompanyId());
List<Point> selectByMap = pointService.selectByMap(map);
if (selectByMap == null || selectByMap.size() == 0) {
return true;
}
Integer state = selectByMap.get(0).getState();
if (state == 0) {
return true;
}
if (vo.getOperatingPoint() == null || vo.getOperatingPoint() == 0) {
return true;
}
Integer pointCount = pointDetailsService.getPointCountByAccountId(vo.getAccountId(), vo.getCompanyId(), vo.getSiteId());//传入用户的金币总数
List<PointActivity> list = pointActivityService.getPointActivity(vo.getCreatePointTime(), vo.getCompanyId(),
vo.getSiteId());
Integer point = 0;
Integer operatingPoint = 0;
Long accountId = vo.getAccountId();
PointDetails pd = null;
if (list.size() > 0) {
List<PointDetails> pdList = new ArrayList<PointDetails>();
for (PointActivity pa : list) {
operatingPoint = vo.getOperatingPoint();
if (operatingPoint == null) {
LOGGER.info("积分消息ID{},业务ID{} 积分为空", pointId, vo.getSourceId());
operatingPoint = 0;
}
operatingPoint = operatingPoint * pa.getMultiple();
point += operatingPoint;
pd = new PointDetails();
pd.setId(idGenerator.generate());
pd.setActivityId(pa.getId());
pd.setTime(vo.getCreatePointTime());
pd.setChangeBefore(pointCount);
pd.setPoint(operatingPoint);
pd.setChangeAfter(pointCount + operatingPoint);
pd.setAccountId(accountId);
pd.setLearnName(vo.getActivityName());
pd.setLearnSource(vo.getActivitySource());
pd.setLearnSourceId(vo.getSourceId());
if (null != vo.getCourseId()) {
pd.setCourseId(vo.getCourseId());
}
pd.setLearnType(vo.getActivityType());
pd.setState(1);
pd.setCreateById(vo.getAccountId());
pd.setCreateByName(vo.getAccountName());
pd.setCreateTime(vo.getCreatePointTime());
pd.setOrgId(vo.getOrgId());
pd.setCompanyId(vo.getCompanyId());
pd.setSiteId(vo.getSiteId());
pd.setMultiple(pa.getMultiple());
pdList.add(pd);
}
if (pdList.size() > 0) {
pointDetailsService.insertBatch(pdList);
}
} else {
point = vo.getOperatingPoint();
pd = new PointDetails();
pd.setId(idGenerator.generate());
pd.setTime(vo.getCreatePointTime());
pd.setChangeBefore(pointCount);
pd.setPoint(point);
pd.setChangeAfter(pointCount + point);
pd.setMultiple(1);
pd.setAccountId(accountId);
pd.setLearnName(vo.getActivityName());
pd.setLearnSource(vo.getActivitySource());
pd.setLearnSourceId(vo.getSourceId());
if (null != vo.getCourseId()) {
pd.setCourseId(vo.getCourseId());
}
pd.setLearnType(vo.getActivityType());
pd.setState(1);
pd.setCreateById(vo.getAccountId());
pd.setCreateByName(vo.getAccountName());
pd.setCreateTime(vo.getCreatePointTime());
pd.setOrgId(vo.getOrgId());
pd.setCompanyId(vo.getCompanyId());
pd.setSiteId(vo.getSiteId());
pointDetailsService.insert(pd);
}
try {
addPoint(pointId, accountId, point, vo.getAccountName(), vo.getOrgId(), vo.getCompanyId(), vo.getSiteId(),
vo.getCreatePointTime(), vo.getActivityType());
} catch (Exception e) {
LOGGER.error("userPoint插入过程中出现异常");
e.printStackTrace();
}
return true;
}
// 个人积分统计
private void addPoint(String pointId, Long accountId, Integer operatingPoint, String accountName, Long orgId,
Long companyId, Long siteId, Date date, String learnType) {
PointUser pu = null;
Map<String, Object> map = new HashMap<String, Object>();
map.put("user_id", accountId);
List<PointUser> selectByMap = pointUserService.selectByMap(map);
Long id = idGenerator.generate();
if (selectByMap == null || selectByMap.size() == 0) {
pu = new PointUser();
pu.setId(id);
pu.setUserId(accountId);
pu.setTotalPoint(operatingPoint);
pu.setState(1);
pu.setCreateById(accountId);
pu.setCreateByName(accountName);
pu.setCreateTime(date);
} else {
pu = selectByMap.get(0);
pu.setTotalPoint(pu.getTotalPoint() + operatingPoint);
pu.setUpdateById(accountId);
pu.setUpdateByName(accountName);
pu.setUpdateTime(date);
}
pu.setOrgId(orgId);
pu.setSiteId(siteId);
pu.setCompanyId(companyId);
boolean b = pointUserService.insertOrUpdate(pu);
// 个人积分变动发消息
if (b && accountId != null) {
TaskVo taskVo = new TaskVo();
taskVo.setReason(learnType);
taskVo.setTaskEndTime(pu.getUpdateTime());
taskVo.setTaskScore(operatingPoint.doubleValue());
RequestContext context = new RequestContext();
context.setCompanyId(companyId);
context.setSiteId(siteId);
context.setAccountId(accountId);
context.setAccountName(accountName);
taskExecutor.asynExecute(new AbstractTaskHandler() {
@Override
public void handle() {
pointEvenSendMessage.evenSendMessage(id, taskVo, accountId, EvenType.POINT_CHANGE, context);
}
});
}
MqPointParam selectById = mqPointParamService.selectById(pointId);
selectById.setState(0);
mqPointParamService.updateById(selectById);
String key = accountId.toString();
// DistributedRedisLock.acquire(key); //加锁
Integer userPoint = (Integer) redisUtils.get(key);
if (userPoint == null) {
redisUtils.set(key, operatingPoint);
} else {
redisUtils.set(key, userPoint + operatingPoint);
}
// Long result = RedissonManager.nextID(); //原子ID
// DistributedRedisLock.release(key); //解锁
// System.out.println("result=" + result);
redisUtils.remove(pointId);
}
}
package com.yizhi.application.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.yizhi.application.domain.MqPointParam;
/**
* <p>
* Mapper 接口
* </p>
*
* @author bob123
* @since 2018-05-08
*/
public interface MqPointParamMapper extends BaseMapper<MqPointParam> {
}
package com.yizhi.application.mapper;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.application.domain.PointActivity;
/**
* <p>
* 活动策略 Mapper 接口
* </p>
*
* @author bob123
* @since 2018-04-20
*/
public interface PointActivityMapper extends BaseMapper<PointActivity> {
List<PointActivity> activityList(@Param("page") Page<PointActivity> page,
@Param("companyId") Long companyId, @Param("siteId") Long siteId, @Param("activityName") String activityName);
List<PointActivity> getPointActivity(@Param("createPointTime") Date createPointTime, @Param("companyId") Long companyId, @Param("siteId") Long siteId);
}
package com.yizhi.application.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.application.domain.PointDetails;
import com.yizhi.point.application.vo.PointDetailsVO;
import com.yizhi.point.application.vo.domain.PointDetailsVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.Date;
import java.util.List;
/**
* <p>
* 积分明细 Mapper 接口
* </p>
*
* @author bob123
* @since 2018-04-20
*/
public interface PointDetailsMapper extends BaseMapper<PointDetails> {
List<PointDetailsVO> todayList(@Param("accountId") Long accountId, @Param("companyId") Long companyId,
@Param("siteId") Long siteId, @Param("orgId") Long orgId);
List<PointDetailsVO> aMonthList(@Param("page") Page<PointDetailsVO> page, @Param("year") String year,
@Param("type") String type, @Param("accountId") Long accountId, @Param("companyId") Long companyId,
@Param("siteId") Long siteId, @Param("orgId") Long orgId);
Integer queryPiont(@Param("userId") Long userId, @Param("type") String type, @Param("companyId") Long companyId,
@Param("siteId") Long siteId, @Param("orgId") Long orgId);
List<PointDetailsVO> getManagePointDetails(@Param("page") Page<PointDetailsVO> page, @Param("activityId") Long activityId,
@Param("accountIds") List<Long> accountIds, @Param("startTime") Date startTime, @Param("endTime") Date endTime,
@Param("companyId") Long companyId, @Param("siteId") Long siteId);
List<PointDetails> getReportPoints(@Param("bizId") Long bizId, @Param("accountId") Long accountId,
@Param("companyId") Long companyId, @Param("siteId") Long siteId,
@Param("isRealTime") boolean isRealTime);
List<PointDetails> getCourseReportPoints(@Param("bizId") Long bizId, @Param("accountId") Long accountId,
@Param("isRealTime") boolean isRealTime);
List<PointDetails> getCourseStatisticsPoint();
List<PointDetails> getNoCourseStatisticsPoint();
Integer getPointByCondition(@Param("accountId") Long accountId, @Param("siteId") Long siteId, @Param("bizIds") List<Long> bizIds);
/**
* 查询积分明细数据
* @param startDate 开始时间 默认访问接口前一天 00:00:00
* @param endDate 统计截至时间 默认访问接口前一天 23:59:59
* @param companyId 统计公司id
* @param siteId 统计站点id
* @return 积分明细list
*/
List<PointDetailsVo> selectPointDetails(@Param("startDate") Date startDate,
@Param("endDate") Date endDate,
@Param("companyId") Long companyId,
@Param("siteId") Long siteId);
// @Update("UPDATE point_details c\n" +
// " LEFT JOIN (\n" +
// " SELECT\n" +
// " d1.id AS id,\n" +
// " sum( d2.point ) AS sum_of_point\n" +
// " FROM\n" +
// " point_details d1\n" +
// " LEFT JOIN point_details d2 ON d1.account_id = d2.account_id\n" +
// " AND d1.site_id = d2.site_id\n" +
// " AND d1.company_id = d2.company_id\n" +
// " WHERE\n" +
// " d1.id >= d2.id\n" +
// " AND d1.site_id = #{siteId}\n" +
// " AND d1.account_id = #{accountId}\n" +
// " GROUP BY\n" +
// " d1.account_id,\n" +
// " d1.company_id,\n" +
// " d1.id\n" +
// " ) AS d ON c.id = d.id\n" +
// " SET c.change_after = d.sum_of_point\n" +
// " WHERE\n" +
// " c.site_id = #{siteId} and\n" +
// " c.account_id = #{accountId}")
void updateChangeAfter(@Param("accountId") Long accountId, @Param("siteId") Long siteId);
List<Long> getAllAccountIds(@Param("siteId") Long siteId);
List<Long> getAllSiteIds();
Integer getPointCountByAccountId(@Param("accountId") Long accountId,
@Param("companyId") Long companyId,
@Param("siteId") Long siteId);
}
package com.yizhi.application.mapper;
import java.util.List;
import com.yizhi.application.domain.PointLevel;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.mapper.BaseMapper;
/**
* <p>
* 积分等级 Mapper 接口
* </p>
*
* @author bob123
* @since 2018-04-20
*/
public interface PointLevelMapper extends BaseMapper<PointLevel> {
Boolean piontLevelDelete(@Param("id") Long id);
List<PointLevel> levelList(@Param("id") Long id);
}
package com.yizhi.application.mapper;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.yizhi.application.domain.Point;
import org.apache.ibatis.annotations.Select;
/**
* <p>
* 积分设置 Mapper 接口
* </p>
*
* @author bob123
* @since 2018-04-20
*/
public interface PointMapper extends BaseMapper<Point> {
Point pointList(@Param("companyId")Long companyId, @Param("siteId")Long siteId);
Integer updateList(@Param("state")Integer state, @Param("unit")String unit, @Param("companyId")Long companyId, @Param("siteId")Long siteId,
@Param("updateAccountId")Long updateAccountId, @Param("updateAccountName")String updateAccountName);
@Select("select unit from point where state = 1 and company_id=#{companyId} and site_id=#{siteId} and org_id=#{orgId}")
String selectUnit( @Param("companyId")Long companyId, @Param("siteId")Long siteId, @Param("orgId")Long orgId);
}
package com.yizhi.application.mapper;
import java.sql.Timestamp;
import java.util.List;
import com.yizhi.application.domain.PointUser;
import com.yizhi.point.application.vo.PointUserListVO;
import com.yizhi.point.application.vo.PointUserParamVO;
import com.yizhi.point.application.vo.TotalPointVO;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
/**
* <p>
* 学员积分 Mapper 接口
* </p>
*
* @author bob123
* @since 2018-04-20
*/
public interface PointUserMapper extends BaseMapper<PointUser> {
Integer queryPiont(@Param("userId") Long userId, @Param("companyId") Long companyId, @Param("siteId") Long siteId);
List<PointUserListVO> userRankList(Page<PointUserListVO> page, @Param("vo") PointUserParamVO vo);
List<PointUserListVO> userRankList(@Param("vo") PointUserParamVO vo);
Integer acquirePoint(@Param("accountId") Long accountId, @Param("learnSourceId") Long learnSourceId, @Param("createTime") String createTime);
Timestamp getStartDate();
List<TotalPointVO> totalPoint(@Param("siteIds") List<Long> siteIds,
@Param("startDate") String startDate, @Param("endDate") String endDate);
}
//package com.fulan.application.redis;
//
//import java.lang.reflect.Method;
//
//import org.springframework.cache.CacheManager;
//import org.springframework.cache.annotation.CachingConfigurerSupport;
//import org.springframework.cache.annotation.EnableCaching;
//import org.springframework.cache.interceptor.KeyGenerator;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.redis.cache.RedisCacheManager;
//import org.springframework.data.redis.connection.RedisConnectionFactory;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.data.redis.core.StringRedisTemplate;
//import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
//
//import com.fasterxml.jackson.annotation.JsonAutoDetect;
//import com.fasterxml.jackson.annotation.PropertyAccessor;
//import com.fasterxml.jackson.databind.ObjectMapper;
//
///**
// * 缓存管理(注解用)
// */
//@Configuration
//@EnableCaching
//public class CacheService extends CachingConfigurerSupport {
//
// /**
// * 生成key的策略
// *
// * @return
// */
// @Bean
// public KeyGenerator keyGenerator() {
// return new KeyGenerator() {
// @Override
// public Object generate(Object target, Method method, Object... params) {
// StringBuilder sb = new StringBuilder();
// sb.append(target.getClass().getName());
// sb.append(method.getName());
// for (Object obj : params) {
// sb.append(obj.toString());
// }
// return sb.toString();
// }
// };
// }
//
// /**
// * 管理缓存
// *
// * @param redisTemplate
// * @return
// */
// @SuppressWarnings("rawtypes")
// @Bean
// public CacheManager cacheManager(RedisTemplate redisTemplate) {
// RedisCacheManager rcm = new RedisCacheManager(redisTemplate);
// // 设置缓存过期时间
// rcm.setDefaultExpiration(600);//秒
// // 设置value的过期时间
//// Map<String, Long> map = new HashMap<String, Long>();
//// map.put("test", 60L);
//// rcm.setExpires(map);
// return rcm;
// }
//
// /**
// * RedisTemplate配置
// * @param factory
// * @return
// */
// @SuppressWarnings({ "rawtypes", "unchecked" })
// @Bean
// public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) {
// StringRedisTemplate template = new StringRedisTemplate(factory);
// Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
// ObjectMapper om = new ObjectMapper();
// om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
// om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
// jackson2JsonRedisSerializer.setObjectMapper(om);
// template.setValueSerializer(jackson2JsonRedisSerializer);
// template.afterPropertiesSet();
// return template;
// }
//}
\ No newline at end of file
package com.yizhi.application.redis;
import java.util.concurrent.TimeUnit;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
public class DistributedRedisLock {
private static RedissonClient redisson = RedissonManager.getRedisson();
private static final String LOCK_TITLE = "redisLock_";
public static boolean acquire(String lockName) {
String key = LOCK_TITLE + lockName;
RLock mylock = redisson.getLock(key);
mylock.lock(2, TimeUnit.MINUTES); // lock提供带timeout参数,timeout结束强制解锁,防止死锁
System.err.println("======lock======" + Thread.currentThread().getName());
return true;
}
public static void release(String lockName) {
String key = LOCK_TITLE + lockName;
RLock mylock = redisson.getLock(key);
mylock.unlock();
System.err.println("======unlock======" + Thread.currentThread().getName());
}
}
\ No newline at end of file
package com.yizhi.application.redis;
import java.io.Serializable;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;
/**
* redicache 工具类
*
*/
@SuppressWarnings("unchecked")
@Service
public class RedisUtils {
@SuppressWarnings("rawtypes")
@Autowired
private RedisTemplate redisTemplate;
/**
* 批量删除对应的value
*
* @param keys
*/
public void remove(final String... keys) {
for (String key : keys) {
remove(key);
}
}
/**
* 批量删除key
*
* @param pattern
*/
public void removePattern(final String pattern) {
Set<Serializable> keys = redisTemplate.keys(pattern);
if (keys.size() > 0)
redisTemplate.delete(keys);
}
/**
* 删除对应的value
*
* @param key
*/
public void remove(final String key) {
if (exists(key)) {
redisTemplate.delete(key);
}
}
/**
* 判断缓存中是否有对应的value
*
* @param key
* @return
*/
public boolean exists(final String key) {
return redisTemplate.hasKey(key);
}
/**
* 读取缓存
*
* @param key
* @return
*/
public Object get(final String key) {
Object result = null;
ValueOperations<Serializable, Object> operations = redisTemplate.opsForValue();
result = operations.get(key);
return result;
}
/**
* 写入缓存
*
* @param key
* @param value
* @return
*/
public boolean set(final String key, Object value) {
boolean result = false;
try {
ValueOperations<Serializable, Object> operations = redisTemplate.opsForValue();
operations.set(key, value);
result = true;
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
/**
* 写入缓存
*
* @param key
* @param value
* @return
*/
public boolean set(final String key, Object value, Long expireTime) {
boolean result = false;
try {
ValueOperations<Serializable, Object> operations = redisTemplate.opsForValue();
operations.set(key, value);
redisTemplate.expire(key, expireTime, TimeUnit.SECONDS);
result = true;
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
}
\ No newline at end of file
package com.yizhi.application.redis;
import org.redisson.Redisson;
import org.redisson.api.RAtomicLong;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
public class RedissonManager {
private static final String RAtomicName = "genId_";
private static Config config = new Config();
private static RedissonClient redisson = null;
public static void init(String key, String value) {
try {
// config.useClusterServers() // 这是用的集群server
// .setScanInterval(2000) // 设置集群状态扫描时间
// .setMasterConnectionPoolSize(10000) // 设置连接数
// .setSlaveConnectionPoolSize(10000).addNodeAddress("redis://127.0.0.1:6379")
// .addNodeAddress("redis://127.0.0.1:6389").addNodeAddress("redis://127.0.0.1:6399");
if (key == null || "".equals(key)) {
key = RAtomicName;
}
config.useSingleServer().setAddress("redis://127.0.0.1:6379");
redisson = Redisson.create(config);
// redisson = (Redisson) Redisson.create();
// config.useClusterServers()
// .setScanInterval(2000) // 集群状态扫描间隔时间,单位是毫秒
// //可以用"rediss://"来启用SSL连接
// .addNodeAddress("redis://127.0.0.1:6389").addNodeAddress("redis://127.0.0.1:6395")
// .addNodeAddress("redis://127.0.0.1:6396").addNodeAddress("redis://127.0.0.1:6397")
// .addNodeAddress("redis://127.0.0.1:6398").addNodeAddress("redis://127.0.0.1:6399");
// redisson = Redisson.create(config);
// 清空自增的ID数字
RAtomicLong atomicLong = redisson.getAtomicLong(key);
long pValue = 1;
if (value != null && !"".equals(value)) {
pValue = Long.parseLong(value);
}
atomicLong.set(pValue);
} catch (Exception e) {
e.printStackTrace();
}
}
public static RedissonClient getRedisson() {
return redisson;
}
/** 获取redis中的原子ID */
public static Long nextID() {
RAtomicLong atomicLong = getRedisson().getAtomicLong(RAtomicName);
// 原子性的获取下一个ID,递增1
atomicLong.incrementAndGet();
return atomicLong.get();
}
}
\ No newline at end of file
package com.yizhi.application.repository;
import com.yizhi.application.domain.PointDetails;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
/**
* @Date 2021/2/4 4:04 下午
* @Author lvjianhui
**/
@Repository
public interface PointDetailsRepository extends JpaRepository<PointDetails,Long> {
@Modifying
@Transactional
@Query(value = "UPDATE point_details c\n" +
" LEFT JOIN (\n" +
" SELECT\n" +
" d1.id AS id,\n" +
" sum( d2.point ) AS sum_of_point\n" +
" FROM\n" +
" point_details d1\n" +
" LEFT JOIN point_details d2 ON d1.account_id = d2.account_id\n" +
" AND d1.site_id = d2.site_id\n" +
" AND d1.company_id = d2.company_id\n" +
" WHERE\n" +
" d1.id >= d2.id\n" +
" AND d1.site_id = ?1\n" +
" AND d1.account_id = ?2\n" +
" GROUP BY\n" +
" d1.account_id,\n" +
" d1.company_id,\n" +
" d1.id\n" +
" ) AS d\n" +
" ON c.id = d.id\n" +
" set c.change_after = d.sum_of_point\n" +
" WHERE\n" +
" c.site_id = ?1\n" +
" and\n" +
" c.account_id = ?2",nativeQuery = true)
public void updatePoint(Long siteId,Long accountId);
}
package com.yizhi.application.service;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.application.domain.MqPointParam;
/**
* <p>
* 服务类
* </p>
*
* @author bob123
* @since 2018-05-08
*/
public interface MqPointParamService extends IService<MqPointParam> {
}
package com.yizhi.application.service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.application.domain.PointActivity;
/**
* <p>
* 活动策略 服务类
* </p>
*
* @author bob123
* @since 2018-04-20
*/
public interface PointActivityService extends IService<PointActivity> {
/**
* 积分活动策略新增
* @param pointActivity
* @return
*/
Long insertDetail(PointActivity pointActivity);
/**
* 积分活动策略删除
* @param pointActivity
* @return
*/
Long deleteDetailById(PointActivity pointActivity);
/**
* 积分活动策略启用
* @param id
* @return
*/
Boolean pointUp(Long id, Long accountId, String accountName);
/**
* 积分活动策略停用
* @param id
* @return
*/
Boolean pointDown(Long id, Long accountId, String accountName);
/**
* 积分活动策略查询、分页列表
* @param page
* @param map
* @return
*/
Page<PointActivity> activityList(Page<PointActivity> page, Map<String, Object> map);
/**
* 获取正在进行的积分活动
* @param createPointTime
* @return
*/
List<PointActivity> getPointActivity(Date createPointTime, Long companyId, Long siteId);
}
package com.yizhi.application.service;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.application.domain.PointDetails;
import com.yizhi.point.application.vo.PointDetailsVO;
import com.yizhi.point.application.vo.PointImportVO;
import com.yizhi.point.application.vo.domain.PointDetailsVo;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* <p>
* 积分明细 服务类
* </p>
*
* @author bob123
* @since 2018-04-20
*/
public interface PointDetailsService extends IService<PointDetails> {
Map<String, Object> pointList(String year, String type, Long accountId, Integer pageNo, Integer pageSize, Long companyId,
Long siteId, Long orgId);
Integer queryPiont(Long userId, Long companyId, Long siteId, Long orgId);
Page<PointDetailsVO> getManagePointDetails(Integer pageNo, Integer pageSize, Long activityId,
List<Long> accountIds, Date startTime, Date endTime, Long companyId, Long siteId);
boolean pointImport(List<PointImportVO> importVOList, Long companyId, Long siteId, Long orgId, Long accountId, String accountName);
List<PointDetails> getReportPoints(Long bizId, Long accountId, Long companyId, Long siteId, boolean isRealTime);
List<PointDetails> getCourseReportPoints(Long bizId, Long accountId, boolean isRealTime);
List<PointDetails> statisticsPoint();
Integer getPointByCondition(Long accontId,Long siteId,List<Long> bizIds);
/**
* 查询积分明细数据
* @param startDate 开始时间 默认访问接口前一天 00:00:00
* @param endDate 统计截至时间 默认访问接口前一天 23:59:59
* @param companyId 统计公司id
* @param siteId 统计站点id
* @return 积分明细list
*
*/
List<PointDetailsVo> syncPointDetails(Date startDate, Date endDate, Long companyId, Long siteId);
/**
* 获取传入用户的积分总量
*
* @param id
* @param companyId
* @param accountId
* @return
*/
Integer getPointCountByAccountId(Long accountId, Long companyId, Long siteId);
void updateChangeAfter(Long accountId,Long siteId);
}
package com.yizhi.application.service;
import java.util.List;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.application.domain.PointLevel;
/**
* <p>
* 积分等级 服务类
* </p>
*
* @author bob123
* @since 2018-04-20
*/
public interface PointLevelService extends IService<PointLevel> {
Boolean inserts(PointLevel pointLevel);
Boolean piontLevelDelete(Long id);
List<PointLevel> levelList(Long id);
Integer updateById1(PointLevel pointLevel);
}
package com.yizhi.application.service;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.application.domain.Point;
/**
* <p>
* 积分设置 服务类
* </p>
*
* @author bob123
* @since 2018-04-20
*/
public interface PointService extends IService<Point> {
Point pointList(Long companyId, Long siteId);
boolean updateList(Point point);
}
package com.yizhi.application.service;
import java.sql.Timestamp;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.application.domain.PointUser;
import com.yizhi.point.application.vo.PointUserListVO;
import com.yizhi.point.application.vo.PointUserParamVO;
/**
* <p>
* 学员积分 服务类
* </p>
*
* @author bob123
* @since 2018-04-20
*/
public interface PointUserService extends IService<PointUser> {
Integer queryPiont(Long userId, Long companyId, Long siteId);
Page<PointUserListVO> userRankList(PointUserParamVO vo);
List<PointUserListVO> userRankListExport(PointUserParamVO vo);
Integer acquirePoint(Long accountId, Long learnSourceId, String createTime);
Timestamp getStartDate();
Map<Long, Long> totalPoint(List<Long> siteIds,String startDate,String endDate);
}
package com.yizhi.application.service.impl;
import com.yizhi.application.domain.MqPointParam;
import com.yizhi.application.service.MqPointParamService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.application.mapper.MqPointParamMapper;
/**
* <p>
* 服务实现类
* </p>
*
* @author bob123
* @since 2018-05-08
*/
@Service
public class MqPointParamServiceImpl extends ServiceImpl<MqPointParamMapper, MqPointParam> implements MqPointParamService {
}
package com.yizhi.application.service.impl;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.yizhi.application.domain.PointActivity;
import com.yizhi.application.mapper.PointActivityMapper;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.application.service.PointActivityService;
import com.yizhi.core.application.context.ContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
/**
* <p>
* 活动策略 服务实现类
* </p>
*
* @author bob123
* @since 2018-04-20
*/
@Service
public class PointActivityServiceImpl extends ServiceImpl<PointActivityMapper, com.yizhi.application.domain.PointActivity> implements PointActivityService {
@Autowired
IdGenerator idGenerator ;
@Autowired
PointActivityMapper pointActivityMapper;
@Override
public Long insertDetail(com.yizhi.application.domain.PointActivity pointActivity) {
Long companyId = ContextHolder.get().getCompanyId();
Long orgId = ContextHolder.get().getOrgId();
Long siteId = ContextHolder.get().getSiteId();
pointActivity.setId(idGenerator.generate());
pointActivity.setCompanyId(companyId);
pointActivity.setOrgId(orgId);
pointActivity.setSiteId(siteId);
Integer count = pointActivityMapper.insert(pointActivity);
if(count > 0){
return pointActivity.getId();
}
return null;
}
@Override
public Long deleteDetailById(com.yizhi.application.domain.PointActivity pointActivity) {
com.yizhi.application.domain.PointActivity tem = new com.yizhi.application.domain.PointActivity();
tem.setId(pointActivity.getId());
int count = pointActivityMapper.selectCount(new EntityWrapper<com.yizhi.application.domain.PointActivity>(tem));
if(count<=0){
return -1L;
}
pointActivity.setState(0);
return (long) pointActivityMapper.updateById(pointActivity);
}
@Override
public Boolean pointUp(Long id, Long accountId, String accountName) {
com.yizhi.application.domain.PointActivity pointActivity = new com.yizhi.application.domain.PointActivity();
Date date = new Date();
pointActivity.setId(id);
pointActivity.setState(2);
pointActivity.setUpdateById(accountId);
pointActivity.setUpdateByName(accountName);
pointActivity.setUpdateTime(date);
pointActivity.setEnableById(accountId);
pointActivity.setEnableByName(accountName);
pointActivity.setEnableTime(date);
return pointActivityMapper.updateById(pointActivity)>0;
}
@Override
public Boolean pointDown(Long id, Long accountId, String accountName) {
com.yizhi.application.domain.PointActivity pointActivity = new com.yizhi.application.domain.PointActivity();
Date date = new Date();
pointActivity.setId(id);
pointActivity.setState(3);
pointActivity.setUpdateById(accountId);
pointActivity.setUpdateByName(accountName);
pointActivity.setUpdateTime(date);
pointActivity.setEnableById(accountId);
pointActivity.setEnableByName(accountName);
pointActivity.setEnableTime(date);
return pointActivityMapper.updateById(pointActivity)>0;
}
@Override
public Page<com.yizhi.application.domain.PointActivity> activityList(Page<com.yizhi.application.domain.PointActivity> page, Map<String, Object> map) {
Long companyId = Long.valueOf((String)map.get("companyId"));
Long siteId = Long.valueOf((String)map.get("siteId"));
String activityName = (String) map.get("activityName");
List<com.yizhi.application.domain.PointActivity> list = pointActivityMapper.activityList(page, companyId, siteId, activityName);
return page.setRecords(list);
}
@Override
public List<PointActivity> getPointActivity(Date createPointTime, Long companyId, Long siteId) {
return pointActivityMapper.getPointActivity(createPointTime, companyId, siteId);
}
}
package com.yizhi.application.service.impl;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.application.constant.PointChangeReasonConstant;
import com.yizhi.application.domain.PointDetails;
import com.yizhi.application.domain.PointUser;
import com.yizhi.application.mapper.PointDetailsMapper;
import com.yizhi.application.mapper.PointMapper;
import com.yizhi.application.mapper.PointUserMapper;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.application.repository.PointDetailsRepository;
import com.yizhi.application.service.PointDetailsService;
import com.yizhi.application.service.PointUserService;
import com.yizhi.point.application.vo.PointDetailsVO;
import com.yizhi.point.application.vo.PointImportVO;
import com.yizhi.point.application.vo.domain.PointDetailsVo;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.sql.Connection;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
* 积分明细 服务实现类
* </p>
*
* @author bob123
* @since 2018-04-20
*/
@Service
@Log4j2
public class PointDetailsServiceImpl extends ServiceImpl<PointDetailsMapper, com.yizhi.application.domain.PointDetails> implements PointDetailsService {
@Autowired
PointDetailsMapper pointDetailsMapper;
@Autowired
PointUserMapper pointUserMapper;
@Autowired
PointUserService pointUserService;
@Autowired
PointMapper pointMapper;
@Autowired
IdGenerator idGenerator;
@Autowired
PointDetailsRepository pointDetailsRepository;
private String updateSql = "";
@Override
public void updateChangeAfter(Long accountId, Long siteId) {
Long time = System.currentTimeMillis();
if (siteId == null) {
List<Long> siteIds = pointDetailsMapper.getAllSiteIds();
siteIds.stream().filter(Objects::nonNull).forEach(it -> {
List<Long> accountIds = pointDetailsMapper.getAllAccountIds(it);
accountIds.parallelStream().forEach( aid -> {
try {
executeSql(it,aid);
}catch (Exception e) {
log.warn("更新用户积分记录异常 aid:{} siteId: {}",aid,it,e);
}
});
});
log.info("总耗时 " + (System.currentTimeMillis() - time) /1000 + " 秒");
return;
}
// 更新指定站点指定用户
if (accountId != null) {
executeSql(siteId,accountId);
return;
}
// 更新指定站点所有用户
List<Long> accountIds = pointDetailsMapper.getAllAccountIds(siteId);
accountIds.parallelStream().forEach( aid -> {
log.info("更新用户积分记录 aid:{} siteId: {}",aid,siteId);
executeSql(siteId,aid);
});
}
private void executeSql(Long siteId,Long accountId) {
if (siteId == null || accountId == null) {
log.warn("更新用户积分记录 参数异常 accountId:{} siteId: {}",accountId,siteId);
return;
}
log.info("更新用户积分记录 accountId:{} siteId: {}",accountId,siteId);
pointDetailsRepository.updatePoint(siteId,accountId);
}
@Override
public Map<String, Object> pointList(String year, String type, Long accountId, Integer pageNo, Integer pageSize, Long companyId,
Long siteId, Long orgId) {
if (!StringUtils.isBlank(year)) {
year = year.trim();
}
Page<PointDetailsVO> page = new Page<PointDetailsVO>(pageNo, pageSize);
List<PointDetailsVO> list1 = pointDetailsMapper.aMonthList(page, year, type, accountId, companyId, siteId, null);
List<PointDetailsVO> pointList = list1.parallelStream().map(pointDetailsVO -> {
log.info("类型:" + pointDetailsVO.getLearnType());
if (pointDetailsVO.getLearnType().contains(PointChangeReasonConstant.CREDITEXAMDONE.getValue())) {
// 考试阅卷通过
pointDetailsVO.setChangeReason(PointChangeReasonConstant.CREDITEXAMDONE.getKey());
log.info("类型:" + pointDetailsVO.getLearnType());
return pointDetailsVO;
} else if (pointDetailsVO.getLearnType().contains(PointChangeReasonConstant.CREDITCOURSEDONE1.getValue())) {
// 课程完成
pointDetailsVO.setChangeReason(PointChangeReasonConstant.CREDITCOURSEDONE1.getKey());
return pointDetailsVO;
} else if (pointDetailsVO.getLearnType().contains(PointChangeReasonConstant.CREDITEXAMPASSED.getValue())) {
pointDetailsVO.setChangeReason(PointChangeReasonConstant.CREDITEXAMPASSED.getKey());
log.info("类型:" + pointDetailsVO.getLearnType());
return pointDetailsVO;
} else if (pointDetailsVO.getLearnType().contains(PointChangeReasonConstant.CREDITRESEARCHDONE.getValue())) {
// 考试通过
pointDetailsVO.setChangeReason(PointChangeReasonConstant.CREDITRESEARCHDONE.getKey());
log.info("类型:" + pointDetailsVO.getLearnType());
return pointDetailsVO;
} else if (pointDetailsVO.getLearnType().contains(PointChangeReasonConstant.CREDITCOURSECHAPTERDONE.getValue())) {
// 课程章节完成
pointDetailsVO.setChangeReason(PointChangeReasonConstant.CREDITCOURSECHAPTERDONE.getKey());
log.info("类型:" + pointDetailsVO.getLearnType());
return pointDetailsVO;
} else if (pointDetailsVO.getLearnType().contains(PointChangeReasonConstant.CREDITQUIZPASSED.getValue())) {
// 课程章节测验通过
pointDetailsVO.setChangeReason(PointChangeReasonConstant.CREDITCOURSECHAPTERDONE.getKey());
log.info("类型:" + pointDetailsVO.getLearnType());
return pointDetailsVO;
} else if (pointDetailsVO.getLearnType().contains(PointChangeReasonConstant.CREDITOFFLINEDONE.getValue())) {
// 线下课程完成
pointDetailsVO.setChangeReason(PointChangeReasonConstant.CREDITOFFLINEDONE.getKey());
log.info("类型:" + pointDetailsVO.getLearnType());
return pointDetailsVO;
} else if (pointDetailsVO.getLearnType().contains(PointChangeReasonConstant.CREDITCOURSEDONE2.getValue())) {
// 课程学习完成
pointDetailsVO.setChangeReason(PointChangeReasonConstant.CREDITCOURSEDONE2.getKey());
log.info("类型:" + pointDetailsVO.getLearnType());
return pointDetailsVO;
} else if (pointDetailsVO.getLearnType().contains(PointChangeReasonConstant.CREDITASSIGNMENTPASSED.getValue())) {
// 作业通过
pointDetailsVO.setChangeReason(PointChangeReasonConstant.CREDITASSIGNMENTPASSED.getKey());
log.info("类型:" + pointDetailsVO.getLearnType());
return pointDetailsVO;
} else if (pointDetailsVO.getLearnType().contains(PointChangeReasonConstant.CREDITEXTERNALIMPORT.getValue())) {
// 外部导入
pointDetailsVO.setChangeReason(PointChangeReasonConstant.CREDITEXTERNALIMPORT.getKey());
log.info("类型:" + pointDetailsVO.getLearnType());
return pointDetailsVO;
} else if (pointDetailsVO.getLearnType().contains(PointChangeReasonConstant.CREDITTRAININGPROJECTDONE.getValue())) {
// 培训项目通过
pointDetailsVO.setChangeReason(PointChangeReasonConstant.CREDITTRAININGPROJECTDONE.getKey());
log.info("类型:" + pointDetailsVO.getLearnType());
return pointDetailsVO;
} else if (pointDetailsVO.getLearnType().contains(PointChangeReasonConstant.CREDITCASELIBRARYDONE.getValue())) {
pointDetailsVO.setChangeReason(PointChangeReasonConstant.CREDITCASELIBRARYDONE.getKey());
log.info("类型:" + pointDetailsVO.getLearnType());
return pointDetailsVO;
} else if (pointDetailsVO.getLearnType().contains(PointChangeReasonConstant.CREDITCALENDARDONE.getValue())) {
pointDetailsVO.setChangeReason(PointChangeReasonConstant.CREDITCALENDARDONE.getKey());
log.info("类型:" + pointDetailsVO.getLearnType());
return pointDetailsVO;
//发布论坛回复发放积分
} else if (pointDetailsVO.getLearnType().contains(PointChangeReasonConstant.CREDITFORUMCOMMENT.getValue())) {
pointDetailsVO.setChangeReason(PointChangeReasonConstant.CREDITFORUMCOMMENT.getKey());
pointDetailsVO.setLearnName(PointChangeReasonConstant.CREDITFORUMCOMMENT.getValue());
log.info("类型:" + pointDetailsVO.getLearnType());
return pointDetailsVO;
//发布论坛帖子发放积分
} else if (pointDetailsVO.getLearnType().contains(PointChangeReasonConstant.CREDITFORUMINVITATION.getValue())) {
pointDetailsVO.setChangeReason(PointChangeReasonConstant.CREDITFORUMINVITATION.getKey());
pointDetailsVO.setLearnName(PointChangeReasonConstant.CREDITFORUMINVITATION.getValue());
log.info("类型:" + pointDetailsVO.getLearnType());
return pointDetailsVO;
} else if (pointDetailsVO.getLearnType().contains(PointChangeReasonConstant.CREDITSIGNDONE.getValue())) {
pointDetailsVO.setChangeReason(PointChangeReasonConstant.CREDITSIGNDONE.getKey());
// pointDetailsVO.setLearnName(PointChangeReasonConstant.CREDITSIGNDONE.getValue());
log.info("类型:" + pointDetailsVO.getLearnType());
return pointDetailsVO;
} else {
return pointDetailsVO;
}
}).collect(Collectors.toList());
String unit = pointMapper.selectUnit(companyId, siteId, orgId);
Map<String, Object> map = new HashMap<String, Object>();
Integer point = pointDetailsMapper.queryPiont(accountId, type, companyId, siteId, null);
if (null == point) {
point = 0;
}
map.put("point", point);
map.put("month", pointList);
map.put("unit", unit);
Map<String, Integer> pageMap = new HashMap<String, Integer>();
pageMap.put("pageNo", pageNo);
pageMap.put("pageSize", pageSize);
pageMap.put("pageTotal", page.getTotal());
Map<String, Object> resap = new HashMap<String, Object>();
resap.put("listMap", map);
resap.put("page", pageMap);
return resap;
}
@Override
public Integer queryPiont(Long userId, Long companyId, Long siteId, Long orgId) {
return pointDetailsMapper.queryPiont(userId, null, companyId, siteId, orgId);
}
@Override
public Page<PointDetailsVO> getManagePointDetails(Integer pageNo, Integer pageSize, Long activityId,
List<Long> accountIds, Date startTime, Date endTime, Long companyId, Long siteId) {
Page<PointDetailsVO> page = new Page<PointDetailsVO>(pageNo, pageSize);
List<PointDetailsVO> list = pointDetailsMapper.getManagePointDetails(page, activityId, accountIds, startTime, endTime, companyId, siteId);
page.setRecords(list);
return page;
}
@Override
public boolean pointImport(List<PointImportVO> importVOList, Long companyId, Long siteId, Long orgId, Long accountId, String accountName) {
// TODO("积分重构")
if (!CollectionUtils.isEmpty(importVOList)) {
List<com.yizhi.application.domain.PointDetails> pointDetailsList = new ArrayList<>();
List<com.yizhi.application.domain.PointUser> pointUserInsertOrUpdateList = new ArrayList<>();
com.yizhi.application.domain.PointDetails pointDetails = null;
com.yizhi.application.domain.PointUser pointUser = null;
boolean isOk = false;
for (PointImportVO importVO : importVOList) {
//新建积分详情对象,加入list
// if (importVO.getPoint() == 0) {
// continue;
// }
Integer pointCount = getPointCountByAccountId(importVO.getAccountId(), companyId, siteId);//导入用户在point_detail的总积分
pointDetails = new com.yizhi.application.domain.PointDetails();
pointDetails.setId(idGenerator.generate());
pointDetails.setAccountId(importVO.getAccountId());
pointDetails.setTime(new Date());
pointDetails.setCreateTime(new Date());
pointDetails.setCreateById(accountId);
pointDetails.setCreateByName(accountName);
pointDetails.setLearnType("外部导入积分");
pointDetails.setLearnName(importVO.getDescription());
pointDetails.setLearnSource("外部导入");
pointDetails.setState(1);
pointDetails.setUpdateTime(new Date());
pointDetails.setCompanyId(companyId);
pointDetails.setSiteId(siteId);
pointDetails.setOrgId(orgId);
pointDetails.setMultiple(1);
pointDetails.setLearnSourceId(Long.valueOf(0));
//查询userpoint是否有数据,有记录加入积分更新入库,没有新建记录插入
pointUser = new com.yizhi.application.domain.PointUser();
pointUser.setUserId(importVO.getAccountId());
pointUser.setCompanyId(companyId);
pointUser.setSiteId(siteId);
pointUser = pointUserMapper.selectOne(pointUser);
if (null != pointUser) {
if (importVO.getPoint() < 0) {
if (pointUser.getTotalPoint() <= 0) {
continue;
}
if (pointUser.getTotalPoint() + importVO.getPoint() <= 0) {
pointDetails.setChangeBefore(pointCount);
pointDetails.setPoint(0 - pointUser.getTotalPoint());
pointDetails.setChangeAfter(pointCount - pointUser.getTotalPoint());
pointUser.setTotalPoint(0);
} else {
pointDetails.setChangeBefore(pointCount);
pointDetails.setPoint(importVO.getPoint());
pointDetails.setChangeAfter(pointCount + importVO.getPoint());
pointUser.setTotalPoint(pointUser.getTotalPoint() + importVO.getPoint());
}
pointDetailsList.add(pointDetails);
} else {
pointUser.setTotalPoint(pointUser.getTotalPoint() + importVO.getPoint());
pointDetails.setChangeBefore(pointCount);
pointDetails.setPoint(importVO.getPoint());
pointDetails.setChangeAfter(pointCount + importVO.getPoint());
pointDetailsList.add(pointDetails);
}
pointUser.setUpdateById(accountId);
pointUser.setUpdateTime(new Date());
pointUser.setUpdateByName(accountName);
pointUserInsertOrUpdateList.add(pointUser);
} else {
if (importVO.getPoint() < 0) {
continue;
}
//用户没有积分设置0
pointDetails.setChangeBefore(0);
pointDetails.setPoint(importVO.getPoint());
pointDetails.setChangeAfter(importVO.getPoint());
pointDetailsList.add(pointDetails);
pointUser = new PointUser();
pointUser.setId(idGenerator.generate());
pointUser.setUserId(importVO.getAccountId());
pointUser.setTotalPoint(importVO.getPoint());
pointUser.setState(1);
pointUser.setCreateTime(new Date());
pointUser.setCreateById(accountId);
pointUser.setCreateByName(accountName);
pointUser.setCompanyId(companyId);
pointUser.setSiteId(siteId);
pointUser.setOrgId(orgId);
pointUserInsertOrUpdateList.add(pointUser);
}
}
if (!CollectionUtils.isEmpty(pointDetailsList)) {
isOk = this.insertBatch(pointDetailsList);
}
if (!CollectionUtils.isEmpty(pointUserInsertOrUpdateList)) {
isOk = pointUserService.insertOrUpdateBatch(pointUserInsertOrUpdateList);
}
return isOk;
}
return true;
}
@Override
public List<com.yizhi.application.domain.PointDetails> getReportPoints(Long bizId, Long accountId, Long companyId, Long siteId, boolean isRealTime) {
return pointDetailsMapper.getReportPoints(bizId, accountId, companyId, siteId, isRealTime);
}
@Override
public List<com.yizhi.application.domain.PointDetails> getCourseReportPoints(Long bizId, Long accountId, boolean isRealTime) {
return pointDetailsMapper.getCourseReportPoints(bizId, accountId, isRealTime);
}
@Override
public List<com.yizhi.application.domain.PointDetails> statisticsPoint() {
// TODO Auto-generated method stub
//第一步 先找到课程的数据
List<com.yizhi.application.domain.PointDetails> listDate = new ArrayList<com.yizhi.application.domain.PointDetails>();
List<PointDetails> listCoursePoint = pointDetailsMapper.getCourseStatisticsPoint();
//List<PointDetails> listNoCoursePoint=pointDetailsMapper.getNoCourseStatisticsPoint();
/*for (PointDetails pointDetails : listNoCoursePoint) {
String learnType = pointDetails.getLearnType();
switch (learnType.substring(0,2)){
case "考试" :
learnType = "1";
break;
case "学习" :
learnType = "7";
break;
case "课程" :
learnType = "0";
break;
default:
learnType = "-1";
}
pointDetails.setLearnType(learnType);
}*/
if (!CollectionUtils.isEmpty(listCoursePoint)) {
listDate.addAll(listCoursePoint);
}
/*if(!CollectionUtils.isEmpty(listNoCoursePoint)) {
listDate.addAll(listNoCoursePoint) ;
}*/
return listDate;
}
@Override
public Integer getPointByCondition(Long accontId, Long siteId, List<Long> bizIds) {
return this.baseMapper.getPointByCondition(accontId, siteId, bizIds);
}
@Override
public Integer getPointCountByAccountId(Long accountId, Long companyId, Long siteId) {
Integer count = 0;
try {
Integer pointCount = baseMapper.getPointCountByAccountId(accountId, companyId, siteId);
if (pointCount != null) {
count = pointCount;
}
return count;
} catch (Exception e) {
//查询表时结构未修改,先返回count = 0
return 0;
}
}
@Override
public List<PointDetailsVo> syncPointDetails(Date startDate, Date endDate, Long companyId, Long siteId) {
log.info("统计积分明细入参: startDate = {}, endDate = {}, companyId = {}, siteId = {} ",startDate,endDate,companyId,siteId);
List<PointDetailsVo> list = new ArrayList<>();
try {
DateTime yesterday = DateUtil.yesterday();
if (null == startDate){
startDate = DateUtil.beginOfDay(yesterday);
}
if (null == endDate){
endDate = DateUtil.endOfDay(yesterday);
}
list = pointDetailsMapper.selectPointDetails(startDate,endDate,companyId,siteId);
if (null == list){
return new ArrayList<>();
}
log.info("统计积分明细结果size={},请求参数: startDate = {}, endDate = {}, companyId = {}, siteId = {} ",list.size(),startDate,endDate,companyId,siteId);
return list;
}catch (Exception e){
log.error("统计积分明细异常: 入参: startDate = {}, endDate = {}, companyId = {}, siteId = {} ",startDate,endDate,companyId,siteId,e);
}
return list;
}
public static void main(String[] args) {
DateTime yesterday = DateUtil.yesterday();
DateTime beginOfDay = DateUtil.beginOfDay(yesterday);
DateTime endOfDay = DateUtil.endOfDay(yesterday);
System.out.println(yesterday);
System.out.println(beginOfDay);
System.out.println(endOfDay);
}
}
package com.yizhi.application.service.impl;
import java.util.List;
import com.yizhi.application.mapper.PointLevelMapper;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.application.service.PointLevelService;
import com.yizhi.application.domain.PointLevel;
import com.yizhi.core.application.context.ContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
/**
* <p>
* 积分等级 服务实现类
* </p>
*
* @author bob123
* @since 2018-04-20
*/
@Service
public class PointLevelServiceImpl extends ServiceImpl<PointLevelMapper, PointLevel> implements PointLevelService {
@Autowired
IdGenerator idGenerator ;
@Autowired
PointLevelMapper pointLevelMapper;
@Override
public Boolean inserts(PointLevel pointLevel) {
Long companyId = ContextHolder.get().getCompanyId();
Long orgId = ContextHolder.get().getOrgId();
Long siteId = ContextHolder.get().getSiteId();
pointLevel.setId(idGenerator.generate());
pointLevel.setCompanyId(companyId);
pointLevel.setOrgId(orgId);
pointLevel.setSiteId(siteId);
return pointLevelMapper.insert(pointLevel)>0;
}
@Override
public Boolean piontLevelDelete(Long id) {
return pointLevelMapper.piontLevelDelete(id);
}
@Override
public List<PointLevel> levelList(Long id) {
return pointLevelMapper.levelList(id);
}
@Override
public Integer updateById1(PointLevel pointLevel) {
return pointLevelMapper.updateById(pointLevel);
}
}
package com.yizhi.application.service.impl;
import java.util.Date;
import com.yizhi.application.orm.id.IdGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.application.domain.Point;
import com.yizhi.application.mapper.PointMapper;
import com.yizhi.application.service.PointService;
/**
* <p>
* 积分设置 服务实现类
* </p>
*
* @author bob123
* @since 2018-04-20
*/
@Service
public class PointServiceImpl extends ServiceImpl<PointMapper, Point> implements PointService {
@Autowired
PointMapper pointMapper;
@Autowired
IdGenerator idGenerator;
@Override
public Point pointList(Long companyId, Long siteId) {
Point point = pointMapper.pointList(companyId, siteId);
if(point == null){
point = new Point();
point.setState(0);
point.setUnit("积分");
}
return point;
}
@Override
public boolean updateList(Point point) {
Integer state = point.getState();
String unit = point.getUnit();
Long companyId = point.getCompanyId();
Long siteId = point.getSiteId();
Long updateAccountId = point.getUpdateById();
String updateAccountName = point.getUpdateByName();
Integer count = pointMapper.updateList(state, unit, companyId, siteId, updateAccountId, updateAccountName);
if(count > 0){
return true;
} else {
point.setId(idGenerator.generate());
point.setCreateById(updateAccountId);
point.setCreateByName(updateAccountName);
point.setCreateTime(new Date());
count = pointMapper.insert(point);
if(count > 0){
return true;
}
}
return false;
}
}
package com.yizhi.application.service.impl;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
import com.yizhi.application.service.PointLevelService;
import com.yizhi.application.service.PointUserService;
import com.yizhi.application.domain.PointUser;
import com.yizhi.point.application.vo.PointUserListVO;
import com.yizhi.point.application.vo.PointUserParamVO;
import com.yizhi.point.application.vo.TotalPointVO;
import com.yizhi.system.application.constant.AuthzConstant;
import com.yizhi.system.application.system.remote.AccountClient;
import com.yizhi.system.application.system.remote.ReportClient;
import com.yizhi.system.application.vo.HQAccountInManageParam;
import com.yizhi.system.application.vo.ReportAccountRespInManageVO;
import com.yizhi.system.application.vo.ReportAccountRespVO;
import com.yizhi.system.application.vo.ReportRangeAccountReqVO;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.application.mapper.PointUserMapper;
import org.springframework.util.CollectionUtils;
/**
* <p>
* 学员积分 服务实现类
* </p>
*
* @author bob123
* @since 2018-04-20
*/
@Service
public class PointUserServiceImpl extends ServiceImpl<PointUserMapper, PointUser> implements PointUserService {
private static final Logger LOGGER = LoggerFactory.getLogger(PointUserServiceImpl.class);
@Autowired
PointUserMapper pointUserMapper;
@Autowired
PointLevelService pointLevelService;
@Autowired
AccountClient accountClient;
@Autowired
ReportClient reportClient;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
@Override
public Integer queryPiont(Long userId, Long companyId, Long siteId) {
return pointUserMapper.queryPiont(userId, companyId, siteId);
}
@Override
public Page<PointUserListVO> userRankList(PointUserParamVO vo) {
Page<PointUserListVO> page = new Page<PointUserListVO>(vo.getPageNo(), vo.getPageSize());
//根据 用户关键字 获取用户id 集合
List<ReportAccountRespVO> accountVOList = null;
boolean isGetAccount = true;
if (vo.isAdmin()) {
//管理员如果是模糊查询,查询用户,如果是所有用户,不查询
if (StringUtils.isNotBlank(vo.getUserName()) || StringUtils.isNotBlank(vo.getOrgNameLike())) {
isGetAccount = false;
ReportRangeAccountReqVO reportRangeAccountReqVO = new ReportRangeAccountReqVO();
reportRangeAccountReqVO.setSiteId(vo.getSiteId());
if (StringUtils.isNotBlank(vo.getUserName())) {
reportRangeAccountReqVO.setAccountName(vo.getUserName().trim());
}
if (StringUtils.isNotBlank(vo.getOrgNameLike())) {
reportRangeAccountReqVO.setOrgName(vo.getOrgNameLike().trim());
}
accountVOList = reportClient.getRangeAccounts(reportRangeAccountReqVO);
if (CollectionUtils.isEmpty(accountVOList)) {
return page;
}
}
} else {
isGetAccount = false;
HQAccountInManageParam reportRangeAccountReqVO = new HQAccountInManageParam();
reportRangeAccountReqVO.setAccountId(vo.getAccountId());
reportRangeAccountReqVO.setSiteId(vo.getSiteId());
reportRangeAccountReqVO.setModuleType(AuthzConstant.moduleType.statistics_point);
if (StringUtils.isNotBlank(vo.getUserName())) {
reportRangeAccountReqVO.setAccountName(vo.getUserName().trim());
}
if (StringUtils.isNotBlank(vo.getOrgNameLike())) {
reportRangeAccountReqVO.setOrgName(vo.getOrgNameLike().trim());
}
ReportAccountRespInManageVO reportAccountRespInManageVO = reportClient.getRangeAccountsInManage(reportRangeAccountReqVO);
if (null != reportAccountRespInManageVO) {
if (!reportAccountRespInManageVO.getIsAdmin()) {
accountVOList = reportAccountRespInManageVO.getList();
} else {
if (StringUtils.isNotBlank(vo.getUserName()) || StringUtils.isNotBlank(vo.getOrgNameLike())) {
isGetAccount = false;
ReportRangeAccountReqVO reportRangeAccountReqVO1 = new ReportRangeAccountReqVO();
reportRangeAccountReqVO1.setSiteId(vo.getSiteId());
if (StringUtils.isNotBlank(vo.getUserName())) {
reportRangeAccountReqVO1.setAccountName(vo.getUserName().trim());
}
if (StringUtils.isNotBlank(vo.getOrgNameLike())) {
reportRangeAccountReqVO1.setOrgName(vo.getOrgNameLike().trim());
}
accountVOList = reportClient.getRangeAccounts(reportRangeAccountReqVO1);
if (CollectionUtils.isEmpty(accountVOList)) {
return page;
}
}else {
isGetAccount = true;
}
}
}
}
Map<Long, ReportAccountRespVO> accountMap = new HashMap<>();
List<Long> accountIds = new ArrayList<>();
if (!CollectionUtils.isEmpty(accountVOList)) {
for (ReportAccountRespVO reportAccountRespVO : accountVOList) {
accountIds.add(reportAccountRespVO.getUserId());
accountMap.put(reportAccountRespVO.getUserId(), reportAccountRespVO);
}
}
if (!CollectionUtils.isEmpty(accountIds)) {
vo.setAccountIds(accountIds);
}
List<PointUserListVO> list = pointUserMapper.userRankList(page, vo);
if (CollectionUtils.isEmpty(list)) {
return page;
}
//管理员非模糊查询根据记录用户id查找用户信息
if (isGetAccount) {
for (PointUserListVO pointUserListVO : list) {
accountIds.add(pointUserListVO.getUserId());
}
if (CollectionUtils.isEmpty(accountIds)) {
return page;
}
ReportRangeAccountReqVO reportRangeAccountReqVO = new ReportRangeAccountReqVO();
reportRangeAccountReqVO.setSiteId(vo.getSiteId());
reportRangeAccountReqVO.setAccountIds(accountIds);
List<ReportAccountRespVO> respVOS = reportClient.getRangeAccounts(reportRangeAccountReqVO);
if (!CollectionUtils.isEmpty(respVOS)) {
for (ReportAccountRespVO respVO : respVOS) {
accountMap.put(respVO.getUserId(), respVO);
}
}
}
if (!CollectionUtils.isEmpty(list)) {
for (PointUserListVO pvo : list) {
Long userId = pvo.getUserId();
if (userId == null) {
continue;
}
ReportAccountRespVO accountVO = accountMap.get(userId);
if (accountVO != null) {
pvo.setUserName(accountVO.getUserName());
pvo.setEmail(accountVO.getEmail());
pvo.setName(accountVO.getUserFullName());
pvo.setOrgId(accountVO.getOrgId());
pvo.setOrgName(accountVO.getOrgName());
pvo.setAccountState(accountVO.getStatus() == 1 ? true : false);
}
}
page.setRecords(list);
}
return page;
}
@Override
public List<PointUserListVO> userRankListExport(PointUserParamVO vo) {
return pointUserMapper.userRankList(vo);
}
@Override
public Integer acquirePoint(Long accountId, Long learnSourceId, String createTime) {
return pointUserMapper.acquirePoint(accountId, learnSourceId, createTime);
}
@Override
public Timestamp getStartDate() {
return pointUserMapper.getStartDate();
}
@Override
public Map<Long, Long> totalPoint( List<Long> siteIds, String startDate, String endDate) {
// TODO Auto-generated method stub
Map<Long, Long> hashMap = new HashMap<Long, Long>();
List<TotalPointVO> list = pointUserMapper.totalPoint(siteIds, startDate, endDate);
for(TotalPointVO vo:list) {
if (vo.getAccountId()!=null) {
hashMap.put(vo.getAccountId(), vo.getPoint());
}
}
return hashMap;
}
}
package com.yizhi.application.util;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.core.application.publish.CloudEventPublisher;
import com.yizhi.message.application.enums.EvenType;
import com.yizhi.message.application.enums.RelationType;
import com.yizhi.message.application.vo.MessageRemindVo;
import com.yizhi.message.application.vo.TaskVo;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
@Component
public class PointEvenSendMessage {
@Autowired
private CloudEventPublisher cloudEventPublisher;
private Logger logger = LoggerFactory.getLogger(PointEvenSendMessage.class);
/**
* 触发事件,
*
* @param taskVo 业务参数对象
* @param accountId
*/
public void evenSendMessage(Long pointUserId, TaskVo taskVo, Long accountId, EvenType evenType, RequestContext context) {
if (taskVo != null) {
MessageRemindVo vo = new MessageRemindVo();
vo.setVisibleRange(1);
vo.setMessageId(evenType.getKey());
vo.setMessageType(3);
vo.setRelationId(pointUserId);
vo.setRelationType(RelationType.JF.getKey());
vo.setSendType(1);
//定时任务默认五分钟执行一次 这里默认暂时不延迟时间
vo.setSendTime(DateUtils.addMinutes(new Date(), 0));
if (accountId != null) {
vo.setAccountId(accountId);
}
vo.setRequestContext(context);
vo.setTaskVo(taskVo);
try {
//临时取消触发功能
// cloudEventPublisher.publish(Constans.MESSAGE_QUEUE, new EventWrapper<MessageRemindVo>(null, vo));
} catch (Exception e) {
e.printStackTrace();
logger.error("发送消息失败=====================", e);
}
}
}
}
server.port=34007
spring.application.name=point
ACTIVE=${spring.profiles.active}
spring.profiles.active=sit
# nacos
spring.cloud.nacos.config.shared-dataids=common-${spring.profiles.active}.properties
spring.cloud.nacos.config.namespace=${spring.profiles.active}
spring.cloud.nacos.config.prefix=${spring.application.name}
spring.cloud.nacos.config.file-extension=properties
spring.cloud.nacos.config.server-addr=192.168.1.13:3333,192.168.1.24:4444,192.168.1.38:5555
<?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.yizhi.application.mapper.MqPointParamMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.yizhi.application.domain.MqPointParam">
<id column="id" property="id" />
<result column="eventName" property="eventName" />
<result column="activityType" property="activityType" />
<result column="activitySource" property="activitySource" />
<result column="sourceId" property="sourceId" />
<result column="activityName" property="activityName" />
<result column="releaseCondition" property="releaseCondition" />
<result column="releaseRules" property="releaseRules" />
<result column="operatingPoint" property="operatingPoint" />
<result column="createPointTime" property="createPointTime" />
<result column="accountId" property="accountId" />
<result column="accountName" property="accountName" />
<result column="siteId" property="siteId" />
<result column="orgId" property="orgId" />
<result column="companyId" property="companyId" />
<result column="state" property="state" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, eventName, activityType, activitySource, sourceId, activityName,
releaseCondition, releaseRules, operatingPoint, createPointTime,
accountId, accountName, siteId, orgId, companyId, state
</sql>
</mapper>
<?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.yizhi.application.mapper.PointActivityMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.yizhi.application.domain.PointActivity">
<id column="id" property="id" />
<result column="activity_name" property="activityName" />
<result column="multiple" property="multiple" />
<result column="start_time" property="startTime" />
<result column="end_time" property="endTime" />
<result column="state" property="state" />
<result column="create_time" property="createTime" />
<result column="create_by_id" property="createById" />
<result column="create_by_name" property="createByName" />
<result column="update_time" property="updateTime" />
<result column="update_by_id" property="updateById" />
<result column="update_by_name" property="updateByName" />
<result column="enable_time" property="enableTime" />
<result column="enable_by_id" property="enableById" />
<result column="enable_by_name" property="enableByName" />
<result column="company_id" property="companyId" />
<result column="org_id" property="orgId" />
<result column="site_id" property="siteId" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
pa.id, pa.activity_name, pa.multiple, pa.start_time, pa.end_time, pa.state, pa.create_time,
pa.create_by_id, pa.create_by_name, pa.update_time, pa.update_by_id, pa.update_by_name,
pa.enable_time, pa.enable_by_id, pa.enable_by_name, pa.company_id, pa.org_id, pa.site_id
</sql>
<select id="activityList" resultType="com.yizhi.application.domain.PointActivity">
SELECT *
FROM point_activity
WHERE state != 0 AND company_id = #{companyId}
<if test="siteId!=null">
AND site_id =#{siteId}
</if>
<if test="activityName!=null and activityName!=''">
AND activity_name like CONCAT('%', #{activityName}, '%')
</if>
</select>
<select id="getPointActivity" resultType="com.yizhi.application.domain.PointActivity">
select
<include refid="Base_Column_List"/>
from point_activity pa where pa.start_time &lt;= #{createPointTime} and pa.end_time &gt;= #{createPointTime}
and state=2 and pa.company_id=#{companyId} and pa.site_id=#{siteId}
</select>
</mapper>
<?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.yizhi.application.mapper.PointDetailsMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.yizhi.application.domain.PointDetails">
<id column="id" property="id"/>
<result column="activity_id" property="activityId"/>
<result column="time" property="time"/>
<result column="point" property="point"/>
<result column="account_id" property="accountId"/>
<result column="learn_type" property="learnType"/>
<result column="learn_name" property="learnName"/>
<result column="learn_source" property="learnSource"/>
<result column="learn_source_id" property="learnSourceId"/>
<result column="state" property="state"/>
<result column="create_time" property="createTime"/>
<result column="create_by_id" property="createById"/>
<result column="create_by_name" property="createByName"/>
<result column="update_time" property="updateTime"/>
<result column="update_by_id" property="updateById"/>
<result column="update_by_name" property="updateByName"/>
<result column="company_id" property="companyId"/>
<result column="org_id" property="orgId"/>
<result column="site_id" property="siteId"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
pd.id, pd.activity_id, pd.time, pd.point, pd.account_id, pd.learn_type, pd.learn_name, pd.learn_source,
pd.learn_source_id, pd.state, pd.create_time, pd.create_by_id, pd.create_by_name,
pd.update_time, pd.update_by_id, pd.update_by_name, pd.company_id, pd.org_id, pd.site_id
</sql>
<select id="todayList" resultType="com.yizhi.point.application.vo.PointDetailsVO">
SELECT time,learn_type,learn_name,learn_source,point,CASE WHEN point > 0 THEN 1 ELSE 0 END AS flag,DATE_FORMAT( time, '%m' ) AS month
from point_details where to_days(time)=to_days(now())
and account_id=#{accountId} order by time
</select>
<select id="aMonthList" resultType="com.yizhi.point.application.vo.PointDetailsVO">
SELECT time,learn_type,learn_name,learn_source,point,
CASE WHEN point > 0 THEN 1 ELSE 0 END AS flag,DATE_FORMAT( time, '%m' ) AS month,
(SELECT SUM( point ) FROM point_details pd WHERE pd.sort &lt;= pdtb.sort and pd.account_id=#{accountId} and
pd.site_id = #{siteId}) as amount
FROM point_details pdtb
WHERE account_id=#{accountId}
<if test="year!=null and year!=''">
and DATE_FORMAT(time, '%Y' )=#{year}
</if>
<if test="siteId!=null and siteId !='' ">
and pdtb.site_id = #{siteId}
</if>
<if test="type!=null and type !='' ">
and pdtb.learn_source LIKE CONCAT('%',#{type},'%')
</if>
order by sort DESC
</select>
<select id="queryPiont" resultType="java.lang.Integer">
SELECT
SUM( pd.point )
FROM
point_details pd
WHERE
pd.account_id=#{userId}
<if test="siteId!=null">
and pd.site_id=#{siteId}
</if>
<if test="companyId!=null">
and pd.company_id=#{companyId}
</if>
<if test="type!=null and type !='' ">
and pd.learn_source LIKE CONCAT('%',#{type},'%')
</if>
</select>
<select id="getManagePointDetails" resultType="com.yizhi.point.application.vo.PointDetailsVO">
SELECT account_id,time,learn_type,learn_name,learn_source,point,CASE WHEN point > 0 THEN 1 ELSE 0 END AS
flag,DATE_FORMAT( time, '%m' ) AS month
FROM point_details
WHERE company_id=#{companyId}
<if test="siteId!=null">
AND site_id=#{siteId}
</if>
<if test="activityId!=null">
AND activity_id=#{activityId}
</if>
<if test="startTime!=null">
AND <![CDATA[ DATE_FORMAT(time,'%Y-%m-%d')>=DATE_FORMAT(#{startTime},'%Y-%m-%d')]]>
</if>
<if test="endTime!=null">
AND <![CDATA[ DATE_FORMAT(time,'%Y-%m-%d')<=DATE_FORMAT(#{endTime},'%Y-%m-%d')]]>
</if>
<if test="accountIds != null and accountIds.size() > 0">
and account_id in
<foreach item="item1" index="index" collection="accountIds" open="(" separator="," close=")">
#{item1}
</foreach>
</if>
order by time DESC
</select>
<select id="getReportPoints" resultType="com.yizhi.application.domain.PointDetails">
SELECT
learn_source_id,learn_source,learn_name,company_id,site_id,account_id,
SUM( point ) as point,MAX(time) as time
FROM
point_details
WHERE
1 = 1
<if test="companyId != null">
AND company_id = #{companyId}
</if>
<if test="siteId != null">
AND site_id = #{siteId}
</if>
<if test="bizId != null">
AND learn_source_id = #{bizId}
</if>
<if test="accountId != null">
AND account_id = #{accountId}
</if>
<if test="!isRealTime">
AND <![CDATA[ DATE_FORMAT(now(),'%Y-%m-%d')>DATE_FORMAT(time,'%Y-%m-%d')]]>
</if>
GROUP BY
learn_source_id,site_id,account_id
</select>
<select id="getCourseReportPoints" resultType="com.yizhi.application.domain.PointDetails">
SELECT sum( point )
FROM point_details
WHERE
account_id = #{accountId}
AND ( learn_source_id IN ( SELECT id FROM cloud_course.chapter WHERE course_id = #{bizId} )
OR learn_source_id = #{bizId})
<if test="!isRealTime">
AND <![CDATA[ DATE_FORMAT(now(),'%Y-%m-%d')>DATE_FORMAT(time,'%Y-%m-%d')]]>
</if>
</select>
<select id="getCourseStatisticsPoint" resultType="com.yizhi.application.domain.PointDetails">
SELECT company_id AS companyId,site_id AS siteId,account_id AS accountId,course_id AS courseId,SUM(POINT) AS POINT,0 as learnType FROM `point_details` WHERE course_id IS NOT NULL AND company_id IS NOT NULL AND site_id IS NOT NULL AND account_id IS NOT NULL
AND <![CDATA[ DATE_FORMAT(now(),'%Y-%m-%d')>DATE_FORMAT(time,'%Y-%m-%d')]]>
GROUP BY company_id,site_id,account_id,course_id
</select>
<select id="getNoCourseStatisticsPoint" resultType="com.yizhi.application.domain.PointDetails">
SELECT company_id AS companyId,site_id AS siteId,account_id AS accountId,learn_source_id AS courseId,SUM(POINT) AS POINT,learn_type as learnType FROM `point_details` WHERE course_id IS NULL AND company_id IS NOT NULL AND site_id IS NOT NULL AND account_id IS NOT NULL
AND <![CDATA[ DATE_FORMAT(now(),'%Y-%m-%d')>DATE_FORMAT(time,'%Y-%m-%d')]]>
GROUP BY company_id,site_id,account_id,learn_source_id
</select>
<select id="getPointByCondition" resultType="Integer">
select sum(point) from `point_details`
<where>
state = 1 and account_id = #{accountId} and site_id = #{siteId}
<if test="bizIds != null and bizIds.size() > 0">
and learn_source_id in (
<foreach collection="bizIds" item="bizId" separator=",">
#{bizId}
</foreach>
)
</if>
</where>
</select>
<select id="getAllAccountIds" resultType="java.lang.Long">
select
distinct account_id
from
point_details
where site_id = #{siteId}
</select>
<select id="getAllSiteIds" resultType="java.lang.Long">
select distinct site_id from point_details
</select>
<update id="updateChangeAfter">
UPDATE point_details c
LEFT JOIN (
SELECT
d1.id AS id,
sum( d2.point ) AS sum_of_point
FROM
point_details d1
LEFT JOIN point_details d2 ON d1.account_id = d2.account_id
AND d1.site_id = d2.site_id
AND d1.company_id = d2.company_id
WHERE
d1.id >= d2.id
AND d1.site_id = #{siteId}
AND d1.account_id = #{accountId}
GROUP BY
d1.account_id,
d1.company_id,
d1.id
) AS d
ON c.id = d.id
set c.change_after = d.sum_of_point
WHERE
c.site_id = #{siteId}
and
c.account_id = #{accountId}
</update>
<select id="getPointCountByAccountId" resultType="java.lang.Integer">
SELECT
change_after count
FROM
`point_details`
WHERE
account_id = #{accountId}
and site_id = #{siteId}
and company_id = #{companyId}
ORDER BY
create_time DESC
LIMIT 1
</select>
<select id="selectPointDetails" resultType="com.yizhi.point.application.vo.domain.PointDetailsVo">
select * from point_details
where
state = 1
and create_time <![CDATA[ >= ]]> #{startDate}
and create_time <![CDATA[ <= ]]> #{endDate}
<if test="null != companyId">
and company_id = #{companyId}
</if>
<if test="null != siteId">
and site_id = #{siteId}
</if>
</select>
</mapper>
<?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.yizhi.application.mapper.PointLevelMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.yizhi.application.domain.PointLevel">
<id column="id" property="id" />
<result column="level_no" property="levelNo" />
<result column="level_name" property="levelName" />
<result column="start_score" property="startScore" />
<result column="end_score" property="endScore" />
<result column="state" property="state" />
<result column="create_time" property="createTime" />
<result column="create_by_id" property="createById" />
<result column="create_by_name" property="createByName" />
<result column="update_time" property="updateTime" />
<result column="update_by_id" property="updateById" />
<result column="update_by_name" property="updateByName" />
<result column="company_id" property="companyId" />
<result column="org_id" property="orgId" />
<result column="site_id" property="siteId" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, level_no AS levelNo, level_name AS levelName, start_score AS
startScore, end_score AS endScore, state, create_time AS createTime,
create_by_id AS createById, create_by_name AS createByName,
update_time AS updateTime, update_by_id AS updateById, update_by_name
AS updateByName, company_id AS companyId, org_id AS orgId, site_id AS
siteId
</sql>
<delete id="piontLevelDelete">
delete from point_level where id=#{id}
</delete>
<select id="levelList" resultType="com.yizhi.application.domain.PointLevel">
select level_no,level_name,start_score,end_score from point_level where id=#{id}
</select>
</mapper>
<?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.yizhi.application.mapper.PointMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.yizhi.application.domain.Point">
<id column="id" property="id" />
<result column="unit" property="unit" />
<result column="state" property="state" />
<result column="create_time" property="createTime" />
<result column="create_by_id" property="createById" />
<result column="create_by_name" property="createByName" />
<result column="update_time" property="updateTime" />
<result column="update_by_id" property="updateById" />
<result column="update_by_name" property="updateByName" />
<result column="enable_time" property="enableTime" />
<result column="enable_by_id" property="enableById" />
<result column="enable_by_name" property="enableByName" />
<result column="company_id" property="companyId" />
<result column="org_id" property="orgId" />
<result column="site_id" property="siteId" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, unit, state, create_time AS createTime, create_by_id AS createById, create_by_name AS createByName, update_time AS updateTime, update_by_id AS updateById, update_by_name AS updateByName, enable_time AS enableTime, enable_by_id AS enableById, enable_by_name AS enableByName, company_id AS companyId, org_id AS orgId, site_id AS siteId
</sql>
<select id="pointList" resultType="com.yizhi.application.domain.Point">
select state,unit
from point
where
<if test="companyId!=null and siteId!=null">
company_id=#{companyId} and site_id=#{siteId}
</if>
</select>
<update id="updateList">
update point
<set>
unit=#{unit} ,
state=#{state} ,
update_by_id=#{updateAccountId} ,
update_by_name=#{updateAccountName},
update_time=now()
</set>
where company_id=#{companyId} AND site_id=#{siteId}
</update>
</mapper>
<?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.yizhi.application.mapper.PointUserMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap"
type="com.yizhi.application.domain.PointUser">
<id column="id" property="id" />
<result column="user_id" property="userId" />
<result column="total_point" property="totalPoint" />
<result column="unused_point" property="unusedPoint" />
<result column="state" property="state" />
<result column="create_time" property="createTime" />
<result column="create_by_id" property="createById" />
<result column="create_by_name" property="createByName" />
<result column="update_time" property="updateTime" />
<result column="update_by_id" property="updateById" />
<result column="update_by_name" property="updateByName" />
<result column="company_id" property="companyId" />
<result column="org_id" property="orgId" />
<result column="site_id" property="siteId" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, user_id AS userId, total_point AS totalPoint,
unused_point AS
unusedPoint, state, create_time AS createTime,
create_by_id AS
createById, create_by_name AS createByName, update_time
AS updateTime,
update_by_id AS updateById, update_by_name AS
updateByName, company_id
AS companyId, org_id AS orgId, site_id AS
siteId
</sql>
<select id="queryPiont" resultType="java.lang.Integer">
select SUM(point) from
point_details
where site_id=#{siteId}
and company_id=#{companyId}
and
account_id=#{userId}
GROUP BY account_id
</select>
<select id="userRankList"
resultType="com.yizhi.point.application.vo.PointUserListVO">
select a.account_id as userId,SUM(a.point) as totalPoint from
point_details a
where a.site_id=#{vo.siteId}
and
a.company_id=#{vo.companyId}
and a.account_id is not null
<if test="vo.startAt != null">
and create_time &gt;= #{vo.startAt}
</if>
<if test="vo.endAt != null">
and create_time &lt; #{vo.endAt}
</if>
<if test="vo.accountIds != null and vo.accountIds.size() > 0">
and a.account_id in
<foreach item="itemId" index="index"
collection="vo.accountIds" open="(" separator="," close=")">
#{itemId}
</foreach>
</if>
GROUP BY a.account_id
order by totalPoint desc,a.account_id
</select>
<select id="getStartDate" resultType="java.sql.Timestamp">
select min(create_time)
from point_user
</select>
<select id="acquirePoint" resultType="java.lang.Integer">
SELECT IFNULL(sum(point),0) from point_details where
account_id=#{accountId} and learn_source_id=#{learnSourceId}
and <![CDATA[ DATE_FORMAT(create_time,'%Y-%m-%d')=DATE_FORMAT(#{createTime,jdbcType=VARCHAR},'%Y-%m-%d')
]]>
</select>
<resultMap type="com.yizhi.point.application.vo.TotalPointVO"
id="pointMap">
<result property="accountId" column="accountId" />
<result property="point" column="count" />
</resultMap>
<select id="totalPoint" resultType="com.yizhi.point.application.vo.TotalPointVO">
SELECT IFNULL(SUM(p.point),0) point,account_id accountId from point_details p
WHERE
p.site_id IN
<foreach item="itemId" index="index" collection="siteIds"
open="(" separator="," close=")">
#{itemId}
</foreach>
AND create_time BETWEEN #{startDate}
AND #{endDate}
group by accountId
</select>
</mapper>
/* 11:45:41 AM yz-dev-- cloud_point */ ALTER TABLE `point_details`
ADD `change_before` INT(11) NULL DEFAULT NULL COMMENT '变动前积分总量' AFTER `time`,
ADD `change_after` INT(11) NULL DEFAULT NULL COMMENT '变动后积分总量' AFTER `point`,
CHANGE `update_time` `update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间';
UPDATE point_details c
LEFT JOIN (
SELECT
d1.id as id,
sum(d2.point) as sum_of_point
FROM
point_details d1
LEFT JOIN
point_details d2
ON d1.account_id = d2.account_id
and d1.site_id = d2.site_id
and d1.company_id = d2.company_id
WHERE
d1.id >= d2.id
GROUP BY
d1.account_id,
d1.company_id,
d1.site_id,
d1.id) AS d ON c.id = d.id
SET c.change_after = d.sum_of_point;
update point_details set change_before = change_after - point;
#报表数据库cloud_statistics新建积分日志表point_log
CREATE TABLE `point_log` (
`id` bigint(20) NOT NULL COMMENT '主键Id',
`point_detail_id` bigint(20) DEFAULT NULL COMMENT '积分记录ID',
`account_id` bigint(20) DEFAULT NULL COMMENT '学员Id',
`before_count` int(11) DEFAULT NULL COMMENT '变动前数量',
`change_count` int(10) DEFAULT NULL COMMENT '变动数量',
`after_count` int(11) DEFAULT NULL COMMENT '变动后数量',
`change_type` int(11) DEFAULT NULL COMMENT '变动类型',
`relation_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT '变动原因(考试名或项目名)',
`create_by_id` bigint(20) DEFAULT NULL COMMENT '创建人',
`create_by_name` varchar(200) DEFAULT NULL COMMENT '创建人姓名',
`company_id` bigint(20) DEFAULT NULL COMMENT '公司ID',
`org_id` bigint(20) DEFAULT NULL COMMENT '部门ID',
`site_id` bigint(20) DEFAULT NULL COMMENT '站点ID',
`created_at` timestamp NULL DEFAULT NULL COMMENT 'log创建时间',
`log_created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'point_details表跑批记录入库时间',
UNIQUE KEY `index_id` (`id`) USING BTREE,
KEY `index_account_site_company_id` (`account_id`,`site_id`,`company_id`) USING BTREE,
KEY `index_created_at` (`created_at`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='积分明细';
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.yizhi</groupId>
<artifactId>wmy-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath/>
</parent>
<groupId>com.yizhi</groupId>
<artifactId>point-project</artifactId>
<version>1.0-SNAPSHOT</version>
<modules>
<module>cloud-point-api</module>
<module>cloud-point</module>
</modules>
<packaging>pom</packaging>
<repositories>
<repository>
<id>wmy4.0</id>
<url>http://mvn.km365.pw/nexus/content/groups/wmy4.0-group/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</project>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment