提交 b406ce95 authored 作者: chenshiying's avatar chenshiying

[新增] 廊坊生成大小类管理问题sql

上级 71159648
package com.loit.common.langfang;
import com.loit.common.langfang.dto.CommandManualDTO;
import com.loit.common.script.dto.BackendFrontEnum;
import com.loit.common.script.dto.DeployInfoDataDTO;
import com.loit.common.utils.ListUtil;
import com.loit.common.utils.StringUtils;
import com.loit.common.utils.excel.ImportExcel;
......@@ -16,18 +14,16 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
public class GeneratorCommandManualScript {
public static final String CASE_TYPE = "1";
protected static String root_path = "F:\\9Git140\\loit-build-common\\loit-build-component\\loit-build-deploy-env\\src\\main\\resources\\langfang";
public static void main(String[] args) {
try {
......@@ -50,6 +46,9 @@ public class GeneratorCommandManualScript {
createBigTypeScript(transformList);
createSmallTypeScript(transformList);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
......@@ -104,9 +103,6 @@ public class GeneratorCommandManualScript {
}
resultList.add(commandManual);
String atype = commandManual.getAtype();
if (StringUtils.isEmpty(commandManual.getBtype())) {
commandManual.setBtype(atype);
......@@ -116,13 +112,21 @@ public class GeneratorCommandManualScript {
commandManual.setCtype(atype);
}
commandManual.setBigAndSmallCode(commandManual.getBigTypeCode() + "|"+ commandManual.getSmallTypeCode());
commandManual.setBigTypeCodeInt(Integer.valueOf(commandManual.getBigTypeCode()));
commandManual.setSmallTypeCodeInt(Integer.valueOf(commandManual.getSmallTypeCode()));
resultList.add(commandManual);
}
return resultList;
}
/**
* 生成大类脚本
*
......@@ -130,16 +134,58 @@ public class GeneratorCommandManualScript {
*/
private static void createBigTypeScript(List<CommandManualDTO> commandManualList) {
Map model = new HashMap();
model.put("springProfilesActive", "123");
String configFilePath = root_path + "\\bigTypeScript.sql";
String jobConfig = FreeMarkerUtils.process("langfang" + "\\bigTypeScript.ftl", model);
FileUtils.appendNewLine(configFilePath, jobConfig);
List<CommandManualDTO> bitTypeList = commandManualList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
new TreeSet<>(Comparator.comparing(CommandManualDTO::getBigTypeCode))), ArrayList::new));
if (bitTypeList == null || bitTypeList.isEmpty()) {
return;
}
for (CommandManualDTO commandManualDTO : bitTypeList) {
Map model = new HashMap();
model.put("bigTypeCode", commandManualDTO.getBigTypeCode());
model.put("bigTypeName", commandManualDTO.getBigTypeName());
model.put("caseType", CASE_TYPE);
System.out.println("test");
String configFilePath = root_path + "\\bigTypeScript.sql";
String jobConfig = FreeMarkerUtils.process("langfang" + "\\bigTypeScript.ftl", model);
FileUtils.append(configFilePath, jobConfig);
}
}
/**
* 生成小类脚本
*
* @throws IOException
*/
private static void createSmallTypeScript(List<CommandManualDTO> commandManualList) {
List<CommandManualDTO> smallTypeList = commandManualList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
new TreeSet<>(Comparator.comparing(CommandManualDTO::getBigAndSmallCode))), ArrayList::new));
if (smallTypeList == null || smallTypeList.isEmpty()) {
return;
}
smallTypeList.sort(Comparator.comparing(CommandManualDTO::getBigTypeCodeInt)
.thenComparing(CommandManualDTO::getSmallTypeCodeInt));
for (CommandManualDTO commandManualDTO : smallTypeList) {
Map model = new HashMap();
model.put("bigTypeCode", commandManualDTO.getBigTypeCode());
model.put("bigTypeName", commandManualDTO.getBigTypeName());
model.put("smallTypeCode", commandManualDTO.getSmallTypeCode());
model.put("smallTypeName", commandManualDTO.getSmallTypeName());
model.put("caseType", CASE_TYPE);
String configFilePath = root_path + "\\smallTypeScript.sql";
String jobConfig = FreeMarkerUtils.process("langfang" + "\\smallTypeScript.ftl", model);
FileUtils.append(configFilePath, jobConfig);
}
}
}
......@@ -50,6 +50,22 @@ public class CommandManualDTO implements Serializable {
private String ctype;
/**
* 大类编号Int
*/
private Integer bigTypeCodeInt;
/**
* 小类编号Int
*/
private Integer smallTypeCodeInt;
/**
* 大类和小类组合编码
*/
private String bigAndSmallCode;
public String getBigTypeCode() {
return bigTypeCode;
}
......@@ -113,4 +129,28 @@ public class CommandManualDTO implements Serializable {
public void setCtype(String ctype) {
this.ctype = ctype;
}
public Integer getBigTypeCodeInt() {
return bigTypeCodeInt;
}
public void setBigTypeCodeInt(Integer bigTypeCodeInt) {
this.bigTypeCodeInt = bigTypeCodeInt;
}
public Integer getSmallTypeCodeInt() {
return smallTypeCodeInt;
}
public void setSmallTypeCodeInt(Integer smallTypeCodeInt) {
this.smallTypeCodeInt = smallTypeCodeInt;
}
public String getBigAndSmallCode() {
return bigAndSmallCode;
}
public void setBigAndSmallCode(String bigAndSmallCode) {
this.bigAndSmallCode = bigAndSmallCode;
}
}
spring.profiles.active=${springProfilesActive}
INSERT INTO `base_base_casetype`(
`obj_code`,
`obj_name`,
`parent_id`,
`all_code`,
`icon`,
`discript`,
`major_depart`,
`is_system`,
`sort`,
`person_name`,
`phone`,
`remarks`,
`create_by`,
`create_date`,
`update_by`,
`update_date`,
`del_flag`,
`verison`,
`is_use`,
`business_type_id`,
`level`,
`case_type`
)
VALUES (
'${bigTypeCode}', -- 大类编码,自己取⼀个
'${bigTypeName}', -- 修改你的大类名称
'',
'',
'',
'',
NULL,
'',
NULL,
'',
'',
NULL,
NULL,
NULL,
NULL,
NULL,
'0',
NULL,
NULL,
NULL,
'2',
'${caseType}' -- 1:事件,2:部件
);
INSERT INTO `base_base_casetype`(
`obj_code`,
`obj_name`,
`parent_id`,
`all_code`,
`icon`,
`discript`,
`major_depart`,
`is_system`,
`sort`,
`person_name`,
`phone`,
`remarks`,
`create_by`,
`create_date`,
`update_by`,
`update_date`,
`del_flag`,
`verison`,
`is_use`,
`business_type_id`,
`level`,
`case_type`
)
VALUES (
'${smallTypeCode}', -- ⼩类编码,自己取一个
'${smallTypeName}', -- 修改你的⼩类
'${bigTypeCode}', -- 大类的 id
'',
'',
'',
NULL,
'',
NULL,
'',
'',
NULL,
NULL,
NULL,
NULL,
NULL,
'0',
NULL,
NULL,
NULL,
'3',
'${caseType}' -- 1:事件,2:部件
);
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论