|
@@ -0,0 +1,914 @@
|
|
|
|
+/*
|
|
|
|
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
|
|
|
+ *
|
|
|
|
+ * Redistribution and use in source and binary forms, with or without
|
|
|
|
+ * modification, are permitted provided that the following conditions are met:
|
|
|
|
+ *
|
|
|
|
+ * Redistributions of source code must retain the above copyright notice,
|
|
|
|
+ * this list of conditions and the following disclaimer.
|
|
|
|
+ * Redistributions in binary form must reproduce the above copyright
|
|
|
|
+ * notice, this list of conditions and the following disclaimer in the
|
|
|
|
+ * documentation and/or other materials provided with the distribution.
|
|
|
|
+ * Neither the name of the dreamlu.net developer nor the names of its
|
|
|
|
+ * contributors may be used to endorse or promote products derived from
|
|
|
|
+ * this software without specific prior written permission.
|
|
|
|
+ * Author: Chill 庄骞 (smallchill@163.com)
|
|
|
|
+ */
|
|
|
|
+package org.springblade.manager.service.impl;
|
|
|
|
+
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
+import com.mixsmart.utils.ListUtils;
|
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
|
+import org.apache.poi.ss.usermodel.*;
|
|
|
|
+import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
|
+import org.apache.poi.util.IOUtils;
|
|
|
|
+import org.jsoup.Jsoup;
|
|
|
|
+import org.jsoup.nodes.Document;
|
|
|
|
+import org.jsoup.nodes.Element;
|
|
|
|
+import org.jsoup.select.Elements;
|
|
|
|
+import org.springblade.business.dto.TrialSelfInspectionRecordDTO;
|
|
|
|
+import org.springblade.business.entity.EntrustInfo;
|
|
|
|
+import org.springblade.business.entity.TrialMaterialMobilization;
|
|
|
|
+import org.springblade.business.entity.TrialSampleInfo;
|
|
|
|
+import org.springblade.business.entity.TrialSelfInspectionRecord;
|
|
|
|
+import org.springblade.common.constant.CommonConstant;
|
|
|
|
+import org.springblade.common.utils.CommonUtil;
|
|
|
|
+import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
|
+import org.springblade.common.vo.DataVO;
|
|
|
|
+import org.springblade.core.log.exception.ServiceException;
|
|
|
|
+import org.springblade.core.oss.model.BladeFile;
|
|
|
|
+import org.springblade.core.secure.utils.AuthUtil;
|
|
|
|
+import org.springblade.core.secure.utils.SecureUtil;
|
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
|
+import org.springblade.core.tool.utils.*;
|
|
|
|
+import org.springblade.manager.bean.TableInfo;
|
|
|
|
+import org.springblade.manager.dto.ServicePlanDTO;
|
|
|
|
+import org.springblade.manager.dto.ServiceUserDto;
|
|
|
|
+import org.springblade.manager.entity.*;
|
|
|
|
+import org.springblade.manager.utils.FileUtils;
|
|
|
|
+import org.springblade.manager.vo.ServicePlanVO;
|
|
|
|
+import org.springblade.manager.mapper.ServicePlanMapper;
|
|
|
|
+import org.springblade.manager.service.IServicePlanService;
|
|
|
|
+import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
|
+import org.springblade.resource.feign.NewIOSSClient;
|
|
|
|
+import org.springblade.system.cache.ParamCache;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.boot.autoconfigure.amqp.RabbitTemplateConfigurer;
|
|
|
|
+import org.springframework.dao.DataAccessException;
|
|
|
|
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
+import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import org.springframework.transaction.TransactionDefinition;
|
|
|
|
+import org.springframework.transaction.TransactionStatus;
|
|
|
|
+import org.springframework.transaction.support.DefaultTransactionDefinition;
|
|
|
|
+
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import java.io.*;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 服务实现类
|
|
|
|
+ *
|
|
|
|
+ * @author BladeX
|
|
|
|
+ * @since 2025-06-25
|
|
|
|
+ */
|
|
|
|
+@Service
|
|
|
|
+public class ServicePlanServiceImpl extends BaseServiceImpl<ServicePlanMapper, ServicePlan> implements IServicePlanService {
|
|
|
|
+ @Resource
|
|
|
|
+ private JdbcTemplate jdbcTemplate;
|
|
|
|
+ @Autowired
|
|
|
|
+ private DataSourceTransactionManager transactionManager1;
|
|
|
|
+ @Autowired
|
|
|
|
+ private NewIOSSClient newIOSSClient;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public IPage<ServicePlanVO> selectServicePlanPage(IPage<ServicePlanVO> page, ServicePlanDTO servicePlan) {
|
|
|
|
+ servicePlan.setUserId(SecureUtil.getUserId()+"");
|
|
|
|
+ List<ServicePlan> vos = baseMapper.selectServicePlanPage(page, servicePlan);
|
|
|
|
+ List<ServicePlanVO>voList = new ArrayList<>();
|
|
|
|
+ for (ServicePlan sp : vos) {
|
|
|
|
+ ServicePlanVO vo = new ServicePlanVO();
|
|
|
|
+ BeanUtil.copyProperties(sp, vo);
|
|
|
|
+ vo.setStatusValue(vo.getStatus()==1?"计划中":vo.getStatus()==2?"确认中-甲方":vo.getStatus()==3?"反馈中-系统":"已计划");
|
|
|
|
+ vo.setIsEdit(checkIsEdit(vo));
|
|
|
|
+ if(vo.getPlanStartTime()!=null){
|
|
|
|
+ vo.setStartTime(vo.getPlanStartTime().format(DateTimeFormatter.ofPattern("yyyy年M月d日")));
|
|
|
|
+ }
|
|
|
|
+ if(vo.getPlanEndTime()!=null){
|
|
|
|
+ vo.setEndTime(vo.getPlanEndTime().format(DateTimeFormatter.ofPattern("yyyy年M月d日")));
|
|
|
|
+ }
|
|
|
|
+ if(StringUtils.isNotEmpty(vo.getStartTime())&&StringUtils.isNotEmpty(vo.getEndTime())){
|
|
|
|
+ vo.setPlanTime(vo.getStartTime()+"至"+vo.getEndTime());
|
|
|
|
+ }
|
|
|
|
+ vo.setWriteUserName(slectUserName(vo.getWriteUser()));
|
|
|
|
+ vo.setSendUserName(slectUserName(vo.getSendUser()));
|
|
|
|
+ voList.add(vo);
|
|
|
|
+ }
|
|
|
|
+ return page.setRecords(voList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private String slectUserName(String sendUser) {
|
|
|
|
+ if(StringUtils.isNotEmpty(sendUser)){
|
|
|
|
+ String sql="select real_name from blade_user where id in("+sendUser+")";
|
|
|
|
+ List<String> list = jdbcTemplate.queryForList(sql, String.class);
|
|
|
|
+ if(!list.isEmpty()){
|
|
|
|
+ return list.stream().collect(Collectors.joining(","));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Boolean checkIsEdit(ServicePlanVO vo) {
|
|
|
|
+ if(vo.getStatus()==1){
|
|
|
|
+ return true;
|
|
|
|
+ }else if(vo.getStatus()==2){
|
|
|
|
+ if(StringUtils.isNotEmpty(vo.getSendUser())){
|
|
|
|
+ return vo.getSendUser().contains(SecureUtil.getUserId()+"");
|
|
|
|
+ }
|
|
|
|
+ }else if(vo.getStatus()==2){
|
|
|
|
+ if(StringUtils.isNotEmpty(vo.getSendUser())){
|
|
|
|
+ return vo.getWriteUser().contains(SecureUtil.getUserId()+"");
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public String getServiceHtml(Long projectId, Long contractId,Long pkeyId) {
|
|
|
|
+ String sql="select * from m_wbs_tree_contract where p_key_id="+pkeyId;
|
|
|
|
+ WbsTreeContract wbsTreeContract = jdbcTemplate.queryForObject( sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
|
+ if (wbsTreeContract == null) {
|
|
|
|
+ throw new ServiceException("暂无表单");
|
|
|
|
+ }
|
|
|
|
+ if (wbsTreeContract.getHtmlUrl() == null) {
|
|
|
|
+ throw new ServiceException("暂无表单");
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ String fileUrl = wbsTreeContract.getHtmlUrl();
|
|
|
|
+ InputStream fileInputStream = FileUtils.getInputStreamByUrl(fileUrl);
|
|
|
|
+ String htmlString = IoUtil.readToString(fileInputStream);
|
|
|
|
+ htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
|
|
|
|
+ htmlString = htmlString.replaceAll("title", "titlexx");
|
|
|
|
+
|
|
|
|
+ // 远程搜索配置
|
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
|
+ Element table = doc.select("table").first();
|
|
|
|
+ // 标题解决
|
|
|
|
+ String sql1="select * from m_project_info where id="+projectId;
|
|
|
|
+ ProjectInfo projectInfo = jdbcTemplate.queryForObject(sql1,new BeanPropertyRowMapper<>(ProjectInfo.class));
|
|
|
|
+ //判断是否是水利水电表,水利水电项目名14,表名12 。 其他表都是18
|
|
|
|
+ Boolean isWater = false;
|
|
|
|
+ // 添加标题显示
|
|
|
|
+ Elements trs = table.select("tr");
|
|
|
|
+ for (int i = 1; i < 6; i++) {
|
|
|
|
+ Element tr = trs.get(i);
|
|
|
|
+ Elements tds = tr.select("td");
|
|
|
|
+ for (int j = 0; j < tds.size(); j++) {
|
|
|
|
+ Element data = tds.get(j);
|
|
|
|
+ String style = data.attr("style");
|
|
|
|
+ if (style.indexOf("font-size") >= 0) {
|
|
|
|
+ int fontsize = Integer.parseInt(style.substring(style.indexOf("font-size:") + 10, style.indexOf(".0pt")));
|
|
|
|
+ Element element = null;
|
|
|
|
+ if (isWater) {
|
|
|
|
+ if (StringUtils.isNotEmpty(data.text()) && fontsize >= 12) {
|
|
|
|
+ element = trs.get(i - 1).select("td").get(0);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (StringUtils.isNotEmpty(data.text()) && fontsize >= 14) {
|
|
|
|
+ element = trs.get(i - 1).select("td").get(0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (element != null && Func.isNotEmpty(element)) {
|
|
|
|
+ //
|
|
|
|
+ Elements allElements = element.children();
|
|
|
|
+ if (allElements.size() >= 1) {
|
|
|
|
+ String defText = allElements.get(0).attr("deftext");
|
|
|
|
+ if (defText != null && Func.isNotEmpty(defText)) {
|
|
|
|
+ element.text(defText);
|
|
|
|
+ } else {
|
|
|
|
+ element.text(projectInfo.getProjectName());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ element.text(projectInfo.getProjectName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ fileInputStream.close();
|
|
|
|
+ return table + "";
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new ServiceException("暂无表单");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean saveServiceData(List<TableInfo> tableInfoList,Long groupId,Long pkeyId) {
|
|
|
|
+ if (ListUtils.isNotEmpty(tableInfoList)) {
|
|
|
|
+ for (TableInfo tableInfo : tableInfoList) {
|
|
|
|
+ String sql="select * from m_wbs_tree_contract where p_key_id="+pkeyId;
|
|
|
|
+ WbsTreeContract wbsTreeContract = jdbcTemplate.queryForObject( sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
|
+ if (wbsTreeContract == null || StringUtils.isEmpty(wbsTreeContract.getInitTableName())) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //删除SQL
|
|
|
|
+ String delSql = "delete from " + wbsTreeContract.getInitTableName() + " where p_key_id='" + pkeyId + "' and group_id = '" + groupId + "'";
|
|
|
|
+
|
|
|
|
+ //新增SQ
|
|
|
|
+ String sqlInfo = "";
|
|
|
|
+ LinkedHashMap<String, String> dataMap2 = tableInfo.getDataMap();
|
|
|
|
+ sqlInfo = "INSERT INTO " + wbsTreeContract.getInitTableName() + " ( ";
|
|
|
|
+ String keyStr = "id,p_key_id,group_id,";
|
|
|
|
+ String valStr = SnowFlakeUtil.getId() + "," + pkeyId + ","+groupId+",";
|
|
|
|
+ if(dataMap2.containsKey("p_key_id")){
|
|
|
|
+ dataMap2.remove("p_key_id");
|
|
|
|
+ }
|
|
|
|
+ for (String keys : dataMap2.keySet()) {
|
|
|
|
+ keyStr += keys + ",";
|
|
|
|
+ valStr += "'" + dataMap2.get(keys) + "',";
|
|
|
|
+ }
|
|
|
|
+ keyStr = keyStr.substring(0, keyStr.lastIndexOf(","));
|
|
|
|
+ valStr = valStr.substring(0, valStr.lastIndexOf(","));
|
|
|
|
+ sqlInfo = sqlInfo + keyStr + ") VALUES (" + valStr + ")";
|
|
|
|
+ TransactionStatus transactionStatus = this.beginTransaction(transactionManager1);
|
|
|
|
+ try {
|
|
|
|
+ //删除
|
|
|
|
+ jdbcTemplate.execute(delSql);
|
|
|
|
+ //新增
|
|
|
|
+ jdbcTemplate.execute(sqlInfo);
|
|
|
|
+ //提交事务
|
|
|
|
+ transactionManager1.commit(transactionStatus);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ //回滚
|
|
|
|
+ transactionManager1.rollback(transactionStatus);
|
|
|
|
+ throw new RuntimeException("500"+e.getCause().getMessage()+" 字段过长,新增失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void saveServicePlanPdf(Long projectId,Long pkeyId, Long id) throws Exception {
|
|
|
|
+ String file_path = FileUtils.getSysLocalFileUrl();//ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
|
+ String sys_file_net_url = ParamCache.getValue(CommonConstant.SYS_FILE_NET_URL);
|
|
|
|
+ String sql="select * from m_wbs_tree_contract where p_key_id="+pkeyId;
|
|
|
|
+ WbsTreeContract wbsTreeContract = jdbcTemplate.queryForObject( sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
|
+ if (wbsTreeContract == null) {
|
|
|
|
+ throw new ServiceException("该数据下无此节点!");
|
|
|
|
+ }
|
|
|
|
+ if (wbsTreeContract.getHtmlUrl() == null) {
|
|
|
|
+ throw new ServiceException("请关联清表!");
|
|
|
|
+ }
|
|
|
|
+ String pdfPath = file_path + "/pdf//" + pkeyId + ".pdf";
|
|
|
|
+ String excelPath = file_path + "/pdf//" + pkeyId + ".xlsx";
|
|
|
|
+ File tabPdf = ResourceUtil.getFile(pdfPath);
|
|
|
|
+ if (tabPdf.exists()) {
|
|
|
|
+ tabPdf.delete();
|
|
|
|
+ }
|
|
|
|
+ String sql1="select * from m_excel_tab where id="+wbsTreeContract.getExcelId();
|
|
|
|
+ //获取清表信息
|
|
|
|
+ ExcelTab excelTab =jdbcTemplate.queryForObject( sql1, new BeanPropertyRowMapper<>(ExcelTab.class));
|
|
|
|
+
|
|
|
|
+ if (excelTab == null) {
|
|
|
|
+ throw new ServiceException("操作失败!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //获取数据信息info
|
|
|
|
+ List<Map<String, Object>> bussDataInfoTrial = this.getBussDataInfoTrial(pkeyId,id);
|
|
|
|
+ Map<String, Object> DataInfo = new HashMap<>();
|
|
|
|
+ if (bussDataInfoTrial.size() > 0) {
|
|
|
|
+ DataInfo.putAll(bussDataInfoTrial.stream().findAny().orElse(null));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //获取清表excel文件
|
|
|
|
+ org.apache.poi.ss.usermodel.Workbook workbook = WorkbookFactory.create(Objects.requireNonNull(CommonUtil.getOSSInputStreamTow(excelTab.getFileUrl())));
|
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
|
+ sheet.setForceFormulaRecalculation(true);
|
|
|
|
+
|
|
|
|
+ String sql2="select * from m_project_info where id="+projectId;
|
|
|
|
+ ProjectInfo projectInfo = jdbcTemplate.queryForObject(sql2, new BeanPropertyRowMapper<>(ProjectInfo.class));
|
|
|
|
+ int all = sheet.getRow(0).getLastCellNum();
|
|
|
|
+ int mergedCellCnt = sheet.getNumMergedRegions();
|
|
|
|
+ for (
|
|
|
|
+ int i = 0;
|
|
|
|
+ i < mergedCellCnt - 1; i++) {
|
|
|
|
+ CellRangeAddress mergedCell = sheet.getMergedRegion(i);
|
|
|
|
+ int xx = mergedCell.getNumberOfCells();
|
|
|
|
+ if (xx <= all) {
|
|
|
|
+ int fisRow = mergedCell.getFirstRow();
|
|
|
|
+ int firstCol = mergedCell.getFirstColumn();
|
|
|
|
+ Cell cell = sheet.getRow(fisRow).getCell(firstCol);
|
|
|
|
+ short fontIndex = cell.getCellStyle().getFontIndex();
|
|
|
|
+ Font oldFontAt = workbook.getFontAt(fontIndex);
|
|
|
|
+ Font redFont = workbook.createFont();
|
|
|
|
+ redFont.setFontHeightInPoints(oldFontAt.getFontHeightInPoints());//设置字体大小
|
|
|
|
+ redFont.setFontName(oldFontAt.getFontName());//设置字体
|
|
|
|
+ CellStyle newStyle = workbook.createCellStyle();//创建单元格样式
|
|
|
|
+ newStyle.cloneStyleFrom(cell.getCellStyle());
|
|
|
|
+ short fontHeightInPoints = redFont.getFontHeightInPoints();
|
|
|
|
+ if (fontHeightInPoints >= 14 && StringUtils.isEmpty(cell.getStringCellValue()) && fisRow <= 8) {
|
|
|
|
+ String title = projectInfo.getProjectName();
|
|
|
|
+ if (title.length() >= 30) {
|
|
|
|
+ sheet.getRow(fisRow).setHeight((short) 900);
|
|
|
|
+ newStyle.setWrapText(true);
|
|
|
|
+ }
|
|
|
|
+ redFont.setBold(true);
|
|
|
|
+ newStyle.setFont(redFont);
|
|
|
|
+ cell.setCellStyle(newStyle);
|
|
|
|
+ cell.setCellValue(title);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //数据不为空,构造数据
|
|
|
|
+ String fileUrl = wbsTreeContract.getHtmlUrl();
|
|
|
|
+ InputStream fileInputStream = FileUtils.getInputStreamByUrl(fileUrl);
|
|
|
|
+
|
|
|
|
+ String htmlString = IoUtil.readToString(fileInputStream);
|
|
|
|
+ htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
|
|
|
|
+ htmlString = htmlString.replaceAll("title", "titlexx");
|
|
|
|
+
|
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
|
+ Element table = doc.select("table").first();
|
|
|
|
+ Elements trs = table.select("tr");
|
|
|
|
+
|
|
|
|
+ if (ObjectUtil.isNotEmpty(DataInfo)) {
|
|
|
|
+ for (String val : Objects.requireNonNull(DataInfo).keySet()) {
|
|
|
|
+ if (val.contains("__")) {
|
|
|
|
+ String[] DataVal = val.split("__");
|
|
|
|
+ String[] xy = DataVal[1].split("_");
|
|
|
|
+ if (Integer.parseInt(xy[0]) < trs.size()) {
|
|
|
|
+ Element ytzData = trs.get(Integer.parseInt(xy[0]));
|
|
|
|
+ if (ytzData != null) {
|
|
|
|
+ Elements tdsx = ytzData.select("td");
|
|
|
|
+ if (Integer.parseInt(xy[1]) < tdsx.size()) {
|
|
|
|
+ Element data = ytzData.select("td").get(Integer.parseInt(xy[1]));
|
|
|
|
+ if (data != null) {
|
|
|
|
+ if (data.html().contains("x1") && data.html().contains("y1")) {
|
|
|
|
+ int x1 = 0;
|
|
|
|
+ int x2 = 0;
|
|
|
|
+ int y1 = 0;
|
|
|
|
+ int y2 = 0;
|
|
|
|
+ if (data.html().contains("el-tooltip")) {
|
|
|
|
+ x1 = Integer.parseInt(data.children().get(0).children().get(0).attr("x1"));
|
|
|
|
+ x2 = Integer.parseInt(data.children().get(0).children().get(0).attr("x2"));
|
|
|
|
+ y1 = Integer.parseInt(data.children().get(0).children().get(0).attr("y1"));
|
|
|
|
+ } else {
|
|
|
|
+ x1 = Integer.parseInt(data.children().get(0).attr("x1"));
|
|
|
|
+ y1 = Integer.parseInt(data.children().get(0).attr("y1"));
|
|
|
|
+ }
|
|
|
|
+ if (x1 == 0) {
|
|
|
|
+ x1 = 1;
|
|
|
|
+ }
|
|
|
|
+ String myData = DataInfo.get(val) + "";
|
|
|
|
+ if (myData.contains("T") && myData.contains("-") && myData.contains(":")) {
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
|
|
|
+ sdf.setTimeZone(TimeZone.getTimeZone("GTM+8"));
|
|
|
|
+ SimpleDateFormat formatStr = new SimpleDateFormat("yyyy年MM月dd日");
|
|
|
|
+ if (myData.contains(",") && myData.contains("]")) {
|
|
|
|
+
|
|
|
|
+ myData = myData.replace("[", "").replace("]", "").replaceAll("'", "");
|
|
|
|
+ String[] dataVal = myData.split(",");
|
|
|
|
+
|
|
|
|
+ Date Start_dataStr = sdf.parse(dataVal[0]);
|
|
|
|
+ Date end_dataStr = sdf.parse(dataVal[1]);
|
|
|
|
+ String StartDate = formatStr.format(Start_dataStr);
|
|
|
|
+ String endDate = formatStr.format(end_dataStr);
|
|
|
|
+ if (StartDate.equals(endDate)) {
|
|
|
|
+ myData = StartDate;
|
|
|
|
+ } else {
|
|
|
|
+ myData = StartDate + "-" + endDate;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ String[] dataStr = myData.split("T")[0].split("-");
|
|
|
|
+ myData = StringUtil.format("{}年{}月{}日", dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (myData.contains("lang.String")) {
|
|
|
|
+ Object obj = DataInfo.get(val);
|
|
|
|
+ if (obj instanceof String[]) {
|
|
|
|
+ String[] dataDate = (String[]) obj;
|
|
|
|
+ myData = dataDate[0].trim() + "至" + dataDate[1].trim();
|
|
|
|
+ if (dataDate[0].trim().equals(dataDate[1].trim())) {
|
|
|
|
+ myData = dataDate[0];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (myData.contains("http") && myData.contains("aliyuncs")) {
|
|
|
|
+ InputStream imageIn = CommonUtil.getOSSInputStream(myData);
|
|
|
|
+ byte[] byteNew = new byte[0];
|
|
|
|
+ if (imageIn != null) {
|
|
|
|
+ byteNew = IOUtils.toByteArray(imageIn);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ byte[] bytes = CommonUtil.compressImage(byteNew);
|
|
|
|
+
|
|
|
|
+ CreationHelper helper = workbook.getCreationHelper();
|
|
|
|
+ ClientAnchor anchor = helper.createClientAnchor();
|
|
|
|
+ anchor.setCol1(x1); // param1是列号
|
|
|
|
+ anchor.setCol2(x2);
|
|
|
|
+ anchor.setRow1(y1); // param2是行号
|
|
|
|
+ anchor.setRow2(y2); // param2是行号
|
|
|
|
+
|
|
|
|
+ Drawing<?> drawing = sheet.createDrawingPatriarch();
|
|
|
|
+ anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE);
|
|
|
|
+ // 插入图片
|
|
|
|
+ Picture picture = drawing.createPicture(anchor, workbook.addPicture(bytes, Workbook.PICTURE_TYPE_PNG));
|
|
|
|
+ picture.resize(1, 1);
|
|
|
|
+ FileUtils.imageOrientation(sheet, anchor, new DataVO(x1 - 1, y1 - 1));
|
|
|
|
+
|
|
|
|
+ } else if (myData.equals("1") && data.html().contains("hc-form-checkbox-group")) {
|
|
|
|
+ Row row = sheet.getRow(y1 - 1);
|
|
|
|
+ if (row != null) {
|
|
|
|
+ Cell cell = row.getCell(x1 - 1);
|
|
|
|
+ if (cell != null) {
|
|
|
|
+ String exceVal = cell.getStringCellValue().replaceAll(" ", "");
|
|
|
|
+ short fontIndex = cell.getCellStyle().getFontIndex();
|
|
|
|
+ Font fontAt = workbook.getFontAt(fontIndex);
|
|
|
|
+ fontAt.setFontName("EUDC");
|
|
|
|
+ cell.setCellValue(exceVal.replace("□", "\u2611"));
|
|
|
|
+ } else {
|
|
|
|
+ ObjectUtils.isNotEmpty(cell);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ Row row = sheet.getRow(y1 - 1);
|
|
|
|
+ if (row != null) {
|
|
|
|
+ Cell cell = row.getCell(x1 - 1);
|
|
|
|
+ if (cell != null) {
|
|
|
|
+ if(myData.contains("[")&&myData.contains("]")){
|
|
|
|
+ myData=myData.replace("[", "").replace("]", "");
|
|
|
|
+ if (myData.contains(",")){
|
|
|
|
+ myData= myData.replace(", ","至");
|
|
|
|
+ }
|
|
|
|
+ if (myData.contains(",")){
|
|
|
|
+ myData= myData.replace(", ","至");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ cell.setCellValue(myData);
|
|
|
|
+ } else {
|
|
|
|
+ ObjectUtils.isNotEmpty(cell);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //输出流
|
|
|
|
+ FileOutputStream outputStream = new FileOutputStream(excelPath);
|
|
|
|
+ workbook.write(outputStream);
|
|
|
|
+ FileUtils.setExcelScaleToPdf(excelPath, pdfPath);
|
|
|
|
+ BladeFile bladeFile = newIOSSClient.uploadFile(id + ".pdf", pdfPath);
|
|
|
|
+ if (bladeFile != null) {
|
|
|
|
+ String sql3="update m_service_plan set pdf_url=' "+bladeFile.getLink()+" ' where id="+id;
|
|
|
|
+ jdbcTemplate.update(sql3);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Map<String, Object> getServiceBussData(Long id, Long pkeyId) {
|
|
|
|
+ Map<String, Object> reData = new HashMap<>();
|
|
|
|
+ String sqll="select * from m_wbs_tree_contract where p_key_id="+pkeyId;
|
|
|
|
+ WbsTreeContract wbsTreeContract = jdbcTemplate.queryForObject(sqll, new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
|
+ if (wbsTreeContract == null) {
|
|
|
|
+ throw new ServiceException("该数据下无此节点!");
|
|
|
|
+ }
|
|
|
|
+ if (wbsTreeContract.getHtmlUrl() == null) {
|
|
|
|
+ throw new ServiceException("请关联清表!");
|
|
|
|
+ }
|
|
|
|
+ //表单是否存储在
|
|
|
|
+ String tabName = wbsTreeContract.getInitTableName();
|
|
|
|
+ String isExitSql = "select * from information_schema.TABLES where TABLE_NAME='" + tabName + "'";
|
|
|
|
+ List<Map<String, Object>> tabList = jdbcTemplate.queryForList(isExitSql);
|
|
|
|
+ if (tabList.size() <= 0) {
|
|
|
|
+ throw new ServiceException("请关联清表!");
|
|
|
|
+ }
|
|
|
|
+ //实体数据
|
|
|
|
+ String querySql = "select * from " + wbsTreeContract.getInitTableName() + " where p_key_id=" + pkeyId + " and group_id = " + id;
|
|
|
|
+ List<Map<String, Object>> dataIn = jdbcTemplate.queryForList(querySql);
|
|
|
|
+ //匹配关联
|
|
|
|
+ try {
|
|
|
|
+ if (dataIn.size() >= 1) {
|
|
|
|
+ Map<String, Object> mysqlData = dataIn.get(0);
|
|
|
|
+ for (String key : mysqlData.keySet()) {
|
|
|
|
+ String tabVal = mysqlData.get(key) + "";
|
|
|
|
+ // 时间段处理
|
|
|
|
+ if (StringUtils.isNotEmpty(tabVal) && !tabVal.equals("null")) {
|
|
|
|
+ if (tabVal.contains("T") && tabVal.contains(".000Z]")) {
|
|
|
|
+ String[] tabData = tabVal.split("_\\^_");
|
|
|
|
+
|
|
|
|
+ if (reData.containsKey("pickerKey")) {
|
|
|
|
+ String pickerKey = reData.get("pickerKey") + "," + key + "__" + tabData[1];
|
|
|
|
+ reData.put("pickerKey", pickerKey);
|
|
|
|
+ } else {
|
|
|
|
+ reData.put("pickerKey", key + "__" + tabData[1]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String sql = tabData[0];
|
|
|
|
+ sql = sql.replaceAll("\\[", "['");
|
|
|
|
+ sql = sql.replaceAll("]", "']");
|
|
|
|
+ sql = sql.replaceAll("000Z,", "000Z',");
|
|
|
|
+ sql = sql.replaceAll(", 20", ", '20");
|
|
|
|
+ // sql = sql.replaceAll("'", "");
|
|
|
|
+ if (StringUtils.isNotEmpty(tabData[0])) {
|
|
|
|
+ reData.put(key + "__" + tabData[1], sql);
|
|
|
|
+ }
|
|
|
|
+ } else if (tabVal.indexOf("T") >= 0 && tabVal.indexOf(".000Z") >= 0) {//时间
|
|
|
|
+ // 时间和字符串合作
|
|
|
|
+ if (tabVal.indexOf("☆") >= 0) {
|
|
|
|
+ String[] mysql = tabVal.split("☆");
|
|
|
|
+ for (String data : mysql) {
|
|
|
|
+ String[] tabData = data.split("_\\^_");
|
|
|
|
+ if (StringUtils.isNotEmpty(tabData[0])) {
|
|
|
|
+ reData.put(key + "__" + tabData[1], tabData[0]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ String[] tabData = tabVal.split("_\\^_");
|
|
|
|
+ if (StringUtils.isNotEmpty(tabData[0])) {
|
|
|
|
+ reData.put(key + "__" + tabData[1], tabData[0]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (tabVal.indexOf("☆") >= 0) {
|
|
|
|
+ String[] mysql = tabVal.split("☆");
|
|
|
|
+ for (String data : mysql) {
|
|
|
|
+ String[] tabData = data.split("_\\^_");
|
|
|
|
+ if (tabVal.contains("[")) {
|
|
|
|
+ String[] strings = StringUtils.strip(tabData[0], "[]").split(",");
|
|
|
|
+ reData.put(key + "__" + tabData[1], strings);
|
|
|
|
+ } else {
|
|
|
|
+ reData.put(key + "__" + tabData[1], tabData[0]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (tabVal.indexOf("_^_") >= 0) {
|
|
|
|
+ String[] tabData = tabVal.split("_\\^_");
|
|
|
|
+ if (StringUtils.isNotEmpty(tabData[0])) {
|
|
|
|
+ if (tabVal.contains("[")) {
|
|
|
|
+ String[] strings = StringUtils.strip(tabData[0], "[]").split(",");
|
|
|
|
+ reData.put(key + "__" + tabData[1], strings);
|
|
|
|
+ } else {
|
|
|
|
+ reData.put(key + "__" + tabData[1], tabData[0]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ reData.put(key, tabVal);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ return reData;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Map<String,List<ServiceUserDto>> getSendUserAndWriteUser(Long projectId, Long contractId) {
|
|
|
|
+ HashMap<String, List<ServiceUserDto>> map = new HashMap<>();
|
|
|
|
+ List<String> sendList=baseMapper.getUserID(projectId, contractId,1);
|
|
|
|
+ List<String> writeList=baseMapper.getUserID(projectId, contractId,2);
|
|
|
|
+ if (!sendList.isEmpty()) {
|
|
|
|
+ List<String> sendResult = sendList.stream()
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
+ .filter(str -> !str.isEmpty())
|
|
|
|
+ .flatMap(str -> Arrays.stream(str.split(",")))
|
|
|
|
+ .distinct()
|
|
|
|
+ .sorted()
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ map.put("sendUser", getUserNamesByIds(sendResult));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!writeList.isEmpty()) {
|
|
|
|
+ List<String> writedResult = writeList.stream()
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
+ .filter(str -> !str.isEmpty())
|
|
|
|
+ .flatMap(str -> Arrays.stream(str.split(",")))
|
|
|
|
+ .distinct()
|
|
|
|
+ .sorted()
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ map.put("writeUser", getUserNamesByIds(writedResult));
|
|
|
|
+ }
|
|
|
|
+ return map;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Long saveServicePlan(Long pkeyId,Long projectId,Long contractId,JSONObject dataInfo,Long groupId1) {
|
|
|
|
+ ServicePlan plan = new ServicePlan();
|
|
|
|
+ if(dataInfo.containsKey("key_15__3_4")){
|
|
|
|
+ Object o = dataInfo.get("key_15__3_4");
|
|
|
|
+ String startDate = null;
|
|
|
|
+ String endDate = null;
|
|
|
|
+ if (o instanceof List<?>) {
|
|
|
|
+ List<?> list = (List<?>) o;
|
|
|
|
+ if (list.size() >= 2 && list.get(0) instanceof String && list.get(1) instanceof String) {
|
|
|
|
+ startDate = formatDate((String) list.get(0));
|
|
|
|
+ endDate = formatDate((String) list.get(1));
|
|
|
|
+ }
|
|
|
|
+ } else if (o != null && o.getClass().isArray()) {
|
|
|
|
+ Object[] array = (Object[]) o;
|
|
|
|
+ if (array.length >= 2 && array[0] instanceof String && array[1] instanceof String) {
|
|
|
|
+ startDate = formatDate((String) array[0]);
|
|
|
|
+ endDate = formatDate((String) array[1]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (startDate != null) {
|
|
|
|
+ plan.setPlanStartTime(LocalDate.parse(startDate));
|
|
|
|
+ }
|
|
|
|
+ if (endDate != null) {
|
|
|
|
+ plan.setPlanEndTime(LocalDate.parse(endDate));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(dataInfo.containsKey("key_42__3_4")){
|
|
|
|
+ Object o = dataInfo.get("key_42__3_4");
|
|
|
|
+ String startDate = null;
|
|
|
|
+ String endDate = null;
|
|
|
|
+ if (o instanceof List<?>) {
|
|
|
|
+ List<?> list = (List<?>) o;
|
|
|
|
+ if (list.size() >= 2 && list.get(0) instanceof String && list.get(1) instanceof String) {
|
|
|
|
+ startDate = formatDate((String) list.get(0));
|
|
|
|
+ endDate = formatDate((String) list.get(1));
|
|
|
|
+ }
|
|
|
|
+ } else if (o != null && o.getClass().isArray()) {
|
|
|
|
+ Object[] array = (Object[]) o;
|
|
|
|
+ if (array.length >= 2 && array[0] instanceof String && array[1] instanceof String) {
|
|
|
|
+ startDate = formatDate((String) array[0]);
|
|
|
|
+ endDate = formatDate((String) array[1]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (startDate != null) {
|
|
|
|
+ plan.setPlanStartTime(LocalDate.parse(startDate));
|
|
|
|
+ }
|
|
|
|
+ if (endDate != null) {
|
|
|
|
+ plan.setPlanEndTime(LocalDate.parse(endDate));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(groupId1 != null){
|
|
|
|
+ plan.setId(groupId1);
|
|
|
|
+ ServicePlan plan1 = this.getById(plan.getId());
|
|
|
|
+ if(plan1.getWriteUser()!=null){
|
|
|
|
+ if(plan1.getStatus()!=2&&!plan1.getWriteUser().contains(SecureUtil.getUserId()+"")){
|
|
|
|
+ plan.setWriteUser(plan1.getWriteUser()+","+SecureUtil.getUserId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(plan1.getStatus()!=null){
|
|
|
|
+ plan.setStatus(plan1.getStatus());
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ plan.setProjectId(projectId);
|
|
|
|
+ plan.setContractId(contractId);
|
|
|
|
+ plan.setStatus(1);
|
|
|
|
+ plan.setWriteUser(SecureUtil.getUserId()+"");
|
|
|
|
+ if(pkeyId==1937773223861026820L){
|
|
|
|
+ plan.setFileInType(1);
|
|
|
|
+ }else {
|
|
|
|
+ plan.setFileInType(2);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.saveOrUpdate(plan);
|
|
|
|
+ return plan.getId();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ServicePlanVO getdetail(Long id) {
|
|
|
|
+ ServicePlan plan = this.getById(id);
|
|
|
|
+ ServicePlanVO vo = new ServicePlanVO();
|
|
|
|
+ BeanUtil.copyProperties(plan, vo);
|
|
|
|
+ vo.setStatusValue(vo.getStatus()==1?"计划中":vo.getStatus()==2?"协同中-甲方":vo.getStatus()==3?"协同中-系统":"已计划");
|
|
|
|
+ vo.setIsEdit(checkIsEdit(vo));
|
|
|
|
+ if(vo.getPlanStartTime()!=null){
|
|
|
|
+ vo.setStartTime(vo.getPlanStartTime().format(DateTimeFormatter.ofPattern("yyyy年M月d日")));
|
|
|
|
+ }
|
|
|
|
+ if(vo.getPlanEndTime()!=null){
|
|
|
|
+ vo.setEndTime(vo.getPlanEndTime().format(DateTimeFormatter.ofPattern("yyyy年M月d日")));
|
|
|
|
+ }
|
|
|
|
+ if(StringUtils.isNotEmpty(vo.getStartTime())&&StringUtils.isNotEmpty(vo.getEndTime())){
|
|
|
|
+ vo.setPlanTime(vo.getStartTime()+"至"+vo.getEndTime());
|
|
|
|
+ }
|
|
|
|
+ vo.setWriteUserName(slectUserName(vo.getWriteUser()));
|
|
|
|
+ vo.setSendUserName(slectUserName(vo.getSendUser()));
|
|
|
|
+ return vo;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static String formatDate(String dateStr) {
|
|
|
|
+ if (dateStr == null || dateStr.trim().isEmpty()) return null;
|
|
|
|
+ try {
|
|
|
|
+ // 替换掉“年”、“月”、“日”字符,然后解析为LocalDate
|
|
|
|
+ return dateStr.replaceAll("年", "-")
|
|
|
|
+ .replaceAll("月", "-")
|
|
|
|
+ .replaceAll("日", "")
|
|
|
|
+ .trim();
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public List<ServiceUserDto> getUserNamesByIds(List<String> sendResult) {
|
|
|
|
+ if (sendResult == null || sendResult.isEmpty()) {
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 构建 SQL 查询语句
|
|
|
|
+ String inSql = sendResult.stream()
|
|
|
|
+ .map(id -> "?")
|
|
|
|
+ .collect(Collectors.joining(", "));
|
|
|
|
+
|
|
|
|
+ String sql = "SELECT id, real_name FROM blade_user WHERE id IN (" + inSql + ")";
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ List<Map<String, Object>> rows = jdbcTemplate.queryForList(sql, sendResult.toArray());
|
|
|
|
+
|
|
|
|
+ return rows.stream()
|
|
|
|
+ .map(row -> new ServiceUserDto(
|
|
|
|
+ row.get("id").toString(),
|
|
|
|
+ row.get("real_name").toString()))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ } catch (DataAccessException e) {
|
|
|
|
+ // 日志记录异常信息
|
|
|
|
+ log.error("查询用户信息失败", e);
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<Map<String, Object>> getBussDataInfoTrial(Long pkeyId ,Long id) {
|
|
|
|
+ String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
|
+ String sys_file_net_url = ParamCache.getValue(CommonConstant.SYS_FILE_NET_URL);
|
|
|
|
+ List<Map<String, Object>> list = new ArrayList<>();
|
|
|
|
+ Map<String, Object> reData = new HashMap<>();
|
|
|
|
+ String sqll="select * from m_wbs_tree_contract where p_key_id="+pkeyId;
|
|
|
|
+ WbsTreeContract wbsTreeContract = jdbcTemplate.queryForObject(sqll, new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
|
+ if (wbsTreeContract == null) {
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+ if (wbsTreeContract.getHtmlUrl() == null) {
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+ //表单是否存储在
|
|
|
|
+ String tabName = wbsTreeContract.getInitTableName();
|
|
|
|
+ String isExitSql = "select * from information_schema.TABLES where TABLE_NAME='" + tabName + "'";
|
|
|
|
+ List<Map<String, Object>> tabList = jdbcTemplate.queryForList(isExitSql);
|
|
|
|
+ if (tabList.size() <= 0) {
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //实体数据
|
|
|
|
+ String querySql = "select * from " + wbsTreeContract.getInitTableName() + " where p_key_id=" + pkeyId + " and group_id = " + id;
|
|
|
|
+ List<Map<String, Object>> dataIn = jdbcTemplate.queryForList(querySql);
|
|
|
|
+ String keyNames="";
|
|
|
|
+ //匹配关联
|
|
|
|
+ try {
|
|
|
|
+ String fileUrl = wbsTreeContract.getHtmlUrl();
|
|
|
|
+ File file1 = ResourceUtil.getFile(fileUrl);
|
|
|
|
+ InputStream fileInputStream;
|
|
|
|
+ if (file1.exists()) {
|
|
|
|
+ fileInputStream = new FileInputStream(file1);
|
|
|
|
+ } else {
|
|
|
|
+ String path = sys_file_net_url + fileUrl.replaceAll("//", "/").replaceAll(file_path, "");
|
|
|
|
+ fileInputStream = CommonUtil.getOSSInputStream(path);
|
|
|
|
+ }
|
|
|
|
+ String htmlString = IoUtil.readToString(fileInputStream);
|
|
|
|
+ htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
|
|
|
|
+ htmlString = htmlString.replaceAll("title", "titlexx");
|
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
|
+ keyNames= getKeyNameList(doc);
|
|
|
|
+ if (dataIn.size() >= 1) {
|
|
|
|
+ Map<String, Object> mysqlData = dataIn.get(0);
|
|
|
|
+ for (String key : mysqlData.keySet()) {
|
|
|
|
+ String tabVal = mysqlData.get(key) + "";
|
|
|
|
+ // 时间段处理
|
|
|
|
+ if (StringUtils.isNotEmpty(tabVal) && !tabVal.equals("null")) {
|
|
|
|
+ if (tabVal.contains("T") && tabVal.contains(".000Z]")) {
|
|
|
|
+ String[] tabData = tabVal.split("_\\^_");
|
|
|
|
+
|
|
|
|
+ if (reData.containsKey("pickerKey")) {
|
|
|
|
+ String pickerKey = reData.get("pickerKey") + "," + key + "__" + tabData[1];
|
|
|
|
+ reData.put("pickerKey", pickerKey);
|
|
|
|
+ } else {
|
|
|
|
+ reData.put("pickerKey", key + "__" + tabData[1]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String sql = tabData[0];
|
|
|
|
+ sql = sql.replaceAll("\\[", "['");
|
|
|
|
+ sql = sql.replaceAll("]", "']");
|
|
|
|
+ sql = sql.replaceAll("000Z,", "000Z',");
|
|
|
|
+ sql = sql.replaceAll(", 20", ", '20");
|
|
|
|
+ // sql = sql.replaceAll("'", "");
|
|
|
|
+ if (StringUtils.isNotEmpty(tabData[0])) {
|
|
|
|
+ reData.put(key + "__" + tabData[1], sql);
|
|
|
|
+ }
|
|
|
|
+ } else if (tabVal.indexOf("T") >= 0 && tabVal.indexOf(".000Z") >= 0) {//时间
|
|
|
|
+ // 时间和字符串合作
|
|
|
|
+ if (tabVal.indexOf("☆") >= 0) {
|
|
|
|
+ String[] mysql = tabVal.split("☆");
|
|
|
|
+ for (String data : mysql) {
|
|
|
|
+ String[] tabData = data.split("_\\^_");
|
|
|
|
+ if (StringUtils.isNotEmpty(tabData[0])) {
|
|
|
|
+ reData.put(key + "__" + tabData[1], tabData[0]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ String[] tabData = tabVal.split("_\\^_");
|
|
|
|
+ if (StringUtils.isNotEmpty(tabData[0])) {
|
|
|
|
+ reData.put(key + "__" + tabData[1], tabData[0]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (tabVal.indexOf("☆") >= 0) {
|
|
|
|
+ String[] mysql = tabVal.split("☆");
|
|
|
|
+ for (String data : mysql) {
|
|
|
|
+ String[] tabData = data.split("_\\^_");
|
|
|
|
+ if (StringUtils.isNotEmpty(tabData[0])) {
|
|
|
|
+ reData.put(key + "__" + tabData[1], tabData[0]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (tabVal.indexOf("_^_") >= 0) {
|
|
|
|
+ String[] tabData = tabVal.split("_\\^_");
|
|
|
|
+ if (StringUtils.isNotEmpty(tabData[0])) {
|
|
|
|
+ if (tabVal.contains("[") && tabVal.contains("年")) {
|
|
|
|
+ String[] strings = StringUtils.strip(tabData[0], "[]").split(",");
|
|
|
|
+ reData.put(key + "__" + tabData[1], strings);
|
|
|
|
+ }else if (tabVal.contains("[") && tabVal.contains("]") ) {
|
|
|
|
+ String[] strings = StringUtils.strip(tabData[0], "[]").split(",");
|
|
|
|
+ reData.put(key + "__" + tabData[1], strings);
|
|
|
|
+ } else {
|
|
|
|
+ reData.put(key + "__" + tabData[1], tabData[0]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ reData.put(key, tabVal);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ // 移除Id 和 p_key_id
|
|
|
|
+ reData.remove("id");
|
|
|
|
+ reData.remove("p_key_id");
|
|
|
|
+ reData.remove("classify");
|
|
|
|
+ reData.remove("contractId");
|
|
|
|
+ reData.remove("pkeyId");
|
|
|
|
+ reData.remove("projectId");
|
|
|
|
+ if(reData.size()>0){
|
|
|
|
+ //处理key重复导致pdf数据错位
|
|
|
|
+ for (Iterator<Map.Entry<String, Object>> iterator = reData.entrySet().iterator(); iterator.hasNext(); ) {
|
|
|
|
+ Map.Entry<String, Object> entry = iterator.next();
|
|
|
|
+ if (!keyNames.equals("") && keyNames.indexOf(entry.getKey()) <0) {
|
|
|
|
+ iterator.remove();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ list.add(reData);
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+ public String getKeyNameList(Document doc){
|
|
|
|
+ StringBuilder allKeyName=new StringBuilder();
|
|
|
|
+ Elements select = doc.getElementsByAttributeValueContaining("keyname","key_");
|
|
|
|
+ if(!select.isEmpty()){
|
|
|
|
+ for (Element element : select) {
|
|
|
|
+ String keyName = element.attr("keyname");
|
|
|
|
+ allKeyName.append(keyName+",");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ String allKeyNames = allKeyName.toString();
|
|
|
|
+ if(allKeyNames.endsWith(",")){
|
|
|
|
+ allKeyNames = allKeyNames.substring(0, allKeyNames.length() - 1);
|
|
|
|
+ }
|
|
|
|
+ return allKeyNames;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public TransactionStatus beginTransaction(DataSourceTransactionManager transactionManager) {
|
|
|
|
+ DefaultTransactionDefinition def = new DefaultTransactionDefinition();//事务定义类
|
|
|
|
+ def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
|
|
|
|
+ return transactionManager.getTransaction(def);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|