Commit 71c09243 by liangkaiping

copy

parent facf03aa
<?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>
<artifactId>customproject</artifactId>
<groupId>com.yizhi</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cloud-customproject-api</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-common-api</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-orm</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-util</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-core</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</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.custom.api.feign;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.custom.api.param.ExperiencePoolParam;
import com.yizhi.custom.api.vo.domain.CodePackageManageVo;
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;
/**
* 代码包管理feign接口
*
* @author dingxiaowei
* @date 2018-11-5
*/
@FeignClient(name = "customproject", contextId = "CodePackageManageClient")
public interface CodePackageManageClient {
/**
* 代码包列表
*
* @param experiencePoolParam
* @return
*/
@GetMapping("/manage/codePackageManage/list")
Page<CodePackageManageVo> getCodePackageManageList(@RequestBody ExperiencePoolParam experiencePoolParam);
/**
* 单个代码包查看
*
* @param CodePackageId
* @return
*/
@GetMapping("/manage/codePackageManage/view")
CodePackageManageVo viewCodePackageManage(@RequestParam("CodePackageId") Long CodePackageId);
/**
* 删除代码包
*
* @param CodePackageId
* @return
*/
@GetMapping("/manage/codePackageManage/delete")
boolean deleteCodePackage(@RequestParam("CodePackageId") Long CodePackageId);
/**
* 复制访问路径
*
* @param CodePackageId
* @return
*/
@GetMapping("/manage/codePackageManage/getUrl")
String getCodePackageUrl(@RequestParam("CodePackageId") Long CodePackageId);
/**
* 导出二维码
*
* @param url
* @param CodePackageId
* @return
*/
@GetMapping("/manage/codePackageManage/getQRCode")
String getQRCode(@RequestParam("url") String url, @RequestParam("CodePackageId") Long CodePackageId);
/**
* 代码包新增(修改)
*
* @param
* @return
*/
@GetMapping("/manage/codePackageManage/insert")
CodePackageManageVo insertCodePackage(@RequestParam(value = "CodePackageId", required = false) Long CodePackageId,
@RequestParam(value = "CodePackageName", required = false) String CodePackageName,
@RequestParam(value = "url", required = false) String url);
}
package com.yizhi.custom.api.feign;
import com.yizhi.custom.api.vo.custom.VisibleRangeExportVo;
import com.yizhi.custom.api.vo.domain.ExperiencePoolAuthorizeVo;
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 dingxiaowei
* @date 2018-11-2
*/
@FeignClient(name = "customproject", contextId = "ExperiencePoolAuthorizeClient")
public interface ExperiencePoolAuthorizeClient {
/**
* 导入可见范围
*
* @param poolAuthorizeList
* @return
*/
@PostMapping("/manage/experiencePool/authorize/insert")
boolean insertExperiencePoolAuthorize(@RequestBody List<ExperiencePoolAuthorizeVo> poolAuthorizeList);
/**
* 导出可见范围
*
* @param experiencePoolId
* @return
*/
@GetMapping("/manage/experiencePool/authorize/list")
VisibleRangeExportVo listAuthorizes(@RequestParam("experiencePoolId") Long experiencePoolId);
/**
* 可见范围列表
*
* @param experiencePoolId
* @return
*/
@GetMapping("/manage/experiencePool/authorize/view")
List<Map<String, Object>> getListMap(@RequestParam("experiencePoolId") Long experiencePoolId);
}
package com.yizhi.custom.api.feign;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.custom.api.param.ExperiencePoolParam;
import com.yizhi.custom.api.vo.custom.ExperiencePoolVoAutorizeAndProjectVO;
import com.yizhi.custom.api.vo.domain.ExperiencePoolVo;
import com.yizhi.custom.api.vo.domain.ProjectActivityExperienceVo;
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;
/**
* 经验池主体feign接口
*
* @author dingxiaowei
* @date 2018-11-2
*/
@FeignClient(name = "customproject", contextId = "ExperiencePoolClient")
public interface ExperiencePoolClient {
/**
* 显示经验池列表
*
* @param param
* @return
*/
@GetMapping("/manage/experiencePool/list")
Page<ExperiencePoolVo> getExperiencePoolList(@RequestBody ExperiencePoolParam param);
/**
* 查看单个经验池查看
*
* @param poolId
* @return
*/
@GetMapping("/manage/experiencePool/view")
ExperiencePoolVoAutorizeAndProjectVO getExperiencePoolView(@RequestParam("poolId") Long poolId);
/**
* 删除经验池
*
* @param experiencePoolId
* @return
*/
@GetMapping("/manage/experiencePool/delete")
boolean deleteExperiencePool(@RequestParam("poolId") Long experiencePoolId);
/**
* 导入线下活动外部经验
*
* @param projectActivityExperienceList
* @return
*/
@PostMapping("/manage/experiencePool/importActivityExperiences")
boolean insertExperiencePoolList(@RequestBody List<ProjectActivityExperienceVo> projectActivityExperienceList);
/**
* 下载经验规则
*
* @param poolId
* @return
*/
@GetMapping("/manage/experiencePool/getActivityExperience")
List<ProjectActivityExperienceVo> getActivityExperienceList(@RequestParam("poolId") Long poolId);
/**
* 经验池保存(新增,修改下一步)(插入经验池可见范围及关联项目并返回项目关联活动列表)
*
* @param experiencePoolAutorizeAndProjectVO
* @return
*/
@PostMapping("/manage/experiencePool/save")
Map<String, Object> insertExperiencePoolAuthorizeAndProject(@RequestBody
ExperiencePoolVoAutorizeAndProjectVO experiencePoolAutorizeAndProjectVO);
/**
* 经验池新增完成
*
* @param poolId
* @return
*/
@GetMapping("/manage/experiencePool/complete")
boolean completeExperiencePool(@RequestParam("poolId") Long poolId);
}
package com.yizhi.custom.api.feign;
import com.yizhi.custom.api.vo.domain.ExperiencePoolLevelVo;
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.util.List;
import java.util.Map;
/**
* 经验池等级feign接口
*
* @author dingxiaowei
* @date 2018-11-2
*/
@FeignClient(name = "customproject", contextId = "ExperiencePoolLevelClient")
public interface ExperiencePoolLevelClient {
/**
* 设置经验池等级(显示经验池列表)
*
* @param poolId
* @return
*/
@GetMapping("/manage/experiencePool/level/list")
List<ExperiencePoolLevelVo> getExperiencePoolLevelList(@RequestParam("poolId") Long poolId);
/**
* 查看单个经验池等级
*
* @param poolId
* @return
*/
@GetMapping("/manage/experiencePool/level/view")
ExperiencePoolLevelVo getExperiencePoolLevelView(@RequestParam("poolId") Long poolId);
/**
* 删除经验池等级
*
* @param poolLevelId
* @return
*/
@GetMapping("/manage/experiencePool/level/delete")
boolean deleteExperiencePoolLevel(@RequestParam("poolLevelId") Long poolLevelId);
/**
* 新增(更新)经验池等级
*
* @param experiencePoolLevel
* @return
*/
@GetMapping("/manage/experiencePool/level/insert")
Map<String, Object> insertExperiencePoolLevel(@RequestBody ExperiencePoolLevelVo experiencePoolLevel);
}
package com.yizhi.custom.api.feign;
import com.yizhi.custom.api.vo.domain.ExperiencePoolProjectVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* 经验池关联项目/活动接口
*
* @author dingxiaowei
* @date 2018-11-2
*/
@FeignClient(name = "customproject", contextId = "ExperiencePoolProjectClient")
public interface ExperiencePoolProjectClient {
/**
* 查看关联活动ID
*
* @param experiencePoolId
* @return
*/
@GetMapping("/manage/experiencePool/project/view")
List<ExperiencePoolProjectVo> getExperiencePoolProjectList(@RequestParam("experiencePoolId") Long experiencePoolId);
}
package com.yizhi.custom.api.feign;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.custom.api.vo.custom.ExperiencePoolReportExportVo;
import com.yizhi.custom.api.vo.custom.ExperiencePoolReportVo;
import com.yizhi.core.application.context.RequestContext;
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;
/**
* @author Ding
* @className ExperiencePoolReportClient
* @description TODO
* @date 2018/11/29
**/
@FeignClient(name = "customproject", contextId = "ExperiencePoolReportClient")
public interface ExperiencePoolReportClient {
/**
* 经验池报表获取列表
*
* @param poolName
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("/manage/poolReport/list")
Page<ExperiencePoolReportVo> poolReportList(@RequestParam(value = "poolName", required = false) String poolName,
@RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize,
@RequestBody RequestContext requestContext);
/**
* 经验池报表查看列表
*
* @param poolId
* @param key
* @param orgName
* @param pageNo
* @param pageSize
* @param type
* @param siteId
* @param requestContext
* @param startTime
* @param endTime
* @return
*/
@GetMapping("/manage/poolReport/list/view")
Page<ExperiencePoolReportExportVo> viewPoolReportList(@RequestParam("poolId") Long poolId,
@RequestParam(value = "key", required = false) String key,
@RequestParam(value = "orgName", required = false) String orgName,
@RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize,
@RequestParam(value = "type", required = false) Integer type,
@RequestParam(value = "startTime", required = false) String startTime,
@RequestParam(value = "endTime", required = false) String endTime,
@RequestParam(value = "siteId", required = false) Long siteId,
@RequestBody RequestContext requestContext);
/**
* 经验池报表查看个人经验明细
*
* @param poolId
* @param accountId
* @param state
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("/manage/poolReport/list/view/account/details")
Page<ExperiencePoolReportExportVo> viewAccountDetails(@RequestParam("poolId") Long poolId,
@RequestParam("accountId") Long accountId,
@RequestParam(value = "state", required = false) Integer state,
@RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize);
/**
* 经验池报表查看个人经验明细下载
*
* @param poolId
* @param accountId
* @param state
* @return
*/
@GetMapping("/manage/poolReport/list/view/account/details/export")
String viewAccountDetailsExport(@RequestParam("poolId") Long poolId,
@RequestParam("accountId") Long accountId,
@RequestParam(value = "state", required = false) Integer state);
/**
* 经验池报表导出所有人经验变更明细
*
* @param poolId
* @return
*/
@GetMapping("/manage/poolReport/list/view/all/details/export")
String viewAllDetailsExport(@RequestParam("poolId") Long poolId);
/**
* 经验池报表导出阶段经验变更明细
*
* @param poolId
* @param startTime
* @param endTime
* @param orgName
* @param accountName
* @return
*/
@GetMapping("/manage/poolReport/list/view/stage/details/export")
String viewStageDetailsExport(@RequestParam("poolId") Long poolId,
@RequestParam(value = "startTime", required = false) String startTime,
@RequestParam(value = "endTime", required = false) String endTime,
@RequestParam(value = "orgName", required = false) String orgName,
@RequestParam(value = "accountName", required = false) String accountName);
/**
* 经验池报表导出阶段经验消费变更明细
*
* @param poolId
* @param startTime
* @param endTime
* @param orgName
* @param accountName
* @return
*/
@GetMapping("/manage/poolReport/list/view/stage/purchase/details/export")
String viewStagePurchaseDetailsExport(@RequestParam("poolId") Long poolId,
@RequestParam(value = "startTime", required = false) String startTime,
@RequestParam(value = "endTime", required = false) String endTime,
@RequestParam(value = "orgName", required = false) String orgName,
@RequestParam(value = "accountName", required = false) String accountName);
}
package com.yizhi.custom.api.feign;
import java.util.List;
import java.util.Map;
import com.yizhi.custom.api.vo.custom.*;
import com.yizhi.custom.api.vo.domain.StudentExperiencePoolVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.baomidou.mybatisplus.plugins.Page;
@FeignClient(name = "customproject", contextId = "MyExperienceClient")
public interface MyExperienceClient {
/**
* 个人经验统计
*
* @param param
* @return
*/
@GetMapping("/api/my/experience")
MyExperienceLevelVo getMyExperiencePool(@RequestParam("poolId") Long poolId, @RequestParam("sort") String sort);
/**
* 经验排行榜
*
* @param poolId
* @param sort
* @param pageSize
* @param pageNo
* @return
*/
@GetMapping("/api/my/experience/ranking")
Page<MyExperienceRankingVo> getMyExperienceRankings(@RequestParam("poolId") Long poolId,
@RequestParam("sort") String sort, @RequestParam("pageSize") Integer pageSize,
@RequestParam("pageNo") Integer pageNo);
/**
* 个人经验明细
*
* @param poolId
* @param pageSize
* @param pageNo
* @return
*/
@GetMapping("/api/my/experience/dtl")
Page<MyExperienceEventsVo> getMyExperienceDtl(@RequestParam("poolId") Long poolId,
@RequestParam("pageSize") Integer pageSize, @RequestParam("pageNo") Integer pageNo);
/**
* 个人经验等级分类
*
* @param poolId
* @param pageSize
* @param pageNo
* @return
*/
@GetMapping("/api/my/experience/classify")
MyExperienceLevelVo getMyExperienceClassify(@RequestParam("poolId") Long poolId,
@RequestParam("pageSize") Integer pageSize, @RequestParam("pageNo") Integer pageNo);
/**
* 经验等级
*
* @param poolId
* @return
*/
@GetMapping("/api/my/experience/level")
List<MyExperienceLevelVo> getMyExperienceLevels(@RequestParam("poolId") Long poolId);
/**
* 我的经验池登录信息
*
* @param poolId
* @return
*/
@GetMapping("/api/my/experience/login")
MyExperiencePoolVo getMyExperienceLogin(@RequestParam("poolId") Long poolId);
/**
* 存步数
*
* @param poolId
* @param step
* @return
*/
@GetMapping("/api/my/experience/savestep")
StudentExperiencePoolVo saveMyExperienceStep(@RequestParam("poolId") Long poolId, @RequestParam("step") Integer step);
/**
* 存座右铭
*
* @param poolId
* @param motto
* @return
*/
@GetMapping("/api/my/experience/savemotto")
StudentExperiencePoolVo saveMyExperienceMotto(@RequestParam("poolId") Long poolId, @RequestParam("motto") String motto);
/**
* 自定义项目按组织经验排行
*
* @param poolId
* @param pageNo
* @param pageSize
* @param type
* @return
*/
@GetMapping("/api/my/experience/orgRanking")
Page<ExperienceOrgRankingVO> getOrgRanking(@RequestParam("poolId") Long poolId,
@RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize,
@RequestParam("type") Integer type);
/**
* 自定义项目获取用户组别,批次,备注信息
*
* @param accountId
* @param poolId
* @return
*/
@GetMapping("/api/my/experience/getBatchGroup")
Map<String, Object> getBatchGroup(@RequestParam("accountId") Long accountId,
@RequestParam("poolId") Long poolId);
}
package com.yizhi.custom.api.feign;
import com.yizhi.custom.api.vo.custom.ExperienceRulesVO;
import com.yizhi.custom.api.vo.domain.ProjectActivityExperienceVo;
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;
/**
* 经验池项目关联活动feign接口
*
* @author dingxiaowei
* @date 2018-11-5
*/
@FeignClient(name = "customproject", contextId = "ProjectActivityExperienceClient")
public interface ProjectActivityExperienceClient {
/**
* @param projectActivityExperienceList
* @return
*/
@PostMapping("/manage/experiencePool/projectActivity/insert")
boolean insertProjectActivityExperienceList(@RequestBody List<ProjectActivityExperienceVo> projectActivityExperienceList);
@GetMapping("/manage/experiencePool/projectActivity/getRules")
List<ExperienceRulesVO> getExperienceRules(@RequestParam("poolId") Long poolId);
}
package com.yizhi.custom.api.feign;
import com.yizhi.custom.api.vo.domain.ProjectActivityExperienceSetVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Map;
/**
* 经验池项目关联活动经验规则feign接口
*
* @author dingxiaowei
* @date 2018-11-5
*/
@FeignClient(name = "customproject", contextId = "ProjectActivityExperienceSetClient")
public interface ProjectActivityExperienceSetClient {
/**
* 查看设置活动经验值规则列表
*
* @param activityExperienceId
* @return
*/
@GetMapping("/manage/experiencePool/projectActivityExperienceSet/list")
Map<String, Object> getProjectActivityExperienceSets(@RequestParam("activityExperienceId") Long activityExperienceId,
@RequestParam(value = "setType", required = false) Integer setType);
/**
* 查看单个设置活动经验值规则
*
* @param activityExperienceSetId
* @return
*/
@GetMapping("/manage/experiencePool/projectActivityExperienceSet/view")
ProjectActivityExperienceSetVo viewProjectActivityExperienceSet(@RequestParam("activityExperienceSetId") Long activityExperienceSetId);
/**
* 经验池项目关联活动经验规则添加(修改)
*
* @param activityExperienceId
* @param setType
* @param minScore
* @param maxScore
* @param experience
* @param times
* @return
*/
@GetMapping("/manage/experiencePool/projectActivityExperienceSet/insert")
Map<String, Object> insertProjectActivityExperienceSet(@RequestParam(value = "activityExperienceSetId", required = false) Long activityExperienceSetId,
@RequestParam(value = "activityExperienceId", required = true) Long activityExperienceId,
@RequestParam(value = "setType", required = true) Integer setType,
@RequestParam(value = "minScore", required = true) Integer minScore,
@RequestParam(value = "experience", required = true) Long experience);
@GetMapping("/manage/experiencePool/projectActivityExperienceSet/insertWithScore")
Map<String, Object> insertProjectActivityExperienceSetWithScore(@RequestParam(value = "activityExperienceSetId", required = false) Long activityExperienceSetId,
@RequestParam(value = "activityExperienceId", required = true) Long activityExperienceId,
@RequestParam(value = "setType", required = true) Integer setType,
@RequestParam(value = "times", required = false) Integer times);
/**
* @param activityExperienceId
* @return
*/
@GetMapping("/manage/experiencePool/projectActivityExperienceSet/delete")
boolean deleteProjectActivityExperienceSet(@RequestParam("projectActivityExperienceSetId") Long projectActivityExperienceSetId);
@GetMapping("/manage/experiencePool/projectActivityExperienceSets/delete")
Map<String, Object> deleteProjectActivityExperienceSets(@RequestParam("activityExperienceId") Long activityExperienceId);
}
package com.yizhi.custom.api.feign;
import com.yizhi.custom.api.param.PurchaseProductsParam;
import com.yizhi.custom.api.vo.custom.ProductVO;
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;
/**
* 消费商品feign接口
*
* @author dingxiaowei
* @date 2019-09-19
*/
@FeignClient(name = "customproject", contextId = "PurchaseProductClient")
public interface PurchaseProductClient {
/**
* 自定义项目获取商品信息
* @param poolId
* @return
*/
@GetMapping("/api/my/getProducts")
ProductVO getProducts(@RequestParam("poolId") Long poolId);
/**
* 自定义项目购买商品
* @param param
* @return
*/
@PostMapping("/api/my/purchaseProducts")
String purchaseProducts(@RequestBody PurchaseProductsParam param);
}
package com.yizhi.custom.api.feign;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.custom.api.vo.domain.StudentExperienceVo;
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;
/**
* 经验池项目关联活动feign接口
*
* @author dingxiaowei
* @date 2018-11-12
*/
@FeignClient(name = "customproject", contextId = "StudentExperienceClient")
public interface StudentExperienceClient {
@PostMapping("/manage/experiencePool/studentExperience/insert")
boolean insertStudentExperienceList(@RequestBody List<StudentExperienceVo> studentExperienceList);
@GetMapping("/manage/experiencePool/studentExperience/push")
boolean pushStudentExperience(@RequestParam("experiencePoolId") Long experiencePoolId,
@RequestParam("activityId") Long activityId,
@RequestParam("activityName") String activityName,
@RequestParam("activityType") Integer activityType,
@RequestParam("accountIds") List<Long> accountIds,
@RequestBody RequestContext requestContext);
}
\ No newline at end of file
package com.yizhi.custom.api.param;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author Ding
*
* 项目列表请求类
* @className BizListParam
* @description TODO
* @date 2018/11/14
**/
@ApiModel("项目列表请求类")
@Data
public class BizListParam {
@ApiModelProperty("项目名称")
private String name;
@ApiModelProperty("所选项目ID")
private List<Long> ids;
@ApiModelProperty("请求第几页数")
private Integer pageNo;
@ApiModelProperty("一页显示条数")
private Integer pageSize;
}
package com.yizhi.custom.api.param;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 经验池列表请求类
*
* @author dingxiaowei
* @date 2018-11-2
*/
@ApiModel("经验池列表请求类")
@Data
public class ExperiencePoolParam {
@ApiModelProperty("用户ID")
private Long accountId;
@ApiModelProperty("企业ID")
private Long companyId;
@ApiModelProperty("部门ID")
private Long orgId;
@ApiModelProperty("站点ID")
private Long siteId;
@ApiModelProperty("不是管理员情况下可见部门ID")
private List<Long> orgIds;
@ApiModelProperty("请求第几页数")
private Integer pageNo;
@ApiModelProperty("一页显示条数")
private Integer pageSize;
}
package com.yizhi.custom.api.param;
import com.yizhi.custom.api.vo.domain.ProductVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author Ding
*
* 项目列表请求类
* @className BizListParam
* @description 自定义项目购买商品请求类
* @date 2019/09/19
**/
@ApiModel("自定义项目购买商品请求类")
@Data
public class PurchaseProductsParam {
@ApiModelProperty("经验池id")
private Long poolId;
@ApiModelProperty("所选项目ID")
private List<ProductVo> products;
}
package com.yizhi.custom.api.vo.custom;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author Ding
* @className ExamRuleListVo
* @description TODO
* @date 2019/1/2
**/
@Data
@ApiModel(value = "考试经验规则列表类", description = "考试经验规则列表类")
public class ExamRuleListVo {
@ApiModelProperty("按考试范围最小分")
private Integer minScore;
@ApiModelProperty("按考试范围最大分")
private Integer maxScore;
@ApiModelProperty("获取对应经验t值")
private Long experience;
@ApiModelProperty("按考试分数倍数")
private Integer times;
}
package com.yizhi.custom.api.vo.custom;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author 外部经验导入行对象
* @className ImportSheetRowVO
* @description TODO
* @date 2018/11/12
**/
@Data
@ApiModel(value = "外部经验导入行对象", description = "外部经验导入行对象")
public class ExperienceImportSheetRowVO {
@ApiModelProperty("用户名")
private String name;
@ApiModelProperty("用户Id")
private Long accountId;
@ApiModelProperty("部门id")
private Long orgId;
@ApiModelProperty("部门名称")
private String orgName;
@ApiModelProperty("经验")
private Long experience;
@ApiModelProperty("行数")
private Integer rowNumber;
}
package com.yizhi.custom.api.vo.custom;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author Ding
* @className ExperienceOrgRankingVO
* @description TODO
* @date 2019/6/19
**/
@Data
@ApiModel(value = "按部门经验排行类",description = "按部门经验排行类")
public class ExperienceOrgRankingVO {
@ApiModelProperty("部门id")
private Long orgId;
@ApiModelProperty("部门名称")
private String orgName;
@ApiModelProperty("部门总经验")
private Double totalExperience;
@ApiModelProperty("部门排名")
private Integer rankings;
}
package com.yizhi.custom.api.vo.custom;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author Ding
* @className ExperiencePoolRuleVo
* @description TODO
* @date 2019/1/2
**/
@Data
@ApiModel(value="考试经验发放规则类" ,description ="考试经验发放规则类")
public class ExperiencePoolExamRuleVo {
@ApiModelProperty("经验池")
private Long experiencePoolId;
@ApiModelProperty("活动类型")
private Integer type;
@ApiModelProperty("活动id")
private Long bizId;
@ApiModelProperty("活动名称")
private String bizName;
@ApiModelProperty("考试发放经验类型:1按设定值发放 2按考试分数范围, 3按考试分数倍数")
private Integer experienceType;
@ApiModelProperty("考试经验规则列表")
private List<ExamRuleListVo> ruleList;
@ApiModelProperty("如果有可见范围,可见范围ids")
private List<Long> accountIds;
}
package com.yizhi.custom.api.vo.custom;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author Ding
* @className ExperiencePoolReportExportVo
* @description TODO
* @date 2018/11/29
**/
@Data
@Api(value = "经验池报表导出类", description = "经验池报表导出类")
public class ExperiencePoolReportExportVo {
@ApiModelProperty("用户id")
private Long accountId;
@ApiModelProperty("用户名")
private String accountName;
@ApiModelProperty("姓名")
private String accountFullName;
@ApiModelProperty("所在部门id")
private Long orgId;
@ApiModelProperty("所在部门")
private String orgName;
@ApiModelProperty("所在组织架构")
private String orgNames;
@ApiModelProperty("邮箱")
private String email;
@ApiModelProperty("账号创建时间")
private Date accountCreateTime;
@ApiModelProperty("总经验值")
private Long experienceTotal;
@ApiModelProperty("消耗总值")
private Long purchaseExperienceTotal;
@ApiModelProperty("增加总值")
private Long increaseExperienceTotal;
@ApiModelProperty("变动经验")
private Long experience;
@ApiModelProperty("经验类型")
private Integer type;
@ApiModelProperty("变动明细")
private String description;
@ApiModelProperty("获得经验活动id")
private Long activityId;
@ApiModelProperty("获得经验活动名称")
private String activityName;
@ApiModelProperty("经验获取时间")
private Date createTime;
@ApiModelProperty("等级")
private String experienceLevel;
@ApiModelProperty("课程学习经验")
private Long courseExperience;
@ApiModelProperty("考试经验")
private Long examExperience;
@ApiModelProperty("调研经验")
private Long researchExperience;
@ApiModelProperty("投票经验")
private Long voteExperience;
@ApiModelProperty("外部经验")
private Long externalExperience;
}
package com.yizhi.custom.api.vo.custom;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author Ding
* @className ExperiencePoolReportVo
* @description TODO
* @date 2018/11/29
**/
@Data
@Api(tags = "经验统计类", description = "经验统计类")
public class ExperiencePoolReportVo {
@ApiModelProperty("经验池id")
private Long experiencePoolId;
@ApiModelProperty("经验池名称")
private String experiencePoolName;
@ApiModelProperty("可见范围:1全平台,2指定范围")
private Integer visibleRange;
@ApiModelProperty("经验池创建时间")
private Date poolCreateTime;
@ApiModelProperty("关联学员数")
private Integer rangeAcountNum;
}
package com.yizhi.custom.api.vo.custom;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author Ding
* @className ExperiencePoolRuleVo
* @description TODO
* @date 2019/1/2
**/
@Data
@ApiModel(value="经验发放规则类" ,description ="经验发放规则类")
public class ExperiencePoolRuleVo {
private Long experiencePoolId;
@ApiModelProperty("经验池可见范围")
private Integer visibleRange;
@ApiModelProperty("活动类型")
private Integer type;
private Long bizId;
@ApiModelProperty("活动名称")
private String bizName;
@ApiModelProperty("获取对应经验值")
private Long experience;
@ApiModelProperty("如果是全平台可见,返回指定用户列表")
private List<Long> accountIds;
}
package com.yizhi.custom.api.vo.custom;
import com.yizhi.custom.api.vo.domain.ExperiencePoolAuthorizeVo;
import com.yizhi.custom.api.vo.domain.ExperiencePoolProjectVo;
import com.yizhi.custom.api.vo.domain.ExperiencePoolVo;
import com.yizhi.custom.api.vo.domain.ProjectActivityExperienceVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 经验池
*
* @author dingxiaowei
* @date 2018-11-2
*/
@Data
@ApiModel(value = "ExperiencePoolVoAutorizeAndProjectVO", description = "经验池可见范围及关联项目类")
public class ExperiencePoolVoAutorizeAndProjectVO extends ExperiencePoolVo {
@ApiModelProperty("可见范围列表")
private List<ExperiencePoolAuthorizeVo> experiencePoolAuthorizes;
@ApiModelProperty("经验池关联项目列表")
private List<ExperiencePoolProjectVo> poolProjects;
@ApiModelProperty("经验池项目关联活动经验值列表")
private List<ProjectActivityExperienceVo> projectActivityExperiences;
}
package com.yizhi.custom.api.vo.custom;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author 经验池可见范围导入对象
* @className ExperienceRangeImportVO
* @description TODO
* @date 2018/11/15
**/
@Data
@ApiModel(value = "经验池可见范围导入对象", description = "经验池可见范围导入对象")
public class ExperienceRangeImportVO {
@ApiModelProperty("用户名")
private String name;
@ApiModelProperty("用户Id")
private Long accountId;
@ApiModelProperty("行数")
private Integer rowNumber;
@ApiModelProperty("组别")
private String group;
@ApiModelProperty("批次")
private String batchNo;
@ApiModelProperty("备注")
private String note;
}
package com.yizhi.custom.api.vo.custom;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author Ding
* @className ExperienceRulesVO
* @description TODO
* @date 2018/11/20
**/
@Data
@ApiModel(value="经验规则导出类" ,description ="经验规则导出类")
public class ExperienceRulesVO {
@ApiModelProperty("活动类型")
private Integer type;
@ApiModelProperty("活动名称")
private String name;
@ApiModelProperty("经验获取条件")
private Integer experienceSource;
@ApiModelProperty("按考试范围最小分")
private Integer minScore;
@ApiModelProperty("按考试范围最大分")
private Integer maxScore;
@ApiModelProperty("获取对应经验值")
private String experience;
}
package com.yizhi.custom.api.vo.custom;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import java.util.List;
/**
* @author Ding
* @className ExamRuleListVo
* @description TODO
* @date 2019/9/9
**/
@Data
@ApiModel(value = "GetAccountListVO", description = "GetAccountListVO")
public class GetAccountListVO {
private Boolean isGetAccount;
private List<ReportAccountRespVOVo> accountVOList;
}
package com.yizhi.custom.api.vo.custom;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "个人经验明细", description = "个人经验明细")
public class MyExperienceEventsVo {
@ApiModelProperty("经验名称")
private String eventName;
@ApiModelProperty("经验编码")
private String eventCode;
@ApiModelProperty("经验")
private Integer experience;
}
package com.yizhi.custom.api.vo.custom;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel(value = "个人经验等级", description = "个人经验等级")
public class MyExperienceLevelVo {
@ApiModelProperty("用户名")
private String name;
@ApiModelProperty("姓名")
private String fullName;
@ApiModelProperty("性别")
private String sex;
@ApiModelProperty("总经验")
private Integer experienceTotal;
@ApiModelProperty("等级名称")
private String levelName;
@ApiModelProperty("等级编码")
private String levelCode;
@ApiModelProperty("排名")
private String ranking;
@ApiModelProperty("当前时间")
String currentTime;
@ApiModelProperty("个人经验明细列表")
List<MyExperienceEventsVo> eventClassifys;
}
package com.yizhi.custom.api.vo.custom;
import java.util.Date;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "我的经验池", description = "我的经验池")
public class MyExperiencePoolVo {
@ApiModelProperty("是否首次登录,1为首次登陆,0为非首次登陆")
private Integer firstLogin;
@ApiModelProperty("系统当前年月日")
private Date nowTime;
@ApiModelProperty("步数")
private Integer step;
@ApiModelProperty("编号(年月第几位)")
private String accountCode;
@ApiModelProperty("座右铭")
private String motto;
}
package com.yizhi.custom.api.vo.custom;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "我的积分排行榜", description = "我的积分排行榜")
public class MyExperienceRankingVo {
@ApiModelProperty("用户名")
private String name;
@ApiModelProperty("姓名")
private String fullName;
@ApiModelProperty("性别")
private String sex;
@ApiModelProperty("用户Id")
private Long accountId;
@ApiModelProperty("排名")
private Integer ranking;
@ApiModelProperty("等级名称")
private String levelName;
@ApiModelProperty("等级编码")
private String levelCode;
@ApiModelProperty("部门名称(全部)")
private String orgName;
@ApiModelProperty("经验")
private Integer experience;
}
package com.yizhi.custom.api.vo.custom;
import com.yizhi.custom.api.vo.domain.ProjectActivityExperienceVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author Ding
* @className PoolSaveReturnVO
* @description TODO
* @date 2018/11/14
**/
@Data
@ApiModel(value = "经验池保存返回类", description = "经验池保存返回类")
public class PoolSaveReturnVO {
@ApiModelProperty("经验池ID")
private Long poolId;
@ApiModelProperty("关联项目经验列表")
private List<ProjectActivityExperienceVo> activityExperienceList;
}
package com.yizhi.custom.api.vo.custom;
import com.yizhi.custom.api.vo.domain.ProductVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author Ding
* @className ExperiencePoolRuleVo
* @description 商品VO类
* @date 2019/09/19
**/
@Data
@ApiModel(value="商品前端显示类" ,description ="商品前端显示类")
public class ProductVO {
@ApiModelProperty(value = "用户总积分")
private Integer totalPoint;
@ApiModelProperty(value = "用户总经验")
private Long totalExperience;
@ApiModelProperty(value = "端口列表")
private List<ProductVo> products;
}
package com.yizhi.custom.api.vo.custom;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @Author: XieHaijun
* @Description:
* @Date: Created in 17:11 2018/7/16
* @Modified By
*/
@Api(tags = "ReportAccountRespVOVo", description = "用户信息返回对象")
@Data
public class ReportAccountRespVOVo {
@ApiModelProperty(value = "用户id")
private Long userId;
@ApiModelProperty(value = "头像")
private String headPortrait;
@ApiModelProperty(value = "用户名")
private String userName;
@ApiModelProperty(value = "用户姓名")
private String userFullName;
@ApiModelProperty(value = "部门id")
private Long orgId;
@ApiModelProperty(value = "部门名称")
private String orgName;
@ApiModelProperty(value = "部门code")
private String orgCode;
@ApiModelProperty(value = "用户状态:1:启用,0:停用")
private Integer status;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "账户邮箱")
private String email;
@ApiModelProperty(value = "企业id")
private Long companyId;
/* @ApiModelProperty(value = "部门编码")
private String orgCode;*/
/* @ApiModelProperty(value = "部门人数")
private Long orgAccountNum;*/
@ApiModelProperty(value = "父节组织名称")
private List<String> parentOrgNames;
@ApiModelProperty(value = "工号")
private String workNum;
private String mobile;
@ApiModelProperty(value = "职位")
private String position;
}
package com.yizhi.custom.api.vo.custom;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
/**
* 2019/09/19
* @author wangfeida
*
*/
@Data
public class VisibleRangeExportVo {
@ApiModelProperty(name="bizId",value="具体业务id")
private Long bizId;
@ApiModelProperty(name="bizName",value="具体业务名字")
private String bizName;
@ApiModelProperty(name="个人ID集合",value="个人id集合")
private List<Long> accountIds;
@ApiModelProperty(name="组织ID集合",value="组织ID集合")
private List<Long> orgIds;
@ApiModelProperty(name="上下文对象",value="上下文对象")
private RequestContext context;
@ApiModelProperty(name="自定义项目增加字段map",value="自定义项目增加字段map")
private Map<Long, SortedMap<String, String>> map;
}
package com.yizhi.custom.api.vo.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 代码包管理主体
* </p>
*
* @author dingxiaowei
* @since 2018-11-01
*/
@Data
@ApiModel(value = "CodePackageManageVo", description = "")
public class CodePackageManageVo {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID")
private Long id;
@ApiModelProperty(value = "代码包名称")
private String codePackageName;
@ApiModelProperty(value = "导入时间")
private Date importTime;
@ApiModelProperty(value = "访问路径")
private String url;
@ApiModelProperty(value = "状态 0 删除 1 有效")
private Integer state;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "创建人ID")
private Long createById;
@ApiModelProperty(value = "创建人名字")
private String createByName;
@ApiModelProperty(value = "修改时间")
private Date updateTime;
@ApiModelProperty(value = "修改人ID")
private Long updateById;
@ApiModelProperty(value = "修改人名字")
private String updateByName;
@ApiModelProperty(value = "企业_ID")
private Long companyId;
@ApiModelProperty(value = "部门_ID")
private Long orgId;
@ApiModelProperty(value = "站点_ID")
private Long siteId;
}
package com.yizhi.custom.api.vo.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 经验池可见范围主体
* </p>
*
* @author dingxiaowei
* @since 2018-11-01
*/
@Data
@ApiModel(value = "ExperiencePoolAuthorizeVo", description = "")
public class ExperiencePoolAuthorizeVo {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID")
private Long id;
@ApiModelProperty(value = "经验池ID") private Long experienceId;
@ApiModelProperty(value = "1 用户 2 部门")
private Integer type;
@ApiModelProperty(value = "批次号")
private String batchNo;
@ApiModelProperty("组别")
private String group;
@ApiModelProperty(value = "范围ID")
private Long relationId;
@ApiModelProperty(value = "学员名字或部门名称")
private String name;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "创建人ID")
private Long createById;
@ApiModelProperty(value = "创建人名字")
private String createByName;
@ApiModelProperty(value = "修改时间")
private Date updateTime;
@ApiModelProperty(value = "修改人ID")
private Long updateById;
@ApiModelProperty(value = "修改人名字")
private String updateByName;
@ApiModelProperty("备注")
private String note;
}
package com.yizhi.custom.api.vo.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 经验池等级主体
* </p>
*
* @author dingxiaowei
* @since 2018-11-01
*/
@Data
@ApiModel(value = "ExperiencePoolLevelVo", description = "")
public class ExperiencePoolLevelVo {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID")
private Long id;
@ApiModelProperty(value = "经验池ID")
private Long experiencePoolId;
@ApiModelProperty(value = "等级编码")
private String levelNo;
@ApiModelProperty(value = "等级名称")
private String levelName;
@ApiModelProperty(value = "等级对应经验最小值")
private Long minLevelExperience;
@ApiModelProperty(value = "状态")
private Integer state;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "创建人ID")
private Long createById;
@ApiModelProperty(value = "创建人名字")
private String createByName;
@ApiModelProperty(value = "修改时间")
private Date updateTime;
@ApiModelProperty(value = "修改人ID")
private Long updateById;
@ApiModelProperty(value = "修改人名字")
private String updateByName;
}
package com.yizhi.custom.api.vo.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 经验池关联项目主体
* </p>
*
* @author dingxiaowei
* @since 2018-11-01
*/
@Data
@ApiModel(value = "ExperiencePoolProjectVo", description = "")
public class ExperiencePoolProjectVo {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID")
private Long id;
@ApiModelProperty(value = "经验池ID")
private Long experienceId;
@ApiModelProperty(value = "项目类型1 课程 2 考试 3 调研 4 投票")
private Integer type;
@ApiModelProperty(value = "项目编码")
private String bizNo;
@ApiModelProperty(value = "项目ID")
private Long bizId;
@ApiModelProperty(value = "项目名称")
private String bizName;
@ApiModelProperty(value = "状态 0 删除 1有效 ")
private Integer state;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "创建人ID")
private Long createById;
@ApiModelProperty(value = "创建人名字")
private String createByName;
@ApiModelProperty(value = "修改时间")
private Date updateTime;
@ApiModelProperty(value = "修改人ID")
private Long updateById;
@ApiModelProperty(value = "修改人名字")
private String updateByName;
}
package com.yizhi.custom.api.vo.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 经验池主体
* </p>
*
* @author dingxiaowei
* @since 2018-11-02
*/
@Data
@ApiModel(value = "ExperiencePoolVo", description = "自定义项目经验池主体表")
public class ExperiencePoolVo {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID")
private Long id;
@ApiModelProperty(value = "经验池编码")
private String experiencePoolNo;
@ApiModelProperty(value = "经验池名称")
private String experiencePoolName;
@ApiModelProperty(value = "0删除 1 草稿 2上架")
private Integer state;
@ApiModelProperty(value = " 1手工输入 2外部导入")
private Integer experiencePoolType;
@ApiModelProperty(value = "可见范围:1 全平台可见 2 指定学员")
private Integer visibleRange;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "创建人ID")
private Long createById;
@ApiModelProperty(value = "创建人名字")
private String createByName;
@ApiModelProperty(value = "修改时间")
private Date updateTime;
@ApiModelProperty(value = "修改人ID")
private Long updateById;
@ApiModelProperty(value = "修改人名字")
private String updateByName;
@ApiModelProperty(value = "企业_ID")
private Long companyId;
@ApiModelProperty(value = "部门_ID")
private Long orgId;
@ApiModelProperty(value = "站点_ID")
private Long siteId;
}
package com.yizhi.custom.api.vo.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 经验发放记录表
* </p>
*
* @author dingxiaowei123
* @since 2019-01-02
*/
@Data
@ApiModel(value = "ExperienceRecordVo", description = "经验发放记录表")
public class ExperienceRecordVo {
private static final long serialVersionUID = 1L;
private Long id;
@ApiModelProperty(value = "经验池id")
private Long experiencePoolId;
@ApiModelProperty(value = "学生id")
private Long accountId;
@ApiModelProperty(value = "活动类型")
private Integer activityType;
@ApiModelProperty(value = "活动id(考试,课程,调研,投票…..)")
private Long activityId;
@ApiModelProperty(value = "活动名称")
private String activityName;
@ApiModelProperty(value = "产生经验")
private Integer experience;
private Date createTime;
private Long createById;
private String createByName;
private Date updateTime;
private Long updateById;
private String updateByName;
}
package com.yizhi.custom.api.vo.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author dingxiaowei123
* @since 2019-09-19
*/
@Data
@ApiModel(value = "ProductVo", description = "")
public class ProductVo {
private static final long serialVersionUID = 1L;
private Long id;
@ApiModelProperty(value = "商品名称")
private String productName;
@ApiModelProperty(value = "商品单价")
private Long price;
@ApiModelProperty(value = "商品总数")
private Integer amount;
@ApiModelProperty(value = "商品剩余数量")
private Integer remainingAmount;
private Date createTime;
@ApiModelProperty(value = "企业_ID")
private Long companyId;
@ApiModelProperty(value = "部门_ID")
private Long orgId;
@ApiModelProperty(value = "站点_ID")
private Long siteId;
@ApiModelProperty(value = "状态, 0:删除 1:有效")
private Integer state;
}
package com.yizhi.custom.api.vo.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 经验池关联项目活动经验值设计主体
* </p>
*
* @author dingxiaowei
* @since 2018-11-01
*/
@Data
@ApiModel(value = "ProjectActivityExperienceSetVo", description = "")
public class ProjectActivityExperienceSetVo {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "项目关联经验值表_ID")
private Long projectActivityExperienceId;
@ApiModelProperty(value = "经验设置类型(1按成绩范围设置,2按成绩值设置)")
private Integer setType;
@ApiModelProperty(value = "经验规则对应最小分数")
private Integer minScore;
@ApiModelProperty(value = "经验值")
private Long experience;
@ApiModelProperty(value = "按成绩值设置倍数")
private Integer times;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "创建人ID")
private Long createById;
@ApiModelProperty(value = "创建人名字")
private String createByName;
@ApiModelProperty(value = "修改时间")
private Date updateTime;
@ApiModelProperty(value = "修改人ID")
private Long updateById;
@ApiModelProperty(value = "修改人名字")
private String updateByName;
}
package com.yizhi.custom.api.vo.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 经验池关联项目活动经验值主体
* </p>
*
* @author dingxiaowei
* @since 2018-11-01
*/
@Data
@ApiModel(value = "ProjectActivityExperienceVo", description = "")
public class ProjectActivityExperienceVo {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID ")
private Long id;
@ApiModelProperty(value = "项目关联活动ID")
private Long experiencePoolProjectId;
@ApiModelProperty(value = "项目类型1 课程 2 考试 3 调研 4 投票 5 外部经验")
private Integer type;
@ApiModelProperty(value = "活动名称")
private String activityName;
@ApiModelProperty(value = "活动经验来源 0 无其他条件 1 按成绩设置")
private Integer activityExperienceSource;
@ApiModelProperty(value = "活动经验值(分值,活动经验值来源为0时取该值,1从经验值条件表中取)")
private Long activityExperience;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "创建人ID")
private Long createById;
@ApiModelProperty(value = "创建人名字")
private String createByName;
@ApiModelProperty(value = "修改时间")
private Date updateTime;
@ApiModelProperty(value = "修改人ID")
private Long updateById;
@ApiModelProperty(value = "修改人名字")
private String updateByName;
@ApiModelProperty(value = "是否有经验")
private Integer evaluate;
}
package com.yizhi.custom.api.vo.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 学员经验池
* </p>
*
* @author dingxiaowei123
* @since 2018-11-12
*/
@Data
@ApiModel(value = "StudentExperiencePoolVo", description = "学员经验池")
public class StudentExperiencePoolVo {
@SuppressWarnings("unused")
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID ")
private Long id;
@ApiModelProperty(value = "经验池ID")
private Long experiencePoolId;
@ApiModelProperty(value = "用户ID")
private Long accountId;
@ApiModelProperty(value = "批次号")
private String batchNo;
@ApiModelProperty(value = "登录序号(第几个登录的)")
private Integer num;
@ApiModelProperty(value = "步数")
private Integer step;
@ApiModelProperty(value = "座右铭")
private String motto;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "创建人ID")
private Long createById;
@ApiModelProperty(value = "创建人名字")
private String createByName;
@ApiModelProperty(value = "修改时间")
private Date updateTime;
@ApiModelProperty(value = "修改人ID")
private Long updateById;
@ApiModelProperty(value = "修改人名字")
private String updateByName;
}
package com.yizhi.custom.api.vo.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 项目关联活动经验值表
* </p>
*
* @author dingxiaowei123
* @since 2018-11-12
*/
@Data
@ApiModel(value = "StudentExperienceVo", description = "项目关联活动经验值表")
public class StudentExperienceVo {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID ")
private Long id;
@ApiModelProperty(value = "经验池ID")
private Long experiencePoolId;
@ApiModelProperty(value = "用户ID ")
private Long accountId;
@ApiModelProperty(value = "用户名")
private String accountName;
@ApiModelProperty(value = "项目类型5 (外部导入)")
private Integer type;
private Long activityId;
private String activityName;
@ApiModelProperty(value = "活动经验值")
private Long experience;
@ApiModelProperty(value = "企业id")
private Long companyId;
@ApiModelProperty(value = "站点id")
private Long siteId;
@ApiModelProperty(value = "部门id")
private Long orgId;
@ApiModelProperty(value = "部门名称")
private String orgName;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "创建人ID")
private Long createById;
@ApiModelProperty(value = "创建人名字")
private String createByName;
@ApiModelProperty(value = "修改时间")
private Date updateTime;
@ApiModelProperty(value = "修改人ID")
private Long updateById;
@ApiModelProperty(value = "修改人名字")
private String updateByName;
@ApiModelProperty(value = "是否删除 0:删除, 1:未删除")
private Integer state;
}
<?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>
<artifactId>customproject</artifactId>
<groupId>com.yizhi</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.yizhi</groupId>
<artifactId>cloud-customproject</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-training-project-api</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-common-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-util</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- 积分api 依赖 -->
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-point-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- 课程api 依赖 -->
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-course-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- 签到api 依赖 -->
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-sign-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- 考试api 依赖 -->
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-exam-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!--作业api 依赖 -->
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-assignment-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!--添加system依赖-->
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-system-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>org.redisson</groupId>
<artifactId>redisson</artifactId>
<version>3.5.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- deploy 时跳过该模块 -->
<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.mybatis.spring.annotation.MapperScan;
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;
/**
* @author Ding
* @className CustomProjectApplication
* @description TODO
* @date 2018/11/12
**/
@SpringBootApplication
@EnableDiscoveryClient
@EnableCaching
@EnableFeignClients(basePackages = {"com.yizhi"})
@ComponentScan(basePackages = {"com.yizhi"})
public class CustomProjectApplication {
public static void main(String[] args) {
SpringApplication.run(CustomProjectApplication.class, args);
}
}
package com.yizhi.application.asynchronousTask;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.application.domain.ExperiencePool;
import com.yizhi.application.service.IExperiencePoolService;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.core.application.file.constant.FileConstant;
import com.yizhi.custom.api.vo.custom.ExperiencePoolReportExportVo;
import com.yizhi.core.application.context.TaskContext;
import com.yizhi.core.application.file.task.AbstractDefaultTask;
import com.yizhi.core.application.file.util.OssUpload;
import com.yizhi.system.application.system.remote.OrganizationClient;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Ding
* @className ViewAccountDetailsExport
* @description 经验池报表查看个人经验明细下载
* @date 2019/9/5
**/
@Component("viewAccountDetailsExport1")
public class ViewAccountDetailsExport extends AbstractDefaultTask<Map, Map<String, Object>> {
private static final Logger LOGGER = LoggerFactory.getLogger(ViewAccountDetailsExport.class);
@Autowired
private IExperiencePoolService poolService;
@Autowired
private OrganizationClient organizationClient;
@Override
protected Map execute(Map<String, Object> map) {
//从map中取信息
Long taskId = (Long) map.get("taskId");
String serialNo = (String) map.get("serialNo");
String taskName = (String) map.get("taskName");
Long poolId = (Long) map.get("poolId");
Long accountId = (Long) map.get("accountId");
Integer state = (Integer) map.get("state");
RequestContext res = (RequestContext) map.get("res");
//开始异步任务
TaskContext taskContext = new TaskContext(taskId, serialNo, taskName,
res.getAccountId(), new Date(), res.getSiteId(), res.getCompanyId());
working(taskContext);
Page<ExperiencePoolReportExportVo> page = null;
List<ExperiencePoolReportExportVo> list = null;
//获取导出数据
try {
page = poolService.viewAccountDetails(poolId, accountId, state, 1, Integer.MAX_VALUE);
if (null != page) {
list = page.getRecords();
}
if (CollectionUtils.isEmpty(list)) {
success(taskContext, "未找到数据", "");
}
} catch (Exception e) {
LOGGER.error("获取数据过程中出现错误", e);
fail(taskContext, "获取数据过程中出现错误");
}
//生成excel,上传阿里云返回url
try {
//获取经验池名称
ExperiencePool experiencePool = poolService.selectById(poolId);
String poolName = experiencePool.getExperiencePoolName();
String accountName = "";
if (list != null && list.size()>0){
accountName = list.get(0).getAccountName();
}
//创建excel文件
XSSFWorkbook wb = new XSSFWorkbook();
//创建报表页
XSSFSheet sheet = wb.createSheet("个人经验值变更明细下载");
//创建表头
XSSFRow row = sheet.createRow(0);
//设置格式(水平垂直居中,加粗,字体大小14号)
XSSFCellStyle style = wb.createCellStyle();
style.setAlignment(HorizontalAlignment.CENTER);
XSSFFont font = wb.createFont();
font.setBold(true);
font.setFontHeightInPoints((short) 14);
style.setFont(font);
CellRangeAddress cra = new CellRangeAddress(0, 0, 0, 6);
//表头合并单元格
sheet.addMergedRegion(cra);
XSSFCell cell = row.createCell(0);
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
//填写表头名
cell.setCellValue("用户" + accountName + "个人经验值变更明细");
//表头居中
cell.setCellStyle(style);
cra = new CellRangeAddress(1, 1, 0, 6);
//第二行合并单元格合并单元格
sheet.addMergedRegion(cra);
row = sheet.createRow(1);
row.createCell(0).setCellValue("经验池: " + poolName);
row = sheet.createRow(2);
//重新设置格式(只加粗)
style = wb.createCellStyle();
font = wb.createFont();
font.setBold(true);
style.setFont(font);
cell = row.createCell(0);
cell.setCellStyle(style);
cell.setCellValue("用户名");
cell = row.createCell(1);
cell.setCellStyle(style);
cell.setCellValue("姓名");
cell = row.createCell(2);
cell.setCellStyle(style);
cell.setCellValue("所在部门");
cell = row.createCell(3);
cell.setCellStyle(style);
cell.setCellValue("变动值");
cell = row.createCell(4);
cell.setCellStyle(style);
cell.setCellValue("时间");
cell = row.createCell(5);
cell.setCellStyle(style);
cell.setCellValue("剩余经验值");
cell = row.createCell(6);
cell.setCellStyle(style);
cell.setCellValue("明细");
cell = row.createCell(7);
cell.setCellStyle(style);
cell.setCellValue("所在组织架构");
Map<Long, String> orgNamesMap = new HashMap<>(16);
//组装数据
if (CollectionUtils.isNotEmpty(list)) {
for (int i = 0; i < list.size(); i++) {
ExperiencePoolReportExportVo listVO = list.get(i);
row = sheet.createRow(i + 3);
row.createCell(0).setCellValue(listVO.getAccountName());
row.createCell(1).setCellValue(listVO.getAccountFullName());
row.createCell(2).setCellValue(listVO.getOrgName());
row.createCell(3).setCellValue(listVO.getExperience());
row.createCell(5).setCellValue(listVO.getExperienceTotal() == null ? "--" : listVO.getExperienceTotal().toString());
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/M/dd HH:mm:ss");
row.createCell(4).setCellValue(sdf1.format(listVO.getCreateTime()));
if (listVO.getType() == 10) {
row.createCell(6).setCellValue("兑换" + listVO.getActivityName() + "消耗" + (0 - listVO.getExperience()) + "经验值");
} else {
row.createCell(6).setCellValue(listVO.getDescription() == null ? "--" : listVO.getDescription());
}
if (null != orgNamesMap.get(listVO.getOrgId())) {
row.createCell(7).setCellValue(orgNamesMap.get(listVO.getOrgId()));
} else {
String orgNames = "";
List<String> orgNamesList = organizationClient.getChiefOrgNames(listVO.getOrgId(), res.getCompanyId());
if (CollectionUtils.isNotEmpty(orgNamesList)) {
for (String s : orgNamesList) {
if (StringUtils.isNotBlank(orgNames)) {
orgNames = orgNames + "/" + s;
} else {
orgNames = orgNames + s;
}
}
row.createCell(7).setCellValue(orgNames);
orgNamesMap.put(listVO.getOrgId(), orgNames);
}else {
row.createCell(7).setCellValue("--");
orgNamesMap.put(listVO.getOrgId(), "--");
}
}
}
}
String fileName = accountName + "个人经验值变更明细" + sdf.format(new Date()) + ".xlsx";
// String requestPath = "/Users/dingxiaowei/aaa";
String requestPath = FileConstant.SAVE_PATH;
File fileDir = new File(requestPath);
if (!fileDir.exists()) {
fileDir.mkdir();
}
String path = requestPath + "/" + fileName;
FileOutputStream os = null;
File file = null;
try {
os = new FileOutputStream(path);
wb.write(os);
//阿里云返回url
String uploadUrl = OssUpload.upload(path, fileName);
file = new File(path);
success(taskContext, "成功导出" + list.size() + "条记录", uploadUrl);
} catch (Exception e2) {
e2.printStackTrace();
fail(taskContext, "个人经验值变更明细下载写入过程中发生错误");
LOGGER.error("个人经验值变更明细下载写入过程中发生错误");
} finally {
if (os != null) {
os.close();
}
if (wb != null) {
wb.close();
}
if (file != null) {
file.delete();
}
}
} catch (Exception e) {
e.printStackTrace();
fail(taskContext, "个人经验值变更明细下载发生错误");
LOGGER.error("个人经验值变更明细下载发生错误,请查看日志");
}
return null;
}
}
package com.yizhi.application.asynchronousTask;
import com.yizhi.application.domain.ExperiencePool;
import com.yizhi.application.service.IExperiencePoolService;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.core.application.context.TaskContext;
import com.yizhi.custom.api.vo.custom.ExperiencePoolReportExportVo;
import com.yizhi.core.application.file.constant.FileConstant;
import com.yizhi.core.application.file.task.AbstractDefaultTask;
import com.yizhi.core.application.file.util.OssUpload;
import org.apache.commons.collections.CollectionUtils;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @author Ding
* @className ViewAllDetailsExport
* @description 经验池报表导出所有人经验变更明细
* @date 2019/9/5
**/
@Component
public class ViewAllDetailsExport extends AbstractDefaultTask<Map, Map<String, Object>> {
private static final Logger LOGGER = LoggerFactory.getLogger(ViewAllDetailsExport.class);
@Autowired
private IExperiencePoolService poolService;
@Override
protected Map execute(Map<String, Object> map) {
//从map中取信息
Long taskId = (Long) map.get("taskId");
String serialNo = (String) map.get("serialNo");
String taskName = (String) map.get("taskName");
Long poolId = (Long) map.get("poolId");
RequestContext res = (RequestContext) map.get("res");
//开始异步任务
TaskContext taskContext = new TaskContext(taskId, serialNo, taskName,
res.getAccountId(), new Date(), res.getSiteId(), res.getCompanyId());
working(taskContext);
List<ExperiencePoolReportExportVo> list = null;
//获取导出数据
try {
list = poolService.viewAllDetails(poolId, null, null, null, null, null, res);
if (CollectionUtils.isEmpty(list)) {
success(taskContext, "未找到数据", "");
}
} catch (Exception e) {
LOGGER.error("获取数据过程中出现错误", e);
fail(taskContext, "获取数据过程中出现错误");
}
//生成excel,上传阿里云返回url
try {
//获取经验池名称
ExperiencePool experiencePool = poolService.selectById(poolId);
String poolName = experiencePool.getExperiencePoolName();
//创建excel文件
XSSFWorkbook wb = new XSSFWorkbook();
//创建报表页
XSSFSheet sheet = wb.createSheet("所有人经验值变更明细下载");
//创建表头
XSSFRow row = sheet.createRow(0);
//设置格式(水平垂直居中,加粗,字体大小14号)
XSSFCellStyle style = wb.createCellStyle();
style.setAlignment(HorizontalAlignment.CENTER);
XSSFFont font = wb.createFont();
font.setBold(true);
font.setFontHeightInPoints((short) 14);
style.setFont(font);
CellRangeAddress cra = new CellRangeAddress(0, 0, 0, 5);
//表头合并单元格
sheet.addMergedRegion(cra);
XSSFCell cell = row.createCell(0);
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
//填写表头名
cell.setCellValue("经验值变更明细统计");
//表头居中
cell.setCellStyle(style);
cra = new CellRangeAddress(1, 1, 0, 5);
//第二行合并单元格合并单元格
sheet.addMergedRegion(cra);
row = sheet.createRow(1);
row.createCell(0).setCellValue("经验池: " + poolName);
row = sheet.createRow(2);
//重新设置格式(只加粗)
style = wb.createCellStyle();
font = wb.createFont();
font.setBold(true);
style.setFont(font);
cell = row.createCell(0);
cell.setCellStyle(style);
cell.setCellValue("用户名");
cell = row.createCell(1);
cell.setCellStyle(style);
cell.setCellValue("姓名");
cell = row.createCell(2);
cell.setCellStyle(style);
cell.setCellValue("所在部门");
cell = row.createCell(3);
cell.setCellStyle(style);
cell.setCellValue("变动值");
cell = row.createCell(4);
cell.setCellStyle(style);
cell.setCellValue("时间");
cell = row.createCell(5);
cell.setCellStyle(style);
cell.setCellValue("明细");
cell = row.createCell(6);
cell.setCellStyle(style);
cell.setCellValue("所在组织架构");
//组装数据
if (CollectionUtils.isNotEmpty(list)) {
for (int i = 0; i < list.size(); i++) {
ExperiencePoolReportExportVo listVO = list.get(i);
row = sheet.createRow(i + 3);
row.createCell(0).setCellValue(listVO.getAccountName());
row.createCell(1).setCellValue(listVO.getAccountFullName()==null?"--":listVO.getAccountFullName());
row.createCell(2).setCellValue(listVO.getOrgName()==null?"--":listVO.getOrgName());
row.createCell(3).setCellValue(listVO.getExperience());
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/M/dd HH:mm:ss");
row.createCell(4).setCellValue(sdf1.format(listVO.getCreateTime()));
row.createCell(5).setCellValue(listVO.getDescription() == null ? "--" : listVO.getDescription());
row.createCell(6).setCellValue(listVO.getOrgNames());
}
}
String fileName = "所有人经验值变更明细下载" + sdf.format(new Date()) + ".xlsx";
// String requestPath = "/Users/dingxiaowei/aaa";
String requestPath = FileConstant.SAVE_PATH;
File fileDir = new File(requestPath);
if (!fileDir.exists()) {
fileDir.mkdir();
}
String path = requestPath + "/" + fileName;
FileOutputStream os = null;
File file = null;
try {
os = new FileOutputStream(path);
wb.write(os);
//阿里云返回url
String uploadUrl = OssUpload.upload(path, fileName);
file = new File(path);
success(taskContext, "成功导出" + list.size() + "条记录", uploadUrl);
} catch (Exception e2) {
e2.printStackTrace();
fail(taskContext, "所有人经验值变更明细下载写入过程中发生错误");
LOGGER.error("所有人经验值变更明细下载写入过程中发生错误");
} finally {
if (os != null) {
os.close();
}
if (wb != null) {
wb.close();
}
if (file != null) {
file.delete();
}
}
} catch (Exception e) {
e.printStackTrace();
fail(taskContext, "所有人经验值变更明细下载发生错误");
LOGGER.error("所有人经验值变更明细下载发生错误,请查看日志");
}
return null;
}
}
package com.yizhi.application.asynchronousTask;
import com.yizhi.application.domain.ExperiencePool;
import com.yizhi.application.service.IExperiencePoolService;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.custom.api.vo.custom.ExperiencePoolReportExportVo;
import com.yizhi.core.application.context.TaskContext;
import com.yizhi.core.application.file.constant.FileConstant;
import com.yizhi.core.application.file.task.AbstractDefaultTask;
import com.yizhi.core.application.file.util.OssUpload;
import com.yizhi.system.application.system.remote.OrganizationClient;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Ding
* @className ViewStageDetailsExport
* @description 经验池报表导出阶段经验变更明细
* @date 2019/9/5
**/
@Component
public class ViewStageDetailsExport extends AbstractDefaultTask<Map, Map<String, Object>> {
private static final Logger LOGGER = LoggerFactory.getLogger(ViewStageDetailsExport.class);
@Autowired
private IExperiencePoolService poolService;
@Autowired
private OrganizationClient organizationClient;
@Override
protected Map execute(Map<String, Object> map) {
//从map中取信息
Long taskId = (Long) map.get("taskId");
String serialNo = (String) map.get("serialNo");
String taskName = (String) map.get("taskName");
Long poolId = (Long) map.get("poolId");
String startTime = (String) map.get("startTime");
String endTime = (String) map.get("endTime");
String orgName = (String) map.get("orgName");
String accountName = (String) map.get("accountName");
RequestContext res = (RequestContext) map.get("res");
//开始异步任务
TaskContext taskContext = new TaskContext(taskId, serialNo, taskName,
res.getAccountId(), new Date(), res.getSiteId(), res.getCompanyId());
working(taskContext);
List<ExperiencePoolReportExportVo> list = null;
//获取导出数据
try {
list = poolService.viewAllDetails(poolId, startTime, endTime, orgName, accountName, null, res);
if (CollectionUtils.isEmpty(list)) {
success(taskContext, "未找到数据", "");
}
} catch (Exception e) {
LOGGER.error("获取数据过程中出现错误", e);
fail(taskContext, "获取数据过程中出现错误");
}
//生成excel,上传阿里云返回url
try {
//获取经验池名称
ExperiencePool experiencePool = poolService.selectById(poolId);
String poolName = experiencePool.getExperiencePoolName();
//创建excel文件
XSSFWorkbook wb = new XSSFWorkbook();
//创建报表页
XSSFSheet sheet = wb.createSheet("阶段经验变更明细");
//创建表头
XSSFRow row = sheet.createRow(0);
//设置格式(水平垂直居中,加粗,字体大小14号)
XSSFCellStyle style = wb.createCellStyle();
style.setAlignment(HorizontalAlignment.CENTER);
XSSFFont font = wb.createFont();
font.setBold(true);
font.setFontHeightInPoints((short) 14);
style.setFont(font);
CellRangeAddress cra = new CellRangeAddress(0, 0, 0, 6);
//表头合并单元格
sheet.addMergedRegion(cra);
XSSFCell cell = row.createCell(0);
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
//填写表头名
cell.setCellValue("经验值变更明细统计");
//表头居中
cell.setCellStyle(style);
cra = new CellRangeAddress(1, 1, 0, 6);
//第二行合并单元格合并单元格
sheet.addMergedRegion(cra);
row = sheet.createRow(1);
row.createCell(0).setCellValue("经验池: " + poolName);
cra = new CellRangeAddress(2, 2, 0, 6);
//第三行合并单元格合并单元格
sheet.addMergedRegion(cra);
row = sheet.createRow(2);
row.createCell(0).setCellValue("统计周期: " + startTime + "~" + endTime);
row = sheet.createRow(3);
//重新设置格式(只加粗)
style = wb.createCellStyle();
font = wb.createFont();
font.setBold(true);
style.setFont(font);
cell = row.createCell(0);
cell.setCellStyle(style);
cell.setCellValue("用户名");
cell = row.createCell(1);
cell.setCellStyle(style);
cell.setCellValue("姓名");
cell = row.createCell(2);
cell.setCellStyle(style);
cell.setCellValue("所在部门");
cell = row.createCell(3);
cell.setCellStyle(style);
cell.setCellValue("变动值");
cell = row.createCell(4);
cell.setCellStyle(style);
cell.setCellValue("时间");
cell = row.createCell(5);
cell.setCellStyle(style);
cell.setCellValue("明细");
cell = row.createCell(6);
cell.setCellStyle(style);
cell.setCellValue("所在组织架构");
Map<Long, String> orgNamesMap = new HashMap<>(16);
//组装数据
if (CollectionUtils.isNotEmpty(list)) {
for (int i = 0; i < list.size(); i++) {
ExperiencePoolReportExportVo listVO = list.get(i);
row = sheet.createRow(i + 4);
row.createCell(0).setCellValue(listVO.getAccountName());
row.createCell(1).setCellValue(listVO.getAccountFullName()==null?"--":listVO.getAccountFullName());
row.createCell(2).setCellValue(listVO.getOrgName()==null?"--":listVO.getOrgName());
row.createCell(3).setCellValue(listVO.getExperience());
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/M/dd HH:mm:ss");
row.createCell(4).setCellValue(sdf1.format(listVO.getCreateTime()));
row.createCell(5).setCellValue(listVO.getDescription() == null ? "--" : listVO.getDescription());
if (null != orgNamesMap.get(listVO.getOrgId())) {
row.createCell(6).setCellValue(orgNamesMap.get(listVO.getOrgId()));
} else {
String orgNames = "";
List<String> orgNamesList = organizationClient.getChiefOrgNames(listVO.getOrgId(), res.getCompanyId());
if (CollectionUtils.isNotEmpty(orgNamesList)) {
for (String s : orgNamesList) {
if (StringUtils.isNotBlank(orgNames)) {
orgNames = orgNames + "/" + s;
} else {
orgNames = orgNames + s;
}
}
row.createCell(6).setCellValue(orgNames);
orgNamesMap.put(listVO.getOrgId(), orgNames);
}else {
row.createCell(6).setCellValue("--");
orgNamesMap.put(listVO.getOrgId(), "--");
}
}
}
}
String fileName = "阶段经验值变更明细下载" + sdf.format(new Date()) + ".xlsx";
// String requestPath = "/Users/dingxiaowei/aaa";
String requestPath = FileConstant.SAVE_PATH;
File fileDir = new File(requestPath);
if (!fileDir.exists()) {
fileDir.mkdir();
}
String path = requestPath + "/" + fileName;
FileOutputStream os = null;
File file = null;
try {
os = new FileOutputStream(path);
wb.write(os);
//阿里云返回url
String uploadUrl = OssUpload.upload(path, fileName);
file = new File(path);
success(taskContext, "成功导出" + list.size() + "条记录", uploadUrl);
} catch (Exception e2) {
e2.printStackTrace();
fail(taskContext, "阶段经验值变更明细下载写入过程中发生错误");
LOGGER.error("阶段经验值变更明细下载写入过程中发生错误");
} finally {
if (os != null) {
os.close();
}
if (wb != null) {
wb.close();
}
if (file != null) {
file.delete();
}
}
} catch (Exception e) {
e.printStackTrace();
fail(taskContext, "阶段经验值变更明细下载发生错误");
LOGGER.error("阶段经验值变更明细下载发生错误,请查看日志");
}
return null;
}
}
package com.yizhi.application.asynchronousTask;
import com.yizhi.application.domain.ExperiencePool;
import com.yizhi.application.service.IExperiencePoolService;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.custom.api.vo.custom.ExperiencePoolReportExportVo;
import com.yizhi.core.application.context.TaskContext;
import com.yizhi.core.application.file.constant.FileConstant;
import com.yizhi.core.application.file.task.AbstractDefaultTask;
import com.yizhi.core.application.file.util.OssUpload;
import com.yizhi.system.application.system.remote.OrganizationClient;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Ding
* @className ViewStagePurchaseDetailsExport
* @description 经验池报表导出阶段经验消费变更明细
* @date 2019/9/5
**/
@Component
public class ViewStagePurchaseDetailsExport extends AbstractDefaultTask<Map, Map<String, Object>> {
private static final Logger LOGGER = LoggerFactory.getLogger(ViewStagePurchaseDetailsExport.class);
@Autowired
private IExperiencePoolService poolService;
@Autowired
private OrganizationClient organizationClient;
@Override
protected Map execute(Map<String, Object> map) {
//从map中取信息
Long taskId = (Long) map.get("taskId");
String serialNo = (String) map.get("serialNo");
String taskName = (String) map.get("taskName");
Long poolId = (Long) map.get("poolId");
String startTime = (String) map.get("startTime");
String endTime = (String) map.get("endTime");
String orgName = (String) map.get("orgName");
String accountName = (String) map.get("accountName");
RequestContext res = (RequestContext) map.get("res");
//开始异步任务
TaskContext taskContext = new TaskContext(taskId, serialNo, taskName,
res.getAccountId(), new Date(), res.getSiteId(), res.getCompanyId());
working(taskContext);
List<ExperiencePoolReportExportVo> list = null;
//获取导出数据
try {
list = poolService.viewAllDetails(poolId, startTime, endTime, orgName, accountName, 2, res);
if (CollectionUtils.isEmpty(list)) {
success(taskContext, "未找到数据", "");
}
} catch (Exception e) {
LOGGER.error("获取数据过程中出现错误", e);
fail(taskContext, "获取数据过程中出现错误");
}
//生成excel,上传阿里云返回url
try {
//获取经验池名称
ExperiencePool experiencePool = poolService.selectById(poolId);
String poolName = experiencePool.getExperiencePoolName();
//创建excel文件
XSSFWorkbook wb = new XSSFWorkbook();
//创建报表页
XSSFSheet sheet = wb.createSheet("阶段经验值消耗明细下载");
//创建表头
XSSFRow row = sheet.createRow(0);
//设置格式(水平垂直居中,加粗,字体大小14号)
XSSFCellStyle style = wb.createCellStyle();
style.setAlignment(HorizontalAlignment.CENTER);
XSSFFont font = wb.createFont();
font.setBold(true);
font.setFontHeightInPoints((short) 14);
style.setFont(font);
CellRangeAddress cra = new CellRangeAddress(0, 0, 0, 5);
//表头合并单元格
sheet.addMergedRegion(cra);
XSSFCell cell = row.createCell(0);
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
//填写表头名
cell.setCellValue("经验值消耗明细统计");
//表头居中
cell.setCellStyle(style);
cra = new CellRangeAddress(1, 1, 0, 5);
//第二行合并单元格合并单元格
sheet.addMergedRegion(cra);
row = sheet.createRow(1);
row.createCell(0).setCellValue("经验池: " + poolName);
cra = new CellRangeAddress(2, 2, 0, 5);
//第三行合并单元格合并单元格
sheet.addMergedRegion(cra);
row = sheet.createRow(1);
row.createCell(0).setCellValue("统计周期: " + startTime + "~" + endTime);
row = sheet.createRow(3);
//重新设置格式(只加粗)
style = wb.createCellStyle();
font = wb.createFont();
font.setBold(true);
style.setFont(font);
cell = row.createCell(0);
cell.setCellStyle(style);
cell.setCellValue("用户名");
cell = row.createCell(1);
cell.setCellStyle(style);
cell.setCellValue("姓名");
cell = row.createCell(2);
cell.setCellStyle(style);
cell.setCellValue("所在部门");
cell = row.createCell(3);
cell.setCellStyle(style);
cell.setCellValue("变动值");
cell = row.createCell(4);
cell.setCellStyle(style);
cell.setCellValue("时间");
cell = row.createCell(5);
cell.setCellStyle(style);
cell.setCellValue("明细");
cell = row.createCell(6);
cell.setCellStyle(style);
cell.setCellValue("所在组织架构");
Map<Long,String> orgNamesMap = new HashMap<>(16);
//组装数据
if (CollectionUtils.isNotEmpty(list)) {
for (int i = 0; i < list.size(); i++) {
ExperiencePoolReportExportVo listVO = list.get(i);
row = sheet.createRow(i + 4);
row.createCell(0).setCellValue(listVO.getAccountName());
row.createCell(1).setCellValue(listVO.getAccountFullName() == null ? "--" : listVO.getAccountFullName());
row.createCell(2).setCellValue(listVO.getOrgName() == null ? "--" : listVO.getOrgName());
row.createCell(3).setCellValue(listVO.getExperience());
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/M/dd HH:mm:ss");
row.createCell(4).setCellValue(sdf1.format(listVO.getCreateTime()));
row.createCell(5).setCellValue(listVO.getDescription() == null ? "--" : listVO.getDescription());
if (null != orgNamesMap.get(listVO.getOrgId())) {
row.createCell(6).setCellValue(orgNamesMap.get(listVO.getOrgId()));
} else {
String orgNames = "";
List<String> orgNamesList = organizationClient.getChiefOrgNames(listVO.getOrgId(), res.getCompanyId());
if (CollectionUtils.isNotEmpty(orgNamesList)) {
for (String s : orgNamesList) {
if (StringUtils.isNotBlank(orgNames)) {
orgNames = orgNames + "/" + s;
} else {
orgNames = orgNames + s;
}
}
row.createCell(6).setCellValue(orgNames);
orgNamesMap.put(listVO.getOrgId(), orgNames);
}else {
row.createCell(6).setCellValue("--");
orgNamesMap.put(listVO.getOrgId(), "--");
}
}
}
}
String fileName = "阶段经验值消耗明细下载" + sdf.format(new Date()) + ".xlsx";
// String requestPath = "/Users/dingxiaowei/aaa";
String requestPath = FileConstant.SAVE_PATH;
File fileDir = new File(requestPath);
if (!fileDir.exists()) {
fileDir.mkdir();
}
String path = requestPath + "/" + fileName;
FileOutputStream os = null;
File file = null;
try {
os = new FileOutputStream(path);
wb.write(os);
//阿里云返回url
String uploadUrl = OssUpload.upload(path, fileName);
file = new File(path);
success(taskContext, "成功导出" + list.size() + "条记录", uploadUrl);
} catch (Exception e2) {
e2.printStackTrace();
fail(taskContext, "阶段经验值消耗明细下载写入过程中发生错误");
LOGGER.error("阶段经验值消耗明细下载写入过程中发生错误");
} finally {
if (os != null) {
os.close();
}
if (wb != null) {
wb.close();
}
if (file != null) {
file.delete();
}
}
} catch (Exception e) {
e.printStackTrace();
fail(taskContext, "阶段经验值消耗明细下载发生错误");
LOGGER.error("阶段经验值消耗明细下载发生错误,请查看日志");
}
return null;
}
}
package com.yizhi.application.constant;
/**
* @author Ding
* @className Constant
* @description TODO
* @date 2019/12/18
**/
public interface Constant {
public final static Integer COURSE_TRANINNING_TYPE = 0;
}
package com.yizhi.application.constant;
public enum PointEventEnum {
/**
* 课程
*/
POINTCOURSE("pointCourse"),
/**
* 考试
*/
POINTEXAM("pointExam"),
/**
* 调研
*/
POINTRESEARCH("pointResearch"),
/**
* 投票
*/
POINTVOTE("pointVote"),
/**
* 作业
*/
POINTASSIGNMENT("pointTassgnment"),
/**
* 测验
*/
POINTCOURSETEST("pointCourseTest"),
/**
* 线下课程
*/
POINTOFFLINECOURSE("pointOfflineCourse");
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.constant;
/**
* 经验池常量
*/
public interface PoolConstant {
public static final Integer COURSETYPE = 1;
public static final Integer EXAMTYPE = 2;
public static final Integer RESEARCHTYPE = 3;
public static final Integer VOTETYPE = 4;
public static final Integer ASSIGNMENTTYPE = 6;
}
package com.yizhi.application.controller;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.application.domain.CodePackageManage;
import com.yizhi.application.service.ICodePackageManageService;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.custom.api.feign.CodePackageManageClient;
import com.yizhi.custom.api.param.ExperiencePoolParam;
import com.yizhi.custom.api.vo.domain.CodePackageManageVo;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.util.application.zip.ZipUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author ding
* @since 2018-11-06
*/
@Component
@ConfigurationProperties(prefix = "bootstrap")
@RestController
@RequestMapping("/manage/codePackageManage")
public class CodePackageManageController implements CodePackageManageClient {
private static final Logger LOGGER = LoggerFactory.getLogger(CodePackageManageController.class);
@Value("${ACTIVE}")
private String active;
@Autowired
private IdGenerator idGenerator;
@Autowired
private ICodePackageManageService codePackageManageService;
@Override
@GetMapping("/list")
public Page<CodePackageManageVo> getCodePackageManageList(@RequestBody ExperiencePoolParam experiencePoolParam) {
Page<CodePackageManage> page = codePackageManageService.getCodePackageManageList(experiencePoolParam);
Page<CodePackageManageVo> pageVo=new Page<>(page.getCurrent(),page.getSize());
List<CodePackageManage> list=page.getRecords();
List<CodePackageManageVo> lists=new ArrayList<>();
if (!list.isEmpty()){
for (CodePackageManage c:list) {
CodePackageManageVo cc=new CodePackageManageVo();
BeanUtils.copyProperties(c,cc);
lists.add(cc);
}
}
pageVo.setRecords(lists);
return pageVo;
}
@Override
@GetMapping("/view")
public CodePackageManageVo viewCodePackageManage(Long CodePackageId) {
CodePackageManage c=codePackageManageService.selectById(CodePackageId);
CodePackageManageVo cv=new CodePackageManageVo();
BeanUtils.copyProperties(c,cv);
return cv;
}
@Override
@GetMapping("/delete")
public boolean deleteCodePackage(Long CodePackageId) {
return codePackageManageService.deleteById(CodePackageId);
}
@Override
@GetMapping("/getUrl")
public String getCodePackageUrl(Long CodePackageId) {
String url = null;
CodePackageManage codePackageManage = codePackageManageService.selectById(CodePackageId);
if (null != codePackageManage) {
url = codePackageManage.getUrl();
}
return url;
}
@Override
public String getQRCode(String url, Long CodePackageId) {
return null;
}
@Override
@GetMapping("/insert")
public CodePackageManageVo insertCodePackage(@RequestParam(value = "CodePackageId", required = false) Long CodePackageId,
@RequestParam(value = "CodePackageName", required = false) String CodePackageName,
@RequestParam(value = "url", required = false) String url) {
CodePackageManage codePackageManage = null;
URL resultUrl = null;
String viewUrl = null;
HttpURLConnection connection = null;
InputStream inputStream = null;
long id = 0;
LOGGER.info("###########################ACTIVE:" + active);
try {
//解析url
String fileName = url.substring(url.lastIndexOf("/") + 1);
String ossUrlPrefix = url.substring(0, url.lastIndexOf("/") + 1);
String name = fileName.substring(0, fileName.lastIndexOf("."));
url = ossUrlPrefix + URLEncoder.encode(fileName, "utf-8");
resultUrl = new URL(url);
connection = (HttpURLConnection) resultUrl.openConnection();
//防止屏蔽程序抓取而返回403错误
connection.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
inputStream = connection.getInputStream();
String zipName = (CodePackageName + "代码包下载.zip");
//用id命名对应代码包的指定文件夹
if (null != CodePackageId) {
id = CodePackageId;
} else {
id = idGenerator.generate();
}
// String requestPath = "/Users/dingxiaowei/aaa/" + id;
String requestPath = "/home/" + id;
// String savePath = "/Users/dingxiaowei/" + id;
String savePath = "/CodePackage/" + id;
viewUrl = "http://customproject.kmelearning.com/" + id + "/index.html";
File fileDir = new File(requestPath);
File saveFileDir = new File(savePath);
if (saveFileDir.exists()) {
deleteDir(saveFileDir);
}
String path = requestPath + "/" + zipName;
if (!fileDir.exists()) {
fileDir.mkdir();
}
if (!saveFileDir.exists()) {
saveFileDir.mkdir();
}
BufferedInputStream in = null;
BufferedOutputStream out = null;
try {
in = new BufferedInputStream(inputStream);
out = new BufferedOutputStream(new FileOutputStream(path));
int len = -1;
byte[] b = new byte[1024];
while ((len = in.read(b)) != -1) {
out.write(b, 0, len);
}
in.close();
out.close();
//解压包
ZipUtil.unZip(path, requestPath);
//复制之前删除压缩包
File file = new File(path);
file.delete();
//将解压文件复制到代码包文件夹(由于代码包文件夹结构只支持单个文件操作,所以在其他包解压),
copyDir(requestPath, savePath);
//删除临时文件夹
boolean success = deleteDir(fileDir);
LOGGER.info("##########################deleteSuccess:" + success);
LOGGER.info("--------------------requestPath:" + requestPath);
} catch (Exception e1) {
LOGGER.error("解压代码包出错", e1);
} finally {
if (null != in) {
in.close();
}
if (null != out) {
out.close();
}
}
} catch (MalformedURLException e) {
LOGGER.error("创建ossurl 连接错误", e);
} catch (IOException e) {
LOGGER.error("创建ossurl 连接错误", e);
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-ddHH:mm:ss");
Date now = new Date();
RequestContext res = ContextHolder.get();
if (null != CodePackageId) {
codePackageManage = codePackageManageService.selectById(CodePackageId);
codePackageManage.setCodePackageName(CodePackageName);
codePackageManage.setImportTime(now);
codePackageManage.setUrl(viewUrl);
codePackageManage.setUpdateById(res.getAccountId());
codePackageManage.setUpdateByName(res.getAccountFullName());
codePackageManage.setUpdateTime(now);
codePackageManageService.updateById(codePackageManage);
} else {
codePackageManage = new CodePackageManage();
codePackageManage.setId(id);
codePackageManage.setCodePackageName(CodePackageName);
codePackageManage.setImportTime(now);
codePackageManage.setUrl(viewUrl);
codePackageManage.setCreateById(res.getAccountId());
codePackageManage.setCreateByName(res.getAccountFullName());
codePackageManage.setCreateTime(now);
codePackageManage.setCompanyId(res.getCompanyId());
codePackageManage.setSiteId(res.getSiteId());
codePackageManage.setOrgId(res.getOrgId());
codePackageManageService.insert(codePackageManage);
}
CodePackageManageVo cv=new CodePackageManageVo();
BeanUtils.copyProperties(codePackageManage,cv);
return cv;
}
//复制文件夹方法
public static void copyDir(String sourcePath, String newPath) throws IOException {
File file = new File(sourcePath);
String[] filePath = file.list();
if (!(new File(newPath)).exists()) {
(new File(newPath)).mkdir();
}
for (int i = 0; i < filePath.length; i++) {
if ((new File(sourcePath + file.separator + filePath[i])).isDirectory()) {
copyDir(sourcePath + file.separator + filePath[i], newPath + file.separator + filePath[i]);
}
if (new File(sourcePath + file.separator + filePath[i]).isFile()) {
copyFile(sourcePath + file.separator + filePath[i], newPath + file.separator + filePath[i]);
}
}
}
//复制文件方法
public static void copyFile(String oldPath, String newPath) throws IOException {
File oldFile = new File(oldPath);
File file = new File(newPath);
FileInputStream in = new FileInputStream(oldFile);
FileOutputStream out = new FileOutputStream(file);
;
byte[] buffer = new byte[2097152];
int readByte = 0;
while ((readByte = in.read(buffer)) != -1) {
out.write(buffer, 0, readByte);
}
in.close();
out.close();
}
//删除法目录方法
private static boolean deleteDir(File dir) {
if (dir.isDirectory()) {
String[] children = dir.list();
//递归删除目录中的子目录下
for (int i = 0; i < children.length; i++) {
boolean success = deleteDir(new File(dir, children[i]));
if (!success) {
return false;
}
}
}
// 目录此时为空,可以删除
return dir.delete();
}
}
package com.yizhi.application.controller;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.yizhi.application.domain.ExperiencePool;
import com.yizhi.application.domain.ExperiencePoolAuthorize;
import com.yizhi.application.service.IExperiencePoolAuthorizeService;
import com.yizhi.application.service.IExperiencePoolService;
import com.yizhi.custom.api.feign.ExperiencePoolAuthorizeClient;
import com.yizhi.custom.api.vo.custom.VisibleRangeExportVo;
import com.yizhi.custom.api.vo.domain.ExperiencePoolAuthorizeVo;
import com.yizhi.exam.application.vo.exam.VisibleRangeExport;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
* <p>
* 前端控制器
* </p>
*
* @author ding
* @since 2018-11-06
*/
@RestController
@RequestMapping("/manage/experiencePool")
public class ExperiencePoolAuthorizeController implements ExperiencePoolAuthorizeClient {
@Autowired
private IExperiencePoolAuthorizeService poolAuthorizeService;
@Autowired
private IExperiencePoolService poolService;
@Override
@PostMapping("/authorize/insert")
public boolean insertExperiencePoolAuthorize(@RequestBody List<ExperiencePoolAuthorizeVo> poolAuthorizeList) {
List<ExperiencePoolAuthorize> list = new ArrayList<>();
if (!poolAuthorizeList.isEmpty()){
for (ExperiencePoolAuthorizeVo ex:poolAuthorizeList) {
ExperiencePoolAuthorize ep=new ExperiencePoolAuthorize();
BeanUtils.copyProperties(ex,ep);
list.add(ep);
}
}
return poolAuthorizeService.insertAuthorizeList(list);
}
@Override
@GetMapping("/authorize/list")
public VisibleRangeExportVo listAuthorizes(Long experiencePoolId) {
VisibleRangeExport visibleRangeExport = new VisibleRangeExport();
List<Long> accountIds = new ArrayList<>();
List<Long> orgIds = new ArrayList<>();
Map<Long, SortedMap<String, String>> map = new HashMap<>();
SortedMap<String, String> sortedMap = null;
//查出可见范围列表
ExperiencePoolAuthorize poolAuthorize = new ExperiencePoolAuthorize();
poolAuthorize.setExperienceId(experiencePoolId);
EntityWrapper<ExperiencePoolAuthorize> entityWrapper = new EntityWrapper<>(poolAuthorize);
List<ExperiencePoolAuthorize> list = poolAuthorizeService.selectList(entityWrapper);
//查出经验池名称
ExperiencePool experiencePool = new ExperiencePool();
experiencePool = poolService.selectById(experiencePoolId);
//将导出所需要具体关键字装入实体类中
if (CollectionUtils.isNotEmpty(list)) {
for (ExperiencePoolAuthorize authorize : list) {
if (authorize.getType() == 1) {
sortedMap = new TreeMap<String, String>();
accountIds.add(authorize.getRelationId());
sortedMap.put("group", authorize.getGroup());
sortedMap.put("batchNo", authorize.getBatchNo());
sortedMap.put("note", authorize.getNote());
map.put(authorize.getRelationId(), sortedMap);
} else if (authorize.getType() == 2) {
orgIds.add(authorize.getRelationId());
}
}
visibleRangeExport.setAccountIds(accountIds);
visibleRangeExport.setOrgIds(orgIds);
visibleRangeExport.setMap(map);
if (null != experiencePool) {
visibleRangeExport.setBizName(experiencePool.getExperiencePoolName());
}
} else {
if (null != experiencePool) {
visibleRangeExport.setBizName(experiencePool.getExperiencePoolName());
}
}
VisibleRangeExportVo v=new VisibleRangeExportVo();
BeanUtils.copyProperties(visibleRangeExport,v);
return v;
}
@Override
@GetMapping("/authorize/view")
public List<Map<String, Object>> getListMap(Long experiencePoolId) {
return poolAuthorizeService.getListMap(experiencePoolId);
}
}
package com.yizhi.application.controller;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.application.domain.ExperiencePool;
import com.yizhi.application.service.IExperiencePoolService;
import com.yizhi.custom.api.feign.ExperiencePoolClient;
import com.yizhi.custom.api.param.ExperiencePoolParam;
import com.yizhi.custom.api.vo.custom.ExperiencePoolVoAutorizeAndProjectVO;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.yizhi.custom.api.vo.domain.ExperiencePoolVo;
import com.yizhi.custom.api.vo.domain.ProjectActivityExperienceVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* <p>
* 前端控制器
* </p>
*
* @author ding
* @since 2018-11-06
*/
@RestController
@RequestMapping("/manage/experiencePool")
public class ExperiencePoolController implements ExperiencePoolClient {
@Autowired
private IExperiencePoolService poolService;
@Override
@GetMapping("/list")
public Page<ExperiencePoolVo> getExperiencePoolList(@RequestBody ExperiencePoolParam param) {
Page<ExperiencePool> page = poolService.getExperiencePoolList(param);
Page<ExperiencePoolVo> pageVo=new Page<>(page.getCurrent(),page.getSize());
List<ExperiencePool> list=page.getRecords();
List<ExperiencePoolVo> lists=new ArrayList<>();
if (!list.isEmpty()){
for (ExperiencePool c:list) {
ExperiencePoolVo cc=new ExperiencePoolVo();
BeanUtils.copyProperties(c,cc);
lists.add(cc);
}
}
pageVo.setRecords(lists);
return pageVo;
}
@Override
@GetMapping("/view")
public ExperiencePoolVoAutorizeAndProjectVO getExperiencePoolView(Long poolId) {
return poolService.getExperiencePoolView(poolId);
}
@Override
@GetMapping("/delete")
public boolean deleteExperiencePool(Long poolId) {
return poolService.deleteById(poolId);
}
@Override
public boolean insertExperiencePoolList(@RequestBody List<ProjectActivityExperienceVo> projectActivityExperienceList) {
return false;
}
@Override
public List<ProjectActivityExperienceVo> getActivityExperienceList(Long poolId) {
return null;
}
@Override
@PostMapping("/save")
public Map<String, Object> insertExperiencePoolAuthorizeAndProject(
@RequestBody ExperiencePoolVoAutorizeAndProjectVO poolAutorizeAndProjectVO) {
return poolService.insertPoolAuthorizeAndProject(poolAutorizeAndProjectVO);
}
@Override
@GetMapping("/complete")
public boolean completeExperiencePool(Long poolId) {
return poolService.complete(poolId);
}
}
package com.yizhi.application.controller;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.yizhi.application.domain.ExperiencePoolLevel;
import com.yizhi.application.service.IExperiencePoolLevelService;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.custom.api.feign.ExperiencePoolLevelClient;
import com.yizhi.custom.api.vo.domain.ExperiencePoolLevelVo;
import com.yizhi.application.orm.id.IdGenerator;
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.RestController;
import java.util.*;
/**
* <p>
* 前端控制器
* </p>
*
* @author ding
* @since 2018-11-06
*/
@RestController
@RequestMapping("/manage/experiencePool")
public class ExperiencePoolLevelController implements ExperiencePoolLevelClient {
@Autowired
IdGenerator idGenerator;
@Autowired
private IExperiencePoolLevelService poolLevelService;
@Override
@GetMapping("/level/list")
public List<ExperiencePoolLevelVo> getExperiencePoolLevelList(Long poolId) {
ExperiencePoolLevel poolLevel = new ExperiencePoolLevel();
poolLevel.setExperiencePoolId(poolId);
EntityWrapper<ExperiencePoolLevel> entityWrapper = new EntityWrapper<>(poolLevel);
entityWrapper.orderBy("min_level_experience", true);
List<ExperiencePoolLevel> list = poolLevelService.selectList(entityWrapper);
List<ExperiencePoolLevelVo> levelVos=new ArrayList<>();
if (!list.isEmpty()) {
for (ExperiencePoolLevel pl : list) {
ExperiencePoolLevelVo pls=new ExperiencePoolLevelVo();
BeanUtils.copyProperties(pl,pls);
levelVos.add(pls);
}
}
return levelVos;
}
@Override
@GetMapping("/level/view")
public ExperiencePoolLevelVo getExperiencePoolLevelView(Long poolId) {
ExperiencePoolLevel pl=poolLevelService.selectById(poolId);
ExperiencePoolLevelVo pls=new ExperiencePoolLevelVo();
BeanUtils.copyProperties(pl,pls);
return pls;
}
@Override
@GetMapping("/level/delete")
public boolean deleteExperiencePoolLevel(Long poolLevelId) {
return poolLevelService.deleteById(poolLevelId);
}
@Override
@GetMapping("/level/insert")
public Map<String, Object> insertExperiencePoolLevel(@RequestBody ExperiencePoolLevelVo experiencePoolLevel) {
Map<String, Object> resultMap = new HashMap<>();
RequestContext res = ContextHolder.get();
ExperiencePoolLevel experiencePoolLevel1 = new ExperiencePoolLevel();
experiencePoolLevel1.setLevelNo(experiencePoolLevel.getLevelNo());
experiencePoolLevel1.setExperiencePoolId(experiencePoolLevel.getExperiencePoolId());
EntityWrapper<ExperiencePoolLevel> entityWrapper = new EntityWrapper<>(experiencePoolLevel1);
//如果是修改,重复编码和等级验证
if (null != experiencePoolLevel.getId()) {
if (!poolLevelService.selectById(experiencePoolLevel.getId()).getLevelNo().equals(experiencePoolLevel.getLevelNo())
&& CollectionUtils.isNotEmpty(poolLevelService.selectList(entityWrapper))) {
resultMap.put("isOk", false);
return resultMap;
} else {
experiencePoolLevel1 = new ExperiencePoolLevel();
experiencePoolLevel1.setMinLevelExperience(experiencePoolLevel.getMinLevelExperience());
experiencePoolLevel1.setExperiencePoolId(experiencePoolLevel.getExperiencePoolId());
entityWrapper = new EntityWrapper<>(experiencePoolLevel1);
if (!poolLevelService.selectById(experiencePoolLevel.getId()).getMinLevelExperience().equals(experiencePoolLevel.getMinLevelExperience())
&& CollectionUtils.isNotEmpty(poolLevelService.selectList(entityWrapper))) {
resultMap.put("isOk", false);
return resultMap;
} else {
resultMap.put("isOk", true);
}
}
} else {
//如果是新建,重复编码和等级验证
if (CollectionUtils.isNotEmpty(poolLevelService.selectList(entityWrapper))) {
resultMap.put("isOk", false);
return resultMap;
} else {
experiencePoolLevel1 = new ExperiencePoolLevel();
experiencePoolLevel1.setMinLevelExperience(experiencePoolLevel.getMinLevelExperience());
experiencePoolLevel1.setExperiencePoolId(experiencePoolLevel.getExperiencePoolId());
entityWrapper = new EntityWrapper<>(experiencePoolLevel1);
if (CollectionUtils.isNotEmpty(poolLevelService.selectList(entityWrapper))) {
resultMap.put("isOk", false);
return resultMap;
} else {
resultMap.put("isOk", true);
}
}
}
ExperiencePoolLevel plv=new ExperiencePoolLevel();
BeanUtils.copyProperties(experiencePoolLevel,plv);
//修改更新入库
if (null != plv.getId()) {
plv.setUpdateById(res.getAccountId());
plv.setUpdateByName(res.getAccountFullName());
plv.setUpdateTime(new Date());
poolLevelService.updateById(plv);
} else {
//新建入库
plv.setId(idGenerator.generate());
plv.setCreateTime(new Date());
plv.setCreateById(res.getAccountId());
plv.setCreateByName(res.getAccountFullName());
poolLevelService.insert(plv);
}
resultMap.put("experiencePoolLevel", experiencePoolLevel);
return resultMap;
}
}
package com.yizhi.application.controller;
import java.util.ArrayList;
import java.util.List;
import com.yizhi.application.domain.ExperiencePoolProject;
import com.yizhi.application.mapper.ExperiencePoolProjectMapper;
import com.yizhi.custom.api.vo.domain.ExperiencePoolProjectVo;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yizhi.custom.api.feign.ExperiencePoolProjectClient;
/**
* <p>
* 前端控制器
* </p>
*
* @author ding
* @since 2018-11-06
*/
@RestController
@RequestMapping("/manage/experiencePool")
public class ExperiencePoolProjectController implements ExperiencePoolProjectClient {
@Autowired
private ExperiencePoolProjectMapper experiencePoolProjectMapper;
@Override
@GetMapping("/project/view")
public List<ExperiencePoolProjectVo> getExperiencePoolProjectList(Long experiencePoolId) {
List<ExperiencePoolProject> list = experiencePoolProjectMapper.getExperiencePoolProjectList(experiencePoolId);
List<ExperiencePoolProjectVo> levelVos=new ArrayList<>();
if (!list.isEmpty()) {
for (ExperiencePoolProject pl : list) {
ExperiencePoolProjectVo pls=new ExperiencePoolProjectVo();
BeanUtils.copyProperties(pl,pls);
levelVos.add(pls);
}
}
return levelVos;
}
}
package com.yizhi.application.controller;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.application.service.IExperiencePoolService;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.custom.api.feign.ExperiencePoolReportClient;
import com.yizhi.custom.api.vo.custom.ExperiencePoolReportExportVo;
import com.yizhi.custom.api.vo.custom.ExperiencePoolReportVo;
import com.yizhi.application.asynchronousTask.ViewAccountDetailsExport;
import com.yizhi.application.asynchronousTask.ViewAllDetailsExport;
import com.yizhi.application.asynchronousTask.ViewStageDetailsExport;
import com.yizhi.application.asynchronousTask.ViewStagePurchaseDetailsExport;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.application.orm.id.IdGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
/**
* @author Ding
* @className ExperiencePoolReportController
* @description TODO
* @date 2018/11/29
**/
@RestController
public class ExperiencePoolReportController implements ExperiencePoolReportClient {
@Autowired
private IExperiencePoolService poolService;
@Autowired
private ViewAccountDetailsExport viewAccountDetailsExport;
@Autowired
private ViewAllDetailsExport viewAllDetailsExport;
@Autowired
private ViewStageDetailsExport viewStageDetailsExport;
@Autowired
private ViewStagePurchaseDetailsExport viewStagePurchaseDetailsExport;
@Autowired
private IdGenerator idGenerator;
@Override
public Page<ExperiencePoolReportVo> poolReportList(@RequestParam(value = "poolName", required = false) String poolName,
@RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize,
@RequestBody RequestContext requestContext) {
return poolService.getPoolReportList(poolName, pageNo, pageSize, requestContext);
}
@Override
public Page<ExperiencePoolReportExportVo> viewPoolReportList(Long poolId, String key, String orgName, Integer pageNo, Integer pageSize,
Integer type, String startTime, String endTime, Long siteId,@RequestBody RequestContext requestContext) {
return poolService.getReportViewList(poolId, key, orgName, pageNo, pageSize, type, startTime, endTime, siteId, requestContext);
}
@Override
public Page<ExperiencePoolReportExportVo> viewAccountDetails(Long poolId, Long accountId, Integer state, Integer pageNo, Integer pageSize) {
return poolService.viewAccountDetails(poolId, accountId, state, pageNo, pageSize);
}
@Override
public String viewAccountDetailsExport(Long poolId, Long accountId, Integer state) {
Map<String, Object> map = new HashMap<>();
Long taskId = idGenerator.generate();
String taskName = "经验-查看-按用户统计-查看-经验值变更明细下载-" + taskId.toString();
String serialNo = "EXPERIENCE-VIEW-ACCOUNT-DETAILS-" + taskId.toString();
RequestContext res = ContextHolder.get();
map.put("taskId", taskId);
map.put("taskName", taskName);
map.put("serialNo", serialNo);
map.put("res", res);
map.put("poolId", poolId);
map.put("accountId", accountId);
map.put("state", state);
viewAccountDetailsExport.execute(map, true);
return serialNo;
}
@Override
public String viewAllDetailsExport(Long poolId) {
Map<String, Object> map = new HashMap<>();
Long taskId = idGenerator.generate();
String taskName = "经验-查看-导出全部变更明细-" + taskId.toString();
String serialNo = "EXPERIENCE-VIEW-ALL-DETAILS-" + taskId.toString();
RequestContext res = ContextHolder.get();
map.put("taskId", taskId);
map.put("taskName", taskName);
map.put("serialNo", serialNo);
map.put("res", res);
map.put("poolId", poolId);
viewAllDetailsExport.execute(map, true);
return serialNo;
}
@Override
public String viewStageDetailsExport(Long poolId, String startTime, String endTime, String orgName, String accountName) {
Map<String, Object> map = new HashMap<>();
Long taskId = idGenerator.generate();
String taskName = "经验-查看-阶段经验值变动统计-明细导出-" + taskId.toString();
String serialNo = "EXPERIENCE-VIEW-STAGE-DETAILS-" + taskId.toString();
RequestContext res = ContextHolder.get();
map.put("taskId", taskId);
map.put("taskName", taskName);
map.put("serialNo", serialNo);
map.put("res", res);
map.put("poolId", poolId);
map.put("startTime", startTime);
map.put("endTime", endTime);
map.put("orgName", orgName);
map.put("accountName", accountName);
viewStageDetailsExport.execute(map, true);
return serialNo;
}
@Override
public String viewStagePurchaseDetailsExport(Long poolId, String startTime, String endTime, String orgName, String accountName) {
Map<String, Object> map = new HashMap<>();
Long taskId = idGenerator.generate();
String taskName = "经验-查看-阶段经验值变动统计-消耗明细导出-" + taskId.toString();
String serialNo = "EXPERIENCE-VIEW-STAGE-PURCHASE-DETAILS-" + taskId.toString();
RequestContext res = ContextHolder.get();
map.put("taskId", taskId);
map.put("taskName", taskName);
map.put("serialNo", serialNo);
map.put("res", res);
map.put("poolId", poolId);
map.put("startTime", startTime);
map.put("endTime", endTime);
map.put("orgName", orgName);
map.put("accountName", accountName);
viewStagePurchaseDetailsExport.execute(map, true);
return serialNo;
}
}
package com.yizhi.application.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
/**
* <p>
* 经验发放记录表 前端控制器
* </p>
*
* @author dingxiaowei123
* @since 2019-01-02
*/
@Controller
@RequestMapping("/experienceRecord")
public class ExperienceRecordController {
}
package com.yizhi.application.controller;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.application.domain.ExperiencePoolAuthorize;
import com.yizhi.application.domain.StudentExperiencePool;
import com.yizhi.application.mapper.ExperiencePoolAuthorizeMapper;
import com.yizhi.application.mapper.MyExperienceMapper;
import com.yizhi.application.service.IExperiencePoolAuthorizeService;
import com.yizhi.application.service.IStudentExperienceService;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.custom.api.feign.MyExperienceClient;
import com.yizhi.custom.api.vo.custom.*;
import com.yizhi.custom.api.vo.domain.StudentExperiencePoolVo;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.system.application.system.remote.AccountClient;
import com.yizhi.system.application.vo.AccountVO;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* <p>
* 我的经验
* </p>
*
* @author ding
* @since 2018-11-06
*/
@RestController
public class MyExperienceController implements MyExperienceClient {
@Autowired
private MyExperienceMapper myExperienceMapper;
@Autowired
private ExperiencePoolAuthorizeMapper experiencePoolAuthorizeMapper;
@Autowired
private IdGenerator idGenerator;
@Autowired
private IExperiencePoolAuthorizeService experiencePoolAuthorizeService;
@Autowired
private AccountClient accountClient;
@Autowired
private IStudentExperienceService studentExperienceService;
@Override
public MyExperienceLevelVo getMyExperiencePool(Long poolId, String sort) {
RequestContext res = ContextHolder.get();
if (res == null) {
return null;
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String currentTime = sdf.format(new Date());
Long accountId = res.getAccountId();
AccountVO accountVO = accountClient.findById(accountId);
if (null == accountVO) {
MyExperienceLevelVo myExperienceLevelVo = new MyExperienceLevelVo();
myExperienceLevelVo.setCurrentTime(currentTime);
return myExperienceLevelVo;
}
MyExperienceLevelVo myExperienceLevelVo = myExperienceMapper.getMyExperiencePoolAndLevel(poolId, accountId);
if (myExperienceLevelVo == null) {
myExperienceLevelVo = myExperienceMapper.getMyExperiencePool(poolId, accountId);
Integer experienceTotal = myExperienceLevelVo.getExperienceTotal();
if (null == experienceTotal) {
myExperienceLevelVo.setRanking("0");
} else {
String s2 = "2";
String s3 = "3";
String group = null;
String batchNo = null;
if (null != sort && s2.equals(sort.trim())) {
group = getGroupOrBatchNo(poolId, res.getAccountId(), 2);
}
if (null != sort && s3.equals(sort.trim())) {
batchNo = getGroupOrBatchNo(poolId, res.getAccountId(), 3);
}
Integer ranking = myExperienceMapper.getMyExperienceRanking(poolId, experienceTotal, group, batchNo);
if (ranking == null) {
ranking = 0;
} else {
ranking += 1;
}
myExperienceLevelVo.setRanking(ranking.toString());
}
if (myExperienceLevelVo == null) {
myExperienceLevelVo = new MyExperienceLevelVo();
myExperienceLevelVo.setCurrentTime(currentTime);
return myExperienceLevelVo;
}
myExperienceLevelVo.setName(accountVO.getName() == null ? "" : accountVO.getName());
myExperienceLevelVo.setFullName(accountVO.getFullName() == null ? "" : accountVO.getFullName());
myExperienceLevelVo.setSex(accountVO.getSex() == null ? "" : accountVO.getSex());
myExperienceLevelVo.setCurrentTime(currentTime);
return myExperienceLevelVo;
}
myExperienceLevelVo.setName(accountVO.getName() == null ? "" : accountVO.getName());
myExperienceLevelVo.setFullName(accountVO.getFullName() == null ? "" : accountVO.getFullName());
myExperienceLevelVo.setSex(accountVO.getSex() == null ? "" : accountVO.getSex());
//获取个人排名
Integer experienceTotal = myExperienceLevelVo.getExperienceTotal();
String s2 = "2";
String s3 = "3";
String group = null;
String batchNo = null;
if (null != sort && s2.equals(sort.trim())) {
group = getGroupOrBatchNo(poolId, res.getAccountId(), 2);
}
if (null != sort && s3.equals(sort.trim())) {
batchNo = getGroupOrBatchNo(poolId, res.getAccountId(), 3);
}
Integer ranking = myExperienceMapper.getMyExperienceRanking(poolId, experienceTotal, group, batchNo);
if (ranking == null) {
ranking = 0;
} else {
ranking += ranking;
}
myExperienceLevelVo.setRanking(ranking.toString());
myExperienceLevelVo.setCurrentTime(currentTime);
return myExperienceLevelVo;
}
@Override
public Page<MyExperienceRankingVo> getMyExperienceRankings(Long poolId, String sort, Integer pageSize,
Integer pageNo) {
RequestContext res = ContextHolder.get();
if (res == null) {
return null;
}
String s2 = "2";
String s3 = "3";
String group = null;
String batchNo = null;
if (null != sort && s2.equals(sort.trim())) {
group = getGroupOrBatchNo(poolId, res.getAccountId(), 2);
}
if (null != sort && s3.equals(sort.trim())) {
batchNo = getGroupOrBatchNo(poolId, res.getAccountId(), 3);
}
List<MyExperienceRankingVo> rankings = myExperienceMapper.getMyExperienceRankings(poolId, group, batchNo, pageSize, pageSize * (pageNo - 1));
if (rankings == null) {
return null;
}
//获取个人排名
for (MyExperienceRankingVo ranking : rankings) {
if (ranking == null) {
continue;
}
Integer total = myExperienceMapper.getMyExperienceRanking(poolId, ranking.getExperience(), group, batchNo);
if (total == null) {
total = 0;
} else {
total += 1;
}
ranking.setRanking(total);
}
Page<MyExperienceRankingVo> page = new Page<MyExperienceRankingVo>(pageNo, pageSize);
if (CollectionUtils.isEmpty(rankings)) {
page.setRecords(new ArrayList<MyExperienceRankingVo>());
} else {
page.setRecords(rankings);
}
Integer count = myExperienceMapper.getMyExperienceRankingsPageTotal(poolId, group, batchNo);
if (count == null) {
count = 0;
}
page.setTotal(count);
return page;
}
@Override
public Page<MyExperienceEventsVo> getMyExperienceDtl(Long poolId, Integer pageSize, Integer pageNo) {
RequestContext res = ContextHolder.get();
if (res == null) {
return null;
}
Page<MyExperienceEventsVo> page = new Page<MyExperienceEventsVo>(pageNo, pageSize);
List<MyExperienceEventsVo> evs = myExperienceMapper.getMyExperienceDtl(poolId, res.getAccountId(), page);
if (evs == null) {
return page;
}
page.setRecords(evs);
return page;
}
@Override
public MyExperienceLevelVo getMyExperienceClassify(Long poolId, Integer pageSize, Integer pageNo) {
RequestContext res = ContextHolder.get();
if (res == null) {
return null;
}
Long accountId = res.getAccountId();
AccountVO accountVO = accountClient.findById(accountId);
if (null == accountVO) {
return null;
}
MyExperienceLevelVo myExperienceLevelVo = myExperienceMapper.getMyExperiencePoolAndLevel(poolId, accountId);
if (myExperienceLevelVo == null) {
myExperienceLevelVo = myExperienceMapper.getMyExperiencePool(poolId, accountId);
if (myExperienceLevelVo == null) {
myExperienceLevelVo = new MyExperienceLevelVo();
myExperienceLevelVo.setFullName(accountVO.getFullName());
myExperienceLevelVo.setName(accountVO.getName());
myExperienceLevelVo.setSex(accountVO.getSex());
return myExperienceLevelVo;
}
myExperienceLevelVo.setLevelCode("");
myExperienceLevelVo.setLevelName("");
myExperienceLevelVo.setRanking("");
}
myExperienceLevelVo.setName(accountVO.getName());
myExperienceLevelVo.setFullName(accountVO.getFullName());
myExperienceLevelVo.setSex(accountVO.getSex());
if (null != myExperienceLevelVo.getExperienceTotal()) {
Integer total = myExperienceMapper.getMyExperienceRanking(poolId, myExperienceLevelVo.getExperienceTotal(), null, null);
if (null == total) {
total = 0;
} else {
total += 1;
}
myExperienceLevelVo.setRanking(total.toString());
}
//获取分类明细
List<MyExperienceEventsVo> evs = myExperienceMapper.getMyExperience(poolId, res.getAccountId());
if (CollectionUtils.isNotEmpty(evs)) {
myExperienceLevelVo.setEventClassifys(evs);
}
return myExperienceLevelVo;
}
@Override
public List<MyExperienceLevelVo> getMyExperienceLevels(Long poolId) {
return myExperienceMapper.getMyExperienceLevels(poolId);
}
@Override
public MyExperiencePoolVo getMyExperienceLogin(Long poolId) {
RequestContext res = ContextHolder.get();
if (res == null) {
return null;
}
Long accountId = res.getAccountId();
MyExperiencePoolVo pool = myExperienceMapper.getMyExperienceLogin(poolId, accountId);
if (pool == null) {
Date date = new Date();
StudentExperiencePool studentExperiencePool = createNewStudentExperiencePool(poolId, accountId);
if (studentExperiencePool == null) {
return null;
}
studentExperiencePool.setCreateById(res.getAccountId());
studentExperiencePool.setCreateByName(res.getAccountName());
studentExperiencePool.setCreateTime(date);
myExperienceMapper.insert(studentExperiencePool);
pool = new MyExperiencePoolVo();
pool.setFirstLogin(0);
pool.setMotto("");
pool.setStep(0);
pool.setNowTime(date);
pool.setAccountCode(studentExperiencePool.getBatchNo());
} else {
pool.setFirstLogin(1);
}
return pool;
}
@Override
public StudentExperiencePoolVo saveMyExperienceStep(Long poolId, Integer step) {
RequestContext res = ContextHolder.get();
if (res == null) {
return null;
}
Long accountId = res.getAccountId();
Date date = new Date();
StudentExperiencePool pool = myExperienceMapper.getMyExperiencePoolInfo(poolId, accountId);
if (pool == null) {
pool = createNewStudentExperiencePool(poolId, accountId);
if (pool == null) {
return null;
}
pool.setCreateByName(res.getAccountName());
pool.setCreateTime(date);
pool.setStep(step);
myExperienceMapper.insert(pool);
} else {
pool.setUpdateById(accountId);
pool.setUpdateByName(res.getAccountName());
pool.setUpdateTime(date);
pool.setStep(step);
myExperienceMapper.updateAllColumnById(pool);
}
StudentExperiencePoolVo spv=new StudentExperiencePoolVo();
BeanUtils.copyProperties(pool,spv);
return spv;
}
@Override
public StudentExperiencePoolVo saveMyExperienceMotto(Long poolId, String motto) {
RequestContext res = ContextHolder.get();
if (res == null) {
return null;
}
Long accountId = res.getAccountId();
Date date = new Date();
StudentExperiencePool pool = myExperienceMapper.getMyExperiencePoolInfo(poolId, accountId);
if (pool == null) {
pool = createNewStudentExperiencePool(poolId, accountId);
if (pool == null) {
return null;
}
pool.setCreateByName(res.getAccountName());
pool.setCreateTime(date);
pool.setMotto(motto);
myExperienceMapper.insert(pool);
} else {
pool.setUpdateById(accountId);
pool.setUpdateByName(res.getAccountName());
pool.setUpdateTime(date);
pool.setMotto(motto);
myExperienceMapper.updateAllColumnById(pool);
}
StudentExperiencePoolVo spv=new StudentExperiencePoolVo();
BeanUtils.copyProperties(pool,spv);
return spv;
}
@Override
public Page<ExperienceOrgRankingVO> getOrgRanking(Long poolId, Integer pageNo, Integer pageSize, Integer type) {
return studentExperienceService.getOrgRanking(poolId, pageNo, pageSize, type);
}
@Override
public Map<String, Object> getBatchGroup(Long accountId, Long poolId) {
return myExperienceMapper.getBatchGroup(accountId, poolId);
}
/**
* 创建对象,设置:主键ID,批次号,登录序号
*
* @param poolId
* @param accountId
* @return
*/
private StudentExperiencePool createNewStudentExperiencePool(Long poolId, Long accountId) {
String key = poolId.toString();
// //查询权限
// ExperiencePoolAuthorizeVo auth = experiencePoolAuthorizeMapper.getExperiencePoolAuthorizeByPoolIdAndAccountId(poolId, accountId);
// if (auth == null) {
// return null;
// }
StudentExperiencePool pool = new StudentExperiencePool();
pool.setId(idGenerator.generate());
pool.setExperiencePoolId(poolId);
// pool.setBatchNo(auth.getBatchNo());
pool.setAccountId(accountId);
pool.setCreateById(accountId);
Integer num = myExperienceMapper.getMaxLoginCount(poolId);
if (num == null) {
num = 0;
}
pool.setNum(num + 1);
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
String batchNo = sdf.format(new Date());
String numString = String.format("%04d", pool.getNum());
batchNo += numString;
pool.setBatchNo(batchNo);
/*
RLock rLock = null;
try{
//加锁同步登录人数
rLock = redissonClient.getLock("redisLock_" + key);
rLock.lock(3, TimeUnit.SECONDS);
//获取当前登录人数缓存中获取
Object value = redisCache.get(key);
Integer num = Integer.valueOf(String.valueOf(value));
if(num == null){
//获取不到查询数据库
num = myExperienceMapper.getMaxLoginCount(poolId);
if(num == null){
num = 1;
}
}
pool.setNum(num);
num+=1;
redisCache.set(key, num.toString(), 36000);
} catch(Exception e){
e.printStackTrace();
} finally {
//释放锁
if(rLock != null){
rLock.unlock();
}
}*/
return pool;
}
/**
* 内部封装 获取组别或者批次
*
* @param poolId
* @param accountId
* @param type
* @return
*/
private String getGroupOrBatchNo(Long poolId, Long accountId, Integer type) {
ExperiencePoolAuthorize experiencePoolAuthorize = new ExperiencePoolAuthorize();
experiencePoolAuthorize.setExperienceId(poolId);
experiencePoolAuthorize.setRelationId(accountId);
String s = null;
List<ExperiencePoolAuthorize> authorizeList = experiencePoolAuthorizeService.selectList(new EntityWrapper<>(experiencePoolAuthorize));
if (CollectionUtils.isNotEmpty(authorizeList)) {
//获取组别
if (type == 2) {
if (null != authorizeList.get(0) && authorizeList.get(0).getGroup() != null) {
s = authorizeList.get(0).getGroup();
}
//获取批次
} else if (type == 3) {
if (null != authorizeList.get(0) && authorizeList.get(0).getBatchNo() != null) {
s = authorizeList.get(0).getBatchNo();
}
}
}
return s;
}
}
package com.yizhi.application.controller;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.yizhi.application.domain.Product;
import com.yizhi.application.domain.StudentExperience;
import com.yizhi.application.service.IProductService;
import com.yizhi.application.service.IStudentExperienceService;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.custom.api.feign.PurchaseProductClient;
import com.yizhi.custom.api.param.PurchaseProductsParam;
import com.yizhi.custom.api.vo.custom.ProductVO;
import com.yizhi.custom.api.vo.domain.ProductVo;
import com.yizhi.core.application.cache.distributedlock.impl.RedisDistributedLock;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.point.application.feign.PointDetailsFeignClients;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author dingxiaowei123
* @since 2019-09-19
*/
@RestController
public class ProductController implements PurchaseProductClient {
private static final Logger LOGGER = LoggerFactory.getLogger(ProductController.class);
@Autowired
private PointDetailsFeignClients pointDetailsFeignClients;
@Autowired
private IStudentExperienceService studentExperienceService;
@Autowired
private IProductService productService;
@Autowired
private RedisDistributedLock redisDistributedLock;
@Override
public ProductVO getProducts(Long poolId) {
RequestContext res = ContextHolder.get();
Integer totalPoint = pointDetailsFeignClients.queryPiont(res.getAccountId(),
res.getCompanyId(), res.getSiteId(), res.getOrgId());
if (null == totalPoint) {
totalPoint = 0;
}
Long totalExperience = studentExperienceService.getTotalExperience(poolId, res.getAccountId());
Product product = new Product();
product.setCompanyId(res.getCompanyId());
product.setSiteId(res.getSiteId());
product.setState(1);
List<Product> products = productService.selectList(new EntityWrapper<>(product));
List<ProductVo> productVos=new ArrayList<>();
for (Product p:products) {
ProductVo pv=new ProductVo();
BeanUtils.copyProperties(p,pv);
productVos.add(pv);
}
ProductVO productVO = new ProductVO();
productVO.setTotalPoint(totalPoint);
productVO.setTotalExperience(totalExperience);
if (CollectionUtils.isNotEmpty(products)) {
productVO.setProducts(productVos);
}
return productVO;
}
@Override
@RequestMapping(produces = "text/plain;charset=UTF-8")
public String purchaseProducts(@RequestBody PurchaseProductsParam param) {
List<ProductVo> products = param.getProducts();
RequestContext res = ContextHolder.get();
String purchaseProductName = "";
String emptyProductName = "";
if (CollectionUtils.isNotEmpty(products)) {
for (ProductVo product : products) {
String lockName = "product_" + product.getId();
//获取redis锁
if (redisDistributedLock.lock(lockName)) {
try {
Product product1 = productService.selectById(product.getId());
//如果库存足够,购买商品
if (product1.getRemainingAmount() >= product.getAmount()) {
StudentExperience studentExperience = new StudentExperience();
studentExperience.setActivityName(product1.getProductName());
studentExperience.setCompanyId(res.getCompanyId());
studentExperience.setSiteId(res.getSiteId());
//消费经验
studentExperience.setType(10);
studentExperience.setCreateById(res.getAccountId());
studentExperience.setCreateByName(res.getAccountName());
studentExperience.setState(1);
studentExperience.setAccountId(res.getAccountId());
studentExperience.setAccountName(res.getAccountName());
studentExperience.setExperiencePoolId(param.getPoolId());
studentExperience.setExperience(product1.getPrice() * product.getAmount());
studentExperienceService.insertStudentExperience(studentExperience);
//库存更新
product1.setRemainingAmount(product1.getRemainingAmount() - product.getAmount());
productService.updateById(product1);
if (StringUtils.isBlank(purchaseProductName)) {
purchaseProductName += product1.getProductName();
} else {
purchaseProductName += "," + product1.getProductName();
}
} else {
//库存不足,不能购买
if (StringUtils.isBlank(emptyProductName)) {
emptyProductName += product1.getProductName();
} else {
emptyProductName += "," + product1.getProductName();
}
}
} catch (Exception e) {
LOGGER.error("商品" + product.getId() + "购买异常", e);
} finally {
redisDistributedLock.releaseLock(lockName);
LOGGER.info("释放reids锁" + lockName);
}
}
}
String result = null;
if (StringUtils.isBlank(purchaseProductName)) {
result = emptyProductName + "库存不足,未能购买";
} else if (StringUtils.isBlank(emptyProductName)) {
result = "购买成功";
} else {
result = purchaseProductName + "购买成功," + emptyProductName + "库存不足,未能购买";
}
System.out.println(result);
return result;
}
return null;
}
}
package com.yizhi.application.controller;
import java.util.ArrayList;
import java.util.List;
import com.yizhi.application.domain.ProjectActivityExperience;
import com.yizhi.application.service.IProjectActivityExperienceService;
import com.yizhi.custom.api.vo.custom.ExperienceRulesVO;
import com.yizhi.custom.api.vo.domain.ProjectActivityExperienceVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.yizhi.custom.api.feign.ProjectActivityExperienceClient;
/**
* <p>
* 前端控制器
* </p>
*
* @author ding
* @since 2018-11-06
*/
@RestController
@RequestMapping("/manage/experiencePool/projectActivity")
public class ProjectActivityExperienceController implements ProjectActivityExperienceClient {
@Autowired
private IProjectActivityExperienceService activityExperienceService;
@Override
@PostMapping("/insert")
public boolean insertProjectActivityExperienceList(@RequestBody List<ProjectActivityExperienceVo> projectActivityExperienceList) {
List<ProjectActivityExperience> list=new ArrayList<>();
if (!projectActivityExperienceList.isEmpty()) {
for (ProjectActivityExperienceVo pv : projectActivityExperienceList) {
ProjectActivityExperience pvs=new ProjectActivityExperience();
BeanUtils.copyProperties(pv,pvs);
list.add(pvs);
}
}
return activityExperienceService.insertList(list);
}
@Override
@GetMapping("/getRules")
public List<ExperienceRulesVO> getExperienceRules(Long poolId) {
return activityExperienceService.getExperienceRules(poolId);
}
}
package com.yizhi.application.controller;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.yizhi.application.domain.ProjectActivityExperience;
import com.yizhi.application.domain.ProjectActivityExperienceSet;
import com.yizhi.application.service.IProjectActivityExperienceService;
import com.yizhi.application.service.IProjectActivityExperienceSetService;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.custom.api.vo.domain.ProjectActivityExperienceSetVo;
import com.yizhi.core.application.context.ContextHolder;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.yizhi.custom.api.feign.ProjectActivityExperienceSetClient;
/**
* <p>
* 前端控制器
* </p>
*
* @author ding
* @since 2018-11-06
*/
@RestController
@RequestMapping("/manage/experiencePool")
public class ProjectActivityExperienceSetController implements ProjectActivityExperienceSetClient {
@Autowired
private IProjectActivityExperienceSetService activityExperienceSetService;
@Autowired
private IProjectActivityExperienceService activityExperienceService;
@Override
@GetMapping("/projectActivityExperienceSet/list")
public Map<String, Object> getProjectActivityExperienceSets(@RequestParam("activityExperienceId") Long activityExperienceId,
@RequestParam(value = "setType", required = false) Integer setType) {
return activityExperienceSetService.getSets(activityExperienceId, setType);
}
@Override
@GetMapping("/projectActivityExperienceSet/view")
public ProjectActivityExperienceSetVo viewProjectActivityExperienceSet(Long activityExperienceSetId) {
ProjectActivityExperienceSet pa=activityExperienceSetService.selectById(activityExperienceSetId);
ProjectActivityExperienceSetVo pav=new ProjectActivityExperienceSetVo();
BeanUtils.copyProperties(pa,pav);
return pav;
}
@Override
@GetMapping("/projectActivityExperienceSet/insert")
public Map<String, Object> insertProjectActivityExperienceSet(@RequestParam(value = "activityExperienceSetId", required = false) Long activityExperienceSetId,
@RequestParam(value = "activityExperienceId", required = true) Long activityExperienceId,
@RequestParam(value = "setType", required = true) Integer setType,
@RequestParam(value = "minScore", required = true) Integer minScore,
@RequestParam(value = "experience", required = true) Long experience) {
return activityExperienceSetService.insertSet(activityExperienceSetId, activityExperienceId, setType, minScore, experience);
}
@Override
@GetMapping("/projectActivityExperienceSet/insertWithScore")
public Map<String, Object> insertProjectActivityExperienceSetWithScore(@RequestParam(value = "activityExperienceSetId", required = false) Long activityExperienceSetId,
@RequestParam(value = "activityExperienceId", required = true) Long activityExperienceId,
@RequestParam(value = "setType", required = false) Integer setType,
@RequestParam(value = "times", required = false) Integer times) {
return activityExperienceSetService.insertSetWithScore(activityExperienceSetId, activityExperienceId, setType, times);
}
@Override
@GetMapping("/projectActivityExperienceSet/delete")
public boolean deleteProjectActivityExperienceSet(Long projectActivityExperienceSetId) {
RequestContext res = ContextHolder.get();
ProjectActivityExperienceSet projectActivityExperienceSet = new ProjectActivityExperienceSet();
projectActivityExperienceSet = activityExperienceSetService.selectById(projectActivityExperienceSetId);
boolean isOk = activityExperienceSetService.deleteById(projectActivityExperienceSetId);
ProjectActivityExperienceSet projectActivityExperienceSet1 = new ProjectActivityExperienceSet();
projectActivityExperienceSet1.setProjectActivityExperienceId(projectActivityExperienceSet.getProjectActivityExperienceId());
EntityWrapper<ProjectActivityExperienceSet> entityWrapper = new EntityWrapper<>(projectActivityExperienceSet1);
List<ProjectActivityExperienceSet> list = activityExperienceSetService.selectList(entityWrapper);
if (CollectionUtils.isEmpty(list)) {
ProjectActivityExperience projectActivityExperience = new ProjectActivityExperience();
projectActivityExperience.setId(projectActivityExperienceSet.getProjectActivityExperienceId());
projectActivityExperience.setActivityExperienceSource(0);
projectActivityExperience.setUpdateById(res.getAccountId());
projectActivityExperience.setUpdateByName(res.getAccountFullName());
projectActivityExperience.setUpdateTime(new Date());
activityExperienceService.updateById(projectActivityExperience);
}
return isOk;
}
@Override
@GetMapping("/projectActivityExperienceSets/delete")
public Map<String, Object> deleteProjectActivityExperienceSets(Long activityExperienceId) {
RequestContext res = ContextHolder.get();
Map<String, Object> map = new HashMap<>();
ProjectActivityExperienceSet activityExperienceSet = new ProjectActivityExperienceSet();
activityExperienceSet.setProjectActivityExperienceId(activityExperienceId);
EntityWrapper<ProjectActivityExperienceSet> entityWrapper = new EntityWrapper<>(activityExperienceSet);
boolean isOk = activityExperienceSetService.delete(entityWrapper);
if (isOk) {
ProjectActivityExperience projectActivityExperience = new ProjectActivityExperience();
projectActivityExperience.setId(activityExperienceId);
projectActivityExperience.setActivityExperienceSource(0);
projectActivityExperience.setUpdateById(res.getAccountId());
projectActivityExperience.setUpdateByName(res.getAccountFullName());
projectActivityExperience.setUpdateTime(new Date());
activityExperienceService.updateById(projectActivityExperience);
map.put("activityExperienceId", activityExperienceId);
map.put("source", 0);
return map;
}
return null;
}
}
package com.yizhi.application.controller;
import com.yizhi.application.domain.StudentExperience;
import com.yizhi.application.service.IStudentExperienceService;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.custom.api.feign.StudentExperienceClient;
import com.yizhi.custom.api.vo.domain.StudentExperienceVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* 项目关联活动经验值表 前端控制器
* </p>
*
* @author dingxiaowei123
* @since 2018-11-12
*/
@RestController
@RequestMapping("/manage/experiencePool/studentExperience")
public class StudentExperienceController implements StudentExperienceClient {
@Autowired
private IStudentExperienceService studentExperienceService;
@Override
@PostMapping("/insert")
public boolean insertStudentExperienceList(@RequestBody List<StudentExperienceVo> studentExperienceList) {
List<StudentExperience> levelVos=new ArrayList<>();
if (!studentExperienceList.isEmpty()) {
for (StudentExperienceVo pl : studentExperienceList) {
StudentExperience pls=new StudentExperience();
BeanUtils.copyProperties(pl,pls);
levelVos.add(pls);
}
}
return studentExperienceService.insertStudentExperienceList(levelVos);
}
/**
* 经验池手动补发经验
*
* @param experiencePoolId
* @return
*/
@Override
@GetMapping("/push")
public boolean pushStudentExperience(Long experiencePoolId, Long activityId, String activityName, Integer activityType, @RequestParam("accountIds") List<Long> accountIds, @RequestBody RequestContext requestContext) {
return studentExperienceService.pushStudentExperience(experiencePoolId, activityId, activityName, activityType, accountIds, requestContext);
}
}
package com.yizhi.application.controller;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.core.application.event.EventWrapper;
import com.yizhi.core.application.publish.CloudEventPublisher;
import com.yizhi.core.application.task.AbstractTaskHandler;
import com.yizhi.core.application.task.TaskExecutor;
import com.yizhi.sign.application.feign.SignApiClient;
import com.yizhi.sign.application.feign.SignRecordApiClient;
import com.yizhi.sign.application.vo.SignVO;
import com.yizhi.training.application.feign.TrainingProjectClient;
import com.yizhi.training.application.vo.domain.TpAuthorizationRangeVo;
import com.yizhi.training.application.vo.domain.TrainingProjectVo;
import com.yizhi.util.application.constant.QueueConstant;
import com.yizhi.util.application.constant.TpActivityType;
import com.yizhi.util.application.domain.Response;
import com.yizhi.util.application.event.TrainingProjectEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yizhi.core.application.context.ContextHolder;
import io.swagger.annotations.ApiOperation;
@RestController
@RequestMapping("/api/sign")
public class StudentSignController {
@Autowired
private SignApiClient signClient;
@Autowired
SignRecordApiClient signRecordApiClient;
@Autowired
private TrainingProjectClient trainingProjectClient;
@Autowired
private TaskExecutor taskExecutor;
@Autowired
private CloudEventPublisher cloudEventPublisher;
private static final Logger LOG = LoggerFactory.getLogger(StudentSignController.class);
@ApiOperation(value = "签到(扫码进入)", notes = "签到(扫码进入)")
@PostMapping(value = "/custom/scan")
public Response<Object> customSignScan(@RequestBody SignVO signVO) {
RequestContext requestContext = ContextHolder.get();
signVO.setSignType(1);
Long projectId = signVO.getTrainingProjectId();
List<Long> relationIds = requestContext.getRelationIds();
Long siteId = requestContext.getSiteId();
Long accountId = requestContext.getAccountId();
Map<String, String> signMap = new HashMap<String, String>();
boolean isPass = false;
TrainingProjectVo project = trainingProjectClient.getOne(projectId);
Integer range = project.getVisibleRange();
if (range != null && range == 1) {
if (siteId != null && project.getSiteId() != null && siteId.equals(project.getSiteId())) {
isPass = true;
}
} else if (range != null && range == 0 && siteId.equals(project.getSiteId())) {
List<TpAuthorizationRangeVo> tpAuthorizationRanges = trainingProjectClient.VisibleRange(projectId);
List<Long> rangeIds = new ArrayList<>();
if (tpAuthorizationRanges != null && tpAuthorizationRanges.size() > 0) {
rangeIds = tpAuthorizationRanges.stream().map(TpAuthorizationRangeVo::getRelationId).collect(Collectors.toList());
LOG.info("rangeIds" + rangeIds.toString());
}
if (rangeIds.contains(accountId)) {
isPass = true;
} else {
for (Long relationId : relationIds) {
if (rangeIds.contains(relationId)) {
isPass = true;
break;
}
}
}
}
if (isPass) {
return sign(signVO);
} else {
return Response.fail("4001", "签到失败,您不在该项目范围内");
}
}
@ApiOperation(value = "签到", notes = "签到")
@PostMapping(value = "/")
public Response<Object> sign(@RequestBody SignVO signVO) {
RequestContext requestContext = ContextHolder.get();
Long accountId = requestContext.getAccountId();
Map<String, String> signMap = new HashMap<String, String>();
boolean isPass = false;
if (null == requestContext) {
signMap.put("code", "0");
signMap.put("name", "非法签到");
return Response.ok(signMap);
}
signVO.setAccountId(accountId);
// 查询是否签到
String result = signClient.sign(signVO);
if (result.indexOf("成功") >= 0) {
signMap.put("code", "1");
signMap.put("name", result);
} else {
signMap.put("code", "0");
signMap.put("name", result);
}
LOG.info(result);
// 向培训项目发送消息,告知业务已经完成
try {
EventWrapper<TrainingProjectEvent> eventWrapper = new EventWrapper<TrainingProjectEvent>(signVO.getId(), TrainingProjectEvent.getInstance(signVO.getId(), TpActivityType.TYPE_SIGN, accountId, new Date(), requestContext.getSiteId()));
LOG.info("向培训项目发送消息,告知签到业务已经完成:{}", eventWrapper);
taskExecutor.asynExecute(new AbstractTaskHandler() {
@Override
public void handle() {
try {
cloudEventPublisher.publish(QueueConstant.TRAINING_PROJECT_EVENT_QUEUE, eventWrapper);
} catch (Exception e) {
e.printStackTrace();
}
}
});
} catch (Exception e) {
LOG.info("签到业务向培训项目发送消息告知已经完成,失败:{}", e);
}
return Response.ok(signMap);
}
}
package com.yizhi.application.domain;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 代码包管理主体
* </p>
*
* @author dingxiaowei
* @since 2018-11-01
*/
@Data
@ApiModel(value = "CodePackageManageVo", description = "")
@TableName("code_package_manage")
public class CodePackageManage {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID")
private Long id;
@ApiModelProperty(value = "代码包名称")
@TableField("code_package_name")
private String codePackageName;
@ApiModelProperty(value = "导入时间")
@TableField("import_time")
private Date importTime;
@ApiModelProperty(value = "访问路径")
private String url;
@ApiModelProperty(value = "状态 0 删除 1 有效")
private Integer state;
@ApiModelProperty(value = "创建时间")
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
@ApiModelProperty(value = "创建人ID")
@TableField(value = "create_by_id", fill = FieldFill.INSERT)
private Long createById;
@ApiModelProperty(value = "创建人名字")
@TableField(value = "create_by_name", fill = FieldFill.INSERT)
private String createByName;
@ApiModelProperty(value = "修改时间")
@TableField(value = "update_time", fill = FieldFill.INSERT)
private Date updateTime;
@ApiModelProperty(value = "修改人ID")
@TableField(value = "update_by_id", fill = FieldFill.INSERT)
private Long updateById;
@ApiModelProperty(value = "修改人名字")
@TableField(value = "update_by_name", fill = FieldFill.INSERT)
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;
}
package com.yizhi.application.domain;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 经验池主体
* </p>
*
* @author dingxiaowei
* @since 2018-11-02
*/
@Data
@ApiModel(value = "ExperiencePoolVo", description = "自定义项目经验池主体表")
@TableName("experience_pool")
public class ExperiencePool {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID")
private Long id;
@ApiModelProperty(value = "经验池编码")
@TableField("experience_pool_no")
private String experiencePoolNo;
@ApiModelProperty(value = "经验池名称")
@TableField("experience_pool_name")
private String experiencePoolName;
@ApiModelProperty(value = "0删除 1 草稿 2上架")
private Integer state;
@ApiModelProperty(value = " 1手工输入 2外部导入")
@TableField("experience_pool_type")
private Integer experiencePoolType;
@ApiModelProperty(value = "可见范围:1 全平台可见 2 指定学员")
@TableField("visible_range")
private Integer visibleRange;
@ApiModelProperty(value = "创建时间")
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
@ApiModelProperty(value = "创建人ID")
@TableField(value = "create_by_id", fill = FieldFill.INSERT)
private Long createById;
@ApiModelProperty(value = "创建人名字")
@TableField(value = "create_by_name", fill = FieldFill.INSERT)
private String createByName;
@ApiModelProperty(value = "修改时间")
@TableField(value = "update_time", fill = FieldFill.INSERT)
private Date updateTime;
@ApiModelProperty(value = "修改人ID")
@TableField(value = "update_by_id", fill = FieldFill.INSERT)
private Long updateById;
@ApiModelProperty(value = "修改人名字")
@TableField(value = "update_by_name", fill = FieldFill.INSERT)
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;
}
package com.yizhi.application.domain;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 经验池可见范围主体
* </p>
*
* @author dingxiaowei
* @since 2018-11-01
*/
@Data
@ApiModel(value = "ExperiencePoolAuthorizeVo", description = "")
@TableName("experience_pool_authorize")
public class ExperiencePoolAuthorize {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID")
private Long id;
@ApiModelProperty(value = "经验池ID")
@TableField("experience_id")
private Long experienceId;
@ApiModelProperty(value = "1 用户 2 部门")
private Integer type;
@ApiModelProperty(value = "批次号")
@TableField("batch_no")
private String batchNo;
@ApiModelProperty("组别")
private String group;
@ApiModelProperty(value = "范围ID")
@TableField("relation_id")
private Long relationId;
@ApiModelProperty(value = "学员名字或部门名称")
private String name;
@ApiModelProperty(value = "创建时间")
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
@ApiModelProperty(value = "创建人ID")
@TableField(value = "create_by_id", fill = FieldFill.INSERT)
private Long createById;
@ApiModelProperty(value = "创建人名字")
@TableField(value = "create_by_name", fill = FieldFill.INSERT)
private String createByName;
@ApiModelProperty(value = "修改时间")
@TableField(value = "update_time", fill = FieldFill.INSERT)
private Date updateTime;
@ApiModelProperty(value = "修改人ID")
@TableField(value = "update_by_id", fill = FieldFill.INSERT)
private Long updateById;
@ApiModelProperty(value = "修改人名字")
@TableField(value = "update_by_name", fill = FieldFill.INSERT)
private String updateByName;
@ApiModelProperty("备注")
private String note;
}
package com.yizhi.application.domain;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 经验池等级主体
* </p>
*
* @author dingxiaowei
* @since 2018-11-01
*/
@Data
@ApiModel(value = "ExperiencePoolLevelVo", description = "")
@TableName("experience_pool_level")
public class ExperiencePoolLevel {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID")
private Long id;
@ApiModelProperty(value = "经验池ID")
@TableField("experience_pool_id")
private Long experiencePoolId;
@ApiModelProperty(value = "等级编码")
@TableField("level_no")
private String levelNo;
@ApiModelProperty(value = "等级名称")
@TableField("level_name")
private String levelName;
@ApiModelProperty(value = "等级对应经验最小值")
@TableField("min_level_experience")
private Long minLevelExperience;
@ApiModelProperty(value = "状态")
private Integer state;
@ApiModelProperty(value = "创建时间")
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
@ApiModelProperty(value = "创建人ID")
@TableField(value = "create_by_id", fill = FieldFill.INSERT)
private Long createById;
@ApiModelProperty(value = "创建人名字")
@TableField(value = "create_by_name", fill = FieldFill.INSERT)
private String createByName;
@ApiModelProperty(value = "修改时间")
@TableField(value = "update_time", fill = FieldFill.INSERT)
private Date updateTime;
@ApiModelProperty(value = "修改人ID")
@TableField(value = "update_by_id", fill = FieldFill.INSERT)
private Long updateById;
@ApiModelProperty(value = "修改人名字")
@TableField(value = "update_by_name", fill = FieldFill.INSERT)
private String updateByName;
}
package com.yizhi.application.domain;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 经验池关联项目主体
* </p>
*
* @author dingxiaowei
* @since 2018-11-01
*/
@Data
@ApiModel(value = "ExperiencePoolProjectVo", description = "")
@TableName("experience_pool_project")
public class ExperiencePoolProject {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID")
private Long id;
@ApiModelProperty(value = "经验池ID")
@TableField("experience_id")
private Long experienceId;
@ApiModelProperty(value = "项目类型1 课程 2 考试 3 调研 4 投票")
private Integer type;
@ApiModelProperty(value = "项目编码")
@TableField("biz_no")
private String bizNo;
@ApiModelProperty(value = "项目ID")
@TableField("biz_id")
private Long bizId;
@ApiModelProperty(value = "项目名称")
@TableField("biz_name")
private String bizName;
@ApiModelProperty(value = "状态 0 删除 1有效 ")
private Integer state;
@ApiModelProperty(value = "创建时间")
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
@ApiModelProperty(value = "创建人ID")
@TableField(value = "create_by_id", fill = FieldFill.INSERT)
private Long createById;
@ApiModelProperty(value = "创建人名字")
@TableField(value = "create_by_name", fill = FieldFill.INSERT)
private String createByName;
@ApiModelProperty(value = "修改时间")
@TableField(value = "update_time", fill = FieldFill.INSERT)
private Date updateTime;
@ApiModelProperty(value = "修改人ID")
@TableField(value = "update_by_id", fill = FieldFill.INSERT)
private Long updateById;
@ApiModelProperty(value = "修改人名字")
@TableField(value = "update_by_name", fill = FieldFill.INSERT)
private String updateByName;
}
package com.yizhi.application.domain;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 经验发放记录表
* </p>
*
* @author dingxiaowei123
* @since 2019-01-02
*/
@Data
@ApiModel(value = "ExperienceRecordVo", description = "经验发放记录表")
@TableName("experience_record")
public class ExperienceRecord {
private static final long serialVersionUID = 1L;
private Long id;
@ApiModelProperty(value = "经验池id")
@TableField("experience_pool_id")
private Long experiencePoolId;
@ApiModelProperty(value = "学生id")
@TableField("account_id")
private Long accountId;
@ApiModelProperty(value = "活动类型")
@TableField("activity_type")
private Integer activityType;
@ApiModelProperty(value = "活动id(考试,课程,调研,投票…..)")
@TableField("activity_id")
private Long activityId;
@ApiModelProperty(value = "活动名称")
@TableField("activity_name")
private String activityName;
@ApiModelProperty(value = "产生经验")
private Integer experience;
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
@TableField(value = "create_by_id", fill = FieldFill.INSERT)
private Long createById;
@TableField(value = "create_by_name", fill = FieldFill.INSERT)
private String createByName;
@TableField(value = "update_time", fill = FieldFill.INSERT)
private Date updateTime;
@TableField(value = "update_by_id", fill = FieldFill.INSERT)
private Long updateById;
@TableField(value = "update_by_name", fill = FieldFill.INSERT)
private String updateByName;
}
package com.yizhi.application.domain;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author dingxiaowei123
* @since 2019-09-19
*/
@Data
@ApiModel(value = "ProductVo", description = "")
@TableName("product")
public class Product {
private static final long serialVersionUID = 1L;
private Long id;
@ApiModelProperty(value = "商品名称")
@TableField("product_name")
private String productName;
@ApiModelProperty(value = "商品单价")
private Long price;
@ApiModelProperty(value = "商品总数")
private Integer amount;
@ApiModelProperty(value = "商品剩余数量")
@TableField("remaining_amount")
private Integer remainingAmount;
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
@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 = "状态, 0:删除 1:有效")
private Integer state;
}
package com.yizhi.application.domain;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 经验池关联项目活动经验值主体
* </p>
*
* @author dingxiaowei
* @since 2018-11-01
*/
@Data
@ApiModel(value = "ProjectActivityExperienceVo", description = "")
@TableName("project_activity_experience")
public class ProjectActivityExperience {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID ")
private Long id;
@ApiModelProperty(value = "项目关联活动ID")
@TableField("experience_pool_project_id")
private Long experiencePoolProjectId;
@ApiModelProperty(value = "项目类型1 课程 2 考试 3 调研 4 投票 5 外部经验")
private Integer type;
@ApiModelProperty(value = "活动名称")
@TableField("activity_name")
private String activityName;
@ApiModelProperty(value = "活动经验来源 0 无其他条件 1 按成绩设置")
@TableField("activity_experience_source")
private Integer activityExperienceSource;
@ApiModelProperty(value = "活动经验值(分值,活动经验值来源为0时取该值,1从经验值条件表中取)")
@TableField("activity_experience")
private Long activityExperience;
@ApiModelProperty(value = "创建时间")
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
@ApiModelProperty(value = "创建人ID")
@TableField(value = "create_by_id", fill = FieldFill.INSERT)
private Long createById;
@ApiModelProperty(value = "创建人名字")
@TableField(value = "create_by_name", fill = FieldFill.INSERT)
private String createByName;
@ApiModelProperty(value = "修改时间")
@TableField(value = "update_time", fill = FieldFill.INSERT)
private Date updateTime;
@ApiModelProperty(value = "修改人ID")
@TableField(value = "update_by_id", fill = FieldFill.INSERT)
private Long updateById;
@ApiModelProperty(value = "修改人名字")
@TableField(value = "update_by_name", fill = FieldFill.INSERT)
private String updateByName;
@ApiModelProperty(value = "是否有经验")
@TableField(value = "evaluate", fill = FieldFill.INSERT)
private Integer evaluate;
}
package com.yizhi.application.domain;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 经验池关联项目活动经验值设计主体
* </p>
*
* @author dingxiaowei
* @since 2018-11-01
*/
@Data
@ApiModel(value = "ProjectActivityExperienceSetVo", description = "")
@TableName("project_activity_experience_set")
public class ProjectActivityExperienceSet {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "项目关联经验值表_ID")
@TableField("project_activity_experience_id")
private Long projectActivityExperienceId;
@ApiModelProperty(value = "经验设置类型(1按成绩范围设置,2按成绩值设置)")
@TableField("set_type")
private Integer setType;
@ApiModelProperty(value = "经验规则对应最小分数")
@TableField("min_score")
private Integer minScore;
@ApiModelProperty(value = "经验值")
private Long experience;
@ApiModelProperty(value = "按成绩值设置倍数")
private Integer times;
@ApiModelProperty(value = "创建时间")
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
@ApiModelProperty(value = "创建人ID")
@TableField(value = "create_by_id", fill = FieldFill.INSERT)
private Long createById;
@ApiModelProperty(value = "创建人名字")
@TableField(value = "create_by_name", fill = FieldFill.INSERT)
private String createByName;
@ApiModelProperty(value = "修改时间")
@TableField(value = "update_time", fill = FieldFill.INSERT)
private Date updateTime;
@ApiModelProperty(value = "修改人ID")
@TableField(value = "update_by_id", fill = FieldFill.INSERT)
private Long updateById;
@ApiModelProperty(value = "修改人名字")
@TableField(value = "update_by_name", fill = FieldFill.INSERT)
private String updateByName;
}
package com.yizhi.application.domain;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 项目关联活动经验值表
* </p>
*
* @author dingxiaowei123
* @since 2018-11-12
*/
@Data
@ApiModel(value = "StudentExperienceVo", description = "项目关联活动经验值表")
@TableName("student_experience")
public class StudentExperience {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID ")
private Long id;
@ApiModelProperty(value = "经验池ID")
@TableField("experience_pool_id")
private Long experiencePoolId;
@ApiModelProperty(value = "用户ID ")
private Long accountId;
@ApiModelProperty(value = "用户名")
private String accountName;
@ApiModelProperty(value = "项目类型5 (外部导入)")
private Integer type;
@TableField("activity_id")
private Long activityId;
@TableField("activity_name")
private String activityName;
@ApiModelProperty(value = "活动经验值")
private Long experience;
@ApiModelProperty(value = "企业id")
private Long companyId;
@ApiModelProperty(value = "站点id")
private Long siteId;
@ApiModelProperty(value = "部门id")
private Long orgId;
@ApiModelProperty(value = "部门名称")
private String orgName;
@ApiModelProperty(value = "创建时间")
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
@ApiModelProperty(value = "创建人ID")
@TableField(value = "create_by_id", fill = FieldFill.INSERT)
private Long createById;
@ApiModelProperty(value = "创建人名字")
@TableField(value = "create_by_name", fill = FieldFill.INSERT)
private String createByName;
@ApiModelProperty(value = "修改时间")
@TableField(value = "update_time", fill = FieldFill.INSERT)
private Date updateTime;
@ApiModelProperty(value = "修改人ID")
@TableField(value = "update_by_id", fill = FieldFill.INSERT)
private Long updateById;
@ApiModelProperty(value = "修改人名字")
@TableField(value = "update_by_name", fill = FieldFill.INSERT)
private String updateByName;
@ApiModelProperty(value = "是否删除 0:删除, 1:未删除")
@TableField(value = "state", fill = FieldFill.INSERT)
private Integer state;
}
package com.yizhi.application.domain;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 学员经验池
* </p>
*
* @author dingxiaowei123
* @since 2018-11-12
*/
@Data
@ApiModel(value = "StudentExperiencePoolVo", description = "学员经验池")
@TableName("student_experience_pool")
public class StudentExperiencePool {
@SuppressWarnings("unused")
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键ID ")
private Long id;
@ApiModelProperty(value = "经验池ID")
@TableField("experience_pool_id")
private Long experiencePoolId;
@ApiModelProperty(value = "用户ID")
@TableField("account_id")
private Long accountId;
@ApiModelProperty(value = "批次号")
@TableField("batch_no")
private String batchNo;
@ApiModelProperty(value = "登录序号(第几个登录的)")
private Integer num;
@ApiModelProperty(value = "步数")
private Integer step;
@ApiModelProperty(value = "座右铭")
private String motto;
@ApiModelProperty(value = "创建时间")
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
@ApiModelProperty(value = "创建人ID")
@TableField(value = "create_by_id", fill = FieldFill.INSERT)
private Long createById;
@ApiModelProperty(value = "创建人名字")
@TableField(value = "create_by_name", fill = FieldFill.INSERT)
private String createByName;
@ApiModelProperty(value = "修改时间")
@TableField(value = "update_time", fill = FieldFill.INSERT)
private Date updateTime;
@ApiModelProperty(value = "修改人ID")
@TableField(value = "update_by_id", fill = FieldFill.INSERT)
private Long updateById;
@ApiModelProperty(value = "修改人名字")
@TableField(value = "update_by_name", fill = FieldFill.INSERT)
private String updateByName;
}
package com.yizhi.application.listener;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.course.application.feign.RecordeClient;
import com.yizhi.application.constant.PoolConstant;
import com.yizhi.application.domain.ExperienceRecord;
import com.yizhi.application.domain.StudentExperience;
import com.yizhi.application.redis.RedisUtils;
import com.yizhi.application.service.IExperienceRecordService;
import com.yizhi.application.service.IStudentExperienceService;
import com.yizhi.custom.api.vo.custom.ExamRuleListVo;
import com.yizhi.custom.api.vo.custom.ExperiencePoolExamRuleVo;
import com.yizhi.custom.api.vo.custom.ExperiencePoolRuleVo;
import com.yizhi.point.application.vo.PointParamVO;
import com.yizhi.system.application.system.remote.AccountClient;
import com.yizhi.system.application.vo.AccountVO;
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.Date;
import java.util.List;
@Component
@Transactional
public class ExperienceListener {
private static final Logger LOGGER = LoggerFactory.getLogger(ExperienceListener.class);
@Autowired
private RedisUtils redisUtils;
@Autowired
private IdGenerator idGenerator;
@Autowired
private IStudentExperienceService studentExperienceService;
@Autowired
private RecordeClient recordeClient;
@Autowired
private IExperienceRecordService experienceRecordService;
@Autowired
private AccountClient accountClient;
/*static {
RedissonManager.init(null, "1");
}*/
@RabbitListener(queues = "experienceCourse")
public void processCourse(String pointId) {
LOGGER.info("------------处理消息course-----------------");
handExperience(pointId, PoolConstant.COURSETYPE);
}
@RabbitListener(queues = "experienceResearch")
public void processResearch(String pointId) {
LOGGER.info("------------处理消息research-----------------");
handExperience(pointId, PoolConstant.RESEARCHTYPE);
}
@RabbitListener(queues = "experienceExam")
public void processExam(String pointId) {
LOGGER.info("------------处理消息exam-----------------");
handExperience(pointId, PoolConstant.EXAMTYPE);
}
@RabbitListener(queues = "experienceVote")
public void processVote(String pointId) {
LOGGER.info("------------处理消息vote-----------------");
handExperience(pointId, PoolConstant.VOTETYPE);
}
@RabbitListener(queues = "experienceAssignment")
public void processAssignment(String pointId) {
LOGGER.info("------------处理消息vote-----------------");
handExperience(pointId, PoolConstant.ASSIGNMENTTYPE);
}
//处理经验(按设定值)
public boolean handExperience(String pointId, Integer type) {
PointParamVO vo = null;
try {
if (null == pointId) {
LOGGER.info("积分MQId为空");
return false;
}
vo = (PointParamVO) redisUtils.get(pointId);
if (vo == null) {
LOGGER.info("消息ID{}获取不到缓存信息");
return false;
}
LOGGER.info("开始处理消息ID{},业务ID{} 的经验", pointId, vo.getSourceId());
Long activityId = null;
//如果是课程发放经验,先取courseId(按章节发送的消息),没有再取sourseId(按课程发送的消息)
if (type.equals(PoolConstant.COURSETYPE)) {
if (null != vo.getCourseId()) {
activityId = vo.getCourseId();
} else {
activityId = vo.getSourceId();
}
} else {
activityId = vo.getSourceId();
}
Long accountId = vo.getAccountId();
Long compantyId = vo.getCompanyId();
Long siteId = vo.getSiteId();
if (type.equals(PoolConstant.COURSETYPE)) {
LOGGER.info("*************portRule" + vo.getPortRule());
if (vo.getPortRule() == 2 || vo.getPortRule() == 3) {
try {
//睡眠5s
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Long isFinished = recordeClient.getCourseFinished(accountId, vo.getSourceId());
LOGGER.info("isFinished" + isFinished);
if (isFinished == 0) {
LOGGER.info("课程{}未完成,不能发放经验", vo.getSourceId());
return false;
} else {
activityId = isFinished;
}
}
AccountVO accountVO = accountClient.findById(accountId);
if (null != accountVO) {
vo.setOrgId(accountVO.getOrgId());
}
}
//如果是考试
if (type.equals(PoolConstant.EXAMTYPE) || type.equals(PoolConstant.ASSIGNMENTTYPE)) {
List<ExperiencePoolExamRuleVo> examRuleVoList = studentExperienceService.getExamRules(activityId, compantyId, siteId, accountId, type);
if (!CollectionUtils.isEmpty(examRuleVoList)) {
for (ExperiencePoolExamRuleVo examRuleVo : examRuleVoList) {
//按设定值发放跟其他活动一样
if (examRuleVo.getExperienceType() == 1) {
ExperiencePoolRuleVo experiencePoolRuleVo = new ExperiencePoolRuleVo();
experiencePoolRuleVo.setExperiencePoolId(examRuleVo.getExperiencePoolId());
experiencePoolRuleVo.setType(examRuleVo.getType());
experiencePoolRuleVo.setBizId(examRuleVo.getBizId());
experiencePoolRuleVo.setBizName(examRuleVo.getBizName());
experiencePoolRuleVo.setExperience(examRuleVo.getRuleList().get(0).getExperience());
addExperience(experiencePoolRuleVo, vo, type);
} else {
//按考试成绩发放
addScoreExperience(examRuleVo, vo, type);
}
}
} else {
LOGGER.error("该站点未找到{}的经验发放规则", activityId);
}
} else {
List<ExperiencePoolRuleVo> ruleVoList = studentExperienceService.getRules(activityId, compantyId, siteId, accountId);
if (!CollectionUtils.isEmpty(ruleVoList)) {
for (ExperiencePoolRuleVo ruleVo : ruleVoList) {
addExperience(ruleVo, vo, type);
}
return true;
} else {
LOGGER.error("该站点未找到{}的经验发放规则", activityId);
}
}
} catch (Exception e) {
LOGGER.error("发放经验异常, 活动ID{}", e);
e.printStackTrace();
}
return false;
}
//按设定值发放经验
public boolean addExperience(ExperiencePoolRuleVo ruleVo, PointParamVO vo, Integer type) {
Long bizId = ruleVo.getBizId();
Long poolId = ruleVo.getExperiencePoolId();
String bizName = ruleVo.getBizName();
ExperienceRecord experienceRecord = new ExperienceRecord();
experienceRecord.setExperiencePoolId(poolId);
experienceRecord.setActivityType(type);
experienceRecord.setActivityId(bizId);
experienceRecord.setAccountId(vo.getAccountId());
EntityWrapper<ExperienceRecord> entityWrapper = new EntityWrapper<>(experienceRecord);
ExperienceRecord experienceRecord1 = experienceRecordService.selectOne(entityWrapper);
if (null != experienceRecord1) {
//已经发放经验的查看记录,判断是否补发经验
if (experienceRecord1.getExperience() >= ruleVo.getExperience()) {
LOGGER.info("经验池{}已发放经验,无需补发", ruleVo.getExperiencePoolId());
} else {
Long oldExperience = Long.valueOf(experienceRecord1.getExperience());
experienceRecord1.setExperience(Math.toIntExact(ruleVo.getExperience()));
experienceRecord1.setUpdateTime(new Date());
experienceRecord1.setUpdateById(vo.getAccountId());
experienceRecord1.setUpdateByName(vo.getAccountName() == null ? "" : vo.getAccountName());
experienceRecordService.updateById(experienceRecord1);
//学生经验表插入补发经验数据
StudentExperience studentExperience = new StudentExperience();
studentExperience.setExperiencePoolId(poolId);
studentExperience.setAccountId(vo.getAccountId());
studentExperience.setAccountName(vo.getAccountName() == null ? "" : vo.getAccountName());
studentExperience.setType(type);
studentExperience.setActivityId(bizId);
studentExperience.setActivityName(bizName);
studentExperience.setCompanyId(vo.getCompanyId());
studentExperience.setSiteId(vo.getSiteId());
studentExperience.setOrgId(vo.getOrgId());
studentExperience.setExperience(ruleVo.getExperience() - oldExperience);
studentExperience.setCreateById(vo.getAccountId());
studentExperience.setCreateTime(new Date());
studentExperience.setCreateByName(vo.getAccountName() == null ? "" : vo.getAccountName());
studentExperienceService.insertStudentExperience(studentExperience);
LOGGER.info("活动{}已发放经验,补发经验", vo.getActivityName());
}
} else {
//未发放经验的直接发放
experienceRecord.setCreateTime(new Date());
experienceRecord.setCreateById(vo.getAccountId());
experienceRecord.setCreateByName(vo.getAccountName() == null ? "" : vo.getAccountName());
experienceRecord.setActivityName(ruleVo.getBizName());
experienceRecord.setExperience(Math.toIntExact(ruleVo.getExperience()));
experienceRecordService.insertRecord(experienceRecord);
//学员经验表插入发放数据
StudentExperience studentExperience = new StudentExperience();
studentExperience.setExperiencePoolId(poolId);
studentExperience.setAccountId(vo.getAccountId());
studentExperience.setAccountName(vo.getAccountName());
studentExperience.setCompanyId(vo.getCompanyId());
studentExperience.setSiteId(vo.getSiteId());
studentExperience.setOrgId(vo.getOrgId());
studentExperience.setType(type);
studentExperience.setActivityId(bizId);
studentExperience.setActivityName(bizName);
studentExperience.setExperience(ruleVo.getExperience());
studentExperience.setCreateById(vo.getAccountId());
studentExperience.setCreateTime(new Date());
studentExperience.setCreateByName(vo.getAccountName() == null ? "" : vo.getAccountName());
studentExperienceService.insertStudentExperience(studentExperience);
LOGGER.info("活动{}发放经验完成", vo.getActivityName());
}
return true;
}
//按考试分数发放经验
public boolean addScoreExperience(ExperiencePoolExamRuleVo examRuleVo, PointParamVO vo, Integer type) {
Long bizId = examRuleVo.getBizId();
Long poolId = examRuleVo.getExperiencePoolId();
String bizName = examRuleVo.getBizName();
Integer score = vo.getScore();
LOGGER.info("**************************score", score);
LOGGER.info("**************************score:{}", score);
Long experience = null;
List<ExamRuleListVo> ruleList = examRuleVo.getRuleList();
if (examRuleVo.getExperienceType() == 2) {
if (!CollectionUtils.isEmpty(ruleList)) {
for (ExamRuleListVo examRuleListVo : ruleList) {
if (score >= examRuleListVo.getMinScore() && null != examRuleListVo.getMaxScore() && score < examRuleListVo.getMaxScore()) {
experience = examRuleListVo.getExperience();
} else if (score >= examRuleListVo.getMinScore() && null != examRuleListVo.getMaxScore() && score > examRuleListVo.getMaxScore()) {
continue;
} else if (score >= examRuleListVo.getMinScore() && null == examRuleListVo.getMaxScore()) {
experience = examRuleListVo.getExperience();
}
}
}
} else {
if (!CollectionUtils.isEmpty(ruleList)) {
Integer times = ruleList.get(0).getTimes();
experience = Long.valueOf(score * times);
}
}
ExperienceRecord experienceRecord = new ExperienceRecord();
experienceRecord.setExperiencePoolId(poolId);
experienceRecord.setActivityType(type);
experienceRecord.setActivityId(bizId);
experienceRecord.setAccountId(vo.getAccountId());
EntityWrapper<ExperienceRecord> entityWrapper = new EntityWrapper<>(experienceRecord);
ExperienceRecord experienceRecord1 = experienceRecordService.selectOne(entityWrapper);
if (null == experience) {
return false;
}
if (null != experienceRecord1) {
//已经发放经验的查看记录,判断是否补发经验
if (experienceRecord1.getExperience() >= experience) {
LOGGER.info("经验池{}已发放经验,无需补发", poolId);
} else {
Integer oldExperience = experienceRecord1.getExperience();
experienceRecord1.setExperience(Math.toIntExact(experience));
experienceRecord1.setUpdateTime(new Date());
experienceRecord1.setUpdateById(vo.getAccountId() == null ? 0 : vo.getAccountId());
experienceRecord1.setUpdateByName(vo.getAccountName() == null ? "" : vo.getAccountName());
experienceRecordService.updateById(experienceRecord1);
//学生经验表插入补发经验数据
StudentExperience studentExperience = new StudentExperience();
studentExperience.setExperiencePoolId(poolId);
studentExperience.setAccountId(vo.getAccountId());
studentExperience.setAccountName(vo.getAccountName() == null ? "" : vo.getAccountName());
studentExperience.setType(type);
studentExperience.setActivityId(bizId);
studentExperience.setActivityName(bizName);
studentExperience.setExperience(experience - Long.valueOf(oldExperience));
studentExperience.setCreateById(vo.getAccountId() == null ? 0 : vo.getAccountId());
studentExperience.setCreateTime(new Date());
studentExperience.setCreateByName(vo.getAccountName() == null ? "" : vo.getAccountName());
studentExperienceService.insertStudentExperience(studentExperience);
LOGGER.info("考试{}已发放经验,补发经验", vo.getActivityName());
}
} else {
//未发放经验的直接发放
experienceRecord.setCreateTime(new Date());
experienceRecord.setCreateById(vo.getAccountId() == null ? 0 : vo.getAccountId());
experienceRecord.setCreateByName(vo.getAccountName() == null ? "" : vo.getAccountName());
experienceRecord.setActivityType(type);
experienceRecord.setActivityName(vo.getActivityName() == null ? "" : vo.getActivityName());
experienceRecord.setExperience(Math.toIntExact(experience));
experienceRecordService.insertRecord(experienceRecord);
//学员经验表插入发放数据
StudentExperience studentExperience = new StudentExperience();
studentExperience.setExperiencePoolId(poolId);
studentExperience.setAccountId(vo.getAccountId());
studentExperience.setAccountName(vo.getAccountName() == null ? "" : vo.getAccountName());
studentExperience.setCompanyId(vo.getCompanyId());
studentExperience.setSiteId(vo.getSiteId());
studentExperience.setOrgId(vo.getOrgId());
studentExperience.setType(type);
studentExperience.setActivityId(bizId);
studentExperience.setActivityName(bizName);
studentExperience.setExperience(experience);
studentExperience.setCreateById(vo.getAccountId());
studentExperience.setCreateTime(new Date());
studentExperience.setCreateByName(vo.getAccountName() == null ? "" : vo.getAccountName());
studentExperienceService.insertStudentExperience(studentExperience);
LOGGER.info("考试{}发放经验完成", vo.getActivityName());
}
return true;
}
}
package com.yizhi.application.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.application.domain.CodePackageManage;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author ding
* @since 2018-11-06
*/
public interface CodePackageManageMapper extends BaseMapper<CodePackageManage> {
List<CodePackageManage> getCodePackageManageList(@Param("companyId") Long companyId,@Param("siteId") Long siteId,@Param("orgIds") List<Long> orgIds,
Page<CodePackageManage> page);
}
package com.yizhi.application.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.yizhi.application.domain.ExperiencePoolAuthorize;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* <p>
* Mapper 接口
* </p>
*
* @author ding
* @since 2018-11-06
*/
public interface ExperiencePoolAuthorizeMapper extends BaseMapper<ExperiencePoolAuthorize> {
List<Map<String, Object>> getListMap(@Param("experiencePoolId") Long experiencePoolId);
ExperiencePoolAuthorize getExperiencePoolAuthorizeByPoolIdAndAccountId(@Param("poolId") Long poolId, @Param("accountId") Long accountId);
}
package com.yizhi.application.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.yizhi.application.domain.ExperiencePoolLevel;
/**
* <p>
* Mapper 接口
* </p>
*
* @author ding
* @since 2018-11-06
*/
public interface ExperiencePoolLevelMapper extends BaseMapper<ExperiencePoolLevel> {
}
package com.yizhi.application.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.custom.api.param.ExperiencePoolParam;
import com.yizhi.custom.api.vo.custom.ExperiencePoolReportVo;
import com.yizhi.application.domain.ExperiencePool;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* 自定义项目经验池主体表 Mapper 接口
* </p>
*
* @author ding
* @since 2018-11-06
*/
public interface ExperiencePoolMapper extends BaseMapper<ExperiencePool> {
List<ExperiencePool> getExperiencePoolList(@Param("param") ExperiencePoolParam param, Page<ExperiencePool> page);
List<ExperiencePoolReportVo> getPoolReportList(@Param("poolName") String poolName,
@Param("accountIds") List<Long> accountIds,
@Param("companyId") Long companyId,
@Param("siteId") Long siteId,
Page<ExperiencePoolReportVo> page);
ExperiencePool selectByPoolId(@Param("poolId") Long poolId);
}
package com.yizhi.application.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.yizhi.application.domain.ExperiencePoolProject;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author ding
* @since 2018-11-06
*/
public interface ExperiencePoolProjectMapper extends BaseMapper<ExperiencePoolProject> {
List<ExperiencePoolProject> getExperiencePoolProjectList(@Param("experiencePoolId") Long experiencePoolId);
}
package com.yizhi.application.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.yizhi.application.domain.ExperienceRecord;
/**
* <p>
* 经验发放记录表 Mapper 接口
* </p>
*
* @author dingxiaowei123
* @since 2019-01-02
*/
public interface ExperienceRecordMapper extends BaseMapper<ExperienceRecord> {
}
package com.yizhi.application.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.application.domain.ExperiencePoolLevel;
import com.yizhi.application.domain.StudentExperiencePool;
import com.yizhi.custom.api.vo.custom.MyExperienceEventsVo;
import com.yizhi.custom.api.vo.custom.MyExperienceLevelVo;
import com.yizhi.custom.api.vo.custom.MyExperiencePoolVo;
import com.yizhi.custom.api.vo.custom.MyExperienceRankingVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* <p>
* 我的经验
* </p>
*
* @author ding
* @since 2018-11-06
*/
public interface MyExperienceMapper extends BaseMapper<StudentExperiencePool> {
/**
* 获取个人经验和等级
*
* @param poolId
* @param accountId
* @param sort
* @return
*/
MyExperienceLevelVo getMyExperiencePoolAndLevel(@Param("poolId") Long poolId, @Param("accountId") Long accountId);
/**
* 获取个人排名
*
* @param poolId
* @param experience
* @param batchNo
* @param group
* @return
*/
Integer getMyExperienceRanking(@Param("poolId") Long poolId, @Param("experience") Integer experience, @Param("group") String group,@Param("batchNo") String batchNo);
/**
* 个人经验统计
*
* @param poolId
* @param accountId
* @param sort
* @return
*/
MyExperienceLevelVo getMyExperiencePool(@Param("poolId") Long poolId, @Param("accountId") Long accountId);
/**
* 获取单个经验等级
*
* @param poolId
* @param experience
* @return
*/
ExperiencePoolLevel getMyExperienceLevel(@Param("poolId") Long poolId, @Param("experience") Integer experience);
/**
* 经验排行榜
*
* @param poolId
* @param group
* @param batchNo
* @param pageNo
* @param pageSize
* @return
*/
List<MyExperienceRankingVo> getMyExperienceRankings(@Param("poolId") Long poolId, @Param("group") String group, @Param("batchNo") String batchNo,
@Param("pageSize") Integer pageSize, @Param("pageNo") Integer pageNo);
/**
* 经验排行榜页数统计
*
* @param poolId
* @param group
* @param batchNo
* @return
*/
Integer getMyExperienceRankingsPageTotal(@Param("poolId") Long poolId, @Param("group") String group, @Param("batchNo") String batchNo);
/**
* 个人经验明细
*
* @param poolId
* @param accountId
* @param rowBounds
* @return
*/
List<MyExperienceEventsVo> getMyExperienceDtl(@Param("poolId") Long poolId, @Param("accountId") Long accountId,
@Param("page") Page<MyExperienceEventsVo> page);
/**
* 经验等级
*
* @param poolId
* @return
*/
List<MyExperienceLevelVo> getMyExperienceLevels(@Param("poolId") Long poolId);
/**
* 我的经验池信息
*
* @param poolId
* @param accountId
* @return
*/
StudentExperiencePool getMyExperiencePoolInfo(@Param("poolId") Long poolId, @Param("accountId") Long accountId);
/**
* 我的经验池登录信息
*
* @param poolId
* @param accountId
* @return
*/
MyExperiencePoolVo getMyExperienceLogin(@Param("poolId") Long poolId, @Param("accountId") Long accountId);
/**
* 获取最大登录人数
*
* @param poolId
* @return
*/
Integer getMaxLoginCount(@Param("poolId") Long poolId);
List<MyExperienceEventsVo> getMyExperience(@Param("poolId") Long poolId, @Param("accountId") Long accountId);
Map<String, Object> getBatchGroup(@Param("accountId") Long accountId, @Param("poolId") Long poolId);
}
package com.yizhi.application.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.yizhi.application.domain.Product;
/**
* <p>
* Mapper 接口
* </p>
*
* @author dingxiaowei123
* @since 2019-09-19
*/
public interface ProductMapper extends BaseMapper<Product> {
}
package com.yizhi.application.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.yizhi.application.domain.ProjectActivityExperience;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author ding
* @since 2018-11-06
*/
public interface ProjectActivityExperienceMapper extends BaseMapper<ProjectActivityExperience> {
List<ProjectActivityExperience> getActivityExperienceList(@Param("poolId") Long poolId);
}
package com.yizhi.application.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.yizhi.application.domain.ProjectActivityExperienceSet;
import org.apache.ibatis.annotations.Param;
/**
* <p>
* Mapper 接口
* </p>
*
* @author ding
* @since 2018-11-06
*/
public interface ProjectActivityExperienceSetMapper extends BaseMapper<ProjectActivityExperienceSet> {
Integer getMaxScore(@Param("activityExperienceId") Long activityExperienceId, @Param("minScore") Integer minScore);
}
package com.yizhi.application.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.application.domain.ProjectActivityExperience;
import com.yizhi.application.domain.StudentExperience;
import com.yizhi.custom.api.vo.custom.ExperienceOrgRankingVO;
import com.yizhi.custom.api.vo.custom.ExperiencePoolReportExportVo;
import com.yizhi.custom.api.vo.custom.ExperiencePoolRuleVo;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
/**
* <p>
* 项目关联活动经验值表 Mapper 接口
* </p>
*
* @author dingxiaowei123
* @since 2018-11-12
*/
public interface StudentExperienceMapper extends BaseMapper<StudentExperience> {
List<ExperiencePoolReportExportVo> getReportViewList(@Param("poolId") Long poolId, @Param("ids") List<Long> ids, Page<ExperiencePoolReportExportVo> page);
List<ExperiencePoolRuleVo> getRules(@Param("activityId") Long activityId, @Param("compantyId") Long compantyId, @Param("siteId") Long siteId);
ProjectActivityExperience getExamRules(@Param("poolId") Long poolId, @Param("activityId") Long activityId);
/**
* 自定义项目按部门经验排行
*
* @param poolId
* @param page
* @return
*/
List<ExperienceOrgRankingVO> getOrgRankings(@Param("poolId") Long poolId, Page<ExperienceOrgRankingVO> page);
/**
* 自定义项目按部门获取单个部门排名
*
* @param poolId
* @param totalExperience
* @return
*/
Integer getOrgRanking(@Param("poolId") Long poolId, @Param("totalExperience") Double totalExperience);
/**
* 获取按组别排名
*
* @param poolId
* @param page
* @return
*/
List<ExperienceOrgRankingVO> getGroupRankings(Long poolId, Page<ExperienceOrgRankingVO> page);
/**
* 获取按组别排名每个组别名次
*
* @param poolId
* @param totalExperience
* @return
*/
Integer getGroupRanking(@Param("poolId") Long poolId, @Param("totalExperience") Double totalExperience);
/**
* 获得按组别排名,可导入外部经验
*
* @param poolId
* @param page
* @return
*/
List<ExperienceOrgRankingVO> getGroupRankingsWithImport(@Param("poolId") Long poolId, Page<ExperienceOrgRankingVO> page);
/**
* 经验池报表查看个人经验明细
*
* @param poolId
* @param accountId
* @param state
* @param page
* @return
*/
List<ExperiencePoolReportExportVo> viewAccountDetails(@Param("poolId") Long poolId,
@Param("accountId") Long accountId,
@Param("state") Integer state, Page<ExperiencePoolReportExportVo> page);
/**
* 获取当页明细开始的总分
* @param poolId
* @param accountId
* @param startIndex
* @param endIndex
* @return
*/
Long getTotalExperience(@Param("poolId") Long poolId,
@Param("accountId") Long accountId,
@Param("startIndex") Integer startIndex,
@Param("endIndex") Integer endIndex);
/**
* 所有人经验变更明细/阶段明细/阶段消费明细
* @param poolId
* @param ids
* @param startTime
* @param endTime
* @param state
* @return
*/
List<ExperiencePoolReportExportVo> viewAllDetails(@Param("poolId") Long poolId,
@Param("ids") List<Long> ids,
@Param("startTime") String startTime,
@Param("endTime") String endTime,
@Param("state") Integer state);
/**
* 获取阶段消耗总值,增加总值
* @param accountIds
* @param poolId
* @param startTime
* @param endTime
* @return
*/
@MapKey("accountId")
Map<Long, Map<String, BigDecimal>> getPurchaseAndIncreaseExperienceTotal(@Param("accountIds") List<Long> accountIds,
@Param("poolId") Long poolId,
@Param("startTime") String startTime,
@Param("endTime") String endTime);
/**
* 获得某个用户某个经验池的总经验
* @param poolId
* @param accountId
* @return
*/
Long getAccountTotalExperience(@Param("poolId") Long poolId,@Param("accountId") Long accountId);
}
//package com.yizhi.application.redis;
//
//import com.fasterxml.jackson.annotation.JsonAutoDetect;
//import com.fasterxml.jackson.annotation.PropertyAccessor;
//import com.fasterxml.jackson.databind.ObjectMapper;
//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 java.lang.reflect.Method;
//
///**
// * 缓存管理(注解用)
// */
//@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 org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import java.util.concurrent.TimeUnit;
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 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;
import java.io.Serializable;
import java.util.Set;
import java.util.concurrent.TimeUnit;
/**
* 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.service;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.application.domain.CodePackageManage;
import com.yizhi.custom.api.param.ExperiencePoolParam;
/**
* <p>
* 服务类
* </p>
*
* @author ding
* @since 2018-11-06
*/
public interface ICodePackageManageService extends IService<CodePackageManage> {
Page<CodePackageManage> getCodePackageManageList(ExperiencePoolParam experiencePoolParam);
}
package com.yizhi.application.service;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.application.domain.ExperiencePoolAuthorize;
import java.util.List;
import java.util.Map;
/**
* <p>
* 服务类
* </p>
*
* @author ding
* @since 2018-11-06
*/
public interface IExperiencePoolAuthorizeService extends IService<ExperiencePoolAuthorize> {
boolean insertAuthorizeList(List<ExperiencePoolAuthorize> poolAuthorizeList);
List<Map<String, Object>> getListMap(Long experiencePoolId);
}
package com.yizhi.application.service;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.application.domain.ExperiencePoolLevel;
/**
* <p>
* 服务类
* </p>
*
* @author ding
* @since 2018-11-06
*/
public interface IExperiencePoolLevelService extends IService<ExperiencePoolLevel> {
}
package com.yizhi.application.service;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.application.domain.ExperiencePoolProject;
import com.yizhi.application.domain.ProjectActivityExperience;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author ding
* @since 2018-11-06
*/
public interface IExperiencePoolProjectService extends IService<ExperiencePoolProject> {
List<ProjectActivityExperience> saveList(Long id, List<ExperiencePoolProject> poolProjects);
}
package com.yizhi.application.service;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.application.domain.ExperiencePool;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.custom.api.param.ExperiencePoolParam;
import com.yizhi.custom.api.vo.custom.ExperiencePoolVoAutorizeAndProjectVO;
import com.yizhi.custom.api.vo.custom.ExperiencePoolReportExportVo;
import com.yizhi.custom.api.vo.custom.ExperiencePoolReportVo;
import java.util.List;
import java.util.Map;
/**
* <p>
* 服务类
* </p>
*
* @author ding
* @since 2018-11-06
*/
public interface IExperiencePoolService extends IService<ExperiencePool> {
Page<ExperiencePool> getExperiencePoolList(ExperiencePoolParam param);
ExperiencePoolVoAutorizeAndProjectVO getExperiencePoolView(Long poolId);
Map<String, Object> insertPoolAuthorizeAndProject(ExperiencePoolVoAutorizeAndProjectVO poolAutorizeAndProjectVO);
boolean complete(Long poolId);
Page<ExperiencePoolReportVo> getPoolReportList(String poolName, Integer pageNo, Integer pageSize, RequestContext requestContext);
Page<ExperiencePoolReportExportVo> getReportViewList(Long poolId, String key, String orgName, Integer pageNo, Integer pageSize, Integer type, String startTime, String endTime, Long siteId, RequestContext requestContext);
Page<ExperiencePoolReportExportVo> viewAccountDetails(Long poolId, Long accountId, Integer state, Integer pageNo, Integer pageSize);
List<ExperiencePoolReportExportVo> viewAllDetails(Long poolId, String startTime, String endTime, String orgName, String accountName, Integer state, RequestContext res);
}
package com.yizhi.application.service;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.application.domain.ExperienceRecord;
/**
* <p>
* 经验发放记录表 服务类
* </p>
*
* @author dingxiaowei123
* @since 2019-01-02
*/
public interface IExperienceRecordService extends IService<ExperienceRecord> {
void insertRecord(ExperienceRecord experienceRecord);
}
package com.yizhi.application.service;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.application.domain.Product;
/**
* <p>
* 服务类
* </p>
*
* @author dingxiaowei123
* @since 2019-09-19
*/
public interface IProductService extends IService<Product> {
}
package com.yizhi.application.service;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.application.domain.ExperiencePoolProject;
import com.yizhi.application.domain.ProjectActivityExperience;
import com.yizhi.custom.api.vo.custom.ExperienceRulesVO;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author ding
* @since 2018-11-06
*/
public interface IProjectActivityExperienceService extends IService<ProjectActivityExperience> {
List<ProjectActivityExperience> saveList(List<Long> deleteList, List<ExperiencePoolProject> poolProjectList);
boolean insertList(List<ProjectActivityExperience> projectActivityExperienceList);
List<ExperienceRulesVO> getExperienceRules(Long poolId);
}
package com.yizhi.application.service;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.application.domain.ProjectActivityExperienceSet;
import java.util.Map;
/**
* <p>
* 服务类
* </p>
*
* @author ding
* @since 2018-11-06
*/
public interface IProjectActivityExperienceSetService extends IService<ProjectActivityExperienceSet> {
Map<String, Object> getSets(Long activityExperienceId, Integer setType);
Map<String, Object> insertSet(Long activityExperienceSetId, Long activityExperienceId, Integer setType, Integer minScore, Long experience);
Map<String, Object> insertSetWithScore(Long activityExperienceSetId, Long activityExperienceId, Integer setType, Integer times);
}
package com.yizhi.application.service;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.application.domain.StudentExperience;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.custom.api.vo.custom.ExperienceOrgRankingVO;
import com.yizhi.custom.api.vo.custom.ExperiencePoolExamRuleVo;
import com.yizhi.custom.api.vo.custom.ExperiencePoolRuleVo;
import java.util.List;
/**
* <p>
* 项目关联活动经验值表 服务类
* </p>
*
* @author dingxiaowei123
* @since 2018-11-12`
*/
public interface IStudentExperienceService extends IService<StudentExperience> {
boolean insertStudentExperienceList(List<StudentExperience> studentExperienceList);
List<ExperiencePoolRuleVo> getRules(Long activityId, Long compantyId, Long siteId, Long accountId);
void insertStudentExperience(StudentExperience studentExperience);
List<ExperiencePoolExamRuleVo> getExamRules(Long activityId, Long compantyId, Long siteId, Long accountId, Integer type);
boolean pushStudentExperience(Long experiencePoolId, Long activityId, String activityName, Integer activityType, List<Long> accountIds, RequestContext requestContext);
/**
* 自定义项目按组织经验排行
*
* @param poolId
* @param pageNo
* @param pageSize
* @param type
* @return
*/
Page<ExperienceOrgRankingVO> getOrgRanking(Long poolId, Integer pageNo, Integer pageSize, Integer type);
/**
* 获得某个用户某个经验池的总经验
*
* @param poolId
* @param accountId
* @return
*/
Long getTotalExperience(Long poolId, Long accountId);
}
package com.yizhi.application.service.impl;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.application.domain.CodePackageManage;
import com.yizhi.application.mapper.CodePackageManageMapper;
import com.yizhi.application.service.ICodePackageManageService;
import com.yizhi.custom.api.param.ExperiencePoolParam;
import com.yizhi.application.orm.hierarchicalauthorization.HQueryUtil;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author ding
* @since 2018-11-06
*/
@Service
public class CodePackageManageServiceImpl extends ServiceImpl<CodePackageManageMapper, CodePackageManage> implements ICodePackageManageService {
@Autowired
private CodePackageManageMapper packageManageMapper;
@Override
public Page<CodePackageManage> getCodePackageManageList(ExperiencePoolParam experiencePoolParam) {
Long companyId = experiencePoolParam.getCompanyId();
Long siteId = experiencePoolParam.getSiteId();
List<Long> orgIds = experiencePoolParam.getOrgIds();
Integer pageNo = experiencePoolParam.getPageNo();
Integer pageSize = experiencePoolParam.getPageSize();
Page<CodePackageManage> page = new Page<>(pageNo, pageSize);
List<CodePackageManage> list = new ArrayList<>();
HQueryUtil.startHQ(CodePackageManage.class);
list = packageManageMapper.getCodePackageManageList(companyId, siteId, orgIds, page);
if (CollectionUtils.isNotEmpty(list)) {
page.setRecords(list);
}
return page;
}
}
package com.yizhi.application.service.impl;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.application.domain.ExperiencePoolAuthorize;
import com.yizhi.application.mapper.ExperiencePoolAuthorizeMapper;
import com.yizhi.application.service.IExperiencePoolAuthorizeService;
import com.yizhi.application.orm.id.IdGenerator;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* <p>
* 服务实现类
* </p>
*
* @author ding
* @since 2018-11-06
*/
@Service
public class ExperiencePoolAuthorizeServiceImpl extends ServiceImpl<ExperiencePoolAuthorizeMapper, ExperiencePoolAuthorize> implements IExperiencePoolAuthorizeService {
@Autowired
private IdGenerator idGenerator;
@Autowired
private ExperiencePoolAuthorizeMapper poolAuthorizeMapper;
@Override
public boolean insertAuthorizeList(List<ExperiencePoolAuthorize> poolAuthorizeList) {
if (CollectionUtils.isNotEmpty(poolAuthorizeList)) {
//先把原有列表范围清空
ExperiencePoolAuthorize experiencePoolAuthorize = new ExperiencePoolAuthorize();
experiencePoolAuthorize.setExperienceId(poolAuthorizeList.get(0).getExperienceId());
EntityWrapper<ExperiencePoolAuthorize> entityWrapper = new EntityWrapper<>(experiencePoolAuthorize);
this.delete(entityWrapper);
//新列表重新入库
for (ExperiencePoolAuthorize poolAuthorize : poolAuthorizeList) {
poolAuthorize.setId(idGenerator.generate());
}
return this.insertBatch(poolAuthorizeList);
}
return true;
}
@Override
public List<Map<String, Object>> getListMap(Long experiencePoolId) {
return poolAuthorizeMapper.getListMap(experiencePoolId);
}
}
package com.yizhi.application.service.impl;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.application.domain.ExperiencePoolLevel;
import com.yizhi.application.mapper.ExperiencePoolLevelMapper;
import com.yizhi.application.service.IExperiencePoolLevelService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author ding
* @since 2018-11-06
*/
@Service
public class ExperiencePoolLevelServiceImpl extends ServiceImpl<ExperiencePoolLevelMapper, ExperiencePoolLevel> implements IExperiencePoolLevelService {
}
package com.yizhi.application.service.impl;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.application.domain.ExperiencePoolProject;
import com.yizhi.application.domain.ProjectActivityExperience;
import com.yizhi.application.mapper.ExperiencePoolProjectMapper;
import com.yizhi.application.service.IExperiencePoolProjectService;
import com.yizhi.application.service.IProjectActivityExperienceService;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.application.orm.id.IdGenerator;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* <p>
* 服务实现类
* </p>
*
* @author ding
* @since 2018-11-06
*/
@Service
public class ExperiencePoolProjectServiceImpl extends ServiceImpl<ExperiencePoolProjectMapper, ExperiencePoolProject> implements IExperiencePoolProjectService {
@Autowired
private IdGenerator idGenerator;
@Autowired
private IProjectActivityExperienceService activityExperienceService;
@Override
public List<ProjectActivityExperience> saveList(Long id, List<ExperiencePoolProject> poolProjects) {
List<ExperiencePoolProject> insertList = null;
List<Long> deleteList = null;
List<ExperiencePoolProject> oldList = null;
List<ProjectActivityExperience> activityExperienceList = null;
RequestContext res = ContextHolder.get();
if (CollectionUtils.isNotEmpty(poolProjects)) {
insertList = new ArrayList<>();
for (ExperiencePoolProject poolProject : poolProjects) {
//如果有id跳过
if (null != poolProject.getId()) {
continue;
}
//没有id新建
poolProject.setId(idGenerator.generate());
poolProject.setExperienceId(id);
poolProject.setCreateById(res.getAccountId());
poolProject.setCreateByName(res.getAccountFullName());
poolProject.setCreateTime(new Date());
insertList.add(poolProject);
}
//获取旧列表判断是否删除
ExperiencePoolProject experiencePoolProject = new ExperiencePoolProject();
experiencePoolProject.setExperienceId(id);
EntityWrapper<ExperiencePoolProject> entityWrapper = new EntityWrapper<>(experiencePoolProject);
oldList = this.selectList(entityWrapper);
if (CollectionUtils.isNotEmpty(oldList)) {
deleteList = new ArrayList<>();
List<Long> ids = poolProjects.stream().map(ExperiencePoolProject::getId).collect(Collectors.toList());
for (ExperiencePoolProject oldPoolProject : oldList) {
if (ids.contains(oldPoolProject.getId())) {
continue;
}
deleteList.add(oldPoolProject.getId());
}
}
//数据库删除已经删除的关联项目
if (CollectionUtils.isNotEmpty(deleteList)) {
this.deleteBatchIds(deleteList);
}
//新增数据入库
if (CollectionUtils.isNotEmpty(insertList)) {
this.insertBatch(insertList);
}
//入库关联项目活动经验
activityExperienceList = activityExperienceService.saveList(deleteList, poolProjects);
}
return activityExperienceList;
}
}
package com.yizhi.application.service.impl;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.application.domain.*;
import com.yizhi.application.mapper.*;
import com.yizhi.application.orm.hierarchicalauthorization.HQueryUtil;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.application.service.IExperiencePoolProjectService;
import com.yizhi.application.service.IExperiencePoolService;
import com.yizhi.application.service.IProjectActivityExperienceService;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.custom.api.param.ExperiencePoolParam;
import com.yizhi.custom.api.vo.custom.*;
import com.yizhi.custom.api.vo.domain.ExperiencePoolAuthorizeVo;
import com.yizhi.custom.api.vo.domain.ExperiencePoolProjectVo;
import com.yizhi.custom.api.vo.domain.ProjectActivityExperienceVo;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.system.application.constant.AuthzConstant;
import com.yizhi.system.application.system.remote.AccountClient;
import com.yizhi.system.application.system.remote.OrganizationClient;
import com.yizhi.system.application.system.remote.ReportClient;
import com.yizhi.system.application.vo.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
* 服务实现类
* </p>
*
* @author ding
* @since 2018-11-06
*/
@Service
public class ExperiencePoolServiceImpl extends ServiceImpl<ExperiencePoolMapper, ExperiencePool> implements IExperiencePoolService {
private static final Logger LOGGER = LoggerFactory.getLogger(ExperiencePoolServiceImpl.class);
@Autowired
private IdGenerator idGenerator;
@Autowired
private ExperiencePoolMapper poolMapper;
@Autowired
private ExperiencePoolAuthorizeMapper authorizeMapper;
@Autowired
private ExperiencePoolProjectMapper poolProjectMapper;
@Autowired
private IExperiencePoolProjectService poolProjectService;
@Autowired
private IProjectActivityExperienceService activityExperienceService;
@Autowired
private AccountClient accountClient;
@Autowired
private MyExperienceMapper myExperienceMapper;
@Autowired
private StudentExperienceMapper studentExperienceMapper;
@Autowired
private ReportClient reportClient;
@Autowired
private ExperiencePoolAuthorizeMapper poolAuthorizeMapper;
@Autowired
private OrganizationClient organizationClient;
@Override
public Page<ExperiencePool> getExperiencePoolList(ExperiencePoolParam param) {
Integer pageNo = param.getPageNo();
Integer pageSize = param.getPageSize();
Page<ExperiencePool> page = new Page<>(pageNo, pageSize);
HQueryUtil.startHQ(ExperiencePool.class);
List<ExperiencePool> list = poolMapper.getExperiencePoolList(param, page);
if (CollectionUtils.isNotEmpty(list)) {
page.setRecords(list);
}
return page;
}
@Override
public ExperiencePoolVoAutorizeAndProjectVO getExperiencePoolView(Long poolId) {
ExperiencePoolVoAutorizeAndProjectVO poolAutorizeAndProjectVO = new ExperiencePoolVoAutorizeAndProjectVO();
ExperiencePool experiencePool = null;
List<ExperiencePoolAuthorize> authorizeList = null;
List<ExperiencePoolProject> poolProjectList = null;
List<ProjectActivityExperience> activityExperienceList = null;
RequestContext res = ContextHolder.get();
//查找经验池主体以及可见范围,关联项目及活动经验,装入拓展类
experiencePool = poolMapper.selectById(poolId);
poolAutorizeAndProjectVO.setId(poolId);
poolAutorizeAndProjectVO.setExperiencePoolNo(experiencePool.getExperiencePoolNo());
poolAutorizeAndProjectVO.setExperiencePoolName(experiencePool.getExperiencePoolName());
if (experiencePool.getVisibleRange() != null) {
poolAutorizeAndProjectVO.setVisibleRange(experiencePool.getVisibleRange());
}
//如果是指定范围查出学员范围列表并装入拓展类
if (experiencePool.getVisibleRange().equals(2)) {
ExperiencePoolAuthorize experiencePoolAuthorize = new ExperiencePoolAuthorize();
experiencePoolAuthorize.setExperienceId(poolId);
EntityWrapper<ExperiencePoolAuthorize> entityWrapper = new EntityWrapper<>(experiencePoolAuthorize);
authorizeList = authorizeMapper.selectList(entityWrapper);
List<ExperiencePoolAuthorizeVo> en = new ArrayList<>();
if (CollectionUtils.isNotEmpty(authorizeList)) {
for (ExperiencePoolAuthorize e : authorizeList) {
ExperiencePoolAuthorizeVo ex = new ExperiencePoolAuthorizeVo();
BeanUtils.copyProperties(e, ex);
en.add(ex);
}
poolAutorizeAndProjectVO.setExperiencePoolAuthorizes(en);
}
}
//查找关联项目列表并装入拓展类
ExperiencePoolProject experiencePoolProject = new ExperiencePoolProject();
experiencePoolProject.setExperienceId(poolId);
EntityWrapper<ExperiencePoolProject> poolProjectEntityWrapper = new EntityWrapper<>(experiencePoolProject);
poolProjectEntityWrapper.orderBy("type", true);
poolProjectList = poolProjectMapper.selectList(poolProjectEntityWrapper);
List<ExperiencePoolProjectVo> ep = new ArrayList<>();
if (CollectionUtils.isNotEmpty(poolProjectList)) {
for (ExperiencePoolProject e : poolProjectList) {
ExperiencePoolProjectVo ex = new ExperiencePoolProjectVo();
BeanUtils.copyProperties(e, ex);
ep.add(ex);
}
poolAutorizeAndProjectVO.setPoolProjects(ep);
}
//查找关联项目活动经验列表并装入拓展类
return poolAutorizeAndProjectVO;
}
@Override
public Map<String, Object> insertPoolAuthorizeAndProject(ExperiencePoolVoAutorizeAndProjectVO poolAutorizeAndProjectVO) {
Map<String, Object> resultMap = new HashMap<>();
ExperiencePool experiencePool = null;
ExperiencePool experiencePool1 = new ExperiencePool();
experiencePool1.setExperiencePoolNo(poolAutorizeAndProjectVO.getExperiencePoolNo());
EntityWrapper<ExperiencePool> entityWrapper1 = new EntityWrapper<>(experiencePool1);
if (null != poolAutorizeAndProjectVO.getId()) {
if (!this.selectById(poolAutorizeAndProjectVO.getId()).getExperiencePoolNo().equals(poolAutorizeAndProjectVO.getExperiencePoolNo())
&& CollectionUtils.isNotEmpty(this.selectList(entityWrapper1))) {
resultMap.put("isOk", false);
return resultMap;
} else {
resultMap.put("isOk", true);
}
} else {
if (CollectionUtils.isNotEmpty(this.selectList(entityWrapper1))) {
resultMap.put("isOk", false);
return resultMap;
} else {
resultMap.put("isOk", true);
}
}
RequestContext res = ContextHolder.get();
List<ExperiencePoolAuthorize> authorizeList = null;
List<ExperiencePoolProject> poolProjectList = null;
List<ProjectActivityExperience> activityExperienceList = null;
Long id = null;
//判断为新建还是修改
if (null == poolAutorizeAndProjectVO.getId()) {
//新建入库
id = idGenerator.generate();
experiencePool = new ExperiencePool();
experiencePool.setId(id);
experiencePool.setCreateById(res.getAccountId());
experiencePool.setCreateByName(res.getAccountFullName());
experiencePool.setCreateTime(new Date());
experiencePool.setState(1);
experiencePool.setExperiencePoolType(1);
experiencePool.setExperiencePoolNo(poolAutorizeAndProjectVO.getExperiencePoolNo());
experiencePool.setExperiencePoolName(poolAutorizeAndProjectVO.getExperiencePoolName());
experiencePool.setVisibleRange(poolAutorizeAndProjectVO.getVisibleRange());
experiencePool.setCompanyId(res.getCompanyId());
experiencePool.setSiteId(res.getSiteId());
experiencePool.setOrgId(res.getOrgId());
poolMapper.insert(experiencePool);
} else {
//修改入库
experiencePool = this.selectById(poolAutorizeAndProjectVO.getId());
experiencePool.setExperiencePoolNo(poolAutorizeAndProjectVO.getExperiencePoolNo());
experiencePool.setExperiencePoolName(poolAutorizeAndProjectVO.getExperiencePoolName());
experiencePool.setVisibleRange(poolAutorizeAndProjectVO.getVisibleRange());
experiencePool.setUpdateById(res.getAccountId());
experiencePool.setUpdateByName(res.getAccountFullName());
experiencePool.setUpdateTime(new Date());
this.updateById(experiencePool);
}
//入库关联项目及有关联项目活动经验
if (null == id) {
id = experiencePool.getId();
}
PoolSaveReturnVO poolSaveReturnVO = new PoolSaveReturnVO();
if (CollectionUtils.isNotEmpty(poolAutorizeAndProjectVO.getPoolProjects())) {
//有关联项目对比更新入库
List<ExperiencePoolProjectVo> ep = poolAutorizeAndProjectVO.getPoolProjects();
List<ExperiencePoolProject> epx = new ArrayList<>();
if (CollectionUtils.isNotEmpty(ep)) {
for (ExperiencePoolProjectVo e : ep) {
ExperiencePoolProject ex = new ExperiencePoolProject();
BeanUtils.copyProperties(e, ex);
epx.add(ex);
}
}
activityExperienceList = poolProjectService.saveList(id, epx);
} else {
//没有关联项目对比删除旧数据
ExperiencePoolProject experiencePoolProject = new ExperiencePoolProject();
experiencePoolProject.setExperienceId(id);
EntityWrapper<ExperiencePoolProject> entityWrapper = new EntityWrapper<>(experiencePoolProject);
List<ExperiencePoolProject> list = poolProjectService.selectList(entityWrapper);
poolProjectService.delete(entityWrapper);
List<Long> deleteList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(list)) {
deleteList = list.stream().map(ExperiencePoolProject::getId).collect(Collectors.toList());
for (Long poolProjectId : deleteList) {
ProjectActivityExperience projectActivityExperience = new ProjectActivityExperience();
projectActivityExperience.setExperiencePoolProjectId(poolProjectId);
EntityWrapper<ProjectActivityExperience> deleteWrapper = new EntityWrapper<>(projectActivityExperience);
activityExperienceService.delete(deleteWrapper);
}
}
poolSaveReturnVO.setPoolId(id);
resultMap.put("poolSaveReturnVO", poolSaveReturnVO);
return resultMap;
}
Map<Long, List<ProjectActivityExperience>> map = new HashMap<>();
poolSaveReturnVO.setPoolId(id);
List<ProjectActivityExperienceVo> exp = new ArrayList<>();
if (CollectionUtils.isNotEmpty(activityExperienceList)) {
for (ProjectActivityExperience e : activityExperienceList) {
ProjectActivityExperienceVo ex = new ProjectActivityExperienceVo();
BeanUtils.copyProperties(e, ex);
exp.add(ex);
}
poolSaveReturnVO.setActivityExperienceList(exp);
}
resultMap.put("poolSaveReturnVO", poolSaveReturnVO);
return resultMap;
}
@Override
public boolean complete(Long poolId) {
RequestContext res = ContextHolder.get();
ExperiencePool experiencePool = new ExperiencePool();
experiencePool = this.selectById(poolId);
experiencePool.setState(2);
experiencePool.setUpdateById(res.getAccountId());
experiencePool.setUpdateByName(res.getAccountFullName());
experiencePool.setUpdateTime(new Date());
return this.updateById(experiencePool);
}
@Override
public Page<ExperiencePoolReportVo> getPoolReportList(String poolName, Integer pageNo, Integer pageSize, RequestContext requestContext) {
Long companyId = requestContext.getCompanyId();
Long siteId = requestContext.getSiteId();
Page<ExperiencePoolReportVo> page = new Page<>(pageNo, pageSize);
List<Long> accountIds = new ArrayList<>();
if (!requestContext.isAdmin()) {
HQAccountInManageParam hqAccountInManageParam = new HQAccountInManageParam();
hqAccountInManageParam.setModuleType(AuthzConstant.moduleType.statistics_experience);
hqAccountInManageParam.setSiteId(siteId);
hqAccountInManageParam.setAccountId(requestContext.getAccountId());
ReportAccountRespInManageVO respInManageVO = reportClient.getRangeAccountsInManage(hqAccountInManageParam);
if (null != respInManageVO) {
List<ReportAccountRespVO> accountList = respInManageVO.getList();
if (CollectionUtils.isNotEmpty(accountList)) {
accountIds = accountList.stream().map(ReportAccountRespVO::getUserId).collect(Collectors.toList());
}
}
}
//优化,如果是管理员不要将用户id加入限制条件
// else {
// ReportRangeAccountReqVO reportRangeAccountReqVO = new ReportRangeAccountReqVO();
// reportRangeAccountReqVO.setSiteId(siteId);
// List<ReportAccountRespVOVo> accountList = reportClient.getRangeAccounts(reportRangeAccountReqVO);
// if (CollectionUtils.isNotEmpty(accountList)) {
// accountIds = accountList.stream().map(ReportAccountRespVOVo::getUserId).collect(Collectors.toList());
// }
// }
String name = null;
if (StringUtils.isNotBlank(poolName)) {
name = poolName.trim();
}
Integer start = (pageNo - 1) * pageSize;
List<ExperiencePoolReportVo> list = new ArrayList<>();
Connection conn = null;
Statement st = null;
Statement st1 = null;
ResultSet rs = null;
ResultSet countRs = null;
StringBuilder sql = new StringBuilder("");
StringBuilder countSql = new StringBuilder();
sql.append("SELECT e.id as experiencePoolId,e.experience_pool_name ,e.visible_range as visibleRange,")
.append("e.create_time as poolCreateTime,IFNULL(b.num,0) as rangeAcountNum")
.append(" FROM experience_pool e")
.append(" LEFT JOIN (select experience_id , COUNT(relation_id) as num from experience_pool_authorize")
.append(" where 1=1");
if (CollectionUtils.isNotEmpty(accountIds)) {
StringBuilder s = new StringBuilder();
for (Long c : accountIds) {
int i = accountIds.size() - 1;
if (accountIds.indexOf(c) != i) {
s.append(c).append(",");
} else {
s.append(c);
}
}
System.out.println(s);
sql.append(" and relation_id in(").append(s).append(")");
}
sql.append(" GROUP BY\n" +
" experience_id)b\n" +
" on e.id = b.experience_id and e.company_id =").append(companyId).append(" and e.site_id = ")
.append(siteId);
sql.append(" where e.company_id = ").append(companyId).append(" and e.site_id = ").append(siteId);
if (StringUtils.isNotBlank(name)) {
sql.append(" and e.experience_pool_name like CONCAT('%','").append(name).append("','%')");
}
sql.append(" and e.state = 2 ORDER BY e.create_time DESC,e.id limit ").append(start).append(",").append(pageSize);
countSql.append("select count(id) as total from experience_pool where company_id =")
.append(companyId).append(" and site_id =").append(siteId).append(" and state = 2");
if (StringUtils.isNotBlank(name)) {
countSql.append(" and experience_pool_name like CONCAT('%','").append(name).append("','%')");
}
Integer pageTotal = 0;
try {
try {
conn = this.sqlSessionBatch().getConnection();
st = conn.createStatement();
LOGGER.info("执行的sql={}", sql.toString());
rs = st.executeQuery(sql.toString());
while (rs.next()) {
ExperiencePoolReportVo reportVo = new ExperiencePoolReportVo();
reportVo.setExperiencePoolId(rs.getLong("experiencePoolId"));
reportVo.setExperiencePoolName(rs.getString("experience_pool_name"));
reportVo.setVisibleRange(rs.getInt("visibleRange"));
reportVo.setPoolCreateTime(rs.getDate("poolCreateTime"));
reportVo.setRangeAcountNum(rs.getInt("rangeAcountNum"));
list.add(reportVo);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (null != rs) {
rs.close();
}
if (null != st) {
st.close();
}
if (null != conn) {
conn.close();
}
}
} catch (SQLException e) {
e.printStackTrace();
LOGGER.info("经验池列表创建jdbc连接过程中,获取列表信息出现异常");
}
try {
try {
conn = this.sqlSessionBatch().getConnection();
st1 = conn.createStatement();
LOGGER.info("执行的countSql={}", countSql.toString());
countRs = st1.executeQuery(countSql.toString());
while (countRs.next()) {
pageTotal = countRs.getInt("total");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (null != countRs) {
countRs.close();
}
if (null != st1) {
st1.close();
}
if (null != conn) {
conn.close();
}
}
} catch (SQLException e) {
LOGGER.info("经验池列表创建jdbc连接过程中,获取分页total出现异常");
}
LOGGER.info("*****************找到{}个经验池" + list.size());
//查出全平台可见人数
ReportRangeAccountReqVO reqVO = new ReportRangeAccountReqVO();
reqVO.setSiteId(siteId);
Integer allNum = Math.toIntExact(reportClient.getRangeAccountCountNum(reqVO));
Integer roleNum = accountIds.size();
if (CollectionUtils.isNotEmpty(list)) {
for (ExperiencePoolReportVo experiencePoolReportVo : list) {
if (!requestContext.isAdmin() && CollectionUtils.isEmpty(accountIds)) {
experiencePoolReportVo.setRangeAcountNum(0);
} else if (experiencePoolReportVo.getVisibleRange() == 1) {
if (requestContext.isAdmin()) {
experiencePoolReportVo.setRangeAcountNum(allNum);
} else {
experiencePoolReportVo.setRangeAcountNum(roleNum);
}
}
}
page.setRecords(list);
page.setTotal(pageTotal);
}
return page;
}
@Override
public Page<ExperiencePoolReportExportVo> getReportViewList(Long poolId, String key, String orgName, Integer pageNo, Integer pageSize, Integer type, String startTime, String endTime, Long siteId, RequestContext requestContext) {
if (StringUtils.isBlank(startTime)) {
startTime = null;
}
if (StringUtils.isBlank(endTime)) {
endTime = null;
}
Page<ExperiencePoolReportExportVo> page = new Page<>(pageNo, pageSize);
//先分页查找对应关联用户id和总经验值
StringBuilder sql = new StringBuilder();
sql.append("select *\n" +
" from experience_pool e\n" +
" where id = ").append(poolId);
Connection conn = this.sqlSessionBatch().getConnection();
Integer visibleRange = 1;
Statement st = null;
ResultSet rs = null;
try {
st = conn.createStatement();
LOGGER.info("执行的sql={}", sql.toString());
rs = st.executeQuery(sql.toString());
while (rs.next()) {
visibleRange = rs.getInt("visible_range");
}
rs.close();
} catch (Exception e) {
e.printStackTrace();
return page;
} finally {
if (null != rs) {
try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (null != st) {
try {
st.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (null != conn) {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
List<ExperiencePoolReportExportVo> list = null;
if (visibleRange == 1) {
boolean isGetAccount = true;
List<ReportAccountRespVO> accountVOList = null;
List<ReportAccountRespVOVo> accountRespVOVos = new ArrayList<>();
GetAccountListVO getAccountListVO = getAccountList(requestContext, key, orgName, isGetAccount, accountVOList);
if (null != getAccountListVO) {
isGetAccount = getAccountListVO.getIsGetAccount();
accountRespVOVos = getAccountListVO.getAccountVOList();
if (!accountRespVOVos.isEmpty()) {
for (ReportAccountRespVOVo rvv : accountRespVOVos
) {
ReportAccountRespVO rv = new ReportAccountRespVO();
BeanUtils.copyProperties(rvv, rv);
accountVOList.add(rv);
}
}
}
List<Long> ids = new ArrayList<>();
Map<Long, ReportAccountRespVO> accountVOMap = new HashMap<>();
//如果全平台可见并且是管理员,先取出记录再根据记录取出对应用户信息,避免全平台人数过多,重复取出多余数据
if (isGetAccount) {
list = studentExperienceMapper.getReportViewList(poolId, null, page);
if (CollectionUtils.isNotEmpty(list)) {
for (ExperiencePoolReportExportVo vo : list) {
ids.add(vo.getAccountId());
}
ReportRangeAccountReqVO reqVO = new ReportRangeAccountReqVO();
reqVO.setSiteId(siteId);
reqVO.setAccountIds(ids);
List<ReportAccountRespVO> respVOS = reportClient.getRangeAccounts(reqVO);
if (CollectionUtils.isNotEmpty(respVOS)) {
for (ReportAccountRespVO respVO : respVOS) {
accountVOMap.put(respVO.getUserId(), respVO);
}
}
}
} else {
if (CollectionUtils.isNotEmpty(accountVOList)) {
for (ReportAccountRespVO reportAccountRespVO : accountVOList) {
ids.add(reportAccountRespVO.getUserId());
accountVOMap.put(reportAccountRespVO.getUserId(), reportAccountRespVO);
}
list = studentExperienceMapper.getReportViewList(poolId, ids, page);
} else {
return page;
}
}
if (CollectionUtils.isNotEmpty(list)) {
Map<Long, Map<String, BigDecimal>> experienceMap = null;
if (null != type && type == 1) {
List<Long> accountIds = list.stream().map(ExperiencePoolReportExportVo::getAccountId).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(accountIds)) {
experienceMap = studentExperienceMapper.getPurchaseAndIncreaseExperienceTotal(accountIds, poolId, startTime, endTime);
}
}
for (ExperiencePoolReportExportVo reportExportVo : list) {
ReportAccountRespVO account = accountVOMap.get(reportExportVo.getAccountId());
if (null == account) {
LOGGER.error("未找到该关联用户信息:" + reportExportVo.getAccountId());
continue;
}
reportExportVo.setAccountName(account.getUserName());
reportExportVo.setAccountFullName(account.getUserFullName());
reportExportVo.setOrgName(account.getOrgName());
reportExportVo.setOrgId(account.getOrgId());
reportExportVo.setEmail(account.getEmail());
reportExportVo.setAccountCreateTime(account.getCreateTime());
if (null != experienceMap) {
BigDecimal increase = null;
BigDecimal purchase = null;
if (null != experienceMap.get(reportExportVo.getAccountId())) {
increase = experienceMap.get(reportExportVo.getAccountId()).get("increaseTotal");
purchase = experienceMap.get(reportExportVo.getAccountId()).get("purchaseTotal");
}
Long increaseTotal = null;
Long purchaseTotal = null;
if (null != increase) {
increaseTotal = increase.longValue();
}
if (null != purchase) {
purchaseTotal = purchase.longValue();
}
reportExportVo.setPurchaseExperienceTotal(purchaseTotal == null ? 0 : purchaseTotal);
reportExportVo.setIncreaseExperienceTotal(increaseTotal == null ? 0 : increaseTotal);
}
if (type == null) {
if (null != reportExportVo.getExperienceTotal()) {
Integer experience = Math.toIntExact(reportExportVo.getExperienceTotal());
//查找经验等级装入实体类中
ExperiencePoolLevel experienceLevel = myExperienceMapper.getMyExperienceLevel(poolId, experience);
if (null != experienceLevel) {
reportExportVo.setExperienceLevel(experienceLevel.getLevelName());
}
// //将分类经验查找出来并装入实体类中
// List<MyExperienceEventsVo> experienceEventsVos = myExperienceMapper.getMyExperience(poolId, reportExportVo.getAccountId());
// if (CollectionUtils.isNotEmpty(experienceEventsVos)) {
// for (MyExperienceEventsVo myExperienceEventsVo : experienceEventsVos) {
// if (myExperienceEventsVo.getEventName().equals("课程")) {
// Long courseExperience = myExperienceEventsVo.getExperience() == null ? 0 : Long.valueOf(myExperienceEventsVo.getExperience());
// reportExportVo.setCourseExperience(courseExperience);
// } else if (myExperienceEventsVo.getEventName().equals("考试")) {
// Long examExperience = myExperienceEventsVo.getExperience() == null ? 0 : Long.valueOf(myExperienceEventsVo.getExperience());
// reportExportVo.setExamExperience(examExperience);
// } else if (myExperienceEventsVo.getEventName().equals("调研")) {
// Long researchExperience = myExperienceEventsVo.getExperience() == null ? 0 : Long.valueOf(myExperienceEventsVo.getExperience());
// reportExportVo.setResearchExperience(researchExperience);
// } else if (myExperienceEventsVo.getEventName().equals("投票")) {
// Long voteExperience = myExperienceEventsVo.getExperience() == null ? 0 : Long.valueOf(myExperienceEventsVo.getExperience());
// reportExportVo.setVoteExperience(voteExperience);
// } else if (myExperienceEventsVo.getEventName().equals("外部导入")) {
// Long externalExperience = myExperienceEventsVo.getExperience() == null ? 0 : Long.valueOf(myExperienceEventsVo.getExperience());
// reportExportVo.setExternalExperience(externalExperience);
// }
// }
// }
}
}
}
}
} else if (visibleRange == 2) {
//可见范围用户id
List<Long> authorizeIds = null;
//可见范围内的管辖区用户
List<Long> ids = new ArrayList<>();
ExperiencePoolAuthorize poolAuthorize = new ExperiencePoolAuthorize();
poolAuthorize.setExperienceId(poolId);
EntityWrapper<ExperiencePoolAuthorize> entityWrapper = new EntityWrapper<>(poolAuthorize);
List<ExperiencePoolAuthorize> authorizeList = poolAuthorizeMapper.selectList(entityWrapper);
if (CollectionUtils.isNotEmpty(authorizeList)) {
authorizeIds = authorizeList.stream().map(ExperiencePoolAuthorize::getRelationId).collect(Collectors.toList());
LOGGER.info("#########################authorizeIds.size:" + authorizeIds.size());
}
if (CollectionUtils.isEmpty(authorizeIds)) {
return null;
}
List<ReportAccountRespVO> accountVOList = null;
Map<Long, ReportAccountRespVO> accountsMap = new HashMap<>();
if (requestContext.isAdmin()) {
ReportRangeAccountReqVO reportRangeAccountReqVO = new ReportRangeAccountReqVO();
reportRangeAccountReqVO.setSiteId(siteId);
reportRangeAccountReqVO.setAccountIds(authorizeIds);
if (StringUtils.isNotBlank(key)) {
reportRangeAccountReqVO.setAccountName(key.trim());
}
if (StringUtils.isNotBlank(orgName)) {
reportRangeAccountReqVO.setOrgName(orgName.trim());
}
accountVOList = reportClient.getRangeAccounts(reportRangeAccountReqVO);
if (CollectionUtils.isNotEmpty(accountVOList)) {
for (ReportAccountRespVO reportAccountRespVO : accountVOList) {
ids.add(reportAccountRespVO.getUserId());
accountsMap.put(reportAccountRespVO.getUserId(), reportAccountRespVO);
}
}
} else {
HQAccountInManageParam reportRangeAccountReqVO = new HQAccountInManageParam();
reportRangeAccountReqVO.setAccountId(requestContext.getAccountId());
reportRangeAccountReqVO.setSiteId(requestContext.getSiteId());
reportRangeAccountReqVO.setModuleType(AuthzConstant.moduleType.statistics_experience);
if (StringUtils.isNotBlank(key)) {
reportRangeAccountReqVO.setAccountName(key.trim());
}
if (StringUtils.isNotBlank(orgName)) {
reportRangeAccountReqVO.setOrgName(orgName.trim());
}
ReportAccountRespInManageVO reportAccountRespInManageVO = reportClient.getRangeAccountsInManage(reportRangeAccountReqVO);
if (null != reportAccountRespInManageVO) {
if (!reportAccountRespInManageVO.getIsAdmin()) {
accountVOList = reportAccountRespInManageVO.getList();
} else {
ReportRangeAccountReqVO reportRangeAccountReqVO1 = new ReportRangeAccountReqVO();
reportRangeAccountReqVO1.setSiteId(siteId);
if (StringUtils.isNotBlank(key)) {
reportRangeAccountReqVO1.setAccountName(key.trim());
}
if (StringUtils.isNotBlank(orgName)) {
reportRangeAccountReqVO1.setOrgName(orgName.trim());
}
accountVOList = reportClient.getRangeAccounts(reportRangeAccountReqVO1);
}
}
if (CollectionUtils.isNotEmpty(accountVOList)) {
for (ReportAccountRespVO reportAccountRespVO : accountVOList) {
if (authorizeIds.contains(reportAccountRespVO.getUserId())) {
ids.add(reportAccountRespVO.getUserId());
accountsMap.put(reportAccountRespVO.getUserId(), reportAccountRespVO);
}
}
}
}
if (CollectionUtils.isNotEmpty(ids)) {
list = studentExperienceMapper.getReportViewList(poolId, ids, page);
LOGGER.info("##########################经验列表list.size:" + list.size());
} else {
return page;
}
if (CollectionUtils.isNotEmpty(list)) {
Map<Long, Map<String, BigDecimal>> experienceMap = null;
if (null != type && type == 1) {
List<Long> accountIds = list.stream().map(ExperiencePoolReportExportVo::getAccountId).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(accountIds)) {
experienceMap = studentExperienceMapper.getPurchaseAndIncreaseExperienceTotal(accountIds, poolId, startTime, endTime);
}
}
//遍历ids将数据查找装入类中
for (ExperiencePoolReportExportVo reportExportVo : list) {
//查找用记信息装入实体类中
ReportAccountRespVO accountVO = accountsMap.get(reportExportVo.getAccountId());
if (null == accountVO) {
LOGGER.error("未找到该关联用户信息:" + reportExportVo.getAccountId());
continue;
}
reportExportVo.setAccountFullName(accountVO.getUserFullName());
reportExportVo.setOrgName(accountVO.getOrgName());
reportExportVo.setOrgId(accountVO.getOrgId());
reportExportVo.setAccountName(accountVO.getUserName());
reportExportVo.setEmail(accountVO.getEmail());
reportExportVo.setAccountCreateTime(accountVO.getCreateTime());
if (null != experienceMap) {
BigDecimal increase = null;
BigDecimal purchase = null;
if (null != experienceMap.get(reportExportVo.getAccountId())) {
increase = experienceMap.get(reportExportVo.getAccountId()).get("increaseTotal");
purchase = experienceMap.get(reportExportVo.getAccountId()).get("purchaseTotal");
}
Long increaseTotal = null;
Long purchaseTotal = null;
if (null != increase) {
increaseTotal = increase.longValue();
}
if (null != purchase) {
purchaseTotal = purchase.longValue();
}
reportExportVo.setPurchaseExperienceTotal(purchaseTotal == null ? 0 : purchaseTotal);
reportExportVo.setIncreaseExperienceTotal(increaseTotal == null ? 0 : increaseTotal);
}
if (null == type) {
if (null != reportExportVo.getExperienceTotal()) {
Integer experience = Math.toIntExact(reportExportVo.getExperienceTotal());
//查找经验等级装入实体类中
ExperiencePoolLevel experienceLevel = myExperienceMapper.getMyExperienceLevel(poolId, experience);
if (null != experienceLevel) {
reportExportVo.setExperienceLevel(experienceLevel.getLevelName());
}
// //将分类经验查找出来并装入实体类中
// List<MyExperienceEventsVo> experienceEventsVos = myExperienceMapper.getMyExperience(poolId, reportExportVo.getAccountId());
// if (CollectionUtils.isNotEmpty(experienceEventsVos)) {
// for (MyExperienceEventsVo myExperienceEventsVo : experienceEventsVos) {
// if (myExperienceEventsVo.getEventName().equals("课程")) {
// Long courseExperience = myExperienceEventsVo.getExperience() == null ? 0 : Long.valueOf(myExperienceEventsVo.getExperience());
// reportExportVo.setCourseExperience(courseExperience);
// } else if (myExperienceEventsVo.getEventName().equals("考试")) {
// Long examExperience = myExperienceEventsVo.getExperience() == null ? 0 : Long.valueOf(myExperienceEventsVo.getExperience());
// reportExportVo.setExamExperience(examExperience);
// } else if (myExperienceEventsVo.getEventName().equals("调研")) {
// Long researchExperience = myExperienceEventsVo.getExperience() == null ? 0 : Long.valueOf(myExperienceEventsVo.getExperience());
// reportExportVo.setResearchExperience(researchExperience);
// } else if (myExperienceEventsVo.getEventName().equals("投票")) {
// Long voteExperience = myExperienceEventsVo.getExperience() == null ? 0 : Long.valueOf(myExperienceEventsVo.getExperience());
// reportExportVo.setVoteExperience(voteExperience);
// } else if (myExperienceEventsVo.getEventName().equals("外部导入")) {
// Long externalExperience = myExperienceEventsVo.getExperience() == null ? 0 : Long.valueOf(myExperienceEventsVo.getExperience());
// reportExportVo.setExternalExperience(externalExperience);
// }
// }
// }
}
}
}
}
}
if (CollectionUtils.isNotEmpty(list)) {
page.setRecords(list);
}
return page;
}
@Override
public Page<ExperiencePoolReportExportVo> viewAccountDetails(Long poolId, Long accountId, Integer state, Integer pageNo, Integer pageSize) {
Page<ExperiencePoolReportExportVo> page = new Page<>(pageNo, pageSize);
List<ExperiencePoolReportExportVo> list = studentExperienceMapper.viewAccountDetails(poolId, accountId, state, page);
if (CollectionUtils.isNotEmpty(list)) {
AccountVO accountVO = accountClient.findById(accountId);
Integer startIndex = (pageNo - 1) * pageSize;
Integer endIndex = Integer.MAX_VALUE;
Long totalExperience = 0L;
if (null == state) {
totalExperience = studentExperienceMapper.getTotalExperience(poolId, accountId, startIndex, endIndex);
}
for (ExperiencePoolReportExportVo experiencePoolReportExportVo : list) {
if (null != accountVO) {
experiencePoolReportExportVo.setAccountName(accountVO.getName());
experiencePoolReportExportVo.setAccountFullName(accountVO.getFullName() == null ? "" : accountVO.getFullName());
experiencePoolReportExportVo.setOrgName(accountVO.getOrgName() == null ? "" : accountVO.getOrgName());
experiencePoolReportExportVo.setOrgId(accountVO.getOrgId());
if (null == state) {
//剩余经验值
experiencePoolReportExportVo.setExperienceTotal(totalExperience);
//变化前前经验
totalExperience = totalExperience - experiencePoolReportExportVo.getExperience();
}
//变动明细
//课程
if (experiencePoolReportExportVo.getType() == 1) {
experiencePoolReportExportVo.setDescription("完成课程获得" + experiencePoolReportExportVo.getExperience() + "经验值");
}
if (experiencePoolReportExportVo.getType() == 2) {
experiencePoolReportExportVo.setDescription("完成考试获得" + experiencePoolReportExportVo.getExperience() + "经验值");
}
if (experiencePoolReportExportVo.getType() == 3) {
experiencePoolReportExportVo.setDescription("完成调研获得" + experiencePoolReportExportVo.getExperience() + "经验值");
}
// if (experiencePoolReportExportVo.getType()==4){
// experiencePoolReportExportVo.setDescription("完成投票获得"+experiencePoolReportExportVo.getExperience()+"经验值");
// }
if (experiencePoolReportExportVo.getType() == 5) {
experiencePoolReportExportVo.setDescription("外部导入获得" + experiencePoolReportExportVo.getExperience() + "经验值");
}
if (experiencePoolReportExportVo.getType() == 6) {
experiencePoolReportExportVo.setDescription("完成作业获得" + experiencePoolReportExportVo.getExperience() + "经验值");
}
if (experiencePoolReportExportVo.getType() == 10) {
experiencePoolReportExportVo.setDescription("购物使用" + (0 - experiencePoolReportExportVo.getExperience()) + "经验值");
}
}
page.setRecords(list);
}
}
return page;
}
@Override
public List<ExperiencePoolReportExportVo> viewAllDetails(Long poolId, String startTime, String endTime, String orgName, String accountName, Integer state, RequestContext res) {
if (StringUtils.isBlank(startTime)) {
startTime = null;
}
if (StringUtils.isBlank(endTime)) {
endTime = null;
}
Integer visibleRange = 1;
ExperiencePool experiencePool = poolMapper.selectById(poolId);
if (null != experiencePool) {
visibleRange = experiencePool.getVisibleRange();
}
List<ExperiencePoolReportExportVo> list = null;
List<ReportAccountRespVO> accountVOList = null;
List<ReportAccountRespVOVo> accountRespVOVos = new ArrayList<>();
Map<Long, ReportAccountRespVO> accountVOMap = new HashMap<>();
if (visibleRange == 1) {
boolean isGetAccount = true;
GetAccountListVO getAccountListVO = getAccountList(res, accountName, orgName, isGetAccount, accountVOList);
if (null != getAccountListVO) {
isGetAccount = getAccountListVO.getIsGetAccount();
accountRespVOVos = getAccountListVO.getAccountVOList();
if (!accountRespVOVos.isEmpty()) {
for (ReportAccountRespVOVo rvv : accountRespVOVos
) {
ReportAccountRespVO rv = new ReportAccountRespVO();
BeanUtils.copyProperties(rvv, rv);
accountVOList.add(rv);
}
}
}
List<Long> ids = new ArrayList<>();
//如果全平台可见并且是管理员,先取出记录再根据记录取出对应用户信息,避免全平台人数过多,重复取出多余数据
if (isGetAccount) {
list = studentExperienceMapper.viewAllDetails(poolId, null, startTime, endTime, state);
if (CollectionUtils.isNotEmpty(list)) {
for (ExperiencePoolReportExportVo vo : list) {
if (!ids.contains(vo.getAccountId())) {
ids.add(vo.getAccountId());
}
}
ReportRangeAccountReqVO reqVO = new ReportRangeAccountReqVO();
reqVO.setSiteId(res.getSiteId());
reqVO.setAccountIds(ids);
List<ReportAccountRespVO> respVOS = reportClient.getRangeAccounts(reqVO);
if (CollectionUtils.isNotEmpty(respVOS)) {
for (ReportAccountRespVO respVO : respVOS) {
accountVOMap.put(respVO.getUserId(), respVO);
}
}
}
} else {
if (CollectionUtils.isNotEmpty(accountVOList)) {
for (ReportAccountRespVO reportAccountRespVO : accountVOList) {
ids.add(reportAccountRespVO.getUserId());
accountVOMap.put(reportAccountRespVO.getUserId(), reportAccountRespVO);
}
list = studentExperienceMapper.viewAllDetails(poolId, ids, startTime, endTime, state);
} else {
return list;
}
}
} else if (visibleRange == 2) {
//可见范围用户id
List<Long> authorizeIds = null;
//可见范围内的管辖区用户
List<Long> ids = new ArrayList<>();
ExperiencePoolAuthorize poolAuthorize = new ExperiencePoolAuthorize();
poolAuthorize.setExperienceId(poolId);
EntityWrapper<ExperiencePoolAuthorize> entityWrapper = new EntityWrapper<>(poolAuthorize);
List<ExperiencePoolAuthorize> authorizeList = poolAuthorizeMapper.selectList(entityWrapper);
if (CollectionUtils.isNotEmpty(authorizeList)) {
authorizeIds = authorizeList.stream().map(ExperiencePoolAuthorize::getRelationId).collect(Collectors.toList());
LOGGER.info("#########################authorizeIds.size:" + authorizeIds.size());
}
if (CollectionUtils.isEmpty(authorizeIds)) {
return null;
}
if (res.isAdmin()) {
ReportRangeAccountReqVO reportRangeAccountReqVO = new ReportRangeAccountReqVO();
reportRangeAccountReqVO.setSiteId(res.getSiteId());
reportRangeAccountReqVO.setAccountIds(authorizeIds);
if (StringUtils.isNotBlank(accountName)) {
reportRangeAccountReqVO.setAccountName(accountName.trim());
}
if (StringUtils.isNotBlank(orgName)) {
reportRangeAccountReqVO.setOrgName(orgName.trim());
}
accountVOList = reportClient.getRangeAccounts(reportRangeAccountReqVO);
if (CollectionUtils.isNotEmpty(accountVOList)) {
for (ReportAccountRespVO reportAccountRespVO : accountVOList) {
if (!ids.contains(reportAccountRespVO.getUserId())) {
ids.add(reportAccountRespVO.getUserId());
accountVOMap.put(reportAccountRespVO.getUserId(), reportAccountRespVO);
}
}
}
} else {
HQAccountInManageParam reportRangeAccountReqVO = new HQAccountInManageParam();
reportRangeAccountReqVO.setAccountId(res.getAccountId());
reportRangeAccountReqVO.setSiteId(res.getSiteId());
reportRangeAccountReqVO.setModuleType(AuthzConstant.moduleType.statistics_experience);
if (StringUtils.isNotBlank(accountName)) {
reportRangeAccountReqVO.setAccountName(accountName.trim());
}
if (StringUtils.isNotBlank(orgName)) {
reportRangeAccountReqVO.setOrgName(orgName.trim());
}
ReportAccountRespInManageVO reportAccountRespInManageVO = reportClient.getRangeAccountsInManage(reportRangeAccountReqVO);
if (null != reportAccountRespInManageVO) {
if (!reportAccountRespInManageVO.getIsAdmin()) {
accountVOList = reportAccountRespInManageVO.getList();
} else {
ReportRangeAccountReqVO reportRangeAccountReqVO1 = new ReportRangeAccountReqVO();
reportRangeAccountReqVO1.setSiteId(res.getSiteId());
if (StringUtils.isNotBlank(accountName)) {
reportRangeAccountReqVO1.setAccountName(accountName.trim());
}
if (StringUtils.isNotBlank(orgName)) {
reportRangeAccountReqVO1.setOrgName(orgName.trim());
}
accountVOList = reportClient.getRangeAccounts(reportRangeAccountReqVO1);
}
}
if (CollectionUtils.isNotEmpty(accountVOList)) {
for (ReportAccountRespVO reportAccountRespVO : accountVOList) {
if (authorizeIds.contains(reportAccountRespVO.getUserId())) {
if (ids.contains(reportAccountRespVO.getUserId())) {
ids.add(reportAccountRespVO.getUserId());
accountVOMap.put(reportAccountRespVO.getUserId(), reportAccountRespVO);
}
}
}
}
}
if (CollectionUtils.isNotEmpty(ids)) {
list = studentExperienceMapper.viewAllDetails(poolId, ids, startTime, endTime, state);
LOGGER.info("##########################所有人经验明细list.size:" + list.size());
} else {
return list;
}
}
Map<Long, String> orgNameMap = new HashMap<>(16);
//组装信息
if (CollectionUtils.isNotEmpty(list)) {
for (ExperiencePoolReportExportVo exportVo : list) {
ReportAccountRespVO accountRespVO = accountVOMap.get(exportVo.getAccountId());
if (null != accountRespVO) {
exportVo.setAccountName(accountRespVO.getUserName());
exportVo.setAccountFullName(accountRespVO.getUserFullName());
exportVo.setOrgName(accountRespVO.getOrgName());
exportVo.setOrgId(accountRespVO.getOrgId());
if (null != orgNameMap.get(accountRespVO)) {
exportVo.setOrgName(orgNameMap.get(accountRespVO));
} else {
String orgNames = "";
List<String> orgNamesList = organizationClient.getChiefOrgNames(accountRespVO.getOrgId(), accountRespVO.getCompanyId());
if (CollectionUtils.isNotEmpty(orgNamesList)) {
for (String s : orgNamesList) {
if (StringUtils.isNotBlank(orgNames)) {
orgNames = orgNames + "/" + s;
} else {
orgNames = orgNames + s;
}
}
exportVo.setOrgNames(orgNames);
orgNameMap.put(accountRespVO.getOrgId(), orgNames);
} else {
exportVo.setOrgNames("--");
orgNameMap.put(accountRespVO.getOrgId(), "--");
}
}
//变动明细
//课程
if (exportVo.getType() == 1) {
exportVo.setDescription("完成课程获得" + exportVo.getExperience() + "经验值");
}
if (exportVo.getType() == 2) {
exportVo.setDescription("完成考试获得" + exportVo.getExperience() + "经验值");
}
if (exportVo.getType() == 3) {
exportVo.setDescription("完成调研获得" + exportVo.getExperience() + "经验值");
}
// if (experiencePoolReportExportVo.getType()==4){
// experiencePoolReportExportVo.setDescription("完成投票获得"+experiencePoolReportExportVo.getExperience()+"经验值");
// }
if (exportVo.getType() == 5) {
exportVo.setDescription("外部导入获得" + exportVo.getExperience() + "经验值");
}
if (exportVo.getType() == 6) {
exportVo.setDescription("完成作业获得" + exportVo.getExperience() + "经验值");
}
if (exportVo.getType() == 10) {
exportVo.setDescription("兑换" + exportVo.getActivityName() + "消耗" + (0 - exportVo.getExperience()) + "经验值");
}
}
}
}
return list;
}
public GetAccountListVO getAccountList(RequestContext res, String key, String orgName, boolean isGetAccount, List<ReportAccountRespVO> accountVOList) {
isGetAccount = true;
if (res.isAdmin()) {
if (StringUtils.isNotBlank(key) || StringUtils.isNotBlank(orgName)) {
isGetAccount = false;
ReportRangeAccountReqVO reportRangeAccountReqVO = new ReportRangeAccountReqVO();
reportRangeAccountReqVO.setSiteId(res.getSiteId());
if (StringUtils.isNotBlank(key)) {
reportRangeAccountReqVO.setAccountName(key.trim());
}
if (StringUtils.isNotBlank(orgName)) {
reportRangeAccountReqVO.setOrgName(orgName.trim());
}
accountVOList = reportClient.getRangeAccounts(reportRangeAccountReqVO);
}
} else {
isGetAccount = false;
HQAccountInManageParam reportRangeAccountReqVO = new HQAccountInManageParam();
reportRangeAccountReqVO.setAccountId(res.getAccountId());
reportRangeAccountReqVO.setSiteId(res.getSiteId());
reportRangeAccountReqVO.setModuleType(AuthzConstant.moduleType.statistics_experience);
if (StringUtils.isNotBlank(key)) {
reportRangeAccountReqVO.setAccountName(key.trim());
}
ReportAccountRespInManageVO reportAccountRespInManageVO = reportClient.getRangeAccountsInManage(reportRangeAccountReqVO);
if (null != reportAccountRespInManageVO) {
if (!reportAccountRespInManageVO.getIsAdmin()) {
accountVOList = reportAccountRespInManageVO.getList();
} else {
if (StringUtils.isNotBlank(key) || StringUtils.isNotBlank(orgName)) {
isGetAccount = false;
ReportRangeAccountReqVO reportRangeAccountReqVO1 = new ReportRangeAccountReqVO();
reportRangeAccountReqVO1.setSiteId(res.getSiteId());
if (StringUtils.isNotBlank(key)) {
reportRangeAccountReqVO1.setAccountName(key.trim());
}
if (StringUtils.isNotBlank(orgName)) {
reportRangeAccountReqVO1.setOrgName(orgName.trim());
}
accountVOList = reportClient.getRangeAccounts(reportRangeAccountReqVO1);
} else {
isGetAccount = true;
}
}
}
}
List<ReportAccountRespVOVo> accountRespVOVos=new ArrayList<>();
if (CollectionUtils.isNotEmpty(accountVOList)) {
for (ReportAccountRespVO rv : accountVOList
) {
ReportAccountRespVOVo rvv = new ReportAccountRespVOVo();
BeanUtils.copyProperties(rv, rvv);
accountRespVOVos.add(rvv);
}
}
GetAccountListVO getAccountListVO = new GetAccountListVO();
getAccountListVO.setIsGetAccount(isGetAccount);
getAccountListVO.setAccountVOList(accountRespVOVos);
return getAccountListVO;
}
}
package com.yizhi.application.service.impl;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.application.domain.ExperienceRecord;
import com.yizhi.application.mapper.ExperienceRecordMapper;
import com.yizhi.application.service.IExperienceRecordService;
import com.yizhi.application.orm.id.IdGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* <p>
* 经验发放记录表 服务实现类
* </p>
*
* @author dingxiaowei123
* @since 2019-01-02
*/
@Service
public class ExperienceRecordServiceImpl extends ServiceImpl<ExperienceRecordMapper, ExperienceRecord> implements IExperienceRecordService {
@Autowired
private IdGenerator idGenerator;
@Override
public void insertRecord(ExperienceRecord experienceRecord) {
if (null!=experienceRecord){
experienceRecord.setId(idGenerator.generate());
this.insert(experienceRecord);
}
}
}
package com.yizhi.application.service.impl;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.application.domain.Product;
import com.yizhi.application.mapper.ProductMapper;
import com.yizhi.application.service.IProductService;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author dingxiaowei123
* @since 2019-09-19
*/
@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements IProductService {
}
package com.yizhi.application.service.impl;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.application.domain.ExperiencePoolProject;
import com.yizhi.application.domain.ProjectActivityExperience;
import com.yizhi.application.domain.ProjectActivityExperienceSet;
import com.yizhi.application.mapper.ProjectActivityExperienceMapper;
import com.yizhi.application.mapper.ProjectActivityExperienceSetMapper;
import com.yizhi.application.service.IProjectActivityExperienceService;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.custom.api.vo.custom.ExperienceRulesVO;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.application.orm.id.IdGenerator;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author ding
* @since 2018-11-06
*/
@Service
public class ProjectActivityExperienceServiceImpl extends ServiceImpl<ProjectActivityExperienceMapper, ProjectActivityExperience> implements IProjectActivityExperienceService {
@Autowired
private IdGenerator idGenerator;
@Autowired
private ProjectActivityExperienceMapper activityExperienceMapper;
@Autowired
private ProjectActivityExperienceSetMapper activityExperienceSetMapper;
@Override
public List<ProjectActivityExperience> saveList(List<Long> deleteList, List<ExperiencePoolProject> poolProjectList) {
List<ProjectActivityExperience> activityExperienceList = null;
List<ProjectActivityExperience> insertList = null;
RequestContext res = ContextHolder.get();
if (CollectionUtils.isNotEmpty(poolProjectList)) {
//删除已删除关联项目的活动经验
if (CollectionUtils.isNotEmpty(deleteList)) {
for (Long poolProjectId : deleteList) {
//如果新列表中删除,库里旧数据删除并删除对应活动经验数据
ProjectActivityExperience deleteActivityExperience = new ProjectActivityExperience();
deleteActivityExperience.setExperiencePoolProjectId(poolProjectId);
EntityWrapper<ProjectActivityExperience> deleteWrapper = new EntityWrapper<>(deleteActivityExperience);
this.delete(deleteWrapper);
}
}
}
insertList = new ArrayList<>();
activityExperienceList = new ArrayList<>();
for (ExperiencePoolProject poolProject : poolProjectList) {
ProjectActivityExperience activityExperience = new ProjectActivityExperience();
//查找是否有记录,没有就新建入库
activityExperience.setExperiencePoolProjectId(poolProject.getId());
EntityWrapper<ProjectActivityExperience> entityWrapper = new EntityWrapper<>(activityExperience);
List<ProjectActivityExperience> list = this.selectList(entityWrapper);
if (CollectionUtils.isNotEmpty(list)) {
activityExperienceList.addAll(list);
} else {
activityExperience.setId(idGenerator.generate());
activityExperience.setType(poolProject.getType());
activityExperience.setActivityName(poolProject.getBizName());
activityExperience.setActivityExperienceSource(0);
activityExperience.setCreateById(res.getAccountId());
activityExperience.setCreateByName(res.getAccountFullName());
activityExperience.setCreateTime(new Date());
insertList.add(activityExperience);
activityExperienceList.add(activityExperience);
}
}
//新建的入库
if (CollectionUtils.isNotEmpty(insertList)) {
this.insertBatch(insertList);
}
return activityExperienceList;
}
@Override
public boolean insertList(List<ProjectActivityExperience> projectActivityExperienceList) {
RequestContext res = ContextHolder.get();
List<ProjectActivityExperience> updateList = new ArrayList<>();
for (ProjectActivityExperience activityExperience : projectActivityExperienceList) {
if (activityExperience.getType() == 2) {
ProjectActivityExperience activityExperience1 = new ProjectActivityExperience();
activityExperience1 = this.selectById(activityExperience.getId());
activityExperience.setUpdateById(res.getAccountId());
activityExperience.setUpdateByName(res.getAccountFullName());
activityExperience.setUpdateTime(new Date());
if (activityExperience1.getActivityExperienceSource() == 0 && null == activityExperience.getActivityExperience()) {
activityExperience.setActivityExperience(0L);
} else if (activityExperience1.getActivityExperienceSource() == 1) {
activityExperience.setActivityExperienceSource(1);
}
activityExperience.setEvaluate(1);
} else {
activityExperience.setUpdateById(res.getAccountId());
activityExperience.setUpdateByName(res.getAccountFullName());
activityExperience.setUpdateTime(new Date());
if (null == activityExperience.getActivityExperience()) {
activityExperience.setActivityExperience(0L);
}
activityExperience.setEvaluate(1);
}
updateList.add(activityExperience);
}
return this.updateBatchById(updateList);
}
@Override
public List<ExperienceRulesVO> getExperienceRules(Long poolId) {
List<ExperienceRulesVO> resultList = new ArrayList<>();
ExperienceRulesVO experienceRulesVO = null;
List<ProjectActivityExperience> activityExperienceList = activityExperienceMapper.getActivityExperienceList(poolId);
if (CollectionUtils.isNotEmpty(activityExperienceList)) {
for (ProjectActivityExperience projectActivityExperience : activityExperienceList) {
//判断是否是完成即获取,如果是直接拿出数据组装
if (projectActivityExperience.getActivityExperienceSource() == 0) {
experienceRulesVO = new ExperienceRulesVO();
experienceRulesVO.setType(projectActivityExperience.getType());
experienceRulesVO.setName(projectActivityExperience.getActivityName());
experienceRulesVO.setExperienceSource(1);
experienceRulesVO.setExperience(null == projectActivityExperience.getActivityExperience() ? "0" : projectActivityExperience.getActivityExperience().toString());
resultList.add(experienceRulesVO);
} else {
//如果不是,查找规则设置再分别组装
List<ProjectActivityExperienceSet> activityExperienceSetList = new ArrayList<>();
ProjectActivityExperienceSet activityExperienceSet = new ProjectActivityExperienceSet();
activityExperienceSet.setProjectActivityExperienceId(projectActivityExperience.getId());
EntityWrapper<ProjectActivityExperienceSet> entityWrapper = new EntityWrapper<>(activityExperienceSet);
activityExperienceSetList = activityExperienceSetMapper.selectList(entityWrapper);
if (CollectionUtils.isNotEmpty(activityExperienceSetList)) {
for (ProjectActivityExperienceSet projectActivityExperienceSet : activityExperienceSetList) {
experienceRulesVO = new ExperienceRulesVO();
if (projectActivityExperienceSet.getSetType() == 1) {
experienceRulesVO.setType(projectActivityExperience.getType());
experienceRulesVO.setName(projectActivityExperience.getActivityName());
experienceRulesVO.setExperienceSource(2);
experienceRulesVO.setMinScore(projectActivityExperienceSet.getMinScore());
Integer maxScore = activityExperienceSetMapper.getMaxScore(projectActivityExperienceSet.getProjectActivityExperienceId(), projectActivityExperienceSet.getMinScore());
experienceRulesVO.setMaxScore(maxScore);
experienceRulesVO.setExperience(projectActivityExperienceSet.getExperience().toString());
resultList.add(experienceRulesVO);
} else {
experienceRulesVO.setType(projectActivityExperience.getType());
experienceRulesVO.setName(projectActivityExperience.getActivityName());
experienceRulesVO.setExperienceSource(3);
experienceRulesVO.setExperience("成绩" + "*" + projectActivityExperienceSet.getTimes());
resultList.add(experienceRulesVO);
}
}
}
}
}
}
return resultList;
}
}
package com.yizhi.application.service.impl;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.application.domain.ProjectActivityExperience;
import com.yizhi.application.domain.ProjectActivityExperienceSet;
import com.yizhi.application.mapper.ProjectActivityExperienceSetMapper;
import com.yizhi.application.service.IProjectActivityExperienceService;
import com.yizhi.application.service.IProjectActivityExperienceSetService;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.application.orm.id.IdGenerator;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* <p>
* 服务实现类
* </p>
*
* @author ding
* @since 2018-11-06
*/
@Service
public class ProjectActivityExperienceSetServiceImpl extends ServiceImpl<ProjectActivityExperienceSetMapper, ProjectActivityExperienceSet> implements IProjectActivityExperienceSetService {
@Autowired
private IdGenerator idGenerator;
@Autowired
private IProjectActivityExperienceService activityExperienceService;
@Override
public Map<String, Object> getSets(Long activityExperienceId, Integer setType) {
Map<String, Object> map = new HashMap<>();
List<ProjectActivityExperienceSet> activityExperienceSets = new ArrayList<>();
ProjectActivityExperienceSet activityExperienceSet = new ProjectActivityExperienceSet();
activityExperienceSet.setProjectActivityExperienceId(activityExperienceId);
EntityWrapper<ProjectActivityExperienceSet> entityWrapper = new EntityWrapper<>(activityExperienceSet);
activityExperienceSets = this.selectList(entityWrapper);
if (CollectionUtils.isNotEmpty(activityExperienceSets)) {
Integer type = activityExperienceSets.get(0).getSetType();
map.put("type", type);
map.put("activityExperienceSets", activityExperienceSets);
}
return map;
}
@Override
public Map<String, Object> insertSet(Long activityExperienceSetId, Long activityExperienceId, Integer setType, Integer minScore, Long experience) {
Map<String, Object> resultMap = new HashMap<>();
//校验成绩,经验值是否存在
ProjectActivityExperienceSet activityExperienceSet1 = new ProjectActivityExperienceSet();
activityExperienceSet1.setMinScore(minScore);
activityExperienceSet1.setProjectActivityExperienceId(activityExperienceId);
EntityWrapper<ProjectActivityExperienceSet> entityWrapper1 = new EntityWrapper<>(activityExperienceSet1);
if (null != activityExperienceSetId) {
if (this.selectById(activityExperienceSetId).getMinScore() != minScore && CollectionUtils.isNotEmpty(this.selectList(entityWrapper1))) {
resultMap.put("isOk", false);
return resultMap;
} else {
activityExperienceSet1 = new ProjectActivityExperienceSet();
activityExperienceSet1.setExperience(experience);
activityExperienceSet1.setProjectActivityExperienceId(activityExperienceId);
entityWrapper1 = new EntityWrapper<>(activityExperienceSet1);
if (this.selectById(activityExperienceSetId).getExperience() != experience && CollectionUtils.isNotEmpty(this.selectList(entityWrapper1))) {
resultMap.put("isOk", false);
return resultMap;
} else {
resultMap.put("isOk", true);
}
}
} else {
if (CollectionUtils.isNotEmpty(this.selectList(entityWrapper1))) {
resultMap.put("isOk", false);
return resultMap;
} else {
activityExperienceSet1 = new ProjectActivityExperienceSet();
activityExperienceSet1.setExperience(experience);
activityExperienceSet1.setProjectActivityExperienceId(activityExperienceId);
entityWrapper1 = new EntityWrapper<>(activityExperienceSet1);
if (CollectionUtils.isNotEmpty(this.selectList(entityWrapper1))) {
resultMap.put("isOk", false);
return resultMap;
} else {
resultMap.put("isOk", true);
}
}
}
ProjectActivityExperienceSet activityExperienceSet = new ProjectActivityExperienceSet();
RequestContext res = ContextHolder.get();
activityExperienceSet.setProjectActivityExperienceId(activityExperienceId);
activityExperienceSet.setSetType(1);
activityExperienceSet.setMinScore(minScore);
activityExperienceSet.setExperience(experience);
ProjectActivityExperience projectActivityExperience1 = new ProjectActivityExperience();
projectActivityExperience1.setId(activityExperienceId);
projectActivityExperience1.setActivityExperienceSource(1);
projectActivityExperience1.setUpdateById(res.getAccountId());
projectActivityExperience1.setUpdateByName(res.getAccountFullName());
projectActivityExperience1.setUpdateTime(new Date());
activityExperienceService.updateById(projectActivityExperience1);
if (null == activityExperienceSetId) {
//如果是新建,生成id入库
Long id = idGenerator.generate();
activityExperienceSet.setId(id);
activityExperienceSet.setCreateById(res.getAccountId());
activityExperienceSet.setCreateByName(res.getAccountFullName());
activityExperienceSet.setCreateTime(new Date());
this.insert(activityExperienceSet);
} else {
//如果是修改,更新入库
activityExperienceSet.setId(activityExperienceSetId);
activityExperienceSet.setUpdateById(res.getAccountId());
activityExperienceSet.setUpdateByName(res.getAccountFullName());
activityExperienceSet.setUpdateTime(new Date());
this.updateById(activityExperienceSet);
}
//返回列表按分数从高到低排列,并将对应项目经验对象source改为1
ProjectActivityExperience projectActivityExperience = new ProjectActivityExperience();
projectActivityExperience = activityExperienceService.selectById(activityExperienceId);
projectActivityExperience.setActivityExperienceSource(1);
projectActivityExperience.setUpdateById(res.getAccountId());
projectActivityExperience.setUpdateByName(res.getAccountFullName());
projectActivityExperience.setUpdateTime(new Date());
activityExperienceService.updateById(projectActivityExperience);
ProjectActivityExperienceSet projectActivityExperienceSet = new ProjectActivityExperienceSet();
projectActivityExperienceSet.setProjectActivityExperienceId(activityExperienceId);
projectActivityExperienceSet.setSetType(1);
EntityWrapper<ProjectActivityExperienceSet> entityWrapper = new EntityWrapper<>(projectActivityExperienceSet);
entityWrapper.orderBy("minScore", false);
resultMap.put("list", this.selectList(entityWrapper));
return resultMap;
}
@Override
public Map<String, Object> insertSetWithScore(Long activityExperienceSetId, Long activityExperienceId, Integer setType, Integer times) {
ProjectActivityExperienceSet activityExperienceSet = new ProjectActivityExperienceSet();
RequestContext res = ContextHolder.get();
Map<String, Object> map = new HashMap<>();
ProjectActivityExperience activityExperience = null;
//如果是按考试范围确定直接将对象的source值返回
if (setType == 1) {
activityExperience = activityExperienceService.selectById(activityExperienceId);
activityExperienceSet.setProjectActivityExperienceId(activityExperienceId);
activityExperienceSet.setSetType(2);
EntityWrapper<ProjectActivityExperienceSet> entityWrapper = new EntityWrapper<>(activityExperienceSet);
this.delete(entityWrapper);
map.put("activityExperienceId", activityExperienceId);
map.put("source", activityExperience.getActivityExperienceSource());
} else if (setType == 2) {
//如果是新建,新建对象并入库
if (null == activityExperienceSetId) {
//如果之前有倍数设置,删除
ProjectActivityExperienceSet activityExperienceSet1 = new ProjectActivityExperienceSet();
activityExperienceSet1.setProjectActivityExperienceId(activityExperienceId);
activityExperienceSet1.setSetType(2);
this.delete(new EntityWrapper<>(activityExperienceSet1));
activityExperienceSet.setId(idGenerator.generate());
activityExperienceSet.setProjectActivityExperienceId(activityExperienceId);
activityExperienceSet.setTimes(times);
activityExperienceSet.setSetType(2);
activityExperienceSet.setCreateById(res.getAccountId());
activityExperienceSet.setCreateByName(res.getAccountFullName());
activityExperienceSet.setCreateTime(new Date());
this.insert(activityExperienceSet);
} else {
//如果是修改,找出对象修改并入库
activityExperienceSet = this.selectById(activityExperienceSetId);
if (null != times) {
activityExperienceSet.setTimes(times);
}
activityExperienceSet.setUpdateTime(new Date());
activityExperienceSet.setUpdateById(res.getAccountId());
activityExperienceSet.setUpdateByName(res.getAccountFullName());
this.updateById(activityExperienceSet);
}
//如果倍数非空,则将source状态改为1
if (null != times) {
activityExperience = activityExperienceService.selectById(activityExperienceId);
activityExperience.setActivityExperienceSource(1);
activityExperience.setCreateById(res.getAccountId());
activityExperience.setUpdateByName(res.getAccountFullName());
activityExperience.setUpdateTime(new Date());
activityExperienceService.updateById(activityExperience);
}
map.put("activityExperienceId", activityExperienceId);
map.put("source", 1);
}
return map;
}
}
package com.yizhi.application.service.impl;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.assignment.application.feign.AssignmentClient;
import com.yizhi.course.application.feign.RecordeClient;
import com.yizhi.application.constant.PoolConstant;
import com.yizhi.application.domain.*;
import com.yizhi.application.listener.ExperienceListener;
import com.yizhi.application.mapper.ExperiencePoolProjectMapper;
import com.yizhi.application.mapper.ProjectActivityExperienceSetMapper;
import com.yizhi.application.mapper.StudentExperienceMapper;
import com.yizhi.application.service.IExperiencePoolAuthorizeService;
import com.yizhi.application.service.IExperiencePoolService;
import com.yizhi.application.service.IProjectActivityExperienceSetService;
import com.yizhi.application.service.IStudentExperienceService;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.core.application.event.EventWrapper;
import com.yizhi.core.application.publish.CloudEventPublisher;
import com.yizhi.core.application.task.AbstractTaskHandler;
import com.yizhi.core.application.task.TaskExecutor;
import com.yizhi.custom.api.vo.custom.ExamRuleListVo;
import com.yizhi.custom.api.vo.custom.ExperienceOrgRankingVO;
import com.yizhi.custom.api.vo.custom.ExperiencePoolExamRuleVo;
import com.yizhi.custom.api.vo.custom.ExperiencePoolRuleVo;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.exam.application.feign.ExamAnswerClient;
import com.yizhi.point.application.feign.PointActivityFeignClients;
import com.yizhi.point.application.vo.PointParamVO;
import com.yizhi.system.application.system.remote.OrganizationClient;
import com.yizhi.system.application.system.remote.ReportClient;
import com.yizhi.system.application.vo.ReportAccountRespVO;
import com.yizhi.system.application.vo.ReportRangeAccountReqVO;
import com.yizhi.util.application.constant.QueueConstant;
import com.yizhi.util.application.event.TrainingProjectEvent;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
* 项目关联活动经验值表 服务实现类
* </p>
*
* @author dingxiaowei123
* @since 2018-11-12
*/
@Service
public class StudentExperienceServiceImpl extends ServiceImpl<StudentExperienceMapper, StudentExperience> implements IStudentExperienceService {
private static final Logger LOGGER = LoggerFactory.getLogger(StudentExperienceServiceImpl.class);
@Autowired
private IdGenerator idGenerator;
@Autowired
private StudentExperienceMapper studentExperienceMapper;
@Autowired
private IExperiencePoolService poolService;
@Autowired
private IProjectActivityExperienceSetService experienceSetService;
@Autowired
private ProjectActivityExperienceSetMapper experienceSetMapper;
@Autowired
private ExperiencePoolProjectMapper experiencePoolProjectMapper;
@Autowired
private ExperienceListener experienceListener;
@Autowired
private PointActivityFeignClients pointActivityFeignClients;
@Autowired
private RecordeClient recordeClient;
@Autowired
private ExamAnswerClient examAnswerClient;
@Autowired
private IExperiencePoolAuthorizeService experiencePoolAuthorizeService;
@Autowired
private ReportClient reportClient;
@Autowired
private OrganizationClient organizationClient;
@Autowired
private AssignmentClient assignmentClient;
@Autowired
private TaskExecutor taskExecutor;
@Autowired
private CloudEventPublisher cloudEventPublisher;
@Override
public boolean insertStudentExperienceList(List<StudentExperience> studentExperienceList) {
if (CollectionUtils.isNotEmpty(studentExperienceList)) {
for (StudentExperience studentExperience : studentExperienceList) {
//获取id
studentExperience.setId(idGenerator.generate());
studentExperience.setCreateTime(new Date());
}
}
LOGGER.info("----------", studentExperienceList.size());
return this.insertOrUpdateBatch(studentExperienceList);
}
@Override
public List<ExperiencePoolRuleVo> getRules(Long activityId, Long compantyId, Long siteId, Long accountId) {
List<ExperiencePoolRuleVo> experiencePoolRuleVos = studentExperienceMapper.getRules(activityId, compantyId, siteId);
if (CollectionUtils.isNotEmpty(experiencePoolRuleVos)) {
for (ExperiencePoolRuleVo experiencePoolRuleVo : experiencePoolRuleVos) {
if (experiencePoolRuleVo.getVisibleRange() == 1) {
continue;
} else {
//如果是指定范围,验证指定范围
ExperiencePoolAuthorize experiencePoolAuthorize = new ExperiencePoolAuthorize();
experiencePoolAuthorize.setExperienceId(experiencePoolRuleVo.getExperiencePoolId());
List<ExperiencePoolAuthorize> authorizeList = experiencePoolAuthorizeService.selectList(new EntityWrapper<>(experiencePoolAuthorize));
if (CollectionUtils.isNotEmpty(authorizeList)) {
List<Long> accountIds = authorizeList.stream().map(ExperiencePoolAuthorize::getRelationId).collect(Collectors.toList());
if (null != accountId) {
//如果实时发放
if (!accountIds.contains(accountId)) {
continue;
}
} else {
//如果补发
experiencePoolRuleVo.setAccountIds(accountIds);
}
} else {
continue;
}
}
}
}
return experiencePoolRuleVos;
}
@Override
public void insertStudentExperience(StudentExperience studentExperience) {
if (null != studentExperience) {
studentExperience.setId(idGenerator.generate());
this.insert(studentExperience);
}
}
@Override
public List<ExperiencePoolExamRuleVo> getExamRules(Long activityId, Long compantyId, Long siteId, Long accountId, Integer type) {
List<ExperiencePoolExamRuleVo> list = new ArrayList<>();
ExperiencePool experiencePool = new ExperiencePool();
experiencePool.setCompanyId(compantyId);
experiencePool.setSiteId(siteId);
experiencePool.setState(2);
EntityWrapper<ExperiencePool> entityWrapper = new EntityWrapper<>(experiencePool);
List<ExperiencePool> poolList = poolService.selectList(entityWrapper);
if (CollectionUtils.isNotEmpty(poolList)) {
for (ExperiencePool experiencePool1 : poolList) {
ExperiencePoolExamRuleVo examRuleVo = new ExperiencePoolExamRuleVo();
//如果是指定范围,验证指定范围
if (experiencePool1.getVisibleRange() == 2) {
ExperiencePoolAuthorize experiencePoolAuthorize = new ExperiencePoolAuthorize();
experiencePoolAuthorize.setExperienceId(experiencePool1.getId());
List<ExperiencePoolAuthorize> authorizeList = experiencePoolAuthorizeService.selectList(new EntityWrapper<>(experiencePoolAuthorize));
if (CollectionUtils.isNotEmpty(authorizeList)) {
List accountIds = authorizeList.stream().map(ExperiencePoolAuthorize::getRelationId).collect(Collectors.toList());
if (accountId == null) {
//补发验证实时发放验证
examRuleVo.setAccountIds(accountIds);
} else {
//实时发放验证
if (!accountIds.contains(accountId)) {
continue;
}
}
} else {
continue;
}
}
ProjectActivityExperience activityExperience = studentExperienceMapper.getExamRules(experiencePool1.getId(), activityId);
if (null == activityExperience) {
continue;
}
examRuleVo.setExperiencePoolId(experiencePool1.getId());
examRuleVo.setBizId(activityId);
examRuleVo.setBizName(activityExperience.getActivityName());
examRuleVo.setType(type);
//如果无其他条件
if (activityExperience.getActivityExperienceSource() == 0) {
examRuleVo.setExperienceType(1);
ExamRuleListVo examRuleListVo = new ExamRuleListVo();
examRuleListVo.setExperience(activityExperience.getActivityExperience());
List<ExamRuleListVo> examRuleListVoList = new ArrayList<>();
examRuleListVoList.add(examRuleListVo);
examRuleVo.setRuleList(examRuleListVoList);
list.add(examRuleVo);
} else {
ProjectActivityExperienceSet experienceSet = new ProjectActivityExperienceSet();
experienceSet.setProjectActivityExperienceId(activityExperience.getId());
EntityWrapper<ProjectActivityExperienceSet> entityWrapper1 = new EntityWrapper<>(experienceSet);
entityWrapper1.orderBy("min_score", true);
List<ProjectActivityExperienceSet> experienceSetList = experienceSetService.selectList(entityWrapper1);
if (CollectionUtils.isNotEmpty(experienceSetList)) {
//按考试成绩范围
if (experienceSetList.get(0).getSetType() == 1) {
List<ExamRuleListVo> examRuleListVoList = new ArrayList<>();
for (ProjectActivityExperienceSet experienceSet1 : experienceSetList) {
Integer minScore = experienceSet1.getMinScore();
Integer maxScore = experienceSetMapper.getMaxScore(experienceSet1.getProjectActivityExperienceId(), minScore);
ExamRuleListVo examRuleListVo = new ExamRuleListVo();
examRuleListVo.setMinScore(minScore);
examRuleListVo.setExperience(experienceSet1.getExperience());
if (null != maxScore) {
examRuleListVo.setMaxScore(maxScore);
}
examRuleListVoList.add(examRuleListVo);
}
examRuleVo.setExperienceType(2);
examRuleVo.setRuleList(examRuleListVoList);
} else {
//按考试成绩倍数
List<ExamRuleListVo> examRuleListVoList = new ArrayList<>();
ExamRuleListVo examRuleListVo = new ExamRuleListVo();
examRuleListVo.setTimes(experienceSetList.get(0).getTimes());
examRuleListVoList.add(examRuleListVo);
examRuleVo.setExperienceType(3);
examRuleVo.setRuleList(examRuleListVoList);
}
}
list.add(examRuleVo);
}
}
}
return list;
}
/**
* 经验池手动补发经验
*
* @param experiencePoolId
* @return
*/
@Override
public boolean pushStudentExperience(Long experiencePoolId, Long activityId, String activityName, Integer activityType, List<Long> accountIds, RequestContext requestContext) {
ExperiencePoolProject experiencePoolProject = new ExperiencePoolProject();
Long companyId = requestContext.getCompanyId();
Long siteId = requestContext.getSiteId();
//获取用户信息并放入map中
ReportRangeAccountReqVO reqVO = new ReportRangeAccountReqVO();
reqVO.setSiteId(siteId);
reqVO.setAccountIds(accountIds);
List<ReportAccountRespVO> accounts = reportClient.getRangeAccounts(reqVO);
Map<Long, ReportAccountRespVO> map = new HashMap<>(16);
if (CollectionUtils.isNotEmpty(accounts)) {
for (ReportAccountRespVO account : accounts) {
map.put(account.getUserId(), account);
}
}
if (activityType.equals(PoolConstant.EXAMTYPE) || activityType.equals(PoolConstant.ASSIGNMENTTYPE)) {
//查找经验发放规则
List<ExperiencePoolExamRuleVo> examRuleVos = this.getExamRules(activityId, companyId, siteId, null, activityType);
if (CollectionUtils.isNotEmpty(examRuleVos)) {
for (ExperiencePoolExamRuleVo examRuleVo : examRuleVos) {
//如果找到对应经验池相关经验发放规则
if (examRuleVo.getExperiencePoolId().equals(experiencePoolId)) {
for (Long accountId : accountIds) {
if (CollectionUtils.isNotEmpty(examRuleVo.getAccountIds())) {
if (!examRuleVo.getAccountIds().contains(accountId)) {
continue;
}
}
PointParamVO vo = new PointParamVO();
ReportAccountRespVO accountRespVO = map.get(accountId);
vo.setAccountId(accountId);
vo.setCompanyId(companyId);
if (null != accountRespVO) {
vo.setOrgId(accountRespVO.getOrgId());
} else {
continue;
}
vo.setSiteId(siteId);
vo.setActivityName(activityName);
if (examRuleVo.getExperienceType() == 1) {
ExperiencePoolRuleVo experiencePoolRuleVo = new ExperiencePoolRuleVo();
experiencePoolRuleVo.setExperiencePoolId(examRuleVo.getExperiencePoolId());
experiencePoolRuleVo.setType(examRuleVo.getType());
experiencePoolRuleVo.setBizId(examRuleVo.getBizId());
experiencePoolRuleVo.setBizName(examRuleVo.getBizName());
experiencePoolRuleVo.setExperience(examRuleVo.getRuleList().get(0).getExperience());
boolean success = experienceListener.addExperience(experiencePoolRuleVo, vo, activityType);
if (success) {
LOGGER.info("考试{}中学员{}经验补发成功", activityId, accountId);
} else {
LOGGER.info("考试{}中学员{}经验补发失败", activityId, accountId);
}
} else {
Integer score = null;
if (activityType.equals(PoolConstant.EXAMTYPE)) {
score = examAnswerClient.getMaxScore(activityId, accountId, companyId, siteId);
} else {
score = assignmentClient.getScore(activityId, siteId, companyId, accountId);
}
if (null == score) {
LOGGER.info("未找到考试{}中学员{}的考试分数", accountId, accountId);
continue;
}
vo.setScore(score);
boolean success = experienceListener.addScoreExperience(examRuleVo, vo, activityType);
if (success) {
LOGGER.info("考试{}中学员{}经验补发成功", activityId, accountId);
} else {
LOGGER.info("考试{}中学员{}经验补发失败", activityId, accountId);
}
}
}
}
}
return true;
}
} else {
List<ExperiencePoolRuleVo> ruleVoList = this.getRules(activityId, companyId, siteId, null);
if (CollectionUtils.isNotEmpty(ruleVoList)) {
for (ExperiencePoolRuleVo ruleVo : ruleVoList) {
//如果找到相关经验发放规则
if (ruleVo.getExperiencePoolId().equals(experiencePoolId)) {
if (activityType.equals(PoolConstant.COURSETYPE)) {
for (Long accountId : accountIds) {
//如果是指定范围,验证是否在指定范围
if (CollectionUtils.isNotEmpty(ruleVo.getAccountIds())) {
if (!ruleVo.getAccountIds().contains(accountId)) {
continue;
}
}
PointParamVO vo = new PointParamVO();
ReportAccountRespVO accountRespVO = map.get(accountId);
vo.setAccountId(accountId);
vo.setCompanyId(companyId);
if (null != accountRespVO) {
vo.setOrgId(accountRespVO.getOrgId());
} else {
continue;
}
vo.setSiteId(siteId);
vo.setActivityName(activityName);
Date time = new Date();
boolean finalIsFinished = true;
taskExecutor.asynExecute(new AbstractTaskHandler() {
@Override
public void handle() {
try {
cloudEventPublisher.publish(QueueConstant.TRAINING_PROJECT_EVENT_QUEUE,
new EventWrapper<TrainingProjectEvent>(ruleVo.getBizId(),
TrainingProjectEvent.getInstanceCourse(ruleVo.getBizId(), accountId, time, 0L,
finalIsFinished, requestContext.getSiteId(), 1)));
} catch (Exception e) {
e.printStackTrace();
LOGGER.error("发送课程:(" + ruleVo.getBizName() + ") 完成信息到trainingProject异常:", e);
}
}
});
boolean success = experienceListener.addExperience(ruleVo, vo, PoolConstant.COURSETYPE);
if (success) {
LOGGER.info("课程{}中学员{}经验补发成功", activityId, accountId);
} else {
LOGGER.info("课程{}中学员{}经验补发失败", activityId, accountId);
}
}
} else if (activityType.equals(PoolConstant.RESEARCHTYPE)) {
for (Long accountId : accountIds) {
//如果是指定范围,验证是否在指定范围
if (CollectionUtils.isNotEmpty(ruleVo.getAccountIds())) {
if (!ruleVo.getAccountIds().contains(accountId)) {
continue;
}
}
PointParamVO vo = new PointParamVO();
ReportAccountRespVO accountRespVO = map.get(accountId);
vo.setAccountId(accountId);
vo.setCompanyId(companyId);
if (null != accountRespVO) {
vo.setOrgId(accountRespVO.getOrgId());
} else {
continue;
}
vo.setSiteId(siteId);
vo.setActivityName(activityName);
boolean success = experienceListener.addExperience(ruleVo, vo, PoolConstant.RESEARCHTYPE);
if (success) {
LOGGER.info("调研{}中学员{}经验补发成功", activityId, accountId);
} else {
LOGGER.info("调研{}中学员{}经验补发失败", activityId, accountId);
}
}
} else if (activityType.equals(PoolConstant.VOTETYPE)) {
for (Long accountId : accountIds) {
//如果是指定范围,验证是否在指定范围
if (CollectionUtils.isNotEmpty(ruleVo.getAccountIds())) {
if (!ruleVo.getAccountIds().contains(accountId)) {
continue;
}
}
PointParamVO vo = new PointParamVO();
ReportAccountRespVO accountRespVO = map.get(accountId);
vo.setAccountId(accountId);
vo.setCompanyId(companyId);
if (null != accountRespVO) {
vo.setOrgId(accountRespVO.getOrgId());
} else {
continue;
}
vo.setSiteId(siteId);
vo.setActivityName(activityName);
boolean success = experienceListener.addExperience(ruleVo, vo, PoolConstant.VOTETYPE);
if (success) {
LOGGER.info("投票{}中学员{}经验补发成功", activityId, accountId);
} else {
LOGGER.info("投票{}中学员{}经验补发失败", activityId, accountId);
}
}
}
}
}
return true;
}
}
return false;
}
@Override
public Page<ExperienceOrgRankingVO> getOrgRanking(Long poolId, Integer pageNo, Integer pageSize, Integer type) {
Page<ExperienceOrgRankingVO> page = new Page<>(pageNo, pageSize);
if (type == 0) {
List<ExperienceOrgRankingVO> list = studentExperienceMapper.getOrgRankings(poolId, page);
if (CollectionUtils.isNotEmpty(list)) {
List<Long> orgIds = list.stream().map(ExperienceOrgRankingVO::getOrgId).collect(Collectors.toList());
Map<Long, String> map = organizationClient.getOrgNames(orgIds);
for (ExperienceOrgRankingVO rankingVO : list) {
if (null != map) {
rankingVO.setOrgName(map.get(rankingVO.getOrgId()));
}
Integer total = studentExperienceMapper.getOrgRanking(poolId, rankingVO.getTotalExperience());
if (null == total) {
total = 0;
} else {
total += 1;
}
rankingVO.setRankings(total);
}
page.setRecords(list);
}
} else if (type == 1) {
//获得按组别排名(平均经验)
List<ExperienceOrgRankingVO> list = studentExperienceMapper.getGroupRankings(poolId, page);
//获得名次(平均经验)
if (CollectionUtils.isNotEmpty(list)) {
for (ExperienceOrgRankingVO experienceOrgRankingVO : list) {
Integer total = studentExperienceMapper.getGroupRanking(poolId, experienceOrgRankingVO.getTotalExperience());
if (null == total) {
total = 0;
} else {
total += 1;
}
experienceOrgRankingVO.setRankings(total);
}
page.setRecords(list);
}
} else if (type == 2) {
//获得按组别排名,可导入外部经验(平均经验,每个部门新建一个人专门导入经验,算平均分的时候不算在内)
List<ExperienceOrgRankingVO> list = studentExperienceMapper.getGroupRankingsWithImport(poolId, page);
//获得名次(平均经验)
if (CollectionUtils.isNotEmpty(list)) {
for (ExperienceOrgRankingVO experienceOrgRankingVO : list) {
Integer total = studentExperienceMapper.getGroupRanking(poolId, experienceOrgRankingVO.getTotalExperience());
if (null == total) {
total = 0;
} else {
total += 1;
}
experienceOrgRankingVO.setRankings(total);
}
page.setRecords(list);
}
}
return page;
}
@Override
public Long getTotalExperience(Long poolId, Long accountId) {
return studentExperienceMapper.getAccountTotalExperience(poolId, accountId);
}
}
//package com.yizhi.application.util;
//
//import org.springframework.boot.SpringApplication;
//import org.springframework.boot.autoconfigure.SpringBootApplication;
//import org.springframework.cache.annotation.EnableCaching;
//import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
//import org.springframework.cloud.netflix.feign.EnableFeignClients;
//
///**
// * @author Ding
// * @className CustomProjectApplication
// * @description TODO
// * @date 2018/11/12
// **/
//
///*@SpringBootApplication
//@EnableEurekaClient
//@EnableCaching
//@EnableFeignClients(basePackages = {"com.yizhi"})*/
//public class CustomProjectApplication {
// public static void main(String[] args) {
// SpringApplication.run(CustomProjectApplication.class, args);
// }
//}
server.port=34008
spring.application.name=customproject
ACTIVE=${spring.profiles.active}
spring.profiles.active=dev
# 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.22:3333,192.168.1.22:4444,192.168.1.22:5555
\ No newline at end of file
<?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.CodePackageManageMapper">
<select id="getCodePackageManageList" resultType="com.yizhi.application.domain.CodePackageManage">
select c.id,c.code_package_name,c.import_time,c.url
from code_package_manage c
where c.company_id = #{companyId}
and c.site_id = #{siteId}
order by c.create_time desc
</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.ExperiencePoolProjectMapper">
<select id="getExperiencePoolProjectList" resultType="com.yizhi.application.domain.ExperiencePoolProject">
select e.biz_name,type,e.biz_id
from experience_pool_project e
where e.experience_id = #{experiencePoolId}
order by type,e.create_time desc
</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.ExperiencePoolAuthorizeMapper">
<select id="getListMap" resultType="java.util.Map">
SELECT e.id ,e.`name`,e.type,e.relation_id
FROM experience_pool_authorize e
where e.experience_id = #{experiencePoolId}
</select>
<select id="getExperiencePoolAuthorizeByPoolIdAndAccountId" resultType="com.yizhi.application.domain.ExperiencePoolAuthorize">
SELECT *
FROM experience_pool_authorize
where experience_id = #{poolId} AND relation_id = #{accountId}
</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.ExperiencePoolMapper">
<select id="getExperiencePoolList" resultType="com.yizhi.application.domain.ExperiencePool">
select *
from experience_pool e
where e.company_id = #{param.companyId}
and e.site_id = #{param.siteId}
order by e.create_time desc
</select>
<select id="getPoolReportList" resultType="com.yizhi.custom.api.vo.custom.ExperiencePoolReportVo">
SELECT e.id as experiencePoolId,e.experience_pool_name ,e.visible_range as visibleRange,
e.create_time as poolCreateTime,IFNULL(b.num,0) as rangeAcountNum
FROM experience_pool e
LEFT JOIN (select experience_id , COUNT(relation_id) as num from experience_pool_authorize
where 1=1
<if test="accountIds != null and accountIds.size()>0">
and relation_id in
<foreach item="item" index="index" collection="accountIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
GROUP BY
experience_id)b
on e.id = b.experience_id and e.company_id = #{companyId} and e.site_id = #{siteId}
<if test="poolName != null and poolName != ''">
and e.experience_pool_name like CONCAT("%",#{poolName},"%")
</if>
where e.company_id = #{companyId} and e.site_id = #{siteId}
<if test="poolName != null and poolName != ''">
and e.experience_pool_name like CONCAT("%",#{poolName},"%")
</if>
and e.state = 2
ORDER BY e.create_time DESC
</select>
<select id="selectByPoolId" resultType="com.yizhi.application.domain.ExperiencePool">
select *
from experience_pool e
where id = #{poolId}
</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.ExperienceRecordMapper">
</mapper>
\ No newline at end of file
<?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.MyExperienceMapper">
<select id="getMyExperiencePoolAndLevel" resultType="com.yizhi.custom.api.vo.custom.MyExperienceLevelVo">
SELECT a.level_no AS levelCode,a.level_name,b.experienceTotal
FROM experience_pool_level a
LEFT JOIN (
SELECT a.experience_pool_id,IFNULL(SUM(a.experience),0) AS experienceTotal
FROM student_experience a
WHERE a.account_id=#{accountId} AND a.experience_pool_id=#{poolId}
) b ON a.experience_pool_id=b.experience_pool_id
WHERE a.experience_pool_id=#{poolId} AND a.min_level_experience>=0 AND <![CDATA[ a.min_level_experience<=b.experienceTotal ]]>
AND a.state=1
ORDER BY min_level_experience DESC
LIMIT 0,1
</select>
<select id="getMyExperienceRanking" resultType="java.lang.Integer">
SELECT COUNT(1)
FROM (
SELECT
SUM(a.experience)
FROM student_experience a
<if test="group!=null and group!=''">
LEFT JOIN experience_pool_authorize b on a.account_id = b.relation_id
</if>
<if test="batchNo!=null and batchNo!=''">
LEFT JOIN experience_pool_authorize b on a.account_id = b.relation_id
</if>
WHERE a.experience_pool_id=#{poolId}
<if test="group!=null and group!=''">
and b.`group` = #{group}
</if>
<if test="batchNo!=null and batchNo!=''">
and b.batch_no = #{batchNo}
</if>
GROUP BY
a.account_id
having sum(a.experience) > #{experience}
) a
</select>
<select id="getMyExperiencePool" resultType="com.yizhi.custom.api.vo.custom.MyExperienceLevelVo">
SELECT (IFNULL(SUM(a.experience),0)) AS experienceTotal
FROM student_experience a
WHERE a.account_id=#{accountId} AND a.experience_pool_id=#{poolId}
</select>
<select id="getMyExperienceLevel" resultType="com.yizhi.application.domain.ExperiencePoolLevel">
SELECT a.id,experience_pool_id,level_no,level_name,min_level_experience
FROM experience_pool_level a
WHERE a.experience_pool_id=#{poolId} AND a.min_level_experience>=0 AND <![CDATA[ a.min_level_experience<=#{experience} ]]>
AND a.state=1
ORDER BY min_level_experience DESC
LIMIT 0,1
</select>
<select id="getMyExperienceRankings" resultType="com.yizhi.custom.api.vo.custom.MyExperienceRankingVo">
SELECT lv.account_id,lv.experience,lt.level_no AS levelCode,lt.level_name AS levelName
FROM (
SELECT a.*,MAX(b.min_level_experience) AS maxlevel
FROM(
SELECT a.experience_pool_id,a.account_id,SUM(IFNULL(a.experience,0)) AS experience
FROM student_experience a
LEFT JOIN (SELECT DISTINCT relation_id,`group` FROM experience_pool_authorize WHERE experience_id = #{poolId})b
on a.account_id = b.relation_id
WHERE a.experience_pool_id=#{poolId}
<if test="group!=null and group!=''">
and b.`group` = #{group}
</if>
<if test="batchNo!=null and batchNo!=''">
and b.batch_no = #{batchNo}
</if>
GROUP BY
a.account_id
ORDER BY SUM(IFNULL(a.experience,0)) DESC,account_id
LIMIT #{pageNo}, #{pageSize}
) a
LEFT JOIN experience_pool_level b ON b.experience_pool_id=#{poolId} AND
b.min_level_experience>=0 AND <![CDATA[ b.min_level_experience<=a.experience]]>
GROUP BY a.account_id
ORDER BY experience DESC,create_time,account_id
) lv
LEFT JOIN experience_pool_level lt ON lt.experience_pool_id=#{poolId} AND
lt.min_level_experience=lv.maxlevel
</select>
<select id="getMyExperienceRankingsPageTotal" resultType="java.lang.Integer">
SELECT COUNT(a.account_id)
FROM(
SELECT a.account_id
FROM student_experience a
LEFT JOIN experience_pool_authorize b ON b.experience_id=a.experience_pool_id AND b.relation_id=a.account_id
WHERE a.experience_pool_id=#{poolId}
<if test="group!=null and group!=''">
and b.`group` = #{group}
</if>
<if test="batchNo!=null and batchNo!=''">
and b.`batch_no` = #{batchNo}
</if>
GROUP BY
a.account_id
) a
</select>
<select id="getMyExperienceDtl" resultType="com.yizhi.custom.api.vo.custom.MyExperienceEventsVo">
SELECT a.type AS eventCode,
CASE WHEN a.type=1 THEN '课程' ELSE
CASE WHEN a.type=2 THEN '考试' ELSE
CASE WHEN a.type=3 THEN '调研' ELSE
CASE WHEN a.type=4 THEN '投票' ELSE
CASE WHEN a.type=5 THEN '外部导入' ELSE
a.type
END
END
END
END
END AS eventName,a.experience
FROM student_experience a
WHERE a.experience_pool_id=#{poolId} AND a.account_id=#{accountId}
</select>
<select id="getMyExperienceLevels" resultType="com.yizhi.custom.api.vo.custom.MyExperienceLevelVo">
SELECT a.level_no AS levelCode, a.level_name AS levelName,a.min_level_experience AS experienceTotal
FROM experience_pool_level a
WHERE a.state=1 AND a.experience_pool_id=#{poolId}
ORDER BY min_level_experience
</select>
<select id="getMyExperiencePoolInfo" resultType="com.yizhi.application.domain.StudentExperiencePool">
SELECT *
FROM student_experience_pool
WHERE experience_pool_id=#{poolId} AND account_id=#{accountId}
</select>
<select id="getMaxLoginCount" resultType="java.lang.Integer">
SELECT MAX(num)
FROM student_experience_pool
WHERE experience_pool_id=#{poolId}
AND DATE_FORMAT(create_time,'%y-%m') = DATE_FORMAT(NOW(),'%y-%m')
</select>
<select id="getMyExperienceLogin" resultType="com.yizhi.custom.api.vo.custom.MyExperiencePoolVo">
SELECT step,motto,now() AS nowTime,batch_no AS accountCode
FROM student_experience_pool
WHERE experience_pool_id=#{poolId} AND account_id=#{accountId}
</select>
<select id="getMyExperience" resultType="com.yizhi.custom.api.vo.custom.MyExperienceEventsVo">
SELECT a.type AS eventCode,
CASE WHEN a.type=1 THEN '课程' ELSE
CASE WHEN a.type=2 THEN '考试' ELSE
CASE WHEN a.type=3 THEN '调研' ELSE
CASE WHEN a.type=4 THEN '投票' ELSE
CASE WHEN a.type=5 THEN '外部导入' ELSE
a.type
END
END
END
END
END AS eventName,SUM(a.experience) as experience
FROM student_experience a
WHERE a.experience_pool_id=#{poolId} AND a.account_id=#{accountId}
GROUP BY a.type
</select>
<select id="getBatchGroup" resultType="java.util.Map">
select `group`,batch_no as batchNo,note from
experience_pool_authorize
where experience_id = #{poolId}
and relation_id = #{accountId}
</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.ProductMapper">
</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.ProjectActivityExperienceMapper">
<select id="getActivityExperienceList" resultType="com.yizhi.application.domain.ProjectActivityExperience">
SELECT b.*
FROM experience_pool_project a LEFT JOIN project_activity_experience b
ON b.experience_pool_project_id = a.id
where a.experience_id = #{poolId}
</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.ProjectActivityExperienceSetMapper">
<select id="getMaxScore" resultType="java.lang.Integer">
SELECT MIN(a.min_score)
FROM project_activity_experience_set a
where a.project_activity_experience_id = #{activityExperienceId}
and a.min_score > #{minScore}
</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.StudentExperienceMapper">
<select id="getReportViewList" resultType="com.yizhi.custom.api.vo.custom.ExperiencePoolReportExportVo">
select account_id,account_name,IFNULL(SUM(experience),0) as experienceTotal
from student_experience
where experience_pool_id =#{poolId}
<if test="ids!=null and ids.size()>0">
AND account_id in
<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
#{item}
</foreach>
</if>
group by account_id
ORDER BY experienceTotal desc,account_id
</select>
<select id="getRules" resultType="com.yizhi.custom.api.vo.custom.ExperiencePoolRuleVo">
SELECT b.experience_id as experiencePoolId,b.type,b.biz_id,b.biz_name,
IFNULL(a.activity_experience,0) as experience,c.visible_range as visibleRange
from project_activity_experience a
LEFT JOIN experience_pool_project b
on a.experience_pool_project_id = b.id
LEFT JOIN experience_pool c
on c.id = b.experience_id
where c.company_id = #{compantyId} and c.site_id = #{siteId} and b.biz_id = #{activityId}
</select>
<select id="getExamRules" resultType="com.yizhi.application.domain.ProjectActivityExperience">
SELECT a.*
from project_activity_experience a
LEFT JOIN experience_pool_project b
on a.experience_pool_project_id = b.id
where b.experience_id = #{poolId} and b.biz_id = #{activityId}
</select>
<select id="getOrgRankings" resultType="com.yizhi.custom.api.vo.custom.ExperienceOrgRankingVO">
select TRUNCATE(SUM(experience)/COUNT(DISTINCT account_id),1) as totalExperience,org_id as orgId from student_experience
where experience_pool_id = #{poolId}
GROUP BY org_id
ORDER BY totalExperience desc,org_id
</select>
<select id="getOrgRanking" resultType="java.lang.Integer">
select COUNT(1) from
(select TRUNCATE(SUM(experience)/COUNT(DISTINCT account_id),1) as totalExperience,org_id as orgId from student_experience
where experience_pool_id = #{poolId}
GROUP BY org_id
ORDER BY totalExperience desc,org_id)a
where a.totalExperience > #{totalExperience}
</select>
<select id="getGroupRankings" resultType="com.yizhi.custom.api.vo.custom.ExperienceOrgRankingVO">
select IFNULL(TRUNCATE(SUM(a.experience)/COUNT(DISTINCT a.account_id),1),0.0) as totalExperience,b.`group` as orgName
from experience_pool_authorize b
LEFT JOIN student_experience a on a.account_id = b.relation_id and a.experience_pool_id = #{poolId}
where b.experience_id = #{poolId}
GROUP BY b.`group`
ORDER BY totalExperience desc,org_id
</select>
<select id="getGroupRanking" resultType="java.lang.Integer">
SELECT COUNT(1) FROM
(select IFNULL(TRUNCATE(SUM(a.experience)/COUNT(DISTINCT a.account_id),1),0.0) as totalExperience
from experience_pool_authorize b
LEFT JOIN student_experience a on a.account_id = b.relation_id and a.experience_pool_id = #{poolId}
where b.experience_id = #{poolId}
and b.`group` is not NULL
GROUP BY b.`group`
HAVING totalExperience > #{totalExperience})a
</select>
<select id="getGroupRankingsWithImport" resultType="com.yizhi.custom.api.vo.custom.ExperienceOrgRankingVO">
select IFNULL(TRUNCATE(SUM(a.experience)/(COUNT(DISTINCT a.account_id)-1),1),0.0) as totalExperience,b.`group` as orgName,COUNT(DISTINCT a.account_id)
from experience_pool_authorize b
LEFT JOIN student_experience a on a.account_id = b.relation_id and a.experience_pool_id = #{poolId}
where b.experience_id = #{poolId}
GROUP BY b.`group`
ORDER BY totalExperience desc,org_id
</select>
<select id="viewAccountDetails" resultType="com.yizhi.custom.api.vo.custom.ExperiencePoolReportExportVo">
select account_id,experience,type,create_time,activity_id,activity_name
from student_experience
where experience_pool_id = #{poolId}
and account_id = #{accountId}
<if test="state!=null and state==1">
and experience > 0
</if>
<if test="state!=null and state==2">
and 0 > experience
</if>
ORDER BY create_time DESC,id
</select>
<select id="getTotalExperience" resultType="java.lang.Long">
select SUM(experience) from
(select experience FROM student_experience
where experience_pool_id = #{poolId}
and account_id = #{accountId}
LIMIT #{startIndex},#{endIndex})a
</select>
<select id="viewAllDetails" resultType="com.yizhi.custom.api.vo.custom.ExperiencePoolReportExportVo">
select account_id,experience,type,create_time,activity_id,activity_name
from student_experience
where experience_pool_id = #{poolId}
<if test="ids!=null and ids.size()>0">
AND account_id in
<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
#{item}
</foreach>
</if>
and experience != 0
<if test="state!=null and state==1">
and experience > 0
</if>
<if test="state!=null and state==2">
and 0 > experience
and type = 10
</if>
<if test="startTime!=null and endTime!=null">
and <![CDATA[ DATE_FORMAT(create_time,'%Y-%m-%d')>=DATE_FORMAT(#{startTime,jdbcType=VARCHAR},'%Y-%m-%d') ]]>
and <![CDATA[ DATE_FORMAT(create_time,'%Y-%m-%d')<=DATE_FORMAT(#{endTime,jdbcType=VARCHAR},'%Y-%m-%d') ]]>
</if>
ORDER BY create_time DESC,id
</select>
<select id="getPurchaseAndIncreaseExperienceTotal" resultType="java.util.Map">
SELECT
a.account_id AS accountId,
IFNULL( SUM( a.experience ), 0 ) AS increaseTotal,
IFNULL( b.experience , 0 ) AS purchaseTotal
FROM
student_experience a
LEFT JOIN (SELECT
account_id AS accountId,
SUM(experience) as experience,
experience_pool_id
FROM
student_experience
WHERE experience_pool_id = #{poolId} and <![CDATA[ experience < 0 ]]>
and type = 10
<if test="accountIds!=null and accountIds.size()>0">
AND account_id in
<foreach item="item" index="index" collection="accountIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="startTime!=null and endTime!=null">
AND <![CDATA[ create_time <= #{endTime} ]]>
AND <![CDATA[ create_time >= #{startTime} ]]>
</if>
GROUP BY
account_id)b
on a.account_id = b.accountId and a.experience_pool_id = b.experience_pool_id
WHERE a.experience_pool_id = #{poolId} AND a.experience > 0
<if test="accountIds!=null and accountIds.size()>0">
AND a.account_id in
<foreach item="item" index="index" collection="accountIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="startTime!=null and endTime!=null">
AND <![CDATA[ a.create_time <= #{endTime} ]]>
AND <![CDATA[ a.create_time >= #{startTime} ]]>
</if>
GROUP BY a.account_id
</select>
<select id="getAccountTotalExperience" resultType="java.lang.Long">
select IFNULL(sum(experience),0) FROM student_experience
where experience_pool_id = #{poolId}
and account_id = #{accountId}
</select>
</mapper>
<?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>customproject</artifactId>
<version>1.0-SNAPSHOT</version>
<modules>
<module>cloud-customproject-api</module>
<module>cloud-customproject</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>
<updatePolicy>always</updatePolicy>
</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