wu
2025-01-17 959a3e15699e4547706b05f07dff190b503d2390
hangzhoumesParent/moduleService/howllowGlassModule/src/main/java/com/mes/hollow/controller/HollowBigStorageCageController.java
@@ -2,30 +2,18 @@
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.IOException;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * (HollowBigStorageCage)表控制层
@@ -44,36 +32,6 @@
    @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");
        // 合并数据模型和模板
        StringWriter out = new StringWriter();
        try {
            temp.process(root, out);
        } catch (TemplateException | IOException e) {
            e.printStackTrace();
        }
        // 输出结果
        System.out.println(out.toString());
        return null;
    }
}