Commit 2a99e04d authored by chase's avatar chase

fix bug

parent a3b88a86
......@@ -342,17 +342,15 @@ public class ReportServiceImpl extends BaseService {
andStartDateLessThanOrEqualTo(queryDate).andEndDateGreaterThanOrEqualTo(queryDate).
andStatusEqualTo(0);
List<RevenueTypeMapping> mappingList = revenueTypeMappingMapper.selectByExample(mappingExample);
//先清除数据
InvoiceRecord delRecord = new InvoiceRecord();
delRecord.setRevenueCofId(null);
if(!isMergeManualData){
delRecord.setModifyRevenueCofId(null);
}
InvoiceRecordExample delExample = new InvoiceRecordExample();
delExample.createCriteria().andProjectIdEqualTo(projectId)
.andProjectIdEqualTo(projectId).
delExample.createCriteria().andProjectIdEqualTo(projectId).
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<>();
for (RevenueTypeMapping mapping : mappingList) {
if (!map.containsKey(mapping.getContent())) {
......
......@@ -129,4 +129,6 @@ public interface InvoiceRecordMapper extends MyVatMapper {
List<String> queryBillTypeGroupBy(@Param("projectId") String projectId,
@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 @@
<!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">
<sql id="QueryCondition">
1 = 1
<if test="@com.github.pagehelper.util.StringUtil@isNotEmpty(irCondition.orgId)">
AND organization_id= #{irCondition.orgId,jdbcType=VARCHAR}
</if>
<if test="irCondition.periodStart!=null">
AND tms_period &gt;= #{irCondition.periodStart,jdbcType=INTEGER}
</if>
<if test="irCondition.periodEnd!=null">
AND tms_period &lt;= #{irCondition.periodEnd,jdbcType=INTEGER}
</if>
</sql>
<sql id="QueryCondition">
1 = 1
<if test="@com.github.pagehelper.util.StringUtil@isNotEmpty(irCondition.orgId)">
AND organization_id= #{irCondition.orgId,jdbcType=VARCHAR}
</if>
<if test="irCondition.periodStart!=null">
AND tms_period &gt;= #{irCondition.periodStart,jdbcType=INTEGER}
</if>
<if test="irCondition.periodEnd!=null">
AND tms_period &lt;= #{irCondition.periodEnd,jdbcType=INTEGER}
</if>
</sql>
<select id="selectByCondition" parameterType="pwc.taxtech.atms.vat.dpo.InvoiceRecordCondition" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from invoice_record
where
<include refid="QueryCondition"/>
</select>
<select id="selectByCondition" parameterType="pwc.taxtech.atms.vat.dpo.InvoiceRecordCondition"
resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from invoice_record
where
<include refid="QueryCondition"/>
</select>
<select id="selectCountByCondition" parameterType="pwc.taxtech.atms.vat.dpo.InvoiceRecordCondition" resultType="Integer">
select
count(*)
from invoice_record
where
<include refid="QueryCondition"/>
</select>
<select id="selectCountByCondition" parameterType="pwc.taxtech.atms.vat.dpo.InvoiceRecordCondition"
resultType="Integer">
select
count(*)
from invoice_record
where
<include refid="QueryCondition"/>
</select>
<insert id="insertBatch" parameterType="java.util.List">
insert into invoice_record
(id, organization_id, project_id, tms_period, period, seq_no, `source`, billing_body,
customer_company_name, invoice_type, billing_content, invoice_amount, applicant,
oa_application_num, contract_no, contract_amount, department, application_date, billing_date,
billing_month, invoice_code, invoice_num, invoices_amount, customer_company_tax_num,
contract_source_system, tax_rate, tax_amount, invoice_status, remarks, create_time,
update_time)
values
<foreach collection="list" item="item" index="index" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=",">
<choose>
<when test="item.id != null">#{item.id,jdbcType=BIGINT},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.organizationId != null">#{item.organizationId,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.projectId != null">#{item.projectId,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.tmsPeriod != null">#{item.tmsPeriod,jdbcType=INTEGER},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.period != null">#{item.period,jdbcType=INTEGER},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.seqNo != null">#{item.seqNo,jdbcType=INTEGER},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.source != null">#{item.source,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.billingBody != null">#{item.billingBody,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.customerCompanyName != null">#{item.customerCompanyName,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.invoiceType != null">#{item.invoiceType,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.billingContent != null">#{item.billingContent,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.invoiceAmount != null">#{item.invoiceAmount,jdbcType=INTEGER},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.applicant != null">#{item.applicant,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.oaApplicationNum != null">#{item.oaApplicationNum,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.contractNo != null">#{item.contractNo,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.contractAmount != null">#{item.contractAmount,jdbcType=DECIMAL},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.department != null">#{item.department,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.applicationDate != null">#{item.applicationDate,jdbcType=TIMESTAMP},</when>
<otherwise>CURRENT_TIMESTAMP,</otherwise>
</choose>
<choose>
<when test="item.billingDate != null">#{item.billingDate,jdbcType=TIMESTAMP},</when>
<otherwise>CURRENT_TIMESTAMP,</otherwise>
</choose>
<choose>
<when test="item.billingMonth != null">#{item.billingMonth,jdbcType=TIMESTAMP},</when>
<otherwise>CURRENT_TIMESTAMP,</otherwise>
</choose>
<choose>
<when test="item.invoiceCode != null">#{item.invoiceCode,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.invoiceNum != null">#{item.invoiceNum,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.invoicesAmount != null">#{item.invoicesAmount,jdbcType=INTEGER},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.customerCompanyTaxNum != null">#{item.customerCompanyTaxNum,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.contractSourceSystem != null">#{item.contractSourceSystem,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.taxRate != null">#{item.taxRate,jdbcType=DECIMAL},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.taxAmount != null">#{item.taxAmount,jdbcType=DECIMAL},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.invoiceStatus != null">#{item.invoiceStatus,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.remarks != null">#{item.remarks,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.createTime != null">#{item.createTime,jdbcType=TIMESTAMP},</when>
<otherwise>CURRENT_TIMESTAMP,</otherwise>
</choose>
<choose>
<when test="item.updateTime != null">#{item.updateTime,jdbcType=TIMESTAMP},</when>
<otherwise>CURRENT_TIMESTAMP,</otherwise>
</choose>
</trim>
</foreach>;
SELECT 1 FROM DUAL;
</insert>
<insert id="insertBatch" parameterType="java.util.List">
insert into invoice_record
(id, organization_id, project_id, tms_period, period, seq_no, `source`, billing_body,
customer_company_name, invoice_type, billing_content, invoice_amount, applicant,
oa_application_num, contract_no, contract_amount, department, application_date, billing_date,
billing_month, invoice_code, invoice_num, invoices_amount, customer_company_tax_num,
contract_source_system, tax_rate, tax_amount, invoice_status, remarks, create_time,
update_time)
values
<foreach collection="list" item="item" index="index" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=",">
<choose>
<when test="item.id != null">#{item.id,jdbcType=BIGINT},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.organizationId != null">#{item.organizationId,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.projectId != null">#{item.projectId,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.tmsPeriod != null">#{item.tmsPeriod,jdbcType=INTEGER},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.period != null">#{item.period,jdbcType=INTEGER},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.seqNo != null">#{item.seqNo,jdbcType=INTEGER},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.source != null">#{item.source,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.billingBody != null">#{item.billingBody,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.customerCompanyName != null">#{item.customerCompanyName,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.invoiceType != null">#{item.invoiceType,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.billingContent != null">#{item.billingContent,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.invoiceAmount != null">#{item.invoiceAmount,jdbcType=INTEGER},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.applicant != null">#{item.applicant,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.oaApplicationNum != null">#{item.oaApplicationNum,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.contractNo != null">#{item.contractNo,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.contractAmount != null">#{item.contractAmount,jdbcType=DECIMAL},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.department != null">#{item.department,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.applicationDate != null">#{item.applicationDate,jdbcType=TIMESTAMP},</when>
<otherwise>CURRENT_TIMESTAMP,</otherwise>
</choose>
<choose>
<when test="item.billingDate != null">#{item.billingDate,jdbcType=TIMESTAMP},</when>
<otherwise>CURRENT_TIMESTAMP,</otherwise>
</choose>
<choose>
<when test="item.billingMonth != null">#{item.billingMonth,jdbcType=TIMESTAMP},</when>
<otherwise>CURRENT_TIMESTAMP,</otherwise>
</choose>
<choose>
<when test="item.invoiceCode != null">#{item.invoiceCode,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.invoiceNum != null">#{item.invoiceNum,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.invoicesAmount != null">#{item.invoicesAmount,jdbcType=INTEGER},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.customerCompanyTaxNum != null">#{item.customerCompanyTaxNum,jdbcType=VARCHAR},
</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.contractSourceSystem != null">#{item.contractSourceSystem,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.taxRate != null">#{item.taxRate,jdbcType=DECIMAL},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.taxAmount != null">#{item.taxAmount,jdbcType=DECIMAL},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.invoiceStatus != null">#{item.invoiceStatus,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.remarks != null">#{item.remarks,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.createTime != null">#{item.createTime,jdbcType=TIMESTAMP},</when>
<otherwise>CURRENT_TIMESTAMP,</otherwise>
</choose>
<choose>
<when test="item.updateTime != null">#{item.updateTime,jdbcType=TIMESTAMP},</when>
<otherwise>CURRENT_TIMESTAMP,</otherwise>
</choose>
</trim>
</foreach>
;
SELECT 1 FROM DUAL;
</insert>
<select id="queryBillWithRevenueConf" resultType="pwc.taxtech.atms.dpo.BillDetailDto">
select detail.*
from (select bd.id as id,
bd.billing_body as subject,
bd.customer_company_name as customer,
bd.invoice_type as billType,
bd.billing_content as billContent,
bd.invoice_amount as billAmount,
bd.tax_rate as billTaxRat,
bd.tax_amount as billTaxAmount,
bd.oa_application_num as OANo,
bd.department as department,
bd.billing_date as billDate,
bd.invoice_code as billCode,
bd.invoice_num as billNumber,
modfiy_rc.id as modifyRevenueCofId,
modfiy_rc.name as modifyRevenueCofName,
rc.id as revenueCofId,
rc.name as revenueConfName,
case
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} and rc.end_date >= #{queryDate} THEN 2]]>
end as emptyCode
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 modfiy_rc on modfiy_rc.id = bd.modify_revenue_cof_id
where bd.project_id = #{projectId}
and bd.period = #{period}
<if test="billType != null and billType != ''">
and bd.invoice_type = #{billType}
</if>
<if test="customer != null and customer != ''">
and bd.customer_company_name like concat('%',#{customer},'%')
</if>
<if test="billNumber != null and billNumber != ''">
and bd.invoice_num like concat('%',#{billNumber},'%')
</if>
<if test="revenueCofId != null">
and if(bd.modify_revenue_cof_id is null,bd.revenue_cof_id = #{revenueCofId},bd.modify_revenue_cof_id = #{revenueCofId})
</if>
<if test="billContent != null and billContent != ''">
and bd.billing_content like concat('%',#{billContent},'%')
</if>
<if test="department != null and department != ''">
and bd.department like concat('%',#{department},'%')
</if>
<if test="billTaxRat != null">
and bd.tax_rate = #{billTaxRat}
</if>
<if test="billDate != null and billDate != ''">
and bd.billing_date = #{billDate}
</if>
) as detail
order by detail.emptyCode,detail.billDate desc
<select id="queryBillWithRevenueConf" resultType="pwc.taxtech.atms.dpo.BillDetailDto">
select detail.*
from (select bd.id as id,
bd.billing_body as subject,
bd.customer_company_name as customer,
bd.invoice_type as billType,
bd.billing_content as billContent,
bd.invoice_amount as billAmount,
bd.tax_rate as billTaxRat,
bd.tax_amount as billTaxAmount,
bd.oa_application_num as OANo,
bd.department as department,
bd.billing_date as billDate,
bd.invoice_code as billCode,
bd.invoice_num as billNumber,
modfiy_rc.id as modifyRevenueCofId,
modfiy_rc.name as modifyRevenueCofName,
rc.id as revenueCofId,
rc.name as revenueConfName,
case
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} and rc.end_date >= #{queryDate} THEN 2]]>
end as emptyCode
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 modfiy_rc on modfiy_rc.id = bd.modify_revenue_cof_id
where bd.project_id = #{projectId}
and bd.period = #{period}
<if test="billType != null and billType != ''">
and bd.invoice_type = #{billType}
</if>
<if test="customer != null and customer != ''">
and bd.customer_company_name like concat('%',#{customer},'%')
</if>
<if test="billNumber != null and billNumber != ''">
and bd.invoice_num like concat('%',#{billNumber},'%')
</if>
<if test="revenueCofId != null">
and if(bd.modify_revenue_cof_id is null,bd.revenue_cof_id = #{revenueCofId},bd.modify_revenue_cof_id =
#{revenueCofId})
</if>
<if test="billContent != null and billContent != ''">
and bd.billing_content like concat('%',#{billContent},'%')
</if>
<if test="department != null and department != ''">
and bd.department like concat('%',#{department},'%')
</if>
<if test="billTaxRat != null">
and bd.tax_rate = #{billTaxRat}
</if>
<if test="billDate != null and billDate != ''">
and bd.billing_date = #{billDate}
</if>
) 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
from invoice_record
where project_id = #{projectId}
......@@ -238,4 +243,18 @@
group by invoice_type;
</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>
\ 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