全所统计

This commit is contained in:
zhangqinlin
2021-09-18 10:45:11 +08:00
parent 2e9a63f4da
commit b4fba29e03
34 changed files with 818 additions and 152 deletions
@@ -3,20 +3,33 @@ package com.jero.statistics.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jero.common.api.vo.Result;
import com.jero.common.system.api.ISysBaseAPI;
import com.jero.meeting.service.IPayMeetingSituationService;
import com.jero.member.service.IPayMemberProjectService;
import com.jero.member.service.IPayMemberProjectSubitemService;
import com.jero.member.service.ITbMemberProjectService;
import com.jero.member.service.ITbMemberProjectSubitemService;
import com.jero.project.entity.PayWorkGroupSubletStatistics;
import com.jero.project.entity.PayWorkingGroupSubletSearch;
import com.jero.project.service.IPayCommonProjectService;
import com.jero.project.service.IPayWorkingGroupService;
import com.jero.project.service.IPayWorkingGroupSubItemService;
import com.jero.statistics.entity.AllProjectStatistics;
import com.jero.statistics.entity.AllProjectStatisticsSearch;
import com.jero.util.AmountUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
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 org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
/**
* @author zql
@@ -28,44 +41,111 @@ import java.util.HashMap;
@Slf4j
public class AllProjectStatisticsController {
// /**
// * 分页列表查询
// *
// * @param payWorkingGroupSubletSearch 全统计搜索
// * @param pageNo 页数
// * @param pageSize 条数
// *
// */
// @ApiOperation(value = "全统计搜索-分页列表查询", notes = "全统计搜索-详情分页列表查询")
// @GetMapping(value = "/list")
// public Result<?> list(AllProjectStatisticsSearch allProjectStatisticsSearch,
// @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
// @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
// Page<PayWorkGroupSubletStatistics> page = new Page<>(pageNo, pageSize);
// if(allProjectStatisticsSearch.getYear()==null|| allProjectStatisticsSearch.getYear().equals("")){
// Calendar calendar= Calendar.getInstance();
// String year = String.valueOf(calendar.get(Calendar.YEAR));
// allProjectStatisticsSearch.setYear(year);
// }
//
//
//
// IPage<PayWorkGroupSubletStatistics> pageList = payWorkingGroupSubItemService.queryPageList2(page, payWorkingGroupSubletSearch);
// double sum = pageList.getRecords().stream().mapToDouble(t -> Double.parseDouble(t.getAllMoney() == null ? "0" : t.getAllMoney())).sum();
// double sum2 = pageList.getRecords().stream().mapToDouble(t -> Double.parseDouble(t.getComeAllMoney() == null ? "0" : t.getComeAllMoney())).sum();
// HashMap<String, Object> hashMap = new HashMap<>();
// DecimalFormat df = new DecimalFormat("#.00");
// for(PayWorkGroupSubletStatistics s: pageList.getRecords()){
// String key = String.valueOf(s.getChargeUse());
// String payment_charge_use = sysBaseAPI.translateDict("payment_charge_use", key);
// s.setChargeUse_text(payment_charge_use);
// }
// hashMap.put("pageList",pageList);
// hashMap.put("sumOfMoney", sum==0.0?sum:df.format(sum));
// hashMap.put("sumOfReallyMoney", sum2==0.0?sum2:df.format(sum2));
// return Result.OK(hashMap);
// }
@Autowired
private ISysBaseAPI sysBaseAPI;
@Autowired
private IPayWorkingGroupSubItemService payWorkingGroupSubItemService;
@Autowired
private IPayWorkingGroupService payWorkingGroupService;
@Autowired
private IPayCommonProjectService payCommonProjectService;
@Autowired
private IPayMemberProjectService payMemberProjectService;
@Autowired
private IPayMeetingSituationService payMeetingSituationService;
@Autowired
private ITbMemberProjectService tbMemberProjectService;
/**
* 分页列表查询
*
* @param allProjectStatisticsSearch 全统计搜索
* @param pageNo 页数
* @param pageSize 条数
*/
@ApiOperation(value = "全统计搜索-分页列表查询", notes = "全统计搜索-详情分页列表查询")
@PostMapping(value = "/list")
public Result<?> list(AllProjectStatisticsSearch allProjectStatisticsSearch,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
}
if (allProjectStatisticsSearch.getYear() == null || allProjectStatisticsSearch.getYear().equals("")) {
Calendar calendar = Calendar.getInstance();
String year = String.valueOf(calendar.get(Calendar.YEAR));
allProjectStatisticsSearch.setYear(year);
}
List<AllProjectStatistics> pageList = payWorkingGroupService.queryPageList3(allProjectStatisticsSearch);
List<AllProjectStatistics> pageList2 = payCommonProjectService.queryPageList3(allProjectStatisticsSearch);
List<AllProjectStatistics> pageList3 = payMemberProjectService.queryPageList3(allProjectStatisticsSearch);
List<AllProjectStatistics> pageList4 = payMeetingSituationService.queryPageList3(allProjectStatisticsSearch);
List<AllProjectStatistics> pageList5 = tbMemberProjectService.queryPageList3(allProjectStatisticsSearch);
pageList4.addAll(pageList5);
pageList3.addAll(pageList4);
pageList2.addAll(pageList3);
pageList.addAll(pageList2);
int total = pageList.size();
int pageTotal =total/pageSize+1;
List<AllProjectStatistics> allProjectStatistics=null;
if(total>=pageSize * pageNo){
allProjectStatistics = pageList.subList(pageSize * (pageNo - 1), pageSize * pageNo-1);
}else if((pageNo-1)*pageSize<total && total<pageSize * pageNo) {
allProjectStatistics = pageList.subList(pageSize * (pageNo - 1), total-1);
}
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("pageNo",pageNo);
hashMap.put("pageSize",pageSize);
hashMap.put("total",total);
hashMap.put("pageTotal",pageTotal);
hashMap.put("records",allProjectStatistics);
double sum = allProjectStatistics != null ? allProjectStatistics.stream().mapToDouble(t -> Double.parseDouble(t.getAllMoney() == null ? "0" : t.getAllMoney())).sum() : 0;
double sum2 = allProjectStatistics != null ? allProjectStatistics.stream().mapToDouble(t -> Double.parseDouble(t.getComeAllMoney() == null ? "0" : t.getComeAllMoney())).sum() : 0;
DecimalFormat df = new DecimalFormat("#.00");
if (allProjectStatistics != null) {
for(AllProjectStatistics s: allProjectStatistics){
String key = String.valueOf(s.getChargeUse());
String payment_charge_use = sysBaseAPI.translateDict("payment_charge_use", key);
s.setChargeUse_text(payment_charge_use);
}
}
hashMap.put("sumOfMoney", sum==0.0?sum:df.format(sum));
hashMap.put("sumOfReallyMoney", sum2==0.0?sum2:df.format(sum2));
return Result.OK(hashMap);
}
/**
*所领导统计
* @param
*
*/
@GetMapping(value = "/statistics/excel")
@ApiOperation(value = "所领导统计-导出统计", notes = "所领导统计-导出统计")
public ModelAndView excel() {
AllProjectStatisticsSearch allProjectStatisticsSearch=new AllProjectStatisticsSearch();
List<AllProjectStatistics> pageList = payWorkingGroupService.queryPageList3(allProjectStatisticsSearch);
List<AllProjectStatistics> pageList2 = payCommonProjectService.queryPageList3(allProjectStatisticsSearch);
List<AllProjectStatistics> pageList3 = payMemberProjectService.queryPageList3(allProjectStatisticsSearch);
List<AllProjectStatistics> pageList4 = payMeetingSituationService.queryPageList3(allProjectStatisticsSearch);
List<AllProjectStatistics> pageList5 = tbMemberProjectService.queryPageList3(allProjectStatisticsSearch);
pageList4.addAll(pageList5);
pageList3.addAll(pageList4);
pageList2.addAll(pageList3);
pageList.addAll(pageList2);
return AmountUtil.exportListXls(pageList, AllProjectStatistics.class, "所领导统计");
}
}
@@ -1,183 +0,0 @@
package com.jero.statistics.controller;
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.jero.common.api.vo.Result;
import com.jero.common.system.api.ISysBaseAPI;
import com.jero.common.system.vo.ComboModel;
import com.jero.common.system.vo.DictModel;
import com.jero.common.system.vo.LoginUser;
import com.jero.mail.commont.constant;
import com.jero.modules.system.entity.SysUser;
import com.jero.modules.system.mapper.SysUserMapper;
import com.jero.project.entity.PayWorkGroupSubletStatistics;
import com.jero.project.entity.PayWorkingGroupSearch;
import com.jero.project.entity.PayWorkingGroupStatistics;
import com.jero.project.entity.PayWorkingGroupSubletSearch;
import com.jero.project.service.IPayWorkingGroupService;
import com.jero.project.service.IPayWorkingGroupSubItemService;
import com.jero.util.AmountUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.ObjectUtils;
import org.apache.poi.hssf.record.DVALRecord;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.BeanUtils;
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 org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import java.text.DecimalFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author zql
* @date 2021/9/15 8:54
*/
@Api(tags="工作组统计")
@RestController
@RequestMapping("/project/payWorkingGroupStatistics")
@Slf4j
public class PayWorkingGroupStatisticsController {
@Resource
private SysUserMapper userMapper;
@Autowired
private ISysBaseAPI sysBaseAPI;
@Autowired
private IPayWorkingGroupSubItemService payWorkingGroupSubItemService;
@Autowired
private IPayWorkingGroupService payWorkingGroupService;
/**
* 分页列表查询
*
* @param payWorkingGroupSearch 工作组项目
* @param pageNo 页数
* @param pageSize 条数
*
*/
@ApiOperation(value="工作组项目统计-统计分页列表查询", notes="工作组项目统计-统计分页列表查询")
@GetMapping(value = "/list")
public Result<?> list(PayWorkingGroupSearch payWorkingGroupSearch,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
Page<PayWorkingGroupStatistics> page = new Page<>(pageNo, pageSize);
if(payWorkingGroupSearch.getYear()==null|| payWorkingGroupSearch.getYear().equals("")){
Calendar calendar= Calendar.getInstance();
String year = String.valueOf(calendar.get(Calendar.YEAR));
payWorkingGroupSearch.setYear(year);
}
String jointo=null;
//判断登录角色,显示特定工作组内容
LoginUser sysUser =(LoginUser) SecurityUtils.getSubject().getPrincipal();
String roleCode = sysUser.getRoleCode();
if(constant.KZ.equals(roleCode)) {
String orgCode = sysUser.getOrgCode();
List<SysUser> userList = userMapper.selectList(new QueryWrapper<SysUser>().eq("status", 1).eq("del_flag", 0).eq("org_code", orgCode));
List<String> list = userList.stream().map(SysUser::getId).collect(Collectors.toList());
jointo = String.join(",", list);
} else if (constant.SLD.equals(roleCode)) {
jointo = null;
}else if( constant.ZY.equals(roleCode)){
jointo= sysUser.getId();
}
IPage<PayWorkingGroupStatistics> pageList = payWorkingGroupService.queryPageListForStatistics(page, payWorkingGroupSearch,jointo);
List<PayWorkingGroupStatistics> records = pageList.getRecords();
//去除项目下来款金额为零的工作组
ArrayList<PayWorkingGroupStatistics> list = new ArrayList<>();
for(PayWorkingGroupStatistics payWorkingGroupStatistics:records){
if (!(payWorkingGroupStatistics.getComeAllMoney().equals("0") || payWorkingGroupStatistics.getComeAllMoney() == null)) {
list.add(payWorkingGroupStatistics);
}
}
//计算应收和实收总金额
double sum = list.stream().mapToDouble(t -> Double.parseDouble(t.getAllMoney()==null ? "0.00" : t.getAllMoney())).sum();
double sum2 = list.stream().mapToDouble(t -> Double.parseDouble(t.getComeAllMoney()==null ? "0.00" : t.getComeAllMoney())).sum();
HashMap<String, Object> objectObjectHashMap = new HashMap<>();
DecimalFormat df = new DecimalFormat("#.00");
objectObjectHashMap.put("pageList",pageList.setRecords(list));
objectObjectHashMap.put("sumOfMoney", sum==0.0?sum:df.format(sum));
objectObjectHashMap.put("sumOfReallyMoney", sum2==0.0?sum2:df.format(sum2));
return Result.OK(objectObjectHashMap);
}
/**
* 导出excel
*
*/
@GetMapping(value = "/exportXls2")
@ApiOperation(value="工作组项目统计-统计导出excel", notes="工作组项目统计-统计导出excel")
public ModelAndView exportXls2() {
List<PayWorkingGroupStatistics> pageList = payWorkingGroupService.queryPageListForStatisticsExcel();
return AmountUtil.exportListXls(pageList, PayWorkingGroupStatistics.class,"工作组项目统计");
}
/**
* 获取工作组列表
*
*/
@GetMapping(value = "/getGroupList")
@ApiOperation(value="工作组获取工作组列表下拉框", notes="工作组获取工作组列表下拉框")
public List<String> getGroupList() {
return payWorkingGroupService.getGroupList();
}
/**
* 分页列表查询
*
* @param payWorkingGroupSubletSearch 工作组成员统计搜索
* @param pageNo 页数
* @param pageSize 条数
*
*/
@ApiOperation(value = "工作组成员统计-详情分页列表查询(传工作组id)", notes = "工作组成员统计-详情分页列表查询(传工作组id)")
@GetMapping(value = "/listSub")
public Result<?> list2(PayWorkingGroupSubletSearch payWorkingGroupSubletSearch,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
Page<PayWorkGroupSubletStatistics> page = new Page<>(pageNo, pageSize);
if(payWorkingGroupSubletSearch.getYear()==null|| payWorkingGroupSubletSearch.getYear().equals("")){
Calendar calendar= Calendar.getInstance();
String year = String.valueOf(calendar.get(Calendar.YEAR));
payWorkingGroupSubletSearch.setYear(year);
}
IPage<PayWorkGroupSubletStatistics> pageList = payWorkingGroupSubItemService.queryPageList2(page, payWorkingGroupSubletSearch);
double sum = pageList.getRecords().stream().mapToDouble(t -> Double.parseDouble(t.getAllMoney() == null ? "0" : t.getAllMoney())).sum();
double sum2 = pageList.getRecords().stream().mapToDouble(t -> Double.parseDouble(t.getComeAllMoney() == null ? "0" : t.getComeAllMoney())).sum();
HashMap<String, Object> hashMap = new HashMap<>();
DecimalFormat df = new DecimalFormat("#.00");
for(PayWorkGroupSubletStatistics s: pageList.getRecords()){
String key = String.valueOf(s.getChargeUse());
String payment_charge_use = sysBaseAPI.translateDict("payment_charge_use", key);
s.setChargeUse_text(payment_charge_use);
}
hashMap.put("pageList",pageList);
hashMap.put("sumOfMoney", sum==0.0?sum:df.format(sum));
hashMap.put("sumOfReallyMoney", sum2==0.0?sum2:df.format(sum2));
return Result.OK(hashMap);
}
/**
*导出
* @param id
*
*/
@GetMapping(value = "/excelSub")
@ApiOperation(value = "工作组成员统计-导出统计(传工作组id)", notes = "工作组成员统计-导出统计(传工作组id)")
public ModelAndView excelSub(@RequestParam(name = "id", required = true) String id) {
List<PayWorkGroupSubletStatistics> list = payWorkingGroupSubItemService.importExcelStatistics(id);
return AmountUtil.exportListXls(list, PayWorkGroupSubletStatistics.class, "工作组成员统计");
}
}
@@ -0,0 +1,44 @@
package com.jero.statistics.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
/**
* @author zql
* @date 2021/9/17 18:04
*/
@Data
public class AllProjectStatistics {
@Excel(name = "项目负责人", width = 15)
@ApiModelProperty(value = "项目负责人")
private String principalName;
@Excel(name = "科室", width = 15)
@ApiModelProperty(value = "科室")
private String depart;
@Excel(name = "来款项目", width = 15)
@ApiModelProperty(value = "来款单位")
private String chargeCompanyTemporaryName;
@Excel(name = "来款项目", width = 15)
@ApiModelProperty(value = "来款项目")
private String projectName;
@Excel(name = "应收总金额", width = 15)
@ApiModelProperty(value = "应收总金额")
private String allMoney;
@Excel(name = "实收总金额", width = 15)
@ApiModelProperty(value = "实收总金额")
private String comeAllMoney;
@Excel(name = "来款用途", width = 15,dicCode = "charge_use")
@ApiModelProperty(value = "来款用途编码")
private String chargeUse;
@ApiModelProperty(value = "来款用途")
private String ChargeUse_text;
}
@@ -14,9 +14,6 @@ import java.math.BigDecimal;
@Data
public class AllProjectStatisticsSearch {
@ApiModelProperty(value = "工作组id")
private String id;
@ApiModelProperty(value = "来款项目")
private String projectName;
@@ -40,13 +37,13 @@ public class AllProjectStatisticsSearch {
private String payStatue;
@ApiModelProperty(value = "来款用途")
private int chargeUse;
private String chargeUse;
@ApiModelProperty(value = "打包")
private int pack;
private String pack;
@ApiModelProperty(value = "付款状态")
private int inAccountStatue;
private String inAccountStatue;
@ApiModelProperty(value = "项目负责人id")
private String principalNameId;