Commit d44953b1 authored by neo's avatar neo

[TEMP] add import rebance impl

parent 62c08f39
package pwc.taxtech.atms.constant.enums;
public enum EnumTbImportType {
Import(0),
CoverImport(1),
AddImport(2);
private Integer code;
EnumTbImportType(Integer code) {
this.code = code;
}
public Integer getCode() {
return code;
}
}
package pwc.taxtech.atms.constant.enums;
public enum EnumValidationType {
TrialBalance (0),
InputVoice (1),
OutputVoice (2),
ErpDuplicate (3), //重复数据
ErpBasicCheck (4),//基础数据校验
ErpCorrect (5),//数据正确性
JournalEntry (6),
InputVoiceItem (7),
CustomInvoice (8),
AccountMapping (9),
InvoiceMapping (10),
VoucherMapping (11);
private Integer code;
EnumValidationType(Integer code) {
this.code = code;
}
public Integer getCode() {
return code;
}
}
package pwc.taxtech.atms.constant.enums;
public enum ProjectImportDataType {
AuditAdjust(1), //审计调整
CustomInvoice(2), //海关清单
JournalEntry(3), //序时账
ErpData(4), //财务数据
InputInvoice(5), //进项发票
InvoiceMapping(6), //发票对应
OutputInvoice(7), //销项发票
TrialBalance(8), //试算平衡表
VoucherMapping(9); //凭证对应
private Integer code;
ProjectImportDataType(Integer code) {
this.code = code;
}
public Integer getCode() {
return code;
}
}
package pwc.taxtech.atms.constant.enums;
public enum ServiceType {
Administration(1), //后台admin
VAT(2),//增值税申报分析
AM(3),//电子税务管理
FDD(4),//财务尽职调查
Dashboard(5),//税务管理平台
CIT(6),// 企业所得税
TCS(7);//电子税务审计
private Integer code;
ServiceType(Integer code) {
this.code = code;
}
public Integer getCode() {
return code;
}
}
......@@ -3,10 +3,11 @@ package pwc.taxtech.atms.dao;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import pwc.taxtech.atms.MyMapper;
import pwc.taxtech.atms.constant.VatErpImportValidation;
@Mapper
public interface CitTBDataImportMapper {
public interface CitTBDataImportMapper extends MyMapper {
@Delete("<script>" +
"<if test=\"tbName =='"+VatErpImportValidation.CompanyBalanceTbName+"' \">" +
" DELETE FROM #{tbName} WHERE PeriodId = #{period}" +
......
package pwc.taxtech.atms.dao;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import pwc.taxtech.atms.MyMapper;
@Mapper
public interface DataImportMapper extends MyMapper {
@Delete("DELETE FROM #{tbName} WHERE Period =#{period}")
Integer deleteByNameAndPeriod(@Param("tbName") String tbName, @Param("period") Integer period);
@Update("TRUNCATE TABLE #{tbName}")
Integer truncateByName(@Param("tbName") String tbName);
@Delete("DELETE FROM ValidationInfo WHERE PeriodId = #{period}and ImportTypeId=#{typeId} ")
void deleteTbValidation(@Param("period") int period, @Param("typeId") Integer typeId);
}
package pwc.taxtech.atms.dto.taxadmin;
import java.util.Date;
public class DataImportedStatusDto {
private String id;
private String projectId;
private String dbName;
private String organizationId;
private Integer year;
private Integer period;
private Integer dataType;
private Integer totalCount;
private Integer exceptionCount;
private Integer successedCount;
private Date startTime;
private Date endTime;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getProjectId() {
return projectId;
}
public void setProjectId(String projectId) {
this.projectId = projectId;
}
public String getDbName() {
return dbName;
}
public void setDbName(String dbName) {
this.dbName = dbName;
}
public String getOrganizationId() {
return organizationId;
}
public void setOrganizationId(String organizationId) {
this.organizationId = organizationId;
}
public Integer getYear() {
return year;
}
public void setYear(Integer year) {
this.year = year;
}
public Integer getPeriod() {
return period;
}
public void setPeriod(Integer period) {
this.period = period;
}
public Integer getDataType() {
return dataType;
}
public void setDataType(Integer dataType) {
this.dataType = dataType;
}
public Integer getTotalCount() {
return totalCount;
}
public void setTotalCount(Integer totalCount) {
this.totalCount = totalCount;
}
public Integer getExceptionCount() {
return exceptionCount;
}
public void setExceptionCount(Integer exceptionCount) {
this.exceptionCount = exceptionCount;
}
public Integer getSuccessedCount() {
return successedCount;
}
public void setSuccessedCount(Integer successedCount) {
this.successedCount = successedCount;
}
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
}
package pwc.taxtech.atms.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.constant.enums.EnumTbImportType;
import pwc.taxtech.atms.constant.enums.EnumValidationType;
import pwc.taxtech.atms.constant.enums.ProjectImportDataType;
import pwc.taxtech.atms.constant.enums.ServiceType;
import pwc.taxtech.atms.dao.DataImportMapper;
import pwc.taxtech.atms.dao.EnterpriseAccountMapper;
import pwc.taxtech.atms.dao.ProjectMapper;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.taxadmin.DataImportedStatusDto;
import pwc.taxtech.atms.dto.vat.CompanyBalanceDto;
import pwc.taxtech.atms.entitiy.EnterpriseAccountExample;
import pwc.taxtech.atms.entitiy.Project;
import pwc.taxtech.atms.entitiy.ProjectExample;
import pwc.taxtech.atms.service.DataImportService;
import pwc.taxtech.atms.vat.dao.CompanyBalanceMapper;
import pwc.taxtech.atms.vat.entity.CompanyBalance;
import pwc.taxtech.atms.vat.entity.CompanyBalanceExample;
import java.util.Date;
import java.util.List;
@Service
public class DataImportServiceImpl implements DataImportService {
private static final String PROJECT_DB_NAME = "test_db";//TODO:fixed use init db
private static final String COMPANY_BALANCE_TABLE = "CompanyBalance";
private static final String BALANCE_TABLE = "Balance";
private static final int FIRST_OR_DEFAULT = 0;
@Autowired
private DataImportMapper mapper;
@Autowired
private CompanyBalanceMapper companyBalanceMapper;
@Autowired
private ProjectMapper projectMapper;
@Autowired
private EnterpriseAccountMapper enterpriseAccountMapper;
@Override
public OperationResultDto importTrialBalance(List<CompanyBalanceDto> balanceList, Integer importType, Integer serviceTypeId, String id) {
return null;
public OperationResultDto importTrialBalance(List<CompanyBalanceDto> balanceList, Integer importType,
Integer serviceTypeId, String userID) {
OperationResultDto result = new OperationResultDto();
if (serviceTypeId == ServiceType.VAT.getCode().intValue()) {
int period = balanceList.get(0).getPeriodId().intValue();
DataImportedStatusDto dataImportedStatus = new DataImportedStatusDto();
dataImportedStatus.setPeriod(period);
dataImportedStatus.setDbName(PROJECT_DB_NAME);
dataImportedStatus.setDataType(ProjectImportDataType.TrialBalance.getCode());
dataImportedStatus.setStartTime(new Date());
//覆盖导入之前删除数据
if (importType == EnumTbImportType.CoverImport.getCode()) {
clearTableData(period, COMPANY_BALANCE_TABLE);
}
// var sqlhelper = new SqlHelper(_projectDbConnstring);
// var companyBalance = ServiceHelper.ToDataTable(balanceList);
// sqlhelper.SqlBulkCopyInsert(_companyBalancetable, companyBalance, 10000);
// sqlhelper.Close();
//TODO: sql bulk copy insert tobe impl(neo)
//SynAccountFromTaxAdmin(period, userID);
Boolean isSuccess = refreshTrialBalance(period, serviceTypeId, userID);
result.setResult(isSuccess);
}else if(serviceTypeId == ServiceType.CIT.getCode()){//TODO import cit (neo)
}
return result;
}
private Boolean refreshTrialBalance(int period, Integer serviceTypeId, String userID) {
CompanyBalanceExample companyBalanceExample = new CompanyBalanceExample();
companyBalanceExample.createCriteria().andPeriodIdEqualTo(period);
List<CompanyBalance> list = companyBalanceMapper.selectByExample(companyBalanceExample);
if (list != null && !list.isEmpty()) {
//同步账套 TODO: sync admin db and project db(neo)
synAccountFromTaxAdmin(period, userID);
//先删除数据
clearTableData(period, BALANCE_TABLE);
mapper.deleteTbValidation(period, EnumValidationType.TrialBalance.getCode());
}
return true;
}
private void synAccountFromTaxAdmin(int period, String userID) {
ProjectExample example = new ProjectExample();
example.createCriteria().andDbNameEqualTo(PROJECT_DB_NAME);
List<Project> plist = projectMapper.selectByExample(example);
if (plist != null && !plist.isEmpty()) {
Project pFirst = plist.get(FIRST_OR_DEFAULT);
if (pFirst.getEnterpriseAccountSetID() != null && !pFirst.getEnterpriseAccountSetID().isEmpty()) {
String easId = pFirst.getEnterpriseAccountSetID();
EnterpriseAccountExample accountExample = new EnterpriseAccountExample();
accountExample.createCriteria().andEnterpriseAccountSetIDEqualTo(easId);
}
}
}
private void clearTableData(int period, String companyBalanceTable) {
if (period > 0) {
mapper.deleteByNameAndPeriod(companyBalanceTable, period);
} else {
mapper.truncateByName(companyBalanceTable);
}
}
}
......@@ -9,6 +9,6 @@ import pwc.taxtech.atms.service.IdentityService;
public class IdentityServiceImpl implements IdentityService {
@Override
public UserDto getIdentityUser() {
return AppCachePool.getCachedUser("cach_test");//TODO:should fixed use session username
return AppCachePool.getCachedUser("cach_test");//TODO:should fixed use session username(neo)
}
}
......@@ -45,7 +45,7 @@ public class ProjectInfoServiceImpl implements ProjectInfoService {
@Override
public OperationResultDto<Boolean> isProjectImportedData(String projectId, Integer importTypeId) {
return isProjectImportedData(projectId,importTypeId);
return isProjectImportedData(projectId, null, importTypeId);
}
@Override
......
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