提交 6c56f13b authored 作者: chenshiying's avatar chenshiying

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

上级 0d7dfbd6
...@@ -24,9 +24,15 @@ import java.util.stream.Collectors; ...@@ -24,9 +24,15 @@ import java.util.stream.Collectors;
@Slf4j @Slf4j
public class GeneratorCommandManualScript { public class GeneratorCommandManualScript {
private static Logger logger = LoggerFactory.getLogger(GeneratorCommandManualScript.class); private static Logger logger = LoggerFactory.getLogger(GeneratorCommandManualScript.class);
public static final String CASE_TYPE = "1"; //TODO 1:事件,2:部件
public static final String CASE_TYPE = "2";
//TODO 大类id 需要手动设置下,后面可以改成查询数据库
public static final String BIG_TYPE_ID = "344";
protected static String root_path = "F:\\9Git140\\loit-build-common\\loit-build-component\\loit-build-deploy-env\\src\\main\\resources\\langfang"; protected static String root_path = "F:\\9Git140\\loit-build-common\\loit-build-component\\loit-build-deploy-env\\src\\main\\resources\\langfang";
...@@ -55,82 +61,13 @@ public class GeneratorCommandManualScript { ...@@ -55,82 +61,13 @@ public class GeneratorCommandManualScript {
createSmallTypeScript(transformList); createSmallTypeScript(transformList);
createManageProblemScript(transformList); createManageProblemScript(transformList);
createManageProblemSmallTypeScript(transformList);
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }
} }
/**
* 对excel中的数据做转换:
* 1、去除空数据
* 2、填充大类小类
* 3、填充A类B类C类处置时限一样的
* 4、
*/
private static List<CommandManualDTO> transform(List<CommandManualDTO> commandManualDTOList) {
String bigTypeCode = null;
String bigTypeName = null;
String smallTypeCode = null;
String smallTypeName = null;
List<CommandManualDTO> resultList = new ArrayList();
for (CommandManualDTO commandManual : commandManualDTOList) {
if (StringUtils.isEmpty(commandManual.getManageProblem())) {
continue;
}
if (StringUtils.isNotEmpty(commandManual.getBigTypeCode())) {
bigTypeCode = commandManual.getBigTypeCode();
} else {
commandManual.setBigTypeCode(bigTypeCode);
}
if (StringUtils.isNotEmpty(commandManual.getBigTypeName())) {
bigTypeName = commandManual.getBigTypeName();
} else {
commandManual.setBigTypeName(bigTypeName);
}
if (StringUtils.isNotEmpty(commandManual.getSmallTypeCode())) {
smallTypeCode = commandManual.getSmallTypeCode();
} else {
commandManual.setSmallTypeCode(smallTypeCode);
}
if (StringUtils.isNotEmpty(commandManual.getSmallTypeName())) {
smallTypeName = commandManual.getSmallTypeName();
} else {
commandManual.setSmallTypeName(smallTypeName);
}
String atype = commandManual.getAtype();
if (StringUtils.isEmpty(commandManual.getBtype())) {
commandManual.setBtype(atype);
}
if (StringUtils.isEmpty(commandManual.getCtype())) {
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;
}
/** /**
* 生成大类脚本 * 生成大类脚本
...@@ -151,13 +88,21 @@ public class GeneratorCommandManualScript { ...@@ -151,13 +88,21 @@ public class GeneratorCommandManualScript {
for (CommandManualDTO commandManualDTO : bitTypeList) { for (CommandManualDTO commandManualDTO : bitTypeList) {
String sql1 = "select * from base_base_casetype order by parent_id asc;\n";
String sql2 = "select * from base_base_casetype where obj_name = '" + commandManualDTO.getBigTypeName() + "';\n";
Map model = new HashMap(); Map model = new HashMap();
model.put("bigTypeCode", commandManualDTO.getBigTypeCode()); model.put("bigTypeCode", commandManualDTO.getBigTypeCode());
model.put("bigTypeName", commandManualDTO.getBigTypeName()); model.put("bigTypeName", commandManualDTO.getBigTypeName());
model.put("caseType", CASE_TYPE); model.put("caseType", CASE_TYPE);
String configFilePath = root_path + "\\bigTypeScript.sql";
String configFilePath = root_path + "\\1、bigTypeScript.sql";
String jobConfig = FreeMarkerUtils.process("langfang" + "\\bigTypeScript.ftl", model); String jobConfig = FreeMarkerUtils.process("langfang" + "\\bigTypeScript.ftl", model);
FileUtils.append(configFilePath, sql1);
FileUtils.append(configFilePath, sql2);
FileUtils.append(configFilePath, jobConfig); FileUtils.append(configFilePath, jobConfig);
} }
} }
...@@ -181,8 +126,15 @@ public class GeneratorCommandManualScript { ...@@ -181,8 +126,15 @@ public class GeneratorCommandManualScript {
smallTypeList.sort(Comparator.comparing(CommandManualDTO::getBigTypeCodeInt) smallTypeList.sort(Comparator.comparing(CommandManualDTO::getBigTypeCodeInt)
.thenComparing(CommandManualDTO::getSmallTypeCodeInt)); .thenComparing(CommandManualDTO::getSmallTypeCodeInt));
String configFilePath = root_path + "\\2、smallTypeScript.sql";
CommandManualDTO commandManual = smallTypeList.get(0);
String sql = "select * from base_base_casetype where parent_id = '" + commandManual.getBigTypeCode() + "';\n";
FileUtils.append(configFilePath, sql);
for (CommandManualDTO commandManualDTO : smallTypeList) { for (CommandManualDTO commandManualDTO : smallTypeList) {
Map model = new HashMap(); Map model = new HashMap();
model.put("bigTypeId", commandManualDTO.getBigTypeId());
model.put("bigTypeCode", commandManualDTO.getBigTypeCode()); model.put("bigTypeCode", commandManualDTO.getBigTypeCode());
model.put("bigTypeName", commandManualDTO.getBigTypeName()); model.put("bigTypeName", commandManualDTO.getBigTypeName());
model.put("smallTypeCode", commandManualDTO.getSmallTypeCode()); model.put("smallTypeCode", commandManualDTO.getSmallTypeCode());
...@@ -190,7 +142,7 @@ public class GeneratorCommandManualScript { ...@@ -190,7 +142,7 @@ public class GeneratorCommandManualScript {
model.put("caseType", CASE_TYPE); model.put("caseType", CASE_TYPE);
String configFilePath = root_path + "\\smallTypeScript.sql";
String jobConfig = FreeMarkerUtils.process("langfang" + "\\smallTypeScript.ftl", model); String jobConfig = FreeMarkerUtils.process("langfang" + "\\smallTypeScript.ftl", model);
FileUtils.append(configFilePath, jobConfig); FileUtils.append(configFilePath, jobConfig);
} }
...@@ -213,6 +165,7 @@ public class GeneratorCommandManualScript { ...@@ -213,6 +165,7 @@ public class GeneratorCommandManualScript {
for (CommandManualDTO commandManualDTO : commandManualList) { for (CommandManualDTO commandManualDTO : commandManualList) {
Map model = new HashMap(); Map model = new HashMap();
model.put("bigTypeId", commandManualDTO.getBigTypeId());
model.put("bigTypeCode", commandManualDTO.getBigTypeCode()); model.put("bigTypeCode", commandManualDTO.getBigTypeCode());
model.put("bigTypeName", commandManualDTO.getBigTypeName()); model.put("bigTypeName", commandManualDTO.getBigTypeName());
model.put("smallTypeCode", commandManualDTO.getSmallTypeCode()); model.put("smallTypeCode", commandManualDTO.getSmallTypeCode());
...@@ -234,13 +187,44 @@ public class GeneratorCommandManualScript { ...@@ -234,13 +187,44 @@ public class GeneratorCommandManualScript {
model.put("climit", climitUnit.getLimit()); model.put("climit", climitUnit.getLimit());
model.put("cunit", climitUnit.getUnit()); model.put("cunit", climitUnit.getUnit());
String configFilePath = root_path + "\\manageProblemScript.sql"; String configFilePath = root_path + "\\3、manageProblemScript.sql";
String jobConfig = FreeMarkerUtils.process("langfang" + "\\manageProblemScript.ftl", model); String jobConfig = FreeMarkerUtils.process("langfang" + "\\manageProblemScript.ftl", model);
FileUtils.append(configFilePath, jobConfig); FileUtils.append(configFilePath, jobConfig);
} }
} }
/**
* 生成管理问题脚本-清洗小类id
*
* @throws IOException
*/
private static void createManageProblemSmallTypeScript(List<CommandManualDTO> commandManualList) {
if (commandManualList == null || commandManualList.isEmpty()) {
return;
}
for (CommandManualDTO commandManualDTO : commandManualList) {
Map model = new HashMap();
model.put("bigTypeId", commandManualDTO.getBigTypeId());
model.put("bigTypeCode", commandManualDTO.getBigTypeCode());
model.put("bigTypeName", commandManualDTO.getBigTypeName());
model.put("smallTypeCode", commandManualDTO.getSmallTypeCode());
model.put("smallTypeName", commandManualDTO.getSmallTypeName());
model.put("manageProblem", commandManualDTO.getManageProblem());
String configFilePath = root_path + "\\4、manageProblem_smallTypeId_Script.sql";
String jobConfig = FreeMarkerUtils.process("langfang" + "\\manageProblem_smallTypeId_Script.ftl", model);
FileUtils.append(configFilePath, jobConfig);
}
}
private static LimitUnitType getLimitUnit(String limitStr) { private static LimitUnitType getLimitUnit(String limitStr) {
LimitUnitType limitUnitType = new LimitUnitType(); LimitUnitType limitUnitType = new LimitUnitType();
...@@ -270,4 +254,84 @@ public class GeneratorCommandManualScript { ...@@ -270,4 +254,84 @@ public class GeneratorCommandManualScript {
return limitUnitType; return limitUnitType;
} }
/**
* 对excel中的数据做转换:
* 1、去除空数据
* 2、填充大类小类
* 3、填充A类B类C类处置时限一样的
* 4、
*/
private static List<CommandManualDTO> transform(List<CommandManualDTO> commandManualDTOList) {
String bigTypeCode = null;
String bigTypeName = null;
String smallTypeCode = null;
String smallTypeName = null;
List<CommandManualDTO> resultList = new ArrayList();
for (CommandManualDTO commandManual : commandManualDTOList) {
if (StringUtils.isEmpty(commandManual.getManageProblem())) {
continue;
}
if (StringUtils.isNotEmpty(commandManual.getBigTypeCode())) {
bigTypeCode = commandManual.getBigTypeCode();
} else {
commandManual.setBigTypeCode(bigTypeCode);
}
if (StringUtils.isNotEmpty(commandManual.getBigTypeName())) {
bigTypeName = commandManual.getBigTypeName();
} else {
commandManual.setBigTypeName(bigTypeName);
}
if (StringUtils.isNotEmpty(commandManual.getSmallTypeCode())) {
smallTypeCode = commandManual.getSmallTypeCode();
} else {
commandManual.setSmallTypeCode(smallTypeCode);
}
if (StringUtils.isNotEmpty(commandManual.getSmallTypeName())) {
smallTypeName = commandManual.getSmallTypeName();
} else {
commandManual.setSmallTypeName(smallTypeName);
}
String atype = commandManual.getAtype();
if (StringUtils.isEmpty(commandManual.getBtype())) {
commandManual.setBtype(atype);
}
if (StringUtils.isEmpty(commandManual.getCtype())) {
commandManual.setCtype(atype);
}
commandManual.setBigAndSmallCode(commandManual.getBigTypeCode() + "|" + commandManual.getSmallTypeCode());
commandManual.setBigTypeCodeInt(Integer.valueOf(commandManual.getBigTypeCode()));
commandManual.setSmallTypeCodeInt(Integer.valueOf(commandManual.getSmallTypeCode()));
//TODO 查询从数据库查询
commandManual.setBigTypeId(BIG_TYPE_ID);
resultList.add(commandManual);
}
return resultList;
}
} }
...@@ -12,6 +12,13 @@ public class CommandManualDTO implements Serializable { ...@@ -12,6 +12,13 @@ public class CommandManualDTO implements Serializable {
private static final long serialVersionUID = -6587921299183759035L; private static final long serialVersionUID = -6587921299183759035L;
/**
* 大类ID
*/
private String bigTypeId;
@ApiModelProperty(value = "大类代码") @ApiModelProperty(value = "大类代码")
@ExcelField(title = "大类代码", sort = 1) @ExcelField(title = "大类代码", sort = 1)
private String bigTypeCode; private String bigTypeCode;
...@@ -66,6 +73,14 @@ public class CommandManualDTO implements Serializable { ...@@ -66,6 +73,14 @@ public class CommandManualDTO implements Serializable {
private String bigAndSmallCode; private String bigAndSmallCode;
public String getBigTypeId() {
return bigTypeId;
}
public void setBigTypeId(String bigTypeId) {
this.bigTypeId = bigTypeId;
}
public String getBigTypeCode() { public String getBigTypeCode() {
return bigTypeCode; return bigTypeCode;
} }
......
...@@ -42,15 +42,15 @@ INSERT INTO `digital_command_manual`( ...@@ -42,15 +42,15 @@ INSERT INTO `digital_command_manual`(
`update_time` `update_time`
) )
VALUES ( VALUES (
'1', '${caseType}',
NULL, NULL,
NULL, NULL,
'${bigTypeName}', -- 你的大类 '${bigTypeName}', -- 你的大类
'${bigTypeCode}', -- 大类的编码 '${bigTypeId}', -- 大类的编码
'${smallTypeName}', -- 你的小类 '${smallTypeName}', -- 你的小类
'${smallTypeCode}', -- 小类的编码 NULL, -- 小类的编码 先设置为null 后面用脚本刷小类id
NULL, NULL,
'施工过程中或者施工堆料未采取有效防尘措施造成扬尘现象', -- 管理问题 '${manageProblem}', -- 管理问题
${alimit}, -- A 类处置时限 ${alimit}, -- A 类处置时限
${aunit}, -- 0:工作日,1:工作时, 2:紧急工作时 ${aunit}, -- 0:工作日,1:工作时, 2:紧急工作时
${blimit}, -- B 类处置时限 ${blimit}, -- B 类处置时限
......
update digital_command_manual
set small_type_id = (select casetype.id from base_base_casetype casetype where casetype.parent_id = '${bigTypeId}' and obj_name= '${smallTypeName}')
where big_type = '${bigTypeName}' and small_type = '${smallTypeName}' and manage_problem = '${manageProblem}';
...@@ -25,7 +25,7 @@ INSERT INTO `base_base_casetype`( ...@@ -25,7 +25,7 @@ INSERT INTO `base_base_casetype`(
VALUES ( VALUES (
'${smallTypeCode}', -- 小类编码,自己取一个 '${smallTypeCode}', -- 小类编码,自己取一个
'${smallTypeName}', -- 修改你的小类 '${smallTypeName}', -- 修改你的小类
'${bigTypeCode}', -- 大类的 id '${bigTypeId}', -- 大类的 id
'', '',
'', '',
'', '',
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论