Commit 2a99e04d authored by chase's avatar chase

fix bug

parent a3b88a86
...@@ -342,17 +342,15 @@ public class ReportServiceImpl extends BaseService { ...@@ -342,17 +342,15 @@ public class ReportServiceImpl extends BaseService {
andStartDateLessThanOrEqualTo(queryDate).andEndDateGreaterThanOrEqualTo(queryDate). andStartDateLessThanOrEqualTo(queryDate).andEndDateGreaterThanOrEqualTo(queryDate).
andStatusEqualTo(0); andStatusEqualTo(0);
List<RevenueTypeMapping> mappingList = revenueTypeMappingMapper.selectByExample(mappingExample); List<RevenueTypeMapping> mappingList = revenueTypeMappingMapper.selectByExample(mappingExample);
//先清除数据
InvoiceRecord delRecord = new InvoiceRecord();
delRecord.setRevenueCofId(null);
if(!isMergeManualData){
delRecord.setModifyRevenueCofId(null);
}
InvoiceRecordExample delExample = new InvoiceRecordExample(); InvoiceRecordExample delExample = new InvoiceRecordExample();
delExample.createCriteria().andProjectIdEqualTo(projectId) delExample.createCriteria().andProjectIdEqualTo(projectId).
.andProjectIdEqualTo(projectId).
andPeriodEqualTo(Integer.valueOf(queryDate.replace("-", ""))); andPeriodEqualTo(Integer.valueOf(queryDate.replace("-", "")));
invoiceRecordMapper.deleteByExample(delExample); if(isMergeManualData){
invoiceRecordMapper.clearRevenueCof(true,false,delExample);
}else{
invoiceRecordMapper.clearRevenueCof(true,true,delExample);
}
Map<String, Long> map = new HashMap<>(); Map<String, Long> map = new HashMap<>();
for (RevenueTypeMapping mapping : mappingList) { for (RevenueTypeMapping mapping : mappingList) {
if (!map.containsKey(mapping.getContent())) { if (!map.containsKey(mapping.getContent())) {
......
...@@ -129,4 +129,6 @@ public interface InvoiceRecordMapper extends MyVatMapper { ...@@ -129,4 +129,6 @@ public interface InvoiceRecordMapper extends MyVatMapper {
List<String> queryBillTypeGroupBy(@Param("projectId") String projectId, List<String> queryBillTypeGroupBy(@Param("projectId") String projectId,
@Param("period") Integer period); @Param("period") Integer period);
int clearRevenueCof(@Param("clearRevenue") boolean clearRevenue, @Param("clearModifyRevenue") boolean clearModifyRevenue,@Param("example") InvoiceRecordExample example);
} }
\ No newline at end of file
...@@ -2,235 +2,240 @@ ...@@ -2,235 +2,240 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="pwc.taxtech.atms.vat.dao.InvoiceRecordMapper"> <mapper namespace="pwc.taxtech.atms.vat.dao.InvoiceRecordMapper">
<sql id="QueryCondition"> <sql id="QueryCondition">
1 = 1 1 = 1
<if test="@com.github.pagehelper.util.StringUtil@isNotEmpty(irCondition.orgId)"> <if test="@com.github.pagehelper.util.StringUtil@isNotEmpty(irCondition.orgId)">
AND organization_id= #{irCondition.orgId,jdbcType=VARCHAR} AND organization_id= #{irCondition.orgId,jdbcType=VARCHAR}
</if> </if>
<if test="irCondition.periodStart!=null"> <if test="irCondition.periodStart!=null">
AND tms_period &gt;= #{irCondition.periodStart,jdbcType=INTEGER} AND tms_period &gt;= #{irCondition.periodStart,jdbcType=INTEGER}
</if> </if>
<if test="irCondition.periodEnd!=null"> <if test="irCondition.periodEnd!=null">
AND tms_period &lt;= #{irCondition.periodEnd,jdbcType=INTEGER} AND tms_period &lt;= #{irCondition.periodEnd,jdbcType=INTEGER}
</if> </if>
</sql> </sql>
<select id="selectByCondition" parameterType="pwc.taxtech.atms.vat.dpo.InvoiceRecordCondition" resultMap="BaseResultMap"> <select id="selectByCondition" parameterType="pwc.taxtech.atms.vat.dpo.InvoiceRecordCondition"
select resultMap="BaseResultMap">
<include refid="Base_Column_List" /> select
from invoice_record <include refid="Base_Column_List"/>
where from invoice_record
<include refid="QueryCondition"/> where
</select> <include refid="QueryCondition"/>
</select>
<select id="selectCountByCondition" parameterType="pwc.taxtech.atms.vat.dpo.InvoiceRecordCondition" resultType="Integer"> <select id="selectCountByCondition" parameterType="pwc.taxtech.atms.vat.dpo.InvoiceRecordCondition"
select resultType="Integer">
count(*) select
from invoice_record count(*)
where from invoice_record
<include refid="QueryCondition"/> where
</select> <include refid="QueryCondition"/>
</select>
<insert id="insertBatch" parameterType="java.util.List"> <insert id="insertBatch" parameterType="java.util.List">
insert into invoice_record insert into invoice_record
(id, organization_id, project_id, tms_period, period, seq_no, `source`, billing_body, (id, organization_id, project_id, tms_period, period, seq_no, `source`, billing_body,
customer_company_name, invoice_type, billing_content, invoice_amount, applicant, customer_company_name, invoice_type, billing_content, invoice_amount, applicant,
oa_application_num, contract_no, contract_amount, department, application_date, billing_date, oa_application_num, contract_no, contract_amount, department, application_date, billing_date,
billing_month, invoice_code, invoice_num, invoices_amount, customer_company_tax_num, billing_month, invoice_code, invoice_num, invoices_amount, customer_company_tax_num,
contract_source_system, tax_rate, tax_amount, invoice_status, remarks, create_time, contract_source_system, tax_rate, tax_amount, invoice_status, remarks, create_time,
update_time) update_time)
values values
<foreach collection="list" item="item" index="index" separator=","> <foreach collection="list" item="item" index="index" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<choose> <choose>
<when test="item.id != null">#{item.id,jdbcType=BIGINT},</when> <when test="item.id != null">#{item.id,jdbcType=BIGINT},</when>
<otherwise>0,</otherwise> <otherwise>0,</otherwise>
</choose> </choose>
<choose> <choose>
<when test="item.organizationId != null">#{item.organizationId,jdbcType=VARCHAR},</when> <when test="item.organizationId != null">#{item.organizationId,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise> <otherwise>'',</otherwise>
</choose> </choose>
<choose> <choose>
<when test="item.projectId != null">#{item.projectId,jdbcType=VARCHAR},</when> <when test="item.projectId != null">#{item.projectId,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise> <otherwise>'',</otherwise>
</choose> </choose>
<choose> <choose>
<when test="item.tmsPeriod != null">#{item.tmsPeriod,jdbcType=INTEGER},</when> <when test="item.tmsPeriod != null">#{item.tmsPeriod,jdbcType=INTEGER},</when>
<otherwise>0,</otherwise> <otherwise>0,</otherwise>
</choose> </choose>
<choose> <choose>
<when test="item.period != null">#{item.period,jdbcType=INTEGER},</when> <when test="item.period != null">#{item.period,jdbcType=INTEGER},</when>
<otherwise>0,</otherwise> <otherwise>0,</otherwise>
</choose> </choose>
<choose> <choose>
<when test="item.seqNo != null">#{item.seqNo,jdbcType=INTEGER},</when> <when test="item.seqNo != null">#{item.seqNo,jdbcType=INTEGER},</when>
<otherwise>0,</otherwise> <otherwise>0,</otherwise>
</choose> </choose>
<choose> <choose>
<when test="item.source != null">#{item.source,jdbcType=VARCHAR},</when> <when test="item.source != null">#{item.source,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise> <otherwise>'',</otherwise>
</choose> </choose>
<choose> <choose>
<when test="item.billingBody != null">#{item.billingBody,jdbcType=VARCHAR},</when> <when test="item.billingBody != null">#{item.billingBody,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise> <otherwise>'',</otherwise>
</choose> </choose>
<choose> <choose>
<when test="item.customerCompanyName != null">#{item.customerCompanyName,jdbcType=VARCHAR},</when> <when test="item.customerCompanyName != null">#{item.customerCompanyName,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise> <otherwise>'',</otherwise>
</choose> </choose>
<choose> <choose>
<when test="item.invoiceType != null">#{item.invoiceType,jdbcType=VARCHAR},</when> <when test="item.invoiceType != null">#{item.invoiceType,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise> <otherwise>'',</otherwise>
</choose> </choose>
<choose> <choose>
<when test="item.billingContent != null">#{item.billingContent,jdbcType=VARCHAR},</when> <when test="item.billingContent != null">#{item.billingContent,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise> <otherwise>'',</otherwise>
</choose> </choose>
<choose> <choose>
<when test="item.invoiceAmount != null">#{item.invoiceAmount,jdbcType=INTEGER},</when> <when test="item.invoiceAmount != null">#{item.invoiceAmount,jdbcType=INTEGER},</when>
<otherwise>0,</otherwise> <otherwise>0,</otherwise>
</choose> </choose>
<choose> <choose>
<when test="item.applicant != null">#{item.applicant,jdbcType=VARCHAR},</when> <when test="item.applicant != null">#{item.applicant,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise> <otherwise>'',</otherwise>
</choose> </choose>
<choose> <choose>
<when test="item.oaApplicationNum != null">#{item.oaApplicationNum,jdbcType=VARCHAR},</when> <when test="item.oaApplicationNum != null">#{item.oaApplicationNum,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise> <otherwise>'',</otherwise>
</choose> </choose>
<choose> <choose>
<when test="item.contractNo != null">#{item.contractNo,jdbcType=VARCHAR},</when> <when test="item.contractNo != null">#{item.contractNo,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise> <otherwise>'',</otherwise>
</choose> </choose>
<choose> <choose>
<when test="item.contractAmount != null">#{item.contractAmount,jdbcType=DECIMAL},</when> <when test="item.contractAmount != null">#{item.contractAmount,jdbcType=DECIMAL},</when>
<otherwise>0,</otherwise> <otherwise>0,</otherwise>
</choose> </choose>
<choose> <choose>
<when test="item.department != null">#{item.department,jdbcType=VARCHAR},</when> <when test="item.department != null">#{item.department,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise> <otherwise>'',</otherwise>
</choose> </choose>
<choose> <choose>
<when test="item.applicationDate != null">#{item.applicationDate,jdbcType=TIMESTAMP},</when> <when test="item.applicationDate != null">#{item.applicationDate,jdbcType=TIMESTAMP},</when>
<otherwise>CURRENT_TIMESTAMP,</otherwise> <otherwise>CURRENT_TIMESTAMP,</otherwise>
</choose> </choose>
<choose> <choose>
<when test="item.billingDate != null">#{item.billingDate,jdbcType=TIMESTAMP},</when> <when test="item.billingDate != null">#{item.billingDate,jdbcType=TIMESTAMP},</when>
<otherwise>CURRENT_TIMESTAMP,</otherwise> <otherwise>CURRENT_TIMESTAMP,</otherwise>
</choose> </choose>
<choose> <choose>
<when test="item.billingMonth != null">#{item.billingMonth,jdbcType=TIMESTAMP},</when> <when test="item.billingMonth != null">#{item.billingMonth,jdbcType=TIMESTAMP},</when>
<otherwise>CURRENT_TIMESTAMP,</otherwise> <otherwise>CURRENT_TIMESTAMP,</otherwise>
</choose> </choose>
<choose> <choose>
<when test="item.invoiceCode != null">#{item.invoiceCode,jdbcType=VARCHAR},</when> <when test="item.invoiceCode != null">#{item.invoiceCode,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise> <otherwise>'',</otherwise>
</choose> </choose>
<choose> <choose>
<when test="item.invoiceNum != null">#{item.invoiceNum,jdbcType=VARCHAR},</when> <when test="item.invoiceNum != null">#{item.invoiceNum,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise> <otherwise>'',</otherwise>
</choose> </choose>
<choose> <choose>
<when test="item.invoicesAmount != null">#{item.invoicesAmount,jdbcType=INTEGER},</when> <when test="item.invoicesAmount != null">#{item.invoicesAmount,jdbcType=INTEGER},</when>
<otherwise>0,</otherwise> <otherwise>0,</otherwise>
</choose> </choose>
<choose> <choose>
<when test="item.customerCompanyTaxNum != null">#{item.customerCompanyTaxNum,jdbcType=VARCHAR},</when> <when test="item.customerCompanyTaxNum != null">#{item.customerCompanyTaxNum,jdbcType=VARCHAR},
<otherwise>'',</otherwise> </when>
</choose> <otherwise>'',</otherwise>
<choose> </choose>
<when test="item.contractSourceSystem != null">#{item.contractSourceSystem,jdbcType=VARCHAR},</when> <choose>
<otherwise>'',</otherwise> <when test="item.contractSourceSystem != null">#{item.contractSourceSystem,jdbcType=VARCHAR},</when>
</choose> <otherwise>'',</otherwise>
<choose> </choose>
<when test="item.taxRate != null">#{item.taxRate,jdbcType=DECIMAL},</when> <choose>
<otherwise>0,</otherwise> <when test="item.taxRate != null">#{item.taxRate,jdbcType=DECIMAL},</when>
</choose> <otherwise>0,</otherwise>
<choose> </choose>
<when test="item.taxAmount != null">#{item.taxAmount,jdbcType=DECIMAL},</when> <choose>
<otherwise>0,</otherwise> <when test="item.taxAmount != null">#{item.taxAmount,jdbcType=DECIMAL},</when>
</choose> <otherwise>0,</otherwise>
<choose> </choose>
<when test="item.invoiceStatus != null">#{item.invoiceStatus,jdbcType=VARCHAR},</when> <choose>
<otherwise>'',</otherwise> <when test="item.invoiceStatus != null">#{item.invoiceStatus,jdbcType=VARCHAR},</when>
</choose> <otherwise>'',</otherwise>
<choose> </choose>
<when test="item.remarks != null">#{item.remarks,jdbcType=VARCHAR},</when> <choose>
<otherwise>'',</otherwise> <when test="item.remarks != null">#{item.remarks,jdbcType=VARCHAR},</when>
</choose> <otherwise>'',</otherwise>
<choose> </choose>
<when test="item.createTime != null">#{item.createTime,jdbcType=TIMESTAMP},</when> <choose>
<otherwise>CURRENT_TIMESTAMP,</otherwise> <when test="item.createTime != null">#{item.createTime,jdbcType=TIMESTAMP},</when>
</choose> <otherwise>CURRENT_TIMESTAMP,</otherwise>
<choose> </choose>
<when test="item.updateTime != null">#{item.updateTime,jdbcType=TIMESTAMP},</when> <choose>
<otherwise>CURRENT_TIMESTAMP,</otherwise> <when test="item.updateTime != null">#{item.updateTime,jdbcType=TIMESTAMP},</when>
</choose> <otherwise>CURRENT_TIMESTAMP,</otherwise>
</trim> </choose>
</foreach>; </trim>
SELECT 1 FROM DUAL; </foreach>
</insert> ;
SELECT 1 FROM DUAL;
</insert>
<select id="queryBillWithRevenueConf" resultType="pwc.taxtech.atms.dpo.BillDetailDto"> <select id="queryBillWithRevenueConf" resultType="pwc.taxtech.atms.dpo.BillDetailDto">
select detail.* select detail.*
from (select bd.id as id, from (select bd.id as id,
bd.billing_body as subject, bd.billing_body as subject,
bd.customer_company_name as customer, bd.customer_company_name as customer,
bd.invoice_type as billType, bd.invoice_type as billType,
bd.billing_content as billContent, bd.billing_content as billContent,
bd.invoice_amount as billAmount, bd.invoice_amount as billAmount,
bd.tax_rate as billTaxRat, bd.tax_rate as billTaxRat,
bd.tax_amount as billTaxAmount, bd.tax_amount as billTaxAmount,
bd.oa_application_num as OANo, bd.oa_application_num as OANo,
bd.department as department, bd.department as department,
bd.billing_date as billDate, bd.billing_date as billDate,
bd.invoice_code as billCode, bd.invoice_code as billCode,
bd.invoice_num as billNumber, bd.invoice_num as billNumber,
modfiy_rc.id as modifyRevenueCofId, modfiy_rc.id as modifyRevenueCofId,
modfiy_rc.name as modifyRevenueCofName, modfiy_rc.name as modifyRevenueCofName,
rc.id as revenueCofId, rc.id as revenueCofId,
rc.name as revenueConfName, rc.name as revenueConfName,
case case
when rc.id is null then 1 when rc.id is null then 1
<![CDATA[WHEN rc.id IS NOT NULL and (rc.start_date > #{queryDate} or rc.end_date < #{queryDate}) then 1]]> <![CDATA[WHEN rc.id IS NOT NULL and (rc.start_date > #{queryDate} or rc.end_date < #{queryDate}) then 1]]>
<![CDATA[WHEN rc.id IS NOT NULL and rc.start_date <= #{queryDate} and rc.end_date >= #{queryDate} THEN 2]]> <![CDATA[WHEN rc.id IS NOT NULL and rc.start_date <= #{queryDate} and rc.end_date >= #{queryDate} THEN 2]]>
end as emptyCode end as emptyCode
from invoice_record as bd from invoice_record as bd
left join revenue_config as rc on rc.org_id = bd.organization_id and rc.id = bd.revenue_cof_id left join revenue_config as rc on rc.org_id = bd.organization_id and rc.id = bd.revenue_cof_id
left join revenue_config as modfiy_rc on modfiy_rc.id = bd.modify_revenue_cof_id left join revenue_config as modfiy_rc on modfiy_rc.id = bd.modify_revenue_cof_id
where bd.project_id = #{projectId} where bd.project_id = #{projectId}
and bd.period = #{period} and bd.period = #{period}
<if test="billType != null and billType != ''"> <if test="billType != null and billType != ''">
and bd.invoice_type = #{billType} and bd.invoice_type = #{billType}
</if> </if>
<if test="customer != null and customer != ''"> <if test="customer != null and customer != ''">
and bd.customer_company_name like concat('%',#{customer},'%') and bd.customer_company_name like concat('%',#{customer},'%')
</if> </if>
<if test="billNumber != null and billNumber != ''"> <if test="billNumber != null and billNumber != ''">
and bd.invoice_num like concat('%',#{billNumber},'%') and bd.invoice_num like concat('%',#{billNumber},'%')
</if> </if>
<if test="revenueCofId != null"> <if test="revenueCofId != null">
and if(bd.modify_revenue_cof_id is null,bd.revenue_cof_id = #{revenueCofId},bd.modify_revenue_cof_id = #{revenueCofId}) and if(bd.modify_revenue_cof_id is null,bd.revenue_cof_id = #{revenueCofId},bd.modify_revenue_cof_id =
</if> #{revenueCofId})
<if test="billContent != null and billContent != ''"> </if>
and bd.billing_content like concat('%',#{billContent},'%') <if test="billContent != null and billContent != ''">
</if> and bd.billing_content like concat('%',#{billContent},'%')
<if test="department != null and department != ''"> </if>
and bd.department like concat('%',#{department},'%') <if test="department != null and department != ''">
</if> and bd.department like concat('%',#{department},'%')
<if test="billTaxRat != null"> </if>
and bd.tax_rate = #{billTaxRat} <if test="billTaxRat != null">
</if> and bd.tax_rate = #{billTaxRat}
<if test="billDate != null and billDate != ''"> </if>
and bd.billing_date = #{billDate} <if test="billDate != null and billDate != ''">
</if> and bd.billing_date = #{billDate}
) as detail </if>
order by detail.emptyCode,detail.billDate desc ) as detail
order by detail.emptyCode,detail.billDate desc
</select> </select>
<select id="queryBillTypeGroupBy" resultType="java.lang.String"> <select id="queryBillTypeGroupBy" resultType="java.lang.String">
select invoice_type select invoice_type
from invoice_record from invoice_record
where project_id = #{projectId} where project_id = #{projectId}
...@@ -238,4 +243,18 @@ ...@@ -238,4 +243,18 @@
group by invoice_type; group by invoice_type;
</select> </select>
<update id="clearRevenueCof">
update invoice_record
<set>
<if test="clearRevenue">
revenue_cof_id = null,
</if>
<if test="clearModifyRevenue">
modify_revenue_cof_id = null,
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment