打包管理

This commit is contained in:
梁琦涛
2021-09-13 11:34:12 +08:00
parent 2a6eb66633
commit 9896dd8450
5 changed files with 108 additions and 3 deletions
@@ -1,5 +1,6 @@
package com.jero.pack.controller;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
@@ -22,6 +23,8 @@ import com.jero.pack.entity.PayPackCompany;
import com.jero.pack.entity.PayPackCompanyProject;
import com.jero.pack.service.IPayPackCompanyProjectService;
import com.jero.pack.service.IPayPackCompanyService;
import com.jero.pack.vo.PayPackCompanyProjectInput;
import com.jero.project.entity.PayCommonProject;
import com.jero.temporary.entity.PayContactsManagementTemporary;
import com.jero.temporary.service.IPayContactsManagementTemporaryService;
import lombok.extern.slf4j.Slf4j;
@@ -73,6 +76,19 @@ public class PayPackCompanyController extends JeroController<PayPackCompany, IPa
if(!CollectionUtils.isEmpty(pageList.getRecords())){
List<PayPackCompany> list = pageList.getRecords();
list.forEach(p->{
// 获取 打包费用,实际到账金额
PayPackCompanyProjectInput input = new PayPackCompanyProjectInput();
input.setCompanyId(p.getCompanyId());
input.setPackId(p.getId());
PayCommonProject payCommonProject = payPackCompanyService.queryPackListCount(input);
if(!Objects.isNull(payCommonProject)){
payCommonProject.setReceivableAmount(payCommonProject.getReceivableAmount());
payCommonProject.setPaidAmount(payCommonProject.getPaidAmount());
}else{
payCommonProject.setReceivableAmount(new BigDecimal("0.00"));
payCommonProject.setPaidAmount(new BigDecimal("0.00"));
}
// todo 获取开票金额
});
}
@@ -93,7 +109,6 @@ public class PayPackCompanyController extends JeroController<PayPackCompany, IPa
if(!StringUtils.isBlank(msg)){
return Result.error(msg.toString());
}
payPackCompanyService.addPayPackCompany(payPackCompany);
return Result.OK("添加成功!");
}
@@ -3,6 +3,8 @@ package com.jero.pack.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jero.pack.entity.PayPackCompany;
import com.jero.pack.vo.PayPackCompanyProjectInput;
import com.jero.project.entity.PayCommonProject;
/**
* @Description: pay_pack_company
@@ -12,4 +14,14 @@ import com.jero.pack.entity.PayPackCompany;
*/
public interface PayPackCompanyMapper extends BaseMapper<PayPackCompany> {
/**
* @Description 查询金额
* @Author lqt
* @Date 2021/9/13
* @Param
* @Return
* @Exception
*/
PayCommonProject queryPackListCount(PayPackCompanyProjectInput input);
}
@@ -1,5 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jero.pack.mapper.PayPackCompanyMapper">
<select id="queryPackListCount" resultType="com.jero.project.entity.PayCommonProject">
SELECT
sum(receivable_amount) as receivable_amount,
sum(paid_amount) as paid_amount
FROM (
<!-- 普通项目-->
select c.id,c.charge_project, c.charge_use, c.principal_id,c.principal_name,c.charge_company_temporary_name,c.receivable_amount,c.paid_amount,c.need_invoice,c.pack,c.in_account,c.make_invoice,c.mail,c.create_time,1 as projectType
from pay_common_project c
<where>
<if test="companyId != null and companyId != ''">
AND c.charge_company_id = #{companyId}
</if>
</where>
<!--工作组项目-->
UNION ALL
select gsub.id,g.working_group_project, gsub.charge_use, g.principal_id_a,g.principal_name_a,gsub.charge_company_temporary_name,gsub.receivable_amount,gsub.paid_amount,gsub.need_invoice,gsub.pack,gsub.in_account,gsub.make_invoice,gsub.mail,gsub.create_time,2
from pay_working_group g
inner join pay_working_group_subitem gsub on g.id = gsub.charge_company_id
<where>
<if test="companyId != null and companyId != ''">
AND gsub.charge_company_id = #{companyId}
</if>
</where>
<!-- 会议项目-->
UNION ALL
select sit.id,meeting.meeting_name,sit.charge_use, meeting.director_id, meeting.director_name,sit.company_name,sit.amount_receivable,sit.paid_amount,sit.need_invoice,sit.pack,sit.in_account,sit.make_invoice,sit.mail,sit.create_time,3
from pay_meeting meeting
inner join pay_meeting_situation sit on meeting.id = sit.meeting_id
<where>
<if test="companyId != null and companyId != ''">
AND sit.company_id = #{companyId}
</if>
</where>
<!-- 会员项目-->
UNION ALL
select msub.id,pmp.project_name,msub.charge_use,pmp.director_id,pmp.director_name,msub.company_name,msub.amount_receivable,msub.paid_amount,msub.need_invoice,msub.pack,msub.in_account,msub.make_invoice,msub.mail,msub.create_time,4
from pay_member_project pmp
inner join pay_member_project_subitem msub on pmp.id=msub.project_id
<where>
<if test="companyId != null and companyId != ''">
AND msub.company_id = #{companyId}
</if>
</where>
<!-- 标协会员项目-->
UNION ALL
select tmsub.id,tmember.project_name,tmsub.charge_use,'','',tmsub.company_name,tmsub.amount_receivable,tmsub.paid_amount,tmsub.invoice_requirements,tmsub.pack,tmsub.in_account,tmsub.make_invoice,tmsub.mail,tmsub.create_time,5
from tb_member_project tmember
inner join tb_member_project_subitem tmsub on tmember.id=tmsub.project_id
<where>
<if test="companyId != null and companyId != ''">
AND tmsub.company_id = #{companyId}
</if>
</where>
) project
<if test="packId != null and packId != ''">
WHERE project.id NOT IN (SELECT project_id FROM pay_pack_company_project where pack_id = #{packId})
</if>
</select>
</mapper>
@@ -2,6 +2,8 @@ package com.jero.pack.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.pack.entity.PayPackCompany;
import com.jero.pack.vo.PayPackCompanyProjectInput;
import com.jero.project.entity.PayCommonProject;
/**
* @Description: pay_pack_company
@@ -28,4 +30,13 @@ public interface IPayPackCompanyService extends IService<PayPackCompany> {
* @Exception
*/
void editPayPackCompany(PayPackCompany payPackCompany);
/**
* @Description 查询金额
* @Author lqt
* @Date 2021/9/13
* @Param
* @Return
* @Exception
*/
PayCommonProject queryPackListCount(PayPackCompanyProjectInput input);
}
@@ -7,6 +7,8 @@ import com.jero.common.exception.JeroBootException;
import com.jero.pack.entity.PayPackCompany;
import com.jero.pack.mapper.PayPackCompanyMapper;
import com.jero.pack.service.IPayPackCompanyService;
import com.jero.pack.vo.PayPackCompanyProjectInput;
import com.jero.project.entity.PayCommonProject;
import com.jero.project.entity.PayWorkingGroupSubItem;
import com.jero.temporary.entity.PayCompanyManagementTemporary;
import com.jero.temporary.entity.PayContactsManagementTemporary;
@@ -17,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Objects;
@@ -35,6 +38,8 @@ public class PayPackCompanyServiceImpl extends ServiceImpl<PayPackCompanyMapper,
private IPayCompanyManagementTemporaryService payCompanyManagementTemporaryService;
@Autowired
private IPayContactsManagementTemporaryService payContactsManagementTemporaryService;
@Resource
private PayPackCompanyMapper payPackCompanyMapper;
@Override
@Transactional
@@ -74,13 +79,18 @@ public class PayPackCompanyServiceImpl extends ServiceImpl<PayPackCompanyMapper,
log.error("",e);
throw new JeroBootException("该年份下已存在此打包企业!");
}
setPayPackCompany(payPackCompany);
// 删除历史数据
payCompanyManagementTemporaryService.removeById(payPackCompanyOld.getCompanyTemporaryId());
payContactsManagementTemporaryService.removeByIds(Arrays.asList(payPackCompanyOld.getCompanyContactTemporaryId(),payPackCompanyOld.getPackContactTemporaryId()));
setPayPackCompany(payPackCompany);
payPackCompanyService.updateById(payPackCompany);
}
@Override
public PayCommonProject queryPackListCount(PayPackCompanyProjectInput input) {
return payPackCompanyMapper.queryPackListCount(input);
}
/**
* @Description 插入企业信息,联系人信息到临时表,更新项目记录
* @Author lqt