diff --git a/attendance-performance-manager/src/main/java/com/mortals/xhx/module/staff/service/impl/StaffPerformSummaryServiceImpl.java b/attendance-performance-manager/src/main/java/com/mortals/xhx/module/staff/service/impl/StaffPerformSummaryServiceImpl.java index e97cfd7b2fe7dd447461ee354bc698cc881a76f4..af36d1528969e1e42c2f6ec22a3578afae8769ec 100644 --- a/attendance-performance-manager/src/main/java/com/mortals/xhx/module/staff/service/impl/StaffPerformSummaryServiceImpl.java +++ b/attendance-performance-manager/src/main/java/com/mortals/xhx/module/staff/service/impl/StaffPerformSummaryServiceImpl.java @@ -1,9 +1,12 @@ package com.mortals.xhx.module.staff.service.impl; +import com.alibaba.fastjson.JSONObject; import com.mortals.framework.exception.AppException; import com.mortals.framework.model.Context; import com.mortals.framework.model.PageInfo; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; +import com.mortals.xhx.base.system.param.service.ParamService; +import com.mortals.xhx.common.pdu.WeightPdu; import com.mortals.xhx.module.staff.dao.StaffPerformSummaryDao; import com.mortals.xhx.module.staff.model.StaffEntity; import com.mortals.xhx.module.staff.model.StaffPerformSummaryEntity; @@ -13,10 +16,14 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.ObjectUtils; +import java.math.BigDecimal; import java.util.Calendar; import java.util.List; +import static com.mortals.xhx.common.key.ParamKey.SYS_PARAM_WEIGHT; + /** * StaffPerformSummaryService * 鍛樺伐缁╂晥缁熻 service瀹炵幇 @@ -30,6 +37,8 @@ public class StaffPerformSummaryServiceImpl extends AbstractCRUDServiceImpl<Staf @Autowired private StaffService staffService; + @Autowired + private ParamService paramService; @Override protected StaffPerformSummaryEntity findBefore(StaffPerformSummaryEntity params, PageInfo pageInfo, Context context) throws AppException { @@ -48,13 +57,44 @@ public class StaffPerformSummaryServiceImpl extends AbstractCRUDServiceImpl<Staf @Override protected void findAfter(StaffPerformSummaryEntity params, PageInfo pageInfo, Context context, List<StaffPerformSummaryEntity> list) throws AppException { if(CollectionUtils.isNotEmpty(list)){ + String value = paramService.getValueByKey(SYS_PARAM_WEIGHT); + WeightPdu weightPdu; + if (ObjectUtils.isEmpty(value)){ + weightPdu = new WeightPdu(); + }else { + weightPdu = JSONObject.parseObject(value,WeightPdu.class); + } for(StaffPerformSummaryEntity item:list) { StaffEntity staffEntity = staffService.get(item.getStaffId()); if(staffEntity!=null){ item.setWorkNum(staffEntity.getWorkNum()); item.setPhoneNumber(staffEntity.getPhoneNumber()); } + computeSummary(item,weightPdu); } } } + + private void computeSummary(StaffPerformSummaryEntity staffPerformSummaryEntity, WeightPdu weightPdu){ + BigDecimal total = new BigDecimal(100); + BigDecimal reviewScore = total.add(staffPerformSummaryEntity.getReviewScore()); //璇勪环 + reviewScore = reviewScore.multiply(weightPdu.reviewWeight()); + staffPerformSummaryEntity.setReviewScore(reviewScore.setScale(2,BigDecimal.ROUND_DOWN)); + BigDecimal attendScore = total.add(staffPerformSummaryEntity.getAttendScore()); //鑰冨嫟 + attendScore = attendScore.multiply(weightPdu.attendWeight()); + staffPerformSummaryEntity.setAttendScore(attendScore.setScale(2,BigDecimal.ROUND_DOWN)); + BigDecimal otherScore = staffPerformSummaryEntity.getOtherScore(); //鑷瘎涓嶇敤鍔�100 + if(otherScore.compareTo(BigDecimal.ZERO)==0){ + otherScore = new BigDecimal(100); + } + otherScore = otherScore.multiply(weightPdu.selfWeight()); + staffPerformSummaryEntity.setOtherScore(otherScore.setScale(2,BigDecimal.ROUND_DOWN)); + BigDecimal goworkScore = total.add(staffPerformSummaryEntity.getGoworkScore()); //鍔炰欢 + goworkScore = goworkScore.multiply(weightPdu.goworkWeight()); + staffPerformSummaryEntity.setGoworkScore(goworkScore.setScale(2,BigDecimal.ROUND_DOWN)); + BigDecimal effectScore = total.add(staffPerformSummaryEntity.getEffectScore()); //鏁堣兘 + effectScore = effectScore.multiply(weightPdu.effectWeight()); + staffPerformSummaryEntity.setEffectScore(effectScore.setScale(2,BigDecimal.ROUND_DOWN)); + + } }