This commit is contained in:
zhangqinlin
2021-09-17 16:50:55 +08:00
parent 6aade37dcd
commit e3c794d173
14 changed files with 322 additions and 118 deletions
@@ -0,0 +1,71 @@
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.project.entity.PayWorkGroupSubletStatistics;
import com.jero.project.entity.PayWorkingGroupSubletSearch;
import com.jero.statistics.entity.AllProjectStatisticsSearch;
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 java.text.DecimalFormat;
import java.util.Calendar;
import java.util.HashMap;
/**
* @author zql
* @date 2021/9/17 16:29
*/
@Api(tags="全所统计")
@RestController
@RequestMapping("/statistics/allProjectStatistics")
@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);
// }
}
@@ -0,0 +1,183 @@
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,55 @@
package com.jero.statistics.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.DecimalMax;
import java.math.BigDecimal;
/**
* @author zql
* @date 2021/9/17 16:37
*/
@Data
public class AllProjectStatisticsSearch {
@ApiModelProperty(value = "工作组id")
private String id;
@ApiModelProperty(value = "来款项目")
private String projectName;
@ApiModelProperty(value = "来款单位")
private String chargeCompanyTemporaryName;
@DecimalMax(value = "9999999999.99",message = "应收总金额(元)格式错误")
@JsonFormat(shape = JsonFormat.Shape.STRING)
@ApiModelProperty(value = "应收总金额")
private BigDecimal allMoney;
@DecimalMax(value = "9999999999.99",message = "应收总金额(元)格式错误")
@JsonFormat(shape = JsonFormat.Shape.STRING)
@ApiModelProperty(value = "应收总金额范围")
private BigDecimal allMoneyTwo;
@ApiModelProperty(value = "来款年份")
private String year;
@ApiModelProperty(value = "付款状态")
private String payStatue;
@ApiModelProperty(value = "来款用途")
private int chargeUse;
@ApiModelProperty(value = "打包")
private int pack;
@ApiModelProperty(value = "付款状态")
private int inAccountStatue;
@ApiModelProperty(value = "项目负责人id")
private String principalNameId;
}