Merge branch 'dev_third_stage'
# Conflicts: # jero-web/src/common/lang/en-us.js # jero-web/src/common/lang/zh-cn.js
This commit is contained in:
+170
@@ -0,0 +1,170 @@
|
||||
package com.jero.modules.docTranslation.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.system.query.QueryGenerator;
|
||||
import com.jero.modules.docTranslation.entity.DocTranslationEO;
|
||||
import com.jero.modules.docTranslation.service.IDocTranslationEOService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.jero.common.system.base.controller.JeroController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import com.jero.common.aspect.annotation.AutoLog;
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 文档翻译表
|
||||
* @Author: jero-boot
|
||||
* @Date: 2022-07-20
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags="文档翻译表")
|
||||
@RestController
|
||||
@RequestMapping("/docTranslation/docTranslationEO")
|
||||
@Slf4j
|
||||
public class DocTranslationEOController extends JeroController<DocTranslationEO, IDocTranslationEOService> {
|
||||
@Autowired
|
||||
private IDocTranslationEOService docTranslationEOService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param docTranslationEO
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "文档翻译表-分页列表查询")
|
||||
@ApiOperation(value="文档翻译表-分页列表查询", notes="文档翻译表-分页列表查询")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<?> queryPageList(DocTranslationEO docTranslationEO,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<DocTranslationEO> queryWrapper = QueryGenerator.initQueryWrapper(docTranslationEO, req.getParameterMap());
|
||||
Page<DocTranslationEO> page = new Page<DocTranslationEO>(pageNo, pageSize);
|
||||
IPage<DocTranslationEO> pageList = docTranslationEOService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "文档翻译表-列表查询")
|
||||
@ApiOperation(value="文档翻译表-列表查询", notes="文档翻译表-列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<List<DocTranslationEO>> queryList() {
|
||||
List<DocTranslationEO> list = docTranslationEOService.queryList();
|
||||
return Result.OK(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param docTranslationEO
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "文档翻译表-添加")
|
||||
@ApiOperation(value="文档翻译表-添加", notes="文档翻译表-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<?> add(@Validated @RequestBody DocTranslationEO docTranslationEO) {
|
||||
docTranslationEOService.add(docTranslationEO);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param docTranslationEO
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "文档翻译表-编辑")
|
||||
@ApiOperation(value="文档翻译表-编辑", notes="文档翻译表-编辑")
|
||||
@PutMapping(value = "/edit")
|
||||
public Result<?> edit(@Validated @RequestBody DocTranslationEO docTranslationEO) {
|
||||
docTranslationEOService.editById(docTranslationEO);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "文档翻译表-通过id删除")
|
||||
@ApiOperation(value="文档翻译表-通过id删除", notes="文档翻译表-通过id删除")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
|
||||
docTranslationEOService.deleteById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "文档翻译表-批量删除")
|
||||
@ApiOperation(value="文档翻译表-批量删除", notes="文档翻译表-批量删除")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.docTranslationEOService.deleteByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "文档翻译表-通过id查询")
|
||||
@ApiOperation(value="文档翻译表-通过id查询", notes="文档翻译表-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
DocTranslationEO docTranslationEO = docTranslationEOService.queryById(id);
|
||||
if(docTranslationEO==null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(docTranslationEO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param docTranslationEO
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, DocTranslationEO docTranslationEO) {
|
||||
return super.exportXls(request, docTranslationEO, DocTranslationEO.class, "文档翻译表");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, DocTranslationEO.class);
|
||||
}
|
||||
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
package com.jero.modules.docTranslation.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.math.BigDecimal;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import com.jero.common.aspect.annotation.Dict;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 文档翻译表
|
||||
* @Author: jero-boot
|
||||
* @Date: 2022-07-20
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("doc_translation")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="doc_translation对象", description="文档翻译表")
|
||||
public class DocTranslationEO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**主键*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "主键")
|
||||
private java.lang.String id;
|
||||
|
||||
/**创建人*/
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private java.lang.String createBy;
|
||||
|
||||
/**创建日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "创建日期")
|
||||
private java.util.Date createTime;
|
||||
|
||||
/**更新人*/
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private java.lang.String updateBy;
|
||||
|
||||
/**更新日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "更新日期")
|
||||
private java.util.Date updateTime;
|
||||
|
||||
/**所属部门*/
|
||||
@ApiModelProperty(value = "所属部门")
|
||||
private java.lang.String sysOrgCode;
|
||||
|
||||
/**文档库id*/
|
||||
@Excel(name = "文档库id", width = 15)
|
||||
@ApiModelProperty(value = "文档库id")
|
||||
private java.lang.String bussDocumentLibraryId;
|
||||
|
||||
/**文本状态*/
|
||||
@Excel(name = "文本状态", width = 15)
|
||||
@ApiModelProperty(value = "文本状态")
|
||||
private java.lang.String textStatus;
|
||||
|
||||
/**文件名称*/
|
||||
@Excel(name = "文件名称", width = 15)
|
||||
@ApiModelProperty(value = "文件名称")
|
||||
private java.lang.String fileName;
|
||||
|
||||
/**翻译前语言(源语言)*/
|
||||
@Excel(name = "翻译前语言(源语言)", width = 15)
|
||||
@ApiModelProperty(value = "翻译前语言(源语言)")
|
||||
private java.lang.String sourceLanguage;
|
||||
|
||||
/**翻译后语言(目标语言)*/
|
||||
@Excel(name = "翻译后语言(目标语言)", width = 15)
|
||||
@ApiModelProperty(value = "翻译后语言(目标语言)")
|
||||
private java.lang.String targetLanguage;
|
||||
|
||||
/**翻译结果*/
|
||||
@Excel(name = "翻译结果", width = 15)
|
||||
@ApiModelProperty(value = "翻译结果")
|
||||
private java.lang.String translationResult;
|
||||
|
||||
/**转换时间*/
|
||||
@Excel(name = "转换时间", width = 15, format = "yyyy-MM-dd")
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "转换时间")
|
||||
private java.util.Date translationTime;
|
||||
|
||||
/**发布情况*/
|
||||
@Excel(name = "发布情况", width = 15)
|
||||
@ApiModelProperty(value = "发布情况")
|
||||
private java.lang.String releaseCondition;
|
||||
|
||||
/**源文件id*/
|
||||
@Excel(name = "源文件id", width = 15)
|
||||
@ApiModelProperty(value = "源文件id")
|
||||
private java.lang.String sourceFileId;
|
||||
|
||||
/**目标文件id*/
|
||||
@Excel(name = "目标文件id", width = 15)
|
||||
@ApiModelProperty(value = "目标文件id")
|
||||
private java.lang.String targetFileId;
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.jero.modules.docTranslation.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.jero.modules.docTranslation.entity.DocTranslationEO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 文档翻译表
|
||||
* @Author: jero-boot
|
||||
* @Date: 2022-07-20
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface DocTranslationEOMapper extends BaseMapper<DocTranslationEO> {
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.jero.modules.docTranslation.mapper.DocTranslationEOMapper">
|
||||
<resultMap id="DocTranslationEOResultMap" type="com.jero.modules.docTranslation.entity.DocTranslationEO">
|
||||
<id column="id" property="id" />
|
||||
<result column="create_by" property="createBy" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="update_by" property="updateBy" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
<result column="sys_org_code" property="sysOrgCode" />
|
||||
<result column="buss_document_library_id" property="bussDocumentLibraryId" />
|
||||
<result column="text_status" property="textStatus" />
|
||||
<result column="file_name" property="fileName" />
|
||||
<result column="source_language" property="sourceLanguage" />
|
||||
<result column="target_language" property="targetLanguage" />
|
||||
<result column="translation_result" property="translationResult" />
|
||||
<result column="translation_time" property="translationTime" />
|
||||
<result column="release_condition" property="releaseCondition" />
|
||||
<result column="source_file_id" property="sourceFileId" />
|
||||
<result column="target_file_id" property="targetFileId" />
|
||||
</resultMap>
|
||||
</mapper>
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
package com.jero.modules.docTranslation.service;
|
||||
|
||||
import com.jero.modules.docTranslation.entity.DocTranslationEO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 文档翻译表
|
||||
* @Author: jero-boot
|
||||
* @Date: 2022-07-20
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface IDocTranslationEOService extends IService<DocTranslationEO> {
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param docTranslationEO
|
||||
* @return
|
||||
*/
|
||||
void add(DocTranslationEO docTranslationEO);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param docTranslationEO
|
||||
* @return
|
||||
*/
|
||||
void editById(DocTranslationEO docTranslationEO);
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
void deleteById(String id);
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
void deleteByIds(List<String> ids);
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
DocTranslationEO queryById(String id);
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<DocTranslationEO> queryList();
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
package com.jero.modules.docTranslation.service.impl;
|
||||
|
||||
import com.jero.modules.docTranslation.entity.DocTranslationEO;
|
||||
import com.jero.modules.docTranslation.mapper.DocTranslationEOMapper;
|
||||
import com.jero.modules.docTranslation.service.IDocTranslationEOService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
/**
|
||||
* @Description: 文档翻译表
|
||||
* @Author: jero-boot
|
||||
* @Date: 2022-07-20
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class DocTranslationEOServiceImpl extends ServiceImpl<DocTranslationEOMapper, DocTranslationEO> implements IDocTranslationEOService {
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param docTranslationEO
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void add(DocTranslationEO docTranslationEO) {
|
||||
Date now = new Date();
|
||||
docTranslationEO.setCreateTime(now);
|
||||
docTranslationEO.setUpdateTime(now);
|
||||
save(docTranslationEO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param docTranslationEO
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void editById(DocTranslationEO docTranslationEO) {
|
||||
Date now = new Date();
|
||||
docTranslationEO.setUpdateTime(now);
|
||||
saveOrUpdate(docTranslationEO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void deleteById(String id) {
|
||||
removeById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void deleteByIds(List<String> ids) {
|
||||
removeByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public DocTranslationEO queryById(String id) {
|
||||
return getById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<DocTranslationEO> queryList() {
|
||||
return list();
|
||||
}
|
||||
}
|
||||
+27
-6
@@ -9,11 +9,10 @@ import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Map;
|
||||
|
||||
@Api(tags="法规符合性看板")
|
||||
@@ -27,8 +26,8 @@ public class LawsComplianceBoardController {
|
||||
|
||||
@AutoLog(value = "项目库-法规符合性看板列表分页查询")
|
||||
@ApiOperation(value="项目库-法规符合性看板列表分页查询", notes="项目库-法规符合性看板列表分页查询")
|
||||
@GetMapping(value = "/page")
|
||||
public JSONObject queryPageList(@RequestParam Map<String,Object> params){
|
||||
@PostMapping(value = "/page")
|
||||
public JSONObject queryPageList(@RequestBody Map<String,Object> params){
|
||||
IPage infoPage = this.lawsComplianceBoardService.queryPageList(params);
|
||||
Result<IPage> ok = Result.OK(infoPage);
|
||||
JSONObject jsonResult = JSONObject.fromObject(ok);
|
||||
@@ -42,4 +41,26 @@ public class LawsComplianceBoardController {
|
||||
JSONObject result = this.lawsComplianceBoardService.queryComplianceResultList(params);
|
||||
return Result.OK(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出符合性结果
|
||||
* @param response
|
||||
* @param request
|
||||
* @param params
|
||||
*/
|
||||
@RequestMapping(value = "/exportComplianceResult")
|
||||
public void exportComplianceResult(HttpServletResponse response, HttpServletRequest request,@RequestParam Map<String,Object> params){
|
||||
this.lawsComplianceBoardService.exportComplianceResult(response,request,params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出符合性结果明细
|
||||
* @param response
|
||||
* @param request
|
||||
* @param params
|
||||
*/
|
||||
@RequestMapping(value = "/exportComplianceResultDetail")
|
||||
public void exportComplianceResultDetail(HttpServletResponse response, HttpServletRequest request,@RequestParam Map<String,Object> params){
|
||||
this.lawsComplianceBoardService.exportComplianceResultDetail(response,request,params);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-1
@@ -8,7 +8,7 @@ import java.util.Map;
|
||||
|
||||
public interface LawsComplianceBoardMapper {
|
||||
/**
|
||||
* 查询出 启动过 设计、prehomo、验证符合性、法规技术评估、法规意见收集其中一个流程 的数据
|
||||
* 分页查询出 启动过 设计、prehomo、验证符合性、法规技术评估、法规意见收集其中一个流程 的数据
|
||||
* @param page
|
||||
* @param params
|
||||
* @return
|
||||
@@ -21,4 +21,11 @@ public interface LawsComplianceBoardMapper {
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> queryComplianceResultList(@Param("params") Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 查询出 启动过 设计、prehomo、验证符合性、法规技术评估、法规意见收集其中一个流程 的数据列表
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> queryList(@Param("params") Map<String, Object> params);
|
||||
}
|
||||
|
||||
+43
-6
@@ -38,7 +38,7 @@
|
||||
pyni.year_name as "yearName",
|
||||
pti.design_status as "designStatus",
|
||||
pti.design_p_id as "designPId",
|
||||
pti.prehomo_status as "prehomoStatsu",
|
||||
pti.prehomo_status as "prehomoStatus",
|
||||
pti.prehomo_p_id as "prehomoPId",
|
||||
pti.verify_status as "verifyStatus",
|
||||
pti.verify_p_id as "verifyPId",
|
||||
@@ -50,16 +50,53 @@
|
||||
LEFT JOIN project_name_info pni ON ( pni.id = plb.project_name_id )
|
||||
LEFT JOIN project_year_name_info pyni ON ( pyni.id = plb.year_name_id )
|
||||
WHERE
|
||||
pli.stand_id = #{params.id}
|
||||
AND( pti.design_p_id IS NOT NULL OR pti.prehomo_p_id IS NOT NULL OR pti.verify_p_id IS NOT NULL )
|
||||
<if test="params.dutyTerritory != null params.dutyTerritory != '' ">
|
||||
1=1
|
||||
<if test="params.id != null and params.id != null">
|
||||
and pli.stand_id = #{params.id}
|
||||
</if>
|
||||
and ( pti.design_p_id is not null or pti.prehomo_p_id is not null or pti.verify_p_id is not null )
|
||||
<if test="params.dutyTerritory != '' and params.dutyTerritory != null ">
|
||||
and pli.duty_territory like CONCAT(CONCAT('%',#{params.dutyTerritory}),'%')
|
||||
</if>
|
||||
<if test="params.projectNameId != null params.projectNameId != '' ">
|
||||
<if test="params.projectNameId != '' and params.projectNameId != null ">
|
||||
and pni.id like CONCAT(CONCAT('%',#{params.projectNameId}),'%')
|
||||
</if>
|
||||
<if test="params.projectName != null params.projectName != '' ">
|
||||
<if test="params.projectName != '' and params.projectName != null ">
|
||||
and pni.project_name like CONCAT(CONCAT('%',#{params.projectName}),'%')
|
||||
</if>
|
||||
<if test="params.idList != null">
|
||||
and pli.stand_id in
|
||||
<foreach collection="params.idList" index="index" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
order by pli.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="queryList" resultType="hashMap">
|
||||
SELECT
|
||||
bdl.id as "id",
|
||||
bdl.serial_number as "serialNumber",
|
||||
bdl.title as "title",
|
||||
bdl.technology_territory as "technologyTerritory",
|
||||
bdl.state as "state",
|
||||
bdl.create_time as "createTime"
|
||||
FROM
|
||||
buss_document_library bdl
|
||||
LEFT JOIN project_laws_inventory pli ON ( pli.stand_id = bdl.id )
|
||||
LEFT JOIN project_task_inventory pti ON ( pli.id = pti.project_laws_inventory_id )
|
||||
WHERE
|
||||
(
|
||||
bdl.id IN ( SELECT DISTINCT stand_id FROM laws_opinion_gather)
|
||||
OR bdl.id IN ( SELECT DISTINCT stand_id FROM laws_technology_evaluation)
|
||||
or pti.design_p_id IS NOT NULL
|
||||
OR pti.prehomo_p_id IS NOT NULL
|
||||
OR pti.verify_p_id IS NOT NULL
|
||||
)
|
||||
<if test="params.condition != '' ">
|
||||
${params.condition}
|
||||
</if>
|
||||
GROUP BY bdl.id
|
||||
order by bdl.create_time desc
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
+26
@@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ILawsComplianceBoardService {
|
||||
@@ -15,4 +18,27 @@ public interface ILawsComplianceBoardService {
|
||||
* @return
|
||||
*/
|
||||
JSONObject queryComplianceResultList(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 导出符合性结果
|
||||
* @param response
|
||||
* @param request
|
||||
* @param params
|
||||
*/
|
||||
void exportComplianceResult(HttpServletResponse response, HttpServletRequest request, Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 导出符合性结果明细
|
||||
* @param response
|
||||
* @param request
|
||||
* @param params
|
||||
*/
|
||||
void exportComplianceResultDetail(HttpServletResponse response, HttpServletRequest request, Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 法规符合性列表数据处理
|
||||
* @param datas
|
||||
* @param cut
|
||||
*/
|
||||
void disposeData(List datas,String cut);
|
||||
}
|
||||
|
||||
+456
-13
@@ -3,6 +3,9 @@ package com.jero.modules.project.service.impl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jero.common.constant.enums.CutEnum;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.query.QueryRuleEnum;
|
||||
import com.jero.modules.document.enums.FieldTypeEnum;
|
||||
import com.jero.modules.document.service.IBussDocumentLibraryEOService;
|
||||
import com.jero.modules.document.vo.QueryConditionVO;
|
||||
@@ -10,20 +13,32 @@ import com.jero.modules.lawsOpinionGather.entity.LawsOpinionGatherEO;
|
||||
import com.jero.modules.lawsOpinionGather.service.ILawsOpinionGatherEOService;
|
||||
import com.jero.modules.lawsTechnologyEvaluation.entity.LawsTechnologyEvaluationEO;
|
||||
import com.jero.modules.lawsTechnologyEvaluation.service.ILawsTechnologyEvaluationEOService;
|
||||
import com.jero.modules.project.enums.DesignComplianceStatusEnum;
|
||||
import com.jero.modules.project.mapper.LawsComplianceBoardMapper;
|
||||
import com.jero.modules.project.service.ILawsComplianceBoardService;
|
||||
import com.jero.modules.system.entity.SysCategory;
|
||||
import com.jero.modules.system.entity.SysDictItem;
|
||||
import com.jero.modules.system.service.ISysDictItemService;
|
||||
import com.jero.modules.system.service.impl.SysCategoryServiceImpl;
|
||||
import com.jero.modules.system.service.impl.SysDictItemServiceImpl;
|
||||
import com.jero.modules.system.util.StringUtils;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Transactional(value = "transactionManager", readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
|
||||
@@ -37,11 +52,18 @@ public class LawsComplianceBoardServiceImpl implements ILawsComplianceBoardServi
|
||||
private ILawsTechnologyEvaluationEOService lawsTechnologyEvaluationEOService;
|
||||
@Autowired
|
||||
private IBussDocumentLibraryEOService bussDocumentLibraryEOService;
|
||||
@Autowired
|
||||
private SysDictItemServiceImpl sysDictItemServiceImpl;
|
||||
@Autowired
|
||||
private SysCategoryServiceImpl sysCategoryService;
|
||||
@Autowired
|
||||
private ISysDictItemService sysDictItemService;
|
||||
|
||||
@Override
|
||||
public IPage queryPageList(Map<String, Object> params) {
|
||||
int pageNo = Integer.parseInt(params.get("pageNo").toString());
|
||||
int pageSize = Integer.parseInt(params.get("pageSize").toString());
|
||||
String cut = (String) params.get("cut");
|
||||
|
||||
//封装查询条件(包含高级搜索)
|
||||
String condition = this.getConditionStr(params);
|
||||
@@ -49,14 +71,58 @@ public class LawsComplianceBoardServiceImpl implements ILawsComplianceBoardServi
|
||||
IPage page = new Page(pageNo, pageSize);
|
||||
IPage infoPage = this.lawsComplianceBoardMapper.queryPageList(page, params);
|
||||
List records = infoPage.getRecords();
|
||||
this.disposeData(records);
|
||||
this.disposeData(records,cut);
|
||||
return infoPage;
|
||||
}
|
||||
|
||||
public void disposeData(List datas){
|
||||
@Override
|
||||
public void disposeData(List datas, String cut){
|
||||
if (CollectionUtils.isNotEmpty(datas)) {
|
||||
//获取数据字典
|
||||
List<SysDictItem> sysDictItems = sysDictItemServiceImpl.selectItemsAll();
|
||||
//树形数据字典
|
||||
List<SysCategory> technologyTerritoryList = sysCategoryService.list();
|
||||
|
||||
List<SysDictItem> stateSysDictItems = sysDictItems.stream().filter(sysDictItem -> {
|
||||
boolean flag = false;
|
||||
if (StringUtils.equals(sysDictItem.getDictCode(), "state")) {
|
||||
flag = true;
|
||||
}
|
||||
return flag;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
for (Object data : datas) {
|
||||
Map<String,Object> dataMap = (Map<String, Object>) data;
|
||||
dataMap.entrySet().forEach(map -> {
|
||||
if(map.getValue() == null){
|
||||
map.setValue("");
|
||||
}
|
||||
});
|
||||
if(dataMap.get("state") != null){
|
||||
String state_dicText = "";
|
||||
if(StringUtils.equals(cut,CutEnum.CN.getValue())){
|
||||
state_dicText = stateSysDictItems.stream().filter(sysDictItem -> {
|
||||
boolean flag = false;
|
||||
if(StringUtils.equals(dataMap.get("state").toString(),sysDictItem.getItemValue())){
|
||||
flag = true;
|
||||
}
|
||||
return flag;
|
||||
}).map(SysDictItem::getItemText).distinct().collect(Collectors.joining(","));
|
||||
}else {
|
||||
state_dicText = stateSysDictItems.stream().filter(sysDictItem -> {
|
||||
boolean flag = false;
|
||||
if(StringUtils.equals(dataMap.get("state").toString(),sysDictItem.getItemValue())){
|
||||
flag = true;
|
||||
}
|
||||
return flag;
|
||||
}).map(SysDictItem::getEnName).distinct().collect(Collectors.joining(","));
|
||||
}
|
||||
dataMap.put("state_dicText",state_dicText);
|
||||
}
|
||||
if(dataMap.get("technologyTerritory") != null){
|
||||
String technologyTerritory_dictText = disposeTechnologyTerritory(technologyTerritoryList, dataMap.get("technologyTerritory").toString(), cut);
|
||||
dataMap.put("technologyTerritory_dicText",technologyTerritory_dictText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,8 +132,9 @@ public class LawsComplianceBoardServiceImpl implements ILawsComplianceBoardServi
|
||||
JSONObject result = new JSONObject();
|
||||
String id = (String) params.get("id");
|
||||
String cut = (String) params.get("cut");
|
||||
List<Map<String,Object>> cmplianceResultList = this.lawsComplianceBoardMapper.queryComplianceResultList(params);
|
||||
result.put("cmplianceResultList",cmplianceResultList);
|
||||
List<Map<String,Object>> complianceResultList = this.lawsComplianceBoardMapper.queryComplianceResultList(params);
|
||||
this.disposeComplianceResult(complianceResultList,cut);
|
||||
result.put("complianceResultList",complianceResultList);
|
||||
|
||||
//查询当前数据是否有法规意见收集流程数据
|
||||
QueryWrapper<LawsOpinionGatherEO> opinionGatherEOQueryWrapper = new QueryWrapper<>();
|
||||
@@ -83,6 +150,258 @@ public class LawsComplianceBoardServiceImpl implements ILawsComplianceBoardServi
|
||||
return result;
|
||||
}
|
||||
|
||||
public void disposeComplianceResult(List<Map<String,Object>> complianceResultList,String cut){
|
||||
if(CollectionUtils.isNotEmpty(complianceResultList)){
|
||||
List<SysDictItem> dutyTerritoryDictItemList = sysDictItemService.selectItemsByDictCode("duty_territory");
|
||||
for (Map<String, Object> complianceResult : complianceResultList) {
|
||||
if (complianceResult.get("designStatus") != null) {
|
||||
String textByValue = DesignComplianceStatusEnum.getTextByValue(complianceResult.get("designStatus").toString(), cut);
|
||||
complianceResult.put("designStatus_dicText",textByValue);
|
||||
}
|
||||
if (complianceResult.get("prehomoStatus") != null && complianceResult.get("prehomoStatus") != "") {
|
||||
String textByValue = DesignComplianceStatusEnum.getTextByValue(complianceResult.get("prehomoStatus").toString(), cut);
|
||||
complianceResult.put("prehomoStatus_dicText",textByValue);
|
||||
}
|
||||
if (complianceResult.get("verifyStatus") != null) {
|
||||
String textByValue = DesignComplianceStatusEnum.getTextByValue(complianceResult.get("verifyStatus").toString(), cut);
|
||||
complianceResult.put("verifyStatus_dicText",textByValue);
|
||||
}
|
||||
if (complianceResult.get("dutyTerritory") != null) {
|
||||
String dutyTerritory_dicText = "";
|
||||
if (CutEnum.EN.getValue().equals(cut)) {
|
||||
dutyTerritory_dicText = dutyTerritoryDictItemList.stream().filter(dictItem -> {
|
||||
boolean flag = false;
|
||||
String[] dutyTerritoryArr = complianceResult.get("dutyTerritory").toString().split(",");
|
||||
for (String duty : dutyTerritoryArr) {
|
||||
if(StringUtils.equals(dictItem.getItemValue(),duty)){
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}).map(SysDictItem::getEnName).collect(Collectors.joining(","));
|
||||
} else {
|
||||
dutyTerritory_dicText = dutyTerritoryDictItemList.stream().filter(dictItem -> {
|
||||
boolean flag = false;
|
||||
String[] dutyTerritoryArr = complianceResult.get("dutyTerritory").toString().split(",");
|
||||
for (String duty : dutyTerritoryArr) {
|
||||
if(StringUtils.equals(dictItem.getItemValue(),duty)){
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}).map(SysDictItem::getItemText).collect(Collectors.joining(","));
|
||||
}
|
||||
complianceResult.put("dutyTerritory_dicText",dutyTerritory_dicText);
|
||||
}
|
||||
|
||||
Map<String,Object> dataMap = (Map<String, Object>) complianceResult;
|
||||
dataMap.entrySet().forEach(map -> {
|
||||
if(map.getValue() == null){
|
||||
map.setValue("");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportComplianceResult(HttpServletResponse response, HttpServletRequest request, Map<String, Object> params) {
|
||||
String cut = (String) params.get("cut");
|
||||
String exportAll = (String) params.get("exportAll");
|
||||
String condition = this.getConditionStr(params);
|
||||
params.put("condition",StringUtils.isNotEmpty(condition) ? condition : "");
|
||||
List<Map<String,Object>> exportData = new ArrayList<>();
|
||||
if(StringUtils.equals(exportAll,"no")){
|
||||
IPage page = this.queryPageList(params);
|
||||
exportData = page.getRecords();
|
||||
}else {
|
||||
exportData = this.lawsComplianceBoardMapper.queryList(params);
|
||||
}
|
||||
this.disposeData(exportData,cut);
|
||||
if(CollectionUtils.isNotEmpty(exportData)){
|
||||
List<String> idList = new ArrayList<>();
|
||||
exportData.forEach(data -> {
|
||||
idList.add(data.get("id").toString());
|
||||
});
|
||||
params.put("idList",idList);
|
||||
List<Map<String,Object>> complianceResultList = new ArrayList<>();
|
||||
if(CollectionUtils.isNotEmpty(idList)){
|
||||
complianceResultList = this.lawsComplianceBoardMapper.queryComplianceResultList(params);
|
||||
this.disposeComplianceResult(complianceResultList,cut);
|
||||
}
|
||||
|
||||
String title = "";
|
||||
String fileName = "";
|
||||
if(StringUtils.equals(cut, CutEnum.CN.getValue())){
|
||||
title = "编号,标题,状态,技术领域,责任领域,相关项目,设计符合性,Pre-Homo确认,验证符合性";
|
||||
fileName = "符合性结果" + ".xlsx";
|
||||
}else if(StringUtils.equals(cut,CutEnum.EN.getValue())){
|
||||
title = "Serial number,Title,State,Technology territory,Responsible Field,Relevant project,Design conformance,Pre-Homo Confirm,Verify conformance";
|
||||
fileName = "Compliance results" + ".xlsx";
|
||||
}
|
||||
OutputStream os = null;
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
|
||||
try {
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment; filename=" + fileName);
|
||||
response.setContentType("application/force-download");
|
||||
|
||||
HSSFSheet sheet = workbook.createSheet("sheet1");
|
||||
|
||||
CellStyle titleCellStyle = workbook.createCellStyle();
|
||||
titleCellStyle.setAlignment(HorizontalAlignment.CENTER);//垂直居中
|
||||
titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//水平居中
|
||||
titleCellStyle.setWrapText(true);//自动换行
|
||||
|
||||
//创建表头
|
||||
String[] firstLineTitleArr = title.split(",");
|
||||
Row firstRow = sheet.createRow(0);
|
||||
|
||||
//设置居中、表头值。
|
||||
for (int i = 0; i < firstLineTitleArr.length; i++){
|
||||
sheet.setColumnWidth(i,5000);
|
||||
Cell cell = firstRow.createCell(i);
|
||||
cell.setCellStyle(titleCellStyle);
|
||||
cell.setCellValue(firstLineTitleArr[i]);
|
||||
}
|
||||
|
||||
//设置导出数据
|
||||
if(CollectionUtils.isNotEmpty(exportData)) {
|
||||
int rowIndex = 1;
|
||||
for (int dataIndex = 0; dataIndex < exportData.size(); dataIndex++) {
|
||||
|
||||
List<Map<String, Object>> byStandIdcomplianceResultList = new ArrayList<>();
|
||||
if(CollectionUtils.isNotEmpty(complianceResultList)){
|
||||
for (Map<String, Object> comlianceResult : complianceResultList) {
|
||||
if (StringUtils.equals(comlianceResult.get("standId").toString(), exportData.get(dataIndex).get("id").toString())) {
|
||||
byStandIdcomplianceResultList.add(comlianceResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(CollectionUtils.isNotEmpty(byStandIdcomplianceResultList)){
|
||||
int byStandIdComlianceResultSize = byStandIdcomplianceResultList.size();
|
||||
for (int i=0; i<byStandIdComlianceResultSize; i++){
|
||||
Row dataRow = sheet.createRow(rowIndex);
|
||||
dataRow.createCell(0).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("serialNumber")));
|
||||
dataRow.createCell(1).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("title")));
|
||||
dataRow.createCell(2).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("state_dicText")));
|
||||
dataRow.createCell(3).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("technologyTerritory_dicText")));
|
||||
|
||||
dataRow.createCell(4).setCellValue(checkValueIsNotNull(byStandIdcomplianceResultList.get(i).get("dutyTerritory_dicText")));
|
||||
String projectName = checkValueIsNotNull(byStandIdcomplianceResultList.get(i).get("projectName")) + "-" + checkValueIsNotNull(byStandIdcomplianceResultList.get(i).get("yearName"));
|
||||
dataRow.createCell(5).setCellValue(projectName);
|
||||
dataRow.createCell(6).setCellValue(checkValueIsNotNull(byStandIdcomplianceResultList.get(i).get("designStatus_dicText")));
|
||||
dataRow.createCell(7).setCellValue(checkValueIsNotNull(byStandIdcomplianceResultList.get(i).get("prehomoStatus_dicText")));
|
||||
dataRow.createCell(8).setCellValue(checkValueIsNotNull(byStandIdcomplianceResultList.get(i).get("verifyStatus_dicText")));
|
||||
if(byStandIdComlianceResultSize > 1 && i != (byStandIdComlianceResultSize - 1)){
|
||||
rowIndex ++;
|
||||
}
|
||||
}
|
||||
}else {
|
||||
Row dataRow = sheet.createRow(rowIndex);
|
||||
dataRow.createCell(0).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("serialNumber")));
|
||||
dataRow.createCell(1).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("title")));
|
||||
dataRow.createCell(2).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("state_dicText")));
|
||||
dataRow.createCell(3).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("technologyTerritory_dicText")));
|
||||
}
|
||||
rowIndex ++;
|
||||
}
|
||||
}
|
||||
os = response.getOutputStream();
|
||||
workbook.write(os);
|
||||
os.flush();
|
||||
}catch (IOException ex){
|
||||
if(CutEnum.CN.getValue().equals(cut)){
|
||||
throw new JeroBootException("下载文件失败");
|
||||
}else{
|
||||
throw new JeroBootException("Failed to download file");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证值是否是null
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public String checkValueIsNotNull(Object str){
|
||||
String result = "";
|
||||
if(str != null){
|
||||
result = str.toString();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportComplianceResultDetail(HttpServletResponse response, HttpServletRequest request, Map<String, Object> params) {
|
||||
String cut = (String) params.get("cut");
|
||||
List<Map<String,Object>> exportData = this.lawsComplianceBoardMapper.queryComplianceResultList(params);
|
||||
this.disposeComplianceResult(exportData,cut);
|
||||
if(CollectionUtils.isNotEmpty(exportData)){
|
||||
String title = "";
|
||||
String fileName = "";
|
||||
if(StringUtils.equals(cut, CutEnum.CN.getValue())){
|
||||
title = "责任领域,相关项目,设计符合性,Pre-Homo确认,验证符合性";
|
||||
fileName = "符合性结果" + ".xlsx";
|
||||
}else if(StringUtils.equals(cut,CutEnum.EN.getValue())){
|
||||
title = "Responsible Field,Relevant project,Design conformance,Pre-Homo Confirm,Verify conformance";
|
||||
fileName = "Compliance results" + ".xlsx";
|
||||
}
|
||||
OutputStream os = null;
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
|
||||
try {
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment; filename=" + fileName);
|
||||
response.setContentType("application/force-download");
|
||||
|
||||
HSSFSheet sheet = workbook.createSheet("sheet1");
|
||||
|
||||
CellStyle titleCellStyle = workbook.createCellStyle();
|
||||
titleCellStyle.setAlignment(HorizontalAlignment.CENTER);//垂直居中
|
||||
titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//水平居中
|
||||
titleCellStyle.setWrapText(true);//自动换行
|
||||
|
||||
//创建表头
|
||||
String[] firstLineTitleArr = title.split(",");
|
||||
Row firstRow = sheet.createRow(0);
|
||||
|
||||
//设置居中、表头值。
|
||||
for (int i = 0; i < firstLineTitleArr.length; i++){
|
||||
sheet.setColumnWidth(i,5000);
|
||||
Cell cell = firstRow.createCell(i);
|
||||
cell.setCellStyle(titleCellStyle);
|
||||
cell.setCellValue(firstLineTitleArr[i]);
|
||||
}
|
||||
|
||||
//设置导出数据
|
||||
if(CollectionUtils.isNotEmpty(exportData)) {
|
||||
int rowIndex = 1;
|
||||
for (int dataIndex = 0; dataIndex < exportData.size(); dataIndex++) {
|
||||
Row dataRow = sheet.createRow(rowIndex);
|
||||
dataRow.createCell(0).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("dutyTerritory_dicText")));
|
||||
dataRow.createCell(1).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("projectName")));
|
||||
dataRow.createCell(2).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("designStatus_dicText")));
|
||||
dataRow.createCell(3).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("prehomoStatus_dicText")));
|
||||
dataRow.createCell(4).setCellValue(checkValueIsNotNull(exportData.get(dataIndex).get("verifyStatus_dicText")));
|
||||
rowIndex ++;
|
||||
}
|
||||
}
|
||||
os = response.getOutputStream();
|
||||
workbook.write(os);
|
||||
os.flush();
|
||||
}catch (IOException ex){
|
||||
if(CutEnum.CN.getValue().equals(cut)){
|
||||
throw new JeroBootException("下载文件失败");
|
||||
}else{
|
||||
throw new JeroBootException("Failed to download file");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public String getConditionStr(Map<String, Object> parameter) {
|
||||
@@ -113,7 +432,7 @@ public class LawsComplianceBoardServiceImpl implements ILawsComplianceBoardServi
|
||||
if (value.contains("%")) {
|
||||
value = value.replace("%", "/%");
|
||||
}
|
||||
conditionSb.append(" and " + key + " like concat(concat('%','" + value + "'),'%') ESCAPE '/'");
|
||||
conditionSb.append(" and bdl." + key + " like concat(concat('%','" + value + "'),'%') ESCAPE '/'");
|
||||
} else if (FieldTypeEnum.PULL_SINGLE.getValue().equals(fieldType)
|
||||
|| FieldTypeEnum.PULL_MORE.getValue().equals(fieldType)
|
||||
|| FieldTypeEnum.TREE.getValue().equals(fieldType)) {
|
||||
@@ -121,27 +440,27 @@ public class LawsComplianceBoardServiceImpl implements ILawsComplianceBoardServi
|
||||
StringBuilder condition = new StringBuilder();
|
||||
for (String valueTemp : value.split(",")) {
|
||||
valueSb.append("'" + valueTemp + "',");
|
||||
condition.append(" or " + key + " like concat(concat('%','" + valueTemp + "'),'%')");
|
||||
condition.append(" or bdl." + key + " like concat(concat('%','" + valueTemp + "'),'%')");
|
||||
}
|
||||
condition.append(")");
|
||||
String substring = valueSb.substring(0, valueSb.length() - 1);
|
||||
//下拉单选或下拉多选
|
||||
conditionSb.append(" and (" + key + " in(" + substring + ")" + condition.toString());
|
||||
conditionSb.append(" and (bdl." + key + " in(" + substring + ")" + condition.toString());
|
||||
|
||||
} else if (FieldTypeEnum.DATE_SINGLE.getValue().equals(fieldType)) {
|
||||
//日期(区分单日期还时间范围)
|
||||
if (value.contains(",")) {
|
||||
conditionSb.append(" and " + "date_format(" + key + ",'%Y-%m-%d') >= '" + value.split(",")[0] + "'"
|
||||
conditionSb.append(" and " + "date_format(bdl." + key + ",'%Y-%m-%d') >= '" + value.split(",")[0] + "'"
|
||||
+ " and " + "date_format(" + key + ",'%Y-%m-%d') <= '" + value.split(",")[1] + "'");
|
||||
} else {
|
||||
conditionSb.append(" and " + "date_format(" + key + ",'%Y-%m-%d') = '" + value + "'");
|
||||
conditionSb.append(" and " + "date_format(bdl." + key + ",'%Y-%m-%d') = '" + value + "'");
|
||||
}
|
||||
} else if (FieldTypeEnum.PERSON.getValue().equals(fieldType)) {
|
||||
//输入框 LIKE CONCAT("%", '/%', "%") ESCAPE '/'
|
||||
if (value.contains("%")) {
|
||||
value = value.replace("%", "/%");
|
||||
}
|
||||
conditionSb.append(" and " + key + " like concat(concat('%','" + value + "'),'%') ESCAPE '/'");
|
||||
conditionSb.append(" and bdl." + key + " like concat(concat('%','" + value + "'),'%') ESCAPE '/'");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -177,13 +496,26 @@ public class LawsComplianceBoardServiceImpl implements ILawsComplianceBoardServi
|
||||
String queryConditionVOListStr = (String) parameter.get("queryConditionVOList");
|
||||
List<QueryConditionVO> queryConditionVOList = com.alibaba.fastjson.JSONObject.parseArray(queryConditionVOListStr, QueryConditionVO.class);
|
||||
if(ObjectUtils.isNotEmpty(queryConditionVOList)){
|
||||
String queryCondition = this.bussDocumentLibraryEOService.sqlJoint(queryConditionVOList);
|
||||
String queryCondition = this.sqlJoint(queryConditionVOList);
|
||||
if(StringUtils.isNotBlank(queryCondition)){
|
||||
conditionSb.append(" and " + queryCondition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String ids = (String) parameter.get("ids");
|
||||
if(StringUtils.isNotEmpty(ids)){
|
||||
List<String> idList = Arrays.asList(ids.split(","));
|
||||
String idStr = "";
|
||||
for (String id : idList) {
|
||||
idStr += "'"+id+"',";
|
||||
}
|
||||
if(StringUtils.isNotEmpty(idStr)){
|
||||
idStr = idStr.substring(0,idStr.length()-1);
|
||||
conditionSb.append(" and id in("+idStr+")");
|
||||
}
|
||||
}
|
||||
|
||||
//处理列表表头排序
|
||||
/*if (StringUtils.isNotBlank((String) parameter.get("orderByField"))) {
|
||||
conditionSb.append(" order by " + (String) parameter.get("orderByField"));
|
||||
@@ -198,4 +530,115 @@ public class LawsComplianceBoardServiceImpl implements ILawsComplianceBoardServi
|
||||
String condition = conditionSb.toString();
|
||||
return condition;
|
||||
}
|
||||
|
||||
public String sqlJoint(List<QueryConditionVO> queryConditionVOList){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if(queryConditionVOList.size() != 0){
|
||||
int count =0;
|
||||
for (QueryConditionVO queryConditionVO : queryConditionVOList) {
|
||||
String type = queryConditionVO.getType();//and或or
|
||||
String rule = queryConditionVO.getRule();
|
||||
String ruleLike = "";
|
||||
if(QueryRuleEnum.LEFT_LIKE.getCondition().equals(rule) || QueryRuleEnum.RIGHT_LIKE.getCondition().equals(rule)){
|
||||
ruleLike = QueryRuleEnum.LIKE.getCondition();
|
||||
}
|
||||
String field = queryConditionVO.getField();
|
||||
String val = queryConditionVO.getVal();
|
||||
//如果查询字段对应的搜索条件值为空,则不作处理
|
||||
if(StringUtils.isNotBlank(val)) {
|
||||
field = "bdl." + field;
|
||||
count++;//从第二个查询条件开始拼接type(and或or)
|
||||
if (count > 1) {
|
||||
sb.append(" " + type + " ");
|
||||
}
|
||||
sb.append(" " + field + " ");
|
||||
//查询类型
|
||||
String ruleTemp = queryType(rule);
|
||||
if (StringUtils.isNotBlank(ruleLike)) {
|
||||
sb.append(ruleLike + " ");
|
||||
} else {
|
||||
sb.append(ruleTemp + " ");
|
||||
}
|
||||
//like和in需要特殊处理
|
||||
if (QueryRuleEnum.IN.getCondition().equals(rule)) {
|
||||
if (val.contains(",")) {
|
||||
StringBuilder sbTemp = new StringBuilder();
|
||||
for (String valTemp : val.split(",")) {
|
||||
sbTemp.append("'" + valTemp + "' ,");
|
||||
}
|
||||
if (StringUtils.isNotBlank(sbTemp)) {
|
||||
String substring = sbTemp.substring(0, sbTemp.length() - 1);
|
||||
sb.append("(" + substring + ")");
|
||||
}
|
||||
}
|
||||
sb.append("('" + val + "')");
|
||||
} else if (QueryRuleEnum.LIKE.getCondition().equals(rule)) {
|
||||
sb.append("'%" + val + "%'");
|
||||
} else if (QueryRuleEnum.LEFT_LIKE.getCondition().equals(rule)) {
|
||||
sb.append("'%" + val + "'");
|
||||
} else if (QueryRuleEnum.RIGHT_LIKE.getCondition().equals(rule)) {
|
||||
sb.append("'" + val + "%'");
|
||||
} else {
|
||||
sb.append("'" + val + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public String queryType(String rule){
|
||||
String value ="";
|
||||
if(QueryRuleEnum.GT.getCondition().equals(rule)){
|
||||
value = QueryRuleEnum.GT.getValue();
|
||||
}else if(QueryRuleEnum.GE.getCondition().equals(rule)){
|
||||
value = QueryRuleEnum.GE.getValue();
|
||||
}else if(QueryRuleEnum.LT.getCondition().equals(rule)){
|
||||
value = QueryRuleEnum.LT.getValue();
|
||||
}else if(QueryRuleEnum.LE.getCondition().equals(rule)){
|
||||
value = QueryRuleEnum.LE.getValue();
|
||||
}else if(QueryRuleEnum.EQ.getCondition().equals(rule)){
|
||||
value = QueryRuleEnum.EQ.getValue();
|
||||
}else if(QueryRuleEnum.NE.getCondition().equals(rule)){
|
||||
value = QueryRuleEnum.NE.getValue();
|
||||
}else if(QueryRuleEnum.LIKE.getCondition().equals(rule)){
|
||||
value = QueryRuleEnum.LIKE.getValue();
|
||||
}else if(QueryRuleEnum.LEFT_LIKE.getCondition().equals(rule)){
|
||||
value = QueryRuleEnum.LEFT_LIKE.getValue();
|
||||
}else if(QueryRuleEnum.RIGHT_LIKE.getCondition().equals(rule)){
|
||||
value = QueryRuleEnum.RIGHT_LIKE.getValue();
|
||||
}else if(QueryRuleEnum.IN.getCondition().equals(rule)){
|
||||
value = QueryRuleEnum.IN.getValue();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理技术领域展示字段
|
||||
* @param technologyTerritoryList
|
||||
* @param technologyTerritory
|
||||
* @param cut
|
||||
* @return
|
||||
*/
|
||||
public String disposeTechnologyTerritory(List<SysCategory> technologyTerritoryList, String technologyTerritory, String cut){
|
||||
String result = "";
|
||||
// technology_territory
|
||||
if(org.apache.commons.lang3.StringUtils.isNotEmpty(technologyTerritory)){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String technologyTerritoryId : technologyTerritory.split(",")) {
|
||||
List<SysCategory> collect = technologyTerritoryList.stream().filter(e -> e.getId().equals(technologyTerritoryId)).collect(Collectors.toList());
|
||||
if(collect.size() != 0){
|
||||
if(CutEnum.CN.getValue().equals(cut)){
|
||||
sb.append(collect.get(0).getName()+",");
|
||||
}else{
|
||||
sb.append(collect.get(0).getEnName()+",");
|
||||
}
|
||||
}
|
||||
}
|
||||
if(org.apache.commons.lang3.StringUtils.isNotEmpty(sb)){
|
||||
result = sb.substring(0, sb.length() - 1);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
+278
-23
@@ -1,14 +1,5 @@
|
||||
package com.jero.modules.project.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.docx4j.Docx4J;
|
||||
import org.docx4j.TraversalUtil;
|
||||
import org.docx4j.XmlUtils;
|
||||
@@ -20,23 +11,24 @@ import org.docx4j.finders.RangeFinder;
|
||||
import org.docx4j.fonts.IdentityPlusMapper;
|
||||
import org.docx4j.fonts.Mapper;
|
||||
import org.docx4j.fonts.PhysicalFonts;
|
||||
import org.docx4j.jaxb.Context;
|
||||
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
|
||||
import org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage;
|
||||
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
|
||||
import org.docx4j.wml.Body;
|
||||
import org.docx4j.wml.CTBookmark;
|
||||
import org.docx4j.wml.Document;
|
||||
import org.docx4j.wml.Drawing;
|
||||
import org.docx4j.wml.ObjectFactory;
|
||||
import org.docx4j.wml.P;
|
||||
import org.docx4j.wml.R;
|
||||
import org.docx4j.wml.Tbl;
|
||||
import org.docx4j.wml.Text;
|
||||
import org.docx4j.wml.Tr;
|
||||
import org.docx4j.wml.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class WordUtil {
|
||||
private static final Logger log = LoggerFactory.getLogger(WordUtil.class);
|
||||
|
||||
@@ -126,7 +118,16 @@ public class WordUtil {
|
||||
table.getContent().remove(rowNum - 1);
|
||||
}
|
||||
|
||||
public static void replacePicture(WordprocessingMLPackage wordMLPackage, String bookmarkName, InputStream inputStream) throws Exception {
|
||||
/**
|
||||
* 通过书签识别需要插入的图片位置,并替换书签对应的文本为图片
|
||||
* @param wordMLPackage
|
||||
* @param bookmarkName 书签名称
|
||||
* @param text 图片前需要加的文本
|
||||
* @param bytes 图片
|
||||
* @throws Exception
|
||||
* @author liyawei
|
||||
*/
|
||||
public static void replacePictureBM(WordprocessingMLPackage wordMLPackage, String bookmarkName, Object text, byte[] bytes) throws Exception {
|
||||
try {
|
||||
MainDocumentPart mainDocumentPart = wordMLPackage.getMainDocumentPart();
|
||||
Document wmlDoc = (Document)mainDocumentPart.getJaxbElement();
|
||||
@@ -139,23 +140,277 @@ public class WordUtil {
|
||||
while(var8.hasNext()) {
|
||||
CTBookmark bm = (CTBookmark)var8.next();
|
||||
if (bm.getName().equals(bookmarkName)) {
|
||||
byte[] bytes = IOUtils.toByteArray(inputStream);
|
||||
BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(wordMLPackage, bytes);
|
||||
Inline inline = imagePart.createImageInline("", "", 0, 1, true);
|
||||
P p = (P)((P)bm.getParent());
|
||||
ObjectFactory factory = new ObjectFactory();
|
||||
R run = factory.createR();
|
||||
Drawing drawing = factory.createDrawing();
|
||||
drawing.getAnchorOrInline().add(inline);
|
||||
run.getContent().add(drawing);
|
||||
p.getContent().add(run);
|
||||
replaceTextToImage(bm, text, wordMLPackage, bytes);
|
||||
}
|
||||
}
|
||||
} catch (Exception var17) {
|
||||
log.error(var17.getMessage(), var17);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 占位符的key 识别需要插入的图片位置,并替换占位符为图片
|
||||
* @param wordMLPackage
|
||||
* @param key 占位符的key ${key}
|
||||
* @param text 图片前需要加的文本
|
||||
* @param bytes 图片
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void replacePicture(WordprocessingMLPackage wordMLPackage, String key, Object text, byte[] bytes) throws Exception {
|
||||
try {
|
||||
MainDocumentPart mainDocumentPart = wordMLPackage.getMainDocumentPart();
|
||||
Docx4jUtils.cleanDocumentPart(mainDocumentPart);
|
||||
Document wmlDoc = (Document)mainDocumentPart.getJaxbElement();
|
||||
Body body = wmlDoc.getBody();
|
||||
Iterator var8 = getAllPlaceholderElementFromObject(body).iterator();
|
||||
|
||||
while(var8.hasNext()) {
|
||||
Text bm = (Text) var8.next();
|
||||
if (bm.getValue().equals("${" + key + "}")) {
|
||||
BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(wordMLPackage, bytes);
|
||||
Inline inline = imagePart.createImageInline("", "", 0, 1, true);
|
||||
ObjectFactory factory = new ObjectFactory();
|
||||
R run = factory.createR();
|
||||
Drawing drawing = factory.createDrawing();
|
||||
drawing.getAnchorOrInline().add(inline);
|
||||
run.getContent().add(drawing);
|
||||
replaceTextToImage(bm, text, wordMLPackage, bytes);
|
||||
}
|
||||
}
|
||||
} catch (Exception var17) {
|
||||
log.error(var17.getMessage(), var17);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 占位符的key 识别需要插入的图片位置,并替换占位符为图片
|
||||
* 批量替换
|
||||
* @param wordMLPackage
|
||||
* @param picList
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void replacePictureBatch(WordprocessingMLPackage wordMLPackage, List<Map<String, Object>> picList) throws Exception {
|
||||
try {
|
||||
MainDocumentPart mainDocumentPart = wordMLPackage.getMainDocumentPart();
|
||||
Docx4jUtils.cleanDocumentPart(mainDocumentPart);
|
||||
Document wmlDoc = (Document)mainDocumentPart.getJaxbElement();
|
||||
Body body = wmlDoc.getBody();
|
||||
List<Text> textList = getAllPlaceholderElementFromObject(body); // 获取文档中所有占位符
|
||||
|
||||
for (Map<String, Object> picMap :picList) {
|
||||
String key = (String) picMap.get("key");
|
||||
Object text = picMap.get("text");
|
||||
byte[] bytes = (byte[]) picMap.get("bytes");
|
||||
|
||||
for(Text bm : textList) {
|
||||
if (bm.getValue().equals("${" + key + "}")) {
|
||||
BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(wordMLPackage, bytes);
|
||||
Inline inline = imagePart.createImageInline("", "", 0, 1, true);
|
||||
ObjectFactory factory = new ObjectFactory();
|
||||
R run = factory.createR();
|
||||
Drawing drawing = factory.createDrawing();
|
||||
drawing.getAnchorOrInline().add(inline);
|
||||
run.getContent().add(drawing);
|
||||
replaceTextToImage(bm, text, wordMLPackage, bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception var17) {
|
||||
log.error(var17.getMessage(), var17);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 发现docx文档包含占位符的文本节点
|
||||
* 未解决问题:两个连着的相同占位符会识别成一个。如 原文:${key1}${key1}
|
||||
* @param obj
|
||||
* @return
|
||||
* @author liyawei
|
||||
*/
|
||||
private static List<Text> getAllPlaceholderElementFromObject(Object obj) {
|
||||
List<Text> result = new ArrayList<>();
|
||||
Class<Text> toSearch = Text.class;
|
||||
Text textPlaceholder;
|
||||
if (obj instanceof JAXBElement) {
|
||||
obj = ((JAXBElement<?>) obj).getValue();
|
||||
}
|
||||
if (obj.getClass().equals(toSearch)) {
|
||||
textPlaceholder = (Text) obj;
|
||||
if (isPlaceholder(textPlaceholder.getValue())) {
|
||||
result.add((Text) obj);
|
||||
}
|
||||
} else if (obj instanceof ContentAccessor) {
|
||||
List<?> children = ((ContentAccessor) obj).getContent();
|
||||
for (Object child : children) {
|
||||
result.addAll(getAllPlaceholderElementFromObject(child));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字符串是否有${}占位符
|
||||
*
|
||||
* @param str 需要判断的字符串
|
||||
* @return 是否字符串是否有${}占位符
|
||||
* @author liyawei
|
||||
*/
|
||||
private static boolean isPlaceholder(String str) {
|
||||
if (str != null && !str.isEmpty()) {
|
||||
Pattern pattern = Pattern.compile("([$]\\{[A-Za-z0-9./ -]+\\})"); // 识别范围 认证模块专用
|
||||
Matcher m = pattern.matcher(str);
|
||||
return m.find();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在标签处插入替换内容
|
||||
*
|
||||
* @param bm
|
||||
* @param object
|
||||
* @throws Exception
|
||||
* @author liyawei
|
||||
*/
|
||||
public static void replaceTextToImage(CTBookmark bm, Object object, WordprocessingMLPackage wordMLPackage , byte[] bytes) throws Exception {
|
||||
if (wordMLPackage == null) {
|
||||
return;
|
||||
}
|
||||
if (bm.getName() == null){
|
||||
return;
|
||||
}
|
||||
String text = object.toString();
|
||||
try {
|
||||
List<Object> theList = null;
|
||||
ParaRPr rpr = null;
|
||||
if (bm.getParent() instanceof P) {
|
||||
PPr pprTemp = ((P) (bm.getParent())).getPPr();
|
||||
if (pprTemp == null) {
|
||||
rpr = null;
|
||||
} else {
|
||||
rpr = ((P) (bm.getParent())).getPPr().getRPr();
|
||||
}
|
||||
theList = ((ContentAccessor) (bm.getParent())).getContent();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
int rangeStart = -1;
|
||||
int rangeEnd = -1;
|
||||
int i = 0;
|
||||
for (Object ox : theList) {
|
||||
Object listEntry = XmlUtils.unwrap(ox);
|
||||
if (listEntry.equals(bm)) {
|
||||
if (((CTBookmark) listEntry).getName() != null) {
|
||||
rangeStart = i + 1;
|
||||
}
|
||||
} else if (listEntry instanceof CTMarkupRange) {
|
||||
if (((CTMarkupRange) listEntry).getId().equals(bm.getId())) {
|
||||
rangeEnd = i - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
int x = i - 1;
|
||||
for (int j = x; j >= rangeStart; j--) {
|
||||
theList.remove(j);
|
||||
}
|
||||
|
||||
BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(wordMLPackage, bytes);
|
||||
Inline inline = imagePart.createImageInline("", "", 0, 1, true);
|
||||
ObjectFactory factory = Context.getWmlObjectFactory();
|
||||
R run = factory.createR();
|
||||
Drawing drawing = factory.createDrawing();
|
||||
if(text != null){
|
||||
Text txt = factory.createText();
|
||||
txt.setValue(text);
|
||||
run.getContent().add(txt);
|
||||
}
|
||||
run.getContent().add(drawing);
|
||||
drawing.getAnchorOrInline().add(inline);
|
||||
theList.add(rangeStart, run);
|
||||
} catch (ClassCastException cce) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 在占位符处插入替换内容
|
||||
*
|
||||
* @param bm
|
||||
* @param object
|
||||
* @throws Exception
|
||||
* @author liyawei
|
||||
*/
|
||||
public static void replaceTextToImage(Text bm, Object object, WordprocessingMLPackage wordMLPackage , byte[] bytes) throws Exception {
|
||||
if (wordMLPackage == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String text = object.toString();
|
||||
try {
|
||||
List<Object> theList = null;
|
||||
ParaRPr rpr = null;
|
||||
if (bm.getParent() instanceof P) {
|
||||
PPr pprTemp = ((P) (bm.getParent())).getPPr();
|
||||
if (pprTemp == null) {
|
||||
rpr = null;
|
||||
} else {
|
||||
rpr = ((P) (bm.getParent())).getPPr().getRPr();
|
||||
}
|
||||
theList = ((ContentAccessor) (bm.getParent())).getContent();
|
||||
} else {
|
||||
R r = (R) bm.getParent();
|
||||
if (r.getParent() instanceof P) {
|
||||
theList = ((ContentAccessor) (r.getParent())).getContent();
|
||||
|
||||
int rangeStart = -1; // 记录占位符run位置
|
||||
int i = 0;
|
||||
for (Object ox : theList) {
|
||||
Object listEntry = XmlUtils.unwrap(ox);
|
||||
if (listEntry.equals(r)) {
|
||||
rangeStart = i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
theList.remove(rangeStart); // 移除原占位符
|
||||
|
||||
BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(wordMLPackage, bytes);
|
||||
Inline inline = imagePart.createImageInline("", "", 0, 1, true);
|
||||
ObjectFactory factory = Context.getWmlObjectFactory();
|
||||
R run = factory.createR();
|
||||
Drawing drawing = factory.createDrawing();
|
||||
if(text != null){
|
||||
Text txt = factory.createText();
|
||||
txt.setValue(text);
|
||||
run.getContent().add(txt);
|
||||
}
|
||||
run.getContent().add(drawing);
|
||||
drawing.getAnchorOrInline().add(inline);
|
||||
theList.add(rangeStart, run); // 添加图片到原占位符位置
|
||||
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (ClassCastException cce) {
|
||||
log.error(cce.getMessage(), cce);
|
||||
}
|
||||
}
|
||||
|
||||
public static void replaceForTemplate(String templatePath, Map<String, String> map, int tableNum, List<Map<String, Object>> dataList, String outPath) throws Exception {
|
||||
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new File(templatePath));
|
||||
MainDocumentPart mainDocumentPart = wordMLPackage.getMainDocumentPart();
|
||||
|
||||
Reference in New Issue
Block a user