Commit d3d456cb authored by tianhongyang's avatar tianhongyang

Merge branch 'V20231129-中建一局二公司' of http://192.168.60.201/root/dsk-operate-sys...

Merge branch 'V20231129-中建一局二公司' of http://192.168.60.201/root/dsk-operate-sys into V20231129-中建一局二公司
parents a9f0d3ed 7f637f80
...@@ -3,6 +3,7 @@ package com.dsk.common.excel; ...@@ -3,6 +3,7 @@ package com.dsk.common.excel;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import com.dsk.common.annotation.Excel; import com.dsk.common.annotation.Excel;
import com.dsk.common.core.domain.AjaxResult; import com.dsk.common.core.domain.AjaxResult;
import com.dsk.common.exception.ServiceException;
import com.dsk.common.exception.UtilException; import com.dsk.common.exception.UtilException;
import com.dsk.common.utils.DateUtils; import com.dsk.common.utils.DateUtils;
import com.dsk.common.utils.DictUtils; import com.dsk.common.utils.DictUtils;
...@@ -13,6 +14,7 @@ import com.dsk.common.utils.file.ImageUtils; ...@@ -13,6 +14,7 @@ import com.dsk.common.utils.file.ImageUtils;
import com.dsk.common.utils.poi.ExcelHandlerAdapter; import com.dsk.common.utils.poi.ExcelHandlerAdapter;
import com.dsk.common.utils.poi.ExcelUtil; import com.dsk.common.utils.poi.ExcelUtil;
import com.dsk.common.utils.reflect.ReflectUtils; import com.dsk.common.utils.reflect.ReflectUtils;
import org.apache.commons.collections4.list.CursorableLinkedList;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.RegExUtils; import org.apache.commons.lang3.RegExUtils;
import org.apache.commons.lang3.reflect.FieldUtils; import org.apache.commons.lang3.reflect.FieldUtils;
...@@ -40,6 +42,8 @@ import java.time.LocalDate; ...@@ -40,6 +42,8 @@ import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
/** /**
* Excel相关处理 * Excel相关处理
...@@ -207,6 +211,7 @@ public class ExcelUtils<T> { ...@@ -207,6 +211,7 @@ public class ExcelUtils<T> {
sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(), titleRow.getRowNum(), titleRow.getRowNum(), titleLastCol)); sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(), titleRow.getRowNum(), titleRow.getRowNum(), titleLastCol));
} }
} }
public void createExportMessage() { public void createExportMessage() {
if (dateStatus) { if (dateStatus) {
subMergedFirstRowNum++; subMergedFirstRowNum++;
...@@ -226,6 +231,7 @@ public class ExcelUtils<T> { ...@@ -226,6 +231,7 @@ public class ExcelUtils<T> {
rownum++; rownum++;
} }
} }
public void createExportDate() { public void createExportDate() {
if (dateStatus) { if (dateStatus) {
subMergedFirstRowNum++; subMergedFirstRowNum++;
...@@ -330,8 +336,8 @@ public class ExcelUtils<T> { ...@@ -330,8 +336,8 @@ public class ExcelUtils<T> {
exportExcel(response); exportExcel(response);
} }
public ByteArrayOutputStream exportExcel( List<T> list, String sheetName, String title, boolean dateStatus) { public ByteArrayOutputStream exportExcel(List<T> list, String sheetName, String title, boolean dateStatus) {
ByteArrayOutputStream ba= new ByteArrayOutputStream(); ByteArrayOutputStream ba = new ByteArrayOutputStream();
this.init(list, sheetName, title, Excel.Type.EXPORT, dateStatus); this.init(list, sheetName, title, Excel.Type.EXPORT, dateStatus);
try { try {
writeSheet(); writeSheet();
...@@ -356,11 +362,11 @@ public class ExcelUtils<T> { ...@@ -356,11 +362,11 @@ public class ExcelUtils<T> {
* @param dateStatus 是否添加导出时间 * @param dateStatus 是否添加导出时间
* @return * @return
*/ */
public String localInit( List<T> list, String sheetName, String title, boolean dateStatus) { public String localInit(List<T> list, String sheetName, String title, boolean dateStatus) {
String fileName = title + "-" + System.currentTimeMillis() + ".xlsx"; String fileName = title + "-" + System.currentTimeMillis() + ".xlsx";
this.init(list, sheetName, title, Excel.Type.EXPORT, dateStatus); this.init(list, sheetName, title, Excel.Type.EXPORT, dateStatus);
writeSheet(); writeSheet();
try (FileOutputStream fileOutputStream = new FileOutputStream(FILE_PATH.concat(fileName))){ try (FileOutputStream fileOutputStream = new FileOutputStream(FILE_PATH.concat(fileName))) {
wb.write(fileOutputStream); wb.write(fileOutputStream);
return fileName; return fileName;
} catch (Exception e) { } catch (Exception e) {
...@@ -1384,11 +1390,37 @@ public class ExcelUtils<T> { ...@@ -1384,11 +1390,37 @@ public class ExcelUtils<T> {
public List<T> importExcel(String sheetName, InputStream is, int titleNum) throws Exception { public List<T> importExcel(String sheetName, InputStream is, int titleNum) throws Exception {
this.type = Excel.Type.IMPORT; this.type = Excel.Type.IMPORT;
this.wb = WorkbookFactory.create(is); this.wb = WorkbookFactory.create(is);
List<T> list = new ArrayList<T>(); List<T> resList = new ArrayList<T>();
// 如果指定sheet名,则取指定sheet中的内容 否则默认指向第1个sheet // 如果指定sheet名,则取指定sheet中的内容 否则默认指向第1个sheet
Sheet sheet = StringUtils.isNotEmpty(sheetName) ? wb.getSheet(sheetName) : wb.getSheetAt(0); Sheet sheet = StringUtils.isNotEmpty(sheetName) ? wb.getSheet(sheetName) : wb.getSheetAt(0);
dealwithSheet(resList, sheet, titleNum);
return resList;
}
/**
* 对excel表单所有表格转换成list
*
* @param titleNum 标题占用行数
* @param is 输入流
* @return 转换后集合
*/
public List<T> importExcelAllSheet(InputStream is, int titleNum) throws Exception {
this.type = Excel.Type.IMPORT;
this.wb = WorkbookFactory.create(is);
List<T> resList = new ArrayList<>();
int sheetCount = wb.getNumberOfSheets();
System.out.println("工作表个数为:" + sheetCount);
IntStream.rangeClosed(0, sheetCount - 1).parallel().forEach(sheetNum -> {
Sheet sheet = wb.getSheetAt(sheetNum);
dealwithSheet(resList, sheet, titleNum);
});
return resList;
}
private void dealwithSheet(List<T> resList, Sheet sheet, int titleNum) {
try {
if (sheet == null) { if (sheet == null) {
throw new IOException("文件sheet不存在"); throw new IOException(sheet.getSheetName() + "为空表!");
} }
boolean isXSSFWorkbook = !(wb instanceof HSSFWorkbook); boolean isXSSFWorkbook = !(wb instanceof HSSFWorkbook);
Map<String, PictureData> pictures; Map<String, PictureData> pictures;
...@@ -1424,6 +1456,7 @@ public class ExcelUtils<T> { ...@@ -1424,6 +1456,7 @@ public class ExcelUtils<T> {
fieldsMap.put(column, objects); fieldsMap.put(column, objects);
} }
} }
for (int i = titleNum + 1; i <= rows; i++) { for (int i = titleNum + 1; i <= rows; i++) {
// 从第2行开始取数据,默认第一行是表头. // 从第2行开始取数据,默认第一行是表头.
Row row = sheet.getRow(i); Row row = sheet.getRow(i);
...@@ -1431,12 +1464,15 @@ public class ExcelUtils<T> { ...@@ -1431,12 +1464,15 @@ public class ExcelUtils<T> {
if (isRowEmpty(row)) { if (isRowEmpty(row)) {
continue; continue;
} }
T entity = null; T entity = null;
for (Map.Entry<Integer, Object[]> entry : fieldsMap.entrySet()) { for (Map.Entry<Integer, Object[]> entry : fieldsMap.entrySet()) {
Object val = this.getCellValue(row, entry.getKey()); Object val = this.getCellValue(row, entry.getKey());
// 如果不存在实例则新建. // 如果不存在实例则新建.
entity = (entity == null ? clazz.newInstance() : entity); entity = (entity == null ? clazz.newInstance() : entity);
// 从map中得到对应列的field. // 从map中得到对应列的field.
Field field = (Field) entry.getValue()[0]; Field field = (Field) entry.getValue()[0];
Excel attr = (Excel) entry.getValue()[1]; Excel attr = (Excel) entry.getValue()[1];
...@@ -1475,6 +1511,7 @@ public class ExcelUtils<T> { ...@@ -1475,6 +1511,7 @@ public class ExcelUtils<T> {
} }
if (!ObjectUtils.isEmpty(fieldType)) { if (!ObjectUtils.isEmpty(fieldType)) {
String propertyName = field.getName(); String propertyName = field.getName();
if (StringUtils.isNotEmpty(attr.targetAttr())) { if (StringUtils.isNotEmpty(attr.targetAttr())) {
propertyName = field.getName() + "." + attr.targetAttr(); propertyName = field.getName() + "." + attr.targetAttr();
} else if (StringUtils.isNotEmpty(attr.readConverterExp())) { } else if (StringUtils.isNotEmpty(attr.readConverterExp())) {
...@@ -1487,10 +1524,14 @@ public class ExcelUtils<T> { ...@@ -1487,10 +1524,14 @@ public class ExcelUtils<T> {
ReflectUtils.invokeSetter(entity, propertyName, val); ReflectUtils.invokeSetter(entity, propertyName, val);
} }
} }
list.add(entity); synchronized (resList){
resList.add(entity);
}
} }
} }
return list; } catch (Exception e) {
e.printStackTrace();
}
} }
} }
...@@ -20,22 +20,26 @@ public interface CbProjectConstants { ...@@ -20,22 +20,26 @@ public interface CbProjectConstants {
* 成本阶段:转固 * 成本阶段:转固
*/ */
Integer CB_STAGE_TO_SOLID = 2; Integer CB_STAGE_TO_SOLID = 2;
/**
* 项目文件状态:未上传
*/
Integer PROJECT_FILE_STATUS_NOT_UPLOAD = 0;
/** /**
* 项目文件状态:待解析 * 项目文件状态:待解析
*/ */
Integer PROJECT_FILE_STATUS_NOT_PARSE = 0; Integer PROJECT_FILE_STATUS_NOT_PARSE = 1;
/** /**
* 项目文件状态:解析中 * 项目文件状态:解析中
*/ */
Integer PROJECT_FILE_STATUS_PARSING = 1; Integer PROJECT_FILE_STATUS_PARSING = 2;
/** /**
* 项目文件状态:解析成功 * 项目文件状态:解析成功
*/ */
Integer PROJECT_FILE_STATUS_PARSE_SUCCESS = 2; Integer PROJECT_FILE_STATUS_PARSE_SUCCESS = 3;
/** /**
* 项目文件状态:解析失败 * 项目文件状态:解析失败
*/ */
Integer PROJECT_FILE_STATUS_PARSE_FAIL = 3; Integer PROJECT_FILE_STATUS_PARSE_FAIL = 4;
/** /**
* 删除状态:未删除 * 删除状态:未删除
*/ */
...@@ -44,5 +48,43 @@ public interface CbProjectConstants { ...@@ -44,5 +48,43 @@ public interface CbProjectConstants {
* 删除状态:已删除 * 删除状态:已删除
*/ */
Integer DELETE_FLAG_NOT_EXIST = 2; Integer DELETE_FLAG_NOT_EXIST = 2;
/**
* 是否获取项目详情:是
*/
Integer IS_GET_PROJECT_DETAIL = 0;
/**
* 是否获取项目详情:否
*/
Integer NOT_GET_PROJECT_DETAIL = 1;
//成本类型(0:直接费成本、1:工料汇总、2:措施项目、3:其他项目、4:现场经费、5:成本汇总、6:未确定)
/**
* 成本类型:直接费成本
*/
Integer CB_TYPE_DIRECT_EXPENSE = 0;
/**
* 成本类型:工料汇总
*/
Integer CB_TYPE_QUANTITY_SUMMARY = 1;
/**
* 成本类型:措施项目
*/
Integer CB_TYPE_MEASURE_PROJECT = 2;
/**
* 成本类型:其他项目
*/
Integer CB_TYPE_OTHER_PROJECT = 3;
/**
* 成本类型:现场经费
*/
Integer CB_TYPE_SCENE_EXPENSE = 4;
/**
* 成本类型:成本汇总
*/
Integer CB_TYPE_ACCOUNT_SUMMARY = 5;
/**
* 成本类型:未确定
*/
Integer CB_TYPE_NOT_CONFIRM = 6;
} }
...@@ -2,11 +2,23 @@ package com.dsk.cscec.controller; ...@@ -2,11 +2,23 @@ package com.dsk.cscec.controller;
import com.dsk.common.core.controller.BaseController; import com.dsk.common.core.controller.BaseController;
import com.dsk.common.core.domain.R;
import com.dsk.common.excel.ExcelUtils;
import com.dsk.common.exception.ServiceException;
import com.dsk.cscec.domain.CbQuantitySummary;
import com.dsk.cscec.domain.bo.CbProjectBaseBo;
import com.dsk.cscec.service.ICbQuantitySummaryService; import com.dsk.cscec.service.ICbQuantitySummaryService;
import org.springframework.web.bind.annotation.RequestMapping; import com.dsk.system.domain.vo.SysUserImportVo;
import org.springframework.web.bind.annotation.RestController; import lombok.RequiredArgsConstructor;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import sun.reflect.generics.tree.Tree;
import javax.annotation.Resource; import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.stream.Collectors;
/** /**
* 成本-工料汇总基本表(CbQuantitySummary)表控制层 * 成本-工料汇总基本表(CbQuantitySummary)表控制层
...@@ -15,14 +27,50 @@ import javax.annotation.Resource; ...@@ -15,14 +27,50 @@ import javax.annotation.Resource;
* @since 2024-02-05 11:06:56 * @since 2024-02-05 11:06:56
*/ */
@RestController @RestController
@RequiredArgsConstructor
@RequestMapping("/cb/quantity/summary") @RequestMapping("/cb/quantity/summary")
public class CbQuantitySummaryController extends BaseController { public class CbQuantitySummaryController extends BaseController {
private final ICbQuantitySummaryService baseService;
/** /**
* 服务对象 * 工料汇总科目树
* @return
*/ */
@Resource @GetMapping(value = "/subjectTree")
private ICbQuantitySummaryService baseService; public R<Map<String, Object>> subjectTree(@PathVariable CbProjectBaseBo bo){
return R.ok(baseService.subjectTree(bo));
}
/**
* 已记录月份集合
*/
@GetMapping(value = "/monthList")
public R<List<String>> monthList(@PathVariable CbProjectBaseBo bo){
return R.ok(baseService.monthList(bo));
}
/**
* 数据导入
*/
@PostMapping(value = "/importData")
public R<Void> importFile(@RequestPart("file") MultipartFile file) throws Exception {
//识别Excel内容
List<CbQuantitySummary> importList = new ExcelUtils<>(CbQuantitySummary.class).importExcelAllSheet(file.getInputStream(), 1);
if (importList.isEmpty()) {
throw new ServiceException("表格中不存在待导入数据!");
}
importList = importList.stream().parallel()
.filter(item -> !ObjectUtils.isEmpty(item.getCbName()))
.peek(item -> {
item.setProjectId(1L);
item.setCbStage(0);
}).collect(Collectors.toList());
if (importList.isEmpty()) {
throw new ServiceException("表格中不存在有效数据数据!");
}
return toAjax(baseService.saveBatch(importList));
}
} }
...@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName; ...@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable; import java.io.Serializable;
import com.dsk.common.annotation.Excel;
import lombok.Data; import lombok.Data;
/** /**
...@@ -30,6 +31,7 @@ public class CbQuantitySummary implements Serializable { ...@@ -30,6 +31,7 @@ public class CbQuantitySummary implements Serializable {
/** /**
* 序号 * 序号
*/ */
@Excel(name = "序号")
private String number; private String number;
/** /**
* 成本阶段(0:标前成本 1:标后成本 2:转固成本) * 成本阶段(0:标前成本 1:标后成本 2:转固成本)
...@@ -38,6 +40,7 @@ public class CbQuantitySummary implements Serializable { ...@@ -38,6 +40,7 @@ public class CbQuantitySummary implements Serializable {
/** /**
* 成本科目名称(合约规划) * 成本科目名称(合约规划)
*/ */
@Excel(name = "成本科目")
private String cbSubjectName; private String cbSubjectName;
/** /**
* 成本科目编号(合约规划编号) * 成本科目编号(合约规划编号)
...@@ -46,66 +49,82 @@ public class CbQuantitySummary implements Serializable { ...@@ -46,66 +49,82 @@ public class CbQuantitySummary implements Serializable {
/** /**
* 公司编码 * 公司编码
*/ */
@Excel(name = "编码")
private String companyNo; private String companyNo;
/** /**
* 集团编码 * 集团编码
*/ */
@Excel(name = "集团编码")
private String orgNo; private String orgNo;
/** /**
* 成本名称 * 成本名称
*/ */
@Excel(name = "名称")
private String cbName; private String cbName;
/** /**
* 工作内容 * 工作内容
*/ */
@Excel(name = "工作内容")
private String jobContent; private String jobContent;
/** /**
* 计算规则 * 计算规则
*/ */
@Excel(name = "计算规则")
private String calculationRule; private String calculationRule;
/** /**
* 计量单位 * 计量单位
*/ */
@Excel(name = "单位")
private String unit; private String unit;
/** /**
* 材料说明 * 材料说明
*/ */
@Excel(name = "甲供材料说明")
private String materialDescription; private String materialDescription;
/** /**
* 指导价格 * 指导价格
*/ */
@Excel(name = "指导价格")
private String guidePrice; private String guidePrice;
/** /**
* 投标选用单价(不含税) * 投标选用单价(不含税)
*/ */
@Excel(name = "投标选用单价(不含税)")
private Double bidUnitPrice; private Double bidUnitPrice;
/** /**
* 单价差额 * 单价差额
*/ */
@Excel(name = "单价差额")
private Double unitPriceDifference; private Double unitPriceDifference;
/** /**
* 数量 * 数量
*/ */
@Excel(name = "数量")
private Double quantity; private Double quantity;
/** /**
* 合价(不含税) * 合价(不含税)
*/ */
@Excel(name = "合价(不含税)")
private Double combinedPrice; private Double combinedPrice;
/** /**
* 合价(含税) * 合价(含税)
*/ */
@Excel(name = "合价(含税)")
private Double combinedPriceTax; private Double combinedPriceTax;
/** /**
* 品牌名称 * 品牌名称
*/ */
@Excel(name = "品牌名称")
private String brandName; private String brandName;
/** /**
* 投标选用来源 * 投标选用来源
*/ */
@Excel(name = "投标选用来源")
private String bidSource; private String bidSource;
/** /**
* 备注 * 备注
*/ */
@Excel(name = "备注")
private String remark; private String remark;
/** /**
* 创建时间 * 创建时间
......
package com.dsk.cscec.domain.bo;
import lombok.Data;
/**
* 项目成本基础参数
*
* @Author lcl
* @Data 2024/2/6 9:24
*/
@Data
public class CbProjectBaseBo {
/**
* 项目id
*/
private Long projectId;
/**
* 成本阶段(0:标前成本 1:标后成本 2:转固成本)
*/
private Integer cbStage;
}
package com.dsk.cscec.listener; //package com.dsk.cscec.listener;
//
import cn.dev33.satoken.secure.BCrypt; //import cn.dev33.satoken.secure.BCrypt;
import cn.hutool.core.bean.BeanUtil; //import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil; //import cn.hutool.core.util.ObjectUtil;
import com.alibaba.excel.context.AnalysisContext; //import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener; //import com.alibaba.excel.event.AnalysisEventListener;
import com.dsk.common.excel.ExcelListener; //import com.dsk.common.excel.ExcelListener;
import com.dsk.common.excel.ExcelResult; //import com.dsk.common.excel.ExcelResult;
import com.dsk.common.exception.ServiceException; //import com.dsk.common.exception.ServiceException;
import com.dsk.common.helper.LoginHelper; //import com.dsk.common.helper.LoginHelper;
import com.dsk.common.utils.ValidatorUtils; //import com.dsk.common.utils.ValidatorUtils;
import com.dsk.common.utils.spring.SpringUtils; //import com.dsk.common.utils.spring.SpringUtils;
import com.dsk.cscec.domain.vo.ProjectMeasuresImportVo; //import com.dsk.cscec.domain.vo.ProjectMeasuresImportVo;
import com.dsk.system.domain.SysUser; //import com.dsk.system.domain.SysUser;
import com.dsk.system.domain.vo.SysUserImportVo; //import com.dsk.system.domain.vo.SysUserImportVo;
import com.dsk.system.service.ISysConfigService; //import com.dsk.system.service.ISysConfigService;
import com.dsk.system.service.ISysUserService; //import com.dsk.system.service.ISysUserService;
import lombok.extern.slf4j.Slf4j; //import lombok.extern.slf4j.Slf4j;
//
import java.util.List; //import java.util.List;
//
/** ///**
* 系统用户自定义导入 // * 系统用户自定义导入
* // *
* @author Lion Li // * @author Lion Li
*/ // */
@Slf4j //@Slf4j
public class ProjectCostMeasureImportListener extends AnalysisEventListener<ProjectMeasuresImportVo> implements ExcelListener<ProjectMeasuresImportVo> { //public class ProjectCostMeasureImportListener extends AnalysisEventListener<ProjectMeasuresImportVo> implements ExcelListener<ProjectMeasuresImportVo> {
//
// private final ISysUserService userService; //// private final ISysUserService userService;
//
// private final String password; //// private final String password;
//
private final Boolean isUpdateSupport; // private final Boolean isUpdateSupport;
//
private final String operName; // private final String operName;
//
private int successNum = 0; // private int successNum = 0;
private int failureNum = 0; // private int failureNum = 0;
private final StringBuilder successMsg = new StringBuilder(); // private final StringBuilder successMsg = new StringBuilder();
private final StringBuilder failureMsg = new StringBuilder(); // private final StringBuilder failureMsg = new StringBuilder();
//
public ProjectCostMeasureImportListener(Boolean isUpdateSupport) { // public ProjectCostMeasureImportListener(Boolean isUpdateSupport) {
// String initPassword = SpringUtils.getBean(ISysConfigService.class).selectConfigByKey("sys.user.initPassword"); //// String initPassword = SpringUtils.getBean(ISysConfigService.class).selectConfigByKey("sys.user.initPassword");
// this.userService = SpringUtils.getBean(ISysUserService.class); //// this.userService = SpringUtils.getBean(ISysUserService.class);
// this.password = BCrypt.hashpw(initPassword); //// this.password = BCrypt.hashpw(initPassword);
this.isUpdateSupport = isUpdateSupport; // this.isUpdateSupport = isUpdateSupport;
this.operName = LoginHelper.getUsername(); // this.operName = LoginHelper.getUsername();
} // }
//
@Override // @Override
public void invoke(ProjectMeasuresImportVo userVo, AnalysisContext context) { // public void invoke(ProjectMeasuresImportVo userVo, AnalysisContext context) {
// SysUser user = this.userService.selectUserByUserName(userVo.getUserName()); //// SysUser user = this.userService.selectUserByUserName(userVo.getUserName());
// try { //// try {
// // 验证是否存在这个用户 //// // 验证是否存在这个用户
// if (ObjectUtil.isNull(user)) { //// if (ObjectUtil.isNull(user)) {
// user = BeanUtil.toBean(userVo, SysUser.class); //// user = BeanUtil.toBean(userVo, SysUser.class);
// ValidatorUtils.validate(user); //// ValidatorUtils.validate(user);
// user.setPassword(password); //// user.setPassword(password);
// user.setCreateBy(operName); //// user.setCreateBy(operName);
// userService.insertUser(user); //// userService.insertUser(user);
// successNum++; //// successNum++;
// successMsg.append("<br/>").append(successNum).append("、账号 ").append(user.getUserName()).append(" 导入成功"); //// successMsg.append("<br/>").append(successNum).append("、账号 ").append(user.getUserName()).append(" 导入成功");
// } else if (isUpdateSupport) { //// } else if (isUpdateSupport) {
// Long userId = user.getUserId(); //// Long userId = user.getUserId();
// user = BeanUtil.toBean(userVo, SysUser.class); //// user = BeanUtil.toBean(userVo, SysUser.class);
// user.setUserId(userId); //// user.setUserId(userId);
// ValidatorUtils.validate(user); //// ValidatorUtils.validate(user);
// userService.checkUserAllowed(user); //// userService.checkUserAllowed(user);
// userService.checkUserDataScope(user.getUserId()); //// userService.checkUserDataScope(user.getUserId());
// user.setUpdateBy(operName); //// user.setUpdateBy(operName);
// userService.updateUser(user); //// userService.updateUser(user);
// successNum++; //// successNum++;
// successMsg.append("<br/>").append(successNum).append("、账号 ").append(user.getUserName()).append(" 更新成功"); //// successMsg.append("<br/>").append(successNum).append("、账号 ").append(user.getUserName()).append(" 更新成功");
//// } else {
//// failureNum++;
//// failureMsg.append("<br/>").append(failureNum).append("、账号 ").append(user.getUserName()).append(" 已存在");
//// }
//// } catch (Exception e) {
//// failureNum++;
//// String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
//// failureMsg.append(msg).append(e.getMessage());
//// log.error(msg, e);
//// }
// }
//
// @Override
// public void doAfterAllAnalysed(AnalysisContext context) {
//
// }
//
// @Override
// public ExcelResult<ProjectMeasuresImportVo> getExcelResult() {
// return new ExcelResult<ProjectMeasuresImportVo>() {
//
// @Override
// public String getAnalysis() {
// if (failureNum > 0) {
// failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
// throw new ServiceException(failureMsg.toString());
// } else { // } else {
// failureNum++; // successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
// failureMsg.append("<br/>").append(failureNum).append("、账号 ").append(user.getUserName()).append(" 已存在"); // }
// return successMsg.toString();
// }
//
// @Override
// public List<ProjectMeasuresImportVo> getList() {
// return null;
// }
//
// @Override
// public List<String> getErrorList() {
// return null;
// } // }
// } catch (Exception e) { // };
// failureNum++;
// String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
// failureMsg.append(msg).append(e.getMessage());
// log.error(msg, e);
// } // }
} //}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
}
@Override
public ExcelResult<ProjectMeasuresImportVo> getExcelResult() {
return new ExcelResult<ProjectMeasuresImportVo>() {
@Override
public String getAnalysis() {
if (failureNum > 0) {
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new ServiceException(failureMsg.toString());
} else {
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
}
return successMsg.toString();
}
@Override
public List<ProjectMeasuresImportVo> getList() {
return null;
}
@Override
public List<String> getErrorList() {
return null;
}
};
}
}
...@@ -2,6 +2,12 @@ package com.dsk.cscec.mapper; ...@@ -2,6 +2,12 @@ package com.dsk.cscec.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dsk.cscec.domain.CbQuantitySummary; import com.dsk.cscec.domain.CbQuantitySummary;
import com.dsk.cscec.domain.bo.CbProjectBaseBo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/** /**
* 成本-工料汇总基本表(CbQuantitySummary)表数据库访问层 * 成本-工料汇总基本表(CbQuantitySummary)表数据库访问层
...@@ -11,5 +17,10 @@ import com.dsk.cscec.domain.CbQuantitySummary; ...@@ -11,5 +17,10 @@ import com.dsk.cscec.domain.CbQuantitySummary;
*/ */
public interface CbQuantitySummaryMapper extends BaseMapper<CbQuantitySummary> { public interface CbQuantitySummaryMapper extends BaseMapper<CbQuantitySummary> {
List<Map<String, Object>> selectSubject(CbProjectBaseBo bo);
int selectOtherSubjectCount(CbProjectBaseBo bo);
} }
...@@ -2,6 +2,10 @@ package com.dsk.cscec.service; ...@@ -2,6 +2,10 @@ package com.dsk.cscec.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.dsk.cscec.domain.CbQuantitySummary; import com.dsk.cscec.domain.CbQuantitySummary;
import com.dsk.cscec.domain.bo.CbProjectBaseBo;
import java.util.List;
import java.util.Map;
/** /**
* 成本-工料汇总基本表(CbQuantitySummary)表服务接口 * 成本-工料汇总基本表(CbQuantitySummary)表服务接口
...@@ -11,5 +15,9 @@ import com.dsk.cscec.domain.CbQuantitySummary; ...@@ -11,5 +15,9 @@ import com.dsk.cscec.domain.CbQuantitySummary;
*/ */
public interface ICbQuantitySummaryService extends IService<CbQuantitySummary> { public interface ICbQuantitySummaryService extends IService<CbQuantitySummary> {
Map<String, Object> subjectTree(CbProjectBaseBo bo);
List<String> monthList(CbProjectBaseBo bo);
} }
package com.dsk.cscec.service.impl; package com.dsk.cscec.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsk.cscec.mapper.CbQuantitySummaryMapper;
import com.dsk.cscec.domain.CbQuantitySummary; import com.dsk.cscec.domain.CbQuantitySummary;
import com.dsk.cscec.domain.bo.CbProjectBaseBo;
import com.dsk.cscec.mapper.CbQuantitySummaryMapper;
import com.dsk.cscec.service.ICbQuantitySummaryService; import com.dsk.cscec.service.ICbQuantitySummaryService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* 成本-工料汇总基本表(CbQuantitySummary)表服务实现类 * 成本-工料汇总基本表(CbQuantitySummary)表服务实现类
...@@ -15,5 +22,27 @@ import org.springframework.stereotype.Service; ...@@ -15,5 +22,27 @@ import org.springframework.stereotype.Service;
@Service @Service
public class CbQuantitySummaryServiceImpl extends ServiceImpl<CbQuantitySummaryMapper, CbQuantitySummary> implements ICbQuantitySummaryService { public class CbQuantitySummaryServiceImpl extends ServiceImpl<CbQuantitySummaryMapper, CbQuantitySummary> implements ICbQuantitySummaryService {
@Override
public Map<String, Object> subjectTree(CbProjectBaseBo bo) {
Map<String, Object> resultMap = new HashMap<>();
List<Map<String, Object>> list = baseMapper.selectSubject(bo);
if (!ObjectUtils.isEmpty(list)) {
Map<String, Map<String, Map<String, List<Map<String, Object>>>>> map = list.stream().collect(
Collectors.groupingBy(item -> item.get("one").toString(),
Collectors.groupingBy(item -> item.get("two").toString(),
Collectors.groupingBy(item -> item.get("three").toString()))));
resultMap.put("房建类成本科目", map);
}
int otherSubjectCount = baseMapper.selectOtherSubjectCount(bo);
if (otherSubjectCount > 0) {
resultMap.put("未归类项目", "other");
}
return resultMap;
}
@Override
public List<String> monthList(CbProjectBaseBo bo) {
return null;
}
} }
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.dsk.cscec.mapper.CbQuantitySummaryMapper">
<select id="selectSubject" resultType="java.util.Map">
select
cs1.cb_subject_name as one, cs2.cb_subject_name as two, cs3.cb_subject_name as three
from cb_subject cs1
join cb_subject cs2 on (cs2.cb_subject_no like concat(cs1.cb_subject_no,'%') and cs2.`level` = 2 )
join cb_subject cs3 on (cs3.cb_subject_no like concat(cs2.cb_subject_no,'%') and cs3.`level` = 3 )
join cb_quantity_summary cqs on (cqs.cb_subject_name = cs3.cb_subject_name and cqs.project_id = #{projectId} and cqs.cb_stage = #{cbStage})
where cs1.`level` = 1
group by cs1.cb_subject_name,cs2.cb_subject_name,cs3.cb_subject_name
</select>
<select id="selectOtherSubjectCount" resultType="java.lang.Integer">
select
count(cqs.id)
from cb_quantity_summary cqs
left join cb_subject cs1 on cqs.cb_subject_name = cs1.cb_subject_name
where cqs.project_id = #{projectId} and cqs.cb_stage = #{cbStage} and cs1.id is null
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment