|
@@ -7,6 +7,11 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
+import com.itextpdf.html2pdf.ConverterProperties;
|
|
|
+import com.itextpdf.html2pdf.resolver.font.DefaultFontProvider;
|
|
|
+import com.itextpdf.io.font.FontProgram;
|
|
|
+import com.itextpdf.io.font.FontProgramFactory;
|
|
|
+import com.itextpdf.layout.font.FontProvider;
|
|
|
import com.spire.xls.ExcelPicture;
|
|
|
import com.spire.xls.ExcelVersion;
|
|
|
import com.spire.xls.Workbook;
|
|
@@ -33,6 +38,7 @@ import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.constant.BladeConstant;
|
|
|
import org.springblade.core.tool.utils.*;
|
|
|
+import org.springblade.manager.bean.TableInfo;
|
|
|
import org.springblade.manager.entity.*;
|
|
|
import org.springblade.manager.mapper.WbsTreePrivateMapper;
|
|
|
import org.springblade.manager.service.*;
|
|
@@ -62,7 +68,6 @@ import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-import static org.springblade.common.constant.CommonConstant.DEFAULT_PARAM_PASSWORD;
|
|
|
|
|
|
/**
|
|
|
* 清表基础数据表 控制器
|
|
@@ -489,16 +494,13 @@ public class ExcelTabController extends BladeController {
|
|
|
|
|
|
File writefile = new File(thmlUrl);
|
|
|
FileUtil.writeToFile(writefile, doc.html(), Boolean.parseBoolean("UTF-8"));
|
|
|
- wbsTreePrivateService.update(updateWrapper);
|
|
|
+
|
|
|
|
|
|
//日志表单关联解决
|
|
|
if(aPrivate.getWbsType().equals("4")){
|
|
|
- WbsTreePrivate wbsTreeCon = wbsTreePrivateService.getBaseMapper().selectOne(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
- .eq(WbsTreePrivate::getId, aPrivate.getParentId()).eq(WbsTreePrivate::getWbsType,"4").eq(WbsTreePrivate::getProjectId,aPrivate.getProjectId()));
|
|
|
- wbsTreeCon.setExcelId(aPrivate.getPKeyId());
|
|
|
- wbsTreePrivateService.saveOrUpdate(wbsTreeCon);
|
|
|
+ updateWrapper.set("excel_id",aPrivate.getPKeyId());
|
|
|
}
|
|
|
-
|
|
|
+ wbsTreePrivateService.update(updateWrapper);
|
|
|
//关联项目下所有的合同段
|
|
|
aPrivate.setHtmlUrl(thmlUrl);
|
|
|
wbsTreeContractService.updateAllNodeTabById(aPrivate);
|
|
@@ -612,7 +614,7 @@ public class ExcelTabController extends BladeController {
|
|
|
/**
|
|
|
*保存用户填报数据接口
|
|
|
*/
|
|
|
- @PostMapping("/save_buss_data")
|
|
|
+ @PostMapping("/save_buss_data_bak")
|
|
|
@ApiOperationSupport(order = 13)
|
|
|
@ApiOperation(value = "填报页面数据保存", notes = "填报页面数据保存")
|
|
|
public R<String> saveBussData(@Valid @RequestBody JSONObject dataInfo, BladeUser bladeUser) throws IOException {
|
|
@@ -711,12 +713,14 @@ public class ExcelTabController extends BladeController {
|
|
|
String tabName = wbsTreeContract.getInitTableName();
|
|
|
|
|
|
// 判读修改还是 添加
|
|
|
- String querySql = "select * from "+tabName+" where p_key_id="+pkeyId ;
|
|
|
- List<Map<String, Object>> dataIn = jdbcTemplate.queryForList(querySql);
|
|
|
+ // String querySql = "select * from "+tabName+" where p_key_id="+pkeyId ;
|
|
|
+ // List<Map<String, Object>> dataIn = jdbcTemplate.queryForList(querySql);
|
|
|
+
|
|
|
+ String delSql = "delete from "+tabName+" where p_key_id="+pkeyId ;;
|
|
|
|
|
|
String sqlInfo="";
|
|
|
|
|
|
- if(dataIn.isEmpty()){ //插入
|
|
|
+ // if(dataIn.isEmpty()){ //插入
|
|
|
sqlInfo = "INSERT INTO "+tabName+" ( ";
|
|
|
String keyStr = "id,";
|
|
|
String valStr = SnowFlakeUtil.getId() + ",";
|
|
@@ -734,14 +738,14 @@ public class ExcelTabController extends BladeController {
|
|
|
|
|
|
//huangjn 保存成功后调用生成资料查询列表数据
|
|
|
this.informationQueryClient.saveOrUpdateInformationQueryData(wbsTreeContractByP.getPKeyId()+"", "文件名称(后面再完善)", Integer.parseInt(classify), 2);
|
|
|
- }else{ //更新
|
|
|
+/* }else{ //更新
|
|
|
sqlInfo = "update "+tabName+" set ";
|
|
|
for (String keys : dataMap2.keySet()){
|
|
|
sqlInfo += keys+"='"+dataMap2.get(keys)+"',";
|
|
|
}
|
|
|
sqlInfo=sqlInfo.substring(0,sqlInfo.lastIndexOf(","));
|
|
|
sqlInfo = sqlInfo + " where p_key_id="+pkeyId;
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
UpdateWrapper<WbsTreeContract> updateWrapper = new UpdateWrapper<>();
|
|
|
updateWrapper.in("p_key_id",pkeyId);
|
|
@@ -1200,7 +1204,7 @@ public class ExcelTabController extends BladeController {
|
|
|
if (tabVal.indexOf("T") >= 0 && tabVal.indexOf(".000Z]") >= 0) {
|
|
|
String tabData[] = tabVal.split("__");
|
|
|
if (reData.containsKey("pickerKey")) {
|
|
|
- String pickerKey = reData.get("pickerKey") + "," + tabData[1];
|
|
|
+ String pickerKey = reData.get("pickerKey") + "," +key+"__"+ tabData[1];
|
|
|
reData.put("pickerKey", pickerKey);
|
|
|
} else {
|
|
|
reData.put("pickerKey", key + "__" + tabData[1]);
|
|
@@ -1393,6 +1397,7 @@ public class ExcelTabController extends BladeController {
|
|
|
public R copeBussTab(Long pkeyId) throws FileNotFoundException {
|
|
|
WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
.eq(WbsTreeContract::getPKeyId, pkeyId));
|
|
|
+
|
|
|
List<WbsTreeContract> wbsTreeContractList = wbsTreeContractService.getBaseMapper().selectList(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
.eq(WbsTreeContract::getId,wbsTreeContract.getId())
|
|
|
.eq(WbsTreeContract::getContractId,wbsTreeContract.getContractId())
|
|
@@ -1557,18 +1562,25 @@ public class ExcelTabController extends BladeController {
|
|
|
@ApiImplicitParam(name = "projectId", value = "项目ID", required = true),
|
|
|
@ApiImplicitParam(name = "contractId", value = "合同段Id", required = true)
|
|
|
})
|
|
|
- public R getBussPdfs(String nodeId,String classify,String contractId,String projectId) throws FileNotFoundException {
|
|
|
+ public R 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 = wbsTreeContractList.stream().filter(wbsTreeContract -> wbsTreeContract.getPdfUrl()!=null && !wbsTreeContract.getIsBussShow().equals("2")).map(WbsTreeContract::getPdfUrl).collect(Collectors.toList());
|
|
|
+ List<String> data = wbsTreeContractList.stream().filter(wbsTreeContract -> wbsTreeContract.getPdfUrl()!=null && wbsTreeContract.getIsBussShow()!=2).map(WbsTreeContract::getPdfUrl).collect(Collectors.toList());
|
|
|
|
|
|
String listPdf = file_path+"pdf/"+nodeId+".pdf";
|
|
|
File tabpdf2 = ResourceUtil.getFile(listPdf);
|
|
|
if(tabpdf2.exists()){
|
|
|
tabpdf2.delete();
|
|
|
}
|
|
|
+ // 添加从来没有预览过的pdf
|
|
|
+ for (WbsTreeContract wbsTreeContract:wbsTreeContractList){
|
|
|
+ if((wbsTreeContract.getPdfUrl()==null ||wbsTreeContract.getPdfUrl().equals("")) && wbsTreeContract.getIsBussShow()!=2){
|
|
|
+ R bussPdfInfo = this.getBussPdfInfo(wbsTreeContract.getPKeyId());
|
|
|
|
|
|
+ data.add(bussPdfInfo.getData()+"");
|
|
|
+ }
|
|
|
+ }
|
|
|
FileUtils.mergePdfPublicMethods(data,listPdf);
|
|
|
|
|
|
BladeFile bladeFile = this.newIOSSClient.uploadFile(nodeId+".pdf", listPdf);
|
|
@@ -1594,11 +1606,33 @@ public class ExcelTabController extends BladeController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- @PostMapping("/save_buss_data_bak")
|
|
|
+ /**
|
|
|
+ * 设置BaseFont
|
|
|
+ * @param fontPath 字体路径
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private static ConverterProperties creatBaseFont(String fontPath) {
|
|
|
+ ConverterProperties properties = new ConverterProperties();
|
|
|
+ FontProvider fontProvider = new DefaultFontProvider();
|
|
|
+ FontProgram fontProgram;
|
|
|
+ try {
|
|
|
+ fontProgram = FontProgramFactory.createFont(fontPath);
|
|
|
+ fontProvider.addFont(fontProgram);
|
|
|
+ properties.setFontProvider(fontProvider);
|
|
|
+ } catch (IOException e) {
|
|
|
+ // log.error("creat base font erro" , e );
|
|
|
+ System.out.println("creat base font erro");
|
|
|
+ }
|
|
|
+ return properties;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/save_buss_data")
|
|
|
@ApiOperationSupport(order = 13)
|
|
|
@ApiOperation(value = "填报页面数据保存", notes = "填报页面数据保存")
|
|
|
public R<String> _saveBussData(@Valid @RequestBody JSONObject dataInfo, BladeUser bladeUser) throws IOException {
|
|
|
-
|
|
|
JSONArray dataArray = new JSONArray();
|
|
|
if(dataInfo.containsKey("dataInfo")){ // 节点保存
|
|
|
JSONObject jsonObject = dataInfo.getJSONObject("dataInfo");
|
|
@@ -1606,132 +1640,9 @@ public class ExcelTabController extends BladeController {
|
|
|
}else{ // 单个保存
|
|
|
dataArray.add(dataInfo);
|
|
|
}
|
|
|
-
|
|
|
- for(int m=0;m<dataArray.size();m++){
|
|
|
- JSONObject dataInfo2= dataArray.getJSONObject(m);
|
|
|
- //
|
|
|
- String contractId = dataInfo2.getString("contractId");
|
|
|
- String pkeyId = dataInfo2.getString("pkeyId");
|
|
|
- String projectId = dataInfo2.getString("projectId");
|
|
|
- //huangjn 填报的类型,施工或监理
|
|
|
- String classify = dataInfo2.getString("classify");
|
|
|
-
|
|
|
- //huangjn 填报的类型,施工或监理
|
|
|
- // 去掉
|
|
|
- dataInfo2.remove("contractId");
|
|
|
- dataInfo2.remove("pkeyId");
|
|
|
- dataInfo2.remove("p_key_id");
|
|
|
- dataInfo2.remove("projectId");
|
|
|
- dataInfo2.remove("classify");
|
|
|
- dataInfo2.remove("pickerKey");
|
|
|
- dataInfo2.remove("id");
|
|
|
- dataInfo2.remove("");
|
|
|
- // 计算数据
|
|
|
- Map<String,String> dataMap = new HashMap<>();
|
|
|
- for(String k:dataInfo2.keySet()){
|
|
|
- if(k.indexOf("__")>=0){
|
|
|
- String key = k.split("__")[0];
|
|
|
- if(dataMap.containsKey(key)){
|
|
|
- dataMap.put(key,dataMap.get(key)+","+k);
|
|
|
- }else{
|
|
|
- dataMap.put(key,k);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- Map<String,String> dataMap2 = new HashMap<>();
|
|
|
-
|
|
|
-
|
|
|
- // 字段组合
|
|
|
- for(String k:dataMap.keySet()){
|
|
|
- if(dataMap.get(k).indexOf(",")>=0 && dataMap.get(k).indexOf("000Z")<0){
|
|
|
- String [] ziduan= dataMap.get(k).split(",");
|
|
|
- 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));
|
|
|
- if(!dataVal.equals("") || !dataVal.equals("[]") ) {
|
|
|
- System.out.println(k+"__"+dataMap.get(k));
|
|
|
- dataMap2.put(k, dataVal+"__"+dataMap.get(k).split("__")[1]);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- dataMap2.put("p_key_id",pkeyId);
|
|
|
-
|
|
|
- WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
- .eq(WbsTreeContract::getPKeyId, pkeyId));
|
|
|
- if(wbsTreeContract == null){
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- String tabName = wbsTreeContract.getInitTableName();
|
|
|
-
|
|
|
- // 判读修改还是 添加
|
|
|
- String querySql = "select * from "+tabName+" where p_key_id="+pkeyId ;
|
|
|
- List<Map<String, Object>> dataIn = jdbcTemplate.queryForList(querySql);
|
|
|
-
|
|
|
- String sqlInfo="";
|
|
|
-
|
|
|
- if(dataIn.isEmpty()){ //插入
|
|
|
- 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,contractId));
|
|
|
-
|
|
|
- //huangjn 保存成功后调用生成资料查询列表数据
|
|
|
- this.informationQueryClient.saveOrUpdateInformationQueryData(wbsTreeContractByP.getPKeyId()+"", "文件名称(后面再完善)", Integer.parseInt(classify), 2);
|
|
|
- }else{ //更新
|
|
|
- sqlInfo = "update "+tabName+" set ";
|
|
|
- for (String keys : dataMap2.keySet()){
|
|
|
- sqlInfo += keys+"='"+dataMap2.get(keys)+"',";
|
|
|
- }
|
|
|
- sqlInfo=sqlInfo.substring(0,sqlInfo.lastIndexOf(","));
|
|
|
- sqlInfo = sqlInfo + " where p_key_id="+pkeyId;
|
|
|
- }
|
|
|
-
|
|
|
- UpdateWrapper<WbsTreeContract> updateWrapper = new UpdateWrapper<>();
|
|
|
- updateWrapper.in("p_key_id",pkeyId);
|
|
|
- updateWrapper.set("is_tab_pdf",2);
|
|
|
- wbsTreeContractService.update(updateWrapper);
|
|
|
-
|
|
|
- jdbcTemplate.execute(sqlInfo);
|
|
|
- // this.getBussPdfInfo(Long.parseLong(pkeyId));
|
|
|
- }
|
|
|
+ List<TableInfo> tableInfoList =this.excelTabService.getTableInfoList(dataArray);
|
|
|
+ this.excelTabService.formulaFillData(tableInfoList);
|
|
|
+ this.excelTabService.saveOrUpdateInfo(tableInfoList);
|
|
|
return R.success("1");
|
|
|
}
|
|
|
|