|
@@ -21,11 +21,15 @@ import cn.hutool.log.StaticLog;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
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 com.spire.xls.CellRange;
|
|
|
+import com.spire.xls.ExcelPicture;
|
|
|
+import com.spire.xls.Workbook;
|
|
|
+import com.spire.xls.Worksheet;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
-import lombok.Data;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.jsoup.Jsoup;
|
|
|
import org.jsoup.nodes.Document;
|
|
@@ -34,31 +38,40 @@ import org.jsoup.select.Elements;
|
|
|
import org.springblade.business.feign.ContractLogClient;
|
|
|
import org.springblade.business.feign.InformationQueryClient;
|
|
|
import org.springblade.business.vo.SaveContractLogVO;
|
|
|
+import org.springblade.common.constant.CommonConstant;
|
|
|
+import org.springblade.common.utils.CommonUtil;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.oss.model.BladeFile;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.node.ForestNodeMerger;
|
|
|
import org.springblade.core.tool.utils.*;
|
|
|
import org.springblade.manager.bean.TableInfo;
|
|
|
-import org.springblade.manager.dto.FormData;
|
|
|
import org.springblade.manager.entity.*;
|
|
|
import org.springblade.manager.formula.KeyMapper;
|
|
|
import org.springblade.manager.formula.impl.TableElementConverter;
|
|
|
import org.springblade.manager.service.*;
|
|
|
+import org.springblade.manager.utils.FileUtils;
|
|
|
import org.springblade.manager.vo.ExceTabTreVO;
|
|
|
import org.springblade.manager.vo.ExcelTabVO;
|
|
|
import org.springblade.manager.mapper.ExcelTabMapper;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
import org.springblade.manager.vo.ExcelTabWbsTypeVO;
|
|
|
import org.springblade.manager.vo.WbsTreeVO;
|
|
|
+import org.springblade.resource.feign.NewIOSSClient;
|
|
|
+import org.springblade.system.cache.ParamCache;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
|
+import javax.imageio.ImageIO;
|
|
|
+import java.awt.*;
|
|
|
+import java.awt.image.BufferedImage;
|
|
|
import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
import java.io.FileNotFoundException;
|
|
|
import java.util.*;
|
|
|
+import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -71,549 +84,920 @@ import java.util.stream.Collectors;
|
|
|
@AllArgsConstructor
|
|
|
public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTab> implements IExcelTabService {
|
|
|
|
|
|
- //客户端资料查询接口
|
|
|
- private final InformationQueryClient informationQueryClient;
|
|
|
- // 元素信息表-
|
|
|
- private final IWbsTreeContractService wbsTreeContractService;
|
|
|
- private final IWbsTreeService wbsTreeService;
|
|
|
- private final IFormulaService formulaService;
|
|
|
- private final JdbcTemplate jdbcTemplate;
|
|
|
-
|
|
|
- private final IWbsParamService wbsParamService;
|
|
|
-
|
|
|
- private final IWbsTreePrivateService wbsTreePrivateService;
|
|
|
-
|
|
|
- private final ContractLogClient contractLogClient;
|
|
|
-
|
|
|
- @Override
|
|
|
- public IPage<ExcelTabVO> selectExcelTabPage(IPage<ExcelTabVO> page, ExcelTabVO excelTab) {
|
|
|
- return page.setRecords(baseMapper.selectExcelTabPage(page, excelTab));
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<ExceTabTreVO> tabLazyTree(String tenantId, Long modeId,Long parentId) {
|
|
|
- if (AuthUtil.isAdministrator()) {
|
|
|
- tenantId = StringPool.EMPTY;
|
|
|
- }
|
|
|
- List<ExceTabTreVO> ls = baseMapper.tabLazyTree(tenantId, modeId,parentId+"");
|
|
|
- return ForestNodeMerger.merge(ls);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<ExceTabTreVO> tabLazyTreeAll(String tenantId, Long modeId,String name) {
|
|
|
- if (AuthUtil.isAdministrator()) {
|
|
|
- tenantId = StringPool.EMPTY;
|
|
|
- }
|
|
|
- return ForestNodeMerger.merge(baseMapper.tabLazyTreeAll(tenantId, modeId,name));
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<ExcelTabWbsTypeVO> getWbsTypeList(Integer wbstType) {
|
|
|
- return baseMapper.getWbsTypeList(wbstType+"");
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<WbsTreeVO> lazyTree(String wbsId, String tenantId, Long parentId) {
|
|
|
- if (AuthUtil.isAdministrator()) {
|
|
|
- tenantId = StringPool.EMPTY;
|
|
|
- }
|
|
|
- return ForestNodeMerger.merge(baseMapper.lazyTree(wbsId, tenantId, parentId));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 私有项目 wbs 树
|
|
|
- */
|
|
|
- @Override
|
|
|
- public List<WbsTreeVO> lazyTreeByPri(String wbsId, String tenantId, Long parentId) {
|
|
|
- if (AuthUtil.isAdministrator()) {
|
|
|
- tenantId = StringPool.EMPTY;
|
|
|
- }
|
|
|
- return ForestNodeMerger.merge(baseMapper.lazyTreeByPri(wbsId, tenantId, parentId));
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean removeBussTabInfoById(String pkeyid) {
|
|
|
- baseMapper.removeBussTabInfoById(pkeyid);
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public BladeFile getBussPdfInfo(Long pkeyId) {
|
|
|
-
|
|
|
-
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- private void setFirstData(JSONObject dataInfo2, TableInfo tableInfo){
|
|
|
- //huangjn 判断是否是首件
|
|
|
- if(dataInfo2.containsKey("isFirst")){
|
|
|
- tableInfo.setIsFirst(dataInfo2.getString("isFirst"));
|
|
|
- }
|
|
|
- //huangjn 判断是否是首件
|
|
|
-
|
|
|
- //首件资料绑定的节点
|
|
|
- if(dataInfo2.containsKey("firstNodeId")){
|
|
|
- tableInfo.setFirstNodeId(dataInfo2.getString("firstNodeId"));
|
|
|
- }
|
|
|
- //首件ID(编辑时有值,新增时为空)
|
|
|
- if(dataInfo2.containsKey("firstId")){
|
|
|
- tableInfo.setFirstId(dataInfo2.getString("firstId"));
|
|
|
- }
|
|
|
- //源文件
|
|
|
- if(dataInfo2.containsKey("sourceUrl")){
|
|
|
- tableInfo.setSourceUrl(dataInfo2.getString("sourceUrl"));
|
|
|
- }
|
|
|
- //pdfUrl
|
|
|
- if(dataInfo2.containsKey("pdfUrl")){
|
|
|
- tableInfo.setPdfUrl(dataInfo2.getString("pdfUrl"));
|
|
|
- }
|
|
|
- //文件名称
|
|
|
- if(dataInfo2.containsKey("firstFileName")){
|
|
|
- tableInfo.setFirstFileName(dataInfo2.getString("firstFileName"));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 设置日志信息
|
|
|
- */
|
|
|
- private void setTheLogData(JSONObject dataInfo2, TableInfo tableInfo){
|
|
|
- //huangjn 判断是否是日志
|
|
|
- if(dataInfo2.containsKey("isTheLog")){
|
|
|
- tableInfo.setIsTheLog(dataInfo2.getString("isTheLog"));
|
|
|
- }
|
|
|
- //huangjn 判断是否是日志
|
|
|
-
|
|
|
- //huangjn 日志ID
|
|
|
- if(dataInfo2.containsKey("theLogId")){
|
|
|
- tableInfo.setTheLogId(dataInfo2.getString("theLogId"));
|
|
|
- }
|
|
|
- //huangjn 日志ID
|
|
|
-
|
|
|
- //huangjn 日志勾选的工序
|
|
|
- if(dataInfo2.containsKey("linkTabIds")){
|
|
|
- tableInfo.setLinkTabIds(dataInfo2.getJSONArray("linkTabIds"));
|
|
|
- }
|
|
|
- //huangjn 日志勾选的工序
|
|
|
-
|
|
|
- //huangjn 日志所选时间
|
|
|
- if(dataInfo2.containsKey("recordTime")){
|
|
|
- tableInfo.setRecordTime(dataInfo2.getString("recordTime"));
|
|
|
- }
|
|
|
- //huangjn 日志所选时间
|
|
|
- //huangjn 每份填报数据的id,目前日志专用
|
|
|
- if(dataInfo2.containsKey("id")){
|
|
|
- tableInfo.setBusinessId(dataInfo2.getString("id"));
|
|
|
- }
|
|
|
- //huangjn 每份填报数据的id,目前日志专用
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<TableInfo> getTableInfoList(JSONArray dataArray) {
|
|
|
- if(dataArray!=null&&!dataArray.isEmpty()){
|
|
|
- List<TableInfo> result = new ArrayList<>();
|
|
|
- for(int m=0;m<dataArray.size();m++){
|
|
|
- TableInfo tableInfo = new TableInfo();
|
|
|
- JSONObject dataInfo2= dataArray.getJSONObject(m);
|
|
|
- //
|
|
|
- tableInfo.setContractId(dataInfo2.getString("contractId"));
|
|
|
- tableInfo.setPkeyId(dataInfo2.getString("pkeyId"));
|
|
|
- tableInfo.setProjectId(dataInfo2.getString("projectId"));
|
|
|
- //huangjn 填报的类型,施工或监理
|
|
|
- tableInfo.setClassify(dataInfo2.getString("classify"));
|
|
|
- //huangjn 填报的类型,施工或监理
|
|
|
-
|
|
|
- //设置首件信息
|
|
|
- this.setFirstData(dataInfo2, tableInfo);
|
|
|
- //设置日志信息
|
|
|
- this.setTheLogData(dataInfo2, tableInfo);
|
|
|
-
|
|
|
- dataInfo2.fluentRemove("contractId")
|
|
|
- .fluentRemove("pkeyId")
|
|
|
- .fluentRemove("p_key_id")
|
|
|
- .fluentRemove("projectId")
|
|
|
- .fluentRemove("classify")
|
|
|
- .fluentRemove("pickerKey")
|
|
|
- .fluentRemove("id")
|
|
|
- .fluentRemove("isFirst")
|
|
|
- .fluentRemove("firstNodeId")
|
|
|
- .fluentRemove("isTheLog")
|
|
|
- .fluentRemove("theLogId")
|
|
|
- .fluentRemove("linkTabIds")
|
|
|
- .fluentRemove("recordTime")
|
|
|
- .fluentRemove("businessId")
|
|
|
- .fluentRemove("sourceUrl")
|
|
|
- .fluentRemove("pdfUrl")
|
|
|
- .fluentRemove("firstFileName")
|
|
|
- .fluentRemove("");
|
|
|
- // 计算数据
|
|
|
- LinkedHashMap<String,List<String>> dataMap =dataInfo2.keySet().stream().filter(e->e.contains("__")).collect(Collectors.groupingBy(e->e.split("__")[0], LinkedHashMap<String,List<String>>::new,Collectors.toList()));
|
|
|
- LinkedHashMap<String,String> dataMap2 = new LinkedHashMap<>();
|
|
|
- // 字段组合
|
|
|
- for(String k:dataMap.keySet()){
|
|
|
- if(dataMap.get(k).size()>1&& !dataMap.get(k).contains("000Z")){
|
|
|
- String[] ziduan= dataMap.get(k).toArray(new String[]{});
|
|
|
- String temp = "";
|
|
|
- for(int i = 0; i < ziduan.length - 1; i++) {
|
|
|
- for (int j = 0; j < ziduan.length - i - 1; j++) {
|
|
|
- Integer tr = Integer.parseInt((ziduan[j].split("__")[1]).split("_")[0]);
|
|
|
- Integer td = Integer.parseInt(ziduan[j].split("__")[1].split("_")[1]);
|
|
|
-
|
|
|
- Integer tr_1 = Integer.parseInt(ziduan[j + 1].split("__")[1].split("_")[0]);
|
|
|
- Integer td_1 = Integer.parseInt(ziduan[j + 1].split("__")[1].split("_")[1]);
|
|
|
-
|
|
|
- if (tr > tr_1 && td==td_1 ) { //纵向排序
|
|
|
- temp = ziduan[j];
|
|
|
- ziduan[j] = ziduan[j + 1];
|
|
|
- ziduan[j + 1] = temp;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- String lastStr = dataInfo2.getString(ziduan[0])+"_^_"+ziduan[0].split("__")[1];
|
|
|
- for (int i=1 ;i<ziduan.length;i++){
|
|
|
- String keyData = dataInfo2.getString(ziduan[i]);
|
|
|
- if(!keyData.equals("")){
|
|
|
- lastStr+="☆"+dataInfo2.getString(ziduan[i])+"_^_"+ziduan[i].split("__")[1];
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- dataMap2.put(k,lastStr);
|
|
|
- }else{
|
|
|
- String dataVal = dataInfo2.getString(dataMap.get(k).get(0));
|
|
|
- dataMap2.put(k, dataVal+"_^_"+dataMap.get(k).get(0).split("__")[1]);
|
|
|
- }
|
|
|
- }
|
|
|
- dataMap2.put("p_key_id",tableInfo.getPkeyId());
|
|
|
- tableInfo.setDataMap(dataMap2);
|
|
|
- result.add(tableInfo);
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void formulaFillData(List<TableInfo> tableInfoList) {
|
|
|
- if(Func.isNotEmpty(tableInfoList)){
|
|
|
- StopWatch stopWatch = new StopWatch();
|
|
|
- String ids =tableInfoList.stream().map(TableInfo::getPkeyId).filter(Func::isNotEmpty).collect(Collectors.joining(","));
|
|
|
- List<Map<String,Object>> list=this.jdbcTemplate.queryForList("SELECT a.p_key_id as nodeId,b.id as fieldId,b.e_key as field,c.init_table_name as tableName from m_wbs_tree_contract a LEFT JOIN m_wbs_form_element b on a.id=b.f_id left JOIN m_wbs_tree c on a.id=c.id where b.is_deleted=0 and a.p_key_id in ("+ids+")");
|
|
|
- List<KeyMapper> keyMappers = JSON.parseArray(JSONArray.toJSONString(list), KeyMapper.class);
|
|
|
- if(Func.isNotEmpty(keyMappers)) {
|
|
|
- Map<String,Map<String,String>> coordinateMap = new HashMap<>(keyMappers.size()*2);
|
|
|
- keyMappers.forEach(e->{
|
|
|
- try {
|
|
|
- if(!coordinateMap.containsKey(e.getTableName())){
|
|
|
- /*不包含定位信息的情况执行*/
|
|
|
- coordinateMap.put(e.getTableName(),getTablbCols(e.getNodeId().toString(),null));
|
|
|
- }
|
|
|
- } catch (FileNotFoundException fileNotFoundException) {
|
|
|
- fileNotFoundException.printStackTrace();
|
|
|
- }
|
|
|
- });
|
|
|
- stopWatch.start("公式处理");
|
|
|
- List<Formula> formulas = this.formulaService.list(Wrappers.<Formula>lambdaQuery().in(Formula::getElementId, keyMappers.stream().map(KeyMapper::getFieldId).distinct().collect(Collectors.toList())));
|
|
|
- TableElementConverter tec = new TableElementConverter(tableInfoList, keyMappers, formulas,coordinateMap,1111111L);
|
|
|
- if (tec.isPresent()) {
|
|
|
- tec.before();
|
|
|
- this.formulaService.execute(tec);
|
|
|
- tec.after();
|
|
|
- }
|
|
|
- stopWatch.stop();
|
|
|
- StaticLog.info("{}", stopWatch);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 保存日志
|
|
|
- */
|
|
|
- private void saveOrUpdateTheLog(List<TableInfo> tableInfoList){
|
|
|
- //查询绑定的节点
|
|
|
- WbsTreePrivate tableNode = this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId, tableInfoList.get(0).getPkeyId()));
|
|
|
- WbsTreePrivate parentNode = this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getProjectId, tableNode.getProjectId()).eq(WbsTreePrivate::getId, tableNode.getParentId()));
|
|
|
-
|
|
|
- //填报日期
|
|
|
- String recordTime = tableInfoList.get(0).getRecordTime();
|
|
|
- if(StringUtils.isEmpty(recordTime)){
|
|
|
- //为空,默认今天
|
|
|
- recordTime = DateUtil.format(new Date(), "yyyy-MM-dd");
|
|
|
- }
|
|
|
-
|
|
|
- String businessId = tableInfoList.get(0).getTheLogId();
|
|
|
- if(StringUtils.isEmpty(businessId)){
|
|
|
-
|
|
|
- //检查是否存在原本的数据
|
|
|
- JSONObject logJson = this.contractLogClient.queryContractLogByPrimaryKeyIdAndRecordTime(parentNode.getPKeyId().toString(), recordTime, tableInfoList.get(0).getContractId());
|
|
|
-
|
|
|
- if(logJson == null){
|
|
|
- businessId = SnowFlakeUtil.getId().toString();
|
|
|
- } else {
|
|
|
- businessId = logJson.getString("dataId");
|
|
|
- if(StringUtils.isEmpty(businessId)){
|
|
|
- businessId = SnowFlakeUtil.getId().toString();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(StringUtils.isNotEmpty(businessId)){
|
|
|
- //删除旧数据
|
|
|
- String delSql = "delete from " + tableNode.getInitTableName() + " where group_id = " + businessId;
|
|
|
- this.jdbcTemplate.execute(delSql);
|
|
|
- }
|
|
|
-
|
|
|
- List<JSONObject> logWbsList = new ArrayList<>();
|
|
|
-
|
|
|
- for(TableInfo tableInfo : tableInfoList){
|
|
|
- WbsTreePrivate wbsTreePrivate = this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId, tableInfo.getPkeyId()));
|
|
|
- if(wbsTreePrivate == null){
|
|
|
- continue;
|
|
|
- }
|
|
|
- String tabName = wbsTreePrivate.getInitTableName();
|
|
|
-
|
|
|
- String id = tableInfo.getBusinessId();
|
|
|
- if(StringUtils.isEmpty(id)){
|
|
|
- id = SnowFlakeUtil.getId() + "";
|
|
|
- }
|
|
|
-
|
|
|
- //拼接SQL
|
|
|
- StringBuilder sql = new StringBuilder("INSERT INTO " + tabName ),
|
|
|
- keySql = new StringBuilder("id, group_id"),
|
|
|
- valSql = new StringBuilder("" + id + ", " + businessId);
|
|
|
- //参数
|
|
|
- LinkedHashMap<String,String> dataMap2 = tableInfo.getDataMap();
|
|
|
- for(String key : dataMap2.keySet()){
|
|
|
- keySql.append(", ").append(key);
|
|
|
- valSql.append(", '").append(dataMap2.get(key)).append("'");
|
|
|
- }
|
|
|
-
|
|
|
- sql.append("(").append(keySql).append(")").append(" values(").append(valSql).append(")");
|
|
|
-
|
|
|
- //新增数据
|
|
|
- try{
|
|
|
- this.jdbcTemplate.execute(sql.toString());
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- List<Object> linkTabIds = tableInfo.getLinkTabIds();
|
|
|
- if(linkTabIds == null || linkTabIds.size() <= 0){
|
|
|
- //这一步主要为了兼容同工序时只想在第一张勾选的情况
|
|
|
- linkTabIds = tableInfoList.get(0).getLinkTabIds();
|
|
|
- }
|
|
|
- if(linkTabIds != null && linkTabIds.size() > 0){
|
|
|
- //处理每个表格的关联情况
|
|
|
- List<JSONObject> jsonLinkTabIds = JSONArray.parseArray(JSONObject.toJSONString(linkTabIds), JSONObject.class);
|
|
|
- for(JSONObject json : jsonLinkTabIds){
|
|
|
- json.put("businessId", id);
|
|
|
- }
|
|
|
- logWbsList.addAll(jsonLinkTabIds);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //保存日志记录
|
|
|
- this.contractLogClient.saveContractLog(new SaveContractLogVO(
|
|
|
- Long.parseLong(businessId),
|
|
|
- tableInfoList.get(0).getProjectId(),
|
|
|
- tableInfoList.get(0).getContractId(),
|
|
|
- parentNode.getPKeyId(),
|
|
|
- tableNode.getPKeyId(),
|
|
|
- parentNode.getMajorDataType(),
|
|
|
- recordTime,
|
|
|
- logWbsList
|
|
|
- ));
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void saveOrUpdateFirst(List<TableInfo> tableInfoList){
|
|
|
- //获取首件绑定的节点
|
|
|
- String firstNodeId = tableInfoList.get(0).getFirstNodeId();
|
|
|
- //获取首件关联的施工记录
|
|
|
- List<JSONObject> linkProcessList = JSONArray.parseArray(JSONObject.toJSONString(tableInfoList.get(0).getLinkProcessList()), JSONObject.class);
|
|
|
- if(linkProcessList == null){
|
|
|
- linkProcessList = new ArrayList<>();
|
|
|
- }
|
|
|
-
|
|
|
- //获取数据所在数据表名
|
|
|
- WbsTreeContract table = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, tableInfoList.get(0).getPkeyId()));
|
|
|
- if(table == null){
|
|
|
- return;
|
|
|
- }
|
|
|
- String tableName = table.getInitTableName();
|
|
|
- if(StringUtils.isEmpty(tableName)){
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- //获取首件记录ID
|
|
|
- String firstId = tableInfoList.get(0).getFirstId();
|
|
|
- if(StringUtils.isNotEmpty(firstId)){
|
|
|
- //删除掉旧数据
|
|
|
- this.jdbcTemplate.execute("DELETE FROM " + tableName + " WHERE group_id = " + firstId);
|
|
|
- } else {
|
|
|
- firstId = SnowFlakeUtil.getId() + "";
|
|
|
- }
|
|
|
-
|
|
|
- //获取上传的文件相关
|
|
|
- String sourceUrl = tableInfoList.get(0).getSourceUrl(),
|
|
|
- pdfUrl = tableInfoList.get(0).getPdfUrl(),
|
|
|
- firstFileName = tableInfoList.get(0).getFirstFileName();
|
|
|
-
|
|
|
- //新增数据
|
|
|
- for(TableInfo tableInfo : tableInfoList){
|
|
|
- //获取字段信息
|
|
|
- LinkedHashMap<String,String> dataMap2 = tableInfo.getDataMap();
|
|
|
-
|
|
|
- //拼接SQL
|
|
|
- StringBuilder sql = new StringBuilder("INSERT INTO " + tableName ),
|
|
|
- keySql = new StringBuilder("id, group_id"),
|
|
|
- valSql = new StringBuilder("" + SnowFlakeUtil.getId() + ", " + firstId);
|
|
|
-
|
|
|
- for(String key : dataMap2.keySet()){
|
|
|
- keySql.append(", ").append(key);
|
|
|
- valSql.append(", '").append(dataMap2.get(key)).append("'");
|
|
|
- }
|
|
|
-
|
|
|
- sql.append("(").append(keySql).append(")").append(" values(").append(valSql).append(")");
|
|
|
-
|
|
|
- //新增数据
|
|
|
- try{
|
|
|
- this.jdbcTemplate.execute(sql.toString());
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- try{
|
|
|
- //新增或修改首件记录
|
|
|
- this.informationQueryClient.saveOrUpdateInformationQueryData(firstNodeId, tableInfoList.get(0).getPkeyId() + "", firstId, "文件名称", Integer.parseInt(tableInfoList.get(0).getClassify()), 2, "true", sourceUrl, pdfUrl, firstFileName, linkProcessList);
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void saveOrUpdateInfo(List<TableInfo> tableInfoList) {
|
|
|
- if(ListUtils.isNotEmpty(tableInfoList)){
|
|
|
- if(StringUtils.isNotEmpty(tableInfoList.get(0).getIsFirst())){
|
|
|
- //首件填报
|
|
|
- this.saveOrUpdateFirst(tableInfoList);
|
|
|
-
|
|
|
- } else if(StringUtils.isNotEmpty(tableInfoList.get(0).getIsTheLog())){
|
|
|
- //日志填报
|
|
|
- this.saveOrUpdateTheLog(tableInfoList);
|
|
|
-
|
|
|
- } else {
|
|
|
- //施工资料填报
|
|
|
- for(TableInfo tableInfo:tableInfoList){
|
|
|
- WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
- .eq(WbsTreeContract::getPKeyId, tableInfo.getPkeyId()));
|
|
|
- if(wbsTreeContract == null){
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- String tabName = wbsTreeContract.getInitTableName();
|
|
|
-
|
|
|
- // 判读修改还是 添加
|
|
|
- String delSql = "delete from "+tabName+" where p_key_id="+tableInfo.getPkeyId();
|
|
|
- jdbcTemplate.execute(delSql);
|
|
|
-
|
|
|
- String sqlInfo="";
|
|
|
- LinkedHashMap<String,String> dataMap2 = tableInfo.getDataMap();
|
|
|
- sqlInfo = "INSERT INTO "+tabName+" ( ";
|
|
|
- String keyStr = "id,";
|
|
|
- String valStr = SnowFlakeUtil.getId() + ",";
|
|
|
- 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 +")";
|
|
|
-
|
|
|
- WbsTreeContract wbsTreeContractByP = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
- .eq(WbsTreeContract::getId, wbsTreeContract.getParentId()).eq(WbsTreeContract::getContractId,tableInfo.getContractId()));
|
|
|
-
|
|
|
- if (wbsTreeContractByP!=null){
|
|
|
- //处理文件提名
|
|
|
- String fileName = this.wbsParamService.createFileTitle(Func.isNotEmpty(wbsTreeContractByP.getOldId())? Long.valueOf(wbsTreeContractByP.getOldId()) :wbsTreeContractByP.getId(), Long.parseLong(wbsTreeContractByP.getContractId()),wbsTreeContractByP);
|
|
|
- fileName = StringUtils.isNotEmpty(fileName) ? fileName : "缺少文件提名配置";
|
|
|
-
|
|
|
- //huangjn 保存成功后调用生成资料查询列表数据
|
|
|
- this.informationQueryClient.saveOrUpdateInformationQueryData(wbsTreeContractByP.getPKeyId()+"", "首件使用字段", "业务ID(主要将来给首件使用)", fileName, Integer.parseInt(tableInfo.getClassify()), 2,"是否是首件(临时,暂时没用到)", "源文件(首件字段)", "pdf文件(首件字段)", "首件上传总结报告名称", new ArrayList<>());
|
|
|
- }
|
|
|
-
|
|
|
- UpdateWrapper<WbsTreeContract> updateWrapper = new UpdateWrapper<>();
|
|
|
- updateWrapper.in("p_key_id",tableInfo.getPkeyId());
|
|
|
- updateWrapper.set("is_tab_pdf",2);
|
|
|
- wbsTreeContractService.update(updateWrapper);
|
|
|
- jdbcTemplate.execute(sqlInfo);
|
|
|
- // pdf 预览添加
|
|
|
- //this.getBussPdfInfo(Long.parseLong(tableInfo.getPkeyId()));
|
|
|
- }
|
|
|
-
|
|
|
- try{
|
|
|
- //获取节点
|
|
|
- WbsTreeContract wbsTreeContract = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, tableInfoList.get(0).getPkeyId()));
|
|
|
-
|
|
|
- WbsTreeContract wbsTreeContractByP = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
- .eq(WbsTreeContract::getId, wbsTreeContract.getParentId()).eq(WbsTreeContract::getContractId, wbsTreeContract.getContractId()));
|
|
|
- //处理文件提名
|
|
|
- String fileName = this.wbsParamService.createFileTitle(Func.isNotEmpty(wbsTreeContractByP.getOldId())? Long.valueOf(wbsTreeContractByP.getOldId()) :wbsTreeContractByP.getId(), Long.parseLong(wbsTreeContractByP.getContractId()),wbsTreeContractByP);
|
|
|
- fileName = StringUtils.isNotEmpty(fileName) ? fileName : "缺少文件提名配置";
|
|
|
-
|
|
|
- //huangjn 保存成功后调用生成资料查询列表数据
|
|
|
- this.informationQueryClient.saveOrUpdateInformationQueryData(wbsTreeContractByP.getPKeyId()+"", "首件使用字段", "业务ID(主要将来给首件使用)", fileName, Integer.parseInt(tableInfoList.get(0).getClassify()), 2,"false", "源文件(首件字段)", "pdf文件(首件字段)", "首件上传总结报告名称", new ArrayList<>());
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- // 获取用户
|
|
|
- @Override
|
|
|
- public Map<String,String> getTablbCols(String pkeyid, String colkey) throws FileNotFoundException {
|
|
|
- Map<String,String> dataMap = new HashMap<>();
|
|
|
- if(StringUtils.isEmpty(pkeyid)){
|
|
|
- return null;
|
|
|
- }
|
|
|
- //获取html
|
|
|
- WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
- .eq(WbsTreeContract::getPKeyId,pkeyid));
|
|
|
- if(Func.isEmpty(wbsTreeContract.getHtmlUrl())){
|
|
|
- return dataMap;
|
|
|
- }
|
|
|
- File file1 = ResourceUtil.getFile(wbsTreeContract.getHtmlUrl());
|
|
|
-
|
|
|
- FileInputStream fileInputStream = new FileInputStream(file1);
|
|
|
- String htmlString = IoUtil.readToString(fileInputStream);
|
|
|
- Document doc = Jsoup.parse(htmlString);
|
|
|
- Element table = doc.select("table").first();
|
|
|
- Elements trs = table.select("tr");
|
|
|
-
|
|
|
- for (int i = 0; i <= trs.size() - 1; i++) {
|
|
|
- Element tr = trs.get(i);
|
|
|
- Elements tds = tr.select("td");
|
|
|
- for (int j = 0; j < tds.size(); j++) {
|
|
|
- Element data = tds.get(j);
|
|
|
- if(!data.children().isEmpty()){
|
|
|
- // String x1 = data.children().get(0).attr("x1");
|
|
|
- // String y1 = data.children().get(0).attr("y1");
|
|
|
- String keyVal = i+"_"+j;
|
|
|
- String keyname = data.children().get(0).attr("keyname");
|
|
|
- if(StringUtils.isNotEmpty(keyname)){
|
|
|
- String[] keys = keyname.split("__");
|
|
|
- String datakey = keys[0];
|
|
|
- dataMap.merge(datakey,keyVal,(v1,v2)-> v1+";"+v2);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return dataMap;
|
|
|
- }
|
|
|
+ //客户端资料查询接口
|
|
|
+ private final InformationQueryClient informationQueryClient;
|
|
|
+ // 元素信息表-
|
|
|
+ private final IWbsTreeContractService wbsTreeContractService;
|
|
|
+ private final IWbsTreeService wbsTreeService;
|
|
|
+ private final IFormulaService formulaService;
|
|
|
+ private final JdbcTemplate jdbcTemplate;
|
|
|
+
|
|
|
+ private final IWbsParamService wbsParamService;
|
|
|
+
|
|
|
+ private final IWbsTreePrivateService wbsTreePrivateService;
|
|
|
+
|
|
|
+ private final ContractLogClient contractLogClient;
|
|
|
+
|
|
|
+ // 表单字典信息表
|
|
|
+ private final ITextdictInfoService textdictInfoService;
|
|
|
+
|
|
|
+ // Oss接口
|
|
|
+ private final NewIOSSClient newIOSSClient;
|
|
|
+ // 表单附件信息
|
|
|
+ private final ITableFileService tableFileService;
|
|
|
+
|
|
|
+ // 合同端信息
|
|
|
+ private final IContractInfoService contractInfoService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<ExcelTabVO> selectExcelTabPage(IPage<ExcelTabVO> page, ExcelTabVO excelTab) {
|
|
|
+ return page.setRecords(baseMapper.selectExcelTabPage(page, excelTab));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<ExceTabTreVO> tabLazyTree(String tenantId, Long modeId, Long parentId) {
|
|
|
+ if (AuthUtil.isAdministrator()) {
|
|
|
+ tenantId = StringPool.EMPTY;
|
|
|
+ }
|
|
|
+ List<ExceTabTreVO> ls = baseMapper.tabLazyTree(tenantId, modeId, parentId + "");
|
|
|
+ return ForestNodeMerger.merge(ls);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<ExceTabTreVO> tabLazyTreeAll(String tenantId, Long modeId, String name) {
|
|
|
+ if (AuthUtil.isAdministrator()) {
|
|
|
+ tenantId = StringPool.EMPTY;
|
|
|
+ }
|
|
|
+ return ForestNodeMerger.merge(baseMapper.tabLazyTreeAll(tenantId, modeId, name));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<ExcelTabWbsTypeVO> getWbsTypeList(Integer wbstType) {
|
|
|
+ return baseMapper.getWbsTypeList(wbstType + "");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<WbsTreeVO> lazyTree(String wbsId, String tenantId, Long parentId) {
|
|
|
+ if (AuthUtil.isAdministrator()) {
|
|
|
+ tenantId = StringPool.EMPTY;
|
|
|
+ }
|
|
|
+ return ForestNodeMerger.merge(baseMapper.lazyTree(wbsId, tenantId, parentId));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 私有项目 wbs 树
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<WbsTreeVO> lazyTreeByPri(String wbsId, String tenantId, Long parentId) {
|
|
|
+ if (AuthUtil.isAdministrator()) {
|
|
|
+ tenantId = StringPool.EMPTY;
|
|
|
+ }
|
|
|
+ return ForestNodeMerger.merge(baseMapper.lazyTreeByPri(wbsId, tenantId, parentId));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean removeBussTabInfoById(String pkeyid) {
|
|
|
+ baseMapper.removeBussTabInfoById(pkeyid);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void setFirstData(JSONObject dataInfo2, TableInfo tableInfo) {
|
|
|
+ //huangjn 判断是否是首件
|
|
|
+ if (dataInfo2.containsKey("isFirst")) {
|
|
|
+ tableInfo.setIsFirst(dataInfo2.getString("isFirst"));
|
|
|
+ }
|
|
|
+ //huangjn 判断是否是首件
|
|
|
+
|
|
|
+ //首件资料绑定的节点
|
|
|
+ if (dataInfo2.containsKey("firstNodeId")) {
|
|
|
+ tableInfo.setFirstNodeId(dataInfo2.getString("firstNodeId"));
|
|
|
+ }
|
|
|
+ //首件ID(编辑时有值,新增时为空)
|
|
|
+ if (dataInfo2.containsKey("firstId")) {
|
|
|
+ tableInfo.setFirstId(dataInfo2.getString("firstId"));
|
|
|
+ }
|
|
|
+ //源文件
|
|
|
+ if (dataInfo2.containsKey("sourceUrl")) {
|
|
|
+ tableInfo.setSourceUrl(dataInfo2.getString("sourceUrl"));
|
|
|
+ }
|
|
|
+ //pdfUrl
|
|
|
+ if (dataInfo2.containsKey("pdfUrl")) {
|
|
|
+ tableInfo.setPdfUrl(dataInfo2.getString("pdfUrl"));
|
|
|
+ }
|
|
|
+ //文件名称
|
|
|
+ if (dataInfo2.containsKey("firstFileName")) {
|
|
|
+ tableInfo.setFirstFileName(dataInfo2.getString("firstFileName"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置日志信息
|
|
|
+ */
|
|
|
+ private void setTheLogData(JSONObject dataInfo2, TableInfo tableInfo) {
|
|
|
+ //huangjn 判断是否是日志
|
|
|
+ if (dataInfo2.containsKey("isTheLog")) {
|
|
|
+ tableInfo.setIsTheLog(dataInfo2.getString("isTheLog"));
|
|
|
+ }
|
|
|
+ //huangjn 判断是否是日志
|
|
|
+
|
|
|
+ //huangjn 日志ID
|
|
|
+ if (dataInfo2.containsKey("theLogId")) {
|
|
|
+ tableInfo.setTheLogId(dataInfo2.getString("theLogId"));
|
|
|
+ }
|
|
|
+ //huangjn 日志ID
|
|
|
+
|
|
|
+ //huangjn 日志勾选的工序
|
|
|
+ if (dataInfo2.containsKey("linkTabIds")) {
|
|
|
+ tableInfo.setLinkTabIds(dataInfo2.getJSONArray("linkTabIds"));
|
|
|
+ }
|
|
|
+ //huangjn 日志勾选的工序
|
|
|
+
|
|
|
+ //huangjn 日志所选时间
|
|
|
+ if (dataInfo2.containsKey("recordTime")) {
|
|
|
+ tableInfo.setRecordTime(dataInfo2.getString("recordTime"));
|
|
|
+ }
|
|
|
+ //huangjn 日志所选时间
|
|
|
+ //huangjn 每份填报数据的id,目前日志专用
|
|
|
+ if (dataInfo2.containsKey("id")) {
|
|
|
+ tableInfo.setBusinessId(dataInfo2.getString("id"));
|
|
|
+ }
|
|
|
+ //huangjn 每份填报数据的id,目前日志专用
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<TableInfo> getTableInfoList(JSONArray dataArray) {
|
|
|
+ if (dataArray != null && !dataArray.isEmpty()) {
|
|
|
+ List<TableInfo> result = new ArrayList<>();
|
|
|
+ for (int m = 0; m < dataArray.size(); m++) {
|
|
|
+ TableInfo tableInfo = new TableInfo();
|
|
|
+ JSONObject dataInfo2 = dataArray.getJSONObject(m);
|
|
|
+ //
|
|
|
+ tableInfo.setContractId(dataInfo2.getString("contractId"));
|
|
|
+ tableInfo.setPkeyId(dataInfo2.getString("pkeyId"));
|
|
|
+ tableInfo.setProjectId(dataInfo2.getString("projectId"));
|
|
|
+ //huangjn 填报的类型,施工或监理
|
|
|
+ tableInfo.setClassify(dataInfo2.getString("classify"));
|
|
|
+ //huangjn 填报的类型,施工或监理
|
|
|
+
|
|
|
+ //设置首件信息
|
|
|
+ this.setFirstData(dataInfo2, tableInfo);
|
|
|
+ //设置日志信息
|
|
|
+ this.setTheLogData(dataInfo2, tableInfo);
|
|
|
+
|
|
|
+ dataInfo2.fluentRemove("contractId")
|
|
|
+ .fluentRemove("pkeyId")
|
|
|
+ .fluentRemove("p_key_id")
|
|
|
+ .fluentRemove("projectId")
|
|
|
+ .fluentRemove("classify")
|
|
|
+ .fluentRemove("pickerKey")
|
|
|
+ .fluentRemove("id")
|
|
|
+ .fluentRemove("isFirst")
|
|
|
+ .fluentRemove("firstNodeId")
|
|
|
+ .fluentRemove("isTheLog")
|
|
|
+ .fluentRemove("theLogId")
|
|
|
+ .fluentRemove("linkTabIds")
|
|
|
+ .fluentRemove("recordTime")
|
|
|
+ .fluentRemove("businessId")
|
|
|
+ .fluentRemove("sourceUrl")
|
|
|
+ .fluentRemove("pdfUrl")
|
|
|
+ .fluentRemove("firstFileName")
|
|
|
+ .fluentRemove("");
|
|
|
+ // 计算数据
|
|
|
+ LinkedHashMap<String, List<String>> dataMap = dataInfo2.keySet().stream().filter(e -> e.contains("__")).collect(Collectors.groupingBy(e -> e.split("__")[0], LinkedHashMap<String, List<String>>::new, Collectors.toList()));
|
|
|
+ LinkedHashMap<String, String> dataMap2 = new LinkedHashMap<>();
|
|
|
+ // 字段组合
|
|
|
+ for (String k : dataMap.keySet()) {
|
|
|
+ if (dataMap.get(k).size() > 1 && !dataMap.get(k).contains("000Z")) {
|
|
|
+ String[] ziduan = dataMap.get(k).toArray(new String[]{});
|
|
|
+ String temp = "";
|
|
|
+ for (int i = 0; i < ziduan.length - 1; i++) {
|
|
|
+ for (int j = 0; j < ziduan.length - i - 1; j++) {
|
|
|
+ Integer tr = Integer.parseInt((ziduan[j].split("__")[1]).split("_")[0]);
|
|
|
+ Integer td = Integer.parseInt(ziduan[j].split("__")[1].split("_")[1]);
|
|
|
+
|
|
|
+ Integer tr_1 = Integer.parseInt(ziduan[j + 1].split("__")[1].split("_")[0]);
|
|
|
+ Integer td_1 = Integer.parseInt(ziduan[j + 1].split("__")[1].split("_")[1]);
|
|
|
+
|
|
|
+ if (tr > tr_1 && td == td_1) { //纵向排序
|
|
|
+ temp = ziduan[j];
|
|
|
+ ziduan[j] = ziduan[j + 1];
|
|
|
+ ziduan[j + 1] = temp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String lastStr = dataInfo2.getString(ziduan[0]) + "_^_" + ziduan[0].split("__")[1];
|
|
|
+ for (int i = 1; i < ziduan.length; i++) {
|
|
|
+ String keyData = dataInfo2.getString(ziduan[i]);
|
|
|
+ if (!keyData.equals("")) {
|
|
|
+ lastStr += "☆" + dataInfo2.getString(ziduan[i]) + "_^_" + ziduan[i].split("__")[1];
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ dataMap2.put(k, lastStr);
|
|
|
+ } else {
|
|
|
+ String dataVal = dataInfo2.getString(dataMap.get(k).get(0));
|
|
|
+ dataMap2.put(k, dataVal + "_^_" + dataMap.get(k).get(0).split("__")[1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dataMap2.put("p_key_id", tableInfo.getPkeyId());
|
|
|
+ tableInfo.setDataMap(dataMap2);
|
|
|
+ result.add(tableInfo);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void formulaFillData(List<TableInfo> tableInfoList) {
|
|
|
+ if (Func.isNotEmpty(tableInfoList)) {
|
|
|
+ StopWatch stopWatch = new StopWatch();
|
|
|
+ String ids = tableInfoList.stream().map(TableInfo::getPkeyId).filter(Func::isNotEmpty).collect(Collectors.joining(","));
|
|
|
+ List<Map<String, Object>> list = this.jdbcTemplate.queryForList("SELECT a.p_key_id as nodeId,b.id as fieldId,b.e_key as field,c.init_table_name as tableName from m_wbs_tree_contract a LEFT JOIN m_wbs_form_element b on a.id=b.f_id left JOIN m_wbs_tree c on a.id=c.id where b.is_deleted=0 and a.p_key_id in (" + ids + ")");
|
|
|
+ List<KeyMapper> keyMappers = JSON.parseArray(JSONArray.toJSONString(list), KeyMapper.class);
|
|
|
+ if (Func.isNotEmpty(keyMappers)) {
|
|
|
+ Map<String, Map<String, String>> coordinateMap = new HashMap<>(keyMappers.size() * 2);
|
|
|
+ keyMappers.forEach(e -> {
|
|
|
+ try {
|
|
|
+ if (!coordinateMap.containsKey(e.getTableName())) {
|
|
|
+ /*不包含定位信息的情况执行*/
|
|
|
+ coordinateMap.put(e.getTableName(), getTablbCols(e.getNodeId().toString(), null));
|
|
|
+ }
|
|
|
+ } catch (FileNotFoundException fileNotFoundException) {
|
|
|
+ fileNotFoundException.printStackTrace();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ stopWatch.start("公式处理");
|
|
|
+ List<Formula> formulas = this.formulaService.list(Wrappers.<Formula>lambdaQuery().in(Formula::getElementId, keyMappers.stream().map(KeyMapper::getFieldId).distinct().collect(Collectors.toList())));
|
|
|
+ TableElementConverter tec = new TableElementConverter(tableInfoList, keyMappers, formulas, coordinateMap, 1111111L);
|
|
|
+ if (tec.isPresent()) {
|
|
|
+ tec.before();
|
|
|
+ this.formulaService.execute(tec);
|
|
|
+ tec.after();
|
|
|
+ }
|
|
|
+ stopWatch.stop();
|
|
|
+ StaticLog.info("{}", stopWatch);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存日志
|
|
|
+ */
|
|
|
+ private void saveOrUpdateTheLog(List<TableInfo> tableInfoList) {
|
|
|
+ //查询绑定的节点
|
|
|
+ WbsTreePrivate tableNode = this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId, tableInfoList.get(0).getPkeyId()));
|
|
|
+ WbsTreePrivate parentNode = this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getProjectId, tableNode.getProjectId()).eq(WbsTreePrivate::getId, tableNode.getParentId()));
|
|
|
+
|
|
|
+ //填报日期
|
|
|
+ String recordTime = tableInfoList.get(0).getRecordTime();
|
|
|
+ if (StringUtils.isEmpty(recordTime)) {
|
|
|
+ //为空,默认今天
|
|
|
+ recordTime = DateUtil.format(new Date(), "yyyy-MM-dd");
|
|
|
+ }
|
|
|
+
|
|
|
+ String businessId = tableInfoList.get(0).getTheLogId();
|
|
|
+ if (StringUtils.isEmpty(businessId)) {
|
|
|
+
|
|
|
+ //检查是否存在原本的数据
|
|
|
+ JSONObject logJson = this.contractLogClient.queryContractLogByPrimaryKeyIdAndRecordTime(parentNode.getPKeyId().toString(), recordTime, tableInfoList.get(0).getContractId());
|
|
|
+
|
|
|
+ if (logJson == null) {
|
|
|
+ businessId = SnowFlakeUtil.getId().toString();
|
|
|
+ } else {
|
|
|
+ businessId = logJson.getString("dataId");
|
|
|
+ if (StringUtils.isEmpty(businessId)) {
|
|
|
+ businessId = SnowFlakeUtil.getId().toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(businessId)) {
|
|
|
+ //删除旧数据
|
|
|
+ String delSql = "delete from " + tableNode.getInitTableName() + " where group_id = " + businessId;
|
|
|
+ this.jdbcTemplate.execute(delSql);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<JSONObject> logWbsList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (TableInfo tableInfo : tableInfoList) {
|
|
|
+ WbsTreePrivate wbsTreePrivate = this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId, tableInfo.getPkeyId()));
|
|
|
+ if (wbsTreePrivate == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String tabName = wbsTreePrivate.getInitTableName();
|
|
|
+
|
|
|
+ String id = tableInfo.getBusinessId();
|
|
|
+ if (StringUtils.isEmpty(id)) {
|
|
|
+ id = SnowFlakeUtil.getId() + "";
|
|
|
+ }
|
|
|
+
|
|
|
+ //拼接SQL
|
|
|
+ StringBuilder sql = new StringBuilder("INSERT INTO " + tabName),
|
|
|
+ keySql = new StringBuilder("id, group_id"),
|
|
|
+ valSql = new StringBuilder("" + id + ", " + businessId);
|
|
|
+ //参数
|
|
|
+ LinkedHashMap<String, String> dataMap2 = tableInfo.getDataMap();
|
|
|
+ for (String key : dataMap2.keySet()) {
|
|
|
+ keySql.append(", ").append(key);
|
|
|
+ valSql.append(", '").append(dataMap2.get(key)).append("'");
|
|
|
+ }
|
|
|
+
|
|
|
+ sql.append("(").append(keySql).append(")").append(" values(").append(valSql).append(")");
|
|
|
+
|
|
|
+ //新增数据
|
|
|
+ try {
|
|
|
+ this.jdbcTemplate.execute(sql.toString());
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<Object> linkTabIds = tableInfo.getLinkTabIds();
|
|
|
+ if (linkTabIds == null || linkTabIds.size() <= 0) {
|
|
|
+ //这一步主要为了兼容同工序时只想在第一张勾选的情况
|
|
|
+ linkTabIds = tableInfoList.get(0).getLinkTabIds();
|
|
|
+ }
|
|
|
+ if (linkTabIds != null && linkTabIds.size() > 0) {
|
|
|
+ //处理每个表格的关联情况
|
|
|
+ List<JSONObject> jsonLinkTabIds = JSONArray.parseArray(JSONObject.toJSONString(linkTabIds), JSONObject.class);
|
|
|
+ for (JSONObject json : jsonLinkTabIds) {
|
|
|
+ json.put("businessId", id);
|
|
|
+ }
|
|
|
+ logWbsList.addAll(jsonLinkTabIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //保存日志记录
|
|
|
+ this.contractLogClient.saveContractLog(new SaveContractLogVO(
|
|
|
+ Long.parseLong(businessId),
|
|
|
+ tableInfoList.get(0).getProjectId(),
|
|
|
+ tableInfoList.get(0).getContractId(),
|
|
|
+ parentNode.getPKeyId(),
|
|
|
+ tableNode.getPKeyId(),
|
|
|
+ parentNode.getMajorDataType(),
|
|
|
+ recordTime,
|
|
|
+ logWbsList
|
|
|
+ ));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void saveOrUpdateFirst(List<TableInfo> tableInfoList) {
|
|
|
+ //获取首件绑定的节点
|
|
|
+ String firstNodeId = tableInfoList.get(0).getFirstNodeId();
|
|
|
+ //获取首件关联的施工记录
|
|
|
+ List<JSONObject> linkProcessList = JSONArray.parseArray(JSONObject.toJSONString(tableInfoList.get(0).getLinkProcessList()), JSONObject.class);
|
|
|
+ if (linkProcessList == null) {
|
|
|
+ linkProcessList = new ArrayList<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取数据所在数据表名
|
|
|
+ WbsTreeContract table = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, tableInfoList.get(0).getPkeyId()));
|
|
|
+ if (table == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String tableName = table.getInitTableName();
|
|
|
+ if (StringUtils.isEmpty(tableName)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取首件记录ID
|
|
|
+ String firstId = tableInfoList.get(0).getFirstId();
|
|
|
+ if (StringUtils.isNotEmpty(firstId)) {
|
|
|
+ //删除掉旧数据
|
|
|
+ this.jdbcTemplate.execute("DELETE FROM " + tableName + " WHERE group_id = " + firstId);
|
|
|
+ } else {
|
|
|
+ firstId = SnowFlakeUtil.getId() + "";
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取上传的文件相关
|
|
|
+ String sourceUrl = tableInfoList.get(0).getSourceUrl(),
|
|
|
+ pdfUrl = tableInfoList.get(0).getPdfUrl(),
|
|
|
+ firstFileName = tableInfoList.get(0).getFirstFileName();
|
|
|
+
|
|
|
+ //新增数据
|
|
|
+ for (TableInfo tableInfo : tableInfoList) {
|
|
|
+ //获取字段信息
|
|
|
+ LinkedHashMap<String, String> dataMap2 = tableInfo.getDataMap();
|
|
|
+
|
|
|
+ //拼接SQL
|
|
|
+ StringBuilder sql = new StringBuilder("INSERT INTO " + tableName),
|
|
|
+ keySql = new StringBuilder("id, group_id"),
|
|
|
+ valSql = new StringBuilder("" + SnowFlakeUtil.getId() + ", " + firstId);
|
|
|
+
|
|
|
+ for (String key : dataMap2.keySet()) {
|
|
|
+ keySql.append(", ").append(key);
|
|
|
+ valSql.append(", '").append(dataMap2.get(key)).append("'");
|
|
|
+ }
|
|
|
+
|
|
|
+ sql.append("(").append(keySql).append(")").append(" values(").append(valSql).append(")");
|
|
|
+
|
|
|
+ //新增数据
|
|
|
+ try {
|
|
|
+ this.jdbcTemplate.execute(sql.toString());
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ //新增或修改首件记录
|
|
|
+ this.informationQueryClient.saveOrUpdateInformationQueryData(firstNodeId, tableInfoList.get(0).getPkeyId() + "", firstId, "文件名称", Integer.parseInt(tableInfoList.get(0).getClassify()), 2, "true", sourceUrl, pdfUrl, firstFileName, linkProcessList);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void saveOrUpdateInfo(List<TableInfo> tableInfoList) {
|
|
|
+ if (ListUtils.isNotEmpty(tableInfoList)) {
|
|
|
+ if (StringUtils.isNotEmpty(tableInfoList.get(0).getIsFirst())) {
|
|
|
+ //首件填报
|
|
|
+ this.saveOrUpdateFirst(tableInfoList);
|
|
|
+
|
|
|
+ } else if (StringUtils.isNotEmpty(tableInfoList.get(0).getIsTheLog())) {
|
|
|
+ //日志填报
|
|
|
+ this.saveOrUpdateTheLog(tableInfoList);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ //施工资料填报
|
|
|
+ for (TableInfo tableInfo : tableInfoList) {
|
|
|
+ WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
+ .eq(WbsTreeContract::getPKeyId, tableInfo.getPkeyId()));
|
|
|
+ if (wbsTreeContract == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ String tabName = wbsTreeContract.getInitTableName();
|
|
|
+
|
|
|
+ // 判读修改还是 添加
|
|
|
+ String delSql = "delete from " + tabName + " where p_key_id=" + tableInfo.getPkeyId();
|
|
|
+ jdbcTemplate.execute(delSql);
|
|
|
+
|
|
|
+ String sqlInfo = "";
|
|
|
+ LinkedHashMap<String, String> dataMap2 = tableInfo.getDataMap();
|
|
|
+ sqlInfo = "INSERT INTO " + tabName + " ( ";
|
|
|
+ String keyStr = "id,";
|
|
|
+ String valStr = SnowFlakeUtil.getId() + ",";
|
|
|
+ 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 + ")";
|
|
|
+
|
|
|
+ WbsTreeContract wbsTreeContractByP = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
+ .eq(WbsTreeContract::getId, wbsTreeContract.getParentId()).eq(WbsTreeContract::getContractId, tableInfo.getContractId()));
|
|
|
+
|
|
|
+ if (wbsTreeContractByP != null) {
|
|
|
+ //处理文件提名
|
|
|
+ String fileName = this.wbsParamService.createFileTitle(Func.isNotEmpty(wbsTreeContractByP.getOldId()) ? Long.valueOf(wbsTreeContractByP.getOldId()) : wbsTreeContractByP.getId(), Long.parseLong(wbsTreeContractByP.getContractId()), wbsTreeContractByP);
|
|
|
+ fileName = StringUtils.isNotEmpty(fileName) ? fileName : "缺少文件提名配置";
|
|
|
+
|
|
|
+ //huangjn 保存成功后调用生成资料查询列表数据
|
|
|
+ this.informationQueryClient.saveOrUpdateInformationQueryData(wbsTreeContractByP.getPKeyId() + "", "首件使用字段", "业务ID(主要将来给首件使用)", fileName, Integer.parseInt(tableInfo.getClassify()), 2, "是否是首件(临时,暂时没用到)", "源文件(首件字段)", "pdf文件(首件字段)", "首件上传总结报告名称", new ArrayList<>());
|
|
|
+ }
|
|
|
+
|
|
|
+ UpdateWrapper<WbsTreeContract> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.in("p_key_id", tableInfo.getPkeyId());
|
|
|
+ updateWrapper.set("is_tab_pdf", 2);
|
|
|
+ wbsTreeContractService.update(updateWrapper);
|
|
|
+ jdbcTemplate.execute(sqlInfo);
|
|
|
+ // pdf 预览添加
|
|
|
+ //this.getBussPdfInfo(Long.parseLong(tableInfo.getPkeyId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ //获取节点
|
|
|
+ WbsTreeContract wbsTreeContract = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, tableInfoList.get(0).getPkeyId()));
|
|
|
+
|
|
|
+ WbsTreeContract wbsTreeContractByP = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
+ .eq(WbsTreeContract::getId, wbsTreeContract.getParentId()).eq(WbsTreeContract::getContractId, wbsTreeContract.getContractId()));
|
|
|
+ //处理文件提名
|
|
|
+ String fileName = this.wbsParamService.createFileTitle(Func.isNotEmpty(wbsTreeContractByP.getOldId()) ? Long.valueOf(wbsTreeContractByP.getOldId()) : wbsTreeContractByP.getId(), Long.parseLong(wbsTreeContractByP.getContractId()), wbsTreeContractByP);
|
|
|
+ fileName = StringUtils.isNotEmpty(fileName) ? fileName : "缺少文件提名配置";
|
|
|
+
|
|
|
+ //huangjn 保存成功后调用生成资料查询列表数据
|
|
|
+ this.informationQueryClient.saveOrUpdateInformationQueryData(wbsTreeContractByP.getPKeyId() + "", "首件使用字段", "业务ID(主要将来给首件使用)", fileName, Integer.parseInt(tableInfoList.get(0).getClassify()), 2, "false", "源文件(首件字段)", "pdf文件(首件字段)", "首件上传总结报告名称", new ArrayList<>());
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 获取用户
|
|
|
+ @Override
|
|
|
+ public Map<String, String> getTablbCols(String pkeyid, String colkey) throws FileNotFoundException {
|
|
|
+ Map<String, String> dataMap = new HashMap<>();
|
|
|
+ if (StringUtils.isEmpty(pkeyid)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ //获取html
|
|
|
+ WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
+ .eq(WbsTreeContract::getPKeyId, pkeyid));
|
|
|
+ if (Func.isEmpty(wbsTreeContract.getHtmlUrl())) {
|
|
|
+ return dataMap;
|
|
|
+ }
|
|
|
+ File file1 = ResourceUtil.getFile(wbsTreeContract.getHtmlUrl());
|
|
|
+
|
|
|
+ FileInputStream fileInputStream = new FileInputStream(file1);
|
|
|
+ String htmlString = IoUtil.readToString(fileInputStream);
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
+ Element table = doc.select("table").first();
|
|
|
+ Elements trs = table.select("tr");
|
|
|
+
|
|
|
+ for (int i = 0; i <= trs.size() - 1; i++) {
|
|
|
+ Element tr = trs.get(i);
|
|
|
+ Elements tds = tr.select("td");
|
|
|
+ for (int j = 0; j < tds.size(); j++) {
|
|
|
+ Element data = tds.get(j);
|
|
|
+ if (!data.children().isEmpty()) {
|
|
|
+ // String x1 = data.children().get(0).attr("x1");
|
|
|
+ // String y1 = data.children().get(0).attr("y1");
|
|
|
+ String keyVal = i + "_" + j;
|
|
|
+ String keyname = data.children().get(0).attr("keyname");
|
|
|
+ if (StringUtils.isNotEmpty(keyname)) {
|
|
|
+ String[] keys = keyname.split("__");
|
|
|
+ String datakey = keys[0];
|
|
|
+ dataMap.merge(datakey, keyVal, (v1, v2) -> v1 + ";" + v2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return dataMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R getBussPdfInfo(Long pkeyId) throws Exception {
|
|
|
+
|
|
|
+ String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
+
|
|
|
+ WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
+ .eq(WbsTreeContract::getPKeyId, pkeyId));
|
|
|
+
|
|
|
+ if (wbsTreeContract == null) {
|
|
|
+ return R.fail("该数据下无此节点!");
|
|
|
+ }
|
|
|
+ if (wbsTreeContract.getHtmlUrl() == null) {
|
|
|
+ return R.fail("请关联清表!");
|
|
|
+ }
|
|
|
+
|
|
|
+ String pdfPath = file_path + "/pdf//" + pkeyId + ".pdf";
|
|
|
+ File tabpdf = ResourceUtil.getFile(pdfPath);
|
|
|
+ if (tabpdf.exists()) {
|
|
|
+ tabpdf.delete();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取清表信息
|
|
|
+ ExcelTab excelTab = this.getById(wbsTreeContract.getExcelId());
|
|
|
+
|
|
|
+ if (excelTab == null) {
|
|
|
+ return R.fail("失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> DataInfo = (Map<String, Object>) getBussDataInfo(pkeyId).getData();
|
|
|
+
|
|
|
+ // 获取excel流 和 html流
|
|
|
+ Workbook wb = new Workbook();
|
|
|
+ wb.loadFromMHtml(CommonUtil.getOSSInputStream(excelTab.getFileUrl()));
|
|
|
+ //获取工作表
|
|
|
+ Worksheet sheet = wb.getWorksheets().get(0);
|
|
|
+
|
|
|
+
|
|
|
+ // 数据不为空 &&
|
|
|
+ if (StringUtils.isNotEmpty(wbsTreeContract.getHtmlUrl())) {
|
|
|
+ File htmlFile = ResourceUtil.getFile(wbsTreeContract.getHtmlUrl());
|
|
|
+ if (htmlFile.exists()) {
|
|
|
+ String htmlString = IoUtil.readToString(new FileInputStream(htmlFile));
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
+ Element table = doc.select("table").first();
|
|
|
+ Elements trs = table.select("tr");
|
|
|
+ Elements cols = table.select("col");
|
|
|
+
|
|
|
+ if (ObjectUtil.isNotEmpty(DataInfo)) {
|
|
|
+ for (String val : DataInfo.keySet()) {
|
|
|
+ if (val.indexOf("__") >= 0) {
|
|
|
+ String DataVal[] = val.split("__");
|
|
|
+ String[] xy = DataVal[1].split("_");
|
|
|
+ Element data = trs.get(Integer.parseInt(xy[0])).select("td").get(Integer.parseInt(xy[1]));
|
|
|
+
|
|
|
+ if (data.html().indexOf("x1") >= 0 && data.html().indexOf("y1") >= 0) {
|
|
|
+ int x1 = 0;
|
|
|
+ int y1 = 0;
|
|
|
+
|
|
|
+ if (data.html().indexOf("el-tooltip") >= 0) {
|
|
|
+ x1 = Integer.parseInt(data.children().get(0).children().get(0).attr("x1"));
|
|
|
+ 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.indexOf("T") >= 0 && myData.indexOf("-") >= 0) {
|
|
|
+ if (myData.indexOf(",") >= 0 && myData.indexOf("]") >= 0) {
|
|
|
+ myData = myData.replace("[", "").replace("]", "");
|
|
|
+ String[] dataVal = myData.split(",");
|
|
|
+ String Start_dataStr[] = dataVal[0].split("T")[0].split("-");
|
|
|
+ String StartDate = StringUtil.format("{}年{}月{}日", new Object[]{Start_dataStr[0], Start_dataStr[1], Integer.parseInt(Start_dataStr[2]) + 1});
|
|
|
+
|
|
|
+ String end_dataStr[] = dataVal[1].split("T")[0].split("-");
|
|
|
+ String endDate = StringUtil.format("{}年{}月{}日", new Object[]{end_dataStr[0], end_dataStr[1], Integer.parseInt(end_dataStr[2]) + 1});
|
|
|
+
|
|
|
+ if (StartDate.equals(endDate)) {
|
|
|
+ myData = StartDate;
|
|
|
+ } else {
|
|
|
+ myData = StartDate + "-" + endDate;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ String dataStr[] = myData.split("T")[0].split("-");
|
|
|
+ myData = StringUtil.format("{}年{}月{}日", new Object[]{dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]) + 1});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //https:bladex-test-info.oss-cn-chengdu.aliyuncs.com//upload/20220819/b53cb6700db369381e3b03d7737bcdec.jpg__16_1
|
|
|
+ if (myData.indexOf("https") >= 0 && myData.indexOf("aliyuncs") >= 0) {
|
|
|
+
|
|
|
+ BufferedImage image = ImageIO.read(CommonUtil.getOSSInputStream(myData));
|
|
|
+
|
|
|
+ int colspan = Integer.parseInt(data.attr("colspan"));
|
|
|
+ int rowspan = Integer.parseInt(data.attr("rowspan"));
|
|
|
+ int picHeight = 0;
|
|
|
+ int picWidth = 0;
|
|
|
+ for (int i = y1; i <= (y1 + rowspan); i++) { // 跨列处理
|
|
|
+ String dataInfo = trs.get(i).attr("height");
|
|
|
+ if (StringUtils.isNotEmpty(dataInfo)) {
|
|
|
+ picHeight += Integer.parseInt(dataInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (colspan >= 1) { //框行处理
|
|
|
+ for (int i = x1 - 1; i < x1 + colspan - 1; i++) {
|
|
|
+ String dataInfo = cols.get(i).attr("width").replaceAll("px", "");
|
|
|
+ if (StringUtils.isNotEmpty(dataInfo)) {
|
|
|
+ picWidth += Integer.parseInt(dataInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ExcelPicture pic = sheet.getPictures().add(y1, x1, image);
|
|
|
+ pic.setWidth(picWidth - 10);
|
|
|
+ pic.setHeight(picHeight);
|
|
|
+ pic.setLeft(5);
|
|
|
+ } else {
|
|
|
+ final CellRange cellRange = sheet.getCellRange(y1, x1);
|
|
|
+ cellRange.setText(myData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 组装电签设置
|
|
|
+ QueryWrapper<TextdictInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("type", 2);
|
|
|
+ queryWrapper.eq("tab_id", wbsTreeContract.getIsTypePrivatePid());
|
|
|
+
|
|
|
+ final List<TextdictInfo> textdictInfos = textdictInfoService.getBaseMapper().selectList(queryWrapper);
|
|
|
+ if (textdictInfos != null && !textdictInfos.isEmpty()) {
|
|
|
+ textdictInfos.forEach(e -> {
|
|
|
+ String key = e.getColKey();
|
|
|
+ String keys[] = key.split("__");
|
|
|
+ String[] trtd = keys[1].split("_");
|
|
|
+ Element data = trs.get(Integer.parseInt(trtd[0])).select("td").get(Integer.parseInt(trtd[1]));
|
|
|
+ int x1 = Integer.parseInt(data.children().get(0).attr("x1"));
|
|
|
+ if (x1 == 0) {
|
|
|
+ x1 = 1;
|
|
|
+ }
|
|
|
+ int y1 = Integer.parseInt(data.children().get(0).attr("y1"));
|
|
|
+
|
|
|
+ final CellRange cellRange = sheet.getCellRange(y1, x1);
|
|
|
+ cellRange.setText(e.getId() + "");
|
|
|
+ cellRange.getCellStyle().getFont().setColor(Color.white);
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ sheet.saveToPdf(pdfPath);
|
|
|
+
|
|
|
+ BladeFile bladeFile = newIOSSClient.uploadFile(pkeyId + ".pdf", pdfPath);
|
|
|
+ //
|
|
|
+ TableFile tableFile1 = tableFileService.getBaseMapper().selectOne(Wrappers.<TableFile>query().lambda()
|
|
|
+ .eq(TableFile::getTabId, pkeyId+"").eq(TableFile::getType, 1));
|
|
|
+ if (tableFile1 != null) {
|
|
|
+ tableFile1.setDomainPdfUrl(bladeFile.getLink());
|
|
|
+ tableFileService.saveOrUpdate(tableFile1);
|
|
|
+ } else {
|
|
|
+ TableFile tableFile = new TableFile();
|
|
|
+ String fileExtension = FileUtil.getFileExtension(wbsTreeContract.getFullName() + ".pdf");
|
|
|
+ tableFile.setTabId(pkeyId + "");
|
|
|
+ tableFile.setName(wbsTreeContract.getFullName() + ".pdf");
|
|
|
+ tableFile.setType(1);
|
|
|
+ tableFile.setDomainUrl(bladeFile.getLink());
|
|
|
+ tableFile.setIsDeleted(0);
|
|
|
+ tableFile.setExtension(fileExtension);
|
|
|
+ tableFile.setDomainPdfUrl(bladeFile.getLink());
|
|
|
+ tableFileService.saveOrUpdate(tableFile);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<TableFile> tableFileList = tableFileService.getBaseMapper().selectList(Wrappers.<TableFile>query().lambda().eq(TableFile::getTabId, pkeyId+"").eq(TableFile::getIsDeleted, 0));
|
|
|
+ tableFileList.sort(Comparator.comparing(TableFile::getType));
|
|
|
+
|
|
|
+
|
|
|
+ List<String> dataListPdf = tableFileList.stream().filter(tableFile -> tableFile.getDomainPdfUrl() != null && (tableFile.getType() == 1 || tableFile.getType() == 2)).map(TableFile::getDomainPdfUrl).collect(Collectors.toList());
|
|
|
+
|
|
|
+ String pdfPath2 = file_path + "/pdf//" + pkeyId + "_2.pdf";
|
|
|
+
|
|
|
+ File tabpdf2 = ResourceUtil.getFile(pdfPath2);
|
|
|
+ if (tabpdf2.exists()) {
|
|
|
+ tabpdf2.delete();
|
|
|
+ }
|
|
|
+ FileUtils.mergePdfPublicMethods(dataListPdf, pdfPath2);
|
|
|
+
|
|
|
+ BladeFile bladeFile2 = newIOSSClient.uploadFile(pkeyId + "2.pdf", pdfPath2);
|
|
|
+
|
|
|
+ UpdateWrapper<WbsTreeContract> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.in("p_key_id", pkeyId+"");
|
|
|
+ updateWrapper.set("pdf_url", bladeFile2.getLink());
|
|
|
+ wbsTreeContractService.update(updateWrapper);
|
|
|
+ wb.dispose();
|
|
|
+ return R.data(bladeFile2.getLink());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void getBussPdfs(String nodeId, String classify, String contractId, String projectId) throws Exception {
|
|
|
+ String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
+ // 获取有权限的节点信息
|
|
|
+ List<WbsTreeContract> wbsTreeContractList = wbsTreeContractService.searchNodeAllTable(nodeId, classify, contractId, projectId);
|
|
|
+ List<String> data = new ArrayList<>();
|
|
|
+ if (wbsTreeContractList != null && wbsTreeContractList.size() >= 1) {
|
|
|
+ for (WbsTreeContract wbsInfo : wbsTreeContractList) {
|
|
|
+ // 隐藏的不生成pdf
|
|
|
+ if (wbsInfo.getIsBussShow() != 2) { //
|
|
|
+ if (StringUtils.isNotEmpty(wbsInfo.getPdfUrl())) {
|
|
|
+ data.add(wbsInfo.getPdfUrl());
|
|
|
+ } else {
|
|
|
+ R bussPdfInfo = this.getBussPdfInfo(wbsInfo.getPKeyId());
|
|
|
+ if (bussPdfInfo.getCode() == 200) {
|
|
|
+ data.add(bussPdfInfo.getData() + "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String listPdf = file_path + "pdf/" + nodeId + ".pdf";
|
|
|
+ File tabpdf2 = ResourceUtil.getFile(listPdf);
|
|
|
+ if (tabpdf2.exists()) {
|
|
|
+ tabpdf2.delete();
|
|
|
+ }
|
|
|
+ FileUtils.mergePdfPublicMethods(data, listPdf);
|
|
|
+ BladeFile bladeFile = this.newIOSSClient.uploadFile(nodeId + ".pdf", listPdf);
|
|
|
+
|
|
|
+ // 合并pdf集合
|
|
|
+ String sql = "update u_information_query set pdf_url ='" + bladeFile.getLink() + "' where classify='" + classify + "' and wbs_id='" + nodeId + "' and contract_id ='" + contractId + "' ";
|
|
|
+ jdbcTemplate.execute(sql);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R getBussDataInfo(Long pkeyId) {
|
|
|
+
|
|
|
+ Map<String, Object> reData = new HashMap<>();
|
|
|
+
|
|
|
+ WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
+ .eq(WbsTreeContract::getPKeyId, pkeyId));
|
|
|
+ if (wbsTreeContract == null) {
|
|
|
+ return R.data(reData);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (wbsTreeContract == null) {
|
|
|
+ return R.data(reData);
|
|
|
+ }
|
|
|
+ if (wbsTreeContract.getHtmlUrl() == null) {
|
|
|
+ return R.data(reData);
|
|
|
+ }
|
|
|
+
|
|
|
+ //表单是否存储在
|
|
|
+ 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 == null || tablist.size() <= 0) {
|
|
|
+ return R.fail("无实体表对应");
|
|
|
+ }
|
|
|
+
|
|
|
+ String querySql = "select * from " + wbsTreeContract.getInitTableName() + " where p_key_id=" + pkeyId;
|
|
|
+ List<Map<String, Object>> dataIn = jdbcTemplate.queryForList(querySql);
|
|
|
+
|
|
|
+
|
|
|
+ // 匹配关联
|
|
|
+
|
|
|
+ try {
|
|
|
+ File file1 = ResourceUtil.getFile(wbsTreeContract.getHtmlUrl());
|
|
|
+ String htmlString = IoUtil.readToString(new FileInputStream(file1));
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
+ //解析
|
|
|
+ Elements dwtitle = doc.select("el-input[placeholder~=^承包单位]");
|
|
|
+ Elements htdtitle = doc.select("el-input[placeholder~=^合同段]");
|
|
|
+ Elements jltitle = doc.select("el-input[placeholder~=^监理单位]");
|
|
|
+ Elements bhtitle = doc.select("el-input[placeholder~=^编号]");
|
|
|
+ ContractInfo contractInfo = contractInfoService.getById(wbsTreeContract.getContractId());
|
|
|
+ //
|
|
|
+ reData.put(dwtitle.attr("keyName"),contractInfo.getConstructionUnitName());
|
|
|
+ reData.put(htdtitle.attr("keyName"),contractInfo.getContractName());
|
|
|
+ reData.put(jltitle.attr("keyName"),contractInfo.getSupervisionUnitName());
|
|
|
+ reData.put(bhtitle.attr("keyName"),contractInfo.getContractNumber());
|
|
|
+
|
|
|
+
|
|
|
+ } catch (FileNotFoundException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (dataIn != null && 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.indexOf("T") >= 0 && tabVal.indexOf(".000Z]") >= 0) {
|
|
|
+ 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("'", "");
|
|
|
+ reData.put(key + "__" + tabData[1], sql);
|
|
|
+ } else if (tabVal.indexOf("T") >= 0 && tabVal.indexOf(".000Z") >= 0) { //时间
|
|
|
+
|
|
|
+ String tabData[] = tabVal.split("_\\^_");
|
|
|
+ reData.put(key + "__" + tabData[1], tabData[0]);
|
|
|
+
|
|
|
+ } else if (tabVal.indexOf("☆") >= 0) {
|
|
|
+ String mysql[] = tabVal.split("☆");
|
|
|
+ for (String data : mysql) {
|
|
|
+ String tabData[] = data.split("_\\^_");
|
|
|
+ reData.put(key + "__" + tabData[1], tabData[0]);
|
|
|
+ }
|
|
|
+ } else if (tabVal.indexOf("_^_") >= 0) {
|
|
|
+ String tabData[] = tabVal.split("_\\^_");
|
|
|
+ reData.put(key + "__" + tabData[1], tabData[0]);
|
|
|
+ } else {
|
|
|
+ reData.put(key, tabVal);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 获取默认值
|
|
|
+ QueryWrapper<TextdictInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("type", 4);
|
|
|
+ queryWrapper.eq("tab_id", wbsTreeContract.getIsTypePrivatePid());
|
|
|
+ final List<TextdictInfo> textdictInfos = textdictInfoService.getBaseMapper().selectList(queryWrapper);
|
|
|
+ if (!textdictInfos.isEmpty()) {
|
|
|
+ for (TextdictInfo textdictInfo : textdictInfos) {
|
|
|
+ if (reData.containsKey(textdictInfo.getColKey())) {
|
|
|
+ String keyVal = reData.get(textdictInfo.getColKey()) + "";
|
|
|
+ } else {
|
|
|
+ reData.put(textdictInfo.getColKey() + "", textdictInfo.getSigRoleName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加4个长量值
|
|
|
+
|
|
|
+
|
|
|
+ // 移除Id 和 p_key_id
|
|
|
+ reData.remove("id");
|
|
|
+ reData.remove("p_key_id");
|
|
|
+ reData.remove("classify");
|
|
|
+ reData.remove("contractId");
|
|
|
+ reData.remove("pkeyId");
|
|
|
+ reData.remove("projectId");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return R.data(reData);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|