package com.mes.hollow.controller;
|
|
|
import com.mes.hollow.entity.dto.HollowBigStorageAndDetailsDTO;
|
import com.mes.hollow.entity.dto.LisecHollowDetails;
|
import com.mes.hollow.entity.vo.HollowBigStorageDetailsQueryVO;
|
import com.mes.hollow.service.HollowBigStorageCageService;
|
import com.mes.utils.Blank;
|
import com.mes.utils.Result;
|
import freemarker.template.Configuration;
|
import freemarker.template.Template;
|
import freemarker.template.TemplateException;
|
import freemarker.template.Version;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.core.io.FileSystemResource;
|
import org.springframework.http.ResponseEntity;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import javax.annotation.Resource;
|
import java.io.*;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* (HollowBigStorageCage)表控制层
|
*
|
* @author makejava
|
* @since 2024-11-21 09:22:39
|
*/
|
@Api(tags = "中空理片笼详情")
|
@RestController
|
@RequestMapping("hollowBigStorageCage")
|
public class HollowBigStorageCageController {
|
@Resource
|
HollowBigStorageCageService hollowBigStorageCageService;
|
|
@ApiOperation("按照查询条件(设备id、流程卡、膜系)获取设备对应的笼子玻璃信息")
|
@PostMapping("/queryHollowBigStorageCageDetail")
|
public Result<List<HollowBigStorageAndDetailsDTO>> queryHollowBigStorageCageDetail(@RequestBody HollowBigStorageDetailsQueryVO query) {
|
return Result.build(200, "查询成功", hollowBigStorageCageService.queryHollowBigStorageCageDetail(query));
|
}
|
|
@PostMapping("/generate")
|
public ResponseEntity<FileSystemResource> generate(@RequestBody LisecHollowDetails details) throws IOException, TemplateException {
|
// 创建和配置Freemarker配置实例
|
Configuration cfg = new Configuration(new Version("2.3.29"));
|
cfg.setClassForTemplateLoading(HollowBigStorageCageController.class, "/templates/");
|
// 创建Calculator实例
|
Blank blank = new Blank();
|
|
// 创建数据模型
|
Map<String, Object> root = new HashMap<>();
|
root.put("blank", blank);
|
|
root.put("details", details);
|
|
// 获取模板
|
Template temp = cfg.getTemplate("hollowGlass.ftl");
|
|
|
// 将生成的文件存入指定路径
|
//todo:计算生成李赛克需要的数据给到每个属性
|
StringWriter out = new StringWriter();
|
File file = new File("D:\\temp", "temp.trf");
|
try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
|
temp.process(root, out);
|
writer.write(out.toString());
|
} catch (TemplateException | IOException e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
}
|