Commit 009c7b6b authored by frank.xa.zhang's avatar frank.xa.zhang

Merge branch 'dev' into dev_frank

parents 7e573a12 7cead2a6
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<property name="forceBigDecimals" value="false" /> <property name="forceBigDecimals" value="false" />
</javaTypeResolver> </javaTypeResolver>
<javaModelGenerator targetPackage="pwc.taxtech.atms.vat.entitiy" targetProject="../../src/main/java"> <javaModelGenerator targetPackage="pwc.taxtech.atms.vat.entity" targetProject="../../src/main/java">
<property name="trimStrings" value="true" /> <property name="trimStrings" value="true" />
</javaModelGenerator> </javaModelGenerator>
...@@ -305,6 +305,8 @@ ...@@ -305,6 +305,8 @@
<table tableName="StandardAccount" domainObjectName="VatStandardAccount"> <table tableName="StandardAccount" domainObjectName="VatStandardAccount">
<property name="useActualColumnNames" value="true" /> <property name="useActualColumnNames" value="true" />
<property name="ignoreQualifiersAtRuntime" value="true"/> <property name="ignoreQualifiersAtRuntime" value="true"/>
<columnOverride column="isActive" javaType="Boolean" />
<columnOverride column="isLeaf" javaType="Boolean" />
</table> </table>
<table tableName="ValidationInfo" domainObjectName="ValidationInfo"> <table tableName="ValidationInfo" domainObjectName="ValidationInfo">
......
...@@ -11,8 +11,12 @@ public final class Constant { ...@@ -11,8 +11,12 @@ public final class Constant {
public static final int CREATE_DB_EXISTS = 0; public static final int CREATE_DB_EXISTS = 0;
public static final int CREATE_DB_FAILED = -1; public static final int CREATE_DB_FAILED = -1;
public static final String DB_SCRIPT_FOLDER="RuntimeDbScripts"; public static final String DB_SCRIPT_FOLDER = "RuntimeDbScripts";
public static final String DB_SCRIPT_SQL="CreateProjectDB.sql"; public static final String DB_SCRIPT_SQL = "CreateProjectDB.sql";
public static final String DB_MYSQL_TYPE="MYSQL"; public static final String DB_MYSQL_TYPE = "MYSQL";
public static final String DB_MYSQL_PATH=DB_SCRIPT_FOLDER + File.separator + DB_MYSQL_TYPE + File.separator + DB_SCRIPT_SQL; public static final String DB_MYSQL_PATH = DB_SCRIPT_FOLDER + File.separator + DB_MYSQL_TYPE + File.separator + DB_SCRIPT_SQL;
}
public static final boolean ACTIVE = true;
public static final String DEFAULT_INDUSTRY_ID = "0";
}
\ No newline at end of file
...@@ -10,6 +10,7 @@ import org.reflections.util.Utils; ...@@ -10,6 +10,7 @@ import org.reflections.util.Utils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import pwc.taxtech.atms.agent.DatabaseAgent; import pwc.taxtech.atms.agent.DatabaseAgent;
import pwc.taxtech.atms.common.CommonUtils; import pwc.taxtech.atms.common.CommonUtils;
...@@ -17,11 +18,14 @@ import pwc.taxtech.atms.common.OperateLogType; ...@@ -17,11 +18,14 @@ import pwc.taxtech.atms.common.OperateLogType;
import pwc.taxtech.atms.common.OperationModule; import pwc.taxtech.atms.common.OperationModule;
import pwc.taxtech.atms.common.datasource.ShardingContextHolder; import pwc.taxtech.atms.common.datasource.ShardingContextHolder;
import pwc.taxtech.atms.constant.Constant; import pwc.taxtech.atms.constant.Constant;
import pwc.taxtech.atms.dao.AccountMappingMapper;
import pwc.taxtech.atms.dao.EnterpriseAccountMapper;
import pwc.taxtech.atms.dao.OrganizationServiceTemplateGroupMapper; import pwc.taxtech.atms.dao.OrganizationServiceTemplateGroupMapper;
import pwc.taxtech.atms.dao.ProjectClientMapper; import pwc.taxtech.atms.dao.ProjectClientMapper;
import pwc.taxtech.atms.dao.ProjectMapper; import pwc.taxtech.atms.dao.ProjectMapper;
import pwc.taxtech.atms.dao.ProjectServiceTypeMapper; import pwc.taxtech.atms.dao.ProjectServiceTypeMapper;
import pwc.taxtech.atms.dao.ServiceTypeMapper; import pwc.taxtech.atms.dao.ServiceTypeMapper;
import pwc.taxtech.atms.dao.StandardAccountMapper;
import pwc.taxtech.atms.dao.TemplateGroupMapper; import pwc.taxtech.atms.dao.TemplateGroupMapper;
import pwc.taxtech.atms.dto.FieldsMapper; import pwc.taxtech.atms.dto.FieldsMapper;
import pwc.taxtech.atms.dto.ProjectClientDto; import pwc.taxtech.atms.dto.ProjectClientDto;
...@@ -34,6 +38,10 @@ import pwc.taxtech.atms.entitiy.*; ...@@ -34,6 +38,10 @@ import pwc.taxtech.atms.entitiy.*;
import pwc.taxtech.atms.entitiy.ProjectClientExample.Criteria; import pwc.taxtech.atms.entitiy.ProjectClientExample.Criteria;
import pwc.taxtech.atms.service.OperationLogService; import pwc.taxtech.atms.service.OperationLogService;
import pwc.taxtech.atms.service.ProjectService; import pwc.taxtech.atms.service.ProjectService;
import pwc.taxtech.atms.vat.dao.VatEnterpriseAccountMapper;
import pwc.taxtech.atms.vat.dao.VatStandardAccountMapper;
import pwc.taxtech.atms.vat.entity.VatEnterpriseAccount;
import pwc.taxtech.atms.vat.entity.VatStandardAccount;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.BufferedWriter; import java.io.BufferedWriter;
...@@ -91,12 +99,18 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -91,12 +99,18 @@ public class ProjectServiceImpl implements ProjectService {
@Autowired @Autowired
private SqlSessionTemplate dynamicSqlSessionTemplate; private SqlSessionTemplate dynamicSqlSessionTemplate;
@Autowired
private StandardAccountMapper standardAccountMapper;
@Autowired
private VatStandardAccountMapper vatStandardAccountMapper;
@Value("${jdbc_admin_db}")
private String adminDbName;
private final OperateLogType LOG_TYPE = OperateLogType.OperationLogProject; private final OperateLogType LOG_TYPE = OperateLogType.OperationLogProject;
private static final Logger logger = LoggerFactory.getLogger(ProjectServiceImpl.class); private static final Logger logger = LoggerFactory.getLogger(ProjectServiceImpl.class);
public ProjectServiceImpl() {
}
@Override @Override
public List<ServiceTypeDto> getServiceList() { public List<ServiceTypeDto> getServiceList() {
...@@ -289,16 +303,62 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -289,16 +303,62 @@ public class ProjectServiceImpl implements ProjectService {
LOGGER.error("generate data base error", e); LOGGER.error("generate data base error", e);
} }
initStandardAccount(project.getIndustryID());
return dbName; return dbName;
} }
private void initStandardAccount(String industryId) {
StandardAccountExample example = new StandardAccountExample();
example.createCriteria().andIsActiveEqualTo(ACTIVE).andIndustryIDIn(Lists.newArrayList(industryId, DEFAULT_INDUSTRY_ID));
List<StandardAccount> standardAccountList = standardAccountMapper.selectByExample(example);
List<VatStandardAccount> prepareAccount = new ArrayList<>();
if (industryId.equalsIgnoreCase(DEFAULT_INDUSTRY_ID)) {
prepareAccount = extractFrom(standardAccountList);
} else {
final List<StandardAccount> groupDefault = new ArrayList<>();
final List<StandardAccount> groupInput = new ArrayList<>();
standardAccountList.forEach(m -> {
if (m.getIndustryID().equalsIgnoreCase(industryId)) groupInput.add(m);
else groupDefault.add(m);
});
if (groupInput.isEmpty()) {
if (!groupDefault.isEmpty())
prepareAccount = extractFrom(groupDefault);
} else {
prepareAccount = extractFrom(groupInput);
}
}
prepareAccount.forEach(m->vatStandardAccountMapper.insert(m));
}
private List<VatStandardAccount> extractFrom(List<StandardAccount> fromSource) {
List<VatStandardAccount> resut = new ArrayList<>(fromSource.size());
fromSource.forEach(m -> {
VatStandardAccount dest = new VatStandardAccount();
try {
FieldsMapper.map(m, dest);
} catch (Exception e) {
LOGGER.warn("some filed can not mapped", e);
}
resut.add(dest);
});
return resut;
}
private Reader prepareRunScriptReader(String sqlPath, String dbName, Project project, String accsetid) { private Reader prepareRunScriptReader(String sqlPath, String dbName, Project project, String accsetid) {
Map<String, String> keyValues = new HashMap<>(); Map<String, String> keyValues = new HashMap<>();
keyValues.put("DBKeyword_ProjectDbName", dbName); keyValues.put("DBKeyword_ProjectDbName", dbName);
keyValues.put("DBKeyword_IndustryId", project.getIndustryID());
keyValues.put("DBKeyword_OrganizationID", project.getOrganizationID()); keyValues.put("DBKeyword_OrganizationID", project.getOrganizationID());
keyValues.put("DBKeyword_EnterpriseAccountSetID", accsetid); keyValues.put("DBKeyword_EnterpriseAccountSetID", accsetid);
keyValues.put("DBKeyword_AdminDbName", adminDbName);
BufferedReader bufferedReader = null; BufferedReader bufferedReader = null;
String line = null; String line = null;
......
...@@ -98,7 +98,7 @@ public class VatStandardAccount implements Serializable { ...@@ -98,7 +98,7 @@ public class VatStandardAccount implements Serializable {
* *
* @mbg.generated * @mbg.generated
*/ */
private Short isLeaf; private Boolean isLeaf;
/** /**
* *
...@@ -116,7 +116,7 @@ public class VatStandardAccount implements Serializable { ...@@ -116,7 +116,7 @@ public class VatStandardAccount implements Serializable {
* *
* @mbg.generated * @mbg.generated
*/ */
private Short isActive; private Boolean isActive;
/** /**
* *
...@@ -368,7 +368,7 @@ public class VatStandardAccount implements Serializable { ...@@ -368,7 +368,7 @@ public class VatStandardAccount implements Serializable {
* *
* @mbg.generated * @mbg.generated
*/ */
public Short getIsLeaf() { public Boolean getIsLeaf() {
return isLeaf; return isLeaf;
} }
...@@ -380,7 +380,7 @@ public class VatStandardAccount implements Serializable { ...@@ -380,7 +380,7 @@ public class VatStandardAccount implements Serializable {
* *
* @mbg.generated * @mbg.generated
*/ */
public void setIsLeaf(Short isLeaf) { public void setIsLeaf(Boolean isLeaf) {
this.isLeaf = isLeaf; this.isLeaf = isLeaf;
} }
...@@ -416,7 +416,7 @@ public class VatStandardAccount implements Serializable { ...@@ -416,7 +416,7 @@ public class VatStandardAccount implements Serializable {
* *
* @mbg.generated * @mbg.generated
*/ */
public Short getIsActive() { public Boolean getIsActive() {
return isActive; return isActive;
} }
...@@ -428,7 +428,7 @@ public class VatStandardAccount implements Serializable { ...@@ -428,7 +428,7 @@ public class VatStandardAccount implements Serializable {
* *
* @mbg.generated * @mbg.generated
*/ */
public void setIsActive(Short isActive) { public void setIsActive(Boolean isActive) {
this.isActive = isActive; this.isActive = isActive;
} }
......
...@@ -794,52 +794,52 @@ public class VatStandardAccountExample { ...@@ -794,52 +794,52 @@ public class VatStandardAccountExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIsLeafEqualTo(Short value) { public Criteria andIsLeafEqualTo(Boolean value) {
addCriterion("IsLeaf =", value, "isLeaf"); addCriterion("IsLeaf =", value, "isLeaf");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIsLeafNotEqualTo(Short value) { public Criteria andIsLeafNotEqualTo(Boolean value) {
addCriterion("IsLeaf <>", value, "isLeaf"); addCriterion("IsLeaf <>", value, "isLeaf");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIsLeafGreaterThan(Short value) { public Criteria andIsLeafGreaterThan(Boolean value) {
addCriterion("IsLeaf >", value, "isLeaf"); addCriterion("IsLeaf >", value, "isLeaf");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIsLeafGreaterThanOrEqualTo(Short value) { public Criteria andIsLeafGreaterThanOrEqualTo(Boolean value) {
addCriterion("IsLeaf >=", value, "isLeaf"); addCriterion("IsLeaf >=", value, "isLeaf");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIsLeafLessThan(Short value) { public Criteria andIsLeafLessThan(Boolean value) {
addCriterion("IsLeaf <", value, "isLeaf"); addCriterion("IsLeaf <", value, "isLeaf");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIsLeafLessThanOrEqualTo(Short value) { public Criteria andIsLeafLessThanOrEqualTo(Boolean value) {
addCriterion("IsLeaf <=", value, "isLeaf"); addCriterion("IsLeaf <=", value, "isLeaf");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIsLeafIn(List<Short> values) { public Criteria andIsLeafIn(List<Boolean> values) {
addCriterion("IsLeaf in", values, "isLeaf"); addCriterion("IsLeaf in", values, "isLeaf");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIsLeafNotIn(List<Short> values) { public Criteria andIsLeafNotIn(List<Boolean> values) {
addCriterion("IsLeaf not in", values, "isLeaf"); addCriterion("IsLeaf not in", values, "isLeaf");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIsLeafBetween(Short value1, Short value2) { public Criteria andIsLeafBetween(Boolean value1, Boolean value2) {
addCriterion("IsLeaf between", value1, value2, "isLeaf"); addCriterion("IsLeaf between", value1, value2, "isLeaf");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIsLeafNotBetween(Short value1, Short value2) { public Criteria andIsLeafNotBetween(Boolean value1, Boolean value2) {
addCriterion("IsLeaf not between", value1, value2, "isLeaf"); addCriterion("IsLeaf not between", value1, value2, "isLeaf");
return (Criteria) this; return (Criteria) this;
} }
...@@ -914,52 +914,52 @@ public class VatStandardAccountExample { ...@@ -914,52 +914,52 @@ public class VatStandardAccountExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIsActiveEqualTo(Short value) { public Criteria andIsActiveEqualTo(Boolean value) {
addCriterion("IsActive =", value, "isActive"); addCriterion("IsActive =", value, "isActive");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIsActiveNotEqualTo(Short value) { public Criteria andIsActiveNotEqualTo(Boolean value) {
addCriterion("IsActive <>", value, "isActive"); addCriterion("IsActive <>", value, "isActive");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIsActiveGreaterThan(Short value) { public Criteria andIsActiveGreaterThan(Boolean value) {
addCriterion("IsActive >", value, "isActive"); addCriterion("IsActive >", value, "isActive");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIsActiveGreaterThanOrEqualTo(Short value) { public Criteria andIsActiveGreaterThanOrEqualTo(Boolean value) {
addCriterion("IsActive >=", value, "isActive"); addCriterion("IsActive >=", value, "isActive");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIsActiveLessThan(Short value) { public Criteria andIsActiveLessThan(Boolean value) {
addCriterion("IsActive <", value, "isActive"); addCriterion("IsActive <", value, "isActive");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIsActiveLessThanOrEqualTo(Short value) { public Criteria andIsActiveLessThanOrEqualTo(Boolean value) {
addCriterion("IsActive <=", value, "isActive"); addCriterion("IsActive <=", value, "isActive");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIsActiveIn(List<Short> values) { public Criteria andIsActiveIn(List<Boolean> values) {
addCriterion("IsActive in", values, "isActive"); addCriterion("IsActive in", values, "isActive");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIsActiveNotIn(List<Short> values) { public Criteria andIsActiveNotIn(List<Boolean> values) {
addCriterion("IsActive not in", values, "isActive"); addCriterion("IsActive not in", values, "isActive");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIsActiveBetween(Short value1, Short value2) { public Criteria andIsActiveBetween(Boolean value1, Boolean value2) {
addCriterion("IsActive between", value1, value2, "isActive"); addCriterion("IsActive between", value1, value2, "isActive");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIsActiveNotBetween(Short value1, Short value2) { public Criteria andIsActiveNotBetween(Boolean value1, Boolean value2) {
addCriterion("IsActive not between", value1, value2, "isActive"); addCriterion("IsActive not between", value1, value2, "isActive");
return (Criteria) this; return (Criteria) this;
} }
......
jdbc_url=${jdbc_url} jdbc_url=${jdbc_url}
jdbc_user=${jdbc_user} jdbc_user=${jdbc_user}
jdbc_password=${jdbc_password} jdbc_password=${jdbc_password}
jdbc_admin_db=${jdbc_admin_db}
jdbc_url_demo=${jdbc_url_demo} jdbc_url_demo=${jdbc_url_demo}
......
jdbc_url=jdbc:mysql://10.157.107.89:3306/tax_admin?useUnicode=true&amp;characterEncoding=utf-8&amp;zeroDateTimeBehavior=convertToNull&amp;allowMultiQueries=true jdbc_url=jdbc:mysql://10.157.107.89:3306/tax_admin?useUnicode=true&amp;characterEncoding=utf-8&amp;zeroDateTimeBehavior=convertToNull&amp;allowMultiQueries=true
jdbc_user=root jdbc_user=root
jdbc_password=tax@Admin2018 jdbc_password=tax@Admin2018
jdbc_admin_db=tax_admin
jdbc_url_demo=jdbc:mysql://10.157.107.89:3306/demo_db_name?useUnicode=true&amp;characterEncoding=utf-8&amp;zeroDateTimeBehavior=convertToNull&amp;allowMultiQueries=true jdbc_url_demo=jdbc:mysql://10.157.107.89:3306/demo_db_name?useUnicode=true&amp;characterEncoding=utf-8&amp;zeroDateTimeBehavior=convertToNull&amp;allowMultiQueries=true
......
jdbc_url=jdbc:sqlserver://192.168.1.102:1434;DatabaseName=QATaxAdmin8 jdbc_url=jdbc:sqlserver://192.168.1.102:1434;DatabaseName=QATaxAdmin8
jdbc_user=sa jdbc_user=sa
jdbc_password=atmsunittestSQL jdbc_password=atmsunittestSQL
jdbc_admin_db=QATaxAdmin8
jdbc_url_demo=jdbc:mysql://10.157.107.89:3306/demo_db_name?useUnicode=true&amp;characterEncoding=utf-8&amp;zeroDateTimeBehavior=convertToNull&amp;allowMultiQueries=true jdbc_url_demo=jdbc:mysql://10.157.107.89:3306/demo_db_name?useUnicode=true&amp;characterEncoding=utf-8&amp;zeroDateTimeBehavior=convertToNull&amp;allowMultiQueries=true
......
jdbc_url=jdbc:mysql://10.157.107.89:3306/tax_admin?useUnicode=true&amp;characterEncoding=utf-8&amp;zeroDateTimeBehavior=convertToNull&amp;allowMultiQueries=true jdbc_url=jdbc:mysql://10.157.107.89:3306/tax_admin?useUnicode=true&amp;characterEncoding=utf-8&amp;zeroDateTimeBehavior=convertToNull&amp;allowMultiQueries=true
jdbc_user=root jdbc_user=root
jdbc_password=tax@Admin2018 jdbc_password=tax@Admin2018
jdbc_admin_db=tax_admin
jdbc_url_demo=jdbc:mysql://10.157.107.89:3306/demo_db_name?useUnicode=true&amp;characterEncoding=utf-8&amp;zeroDateTimeBehavior=convertToNull&amp;allowMultiQueries=true jdbc_url_demo=jdbc:mysql://10.157.107.89:3306/demo_db_name?useUnicode=true&amp;characterEncoding=utf-8&amp;zeroDateTimeBehavior=convertToNull&amp;allowMultiQueries=true
......
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