Commit f035af54 by Water Wang

add activity query interface

parent c7154301
...@@ -264,4 +264,18 @@ public class PractitionerController { ...@@ -264,4 +264,18 @@ public class PractitionerController {
return result; return result;
} }
/**
* 团队长--查看目前活动量
* @param requestVO 请求数据
* @return 响应数据
*/
@RequestMapping("/potentialActivityQuery")
public Object potentialActivityQuery(@RequestBody PotentialActivityQueryRequestVO requestVO){
JsonResult result = new JsonResult();
PotentialActivityQueryResponseVO responseVO = practitionerService.potentialActivityQuery(requestVO);
result.addResult(responseVO);
result.setData(responseVO);
return result;
}
} }
...@@ -138,4 +138,11 @@ public interface PractitionerService { ...@@ -138,4 +138,11 @@ public interface PractitionerService {
* @return 响应数据 * @return 响应数据
*/ */
PotentialGoalsActionsUpdateResponseVO potentialGoalsActionsUpdate(PotentialGoalsActionsUpdateRequestVO requestVO); PotentialGoalsActionsUpdateResponseVO potentialGoalsActionsUpdate(PotentialGoalsActionsUpdateRequestVO requestVO);
/**
* 团队长--查看目前自己的活动量
* @param requestVO 请求数据
* @return 响应数据
*/
PotentialActivityQueryResponseVO potentialActivityQuery(PotentialActivityQueryRequestVO requestVO);
} }
...@@ -1415,6 +1415,105 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -1415,6 +1415,105 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
return responseVO; return responseVO;
} }
@Override
public PotentialActivityQueryResponseVO potentialActivityQuery(PotentialActivityQueryRequestVO requestVO) {
PotentialActivityQueryResponseVO responseVO = new PotentialActivityQueryResponseVO();
Long practitionerId = requestVO.getPractitionerId();
if(practitionerId != null){
List<AclPractitionerPotentialAssignedTrack> assignedTrackList = aclPractitionerPotentialAssignedTrackDALService.findScoreByPractitionerIdAndDate(practitionerId,"month");
int activityForToday = 0,activityForWeek = 0,activityForMonth = 0,activityForQuarter = 0;
Set<Long> succeedRecruitSet = new HashSet<>();
if(assignedTrackList != null && !assignedTrackList.isEmpty()){
Integer trackScore;
Date trackTime;
Long trackStatusId;
Calendar calendar = Calendar.getInstance();
//获取增员成功id
List<MdDropOptions> optionsList = mdDropOptionsDALService.findByMasterCodeAndOptionsCode("team_building_track","7");
long trackSucceedId = (optionsList != null && !optionsList.isEmpty()) ? optionsList.get(0).getId() : 113L;
Date todayStartDate = getTimeStartDate(calendar,"today");//本天的开始时间
Date weekStartDate = getTimeStartDate(calendar,"week");//本周的开始时间
Date monthStartDate = getTimeStartDate(calendar,"month");//本月的开始时间
// Date quarterStartDate = getTimeStartDate(calendar,"quarter"); //本季的开始时间
for(AclPractitionerPotentialAssignedTrack item : assignedTrackList){
trackStatusId = item.getTrackStatusId();
trackScore = item.getTrackScore();
trackTime = item.getTrackTime();
if(trackStatusId != null && trackSucceedId == trackStatusId){
succeedRecruitSet.add(item.getId());
}
if(trackScore != null && trackScore != 0){
if(!trackTime.before(todayStartDate)){
activityForToday += trackScore;
activityForWeek += trackScore;
activityForMonth += trackScore;
activityForQuarter += trackScore;
}else if(!trackTime.before(weekStartDate)){
activityForWeek += trackScore;
activityForMonth += trackScore;
activityForQuarter += trackScore;
}else if(!trackTime.before(monthStartDate)){
activityForMonth += trackScore;
activityForQuarter += trackScore;
}else{
activityForQuarter += trackScore;
}
}
}
}
responseVO.setActivityForToday(activityForToday);
responseVO.setActivityForWeek(activityForWeek);
responseVO.setActivityForMonth(activityForMonth);
responseVO.setActivityForQuarter(activityForQuarter);
responseVO.setRecruitSucceed(succeedRecruitSet.size());
responseVO.setCommonResult(new CommonResult(true,ZHBErrorConfig.getErrorInfo("800000")));
}else{
String [] paras = {"practitionerId"};
responseVO.setCommonResult(new CommonResult(false,ZHBErrorConfig.getErrorInfo("610002",paras)));
}
return responseVO;
}
private Date getTimeStartDate(Calendar calendar, String time) {
if(calendar != null){
switch (time) {
case "today":
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
case "week":
calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
return calendar.getTime();
case "month":
calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
return calendar.getTime();
default:
int currentMonth = calendar.get(Calendar.MONTH) + 1;
SimpleDateFormat longSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat shortSdf = new SimpleDateFormat("yyyy-MM-dd");
try {
if (currentMonth <= 3)
calendar.set(Calendar.MONTH, 0);
else if (currentMonth <= 6)
calendar.set(Calendar.MONTH, 3);
else if (currentMonth <= 9)
calendar.set(Calendar.MONTH, 4);
else if (currentMonth <= 12)
calendar.set(Calendar.MONTH, 9);
calendar.set(Calendar.DATE, 1);
return longSdf.parse(shortSdf.format(calendar.getTime()) + " 00:00:00");
} catch (Exception e) {
e.printStackTrace();
}
}
}
return null;
}
private void savePotentialGoalsActions(List<AclPractitionerPotentialGoalsActions> potentialGoalsActionsList, Long practitionerId, Integer currentYear, Long potentialActionId, String potentialActionName, int result, Date version) { private void savePotentialGoalsActions(List<AclPractitionerPotentialGoalsActions> potentialGoalsActionsList, Long practitionerId, Integer currentYear, Long potentialActionId, String potentialActionName, int result, Date version) {
//月 //月
savePotentialGoalsActionsDetail(potentialGoalsActionsList,practitionerId,currentYear,3,potentialActionId,potentialActionName,result,version); savePotentialGoalsActionsDetail(potentialGoalsActionsList,practitionerId,currentYear,3,potentialActionId,potentialActionName,result,version);
......
package com.yd.api.practitioner.vo.recruit;
public class PotentialActivityQueryRequestVO {
private Long practitionerId;
public Long getPractitionerId() {
return practitionerId;
}
public void setPractitionerId(Long practitionerId) {
this.practitionerId = practitionerId;
}
}
package com.yd.api.practitioner.vo.recruit;
import com.yd.api.result.CommonResult;
public class PotentialActivityQueryResponseVO {
private Integer activityForToday;
private Integer activityForWeek;
private Integer activityForMonth;
private Integer activityForQuarter;
private Integer recruitSucceed;
private CommonResult commonResult;
public Integer getActivityForToday() {
return activityForToday;
}
public void setActivityForToday(Integer activityForToday) {
this.activityForToday = activityForToday;
}
public Integer getActivityForWeek() {
return activityForWeek;
}
public void setActivityForWeek(Integer activityForWeek) {
this.activityForWeek = activityForWeek;
}
public Integer getActivityForMonth() {
return activityForMonth;
}
public void setActivityForMonth(Integer activityForMonth) {
this.activityForMonth = activityForMonth;
}
public Integer getActivityForQuarter() {
return activityForQuarter;
}
public void setActivityForQuarter(Integer activityForQuarter) {
this.activityForQuarter = activityForQuarter;
}
public Integer getRecruitSucceed() {
return recruitSucceed;
}
public void setRecruitSucceed(Integer recruitSucceed) {
this.recruitSucceed = recruitSucceed;
}
public CommonResult getCommonResult() {
return commonResult;
}
public void setCommonResult(CommonResult commonResult) {
this.commonResult = commonResult;
}
}
...@@ -28,4 +28,6 @@ public interface AclPractitionerPotentialAssignedTrackMapper { ...@@ -28,4 +28,6 @@ public interface AclPractitionerPotentialAssignedTrackMapper {
void updateAll(@Param("assignedTrackUpdateList")List<AclPractitionerPotentialAssignedTrack> assignedTrackUpdateList); void updateAll(@Param("assignedTrackUpdateList")List<AclPractitionerPotentialAssignedTrack> assignedTrackUpdateList);
List<AclPractitionerPotentialAssignedTrack> findByPractitionerIdAndPotentialId(@Param("practitionerId")Long practitionerId, @Param("potentialId")Long potentialId); List<AclPractitionerPotentialAssignedTrack> findByPractitionerIdAndPotentialId(@Param("practitionerId")Long practitionerId, @Param("potentialId")Long potentialId);
List<AclPractitionerPotentialAssignedTrack> findScoreByPractitionerIdAndDate(@Param("practitionerId")Long practitionerId, @Param("time")String time);
} }
\ No newline at end of file
...@@ -24,4 +24,6 @@ public interface MdDropOptionsMapper { ...@@ -24,4 +24,6 @@ public interface MdDropOptionsMapper {
List<MdDropOptions> findByMasterCode(@Param("masterCode")String masterCode); List<MdDropOptions> findByMasterCode(@Param("masterCode")String masterCode);
List<MdDropOptions> findByMasterCodeAndOrderId(@Param("masterCode")String masterCode, @Param("orderId")int orderId); List<MdDropOptions> findByMasterCodeAndOrderId(@Param("masterCode")String masterCode, @Param("orderId")int orderId);
List<MdDropOptions> findByMasterCodeAndOptionsCode(@Param("masterCode")String masterCode, @Param("optionsCode")String optionsCode);
} }
\ No newline at end of file
...@@ -20,4 +20,6 @@ public interface AclPractitionerPotentialAssignedTrackDALService { ...@@ -20,4 +20,6 @@ public interface AclPractitionerPotentialAssignedTrackDALService {
void updateAll(List<AclPractitionerPotentialAssignedTrack> assignedTrackUpdateList); void updateAll(List<AclPractitionerPotentialAssignedTrack> assignedTrackUpdateList);
List<AclPractitionerPotentialAssignedTrack> findByPractitionerIdAndPotentialId(Long practitionerId, Long potentialId); List<AclPractitionerPotentialAssignedTrack> findByPractitionerIdAndPotentialId(Long practitionerId, Long potentialId);
List<AclPractitionerPotentialAssignedTrack> findScoreByPractitionerIdAndDate(Long practitionerId, String time);
} }
...@@ -45,4 +45,9 @@ public class AclPractitionerPotentialAssignedTrackDALServiceImpl implements AclP ...@@ -45,4 +45,9 @@ public class AclPractitionerPotentialAssignedTrackDALServiceImpl implements AclP
public List<AclPractitionerPotentialAssignedTrack> findByPractitionerIdAndPotentialId(Long practitionerId, Long potentialId) { public List<AclPractitionerPotentialAssignedTrack> findByPractitionerIdAndPotentialId(Long practitionerId, Long potentialId) {
return aclPractitionerPotentialAssignedTrackMapper.findByPractitionerIdAndPotentialId(practitionerId,potentialId); return aclPractitionerPotentialAssignedTrackMapper.findByPractitionerIdAndPotentialId(practitionerId,potentialId);
} }
@Override
public List<AclPractitionerPotentialAssignedTrack> findScoreByPractitionerIdAndDate(Long practitionerId, String time) {
return aclPractitionerPotentialAssignedTrackMapper.findScoreByPractitionerIdAndDate(practitionerId,time);
}
} }
...@@ -16,4 +16,6 @@ public interface MdDropOptionsDALService { ...@@ -16,4 +16,6 @@ public interface MdDropOptionsDALService {
List<MdDropOptions> findByMasterCode(String masterCode); List<MdDropOptions> findByMasterCode(String masterCode);
List<MdDropOptions> findByMasterCodeAndOrderId(String masterCode, int orderId); List<MdDropOptions> findByMasterCodeAndOrderId(String masterCode, int orderId);
List<MdDropOptions> findByMasterCodeAndOptionsCode(String team_building_track, String s);
} }
...@@ -43,4 +43,9 @@ public class MdDropOptionsDALServiceImpl implements MdDropOptionsDALService { ...@@ -43,4 +43,9 @@ public class MdDropOptionsDALServiceImpl implements MdDropOptionsDALService {
public List<MdDropOptions> findByMasterCodeAndOrderId(String masterCode, int orderId) { public List<MdDropOptions> findByMasterCodeAndOrderId(String masterCode, int orderId) {
return mdDropOptionsMapper.findByMasterCodeAndOrderId(masterCode,orderId); return mdDropOptionsMapper.findByMasterCodeAndOrderId(masterCode,orderId);
} }
@Override
public List<MdDropOptions> findByMasterCodeAndOptionsCode(String masterCode, String optionsCode) {
return mdDropOptionsMapper.findByMasterCodeAndOptionsCode(masterCode,optionsCode);
}
} }
...@@ -301,4 +301,28 @@ ...@@ -301,4 +301,28 @@
where id = #{item.id,jdbcType=BIGINT} where id = #{item.id,jdbcType=BIGINT}
</foreach> </foreach>
</update> </update>
<select id="findScoreByPractitionerIdAndDate" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from ag_acl_practitioner_potential_assigned_track
where practitioner_assigned_id = #{practitionerId,jdbcType=BIGINT} and track_score > 0
<choose>
<when test="time == 'today'">
and to_days(track_time) = to_days(now())
</when>
<when test="time == 'week'">
and yearweek(date_format(track_time,'%Y-%m-%d') = yearweek(NOW())
</when>
<when test="time == 'month'">
and date_format(track_time,'%Y%m') = date_format(curdate(),'%Y%m')
</when>
<when test="time == 'quarter'">
and QUARTER(track_time) = QUARTER(NOW()) AND year(track_time)=year(now())
</when>
<otherwise>
and YEAR(track_time) = YEAR(now())
</otherwise>
</choose>
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -218,4 +218,19 @@ ...@@ -218,4 +218,19 @@
from ag_md_drop_master m left join ag_md_drop_options o on m.id = o.drop_master_id and o.is_active = 1 and o.drop_option_order = #{orderId,jdbcType=INTEGER} from ag_md_drop_master m left join ag_md_drop_options o on m.id = o.drop_master_id and o.is_active = 1 and o.drop_option_order = #{orderId,jdbcType=INTEGER}
where m.scenario_code = #{masterCode,jdbcType=BIGINT} where m.scenario_code = #{masterCode,jdbcType=BIGINT}
</select> </select>
<select id="findByMasterCodeAndOptionsCode" resultType="com.yd.dal.entity.meta.MdDropOptions">
select
o.id id,
o.drop_master_id dropMasterId,
o.drop_option_name dropOptionName,
o.drop_option_code dropOptionCode,
o.drop_option_order dropOptionOrder,
o.drop_option_score dropOptionScore,
o.drop_option_remark dropOptionRemark,
o.is_active isActive,
o.created_at createdAt,
o.created_by createdBy
from ag_md_drop_master m left join ag_md_drop_options o on m.id = o.drop_master_id and o.is_active = 1 and o.drop_option_code = #{optionsCode,jdbcType=VARCHAR}
where m.scenario_code = #{masterCode,jdbcType=BIGINT}
</select>
</mapper> </mapper>
\ 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