|
@@ -1,34 +1,50 @@
|
|
|
package org.springblade.business.controller;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import com.aspose.cells.Workbook;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.BeanUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import lombok.SneakyThrows;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springblade.business.dto.EKeyDto;
|
|
|
+import org.springblade.business.dto.NeiYeLedgerDto1;
|
|
|
import org.springblade.business.entity.ConstructionLedger;
|
|
|
import org.springblade.business.entity.Task;
|
|
|
import org.springblade.business.feign.TaskClient;
|
|
|
import org.springblade.business.service.IConstructionLedgerService;
|
|
|
import org.springblade.business.service.IInformationQueryService;
|
|
|
import org.springblade.business.vo.NeiYeLedgerVO;
|
|
|
+import org.springblade.business.vo.NeiYeLedgerVO1;
|
|
|
import org.springblade.business.vo.NeiYeQueryVO;
|
|
|
import org.springblade.business.vo.QueryProcessDataVO;
|
|
|
import org.springblade.common.utils.CommonUtil;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.utils.BeanUtil;
|
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
import org.springblade.manager.entity.ContractInfo;
|
|
|
+import org.springblade.manager.entity.WbsFormElement;
|
|
|
import org.springblade.manager.entity.WbsTreeContract;
|
|
|
+import org.springblade.manager.entity.WbsTreePrivate;
|
|
|
import org.springblade.manager.feign.ContractClient;
|
|
|
import org.springblade.manager.feign.WbsTreeContractClient;
|
|
|
+import org.springblade.manager.feign.WbsTreePrivateClient;
|
|
|
import org.springblade.manager.vo.WbsTreeContractTreeVOS;
|
|
|
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+import org.springframework.jdbc.core.SingleColumnRowMapper;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -40,6 +56,8 @@ public class NeiYeController {
|
|
|
|
|
|
private final WbsTreeContractClient wbsTreeContractClient;
|
|
|
|
|
|
+ private final WbsTreePrivateClient wbsTreePrivatClient;
|
|
|
+
|
|
|
private final IConstructionLedgerService constructionLedgerService;
|
|
|
|
|
|
private final IInformationQueryService informationQueryService;
|
|
@@ -93,7 +111,7 @@ public class NeiYeController {
|
|
|
if (node.getParentId() == 0) {
|
|
|
queryDataResult = this.informationQueryService.queryProcessDataByParentIdAndContractIdTwo("", contractType, contractId);
|
|
|
} else {
|
|
|
- queryDataResult = this.informationQueryService.queryProcessDataByParentIdAndContractIdTwo(node.getId().toString(), contractType, contractId);
|
|
|
+ queryDataResult = this.informationQueryService.queryProcessDataByParentIdAndContractIdTwo(node.getPKeyId().toString(), contractType, contractId);
|
|
|
}
|
|
|
} else {
|
|
|
//填报节点
|
|
@@ -276,6 +294,184 @@ public class NeiYeController {
|
|
|
return R.data(300, null, "未查询到数据");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @PostMapping("/queryCurrentNodeNeiYeLedger1")
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
+ @ApiOperation(value = "获取内业台账列表(水利)")
|
|
|
+ public R<List<NeiYeLedgerVO1>>queryCurrentNodeNeiYeLedger1(@RequestBody NeiYeLedgerDto1 dto){
|
|
|
+ Integer type=dto.getType();
|
|
|
+ //初始数据 type=1最后返回vo1,type=2就复制在修改组装成一个集合
|
|
|
+ NeiYeLedgerVO1 vo1 = new NeiYeLedgerVO1();
|
|
|
+ List<NeiYeLedgerVO1>voList = new ArrayList<>();
|
|
|
+ //查出当前节点的信息contract
|
|
|
+ WbsTreeContract wbsTreeContract = wbsTreeContractClient.getById(dto.getPkeyId());
|
|
|
+ if(wbsTreeContract!=null){
|
|
|
+ String ancestors = wbsTreeContract.getAncestors();
|
|
|
+ //将父级节点全部查出来
|
|
|
+ List<WbsTreeContract> ancetorsList=wbsTreeContractClient.getAncestors(ancestors);
|
|
|
+ if(ancetorsList.size()>0){
|
|
|
+ for (WbsTreeContract contract : ancetorsList) {
|
|
|
+ if(new Integer("1").equals(contract.getNodeType())&&contract.getParentId()!=0L){
|
|
|
+ //类型属于1则为单位工程
|
|
|
+ vo1.setClassName(contract.getNodeName());
|
|
|
+ }else if(new Integer("2").equals(contract.getNodeType())){
|
|
|
+ //类型属于2则为分部工程
|
|
|
+ vo1.setPartName(contract.getNodeName());
|
|
|
+ }else if(new Integer("3").equals(contract.getNodeType())){
|
|
|
+ //类型属于3则为子分部工程
|
|
|
+ vo1.setSubPartName(contract.getNodeName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(wbsTreeContract.getNodeType()==1){
|
|
|
+ vo1.setClassName(wbsTreeContract.getNodeName());
|
|
|
+ } else if (wbsTreeContract.getNodeType()==2) {
|
|
|
+ vo1.setPartName(wbsTreeContract.getNodeName());
|
|
|
+ }else if(wbsTreeContract.getNodeType()==3){
|
|
|
+ vo1.setPartName(wbsTreeContract.getNodeName());
|
|
|
+ }
|
|
|
+ //如果选择的节点正好是工序则直接将单元查出来
|
|
|
+ if(wbsTreeContract.getNodeType()==6){
|
|
|
+ Integer unitNameNum=0;
|
|
|
+ if(wbsTreeContract!=null&&wbsTreeContract.getUnitName()!=null){
|
|
|
+ unitNameNum=wbsTreeContract.getUnitName();
|
|
|
+ }
|
|
|
+ if(unitNameNum!=null&&unitNameNum!=0){
|
|
|
+ String sql="select unit_name from m_classifcation where id="+unitNameNum;
|
|
|
+ String unitName = jdbcTemplate.queryForObject(sql, new SingleColumnRowMapper<>(String.class));
|
|
|
+ vo1.setUnitName(unitName);
|
|
|
+ vo1.setUnitCount(1);
|
|
|
+ }else {
|
|
|
+ return R.data(300,null,"该节点暂未设置单元工程名称");
|
|
|
+ }
|
|
|
+ //查询合格,优良,优良率
|
|
|
+ //查出当前节点下的单元工程施工质量验收评定表 后面需要改一下pid
|
|
|
+ List<WbsTreeContract> tables = wbsTreeContractClient.getTables(wbsTreeContract.getContractId(),wbsTreeContract.getPKeyId(),wbsTreeContract.getWbsId());
|
|
|
+ if(tables.size()>0){
|
|
|
+ //评定节点
|
|
|
+ WbsTreeContract nodeClass = tables.get(0);
|
|
|
+ String elementSql = "SELECT * from m_wbs_form_element where f_id="+"(SELECT id from m_table_info Where tab_en_name=" + "'" + nodeClass.getInitTableName() + "')"+" and dynamic_dict=600";
|
|
|
+ List<WbsFormElement> elements = jdbcTemplate.query(elementSql, new BeanPropertyRowMapper<>(WbsFormElement.class));
|
|
|
+ String querySql = "select "+elements.get(0).getEKey()+" from " + nodeClass.getInitTableName() + " where p_key_id=" + nodeClass.getPKeyId();
|
|
|
+ List<String> infos = jdbcTemplate.query(querySql, new SingleColumnRowMapper<>(String.class));
|
|
|
+ String info="";
|
|
|
+ if(!infos.isEmpty()){
|
|
|
+ info = infos.get(0);
|
|
|
+ }
|
|
|
+ if(info!=null){
|
|
|
+ if(info.indexOf("优良")>=0){
|
|
|
+ vo1.setGoodCount(1);
|
|
|
+ vo1.setPassCount(0);
|
|
|
+ vo1.setGoodRate("100%");
|
|
|
+ }else {
|
|
|
+ vo1.setGoodCount(0);
|
|
|
+ vo1.setPassCount(1);
|
|
|
+ vo1.setGoodRate("0%");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ voList.add(vo1);
|
|
|
+ return R.data(voList);
|
|
|
+ }
|
|
|
+ //如果点的不是工序,则需要先查出当前节点下的所有工序节点
|
|
|
+ List<WbsTreeContract> list = wbsTreeContractClient.getNodeTyp6(wbsTreeContract.getPKeyId());
|
|
|
+ if(list.size()>0){
|
|
|
+ Integer unitCount=0;
|
|
|
+ Integer passCount=0;
|
|
|
+ Integer goodCount=0;
|
|
|
+ for (WbsTreeContract contract : list) {
|
|
|
+ NeiYeLedgerVO1 vo2 = new NeiYeLedgerVO1();
|
|
|
+ BeanUtil.copyProperties(vo1,vo2);
|
|
|
+ Integer unitNameNum=0;
|
|
|
+ if(contract.getUnitName()!=null){
|
|
|
+ unitNameNum=contract.getUnitName();
|
|
|
+ }
|
|
|
+ if(unitNameNum!=null&&unitNameNum!=0){
|
|
|
+ String sql1="select unit_name from m_classifcation where id="+unitNameNum;
|
|
|
+ String unitName = jdbcTemplate.queryForObject(sql1, new SingleColumnRowMapper<>(String.class));
|
|
|
+ if (type==2){
|
|
|
+ vo2.setUnitName(unitName);
|
|
|
+ vo2.setUnitCount(1);
|
|
|
+ }else {
|
|
|
+ unitCount++;
|
|
|
+ }
|
|
|
+
|
|
|
+ }else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //查询合格,优良,优良率
|
|
|
+ //查出当前节点下的单元工程施工质量验收评定表
|
|
|
+ EKeyDto eKey = wbsTreeContractClient.getEKey(contract.getContractId(), contract.getPKeyId(), contract.getWbsId());
|
|
|
+ // List<WbsTreeContract> tables = wbsTreeContractClient.getTables(contract.getContractId(),contract.getPKeyId(),contract.getWbsId());
|
|
|
+ if(eKey!=null){
|
|
|
+ //评定节点
|
|
|
+// WbsTreeContract nodeClass = tables.get(0);
|
|
|
+// String elementSql = "SELECT e_key from m_wbs_form_element where f_id="+"(SELECT id from m_table_info Where tab_en_name=" + "'" + nodeClass.getInitTableName() + "')"+" and dynamic_dict=600";
|
|
|
+// List<String> elements = jdbcTemplate.query(elementSql, new SingleColumnRowMapper<>(String.class));
|
|
|
+ String querySql = "select "+eKey.getEKey()+" from " + eKey.getInitTableName() + " where p_key_id=" + eKey.getPKeyId();
|
|
|
+ List<String> infos = jdbcTemplate.query(querySql, new SingleColumnRowMapper<>(String.class));
|
|
|
+ String info="";
|
|
|
+ if(!infos.isEmpty()){
|
|
|
+ info = infos.get(0);
|
|
|
+ }
|
|
|
+ if(info!=null){
|
|
|
+ if(info.indexOf("优良")>=0){
|
|
|
+ if(type==2){
|
|
|
+ vo2.setGoodCount(1);
|
|
|
+ vo2.setPassCount(0);
|
|
|
+ vo2.setGoodRate("100%");
|
|
|
+ }else {
|
|
|
+ goodCount++;
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if(type==2){
|
|
|
+ vo2.setGoodCount(0);
|
|
|
+ vo2.setPassCount(1);
|
|
|
+ vo2.setGoodRate("0%");
|
|
|
+ }else {
|
|
|
+ passCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(type==2){
|
|
|
+ voList.add(vo2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(type==2){
|
|
|
+ return R.data(voList);
|
|
|
+ }
|
|
|
+ else if(type==1){
|
|
|
+ vo1.setUnitCount(unitCount);
|
|
|
+ vo1.setGoodCount(goodCount);
|
|
|
+ vo1.setPassCount(passCount);
|
|
|
+ vo1.setGoodRate(calculatePercentage(goodCount,unitCount));
|
|
|
+ voList.add(vo1);
|
|
|
+ return R.data(voList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.data(300,null,"未查询到数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ @SneakyThrows
|
|
|
+ @GetMapping("/downloadNeiYe")
|
|
|
+ @ApiOperationSupport(order = 13)
|
|
|
+ @ApiOperation(value = "客户端-下载元素表对应的excel模板")
|
|
|
+ public void downloadNeiYe(@RequestBody List<NeiYeLedgerVO1> list){
|
|
|
+
|
|
|
+ }
|
|
|
+ public static String calculatePercentage(Integer numerator, Integer denominator) {
|
|
|
+ if (denominator == null || denominator == 0) {
|
|
|
+ return "0%";
|
|
|
+ }
|
|
|
+ double percentage = (numerator.doubleValue() / denominator) * 100;
|
|
|
+ return String.format("%.0f%%", percentage); // 不带小数
|
|
|
+ // 或者 String.format("%.1f%%", percentage); // 带一位小数
|
|
|
+ // 或者 String.format("%.2f%%", percentage); // 带两位小数
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 递归获取父节点信息
|
|
|
*
|