Commit fd95a467 authored by zhkwei's avatar zhkwei

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

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