全所统计

This commit is contained in:
zhangqinlin
2021-09-18 18:03:48 +08:00
parent 90f27445dc
commit 383cac6f25
6 changed files with 72 additions and 51 deletions
@@ -77,41 +77,45 @@ public class PayWorkingGroupStatisticsController {
payWorkingGroupSearch.setYear(year);
}
//根据不同角色加载不同列表的参数
String joint=null;
List<String> idList = new ArrayList<>();
//判断登录角色,显示特定工作组内容,判断依据为登录用户的角色和机构编码
LoginUser sysUser =(LoginUser) SecurityUtils.getSubject().getPrincipal();
String roleCode = sysUser.getRoleCode();
//部门负责人
//科长
if(constant.BMFZR.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());
joint = String.join(",", list);
idList = userList.stream().map(SysUser::getId).collect(Collectors.toList());
//所领导或者超级管理员
} else if (constant.SLD.equals(roleCode)||constant.ADMIN.equals(roleCode)) {
joint = null;
//企业职员
idList=null;
//企业职员项目负责人
}else if( constant.QYRY.equals(roleCode)){
return Result.OK("无权限");
//超级管理员
}
IPage<PayWorkingGroupStatistics> pageList = payWorkingGroupService.queryPageListForStatistics(page, payWorkingGroupSearch,joint);
String userId = sysUser.getId();
idList.add(userId);
}
IPage<PayWorkingGroupStatistics> pageList = payWorkingGroupService.queryPageListForStatistics(page, payWorkingGroupSearch,idList);
List<PayWorkingGroupStatistics> records = pageList.getRecords();
//去除项目下来款金额为零的工作组
ArrayList<PayWorkingGroupStatistics> list = new ArrayList<>();
for(PayWorkingGroupStatistics payWorkingGroupStatistics:records) {
if (ObjectUtils.isNotEmpty(payWorkingGroupStatistics)) {
if (!("0".equals(payWorkingGroupStatistics.getComeAllMoney()) || payWorkingGroupStatistics.getComeAllMoney() == null)) {
list.add(payWorkingGroupStatistics);
}
for (PayWorkingGroupStatistics payWorkingGroupStatistics:records){
if(payWorkingGroupStatistics.getComeAllMoney()==null||payWorkingGroupStatistics.getComeAllMoney()==""){
payWorkingGroupStatistics.setComeAllMoney("0.00");
}
}
// //去除项目下来款金额为零的工作组
// ArrayList<PayWorkingGroupStatistics> list = new ArrayList<>();
// for(PayWorkingGroupStatistics payWorkingGroupStatistics:records) {
// if (ObjectUtils.isNotEmpty(payWorkingGroupStatistics)) {
// if (!("0".equals(payWorkingGroupStatistics.getComeAllMoney()) || 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();
double sum = records.stream().mapToDouble(t -> Double.parseDouble(t.getAllMoney()==null ? "0.00" : t.getAllMoney())).sum();
double sum2 = records.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("pageList",pageList.setRecords(records));
objectObjectHashMap.put("sumOfMoney", sum==0.0?sum:df.format(sum));
objectObjectHashMap.put("sumOfReallyMoney", sum2==0.0?sum2:df.format(sum2));
return Result.OK(objectObjectHashMap);
@@ -60,7 +60,7 @@ public interface PayWorkingGroupMapper extends BaseMapper<PayWorkingGroup> {
* @Return
* @Exception
*/
IPage<PayWorkingGroupStatistics> queryPageListForStatistics(Page<PayWorkingGroupStatistics> page,@Param("payWorkingGroupSearch") PayWorkingGroupSearch payWorkingGroupSearch,@Param("joint")String joint);
IPage<PayWorkingGroupStatistics> queryPageListForStatistics(Page<PayWorkingGroupStatistics> page,@Param("payWorkingGroupSearch") PayWorkingGroupSearch payWorkingGroupSearch,@Param("ids")List<String> ids);
/**
* @Description 工作组统计导出
@@ -113,11 +113,14 @@
GROUP BY working_group_id) pwgs on(pwg.id=pwgs.working_group_id)
left join pay_payment_record ppr on(pwgs.id=ppr.project_id)
<where>
<if test="joint != null and joint != ''">
pwg.principal_id_a =#{joint}
<if test="ids != null and ids != ''">
pwg.principal_id_a in
<foreach item="item" open="(" separator="," close=")" collection="ids">
#{item}
</foreach>
</if>
<if test="payWorkingGroupSearch.workGroup != null and payWorkingGroupSearch.workGroup != ''">
pwg.working_group_project LIKE concat('%',concat(#{payWorkingGroupSearch.workGroup},'%'))
and pwg.working_group_project LIKE concat('%',concat(#{payWorkingGroupSearch.workGroup},'%'))
</if>
<if test="payWorkingGroupSearch.year != null and payWorkingGroupSearch.year != ''">
AND date_format(ppr.payment_date,'%Y-%m-%d') LIKE concat('%',concat(#{payWorkingGroupSearch.year},'%'))
@@ -74,7 +74,7 @@ public interface IPayWorkingGroupService extends IService<PayWorkingGroup> {
* @Return
* @Exception
*/
IPage<PayWorkingGroupStatistics> queryPageListForStatistics(Page<PayWorkingGroupStatistics> page, PayWorkingGroupSearch payWorkingGroupSearch,String joint);
IPage<PayWorkingGroupStatistics> queryPageListForStatistics(Page<PayWorkingGroupStatistics> page, PayWorkingGroupSearch payWorkingGroupSearch,List<String> ids);
/**
* @Description 工作组统计查询导出
* @Author zql
@@ -99,8 +99,8 @@ public class PayWorkingGroupServiceImpl extends ServiceImpl<PayWorkingGroupMappe
}
@Override
public IPage<PayWorkingGroupStatistics> queryPageListForStatistics(Page<PayWorkingGroupStatistics> page, PayWorkingGroupSearch payWorkingGroupSearch,String joint) {
return payWorkingGroupMapper.queryPageListForStatistics(page,payWorkingGroupSearch, joint);
public IPage<PayWorkingGroupStatistics> queryPageListForStatistics(Page<PayWorkingGroupStatistics> page, PayWorkingGroupSearch payWorkingGroupSearch,List<String> ids) {
return payWorkingGroupMapper.queryPageListForStatistics(page,payWorkingGroupSearch, ids);
}
@Override
@@ -4,6 +4,8 @@ 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.LoginUser;
import com.jero.mail.commont.constant;
import com.jero.meeting.service.IPayMeetingSituationService;
import com.jero.member.service.IPayMemberProjectService;
import com.jero.member.service.IPayMemberProjectSubitemService;
@@ -22,6 +24,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
@@ -61,29 +64,34 @@ public class AllProjectStatisticsController {
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);
}
Page<AllProjectStatistics> page = new Page<>(pageNo, pageSize);
IPage<AllProjectStatistics> pageList = payWorkingGroupService.queryPageList3(page,allProjectStatisticsSearch);
HashMap<String, Object> hashMap = new HashMap<>();
double sum = pageList.getRecords() != null ? pageList.getRecords().stream().mapToDouble(t -> Double.parseDouble(t.getAllMoney() == null ? "0" : t.getAllMoney())).sum() : 0;
double sum2 = pageList.getRecords() != null ? pageList.getRecords().stream().mapToDouble(t -> Double.parseDouble(t.getComeAllMoney() == null ? "0" : t.getComeAllMoney())).sum() : 0;
DecimalFormat df = new DecimalFormat("#.00");
if (pageList.getRecords() != null) {
for(AllProjectStatistics 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);
LoginUser sysUser =(LoginUser) SecurityUtils.getSubject().getPrincipal();
String roleCode = sysUser.getRoleCode();
if(constant.SLD.equals(roleCode)||constant.ADMIN.equals(roleCode)) {
if (allProjectStatisticsSearch.getYear() == null || allProjectStatisticsSearch.getYear().equals("")) {
Calendar calendar = Calendar.getInstance();
String year = String.valueOf(calendar.get(Calendar.YEAR));
allProjectStatisticsSearch.setYear(year);
}
Page<AllProjectStatistics> page = new Page<>(pageNo, pageSize);
IPage<AllProjectStatistics> pageList = payWorkingGroupService.queryPageList3(page,allProjectStatisticsSearch);
HashMap<String, Object> hashMap = new HashMap<>();
double sum = pageList.getRecords() != null ? pageList.getRecords().stream().mapToDouble(t -> Double.parseDouble(t.getAllMoney() == null ? "0" : t.getAllMoney())).sum() : 0;
double sum2 = pageList.getRecords() != null ? pageList.getRecords().stream().mapToDouble(t -> Double.parseDouble(t.getComeAllMoney() == null ? "0" : t.getComeAllMoney())).sum() : 0;
DecimalFormat df = new DecimalFormat("#.00");
if (pageList.getRecords() != null) {
for(AllProjectStatistics 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("sumOfMoney", sum==0.0?sum:df.format(sum));
hashMap.put("sumOfReallyMoney", sum2==0.0?sum2:df.format(sum2));
hashMap.put("pageList",pageList);
return Result.OK(hashMap);
}else {
return Result.OK("权限不足");
}
hashMap.put("sumOfMoney", sum==0.0?sum:df.format(sum));
hashMap.put("sumOfReallyMoney", sum2==0.0?sum2:df.format(sum2));
hashMap.put("pageList",pageList);
return Result.OK(hashMap);
}
/**
@@ -93,11 +101,17 @@ public class AllProjectStatisticsController {
@GetMapping(value = "/statistics/excel")
@ApiOperation(value = "所领导统计-导出统计", notes = "所领导统计-导出统计")
public ModelAndView excel() {
AllProjectStatisticsSearch allProjectStatisticsSearch=new AllProjectStatisticsSearch();
AllProjectStatisticsSearch allProjectStatisticsSearch = new AllProjectStatisticsSearch();
// Calendar calendar = Calendar.getInstance();
// String year = String.valueOf(calendar.get(Calendar.YEAR));
// allProjectStatisticsSearch.setYear(year);
List<AllProjectStatistics> pageList = payWorkingGroupService.queryPageListExcel(allProjectStatisticsSearch);
return AmountUtil.exportListXls(pageList, AllProjectStatistics.class, "所领导统计");
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String roleCode = sysUser.getRoleCode();
if(constant.SLD.equals(roleCode)||constant.ADMIN.equals(roleCode)) {
List<AllProjectStatistics> pageList = payWorkingGroupService.queryPageListExcel(allProjectStatisticsSearch);
return AmountUtil.exportListXls(pageList, AllProjectStatistics.class, "所领导统计");
}else {
return new ModelAndView();
}
}
}