Commit fd95a467 authored by zhkwei's avatar zhkwei

CIT--Excel导入完善及bug修改

parent 7db8502a
...@@ -152,6 +152,14 @@ public class CitImportExcelServiceImpl extends BaseService { ...@@ -152,6 +152,14 @@ public class CitImportExcelServiceImpl extends BaseService {
String companyName = CitCommonUtil.getValue(sheet.getRow(1).getCell(19)).toString(); String companyName = CitCommonUtil.getValue(sheet.getRow(1).getCell(19)).toString();
String companyCode = CitCommonUtil.getValue(sheet.getRow(1).getCell(9)).toString(); String companyCode = CitCommonUtil.getValue(sheet.getRow(1).getCell(9)).toString();
if(companyCode == null){
saveResult.setResult(false);
saveResult.setResultMsg(ErrorMessageCN.NoCompanyError);
return saveResult;
}
companyCode = companyCode.contains(".")?companyCode.substring(0,companyCode.indexOf(".")):companyCode;
//根据code(主体)获取机构相关信息 //根据code(主体)获取机构相关信息
List<Organization> organizations = getOrganizationByCode(companyCode); List<Organization> organizations = getOrganizationByCode(companyCode);
String orgId = ""; String orgId = "";
...@@ -295,16 +303,16 @@ public class CitImportExcelServiceImpl extends BaseService { ...@@ -295,16 +303,16 @@ public class CitImportExcelServiceImpl extends BaseService {
//覆盖导入要删除原有的该操作人在当前期间导入的数据,且更改之前导入的日志记录状态 //覆盖导入要删除原有的该操作人在当前期间导入的数据,且更改之前导入的日志记录状态
msg = "覆盖导入成功"; msg = "覆盖导入成功";
CitJournalEntryAdjustExample citJEAExample = new CitJournalEntryAdjustExample(); CitJournalEntryAdjustExample citJEAExample = new CitJournalEntryAdjustExample();
citJEAExample.createCriteria().andCreatedByEqualTo(currentUserName).andPeriodEqualTo(period).andOrganizationIdIn(orgList); citJEAExample.createCriteria().andCreatedByEqualTo(currentUserName).andPeriodEqualTo(period).andProjectIdEqualTo(projectId);
logger.info("删除符合条件的日记账"); logger.info("删除符合条件的日记账");
citJournalEntryAdjustMapper.deleteByExample(citJEAExample); citJournalEntryAdjustMapper.deleteByExample(citJEAExample);
//删除自动生成的试算平衡表相关数据 //删除自动生成的试算平衡表相关数据
CitTrialBalanceExample citTbExample = new CitTrialBalanceExample(); CitTrialBalanceExample citTbExample = new CitTrialBalanceExample();
citTbExample.createCriteria().andPeriodEqualTo(period).andCreateByEqualTo(currentUserName).andOrganizationIdIn(orgList); citTbExample.createCriteria().andPeriodEqualTo(period).andCreateByEqualTo(currentUserName).andProjectIdEqualTo(projectId);
int deleteByExample = citTrialBalanceMapper.deleteByExample(citTbExample); int deleteByExample = citTrialBalanceMapper.deleteByExample(citTbExample);
logger.info("删除符合条件的试算平衡表数据"); logger.info("删除符合条件的试算平衡表数据");
CitTbamExample citTbamExample = new CitTbamExample(); CitTbamExample citTbamExample = new CitTbamExample();
citTbamExample.createCriteria().andPeriodEqualTo(period).andCreateByEqualTo(currentUserName).andOrganizationIdIn(orgList); citTbamExample.createCriteria().andPeriodEqualTo(period).andCreateByEqualTo(currentUserName).andProjectIdEqualTo(projectId);
logger.info("删除符合条件的试算平衡表Mapping数据"); logger.info("删除符合条件的试算平衡表Mapping数据");
citTbamMapper.deleteByExample(citTbamExample); citTbamMapper.deleteByExample(citTbamExample);
updateImportLog(EnumCitImportType.JournalAdjust.getCode()); updateImportLog(EnumCitImportType.JournalAdjust.getCode());
...@@ -320,7 +328,7 @@ public class CitImportExcelServiceImpl extends BaseService { ...@@ -320,7 +328,7 @@ public class CitImportExcelServiceImpl extends BaseService {
//导入日志录入到数据库 //导入日志录入到数据库
addDataImportLog(citDataImportLogList); addDataImportLog(citDataImportLogList);
//根据日记账自动生成试算平衡表,即试算平衡表生成版 //根据日记账自动生成试算平衡表,即试算平衡表生成版
autoGeneTB(period, orgId, orgList); autoGeneTB(period, orgId, orgList,projectId);
saveResult.setResult(true); saveResult.setResult(true);
saveResult.setResultMsg("导入成功"); saveResult.setResultMsg("导入成功");
return saveResult; return saveResult;
...@@ -362,6 +370,7 @@ public class CitImportExcelServiceImpl extends BaseService { ...@@ -362,6 +370,7 @@ public class CitImportExcelServiceImpl extends BaseService {
Map<String, Integer> companyFailMap = new HashMap(); Map<String, Integer> companyFailMap = new HashMap();
Map<String, Integer> noCompanyMap = new HashMap(); Map<String, Integer> noCompanyMap = new HashMap();
Map<String,Integer> noProjectMap = new HashMap<>(); Map<String,Integer> noProjectMap = new HashMap<>();
List<String> projectIdList = new ArrayList<>();
String currentUserName = authUserHelper.getCurrentAuditor().get(); String currentUserName = authUserHelper.getCurrentAuditor().get();
//通过循环来完成sheet获取每一行每一列数据并进行相关逻辑处理 //通过循环来完成sheet获取每一行每一列数据并进行相关逻辑处理
for (int rowNum = sheet.getFirstRowNum() + 8; rowNum <= sheet.getLastRowNum(); rowNum++) { for (int rowNum = sheet.getFirstRowNum() + 8; rowNum <= sheet.getLastRowNum(); rowNum++) {
...@@ -417,6 +426,7 @@ public class CitImportExcelServiceImpl extends BaseService { ...@@ -417,6 +426,7 @@ public class CitImportExcelServiceImpl extends BaseService {
noProjectMap.put(sb.toString(),companyFailMap.containsKey(sb.toString())?companyFailMap.get(sb.toString())+1:1); noProjectMap.put(sb.toString(),companyFailMap.containsKey(sb.toString())?companyFailMap.get(sb.toString())+1:1);
continue; continue;
} }
projectIdList.add(projectId);
companySuccessMap.put(sb.toString(),companySuccessMap.containsKey(sb.toString())?companySuccessMap.get(sb.toString())+1:1); companySuccessMap.put(sb.toString(),companySuccessMap.containsKey(sb.toString())?companySuccessMap.get(sb.toString())+1:1);
}else{ }else{
...@@ -451,6 +461,7 @@ public class CitImportExcelServiceImpl extends BaseService { ...@@ -451,6 +461,7 @@ public class CitImportExcelServiceImpl extends BaseService {
CitTrialBalanceExample.Criteria criteria = citTrialBalanceExample.createCriteria(); CitTrialBalanceExample.Criteria criteria = citTrialBalanceExample.createCriteria();
criteria.andCreateByEqualTo(currentUserName); criteria.andCreateByEqualTo(currentUserName);
criteria.andPeriodEqualTo(period); criteria.andPeriodEqualTo(period);
criteria.andProjectIdIn(projectIdList);
citTrialBalanceMapper.deleteByExample(citTrialBalanceExample); citTrialBalanceMapper.deleteByExample(citTrialBalanceExample);
updateImportLog(EnumCitImportType.TrialBalance.getCode()); updateImportLog(EnumCitImportType.TrialBalance.getCode());
} }
...@@ -627,6 +638,11 @@ public class CitImportExcelServiceImpl extends BaseService { ...@@ -627,6 +638,11 @@ public class CitImportExcelServiceImpl extends BaseService {
List<CitDataImportLog> citDataImportLogList = new ArrayList<>(); List<CitDataImportLog> citDataImportLogList = new ArrayList<>();
// Integer period = CitCommonUtil.getPeriod(); // Integer period = CitCommonUtil.getPeriod();
String companyName = CitCommonUtil.getValue(sheet.getRow(5).getCell(1)).toString(); String companyName = CitCommonUtil.getValue(sheet.getRow(5).getCell(1)).toString();
if(companyName == null){
saveResult.setResult(false);
saveResult.setResultMsg(ErrorMessageCN.NoCompanyError);
return saveResult;
}
List<Organization> organizations = getOrganizationByName(companyName).stream().filter(r->r.getCode()!=null&&!("".equals(r.getCode()))).collect(Collectors.toList()); List<Organization> organizations = getOrganizationByName(companyName).stream().filter(r->r.getCode()!=null&&!("".equals(r.getCode()))).collect(Collectors.toList());
String companyCode = ""; String companyCode = "";
String orgId = ""; String orgId = "";
...@@ -713,6 +729,7 @@ public class CitImportExcelServiceImpl extends BaseService { ...@@ -713,6 +729,7 @@ public class CitImportExcelServiceImpl extends BaseService {
CitBalanceSheetPrcAdjustExample.Criteria criteria = example.createCriteria(); CitBalanceSheetPrcAdjustExample.Criteria criteria = example.createCriteria();
criteria.andCreateByEqualTo(currentUserName); criteria.andCreateByEqualTo(currentUserName);
criteria.andPeriodEqualTo(period); criteria.andPeriodEqualTo(period);
criteria.andProjectIdEqualTo(projectId);
citBSPrcAdjustMapper.deleteByExample(example); citBSPrcAdjustMapper.deleteByExample(example);
updateImportLog(EnumCitImportType.BalanceSheetPrcAdjust.getCode()); updateImportLog(EnumCitImportType.BalanceSheetPrcAdjust.getCode());
} }
...@@ -762,6 +779,12 @@ public class CitImportExcelServiceImpl extends BaseService { ...@@ -762,6 +779,12 @@ public class CitImportExcelServiceImpl extends BaseService {
// Integer period = CitCommonUtil.getPeriod(); // Integer period = CitCommonUtil.getPeriod();
String companyName = CitCommonUtil.getValue(sheet.getRow(4).getCell(1)).toString(); String companyName = CitCommonUtil.getValue(sheet.getRow(4).getCell(1)).toString();
String companyCode = CitCommonUtil.getValue(sheet.getRow(5).getCell(1)).toString(); String companyCode = CitCommonUtil.getValue(sheet.getRow(5).getCell(1)).toString();
if(companyCode == null){
saveResult.setResult(false);
saveResult.setResultMsg(ErrorMessageCN.NoCompanyError);
return saveResult;
}
companyCode = companyCode.contains(".")?companyCode.substring(0,companyCode.indexOf(".")):companyCode;
List<Organization> organizations = getOrganizationByCode(companyCode); List<Organization> organizations = getOrganizationByCode(companyCode);
String orgId = ""; String orgId = "";
String projectId = ""; String projectId = "";
...@@ -842,6 +865,7 @@ public class CitImportExcelServiceImpl extends BaseService { ...@@ -842,6 +865,7 @@ public class CitImportExcelServiceImpl extends BaseService {
CitProfitPrcAdjustExample.Criteria criteria = example.createCriteria(); CitProfitPrcAdjustExample.Criteria criteria = example.createCriteria();
criteria.andCreateByEqualTo(currentUserName); criteria.andCreateByEqualTo(currentUserName);
criteria.andPeriodEqualTo(period); criteria.andPeriodEqualTo(period);
criteria.andProjectIdEqualTo(projectId);
citProfitPrcAdjustMapper.deleteByExample(example); citProfitPrcAdjustMapper.deleteByExample(example);
updateImportLog(EnumCitImportType.ProfitPrcAdjust.getCode()); updateImportLog(EnumCitImportType.ProfitPrcAdjust.getCode());
} }
...@@ -1268,7 +1292,7 @@ public class CitImportExcelServiceImpl extends BaseService { ...@@ -1268,7 +1292,7 @@ public class CitImportExcelServiceImpl extends BaseService {
* @param orgList * @param orgList
* @return * @return
*/ */
public OperationResultDto autoGeneTB(Integer period, String orgId, List<String> orgList){ public OperationResultDto autoGeneTB(Integer period, String orgId, List<String> orgList,String projectId){
OperationResultDto autoGeneResult = new OperationResultDto(); OperationResultDto autoGeneResult = new OperationResultDto();
//第一步,根据合并日记账计算出借方发生额,贷方发生额,科目代码等相关信息 //第一步,根据合并日记账计算出借方发生额,贷方发生额,科目代码等相关信息
...@@ -1289,6 +1313,7 @@ public class CitImportExcelServiceImpl extends BaseService { ...@@ -1289,6 +1313,7 @@ public class CitImportExcelServiceImpl extends BaseService {
trialBalance.setPeriod(period); trialBalance.setPeriod(period);
trialBalance.setCreateBy(currentUserName); trialBalance.setCreateBy(currentUserName);
trialBalance.setOrganizationId(orgId); trialBalance.setOrganizationId(orgId);
trialBalance.setProjectId(projectId);
trialBalance.setAccountCode(citJournal.getSubjectCode()); trialBalance.setAccountCode(citJournal.getSubjectCode());
trialBalance.setAccountDescription(citJournal.getSubjectName()); trialBalance.setAccountDescription(citJournal.getSubjectName());
//此期间默认为12 //此期间默认为12
......
...@@ -297,6 +297,7 @@ ...@@ -297,6 +297,7 @@
<select id="sumAmountByCondition" parameterType="map" resultMap="BaseResultMap"> <select id="sumAmountByCondition" parameterType="map" resultMap="BaseResultMap">
SELECT SELECT
subject_code as subject_code, subject_code as subject_code,
max(jfinal.subject_name) as subject_name,
sum(jfinal.accounted_dr) as accounted_dr, sum(jfinal.accounted_dr) as accounted_dr,
sum(jfinal.accounted_cr) as accounted_cr sum(jfinal.accounted_cr) as accounted_cr
from from
...@@ -304,7 +305,8 @@ ...@@ -304,7 +305,8 @@
select select
cj.accounted_dr as accounted_dr, cj.accounted_dr as accounted_dr,
cj.accounted_cr as accounted_cr , cj.accounted_cr as accounted_cr ,
cj.subject_code as subject_code cj.subject_code as subject_code,
cj.subject_name as subject_name
from from
cit_journal_entry_adjust cj cit_journal_entry_adjust cj
where where
...@@ -321,7 +323,8 @@ ...@@ -321,7 +323,8 @@
select select
j.accounted_dr as accounted_dr, j.accounted_dr as accounted_dr,
j.accounted_cr as accounted_cr, j.accounted_cr as accounted_cr,
j.segment3 as subject_code j.segment3 as subject_code,
j.segment3_name as subject_name
from from
journal_entry j journal_entry j
where where
......
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