Commit 19a34a92 authored by chase's avatar chase

修复开票收入取值错误

parent 08e321eb
......@@ -6,7 +6,7 @@ import pwc.taxtech.atms.dto.billDetail.BillDetailParam;
import pwc.taxtech.atms.dto.billDetail.BillDetailResult;
import pwc.taxtech.atms.dto.input.CamelPagingResultDto;
import pwc.taxtech.atms.service.impl.BillDetailService;
import pwc.taxtech.atms.vat.entity.BillDetail;
import pwc.taxtech.atms.vat.entity.InvoiceRecord;
import javax.annotation.Resource;
import java.util.List;
......@@ -30,7 +30,7 @@ public class BillDetailController extends BaseController {
return billDetailService.queryBillTypeGroupBy(projectId,period);
}
@PostMapping("update")
public ApiResultDto updateConf(@RequestBody BillDetail billDetail) {
public ApiResultDto updateConf(@RequestBody InvoiceRecord billDetail) {
billDetailService.updateBillDetail(billDetail);
return ApiResultDto.success();
}
......
......@@ -39,6 +39,7 @@ public class BillDetailResult implements Serializable {
private String revenueConfName;
@JsonSerialize(using = PwCIdSerialize.class)
private Long revenueCofId;
private Integer emptyCode;
......
package pwc.taxtech.atms.dto.revenuconf;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import pwc.taxtech.atms.common.util.PwCIdSerialize;
import pwc.taxtech.atms.constant.enums.RevenueConfEnum;
import pwc.taxtech.atms.vat.entity.RevenueConfig;
public class RevenueConfResult extends RevenueConfig {
@JsonSerialize(using = PwCIdSerialize.class)
private Long id;
@Override
public Long getId() {
return id;
}
@Override
public void setId(Long id) {
this.id = id;
}
public String getAccountTypeStr() {
return RevenueConfEnum.AccountType.MAPPING.get(this.getAccountType());
}
......
......@@ -7,8 +7,8 @@ import org.springframework.stereotype.Service;
import pwc.taxtech.atms.dpo.BillDetailDto;
import pwc.taxtech.atms.dto.billDetail.BillDetailParam;
import pwc.taxtech.atms.dto.billDetail.BillDetailResult;
import pwc.taxtech.atms.vat.dao.BillDetailMapper;
import pwc.taxtech.atms.vat.entity.BillDetail;
import pwc.taxtech.atms.vat.dao.InvoiceRecordMapper;
import pwc.taxtech.atms.vat.entity.InvoiceRecord;
import javax.annotation.Resource;
import java.util.List;
......@@ -18,13 +18,13 @@ import java.util.stream.Collectors;
public class BillDetailService extends BaseService {
@Resource
private BillDetailMapper billDetailMapper;
private InvoiceRecordMapper invoiceRecordMapper;
public PageInfo<BillDetailResult> queryPage(BillDetailParam param) {
Page page = PageHelper.startPage(param.getPageInfo().getPageIndex(), param.getPageInfo().getPageSize());
List<BillDetailDto> dataList = billDetailMapper.queryBillWithRevenueConf(param.getBillType(), param.getCustomer(), param.getBillNumber(), param.getRevenueCofId(), param.getBillContent(), param.getDepartment(), param.getBillTaxRat(), param.getBillDate(), param.getProjectId(), param.getPeriod(), param.getQueryDate());
List<BillDetailDto> dataList = invoiceRecordMapper.queryBillWithRevenueConf(param.getBillType(), param.getCustomer(), param.getBillNumber(), param.getRevenueCofId(), param.getBillContent(), param.getDepartment(), param.getBillTaxRat(), param.getBillDate(), param.getProjectId(), param.getPeriod(), param.getQueryDate());
PageInfo<BillDetailResult> pageInfo = new PageInfo<>(dataList.stream()
.map(o -> beanUtil.copyProperties(o, new BillDetailResult())).collect(Collectors.toList()));
pageInfo.setTotal(page.getTotal());
......@@ -32,10 +32,11 @@ public class BillDetailService extends BaseService {
}
public List<String> queryBillTypeGroupBy(String projectId,Integer period){
return billDetailMapper.queryBillTypeGroupBy(projectId,period);
return invoiceRecordMapper.queryBillTypeGroupBy(projectId,period);
}
public void updateBillDetail(BillDetail billDetail) {
billDetailMapper.updateByPrimaryKeySelective(billDetail);
public void updateBillDetail(InvoiceRecord billDetail) {
invoiceRecordMapper.updateByPrimaryKeySelective(billDetail);
}
}
......@@ -124,6 +124,10 @@ public class ReportServiceImpl extends BaseService {
private PeriodApproveMapper periodApprovalMapper;
@Resource
RevenueConfigMapper revenueConfigMapper;
@Resource
RevenueTypeMappingMapper revenueTypeMappingMapper;
@Resource
InvoiceRecordMapper invoiceRecordMapper;
@Autowired
private HttpFileService httpFileService;
@Autowired
......@@ -291,12 +295,47 @@ public class ReportServiceImpl extends BaseService {
private void updateConfig(String projectId, Integer period, Boolean isMergeManualData, List<Template> templates, PeriodJob job) {
List<Long> exceptTemplateIds = templateMapper.getIdsForExceptTemplate();
//根据收入类型映射生成开票记录关联数据
assembleInvoiceRecord(projectId,period);
clearPeriodData(projectId, period, exceptTemplateIds, isMergeManualData);
copyTemplateAndConfigFromAdmin(projectId, templates, period);
setStatus(job, STATUS_END);
periodJobMapper.updateByPrimaryKey(job);
}
public void assembleInvoiceRecord(String projectId,Integer period){
Project project = projectMapper.selectByPrimaryKey(projectId);
MyAsserts.assertNotNull(project, Exceptions.NOT_FOUND_REPORT_EXCEPTION);
String queryDate = project.getYear()+"-"+(period<10?("0"+period):(period+""));
RevenueTypeMappingExample mappingExample = new RevenueTypeMappingExample();
mappingExample.createCriteria().andOrgIdEqualTo(project.getOrganizationId()).
andStartDateLessThanOrEqualTo(queryDate).andEndDateGreaterThanOrEqualTo(queryDate).
andStatusEqualTo(0);
List<RevenueTypeMapping> mappingList = revenueTypeMappingMapper.selectByExample(mappingExample);
Map<String,Long> map = new HashMap<>();
for(RevenueTypeMapping mapping:mappingList){
if(!map.containsKey(mapping.getContent())){
RevenueConfigExample configExample = new RevenueConfigExample();
configExample.createCriteria().andNameEqualTo(mapping.getRevenueTypeName()).
andStatusEqualTo(0).andOrgIdEqualTo(mapping.getOrgId()).
andStartDateLessThanOrEqualTo(queryDate).andEndDateGreaterThanOrEqualTo(queryDate);
List<RevenueConfig> configs = revenueConfigMapper.selectByExample(configExample);
if(CollectionUtils.isNotEmpty(configs)){
map.put(mapping.getContent(),configs.get(0).getId());
}
}
if(map.containsKey(mapping.getContent())){
InvoiceRecord destRecord = new InvoiceRecord();
destRecord.setRevenueCofId(map.get(mapping.getContent()));
InvoiceRecordExample recordExample = new InvoiceRecordExample();
recordExample.createCriteria().andProjectIdEqualTo(projectId)
.andOrganizationIdEqualTo(mapping.getOrgId()).andBillingContentEqualTo(mapping.getContent()).
andPeriodEqualTo(Integer.valueOf(queryDate.replace("-","")));
invoiceRecordMapper.updateByExampleSelective(destRecord,recordExample);
}
}
}
private List<Template> getTemplatesByProjectId(String projectId) {
MyAsserts.assertNotEmpty(projectId, Exceptions.PROJECT_PROJECT_EXCEPTION);
Project project = projectMapper.selectByPrimaryKey(projectId);
......
......@@ -40,6 +40,11 @@
<javaClientGenerator type="XMLMAPPER" targetPackage="pwc.taxtech.atms.vat.dao" targetProject="../../src/main/java">
<property name="rootInterface" value="pwc.taxtech.atms.MyVatMapper" />
</javaClientGenerator>
<table tableName="invoice_record" domainObjectName="InvoiceRecord">
<property name="useActualColumnNames" value="false"/>
<property name="ignoreQualifiersAtRuntime" value="true"/>
</table>
<!--
......@@ -89,11 +94,7 @@
<property name="ignoreQualifiersAtRuntime" value="true"/>
</table>
<table tableName="invoice_record" domainObjectName="InvoiceRecord">
<property name="useActualColumnNames" value="false"/>
<property name="ignoreQualifiersAtRuntime" value="true"/>
</table>
<table tableName="revenue_config" domainObjectName="RevenueConfig">
<property name="useActualColumnNames" value="false"/>
<property name="ignoreQualifiersAtRuntime" value="true"/>
......
package pwc.taxtech.atms.vat.dao;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;
import pwc.taxtech.atms.MyVatMapper;
import pwc.taxtech.atms.vat.dpo.CashFlowCondition;
import pwc.taxtech.atms.dpo.BillDetailDto;
import pwc.taxtech.atms.vat.dpo.InvoiceRecordCondition;
import pwc.taxtech.atms.vat.entity.CashFlow;
import pwc.taxtech.atms.vat.entity.InvoiceRecord;
import pwc.taxtech.atms.vat.entity.InvoiceRecordExample;
import java.math.BigDecimal;
import java.util.List;
@Mapper
public interface InvoiceRecordMapper extends MyVatMapper {
/**
......@@ -113,4 +114,19 @@ public interface InvoiceRecordMapper extends MyVatMapper {
int insertBatch(List<InvoiceRecord> cils);
List<BillDetailDto> queryBillWithRevenueConf(
@Param("billType") String billType,
@Param("customer") String customer,
@Param("billNumber") String billNumber,
@Param("revenueCofId") Long revenueCofId,
@Param("billContent") String billContent,
@Param("department") String department,
@Param("billTaxRat") BigDecimal billTaxRat,
@Param("billDate") String billDate,
@Param("projectId") String projectId,
@Param("period") Integer period,
@Param("queryDate") String queryDate);
List<String> queryBillTypeGroupBy(@Param("projectId") String projectId,
@Param("period") Integer period);
}
\ No newline at end of file
package pwc.taxtech.atms.vat.entity;
import pwc.taxtech.atms.entity.BaseEntity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import pwc.taxtech.atms.entity.BaseEntity;
/**
*
......@@ -354,6 +355,17 @@ public class InvoiceRecord extends BaseEntity implements Serializable {
*/
private Date updateTime;
/**
* Database Column Remarks:
* 收入类型id
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column invoice_record.revenue_cof_id
*
* @mbg.generated
*/
private Long revenueCofId;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table invoice_record
......@@ -1106,6 +1118,30 @@ public class InvoiceRecord extends BaseEntity implements Serializable {
this.updateTime = updateTime;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column invoice_record.revenue_cof_id
*
* @return the value of invoice_record.revenue_cof_id
*
* @mbg.generated
*/
public Long getRevenueCofId() {
return revenueCofId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column invoice_record.revenue_cof_id
*
* @param revenueCofId the value for invoice_record.revenue_cof_id
*
* @mbg.generated
*/
public void setRevenueCofId(Long revenueCofId) {
this.revenueCofId = revenueCofId;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table invoice_record
......@@ -1149,6 +1185,7 @@ public class InvoiceRecord extends BaseEntity implements Serializable {
sb.append(", remarks=").append(remarks);
sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime);
sb.append(", revenueCofId=").append(revenueCofId);
sb.append("]");
return sb.toString();
}
......
......@@ -2225,6 +2225,66 @@ public class InvoiceRecordExample {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andRevenueCofIdIsNull() {
addCriterion("revenue_cof_id is null");
return (Criteria) this;
}
public Criteria andRevenueCofIdIsNotNull() {
addCriterion("revenue_cof_id is not null");
return (Criteria) this;
}
public Criteria andRevenueCofIdEqualTo(Long value) {
addCriterion("revenue_cof_id =", value, "revenueCofId");
return (Criteria) this;
}
public Criteria andRevenueCofIdNotEqualTo(Long value) {
addCriterion("revenue_cof_id <>", value, "revenueCofId");
return (Criteria) this;
}
public Criteria andRevenueCofIdGreaterThan(Long value) {
addCriterion("revenue_cof_id >", value, "revenueCofId");
return (Criteria) this;
}
public Criteria andRevenueCofIdGreaterThanOrEqualTo(Long value) {
addCriterion("revenue_cof_id >=", value, "revenueCofId");
return (Criteria) this;
}
public Criteria andRevenueCofIdLessThan(Long value) {
addCriterion("revenue_cof_id <", value, "revenueCofId");
return (Criteria) this;
}
public Criteria andRevenueCofIdLessThanOrEqualTo(Long value) {
addCriterion("revenue_cof_id <=", value, "revenueCofId");
return (Criteria) this;
}
public Criteria andRevenueCofIdIn(List<Long> values) {
addCriterion("revenue_cof_id in", values, "revenueCofId");
return (Criteria) this;
}
public Criteria andRevenueCofIdNotIn(List<Long> values) {
addCriterion("revenue_cof_id not in", values, "revenueCofId");
return (Criteria) this;
}
public Criteria andRevenueCofIdBetween(Long value1, Long value2) {
addCriterion("revenue_cof_id between", value1, value2, "revenueCofId");
return (Criteria) this;
}
public Criteria andRevenueCofIdNotBetween(Long value1, Long value2) {
addCriterion("revenue_cof_id not between", value1, value2, "revenueCofId");
return (Criteria) this;
}
}
/**
......
......@@ -37,6 +37,7 @@
<result column="remarks" jdbcType="VARCHAR" property="remarks" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="revenue_cof_id" jdbcType="BIGINT" property="revenueCofId" />
</resultMap>
<sql id="Example_Where_Clause">
<!--
......@@ -114,7 +115,7 @@
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
update_time, revenue_cof_id
</sql>
<select id="selectByExample" parameterType="pwc.taxtech.atms.vat.entity.InvoiceRecordExample" resultMap="BaseResultMap">
<!--
......@@ -177,7 +178,7 @@
invoice_num, invoices_amount, customer_company_tax_num,
contract_source_system, tax_rate, tax_amount,
invoice_status, remarks, create_time,
update_time)
update_time, revenue_cof_id)
values (#{id,jdbcType=BIGINT}, #{organizationId,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR},
#{tmsPeriod,jdbcType=INTEGER}, #{period,jdbcType=INTEGER}, #{seqNo,jdbcType=INTEGER},
#{source,jdbcType=VARCHAR}, #{billingBody,jdbcType=VARCHAR}, #{customerCompanyName,jdbcType=VARCHAR},
......@@ -188,7 +189,7 @@
#{invoiceNum,jdbcType=VARCHAR}, #{invoicesAmount,jdbcType=INTEGER}, #{customerCompanyTaxNum,jdbcType=VARCHAR},
#{contractSourceSystem,jdbcType=VARCHAR}, #{taxRate,jdbcType=DECIMAL}, #{taxAmount,jdbcType=DECIMAL},
#{invoiceStatus,jdbcType=VARCHAR}, #{remarks,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP})
#{updateTime,jdbcType=TIMESTAMP}, #{revenueCofId,jdbcType=BIGINT})
</insert>
<insert id="insertSelective" parameterType="pwc.taxtech.atms.vat.entity.InvoiceRecord">
<!--
......@@ -290,6 +291,9 @@
<if test="updateTime != null">
update_time,
</if>
<if test="revenueCofId != null">
revenue_cof_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
......@@ -385,6 +389,9 @@
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="revenueCofId != null">
#{revenueCofId,jdbcType=BIGINT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="pwc.taxtech.atms.vat.entity.InvoiceRecordExample" resultType="java.lang.Long">
......@@ -497,6 +504,9 @@
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
<if test="record.revenueCofId != null">
revenue_cof_id = #{record.revenueCofId,jdbcType=BIGINT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
......@@ -538,7 +548,8 @@
invoice_status = #{record.invoiceStatus,jdbcType=VARCHAR},
remarks = #{record.remarks,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP}
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
revenue_cof_id = #{record.revenueCofId,jdbcType=BIGINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
......@@ -640,6 +651,9 @@
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="revenueCofId != null">
revenue_cof_id = #{revenueCofId,jdbcType=BIGINT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
......@@ -678,7 +692,8 @@
invoice_status = #{invoiceStatus,jdbcType=VARCHAR},
remarks = #{remarks,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
update_time = #{updateTime,jdbcType=TIMESTAMP},
revenue_cof_id = #{revenueCofId,jdbcType=BIGINT}
where id = #{id,jdbcType=BIGINT}
</update>
<select id="selectByExampleWithRowbounds" parameterType="pwc.taxtech.atms.vat.entity.InvoiceRecordExample" resultMap="BaseResultMap">
......
......@@ -65,6 +65,6 @@
and period = #{period}
group by bill_type;
</select>
</select>
</mapper>
\ No newline at end of file
......@@ -165,4 +165,69 @@
</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,
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
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 bd.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 id="queryBillTypeGroupBy" resultType="java.lang.String">
select invoice_type
from invoice_record
where project_id = #{projectId}
and period = #{period}
group by invoice_type;
</select>
</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