2023年6月14日 添加统计

This commit is contained in:
bai 2023-06-14 08:40:52 +08:00
parent 3322f49a4d
commit 20cbcc4794
2 changed files with 190 additions and 2 deletions

View File

@ -318,8 +318,17 @@ public class KcEvaluation implements Serializable {
/**教工号*/
@TableField(exist = false)
private java.lang.String jgh;
/**状态*/
/**状态*/
@TableField(exist = false)
private java.lang.String zt;
@TableField(exist = false)
private java.lang.String zt;
private String dwmc;
@TableField(exist = false)
private String xqxn;
}

View File

@ -0,0 +1,179 @@
package org.jeecg.modules.kc.statistics;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.beust.jcommander.internal.Sets;
import com.google.common.collect.Maps;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.kc.grab.imports.entity.Xxhbuser;
import org.jeecg.modules.kc.grab.imports.service.IXxhbuserService;
import org.jeecg.modules.kc.kcXqxnHistory.entity.KcXqxnHistory;
import org.jeecg.modules.kc.kcXqxnHistory.service.IKcXqxnHistoryService;
import org.jeecg.modules.kc.qa.entity.KcEvaluation;
import org.jeecg.modules.kc.qa.service.IKcEvaluationService;
import org.jeecg.modules.kc.tksf.kctksfrzb.entity.KcTksfrzb;
import org.jeecg.modules.kc.tksf.kctksfrzb.service.IKcTksfrzbService;
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 javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @Description: 调查问卷-答案表
* @Author: jeecg-boot
* @Date: 2023-04-09
* @Version: V1.0
*/
@Api(tags="调查问卷-答案表")
@RestController
@RequestMapping("/statistics")
@Slf4j
public class TingKeStatisticsController{
@Autowired
private IKcEvaluationService kcEvaluationService;
@Autowired
private IXxhbuserService xxhbuserService;
@Autowired
private IKcTksfrzbService kcTksfrzbService;
@Autowired
private IKcXqxnHistoryService kcXqxnHistoryService;
@ApiOperation(value="调查问卷-答案表-分页列表查询", notes="调查问卷-答案表-分页列表查询")
@GetMapping(value = "/getEvaluationList")
public Result<IPage<KcEvaluation>> list(KcEvaluation evaluation,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<KcEvaluation> queryWrapper = QueryGenerator.initQueryWrapper(evaluation, req.getParameterMap());
queryWrapper.isNotNull("upuserid");
queryWrapper.isNotNull("minkcid");
Page<KcEvaluation> page = new Page<KcEvaluation>(pageNo, pageSize);
IPage<KcEvaluation> pageList = kcEvaluationService.page(page, queryWrapper);
//---------------------补数据1------------------------------------------
Map<Integer,String> sourceDictMap = Maps.newHashMap();
//0门户添加1老系统2政务大厅3后台导入
sourceDictMap.put(0,"门户添加");
sourceDictMap.put(1,"老系统");
sourceDictMap.put(2,"政务大厅");
sourceDictMap.put(3,"后台导入");
//---------------------补数据1------------------------------------------
Set<String> tjSet = Sets.newHashSet();
pageList.getRecords().forEach(x -> {
//补充信息
x.setSourceName(sourceDictMap.get(x.getSource()));//数据来源
Integer ixuserId = x.getUpuserid();
String xuserId = String.valueOf(ixuserId);
tjSet.add(xuserId);
});
//---------------------补数据2------------------------------------------
//查询所在单位
QueryWrapper<Xxhbuser> szdwQw = new QueryWrapper<>();
szdwQw.in("gh",tjSet);
List<Xxhbuser> szdwList = xxhbuserService.list(szdwQw);
Map<String, Xxhbuser> szdwMap = Maps.newHashMap();
szdwList.forEach(x -> {
szdwMap.put(x.getGh(),x);
});
// QueryWrapper<KcXqxnHistory> kcXqxnHistoryQueryWrapper = new QueryWrapper<KcXqxnHistory>();
List<KcXqxnHistory> kcXqxnHistoryList = kcXqxnHistoryService.list();
//查询听课身份
QueryWrapper<KcTksfrzb> tksfQw = new QueryWrapper<>();
tksfQw.in("gh",tjSet);
List<KcTksfrzb> tksfList = kcTksfrzbService.list(tksfQw);
Map<String, KcTksfrzb> tksfMap = Maps.newHashMap();
tksfList.forEach(x -> {
if(tksfMap.containsKey(x.getGh())){
//存在了拼接职务名称取最大的听课要求
KcTksfrzb currentData = tksfMap.get(x.getGh());
String currentZwmc = currentData.getZwmc();
String currentTkyq = currentData.getTkyq();
if(StringUtils.isNotBlank(currentTkyq)){
int tkyq = Integer.parseInt(currentTkyq);
int xtkyq = Integer.parseInt(x.getTkyq());
x.setZwmc(currentZwmc + "" + x.getZwmc());
if(tkyq > xtkyq){
x.setTkyq(String.valueOf(tkyq));
}else{
x.setTkyq(String.valueOf(xtkyq));
}
}
tksfMap.put(x.getGh(),x);
}else {
tksfMap.put(x.getGh(),x);
}
});
//---------------------补数据2------------------------------------------
pageList.getRecords().forEach(x -> {
Integer ixuserId = x.getUpuserid();
String xuserId = String.valueOf(ixuserId);
if(szdwMap.containsKey(xuserId)){
Xxhbuser currentData = szdwMap.get(xuserId);
x.setDwmc(currentData.getDwmc());
}
if(tksfMap.containsKey(xuserId)){
KcTksfrzb currentData = tksfMap.get(xuserId);
//tj.setJsxm(currentData.getXm());
x.setTksf(currentData.getZwmc());
//tj.setYskcs(currentData.getTkyq());
}
Date upDate = x.getUpDate();
kcXqxnHistoryList.forEach(hx -> {
Date startTime = hx.getStartTime();
Date endTime = hx.getEndTime();
long betweenStartDay = DateUtil.between(startTime, upDate, DateUnit.DAY,false);
long betweenEndDay = DateUtil.between(endTime, upDate, DateUnit.DAY,false);
if(betweenStartDay >=0 && betweenEndDay <=0) {
System.out.println("在范围内");
x.setXqxn(hx.getTitle());
}
} );
});
return Result.OK(pageList);
}
public static void main(String[] args) {
Date upDate = DateUtil.parseDateTime("2023-03-13 00:00:00");
Date startTime = DateUtil.parseDateTime("2023-05-01 00:00:00");
Date endTime = DateUtil.parseDateTime("2023-07-01 00:00:00");
long betweenStartDay = DateUtil.between(startTime, upDate, DateUnit.DAY,false);
long betweenEndDay = DateUtil.between(endTime, upDate, DateUnit.DAY,false);
if(betweenStartDay >=0 && betweenEndDay <=0) {
System.out.println("在范围内");
}
System.out.println(betweenStartDay);
System.out.println(betweenEndDay);
}
}