| | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.io.FileUtil; |
| | | import cn.hutool.core.net.URLEncodeUtil; |
| | | import cn.hutool.extra.spring.SpringUtil; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.deepoove.poi.XWPFTemplate; |
| | | import com.deepoove.poi.config.Configure; |
| | | import com.deepoove.poi.config.ConfigureBuilder; |
| | |
| | | import com.product.print.config.CmnConst; |
| | | import com.product.print.service.ide.IPrintRealizeService; |
| | | import com.product.print.util.DynamicTableRenderPolicy; |
| | | import com.product.tool.flow.service.FlowDetailService; |
| | | import com.product.util.BaseUtil; |
| | | |
| | | import com.product.util.SystemParamReplace; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | if (fieldSetEntity == null || StringUtils.isEmpty(fieldSetEntity.getString(CmnConst.PRINT_TEMPLATE))) { |
| | | throw new BaseException(CmnCode.PRINT_CONFIG_NOT_EXIST.getValue(), CmnCode.PRINT_CONFIG_NOT_EXIST.getText()); |
| | | } |
| | | |
| | | return fieldSetEntity; |
| | | } |
| | | |
| | |
| | | * @throws BaseException 异常 |
| | | */ |
| | | private String replaceTemplateFileOut(FieldSetEntity printConf, FieldSetEntity fse, boolean isConvertPdf) throws BaseException { |
| | | |
| | | Object[] fields = fse.getFields(); |
| | | for (int i = 0; i < fields.length; i++) { |
| | | String field = fields[i].toString(); |
| | | FieldSetEntity metaEntity = fse.getMeta().getFieldMeta(field); |
| | | String fieldType = metaEntity.getString("field_type"); |
| | | //判断是否拥有流程标识 |
| | | if ("flowsign".equals(fieldType)) { |
| | | if (StringUtils.equalsAny(fse.getString(field), "1", "2")) { |
| | | //流程办理中或办结 获取流程意见 |
| | | FieldSetEntity flowTask = getBaseDao().getFieldSetByFilter("product_sys_flow_task", "table_name=? and record_uuid=?", new Object[]{fse.getTableName(), fse.getUUID()}, false); |
| | | if (flowTask != null) { |
| | | String taskUuid = flowTask.getString(CmnConst.UUID); |
| | | //获取流程意见 |
| | | FlowDetailService flowDetailService = SpringUtil.getBean(FlowDetailService.class); |
| | | JSONArray opinion = flowDetailService.getHistoryInfo(taskUuid); |
| | | fse.setValue("~flow_opinion~", opinion); |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | |
| | | // 打印模板附件uuid |
| | | String template_uuid = printConf.getString(CmnConst.PRINT_TEMPLATE); |
| | | // 获取打印模板 |
| | |
| | | String localTempPathWord = Global.getSystemConfig("temp.dir", "") + File.separator + "temp_print_" + tempKey + ".docx"; |
| | | replaceWord(localTempPathWord, file.getPath(), fse); |
| | | file.delete(); |
| | | |
| | | String replaceParams = SystemParamReplace.replaceParams(printConf.getString(CmnConst.PRINT_FILE_NAME), fse); |
| | | printConf.setValue(CmnConst.PRINT_FILE_NAME, replaceParams); |
| | | if (isConvertPdf) { |
| | | try { |
| | | // 替换后的pdf临时路径 |
| | |
| | | * @param dataFse 替换数据 |
| | | */ |
| | | public static void replaceWord(String outPath, String templatePath, FieldSetEntity dataFse) { |
| | | JSONArray flowOpinion = (JSONArray) dataFse.getObject("~flow_opinion~"); |
| | | if (flowOpinion != null) { |
| | | dataFse.remove("~flow_opinion~"); |
| | | } |
| | | //转换数据为复选框 |
| | | dataConvertCheckedData(dataFse); |
| | | //克隆一份values |
| | |
| | | config.bind(entry.getKey(), new DynamicTableRenderPolicy(entry.getKey())); |
| | | } |
| | | } |
| | | if(flowOpinion!=null && flowOpinion.size()>0){ |
| | | cloneValues.put("lx_flow_opinion", flowOpinion); |
| | | config.bind("lx_flow_opinion", new DynamicTableRenderPolicy("lx_flow_opinion")); |
| | | } |
| | | try { |
| | | //检查输出文件是否存在,不存在则创建 |
| | | FileUtil.touch(outPath); |