|
@@ -13,12 +13,17 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.apache.poi.ss.usermodel.Cell;
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.jsoup.Jsoup;
|
|
|
import org.jsoup.nodes.Document;
|
|
|
import org.jsoup.nodes.Element;
|
|
|
import org.jsoup.select.Elements;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
+import org.springblade.business.dto.ImportTreeDto;
|
|
|
import org.springblade.business.entity.ConstructionLedger;
|
|
|
import org.springblade.business.feign.ConstructionLedgerFeignClient;
|
|
|
import org.springblade.business.feign.InformationQueryClient;
|
|
@@ -66,6 +71,7 @@ import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
+import java.lang.reflect.Field;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.BigInteger;
|
|
|
import java.util.*;
|
|
@@ -2168,6 +2174,79 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+ @Override
|
|
|
+ public void importTree(MultipartFile file, Long pkeyId) throws IOException {
|
|
|
+ InputStream inputStream = file.getInputStream();
|
|
|
+ org.apache.poi.ss.usermodel.Workbook workbook = new XSSFWorkbook(inputStream);
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+ List<ImportTreeDto>list=new ArrayList<>();
|
|
|
+ for (int i = 2; i <= sheet.getLastRowNum(); i++){
|
|
|
+ Row row = sheet.getRow(i);
|
|
|
+ if (row == null) continue;
|
|
|
+ // 获取每一列的值
|
|
|
+ String unitName = getCellValue(row.getCell(0)); // A列:单位工程名称
|
|
|
+ String unitCode = getCellValue(row.getCell(1)); // B列:单位工程编号
|
|
|
+ String subUnitName = getCellValue(row.getCell(2)); // C列:子单位工程名称
|
|
|
+ String subUnitCode = getCellValue(row.getCell(3)); // D列:子单位工程编号
|
|
|
+ String divisionName = getCellValue(row.getCell(4)); // E列:分部工程名称
|
|
|
+ String divisionCode = getCellValue(row.getCell(5)); // F列:分部工程编号
|
|
|
+ String subDivisionName = getCellValue(row.getCell(6)); // G列:子分部工程名称
|
|
|
+ String subDivisionCode = getCellValue(row.getCell(7)); // H列:子分部工程编号
|
|
|
+ String itemName = getCellValue(row.getCell(8)); // I列:分项工程名称
|
|
|
+ String itemCode = getCellValue(row.getCell(9)); // J列:分项工程编号
|
|
|
+ String subItemName = getCellValue(row.getCell(10)); // K列:子分项工程名称
|
|
|
+ String subItemCode = getCellValue(row.getCell(11));// L列:子分项工程编号
|
|
|
+ ImportTreeDto dto=new ImportTreeDto(unitName,unitCode,1,false,subUnitName,subUnitCode,18,false,divisionName,divisionCode,2,false, subDivisionName,subDivisionCode,3,false,itemName,itemCode,4,false,subItemName,subItemCode,5,false);
|
|
|
+ list.add(dto);
|
|
|
+ }
|
|
|
+ if(list.isEmpty()){
|
|
|
+ throw new ServiceException("导入模版为空,请先填写数据");
|
|
|
+ }
|
|
|
+ //最高节点
|
|
|
+ WbsTreeContract wbsTreeContractRoot = baseMapper.selectOne(Wrappers.<WbsTreeContract>query().lambda().eq(WbsTreeContract::getPKeyId, pkeyId));
|
|
|
+ //获取当前节点下所有子节点
|
|
|
+ List<WbsTreeContractVO> wbsTreeContractVOS = contractInfoMapper.tree4(wbsTreeContractRoot.getContractId(), String.valueOf(wbsTreeContractRoot.getId()));
|
|
|
+ if (wbsTreeContractVOS.size() <= 0) {
|
|
|
+ throw new ServiceException("未查询到当前合同段的wbs树,请先分配该合同的合同段wsb树");
|
|
|
+ }
|
|
|
+ //本次新增的节点
|
|
|
+ List<String>insertList=new ArrayList<>();
|
|
|
+ //本次修改的节点
|
|
|
+ List<String> updateList=new ArrayList<>();
|
|
|
+
|
|
|
+ //新增和修改
|
|
|
+ for (ImportTreeDto dto : list) {
|
|
|
+ for (WbsTreeContractVO vo : wbsTreeContractVOS) {
|
|
|
+ //wbs节点的名称和单位工程的名称类型能对应上,并且编号不一,就修改编号
|
|
|
+ if(vo.getNodeName().equals(dto.getUnitName())&&vo.getNodeType()==1){
|
|
|
+ baseMapper.update(null,Wrappers.<WbsTreeContract>lambdaUpdate().set(WbsTreeContract::getPartitionCode,dto.getUnitCode()).eq(WbsTreeContract::getPKeyId,vo.getPrimaryKeyId()));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取单元格的值
|
|
|
+ *
|
|
|
+ * @param cell 单元格
|
|
|
+ * @return 单元格的值(字符串)
|
|
|
+ */
|
|
|
+ private static String getCellValue(Cell cell) {
|
|
|
+ if (cell == null) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ switch (cell.getCellType()) {
|
|
|
+ case 1:
|
|
|
+ return cell.getStringCellValue();
|
|
|
+ case 0:
|
|
|
+ return String.valueOf((int) cell.getNumericCellValue());
|
|
|
+ default:
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
private WbsTreeContractVO4 importSubmitWbsContractNodes(ArrayList<Map<String, String>> result, String
|
|
|
primaryKeyId, Integer isSplicingNumber) {
|
|
@@ -2725,6 +2804,9 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public List<WbsTreeContract> findAllContract(WbsTreeContract wbsTreeContract){
|
|
|
QueryWrapper<WbsTreeContract> wbsTreeContractQueryWrapper = new QueryWrapper<>();
|
|
|
wbsTreeContractQueryWrapper.select("p_key_id","id","p_id","wbs_id","contract_id","parent_id","ancestors");
|