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

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

上级 39b278fd
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;
import com.loit.common.utils.file.FileUtils;
import com.loit.common.utils.freemarker.FreeMarkerUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.entity.ContentType;
import org.springframework.mock.web.MockMultipartFile;
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;
@Slf4j
public class GeneratorCommandManualScript {
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 {
String filePathStr = "F:\\9Git140\\loit-build-common\\loit-build-component\\loit-build-deploy-env\\src\\main\\resources\\井盖大小类扩展20230516.xlsx";
File pdfFile = new File(filePathStr);
FileInputStream fileInputStream = new FileInputStream(pdfFile);
MultipartFile multipartFile = new MockMultipartFile(pdfFile.getName(), pdfFile.getName(),
ContentType.APPLICATION_OCTET_STREAM.toString(), fileInputStream);
ImportExcel ei = new ImportExcel(multipartFile, 2, 0);
List<CommandManualDTO> commandManualDTOList = ei.getDataList(CommandManualDTO.class);
if (ListUtil.isEmpty(commandManualDTOList)) {
return;
}
List<CommandManualDTO> transformList = transform(commandManualDTOList);
createBigTypeScript(transformList);
} catch (Exception 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);
}
resultList.add(commandManual);
String atype = commandManual.getAtype();
if (StringUtils.isEmpty(commandManual.getBtype())) {
commandManual.setBtype(atype);
}
if (StringUtils.isEmpty(commandManual.getCtype())) {
commandManual.setCtype(atype);
}
}
return resultList;
}
/**
* 生成大类脚本
*
* @throws IOException
*/
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);
System.out.println("test");
}
}
package com.loit.common.langfang.dto;
import com.loit.common.utils.excel.annotation.ExcelField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
@ApiModel(value = "CommandManualDTO", description = "管理手册DTO")
public class CommandManualDTO implements Serializable {
private static final long serialVersionUID = -6587921299183759035L;
@ApiModelProperty(value = "大类代码")
@ExcelField(title = "大类代码", sort = 1)
private String bigTypeCode;
@ApiModelProperty(value = "大类名称")
@ExcelField(title = "大类名称", sort = 2)
private String bigTypeName;
@ApiModelProperty(value = "小类代码")
@ExcelField(title = "小类代码", sort = 3)
private String smallTypeCode;
@ApiModelProperty(value = "小类代码名称")
@ExcelField(title = "小类代码名称", sort = 4)
private String smallTypeName;
@ApiModelProperty(value = "管理问题")
@ExcelField(title = "管理问题", sort = 5)
private String manageProblem;
@ApiModelProperty(value = "a类处置时限")
@ExcelField(title = "atype", sort = 6)
private String atype;
@ApiModelProperty(value = "b类处置时限")
@ExcelField(title = "btype", sort = 7)
private String btype;
@ApiModelProperty(value = "c类处置时限")
@ExcelField(title = "ctype", sort = 8)
private String ctype;
public String getBigTypeCode() {
return bigTypeCode;
}
public void setBigTypeCode(String bigTypeCode) {
this.bigTypeCode = bigTypeCode;
}
public String getBigTypeName() {
return bigTypeName;
}
public void setBigTypeName(String bigTypeName) {
this.bigTypeName = bigTypeName;
}
public String getSmallTypeCode() {
return smallTypeCode;
}
public void setSmallTypeCode(String smallTypeCode) {
this.smallTypeCode = smallTypeCode;
}
public String getSmallTypeName() {
return smallTypeName;
}
public void setSmallTypeName(String smallTypeName) {
this.smallTypeName = smallTypeName;
}
public String getManageProblem() {
return manageProblem;
}
public void setManageProblem(String manageProblem) {
this.manageProblem = manageProblem;
}
public String getAtype() {
return atype;
}
public void setAtype(String atype) {
this.atype = atype;
}
public String getBtype() {
return btype;
}
public void setBtype(String btype) {
this.btype = btype;
}
public String getCtype() {
return ctype;
}
public void setCtype(String ctype) {
this.ctype = ctype;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论