|
|
@@ -0,0 +1,117 @@
|
|
|
+package com.lc.ibps.business.service.impl;
|
|
|
+
|
|
|
+import com.lc.ibps.base.core.constants.StringPool;
|
|
|
+import com.lc.ibps.base.core.util.BeanUtils;
|
|
|
+import com.lc.ibps.base.framework.table.ICommonDao;
|
|
|
+import com.lc.ibps.business.service.TrainingStatisticsService;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author Administrator
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class TrainingStatisticsServiceImpl implements TrainingStatisticsService {
|
|
|
+
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ICommonDao<?> commonDao;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取当前地点下所有用户的培训统计
|
|
|
+ * @param diDian
|
|
|
+ * @param userId
|
|
|
+ * @param deptId
|
|
|
+ * @param startTime
|
|
|
+ * @param endTime
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<Map<String, Object>> getUserTrainCount(String diDian,String userId,String deptId,String startTime,String endTime) throws Exception {
|
|
|
+ if (BeanUtils.isEmpty(diDian)){
|
|
|
+ throw new Exception("参数diDian(地点)不能为空!");
|
|
|
+ }
|
|
|
+ StringBuilder sql = new StringBuilder(" select id_,name_,positions_,jian_ding_zi_ge_z from ibps_party_employee c where id_ != '-1' " +
|
|
|
+ " and status_ !='deleted' and exists (select 1 from ibps_party_entity d where find_in_set(d.id_,c.positions_) and (d.path_ like '%"+diDian+"%')) ");
|
|
|
+ if (BeanUtils.isNotEmpty(userId)){
|
|
|
+ String[] user = userId.split(StringPool.COMMA);
|
|
|
+ if (user.length>1){
|
|
|
+ sql.append("and id_ in(");
|
|
|
+ for (String id : user){
|
|
|
+ sql.append("'").append(id).append("',");
|
|
|
+ }
|
|
|
+ sql.deleteCharAt(sql.length() - 1);
|
|
|
+ sql.append(")");
|
|
|
+ }else {
|
|
|
+ sql.append("and id_='").append(userId).append("'");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (BeanUtils.isNotEmpty(deptId)){
|
|
|
+ sql.append("and positions_ like '%").append(deptId).append("%'");
|
|
|
+ }
|
|
|
+ sql.append(" order by create_time_ desc");
|
|
|
+
|
|
|
+ List<Map<String,Object>> userList = (List<Map<String, Object>>) commonDao.query(sql.toString());
|
|
|
+ for (Map<String,Object> map : userList){
|
|
|
+
|
|
|
+ String employee = map.get("id_").toString();
|
|
|
+ String sumSql = "select count(*)as planedjoin from t_rypxcjb where shi_fou_guo_shen_='已结束' and pei_xun_ren_yuan_ like '%"+employee+"%'";
|
|
|
+ if (BeanUtils.isNotEmpty(startTime)){
|
|
|
+ sumSql = sumSql + " and date_format(pei_xun_shi_jian_,'%Y-%m-%d')>='"+startTime+"' ";
|
|
|
+ }
|
|
|
+ if (BeanUtils.isNotEmpty(endTime)){
|
|
|
+ sumSql = sumSql + " and date_format(pei_xun_shi_jian_,'%Y-%m-%d')<='"+endTime+"' ";
|
|
|
+ }
|
|
|
+ Map<String,Object> total = commonDao.queryOne(sumSql);
|
|
|
+ map.put("planedjoin",total.get("planedjoin"));
|
|
|
+
|
|
|
+ String signSql = "select count(distinct guan_lian_id_) as truejoin from t_qdxxb where ren_yuan_id_ ='"+employee+"' and guan_lian_id_ " +
|
|
|
+ " in(select id_ from t_rypxcjb where shi_fou_guo_shen_='已结束' and pei_xun_ren_yuan_ like '%"+employee+"%'";
|
|
|
+ if (BeanUtils.isNotEmpty(startTime)){
|
|
|
+ signSql = signSql + " and date_format(pei_xun_shi_jian_,'%Y-%m-%d')>='"+startTime+"' ";
|
|
|
+ }
|
|
|
+ if (BeanUtils.isNotEmpty(endTime)){
|
|
|
+ signSql = signSql + " and date_format(pei_xun_shi_jian_,'%Y-%m-%d')<='"+endTime+"' ";
|
|
|
+ }
|
|
|
+ Map<String,Object> already = commonDao.queryOne(signSql+" ) ");
|
|
|
+ map.put("truejoin",already.get("truejoin"));
|
|
|
+
|
|
|
+ BigDecimal sum = new BigDecimal(total.get("planedjoin").toString());
|
|
|
+ BigDecimal sign = new BigDecimal(already.get("truejoin").toString());
|
|
|
+ if (sum.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ map.put("participationRate","0.00%");
|
|
|
+ }else {
|
|
|
+ BigDecimal percentage = sign.divide(sum, 10, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
|
|
|
+ percentage = percentage.setScale(2, RoundingMode.HALF_UP);
|
|
|
+ map.put("participationRate",percentage+"%");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (BeanUtils.isNotEmpty(map.get("positions_"))){
|
|
|
+ String positionId = map.get("positions_").toString();
|
|
|
+ String[] posi = positionId.split(StringPool.COMMA);
|
|
|
+ StringBuffer deptName = new StringBuffer();
|
|
|
+ if (posi.length>1){
|
|
|
+ for (String str : posi){
|
|
|
+ Map<String,Object> name = commonDao.queryOne("select name_ from ibps_party_entity where id_ ='"+str+"'");
|
|
|
+ deptName.append(name.get("name_")).append(",");
|
|
|
+ }
|
|
|
+ deptName.deleteCharAt(deptName.length() - 1);
|
|
|
+ map.put("deptName",deptName);
|
|
|
+ }else {
|
|
|
+ Map<String,Object> name = commonDao.queryOne("select name_ from ibps_party_entity where id_ ='"+positionId+"'");
|
|
|
+ map.put("deptName",name.get("name_"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return userList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|