parent
48596a83fb
commit
43f38b24df
@ -0,0 +1,91 @@ |
||||
package com.keyware.shandan.browser.controller; |
||||
|
||||
import com.alibaba.fastjson.JSON; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.keyware.shandan.bianmu.entity.DirectoryResource; |
||||
import com.keyware.shandan.bianmu.export.DirectoryExport; |
||||
import com.keyware.shandan.bianmu.export.ExportCache; |
||||
import com.keyware.shandan.bianmu.export.ExportProgress; |
||||
import com.keyware.shandan.bianmu.mapper.DirectoryResourceMapper; |
||||
import com.keyware.shandan.browser.entity.CustomForm; |
||||
import com.keyware.shandan.browser.entity.SearchConditionVo; |
||||
import com.keyware.shandan.browser.service.CustomFormService; |
||||
import com.keyware.shandan.common.entity.Result; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.security.core.Authentication; |
||||
import org.springframework.util.Assert; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.json.Json; |
||||
import javax.json.JsonObject; |
||||
import java.io.IOException; |
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author YaoJz |
||||
* @description |
||||
* 制式表格 控制类 |
||||
* @date 2024/4/18 17:30 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/CustomForm") |
||||
public class CustomFormController { |
||||
|
||||
@Autowired |
||||
CustomFormService customFormService; |
||||
@Autowired |
||||
private DirectoryResourceMapper directoryResourceMapper; |
||||
/** |
||||
* 创建制式表格 |
||||
* @param customForm |
||||
* @return com.keyware.shandan.common.entity.Result<java.lang.Object> |
||||
* @author YaoJz |
||||
* @date 2024/04/18 17:43 |
||||
*/ |
||||
@PostMapping("/create") |
||||
public Result<Object> createCustomForm(CustomForm customForm) { |
||||
String fieldConfig = JSON.toJSONString(customForm.getFieldList()); |
||||
customForm.setFieldConfig(fieldConfig); |
||||
return Result.of( customFormService.save(customForm)); |
||||
} |
||||
@GetMapping("/list") |
||||
public Result<Object> listCustomForm() { |
||||
return Result.of( customFormService.list()); |
||||
} |
||||
@GetMapping("/getOne/{id}") |
||||
public Result<Object> getCustomForm(@PathVariable String id) { |
||||
return Result.of( customFormService.getById(id)); |
||||
} |
||||
@PostMapping("/updata") |
||||
public Result<Object> updataCustomForm(CustomForm customForm) { |
||||
return Result.of( customFormService.updateById(customForm)); |
||||
} |
||||
@GetMapping("/delete") |
||||
public Result<Object> deleteCustomForm(@PathVariable String id) { |
||||
return Result.of( customFormService.removeById(id)); |
||||
} |
||||
@PostMapping("/export/{customFormId}") |
||||
public Result<Object> exportCustomForm(@PathVariable String customFormId, Authentication auth) { |
||||
CustomForm customForm = customFormService.getById(customFormId); |
||||
HashMap<String, String> map = new HashMap<>(); |
||||
map.put("fieldConfig",customForm.getFieldConfig()); |
||||
map.put("otherContext",customForm.getOtherContext()); |
||||
DirectoryResource resource = directoryResourceMapper.selectById(customForm.getMetaId()); |
||||
resource.setIsCustom(true); |
||||
resource.setCustomConfigMap(map); |
||||
List<DirectoryResource> directoryResourceList = new ArrayList<>(); |
||||
directoryResourceList.add(resource); |
||||
Assert.notNull(auth, "用户信息认证失败"); |
||||
String userId = auth.getPrincipal().toString(); |
||||
// 这个逻辑只允许同一个用户同时只能有一个导出任务
|
||||
ExportProgress export = ExportCache.getCache(userId, null); |
||||
if (export == null) { |
||||
// 查询数据
|
||||
export = new DirectoryExport(userId, directoryResourceList); |
||||
ExportCache.startExport(export); |
||||
} |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,43 @@ |
||||
package com.keyware.shandan.browser.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import lombok.Data; |
||||
import java.io.Serializable; |
||||
import java.util.List; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
||||
import javax.validation.constraints.NotNull; |
||||
|
||||
/** |
||||
* @author YaoJz |
||||
* @description |
||||
* @date 2024/4/18 16:59 |
||||
*/ |
||||
@Data |
||||
@TableName("CUSTOM_FORM") |
||||
public class CustomForm implements Serializable { |
||||
private static final long serialVersionUID = 7552053530616826540L; |
||||
@TableId("ID") |
||||
private Integer id; |
||||
|
||||
@NotNull |
||||
private List<CustFormFormat> fieldList; |
||||
@TableField("METAID") |
||||
@NotNull |
||||
private String metaId; |
||||
@TableField("OTHERCONTEXT") |
||||
private String otherContext; |
||||
@TableField("FORMID") |
||||
private String formId; |
||||
@TableField("FIELD_CONFIG") |
||||
private String fieldConfig; |
||||
|
||||
} |
||||
@Data |
||||
class CustFormFormat{ |
||||
private String fieldKey; |
||||
private String fieldName; |
||||
private String fieldIndex; |
||||
} |
@ -0,0 +1,15 @@ |
||||
package com.keyware.shandan.browser.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.keyware.shandan.browser.entity.CustomForm; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.springframework.stereotype.Repository; |
||||
|
||||
/** |
||||
* @author YaoJz |
||||
* @description |
||||
* @date 2024/4/18 17:41 |
||||
*/ |
||||
@Mapper |
||||
public interface CustomFormMapper extends BaseMapper<CustomForm> { |
||||
} |
@ -0,0 +1,14 @@ |
||||
package com.keyware.shandan.browser.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.keyware.shandan.browser.entity.CustomForm; |
||||
import com.keyware.shandan.common.service.IBaseService; |
||||
|
||||
/** |
||||
* @author YaoJz |
||||
* @description |
||||
* @date 2024/4/18 17:34 |
||||
*/ |
||||
public interface CustomFormService extends IService<CustomForm> { |
||||
String checkArg(CustomForm customForm); |
||||
} |
@ -0,0 +1,20 @@ |
||||
package com.keyware.shandan.browser.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.keyware.shandan.browser.entity.CustomForm; |
||||
import com.keyware.shandan.browser.mapper.CustomFormMapper; |
||||
import com.keyware.shandan.browser.service.CustomFormService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* @author YaoJz |
||||
* @description |
||||
* @date 2024/4/18 17:37 |
||||
*/ |
||||
@Service |
||||
public class CustomFormServiceImpl extends ServiceImpl<CustomFormMapper, CustomForm> implements CustomFormService { |
||||
@Override |
||||
public String checkArg(CustomForm customForm) { |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,48 @@ |
||||
#layer-content-report { |
||||
height: 100% |
||||
} |
||||
|
||||
.report-main { |
||||
display: flex; |
||||
flex-direction: column; |
||||
width: 100%; |
||||
height: 100% |
||||
} |
||||
|
||||
.report-main .report-btn-line { |
||||
display: flex; |
||||
justify-content: flex-end; |
||||
padding: 10px 20px; |
||||
} |
||||
|
||||
.sorting-item { |
||||
display: flex; |
||||
flex-direction: row; |
||||
justify-content: space-between; |
||||
padding: 5px 0 !important; |
||||
} |
||||
|
||||
.report-main .report-items { |
||||
flex-grow: 1; |
||||
display: flex; |
||||
flex-wrap: wrap; |
||||
overflow-y: overlay; |
||||
justify-content: space-around; |
||||
} |
||||
|
||||
.echarts-item { |
||||
width: 500px; |
||||
height: 40%; |
||||
padding: 0 20px; |
||||
} |
||||
.layui-elem-field{border-color: #e8e8e8 !important;} |
||||
.layui-elem-field legend { |
||||
margin-left: 20px; |
||||
padding: 0 10px; |
||||
font-size: 16px; |
||||
font-weight: 400; |
||||
color: #7d7d7d; |
||||
} |
||||
.layui-field-box { |
||||
padding: 15px 50px 15px 15px; |
||||
} |
@ -0,0 +1,113 @@ |
||||
/** |
||||
* 统计报表组件 |
||||
* |
||||
* @author GuoXin |
||||
* @since 2021/7/12 |
||||
*/ |
||||
const template_configs = ` |
||||
<div> |
||||
<div> asdsssssssasdasd</div> |
||||
<!--<table class="layui-hide" id="ID-table-demo-data"></table>--> |
||||
<table class="layui-hide" id="ID-table-demo-data" lay-filter="meta-result-table"></table> |
||||
|
||||
<div > <a class="layui-btn layui-btn-xs layui-btn-primary my-btn" name="create" |
||||
data-type="single-filed">添加条件</a></div> |
||||
</div> |
||||
`;
|
||||
|
||||
function CustomReportComponent(columns, conditions, metadataId) { |
||||
this.metadataId = metadataId || ''; |
||||
this.columns = columns || []; |
||||
this.conditions = conditions || []; |
||||
this.echarts = []; |
||||
this.size = 0; |
||||
this.formData = {}; |
||||
this.form = {}; |
||||
this.gtable = {}; |
||||
layui.use(['form','gtable'], () => { |
||||
this.gtable = layui.gtable; |
||||
this.form = layui.form; |
||||
}) |
||||
} |
||||
|
||||
function initTable(table) { |
||||
var inst = table.render({ |
||||
elem: '#ID-table-demo-data', |
||||
cols: [[ //标题栏
|
||||
{field: 'id', title: 'ID', width: 80, sort: true}, |
||||
{field: 'username', title: '名称', width: 120}, |
||||
{field: 'sign', title: '顺序', minWidth: 160} |
||||
]], |
||||
data: [{ // 赋值已知数据
|
||||
"id": "10001", |
||||
"username": "张三1", |
||||
"sex": "男", |
||||
"city": "浙江杭州", |
||||
"sign": "人生恰似一场修行", |
||||
"experience": "116" |
||||
}, { |
||||
"id": "10008", |
||||
"username": "张三8", |
||||
"sex": "男", |
||||
"city": "浙江杭州", |
||||
"sign": "人生恰似一场修行", |
||||
"experience": "106" |
||||
}], |
||||
page: false, // 是否显示分页
|
||||
limits: [5, 10, 15], |
||||
// limit: 5 // 每页默认显示的数量
|
||||
}); |
||||
|
||||
} |
||||
|
||||
function createNewTable(){ |
||||
console.log("createNewTable1") |
||||
$(`a[name='create']`).on('click', createNewTable); |
||||
} |
||||
function createTable(){ |
||||
console.log("createNewTable2") |
||||
$(`a[name='create']`).on('click', createNewTable); |
||||
} |
||||
|
||||
/** |
||||
* 打开统计报表主窗口 |
||||
*/ |
||||
CustomReportComponent.prototype.openMainLayer = function () { |
||||
const _this = this; |
||||
layer.open({ |
||||
type: 1, |
||||
title: '统计报表', |
||||
area: ['900px', '100%'], |
||||
content: template_configs, |
||||
success: function (layero, index) { |
||||
initTable(_this.gtable) |
||||
createTable() |
||||
}, |
||||
|
||||
done: function () { |
||||
} |
||||
}) |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 打开图表配置窗口 |
||||
*/ |
||||
CustomReportComponent.prototype.openEchartsConfigLayer = function () { |
||||
const _this = this; |
||||
layer.open({ |
||||
title: '统计报表配置', |
||||
type: 1, |
||||
resize: false, |
||||
closeBtn: false, |
||||
btn: ['确定', '取消'], |
||||
content: template_config, |
||||
success: function (layerObj, index) { |
||||
_this.renderSelect(); |
||||
$('#echartsConfigForm').parent().css('overflow', 'visible') |
||||
}, |
||||
yes: function (index) { |
||||
_this.requestData(() => layer.close(index)); |
||||
} |
||||
}); |
||||
} |
@ -0,0 +1,127 @@ |
||||
<!DOCTYPE html> |
||||
<html xmlns:th="http://www.thymeleaf.org" lang="zh-CN"> |
||||
<script type="text/javascript"> |
||||
|
||||
// 达梦日期类型集合 |
||||
const dm_date_types = ['DATE', 'DATETIME', 'DATETIME WITH TIME ZONE', 'TIME', 'TIMESTAMP', 'TIME WITH TIME ZONE', 'TIMESTAMP WITH TIME ZONE', 'TIMESTAMP WITH LOCAL TIME ZONE']; |
||||
// 达梦数值类型集合 |
||||
const dm_number_types = ['NUMERIC', 'NUMBER', 'DECIMAL', 'DEC', 'INTEGER', 'INT', 'PLS_INTEGER', 'BIGINT', 'TINYINT', 'BYTE', 'SMALLINT', 'FLOAT', 'DOUBLE', 'DOUBLE PRECISION']; |
||||
const common_fields = [ |
||||
{field: 'SOURCE', dataType: 'VARCHAR2', comment: '文件来源'}, |
||||
{field: 'INPUTDATE', dataType: 'DATETIME', comment: '任务时间'}, |
||||
{field: 'ENTRYSTAFF', dataType: 'VARCHAR2', comment: '录入人员'}, |
||||
{field: 'TASKNATURE', dataType: 'VARCHAR2', comment: '任务性质'}, |
||||
{field: 'TASKCODE', dataType: 'VARCHAR2', comment: '任务代号'}, |
||||
{field: 'TARGETNUMBER', dataType: 'VARCHAR2', comment: '目标/靶标类型'}, |
||||
{field: 'TROOPCODE', dataType: 'VARCHAR2', comment: '部队代号'}, |
||||
{field: 'EQUIPMENTMODEL', dataType: 'VARCHAR2', comment: '装备型号'}, |
||||
{field: 'MISSILENUMBER', dataType: 'VARCHAR2', comment: '导弹编号'}, |
||||
]; |
||||
const template_config = ` |
||||
<div class="layui-form-item">阿三顶顶顶</div>`; |
||||
const template_configs = ` |
||||
<div class="layui-form" lay-filter="echartsConfigForm" id="echartsConfigForm" style="padding:15px; padding-bottom: 0;"> |
||||
|
||||
<fieldset class="layui-elem-field"> |
||||
<legend>图表配置</legend> |
||||
<div class="layui-field-box"> |
||||
<div class="layui-form-item" style="padding:0 20px;"> |
||||
<div class="layui-form-label" style="width: 100px">标题</div> |
||||
<div class="layui-inline"> |
||||
<div class="layui-input-inline" style="width: 300px"> |
||||
<input type="text" name="title" class="layui-input" placeholder="设置图表的标题"> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<div class="layui-form-item" style="padding:0 20px;"> |
||||
<div class="layui-form-label" style="width: 100px">图表类型</div> |
||||
<div class="layui-inline"> |
||||
<div class="layui-input-inline" style="width: 300px"> |
||||
<select name="reportType" lay-filter="reportType"> |
||||
<option value="pie" selected>饼图</option> |
||||
<option value="bar">柱状图</option> |
||||
<option value="line">折线图</option> |
||||
</select> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</fieldset> |
||||
<fieldset class="layui-elem-field"> |
||||
<legend>统计维度</legend> |
||||
<div class="layui-field-box"> |
||||
<div class="layui-form-item" style="padding:0 20px;"> |
||||
<div class="layui-form-label" style="width: 100px">字段</div> |
||||
<div class="layui-inline"> |
||||
<div class="layui-input-inline" style="width: 300px"> |
||||
<input type="hidden" name="fieldXType" /> |
||||
<select name="fieldX" id="selectFieldX" lay-filter="selectFieldX"></select> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<div class="layui-form-item layui-hide" style="padding:0 20px;" id="range-date-item"> |
||||
<div class="layui-form-label" style="width: 100px">时间间隔</div> |
||||
<div class="layui-inline"> |
||||
<div class="layui-input-inline" style="width: 300px"> |
||||
<select name="dateInterval" id="dateInterval"> |
||||
<option value="" selected>选择时间间隔</option> |
||||
<option value="minute">每分钟</option> |
||||
<option value="hour">每小时</option> |
||||
<option value="day">每日</option> |
||||
<!--<option value="week">每周</option>--> |
||||
<option value="month">每月</option> |
||||
<option value="year">每年</option> |
||||
</select> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<div class="layui-form-item layui-hide" style="padding:0 20px;" id="range-number-item"> |
||||
<div class="layui-form-label" style="width: 100px">数值间隔</div> |
||||
<div class="layui-inline"> |
||||
<div class="layui-input-inline" style="width: 300px"> |
||||
<input class="layui-input" type="text" name="numberInterval" autocomplete="off" /> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</fieldset> |
||||
<fieldset class="layui-elem-field"> |
||||
<legend>统计指标</legend> |
||||
<div class="layui-field-box"> |
||||
<div class="layui-form-item" style="padding:0 20px;"> |
||||
<div class="layui-form-label" style="width: 100px">描述文本</div> |
||||
<div class="layui-inline"> |
||||
<div class="layui-input-inline" style="width: 300px"> |
||||
<input type="text" class="layui-input" name="remark" autocomplete="off" placeholder="用于生成文档报表,如:录入总数"> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<div class="layui-form-item" style="padding:0 20px;" id="field-select-item-y"> |
||||
<div class="layui-form-label" style="width: 100px">聚合字段</div> |
||||
<div class="layui-inline"> |
||||
<div class="layui-input-inline" style="width: 300px"> |
||||
<select name="fieldY" id="selectFieldY" lay-filter="selectFieldY"></select> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<div class="layui-form-item" style="padding:0 20px;"> |
||||
<div class="layui-form-label" style="width: 100px">聚合方式</div> |
||||
<div class="layui-inline"> |
||||
<div class="layui-input-inline" style="width: 300px"> |
||||
<select name="aggregationType" id="aggregationType" lay-filter="aggregationType"> |
||||
<option value="count" selected>计数</option> |
||||
<option value="sum">求和</option> |
||||
<option value="avg">平均值</option> |
||||
</select> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</fieldset> |
||||
</div>`; |
||||
</script> |
||||
<!-- echarts-5.1.2 --> |
||||
<script th:src="@{/js/customForm.js}"></script> |
||||
<script th:src="@{/js/common/echarts/echarts.min.js}"></script> |
||||
|
||||
</html> |
@ -0,0 +1,82 @@ |
||||
package com.keyware.shandan.system.utils; |
||||
|
||||
import com.aspose.words.Document; |
||||
import com.aspose.words.License; |
||||
import com.aspose.words.SaveFormat; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.core.io.ClassPathResource; |
||||
import org.springframework.core.io.Resource; |
||||
|
||||
import java.io.File; |
||||
import java.io.FileOutputStream; |
||||
import java.io.IOException; |
||||
import java.io.InputStream; |
||||
|
||||
/** |
||||
* @BelongsProject: xscan |
||||
* @BelongsPackage: com.keyware.xscan.util |
||||
* @Author: yaojz |
||||
* @CreateTime: 2022-08-05 13:59 |
||||
* @Description: TODO |
||||
* @Version: *** |
||||
*/ |
||||
public class Word2PdfAsposeUtil { |
||||
private static final Logger logger = LoggerFactory.getLogger(Word2PdfAsposeUtil.class); |
||||
/** |
||||
* |
||||
* @return |
||||
*/ |
||||
public static boolean getLicense() { |
||||
boolean result = false; |
||||
InputStream is = null; |
||||
try { |
||||
Resource resource = new ClassPathResource("Aspose.license.lic"); |
||||
is = resource.getInputStream(); |
||||
License aposeLic = new License(); |
||||
aposeLic.setLicense(is); |
||||
result = true; |
||||
} catch (Exception e) { |
||||
logger.error("获取许可证异常...",e); |
||||
} finally { |
||||
if (is != null) { |
||||
try { |
||||
is.close(); |
||||
} catch (IOException e) { |
||||
logger.error("关闭流异常...",e); |
||||
} |
||||
} |
||||
} |
||||
return result; |
||||
} |
||||
/** |
||||
* @return boolean |
||||
* @Param [inPath, outPath] |
||||
**/ |
||||
public static boolean doc2pdf(String inPath, String outPath) { |
||||
// 验证License 若不验证则转化出的pdf文档会有水印产生
|
||||
if (!getLicense()) { |
||||
return false; |
||||
} |
||||
File file = new File(outPath); |
||||
// FileOutputStream os = null;
|
||||
try(FileOutputStream osStream = new FileOutputStream(file) ) { |
||||
long old = System.currentTimeMillis(); |
||||
// 新建一个空白pdf文档
|
||||
// Address是将要被转化的word文档
|
||||
Document doc = new Document(inPath); |
||||
// 全面支持DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF,
|
||||
doc.save(osStream, SaveFormat.PDF); |
||||
osStream.flush(); |
||||
osStream.close(); |
||||
// EPUB, XPS, SWF 相互转换
|
||||
long now = System.currentTimeMillis(); |
||||
// 转化用时
|
||||
System.out.println("pdf转换成功,共耗时:" + ((now - old) / 1000.0) + "秒"); |
||||
} catch (Exception e) { |
||||
logger.error("pdf转换失败...",e); |
||||
return false; |
||||
} |
||||
return true; |
||||
} |
||||
} |
@ -0,0 +1,20 @@ |
||||
<License> |
||||
<Data> |
||||
<LicensedTo>iMedRIS Data Corporation</LicensedTo> |
||||
<EmailTo>whs@imedris.com</EmailTo> |
||||
<LicenseType>Developer OEM</LicenseType> |
||||
<LicenseNote>Limited to 1 developer, unlimited physical locations</LicenseNote> |
||||
<OrderID>190103154649</OrderID> |
||||
<UserID>289601</UserID> |
||||
<OEM>This is a redistributable license</OEM> |
||||
<Products> |
||||
<Product>Aspose.Total for Java</Product> |
||||
</Products> |
||||
<EditionType>Enterprise</EditionType> |
||||
<SerialNumber>7f645a78-5687-4fad-ab7f-9b4141651d27</SerialNumber> |
||||
<SubscriptionExpiry>20200403</SubscriptionExpiry> |
||||
<LicenseVersion>3.0</LicenseVersion> |
||||
<LicenseInstructions>https://purchase.aspose.com/policies/use-license</LicenseInstructions> |
||||
</Data> |
||||
<Signature>cqB2T9ic/d8/1ICIPO2PoYfvwQaljWeY3om8xXMo4zllu3h/xL1CbF8iFc6xk1RXXq2UOd3XKfJL9QnoRtjm3IHod2iINB+DC1lolh5GumiJkR/C8oighnumtCIDJHZyEQvyAK1oqELhTWVlLcpyXOkIwdhXDI6l4/uhptYGz3E=</Signature> |
||||
</License> |
Reference in new issue