Commit 68eb9555 authored by zhkwei's avatar zhkwei

CIT数据处理一些数据的前置准备,数据导入数据预览bug的修改

parent 08fc627f
......@@ -22,6 +22,7 @@ import static javax.servlet.http.HttpServletResponse.SC_NO_CONTENT;
import static javax.servlet.http.HttpServletResponse.SC_OK;
/**
* CIT数据预览功能模块Controller
* @author zhikai.z.wei
*/
@RestController
......@@ -31,12 +32,22 @@ public class CitDataPreviewController extends BaseController {
@Autowired
private CitDataPreviewServiceImpl citDataPreviewService;
/**
* 日记账合并版数据的获取
* @param citJournalAdjustDto
* @return
*/
@PostMapping("getJournalMergeData")
public PageInfo<CitJournalAdjustDto> getJournalMergeData(@RequestBody CitJournalAdjustDto citJournalAdjustDto) {
logger.debug(String.format("CIT日记账合并预览 Condition:%s", JSON.toJSONString(citJournalAdjustDto)));
return citDataPreviewService.getJournalMergeData(citJournalAdjustDto);
}
/**
* 日记账合并版导出
* @param paras
* @param response
*/
@RequestMapping(value = "exportJournalMergeData", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public void exportJournalMergeData(@RequestBody CitJournalAdjustDto paras, HttpServletResponse response) {
int count = citDataPreviewService.exportJournalMergeData2(paras, response);
......@@ -48,13 +59,22 @@ public class CitDataPreviewController extends BaseController {
}
/**
* 试算平衡表生成版的数据获取
* @param citTrialBalanceDto
* @return
*/
@PostMapping("getTbGeneVerData")
public PageInfo<CitTrialBalanceDto> getTbGeneVerData(@RequestBody CitTrialBalanceDto citTrialBalanceDto) {
logger.debug(String.format("CIT日记账合并预览 Condition:%s", JSON.toJSONString(citTrialBalanceDto)));
return citDataPreviewService.getTbGeneVerData(citTrialBalanceDto);
}
/**
* 试算平衡表生成版的导出
* @param paras
* @param response
*/
@RequestMapping(value = "exportTbGeneVerData", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public void exportTbGeneVerData(@RequestBody CitTrialBalanceDto paras, HttpServletResponse response) {
// response.setContentType("application/vnd.ms-excel;charset=utf-8");
......@@ -86,13 +106,23 @@ public class CitDataPreviewController extends BaseController {
}
}
/**
* 试算平衡表Mapping版的数据获取
* @param citTrialBalanceDto
* @return
*/
@PostMapping("getTbMappingVerData")
public PageInfo<CitTrialBalanceDto> getTbMappingVerData(@RequestBody CitTrialBalanceDto citTrialBalanceDto) {
logger.debug(String.format("CIT日记账合并预览 Condition:%s", JSON.toJSONString(citTrialBalanceDto)));
logger.debug(String.format("CIT算平衡表Mapping版 Condition:%s", JSON.toJSONString(citTrialBalanceDto)));
return citDataPreviewService.getTbMappingVerData(citTrialBalanceDto);
}
/**
* 试算平衡表Mapping版的导出
* @param paras
* @param response
*/
@RequestMapping(value = "exportTbMappingVerData", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public void exportTbMappingVerData(@RequestBody CitTrialBalanceDto paras, HttpServletResponse response) {
int count = citDataPreviewService.exportTbMappingVerData2(paras, response);
......
......@@ -17,7 +17,7 @@ import java.util.List;
import static pwc.taxtech.atms.constant.enums.EnumCitImportType.JournalAdjust;
/**
* @Description 资产相关Controller
* @Description CIT文件导入Controller
* @Author zhikai.z.wei
*/
@RestController
......@@ -28,14 +28,22 @@ public class CitImportExcelController {
@Autowired
private CitImportExcelServiceImpl citImportExcelService;
/**
* CIT文件导入
* @param file
* @param orgIds
* @param periodDate
* @param importType
* @param importFileType
* @return
*/
@RequestMapping(value = "/citImportExcel", method = RequestMethod.POST)
public @ResponseBody
OperationResultDto citImportExcel(@RequestParam MultipartFile file, @RequestParam(required = false) String orgIds,
@RequestParam String periodDate,
@RequestParam Integer importType,
@RequestParam Integer importFileType){
logger.info("CIT调整版日记账导入");
logger.info("CIT文件导入");
OperationResultDto opeResultDto = new OperationResultDto();
try{
if (file == null || file.getSize() <= 0) {
......
......@@ -41,6 +41,7 @@ import java.util.List;
import java.util.Map;
/**
* CIT数据预览功能模块
* @author zhikai.z.wei
* @Date: 02/03/2019
* @Description:
......@@ -76,7 +77,7 @@ public class CitDataPreviewServiceImpl extends BaseService {
}
/**
* 日记账导出
* 日记账导出(第一种方式)
* @param citJournalAdjustDto
* @param os
* @return
......@@ -101,6 +102,12 @@ public class CitDataPreviewServiceImpl extends BaseService {
}
}
/**
* 日记账导出(第二种方式)
* @param citJournalAdjustDto
* @param response
* @return
*/
public int exportJournalMergeData2(CitJournalAdjustDto citJournalAdjustDto, HttpServletResponse response){
CitJournalEntryAdjust citJournalEntryAdjust = beanUtil.copyProperties(citJournalAdjustDto, new CitJournalEntryAdjust());
List<CitJournalEntryAdjust> journalMerges = citJournalMapper.getJournalMerge(citJournalEntryAdjust);
......@@ -117,6 +124,10 @@ public class CitDataPreviewServiceImpl extends BaseService {
return 1;
}
/**
* 日记账导出(第一种方式)所用到的获取Excel表头
* @return
*/
private Map<String, String> generalJMHeader() {
Map<String, String> header = new LinkedHashMap<>();
header.put("ApprovalStatus","审批状态");
......@@ -169,7 +180,7 @@ public class CitDataPreviewServiceImpl extends BaseService {
}
/**
* 试算平衡表生成版的导出
* 试算平衡表生成版的导出(第一种方式)
* @param citTrialBalanceDto
* @param os
* @return
......@@ -220,6 +231,10 @@ public class CitDataPreviewServiceImpl extends BaseService {
return 1;
}
/**
* 试算平衡表生成版的导出(第一种方式)所用到的生成Excel的表头
* @return
*/
private Map<String, String> generalTbGeneVerHeader() {
Map<String, String> header = new LinkedHashMap<>();
header.put("AccountCode","科目代码");
......@@ -255,7 +270,7 @@ public class CitDataPreviewServiceImpl extends BaseService {
}
/**
* 试算平衡表Mapping版的导出
* 试算平衡表Mapping版的导出(第一种方式)
* @param citTrialBalanceDto
* @param os
* @return
......
......@@ -64,6 +64,9 @@ public class CitImportExcelServiceImpl extends BaseService {
@Resource
private ProjectMapper projectMapper;
@Resource
private CitTbamMapper citTbamMapper;
/**
* 根据导入的文件类型进行方法分发
*
......@@ -284,11 +287,19 @@ public class CitImportExcelServiceImpl extends BaseService {
if (EnumTbImportType.CoverImport.getCode().equals(importType)) {
//覆盖导入要删除原有的该操作人在当前期间导入的数据,且更改之前导入的日志记录状态
msg = "覆盖导入成功";
CitJournalEntryAdjustExample example = new CitJournalEntryAdjustExample();
CitJournalEntryAdjustExample.Criteria criteria = example.createCriteria();
criteria.andCreatedByEqualTo(currentUserName);
criteria.andPeriodEqualTo(period);
citJournalEntryAdjustMapper.deleteByExample(example);
CitJournalEntryAdjustExample citJEAExample = new CitJournalEntryAdjustExample();
citJEAExample.createCriteria().andCreatedByEqualTo(currentUserName).andPeriodEqualTo(period).andOrganizationIdIn(orgList);
logger.info("删除符合条件的日记账");
citJournalEntryAdjustMapper.deleteByExample(citJEAExample);
//删除自动生成的试算平衡表相关数据
CitTrialBalanceExample citTbExample = new CitTrialBalanceExample();
citTbExample.createCriteria().andPeriodEqualTo(period).andCreateByEqualTo(currentUserName).andOrganizationIdIn(orgList);
int deleteByExample = citTrialBalanceMapper.deleteByExample(citTbExample);
logger.info("删除符合条件的试算平衡表数据");
CitTbamExample citTbamExample = new CitTbamExample();
citTbamExample.createCriteria().andPeriodEqualTo(period).andCreateByEqualTo(currentUserName).andOrganizationIdIn(orgList);
logger.info("删除符合条件的试算平衡表Mapping数据");
citTbamMapper.deleteByExample(citTbamExample);
updateImportLog(EnumCitImportType.JournalAdjust.getCode());
}
int insertBatchNum = citJournalEntryAdjustMapper.insertBatch(journalAdjustList);
......@@ -299,7 +310,9 @@ public class CitImportExcelServiceImpl extends BaseService {
citDataImportLog.setErrorMsg(msg);
citDataImportLogList.add(citDataImportLog);
//导入日志录入到数据库
addDataImportLog(citDataImportLogList);
//根据日记账自动生成试算平衡表,即试算平衡表生成版
autoGeneTB(period, orgId, orgList);
saveResult.setResult(true);
saveResult.setResultMsg("导入成功");
......@@ -518,7 +531,8 @@ public class CitImportExcelServiceImpl extends BaseService {
continue;
}
DecimalFormat df=new DecimalFormat("0");
citDAMapping.setAcctCode(df.format(cellValue));
// String s = cellValue.toString();
citDAMapping.setAcctCode(cellValue.toString());
cellValue = CitCommonUtil.getValue(rowData.getCell(6));
if(cellValue == null){
......@@ -1203,7 +1217,7 @@ public class CitImportExcelServiceImpl extends BaseService {
}
/**
* 自动生成试算平衡表
* 自动生成试算平衡表和join出Mapping版的attribute mapping TB
* @param period
* @param orgList
* @return
......@@ -1215,14 +1229,17 @@ public class CitImportExcelServiceImpl extends BaseService {
StringBuilder periodSb = new StringBuilder();
periodSb.append(period);
periodSb.append("%");
//第二步,查出cit_journal_entry_adjust该期间的调整日记账,
List<CitJournalEntryAdjust> citJournalEntryAdjustList = citJournalEntryAdjustMapper.sumAmountByCondition(periodSb.toString(), orgList);
//第二步,查出cit_journal_entry_adjust该期间的调整日记账,
List<CitTrialBalance> trialBalanceList = new ArrayList<>();
//存放TB与Mapping结合的实体
List<CitTbam> citTbamList = new ArrayList<>();
String currentUserName = authUserHelper.getCurrentAuditor().get();
for (CitJournalEntryAdjust citJournal:citJournalEntryAdjustList) {
CitTrialBalance trialBalance = new CitTrialBalance();
trialBalance.setId(idService.nextId());
trialBalance.setPeriod(period);
trialBalance.setCreateBy(currentUserName);
trialBalance.setOrganizationId(orgId);
......@@ -1249,10 +1266,33 @@ public class CitImportExcelServiceImpl extends BaseService {
//计算出期末余额,期末余额为期初余额+借方发生额-贷方发生额
trialBalance.setEndingBalance(lastYearBegBla.add(citJournal.getAccountedDr()).subtract(citJournal.getAccountedCr()));
//根据科目代码及期间查询出相应底稿&科目Mapping数据并赋值给实体CitTBam
CitDraftAccountMappingExample citDAMappingExample = new CitDraftAccountMappingExample();
citDAMappingExample.createCriteria().andAcctCodeEqualTo(citJournal.getSubjectCode()).andPeriodEqualTo(period);
List<CitDraftAccountMapping> citDraftAccountMappings = citDAMappingMapper.selectByExample(citDAMappingExample);
for (CitDraftAccountMapping daMapping : citDraftAccountMappings) {
CitTbam citTbam = new CitTbam();
//把根据日记账算出的TB数据复制到Mapping的TB
beanUtil.copyProperties(trialBalance,citTbam);
citTbam.setId(idService.nextId());
citTbam.setAttribute(daMapping.getAttribute());
citTbamList.add(citTbam);
}
// citDraftAccountMappings.stream().forEach(daMapping -> {
// citTbam.setId(idService.nextId());
// citTbam.setAttribute(daMapping.getAttribute());
// citTbamList.add(citTbam);
// if("70019900".equals(citTbam.getAccountCode())){
// System.out.println(citTbam.getId());
// }
// });
trialBalance.setId(idService.nextId());
trialBalanceList.add(trialBalance);
}
int insertBatch = citTrialBalanceMapper.insertBatch(trialBalanceList);
int insertBatch1 = citTbamMapper.insertBatch(citTbamList);
autoGeneResult.setResult(true);
autoGeneResult.setResultMsg("自动生成TB成功");
return autoGeneResult;
......
package pwc.taxtech.atms.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.MyMapper;
import pwc.taxtech.atms.entity.CitTbam;
import pwc.taxtech.atms.entity.CitTbamExample;
@Mapper
public interface CitTbamMapper extends MyMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table cit_tbam
*
* @mbg.generated
*/
long countByExample(CitTbamExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table cit_tbam
*
* @mbg.generated
*/
int deleteByExample(CitTbamExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table cit_tbam
*
* @mbg.generated
*/
int deleteByPrimaryKey(Long id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table cit_tbam
*
* @mbg.generated
*/
int insert(CitTbam record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table cit_tbam
*
* @mbg.generated
*/
int insertSelective(CitTbam record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table cit_tbam
*
* @mbg.generated
*/
List<CitTbam> selectByExampleWithRowbounds(CitTbamExample example, RowBounds rowBounds);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table cit_tbam
*
* @mbg.generated
*/
List<CitTbam> selectByExample(CitTbamExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table cit_tbam
*
* @mbg.generated
*/
CitTbam selectByPrimaryKey(Long id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table cit_tbam
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") CitTbam record, @Param("example") CitTbamExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table cit_tbam
*
* @mbg.generated
*/
int updateByExample(@Param("record") CitTbam record, @Param("example") CitTbamExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table cit_tbam
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(CitTbam record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table cit_tbam
*
* @mbg.generated
*/
int updateByPrimaryKey(CitTbam record);
/**
* 批量插入数据
* @author zhikai.z.wei
* @param citTbamList
* @return
*/
int insertBatch(List<CitTbam> citTbamList);
}
\ No newline at end of file
This diff is collapsed.
<?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="pwc.taxtech.atms.dao.CitTbamMapper">
<insert id="insertBatch" parameterType="java.util.List">
insert into cit_tbam
(<include refid="Base_Column_List"/>)
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.date != null">#{item.date,jdbcType=TIMESTAMP},</when>
<otherwise>CURRENT_TIMESTAMP,</otherwise>
</choose>
<choose>
<when test="item.source != null">#{item.source,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.period != null">#{item.period,jdbcType=INTEGER},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.accountPeriod != null">#{item.accountPeriod,jdbcType=INTEGER},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.attribute != null">#{item.attribute,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.accountCode != null">#{item.accountCode,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.accountDescription != null">#{item.accountDescription,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.debitAmount != null">#{item.debitAmount,jdbcType=DECIMAL},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.creditAmount != null">#{item.creditAmount,jdbcType=DECIMAL},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.beginningBalance != null">#{item.beginningBalance,jdbcType=DECIMAL},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.endingBalance != null">#{item.endingBalance,jdbcType=DECIMAL},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.createBy != null">#{item.createBy,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>
</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