Commit 846aed0e authored by 林洋洋's avatar 林洋洋

修改工具

parent c254dd2b
......@@ -46,7 +46,7 @@ public class ExcelTools {
@Autowired
private FileTemplate fileTemplate;
private final List<String> placeholders = List.of(
private final List<String> placeholders = List.of(
"@天津智深数据.iICTS_MoQty",
"@天津智深数据.iICTS_CompletionQty",
"@天津智深数据.iICTS_OKRate",
......@@ -124,25 +124,25 @@ public class ExcelTools {
return jsonObject.toString();
}
@Tool(description = "获取天津智深DCS卡件日报",returnDirect=true)
public String getDcsFile(@ToolParam(description = "时间(yyyy-M-d)")String dateStr) {
@Tool(description = "获取天津智深DCS卡件日报")
public String getDcsFile(@ToolParam(description = "时间(yyyy-M-d)") String dateStr) {
var ref = new Object() {
String markDown = "| 产线 | 计划产量 | 实际产量 | 成品率 |\n" +
"| --- | --- | --- | --- |\n" +
"| iICTS | @天津智深数据.iICTS_MoQty | @天津智深数据.iICTS_CompletionQty | @天津智深数据.iICTS_OKRate |\n" +
"| iAS | @天津智深数据.日iAS计划数量 | @天津智深数据.iAS_CompletionQty | @天津智深数据.iAS_OKRate |\n" +
"| iSMTS | @天津智深数据.iSMTS_MoQty | @天津智深数据.iSMTS_CompletionQty | @天津智深数据.iSMTS_OKRate |\n" +
"| iDIPS | @天津智深数据.iDIPS_MoQty | @天津智深数据.iDIPS_CompletionQty | @天津智深数据.iDIPS_OKRate |\n" +
"| iFCTS | @天津智深数据.iFCTS_MoQty | @天津智深数据.iFCTS_CompletionQty | @天津智深数据.iFCTS_OKRate |\n" +
"| iCCS | @天津智深数据.iCCS_MoQty | @天津智深数据.iCCS_CompletionQty | @天津智深数据.iDIPS_OKRate |\n" +
"| iPS | @天津智深数据.iPS_MoQty | @天津智深数据.iPS_CompletionQty | \\- |\n" +
"| iBS | @天津智深数据.iBS_MoQty | @天津智深数据.iBS_CompletionQty | @天津智深数据.iBS_OKRate |\n" +
"| **总计** | @天津智深数据.今日_PlanQty | @天津智深数据.今日生产成品 | \\- |\n" +
String markDown =
"\n" +
"<p align=\"center\">\n" +
" <a href=\"fileUrl\" download>\uD83D\uDCCE 点击下载文件</a>\n" +
"</p>";
"| 产线 | 计划产量 | 实际产量 | 成品率 |\n" +
"| --- | --- | --- | --- |\n" +
"| iICTS | @天津智深数据.iICTS_MoQty | @天津智深数据.iICTS_CompletionQty | @天津智深数据.iICTS_OKRate |\n" +
"| iAS | @天津智深数据.日iAS计划数量 | @天津智深数据.iAS_CompletionQty | @天津智深数据.iAS_OKRate |\n" +
"| iSMTS | @天津智深数据.iSMTS_MoQty | @天津智深数据.iSMTS_CompletionQty | @天津智深数据.iSMTS_OKRate |\n" +
"| iDIPS | @天津智深数据.iDIPS_MoQty | @天津智深数据.iDIPS_CompletionQty | @天津智深数据.iDIPS_OKRate |\n" +
"| iFCTS | @天津智深数据.iFCTS_MoQty | @天津智深数据.iFCTS_CompletionQty | @天津智深数据.iFCTS_OKRate |\n" +
"| iCCS | @天津智深数据.iCCS_MoQty | @天津智深数据.iCCS_CompletionQty | @天津智深数据.iDIPS_OKRate |\n" +
"| iPS | @天津智深数据.iPS_MoQty | @天津智深数据.iPS_CompletionQty | \\- |\n" +
"| iBS | @天津智深数据.iBS_MoQty | @天津智深数据.iBS_CompletionQty | @天津智深数据.iBS_OKRate |\n" +
"| **总计** | @天津智深数据.今日_PlanQty | @天津智深数据.今日生产成品 | \\- |\n" +
"\n" +
"下载连接:[@fileName](@fileUrl)";
};
log.info("getDcsFile{}", dateStr);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-M-d");
......@@ -156,17 +156,19 @@ public class ExcelTools {
String fileName = UUID.randomUUID().toString().replace("-", "") + ".docx";
String originalName = String.format("dcs卡件日报(%s).docx", dateFileStr);
String url = baseUrl + "/admin/sys-file/" + bucketName + "/" + fileName + "/" + originalName;
ref.markDown = ref.markDown.replace("fileUrl",url);
Map<String, Object> paramMap = generateParamData(startTime, endTime,placeholders);
ref.markDown = ref.markDown.replace("@fileUrl", url);
ref.markDown = ref.markDown.replace("@fileName", originalName);
Map<String, Object> paramMap = generateParamData(startTime, endTime, placeholders);
log.info("入参{}", paramMap);
paramMap.forEach((key, value)->{
ref.markDown = ref.markDown.replace(key,String.valueOf(value));
paramMap.forEach((key, value) -> {
ref.markDown = ref.markDown.replace(key, String.valueOf(value));
});
boolean result = convertUtils.fillWordLoop(fileName, "dcs卡件日报模板.docx", paramMap, bucketName);
log.info("{} {}",result,ref.markDown);
if(!result){
log.info("{} {}", result, ref.markDown);
if (!result) {
return "dcs卡件日报生成失败";
}
......@@ -174,7 +176,6 @@ public class ExcelTools {
}
public Map<String, Object> generateReport(LocalDateTime startTime, LocalDateTime endTime) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("year", startTime.getYear());
......@@ -238,7 +239,7 @@ public class ExcelTools {
return paramMap;
}
public Map<String, Object> generateParamData(LocalDateTime startTime, LocalDateTime endTime,List<String> params) {
public Map<String, Object> generateParamData(LocalDateTime startTime, LocalDateTime endTime, List<String> params) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("year", startTime.getYear());
paramMap.put("month", startTime.getMonthValue());
......@@ -257,9 +258,9 @@ public class ExcelTools {
(existingValue, newValue) -> existingValue // 如果有重复的键,这里决定如何处理。这里选择保留现有的值。
));
params.forEach(param -> {
paramMap.put(param,"");
if(result.containsKey(param)){
paramMap.put(param,result.get(param));
paramMap.put(param, "");
if (result.containsKey(param)) {
paramMap.put(param, result.get(param));
}
});
......
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