Commit 2d9565ed authored by chase's avatar chase

fix bug

parent 1a9c6c4b
...@@ -6,13 +6,10 @@ import com.github.pagehelper.PageHelper; ...@@ -6,13 +6,10 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.grapecity.documents.excel.V;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.map.HashedMap; import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
...@@ -59,7 +56,6 @@ import javax.servlet.http.HttpServletRequest; ...@@ -59,7 +56,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.BlockingQueue; import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
...@@ -335,7 +331,11 @@ public class ReportServiceImpl extends BaseService { ...@@ -335,7 +331,11 @@ public class ReportServiceImpl extends BaseService {
TrialBalanceFinalExample example = new TrialBalanceFinalExample(); TrialBalanceFinalExample example = new TrialBalanceFinalExample();
example.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(Integer.valueOf(queryPeriod)); example.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(Integer.valueOf(queryPeriod));
trialBalanceFinalMapper.deleteByExample(example); trialBalanceFinalMapper.deleteByExample(example);
trialBalanceFinalMapper.generateFinalData(projectId, Integer.valueOf(queryPeriod), lastProject == null ? "0" : lastProject.getId(), Integer.valueOf(lastPeriod)); List<TrialBalanceFinal> dataList = trialBalanceFinalMapper.queryGenerateFinalData(projectId, Integer.valueOf(queryPeriod), lastProject == null ? "0" : lastProject.getId(), Integer.valueOf(lastPeriod));
if (!CollectionUtils.isEmpty(dataList)) {
List<List<TrialBalanceFinal>> batchList = CommonUtils.subListWithLen(dataList, CommonUtils.BATCH_NUM_2000);
batchList.forEach(l -> trialBalanceFinalMapper.batchInsert(l));
}
} }
public void assembleInvoiceRecord(String projectId, Integer period, Boolean isMergeManualData) { public void assembleInvoiceRecord(String projectId, Integer period, Boolean isMergeManualData) {
......
...@@ -122,8 +122,10 @@ public interface TrialBalanceFinalMapper extends MyVatMapper { ...@@ -122,8 +122,10 @@ public interface TrialBalanceFinalMapper extends MyVatMapper {
@Param("period") Integer period, @Param("period") Integer period,
@Param("queryDate") String queryDate); @Param("queryDate") String queryDate);
int generateFinalData(@Param("projectId") String projectId, List<TrialBalanceFinal> queryGenerateFinalData(@Param("projectId") String projectId,
@Param("period") Integer period, @Param("period") Integer period,
@Param("lastProjectId") String lastProjectId, @Param("lastProjectId") String lastProjectId,
@Param("lastPeriod") Integer lastPeriod); @Param("lastPeriod") Integer lastPeriod);
int batchInsert(List<TrialBalanceFinal> list);
} }
\ No newline at end of file
...@@ -74,10 +74,9 @@ ...@@ -74,10 +74,9 @@
order by detail.emptyCode order by detail.emptyCode
</select> </select>
<insert id="generateFinalData" > <select id="queryGenerateFinalData" resultMap="BaseResultMap">
insert select
into trial_balance_final balance.id,
select balance.id,
balance.organization_id, balance.organization_id,
balance.project_id, balance.project_id,
balance.date, balance.date,
...@@ -124,11 +123,11 @@ select balance.id, ...@@ -124,11 +123,11 @@ select balance.id,
balance.ytd_cr, balance.ytd_cr,
balance.beg_bal_beq, balance.beg_bal_beq,
balance.period_dr_beq + if(adjustment.period_dr_beq is null, 0, adjustment.period_dr_beq) - balance.period_dr_beq + if(adjustment.period_dr_beq is null, 0, adjustment.period_dr_beq) -
if(last_adjustment.period_dr_beq is null, 0, last_adjustment.period_dr_beq), if(last_adjustment.period_dr_beq is null, 0, last_adjustment.period_dr_beq) as period_dr_beq,
balance.period_cr_beq + if(adjustment.period_cr_beq is null, 0, adjustment.period_cr_beq) - balance.period_cr_beq + if(adjustment.period_cr_beq is null, 0, adjustment.period_cr_beq) -
if(last_adjustment.period_cr_beq is null, 0, last_adjustment.period_cr_beq), if(last_adjustment.period_cr_beq is null, 0, last_adjustment.period_cr_beq) as period_cr_beq,
balance.end_bal_beq + if(adjustment.end_bal_beq is null, 0, adjustment.end_bal_beq) - balance.end_bal_beq + if(adjustment.end_bal_beq is null, 0, adjustment.end_bal_beq) -
if(last_adjustment.end_bal_beq is null, 0, last_adjustment.end_bal_beq), if(last_adjustment.end_bal_beq is null, 0, last_adjustment.end_bal_beq) as end_bal_beq,
balance.qtd_dr_beq, balance.qtd_dr_beq,
balance.qtd_cr_beq, balance.qtd_cr_beq,
balance.ytd_dr_beq, balance.ytd_dr_beq,
...@@ -194,5 +193,87 @@ where balance.project_id = #{projectId} ...@@ -194,5 +193,87 @@ where balance.project_id = #{projectId}
</insert> </select>
<insert id="batchInsert">
insert into trial_balance_final
(id, organization_id, project_id,
`date`, `source`, tms_period,
period, ledger_id, ledger_name,
currency_code, `status`, category,
account_category, acct_code1, acct_name1,
acct_name2, acct_name3, segment1,
segment2, segment3, segment4,
segment5, segment6, segment7,
segment8, segment9, segment10,
segment1_name, segment2_name, segment3_name,
segment4_name, segment5_name, segment6_name,
segment7_name, segment8_name, segment9_name,
segment10_name, beg_bal, period_dr,
period_cr, end_bal, qtd_dr,
qtd_cr, ytd_dr, ytd_cr,
beg_bal_beq, period_dr_beq, period_cr_beq,
end_bal_beq, qtd_dr_beq, qtd_cr_beq,
ytd_dr_beq, ytd_cr_beq, create_time,
update_time)
values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.id,jdbcType=BIGINT},
#{item.organizationId,jdbcType=VARCHAR},
#{item.projectId,jdbcType=VARCHAR},
#{item.date,jdbcType=TIMESTAMP},
#{item.source,jdbcType=VARCHAR},
#{item.tmsPeriod,jdbcType=INTEGER},
#{item.period,jdbcType=INTEGER},
#{item.ledgerId,jdbcType=VARCHAR},
#{item.ledgerName,jdbcType=VARCHAR},
#{item.currencyCode,jdbcType=VARCHAR},
#{item.status,jdbcType=VARCHAR},
#{item.category,jdbcType=VARCHAR},
#{item.accountCategory,jdbcType=VARCHAR},
#{item.acctCode1,jdbcType=VARCHAR},
#{item.acctName1,jdbcType=VARCHAR},
#{item.acctName2,jdbcType=VARCHAR},
#{item.acctName3,jdbcType=VARCHAR},
#{item.segment1,jdbcType=VARCHAR},
#{item.segment2,jdbcType=VARCHAR},
#{item.segment3,jdbcType=VARCHAR},
#{item.segment4,jdbcType=VARCHAR},
#{item.segment5,jdbcType=VARCHAR},
#{item.segment6,jdbcType=VARCHAR},
#{item.segment7,jdbcType=VARCHAR},
#{item.segment8,jdbcType=VARCHAR},
#{item.segment9,jdbcType=VARCHAR},
#{item.segment10,jdbcType=VARCHAR},
#{item.segment1Name,jdbcType=VARCHAR},
#{item.segment2Name,jdbcType=VARCHAR},
#{item.segment3Name,jdbcType=VARCHAR},
#{item.segment4Name,jdbcType=VARCHAR},
#{item.segment5Name,jdbcType=VARCHAR},
#{item.segment6Name,jdbcType=VARCHAR},
#{item.segment7Name,jdbcType=VARCHAR},
#{item.segment8Name,jdbcType=VARCHAR},
#{item.segment9Name,jdbcType=VARCHAR},
#{item.segment10Name,jdbcType=VARCHAR},
#{item.begBal,jdbcType=DECIMAL},
#{item.periodDr,jdbcType=DECIMAL},
#{item.periodCr,jdbcType=DECIMAL},
#{item.endBal,jdbcType=DECIMAL},
#{item.qtdDr,jdbcType=DECIMAL},
#{item.qtdCr,jdbcType=DECIMAL},
#{item.ytdDr,jdbcType=DECIMAL},
#{item.ytdCr,jdbcType=DECIMAL},
#{item.begBalBeq,jdbcType=DECIMAL},
#{item.periodDrBeq,jdbcType=DECIMAL},
#{item.periodCrBeq,jdbcType=DECIMAL},
#{item.endBalBeq,jdbcType=DECIMAL},
#{item.qtdDrBeq,jdbcType=DECIMAL},
#{item.qtdCrBeq,jdbcType=DECIMAL},
#{item.ytdDrBeq,jdbcType=DECIMAL},
#{item.ytdCrBeq,jdbcType=DECIMAL},
#{item.createTime,jdbcType=TIMESTAMP},
#{item.updateTime,jdbcType=TIMESTAMP}
)
</foreach>
</insert>
</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