培训添加返回值
This commit is contained in:
@@ -23,13 +23,14 @@ public class EmployeeTrainingDAO {
|
||||
|
||||
public List<EmployeeTrainingVO> employeeTrainingList(String keyWord, List<String> regionIdList,
|
||||
List<String> authRegionIdList, Boolean assignFlag,
|
||||
String beginTime, String endTime, List<Long> shopIdList,
|
||||
String beginTime, String endTime, List<String> storeNumList,
|
||||
Integer theoreticalExamStatus,
|
||||
Integer practicalExamStatus,
|
||||
Integer assessmentStatus) {
|
||||
Integer assessmentStatus,
|
||||
Boolean assignStoreFlag) {
|
||||
|
||||
return employeeTrainingMapper.employeeTrainingMapper(keyWord, regionIdList, authRegionIdList, assignFlag, beginTime, endTime, shopIdList,
|
||||
theoreticalExamStatus, practicalExamStatus, assessmentStatus);
|
||||
return employeeTrainingMapper.employeeTrainingMapper(keyWord, regionIdList, authRegionIdList, assignFlag, beginTime, endTime, storeNumList,
|
||||
theoreticalExamStatus, practicalExamStatus, assessmentStatus, assignStoreFlag);
|
||||
}
|
||||
|
||||
public EmployeeTrainingDO selectById(Long id) {
|
||||
|
||||
@@ -41,4 +41,12 @@ public class StoreDao {
|
||||
return storeMapper.listStoreByRegionId(regionId);
|
||||
}
|
||||
|
||||
public List<String> getStoreNumByStoreIds(List<String> storeIdList) {
|
||||
if(CollectionUtils.isEmpty(storeIdList)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return storeMapper.getStoreNumByStoreIds(storeIdList);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -13,10 +13,11 @@ public interface EmployeeTrainingMapper extends Mapper<EmployeeTrainingDO> {
|
||||
|
||||
List<EmployeeTrainingVO> employeeTrainingMapper(@Param("keyWord") String keyWord, @Param("regionIdList") List<String> regionIdList,
|
||||
@Param("authRegionIdList") List<String> authRegionIdList, @Param("assignFlag") Boolean assignFlag,
|
||||
@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("shopIdList") List<Long> shopIdList,
|
||||
@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("storeNumList") List<String> storeNumList,
|
||||
@Param("theoreticalExamStatus") Integer theoreticalExamStatus,
|
||||
@Param("practicalExamStatus") Integer practicalExamStatus,
|
||||
@Param("assessmentStatus") Integer assessmentStatus);
|
||||
@Param("assessmentStatus") Integer assessmentStatus,
|
||||
@Param("assignStoreFlag") Boolean assignStoreFlag);
|
||||
|
||||
List<EmployeeTrainingVO> trainingListByShopId(@Param("shopId") Long shopId, @Param("trainingTeacherUserId") String trainingTeacherUserId,
|
||||
@Param("status") Integer status);
|
||||
|
||||
@@ -19,4 +19,7 @@ public interface StoreMapper {
|
||||
*/
|
||||
List<StoreDO> listStoreByRegionId(@Param("regionId") String regionId);
|
||||
|
||||
|
||||
List<String> getStoreNumByStoreIds(@Param("storeIds") List<String> storeIds);
|
||||
|
||||
}
|
||||
|
||||
@@ -52,7 +52,8 @@
|
||||
e.training_end_time as trainingEndTime,
|
||||
e.training_store_id as trainingStoreId,
|
||||
e.estimated_assessment_time as estimatedAssessmentTime,
|
||||
e.actual_assessment_time as actualAssessmentTime
|
||||
e.actual_assessment_time as actualAssessmentTime,
|
||||
e.assign_flag as assignFlag
|
||||
from xfsg_temp_user_detail u
|
||||
left join xfsg_employee_training e on e.xfsg_user_detail_id = u.id
|
||||
left join xfsg_shop_info s on s.id = u.shop_id
|
||||
@@ -81,9 +82,9 @@
|
||||
<if test="endTime != null and endTime != ''">
|
||||
and u.register_time <= #{endTime}
|
||||
</if>
|
||||
<if test="shopIdList != null and shopIdList.size() > 0">
|
||||
and u.shop_id in
|
||||
<foreach collection="shopIdList" item="item" index="index" open="(" separator="," close=")">
|
||||
<if test="storeNumList != null and storeNumList.size() > 0">
|
||||
and s.store_num in
|
||||
<foreach collection="storeNumList" item="item" index="index" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
@@ -99,6 +100,9 @@
|
||||
<if test="assessmentStatus != null and assessmentStatus == 1">
|
||||
and e.assessment_total_num = e.assessment_num
|
||||
</if>
|
||||
<if test="assignStoreFlag != null">
|
||||
and s.store_num not null
|
||||
</if>
|
||||
</select>
|
||||
<select id="trainingListByShopId" resultType="com.cool.store.vo.EmployeeTrainingVO">
|
||||
select
|
||||
|
||||
@@ -63,5 +63,15 @@
|
||||
and region_path like concat('%/', #{regionId}, '/%')
|
||||
</if>
|
||||
</select>
|
||||
<select id="getStoreNumByStoreIds" resultType="java.lang.String">
|
||||
select store_num
|
||||
from store_${enterpriseId}
|
||||
where is_delete = 'effective'
|
||||
<if test="storeIds != null">
|
||||
<foreach collection="storeIds" item="item" separator="," open="and store_id in (" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -23,6 +23,9 @@ public class EmployeeTrainingRequest extends PageBasicInfo {
|
||||
@ApiModelProperty("是否分配 0-待分配 1-已分配")
|
||||
private Boolean assignFlag;
|
||||
|
||||
@ApiModelProperty("是否分配门店 0-未分配 1-已分配")
|
||||
private Boolean assignStoreFlag;
|
||||
|
||||
@ApiModelProperty("开始时间")
|
||||
private Long beginTime;
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.cool.store.vo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@@ -123,4 +122,7 @@ public class EmployeeTrainingVO {
|
||||
|
||||
@ApiModelProperty("登记时间")
|
||||
private Date registerTime;
|
||||
|
||||
@ApiModelProperty("是否分配 0-待分配 1-已分配")
|
||||
private Boolean assignFlag;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,7 @@ import com.cool.store.dto.ehr.StaffBaseInfoDTO;
|
||||
import com.cool.store.request.TempUserDetailRequest;
|
||||
import com.cool.store.vo.TempUserDetailInfoVO;
|
||||
import com.cool.store.vo.TempUserDetailListVO;
|
||||
import com.cool.store.vo.TempUserDetailVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author byd
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.cool.store.service;
|
||||
|
||||
import com.cool.store.dto.yun.StudentResultDTO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author byd
|
||||
* @date 2024-04-29 9:55
|
||||
*/
|
||||
public interface YunXueTangApiService {
|
||||
|
||||
|
||||
String getAccessToken();
|
||||
|
||||
Map<String, StudentResultDTO> studentResultUserList(List<String> userIdList);
|
||||
}
|
||||
@@ -85,11 +85,18 @@ public class EmployeeTrainingServiceImpl implements EmployeeTrainingService {
|
||||
if (!sysRoleService.checkIsAdmin(userId)) {
|
||||
authRegionIdList = userAuthMappingService.getAuthRegionIdAndSubRegionIdByUserId(userId);
|
||||
}
|
||||
List<String> storeNumList = new ArrayList<>();
|
||||
if(CollectionUtils.isNotEmpty(request.getStoreIdList())){
|
||||
storeNumList = storeDAO.getStoreNumByStoreIds(request.getStoreIdList());
|
||||
}
|
||||
if(CollectionUtils.isEmpty(storeNumList)){
|
||||
return new PageInfo<>();
|
||||
}
|
||||
PageHelper.startPage(request.getPageNum(), request.getPageSize());
|
||||
List<EmployeeTrainingVO> list = employeeTrainingDAO.employeeTrainingList(request.getKeyWord(), request.getRegionIdList(), authRegionIdList, request.getAssignFlag(),
|
||||
DateUtils.parseLongDateToStr(request.getBeginTime()),
|
||||
DateUtils.parseLongDateToStr(request.getEndTime()), null,
|
||||
request.getTheoreticalExamStatus(), request.getPracticalExamStatus(), request.getAssessmentStatus());
|
||||
DateUtils.parseLongDateToStr(request.getEndTime()), storeNumList,
|
||||
request.getTheoreticalExamStatus(), request.getPracticalExamStatus(), request.getAssessmentStatus(), request.getAssignStoreFlag());
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return new PageInfo<>(list);
|
||||
}
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
package com.cool.store.service.impl;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import com.cool.store.constants.RedisConstant;
|
||||
import com.cool.store.dto.yun.StudentResultDTO;
|
||||
import com.cool.store.mq.util.HttpRestTemplateService;
|
||||
import com.cool.store.service.YunXueTangApiService;
|
||||
import com.cool.store.utils.RedisUtilPool;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author byd
|
||||
* @date 2024-04-29 9:55
|
||||
*/
|
||||
@Service
|
||||
public class YunXueTangApiServiceImpl implements YunXueTangApiService {
|
||||
|
||||
private final static String REQUEST_URL = "https://openapi.yunxuetang.cn/";
|
||||
|
||||
private final static String APP_ID = "1782195114";
|
||||
|
||||
private final static String APP_SECRET = "W2Py1G4XYvBFGkXVgdbrZsm4C9zStM5QvBG8WS-0YYw4lPTcoKaFB9S6F5spshCJ";
|
||||
|
||||
private final static String ARRANGE_ID = "d011f26d-cd82-4a58-b705-529c63295198";
|
||||
|
||||
@Resource
|
||||
private RedisUtilPool redisUtilPool;
|
||||
|
||||
@Resource
|
||||
private HttpRestTemplateService httpRestTemplateService;
|
||||
|
||||
|
||||
@Override
|
||||
public String getAccessToken() {
|
||||
|
||||
//若果在缓存中存在,从缓存中去取
|
||||
String accessToken = redisUtilPool.getString(RedisConstant.YUN_XUE_TANG_ACCESS_TOKEN);
|
||||
if (StringUtils.isNotBlank(accessToken)) {
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
|
||||
// 请求接口地址
|
||||
String url = "token";
|
||||
// url拼接所需参数
|
||||
String pathUrl = REQUEST_URL + url + "?" + "appId=" + APP_ID + "&appSecret=" + APP_SECRET;
|
||||
// 以post方式调用第三方接口,获取响应结果
|
||||
String result = HttpUtil.post(pathUrl, body);
|
||||
|
||||
// 返回accessToken
|
||||
JSONObject jsonObject = JSONObject.parseObject(result, JSONObject.class);
|
||||
accessToken = jsonObject.getString("accessToken");
|
||||
if (StringUtils.isNotBlank(accessToken)) {
|
||||
Integer expiresIn = jsonObject.getInteger("expiresIn");
|
||||
redisUtilPool.setString(RedisConstant.YUN_XUE_TANG_ACCESS_TOKEN, accessToken, expiresIn - 5 * 60);
|
||||
}
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, StudentResultDTO> studentResultUserList(List<String> userIdList) {
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("arrangeId", ARRANGE_ID);
|
||||
body.put("thirdUserIds", userIdList);
|
||||
body.put("limit", userIdList.size());
|
||||
String pathUrl = "v1/rpt2open/public/ote/student/result/user/list";
|
||||
// 以post方式调用第三方接口,获取响应结果
|
||||
Map<String, String> headMap = new HashMap<>();
|
||||
headMap.put("Authorization", this.getAccessToken());
|
||||
String result = httpRestTemplateService.postForObject(REQUEST_URL + pathUrl, body, String.class, headMap);
|
||||
List<StudentResultDTO> resultDTOList = new ArrayList<>();
|
||||
// 返回accessToken
|
||||
JSONObject jsonObject = JSONObject.parseObject(result, JSONObject.class);
|
||||
String code = jsonObject.getString("code");
|
||||
if (CommonConstants.YUN_XUE_TANG_SUC_CODE.equals(code)) {
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
JSONArray jsonArray = jsonObject.getJSONArray("datas");
|
||||
if (CollectionUtils.isNotEmpty(jsonArray)) {
|
||||
jsonArray.forEach(item -> {
|
||||
JSONObject itemObj = (JSONObject) item;
|
||||
StudentResultDTO resultDTO = new StudentResultDTO();
|
||||
resultDTO.setUserId(itemObj.getString("thirdUserId"));
|
||||
resultDTO.setPassed(itemObj.getInteger("passed"));
|
||||
resultDTO.setNewScore(itemObj.getFloat("newScore"));
|
||||
resultDTO.setUserExamStatus(itemObj.getInteger("userExamStatus"));
|
||||
resultDTOList.add(resultDTO);
|
||||
});
|
||||
}
|
||||
}
|
||||
return resultDTOList.stream().collect(
|
||||
Collectors.toMap(StudentResultDTO::getUserId, Function.identity()));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user