修改提交
This commit is contained in:
parent
d8cf513d66
commit
4ea93fdacb
@ -0,0 +1,353 @@
|
||||
package com.zhgd.xmgl.modules.cost.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.zhgd.annotation.OperLog;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.Company;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.ICompanyService;
|
||||
import com.zhgd.xmgl.modules.cost.entity.CostSubject;
|
||||
import com.zhgd.xmgl.modules.cost.service.ICostSubjectService;
|
||||
import com.zhgd.xmgl.modules.exam.entity.ExamQuestionBank;
|
||||
import com.zhgd.xmgl.modules.project.entity.vo.ProjectInfoExtVo;
|
||||
import com.zhgd.xmgl.modules.project.service.IProjectService;
|
||||
import com.zhgd.xmgl.security.entity.UserInfo;
|
||||
import com.zhgd.xmgl.security.util.SecurityUtils;
|
||||
import com.zhgd.xmgl.util.ExcelUtils;
|
||||
import com.zhgd.xmgl.util.PageUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.jeecg.common.util.oConvertUtils;
|
||||
import com.zhgd.xmgl.modules.cost.entity.CostBudget;
|
||||
import com.zhgd.xmgl.modules.cost.service.ICostBudgetService;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
|
||||
/**
|
||||
* @Title: Controller
|
||||
* @Description: 成本科目预算
|
||||
* @author: pengj
|
||||
* @date: 2024-07-03
|
||||
* @version: V1.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/xmgl/costBudget")
|
||||
@Slf4j
|
||||
@Api(tags = "成本科目预算管理")
|
||||
public class CostBudgetController {
|
||||
@Autowired
|
||||
private ICostBudgetService costBudgetService;
|
||||
|
||||
@Autowired
|
||||
private ICostSubjectService costSubjectService;
|
||||
|
||||
@Autowired
|
||||
private IProjectService projectService;
|
||||
|
||||
@Autowired
|
||||
private ICompanyService companyService;
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "成本科目管理", operType = "列表查询", operDesc = "列表查询成本科目信息")
|
||||
@ApiOperation(value = " 列表查询成本科目信息", notes = "列表查询成本科目信息", httpMethod = "POST")
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "body", dataType = "String")
|
||||
@PostMapping(value = "/tree")
|
||||
public Result<List<CostSubject>> tree(@ApiIgnore @RequestBody Map<String, Object> map) {
|
||||
String projectSn = MapUtils.getString(map, "projectSn");
|
||||
ProjectInfoExtVo projectInfoBySn = projectService.getProjectInfoBySn(projectSn);
|
||||
Company company = companyService.getOne(Wrappers.<Company>lambdaQuery().eq(Company::getCompanySn, projectInfoBySn.getCompanySn()));
|
||||
map.put("companySn", company.getHeadquartersSn());
|
||||
QueryWrapper<CostSubject> queryWrapper = QueryGenerator.initPageQueryWrapper(CostSubject.class, map);
|
||||
queryWrapper.lambda().eq(CostSubject::getType, projectInfoBySn.getProjectType());
|
||||
List<CostSubject> list = costBudgetService.tree(queryWrapper, projectInfoBySn);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "成本科目预算管理", operType = "分页查询", operDesc = "分页列表查询成本科目预算信息")
|
||||
@ApiOperation(value = " 分页列表查询成本科目预算信息", notes = "分页列表查询成本科目预算信息", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "pageNo", value = "页数", paramType = "body", required = true, defaultValue = "1", dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "body", required = true, defaultValue = "10", dataType = "Integer")
|
||||
})
|
||||
@PostMapping(value = "/page")
|
||||
public Result<IPage<CostBudget>> queryPageList(@ApiIgnore @RequestBody Map<String, Object> map) {
|
||||
QueryWrapper<CostBudget> queryWrapper = QueryGenerator.initPageQueryWrapper(CostBudget.class, map);
|
||||
Page<CostBudget> page = PageUtil.getPage(map);
|
||||
IPage<CostBudget> pageList = costBudgetService.page(page, queryWrapper);
|
||||
return Result.success(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param costBudget
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "成本科目预算管理", operType = "列表查询", operDesc = "列表查询成本科目预算信息")
|
||||
@ApiOperation(value = " 列表查询成本科目预算信息", notes = "列表查询成本科目预算信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/list")
|
||||
public Result<List<CostBudget>> queryList(@RequestBody CostBudget costBudget) {
|
||||
QueryWrapper<CostBudget> queryWrapper = QueryGenerator.initQueryWrapper(costBudget);
|
||||
List<CostBudget> list = costBudgetService.list(queryWrapper);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param costBudget
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "成本科目预算管理", operType = "新增", operDesc = "添加成本科目预算信息")
|
||||
@ApiOperation(value = " 添加成本科目预算信息", notes = "添加成本科目预算信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<Object> add(@RequestBody CostBudget costBudget) {
|
||||
UserInfo user = SecurityUtils.getUser();
|
||||
costBudget.setCreateBy(user.getUserId().toString());
|
||||
costBudget.setCreateTime(new Date());
|
||||
costBudgetService.save(costBudget);
|
||||
return Result.success("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param costBudget
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "成本科目预算管理", operType = "修改", operDesc = "编辑成本科目预算信息")
|
||||
@ApiOperation(value = "编辑成本科目预算信息", notes = "编辑成本科目预算信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/edit")
|
||||
public Result<CostBudget> edit(@RequestBody CostBudget costBudget) {
|
||||
Result<CostBudget> result = new Result<CostBudget>();
|
||||
CostBudget costBudgetEntity = costBudgetService.getById(costBudget.getId());
|
||||
if (costBudgetEntity == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
UserInfo user = SecurityUtils.getUser();
|
||||
costBudget.setUpdateBy(user.getUserId().toString());
|
||||
costBudget.setUpdateTime(new Date());
|
||||
boolean ok = costBudgetService.updateById(costBudget);
|
||||
if (ok) {
|
||||
result.success("修改成功!");
|
||||
} else {
|
||||
result.success("操作失败!");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "成本科目预算管理", operType = "删除", operDesc = "删除成本科目预算信息")
|
||||
@ApiOperation(value = "删除成本科目预算信息", notes = "删除成本科目预算信息", httpMethod = "POST")
|
||||
@ApiImplicitParam(name = "id", value = "成本科目预算ID", paramType = "body", required = true, dataType = "Integer")
|
||||
@PostMapping(value = "/delete")
|
||||
public Result<CostBudget> delete(@RequestBody CostBudget costBudget) {
|
||||
Result<CostBudget> result = new Result<CostBudget>();
|
||||
CostBudget costBudgetEntity = costBudgetService.getById(costBudget.getId());
|
||||
if (costBudgetEntity == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
boolean ok = costBudgetService.removeById(costBudget.getId());
|
||||
if (ok) {
|
||||
result.success("删除成功!");
|
||||
} else {
|
||||
result.success("操作失败!");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "成本科目预算管理", operType = "查询", operDesc = "通过id查询成本科目预算信息")
|
||||
@ApiOperation(value = "通过id查询成本科目预算信息", notes = "通过id查询成本科目预算信息", httpMethod = "POST")
|
||||
@ApiImplicitParam(name = "id", value = "成本科目预算ID", paramType = "body", required = true, dataType = "Integer")
|
||||
@PostMapping(value = "/queryById")
|
||||
public Result<CostBudget> queryById(@ApiIgnore @RequestBody Map<String, Object> map) {
|
||||
Result<CostBudget> result = new Result<CostBudget>();
|
||||
CostBudget costBudget = costBudgetService.getById(MapUtils.getString(map, "id"));
|
||||
if (costBudget == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
result.setResult(costBudget);
|
||||
result.setSuccess(true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
*/
|
||||
@ApiOperation(value = "导出excel成本科目预算信息", notes = "导出excel成本科目预算信息", httpMethod = "POST")
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "body", dataType = "String")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(@RequestBody Map<String, Object> map) {
|
||||
// Step.1 组装查询条件
|
||||
String projectSn = MapUtils.getString(map, "projectSn");
|
||||
ProjectInfoExtVo projectInfoBySn = projectService.getProjectInfoBySn(projectSn);
|
||||
Company company = companyService.getOne(Wrappers.<Company>lambdaQuery().eq(Company::getCompanySn, projectInfoBySn.getCompanySn()));
|
||||
map.put("companySn", company.getHeadquartersSn());
|
||||
map.put("type", projectInfoBySn.getProjectType());
|
||||
QueryWrapper<CostSubject> queryWrapper = QueryGenerator.initPageQueryWrapper(CostSubject.class, map);
|
||||
//Step.2 AutoPoi 导出Excel
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
List<CostSubject> list = costBudgetService.exportList(queryWrapper, projectInfoBySn, true);
|
||||
//导出文件名称
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "成本科目预算");
|
||||
mv.addObject(NormalExcelConstants.CLASS, CostSubject.class);
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("成本科目预算数据", "导出人:" + SecurityUtils.getUser().getRealName(), "导出信息"));
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, list);
|
||||
return mv;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 导出excel模版
|
||||
// *
|
||||
// */
|
||||
// @ApiOperation(value = "导出excel成本科目预算模版", notes = "导出excel成本科目预算模版", httpMethod = "POST")
|
||||
// @ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "body", dataType = "String")
|
||||
// @RequestMapping(value = "/exportTemplate")
|
||||
// public ModelAndView exportTemplate(@RequestBody Map<String, Object> map) {
|
||||
// // Step.1 组装查询条件
|
||||
// String projectSn = MapUtils.getString(map, "projectSn");
|
||||
// ProjectInfoExtVo projectInfoBySn = projectService.getProjectInfoBySn(projectSn);
|
||||
// Company company = companyService.getOne(Wrappers.<Company>lambdaQuery().eq(Company::getCompanySn, projectInfoBySn.getCompanySn()));
|
||||
// map.put("companySn", company.getHeadquartersSn());
|
||||
// map.put("type", projectInfoBySn.getProjectType());
|
||||
// QueryWrapper<CostSubject> queryWrapper = QueryGenerator.initPageQueryWrapper(CostSubject.class, map);
|
||||
// //Step.2 AutoPoi 导出Excel
|
||||
// ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
// List<CostSubject> list = costBudgetService.exportList(queryWrapper, projectInfoBySn, false);
|
||||
// //导出文件名称
|
||||
// mv.addObject(NormalExcelConstants.FILE_NAME, "成本科目预算");
|
||||
// mv.addObject(NormalExcelConstants.CLASS, CostSubject.class);
|
||||
// mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("成本科目预算数据", "导出人:" + SecurityUtils.getUser().getRealName(), "导出信息"));
|
||||
// mv.addObject(NormalExcelConstants.DATA_LIST, list);
|
||||
// return mv;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "通过excel导入成本科目预算信息", notes = "通过excel导入成本科目预算信息", httpMethod = "POST")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
String projectSn = request.getParameter("projectSn");
|
||||
ProjectInfoExtVo projectInfoBySn = projectService.getProjectInfoBySn(projectSn);
|
||||
Company company = companyService.getOne(Wrappers.<Company>lambdaQuery().eq(Company::getCompanySn, projectInfoBySn.getCompanySn()));
|
||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||
LambdaQueryWrapper<CostSubject> wrapper = Wrappers.<CostSubject>lambdaQuery()
|
||||
.eq(CostSubject::getCompanySn, company.getHeadquartersSn())
|
||||
.eq(CostSubject::getType, projectInfoBySn.getProjectType());
|
||||
List<CostSubject> subjectList = costSubjectService.list(wrapper);
|
||||
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||
MultipartFile file = entity.getValue();// 获取上传文件对象
|
||||
ImportParams params = new ImportParams();
|
||||
params.setTitleRows(2);
|
||||
params.setHeadRows(1);
|
||||
try {
|
||||
List<CostSubject> listCostSubjects = ExcelImportUtil.importExcel(file.getInputStream(), CostSubject.class, params);
|
||||
// List<Map<String, String>> costSubjectList = ExcelUtils.jxlExlToList(file.getInputStream(), 0);
|
||||
List<CostBudget> costBudgetList = new ArrayList<>();
|
||||
for (CostSubject costSubject : listCostSubjects) {
|
||||
String code = costSubject.getCode();
|
||||
String budgetCost = costSubject.getBudgetCost();
|
||||
String actualCost = costSubject.getActualCost();
|
||||
String costDifference = costSubject.getCostDifference();
|
||||
List<CostSubject> codeList = subjectList.stream().filter(s -> s.getCode().equals(code)).collect(Collectors.toList());
|
||||
CostBudget costBudget = new CostBudget();
|
||||
costBudget.setSubjectId(codeList.get(0).getId());
|
||||
costBudget.setProjectSn(projectSn);
|
||||
costBudget.setBudgetCost(budgetCost);
|
||||
costBudget.setActualCost(actualCost);
|
||||
costBudget.setCostDifference(costDifference);
|
||||
costBudget.setCreateBy(SecurityUtils.getUser().getUserId().toString());
|
||||
costBudget.setCreateTime(new Date());
|
||||
costBudgetList.add(costBudget);
|
||||
}
|
||||
/*for (CostBudget costBudget : costBudgetList) {
|
||||
List<CostSubject> subSubject = subjectList.stream().filter(s -> s.getAncestors().contains(costBudget.getSubjectId().toString())).collect(Collectors.toList());
|
||||
if (subSubject.size() > 0) {
|
||||
BigDecimal budgetCost = subSubject.stream().map(s -> new BigDecimal(s.getBudgetCost())).reduce(BigDecimal.ZERO, BigDecimal::add).add(new BigDecimal(costBudget.getBudgetCost()));
|
||||
BigDecimal actualCost = subSubject.stream().map(s -> new BigDecimal(s.getActualCost())).reduce(BigDecimal.ZERO, BigDecimal::add).add(new BigDecimal(costBudget.getActualCost()));
|
||||
costBudget.setBudgetCost(budgetCost.toString());
|
||||
costBudget.setBudgetCost(budgetCost.toString());
|
||||
costBudget.setCostDifference(actualCost.subtract(budgetCost).divide(budgetCost, 2, BigDecimal.ROUND_HALF_UP).toString());
|
||||
}
|
||||
}*/
|
||||
costBudgetService.remove(Wrappers.<CostBudget>lambdaQuery().eq(CostBudget::getProjectSn, projectSn));
|
||||
costBudgetService.saveBatch(costBudgetList);
|
||||
return Result.ok("文件导入成功!数据行数:" + costBudgetList.size());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return Result.error("文件导入失败!");
|
||||
} finally {
|
||||
try {
|
||||
file.getInputStream().close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.ok("文件导入失败!");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,223 @@
|
||||
package com.zhgd.xmgl.modules.cost.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.zhgd.annotation.OperLog;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.Company;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.ICompanyService;
|
||||
import com.zhgd.xmgl.modules.cost.vo.CostSubjectVo;
|
||||
import com.zhgd.xmgl.modules.project.entity.vo.ProjectInfoExtVo;
|
||||
import com.zhgd.xmgl.modules.project.service.IProjectService;
|
||||
import com.zhgd.xmgl.util.PageUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.jeecg.common.util.oConvertUtils;
|
||||
import com.zhgd.xmgl.modules.cost.entity.CostSubject;
|
||||
import com.zhgd.xmgl.modules.cost.service.ICostSubjectService;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
|
||||
/**
|
||||
* @Title: Controller
|
||||
* @Description: 成本科目
|
||||
* @author: pengj
|
||||
* @date: 2024-07-03
|
||||
* @version: V1.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/xmgl/costSubject")
|
||||
@Slf4j
|
||||
@Api(tags = "成本科目管理")
|
||||
public class CostSubjectController {
|
||||
@Autowired
|
||||
private ICostSubjectService costSubjectService;
|
||||
|
||||
@Autowired
|
||||
private IProjectService projectService;
|
||||
|
||||
@Autowired
|
||||
private ICompanyService companyService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "成本科目管理", operType = "分页查询", operDesc = "分页列表查询成本科目信息")
|
||||
@ApiOperation(value = " 分页列表查询成本科目信息", notes = "分页列表查询成本科目信息", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "pageNo", value = "页数", paramType = "body", required = true, defaultValue = "1", dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "body", required = true, defaultValue = "10", dataType = "Integer")
|
||||
})
|
||||
@PostMapping(value = "/page")
|
||||
public Result<IPage<CostSubject>> queryPageList(@ApiIgnore @RequestBody Map<String, Object> map) {
|
||||
QueryWrapper<CostSubject> queryWrapper = QueryGenerator.initPageQueryWrapper(CostSubject.class, map);
|
||||
Page<CostSubject> page = PageUtil.getPage(map);
|
||||
IPage<CostSubject> pageList = costSubjectService.page(page, queryWrapper);
|
||||
return Result.success(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param costSubject
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "成本科目管理", operType = "列表查询", operDesc = "列表查询成本科目信息")
|
||||
@ApiOperation(value = " 列表查询成本科目信息", notes = "列表查询成本科目信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/list")
|
||||
public Result<List<CostSubject>> queryList(@RequestBody CostSubject costSubject) {
|
||||
QueryWrapper<CostSubject> queryWrapper = QueryGenerator.initQueryWrapper(costSubject);
|
||||
List<CostSubject> list = costSubjectService.list(queryWrapper);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "成本科目管理", operType = "列表查询", operDesc = "列表查询成本科目信息")
|
||||
@ApiOperation(value = " 列表查询成本科目信息", notes = "列表查询成本科目信息", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "pageNo", value = "页数", paramType = "body", required = true, defaultValue = "1", dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "body", required = true, defaultValue = "10", dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "body", dataType = "String"),
|
||||
@ApiImplicitParam(name = "companySn", value = "企业SN", paramType = "body", dataType = "String")
|
||||
})
|
||||
@PostMapping(value = "/tree")
|
||||
public Result<Page<CostSubject>> tree(@ApiIgnore @RequestBody Map<String, Object> map) {
|
||||
String projectSn = MapUtils.getString(map, "projectSn");
|
||||
if (StringUtils.isNotBlank(projectSn)) {
|
||||
ProjectInfoExtVo projectInfoBySn = projectService.getProjectInfoBySn(projectSn);
|
||||
Company company = companyService.getOne(Wrappers.<Company>lambdaQuery().eq(Company::getCompanySn, projectInfoBySn.getCompanySn()));
|
||||
map.put("companySn", company.getHeadquartersSn());
|
||||
map.put("type", projectInfoBySn.getProjectType());
|
||||
}
|
||||
Page<CostSubject> page = PageUtil.getPage(map);
|
||||
QueryWrapper<CostSubject> queryWrapper = QueryGenerator.initPageQueryWrapper(CostSubject.class, map);
|
||||
Page<CostSubject> list = costSubjectService.tree(page, queryWrapper);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param costSubject
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "成本科目管理", operType = "新增", operDesc = "添加成本科目信息")
|
||||
@ApiOperation(value = " 添加成本科目信息", notes = "添加成本科目信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<Object> add(@RequestBody CostSubject costSubject) {
|
||||
costSubjectService.saveInfo(costSubject);
|
||||
return Result.success("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param costSubject
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "成本科目管理", operType = "修改", operDesc = "编辑成本科目信息")
|
||||
@ApiOperation(value = "编辑成本科目信息", notes = "编辑成本科目信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/edit")
|
||||
public Result<CostSubject> edit(@RequestBody CostSubject costSubject) {
|
||||
Result<CostSubject> result = new Result<CostSubject>();
|
||||
CostSubject costSubjectEntity = costSubjectService.getById(costSubject.getId());
|
||||
if (costSubjectEntity == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
boolean ok = costSubjectService.updateInfo(costSubject);
|
||||
if (ok) {
|
||||
result.success("修改成功!");
|
||||
} else {
|
||||
result.success("操作失败!");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "成本科目管理", operType = "删除", operDesc = "删除成本科目信息")
|
||||
@ApiOperation(value = "删除成本科目信息", notes = "删除成本科目信息", httpMethod = "POST")
|
||||
@ApiImplicitParam(name = "id", value = "成本科目ID", paramType = "body", required = true, dataType = "Integer")
|
||||
@PostMapping(value = "/delete")
|
||||
public Result<CostSubject> delete(@RequestBody CostSubject costSubject) {
|
||||
Result<CostSubject> result = new Result<CostSubject>();
|
||||
CostSubject costSubjectEntity = costSubjectService.getById(costSubject.getId());
|
||||
if (costSubjectEntity == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
boolean ok = costSubjectService.delInfo(costSubject);
|
||||
if (ok) {
|
||||
result.success("删除成功!");
|
||||
} else {
|
||||
result.success("操作失败!");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "成本科目管理", operType = "查询", operDesc = "通过id查询成本科目信息")
|
||||
@ApiOperation(value = "通过id查询成本科目信息", notes = "通过id查询成本科目信息", httpMethod = "POST")
|
||||
@ApiImplicitParam(name = "id", value = "成本科目ID", paramType = "body", required = true, dataType = "Integer")
|
||||
@PostMapping(value = "/queryById")
|
||||
public Result<CostSubject> queryById(@ApiIgnore @RequestBody Map<String, Object> map) {
|
||||
Result<CostSubject> result = new Result<CostSubject>();
|
||||
CostSubject costSubject = costSubjectService.getById(MapUtils.getString(map, "id"));
|
||||
if (costSubject == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
result.setResult(costSubject);
|
||||
result.setSuccess(true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
106
src/main/java/com/zhgd/xmgl/modules/cost/entity/CostBudget.java
Normal file
106
src/main/java/com/zhgd/xmgl/modules/cost/entity/CostBudget.java
Normal file
@ -0,0 +1,106 @@
|
||||
package com.zhgd.xmgl.modules.cost.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @Description: 成本科目预算
|
||||
* @author: pengj
|
||||
* @date: 2024-07-03
|
||||
* @version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("cost_budget")
|
||||
@ApiModel(value = "CostBudget实体类", description = "CostBudget")
|
||||
public class CostBudget implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 成本预算ID
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "成本预算ID")
|
||||
private Long id;
|
||||
/**
|
||||
* 成本科目ID
|
||||
*/
|
||||
@Excel(name = "成本科目ID", width = 15)
|
||||
@ApiModelProperty(value = "成本科目ID")
|
||||
private Long subjectId;
|
||||
/**
|
||||
* 项目SN
|
||||
*/
|
||||
@Excel(name = "项目SN", width = 15)
|
||||
@ApiModelProperty(value = "项目SN")
|
||||
private String projectSn;
|
||||
/**
|
||||
* 分项
|
||||
*/
|
||||
@Excel(name = "分项", width = 15)
|
||||
@ApiModelProperty(value = "分项")
|
||||
private String subItem;
|
||||
/**
|
||||
* 预算成本
|
||||
*/
|
||||
@Excel(name = "预算成本", width = 15)
|
||||
@ApiModelProperty(value = "预算成本")
|
||||
private String budgetCost;
|
||||
/**
|
||||
* 成本占比
|
||||
*/
|
||||
@Excel(name = "成本占比", width = 15)
|
||||
@ApiModelProperty(value = "成本占比")
|
||||
private String costRatio;
|
||||
/**
|
||||
* 目标对比差额
|
||||
*/
|
||||
@Excel(name = "目标对比差额", width = 15)
|
||||
@ApiModelProperty(value = "目标对比差额")
|
||||
private String costDifference;
|
||||
/**
|
||||
* 预算清单附件
|
||||
*/
|
||||
@Excel(name = "预算清单附件", width = 15)
|
||||
@ApiModelProperty(value = "预算清单附件")
|
||||
private String budgetFile;
|
||||
/**
|
||||
* 实际成本
|
||||
*/
|
||||
@Excel(name = "实际成本", width = 15)
|
||||
@ApiModelProperty(value = "实际成本")
|
||||
private String actualCost;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@Excel(name = "创建人", width = 15)
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private String createBy;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 最后操作人
|
||||
*/
|
||||
@Excel(name = "最后操作人", width = 15)
|
||||
@ApiModelProperty(value = "最后操作人")
|
||||
private String updateBy;
|
||||
/**
|
||||
* 最后操作时间
|
||||
*/
|
||||
@Excel(name = "最后操作时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "最后操作时间")
|
||||
private Date updateTime;
|
||||
}
|
||||
112
src/main/java/com/zhgd/xmgl/modules/cost/entity/CostSubject.java
Normal file
112
src/main/java/com/zhgd/xmgl/modules/cost/entity/CostSubject.java
Normal file
@ -0,0 +1,112 @@
|
||||
package com.zhgd.xmgl.modules.cost.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @Description: 成本科目
|
||||
* @author: pengj
|
||||
* @date: 2024-07-03
|
||||
* @version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("cost_subject")
|
||||
@ApiModel(value = "CostSubject实体类", description = "CostSubject")
|
||||
public class CostSubject implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 成本科目ID
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "成本科目ID")
|
||||
private Long id;
|
||||
/**
|
||||
* 科目类型(字典数据)
|
||||
*/
|
||||
@ApiModelProperty(value = "科目类型(字典数据)")
|
||||
private Integer type;
|
||||
/**
|
||||
* 企业SN
|
||||
*/
|
||||
@ApiModelProperty(value = "企业SN")
|
||||
private String companySn;
|
||||
/**
|
||||
* 级别层次
|
||||
*/
|
||||
@ApiModelProperty(value = "级别层次")
|
||||
private Integer level;
|
||||
/**
|
||||
* 科目名称
|
||||
*/
|
||||
@Excel(name = "科目名称", width = 15)
|
||||
@ApiModelProperty(value = "科目名称")
|
||||
private String name;
|
||||
/**
|
||||
* 科目编码
|
||||
*/
|
||||
@Excel(name = "科目编码", width = 15)
|
||||
@ApiModelProperty(value = "科目编码")
|
||||
private String code;
|
||||
/**
|
||||
* 父级科目ID
|
||||
*/
|
||||
@ApiModelProperty(value = "父级科目ID")
|
||||
private Long parentId;
|
||||
/**
|
||||
* 祖级关系
|
||||
*/
|
||||
@ApiModelProperty(value = "祖级关系")
|
||||
private String ancestors;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private String createBy;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 最后操作人
|
||||
*/
|
||||
@ApiModelProperty(value = "最后操作人")
|
||||
private String updateBy;
|
||||
/**
|
||||
* 最后操作时间
|
||||
*/
|
||||
@ApiModelProperty(value = "最后操作时间")
|
||||
private Date updateTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "子级科目信息")
|
||||
private List<CostSubject> children;
|
||||
|
||||
@Excel(name = "预算成本", width = 15)
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "预算成本")
|
||||
private String budgetCost;
|
||||
|
||||
@Excel(name = "实际成本", width = 15)
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "实际成本")
|
||||
private String actualCost;
|
||||
|
||||
@Excel(name = "目标对比差额", width = 15)
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "目标对比差额")
|
||||
private String costDifference;
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.zhgd.xmgl.modules.cost.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.zhgd.xmgl.modules.cost.entity.CostBudget;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 成本科目预算
|
||||
* @author: pengj
|
||||
* @date: 2024-07-03
|
||||
* @version: V1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface CostBudgetMapper extends BaseMapper<CostBudget> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.zhgd.xmgl.modules.cost.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.zhgd.xmgl.modules.cost.entity.CostSubject;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 成本科目
|
||||
* @author: pengj
|
||||
* @date: 2024-07-03
|
||||
* @version: V1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface CostSubjectMapper extends BaseMapper<CostSubject> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
<?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.zhgd.xmgl.modules.cost.mapper.CostBudgetMapper">
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,5 @@
|
||||
<?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.zhgd.xmgl.modules.cost.mapper.CostSubjectMapper">
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,23 @@
|
||||
package com.zhgd.xmgl.modules.cost.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.xmgl.modules.cost.entity.CostBudget;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhgd.xmgl.modules.cost.entity.CostSubject;
|
||||
import com.zhgd.xmgl.modules.project.entity.vo.ProjectInfoExtVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 成本科目预算
|
||||
* @author: pengj
|
||||
* @date: 2024-07-03
|
||||
* @version: V1.0
|
||||
*/
|
||||
public interface ICostBudgetService extends IService<CostBudget> {
|
||||
|
||||
List<CostSubject> tree(QueryWrapper<CostSubject> wrapper, ProjectInfoExtVo projectInfoBySn);
|
||||
|
||||
List<CostSubject> exportList(QueryWrapper<CostSubject> wrapper, ProjectInfoExtVo projectInfoBySn, boolean flag);
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package com.zhgd.xmgl.modules.cost.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.xmgl.modules.cost.entity.CostSubject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 成本科目
|
||||
* @author: pengj
|
||||
* @date: 2024-07-03
|
||||
* @version: V1.0
|
||||
*/
|
||||
public interface ICostSubjectService extends IService<CostSubject> {
|
||||
|
||||
Page<CostSubject> tree(Page page, QueryWrapper<CostSubject> wrapper);
|
||||
|
||||
boolean saveInfo(CostSubject costSubject);
|
||||
|
||||
boolean updateInfo(CostSubject costSubject);
|
||||
|
||||
boolean delInfo(CostSubject costSubject);
|
||||
}
|
||||
@ -0,0 +1,82 @@
|
||||
package com.zhgd.xmgl.modules.cost.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.xmgl.modules.cost.entity.CostBudget;
|
||||
import com.zhgd.xmgl.modules.cost.entity.CostSubject;
|
||||
import com.zhgd.xmgl.modules.cost.mapper.CostBudgetMapper;
|
||||
import com.zhgd.xmgl.modules.cost.service.ICostBudgetService;
|
||||
import com.zhgd.xmgl.modules.cost.service.ICostSubjectService;
|
||||
import com.zhgd.xmgl.modules.project.entity.vo.ProjectInfoExtVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description: 成本科目预算
|
||||
* @author: pengj
|
||||
* @date: 2024-07-03
|
||||
* @version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class CostBudgetServiceImpl extends ServiceImpl<CostBudgetMapper, CostBudget> implements ICostBudgetService {
|
||||
|
||||
@Autowired
|
||||
private ICostSubjectService costSubjectService;
|
||||
|
||||
@Override
|
||||
public List<CostSubject> tree(QueryWrapper<CostSubject> wrapper, ProjectInfoExtVo projectInfoBySn) {
|
||||
wrapper.lambda().eq(CostSubject::getParentId, 0);
|
||||
List<CostSubject> list = costSubjectService.list(wrapper);
|
||||
if (list.size() > 0) {
|
||||
List<CostSubject> allList = costSubjectService.list();
|
||||
List<CostBudget> budgetList = this.list(Wrappers.<CostBudget>lambdaQuery()
|
||||
.eq(CostBudget::getProjectSn, projectInfoBySn.getProjectSn()));
|
||||
getChildren(list, allList, budgetList, true);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CostSubject> exportList(QueryWrapper<CostSubject> wrapper, ProjectInfoExtVo projectInfoBySn, boolean flag) {
|
||||
wrapper.lambda().eq(CostSubject::getParentId, 0);
|
||||
List<CostSubject> list = costSubjectService.list(wrapper);
|
||||
if (list.size() > 0) {
|
||||
List<CostSubject> allList = costSubjectService.list();
|
||||
List<CostBudget> budgetList = this.list(Wrappers.<CostBudget>lambdaQuery()
|
||||
.eq(CostBudget::getProjectSn, projectInfoBySn.getProjectSn()));
|
||||
getChildren(list, allList, budgetList, flag);
|
||||
}
|
||||
List<CostSubject> resultList = new ArrayList<>();
|
||||
addChildren(list, resultList);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
private void addChildren(List<CostSubject> list, List<CostSubject> resultList) {
|
||||
for (CostSubject costSubject : list) {
|
||||
resultList.add(costSubject);
|
||||
resultList.addAll(costSubject.getChildren());
|
||||
addChildren(costSubject.getChildren(), resultList);
|
||||
}
|
||||
}
|
||||
|
||||
private void getChildren(List<CostSubject> list, List<CostSubject> allList, List<CostBudget> budgetList, boolean flag) {
|
||||
for (CostSubject costSubject : list) {
|
||||
List<CostBudget> costBudgets = budgetList.stream().filter(b -> costSubject.getId().toString().equals(b.getSubjectId().toString())).collect(Collectors.toList());
|
||||
if (costBudgets.size() > 0 && flag) {
|
||||
costSubject.setBudgetCost(costBudgets.get(0).getBudgetCost());
|
||||
costSubject.setActualCost(costBudgets.get(0).getActualCost());
|
||||
costSubject.setCostDifference(costBudgets.get(0).getCostDifference());
|
||||
}
|
||||
List<CostSubject> childrenList = allList.stream().filter(a -> a.getParentId().toString().equals(costSubject.getId().toString())).collect(Collectors.toList());
|
||||
getChildren(childrenList, allList, budgetList, flag);
|
||||
costSubject.setChildren(childrenList);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
package com.zhgd.xmgl.modules.cost.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.xmgl.modules.cost.entity.CostSubject;
|
||||
import com.zhgd.xmgl.modules.cost.mapper.CostSubjectMapper;
|
||||
import com.zhgd.xmgl.modules.cost.service.ICostSubjectService;
|
||||
import com.zhgd.xmgl.security.entity.UserInfo;
|
||||
import com.zhgd.xmgl.security.util.SecurityUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description: 成本科目
|
||||
* @author: pengj
|
||||
* @date: 2024-07-03
|
||||
* @version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class CostSubjectServiceImpl extends ServiceImpl<CostSubjectMapper, CostSubject> implements ICostSubjectService {
|
||||
|
||||
@Override
|
||||
public Page<CostSubject> tree(Page page, QueryWrapper<CostSubject> wrapper) {
|
||||
wrapper.lambda().eq(CostSubject::getParentId, 0);
|
||||
wrapper.lambda().isNotNull(CostSubject::getName);
|
||||
List<CostSubject> allList = this.list();
|
||||
Page<CostSubject> pageList = this.page(page, wrapper);
|
||||
getChildren(pageList.getRecords(), allList);
|
||||
return pageList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveInfo(CostSubject costSubject) {
|
||||
UserInfo user = SecurityUtils.getUser();
|
||||
CostSubject parent = this.getById(costSubject.getParentId());
|
||||
if (parent != null) {
|
||||
costSubject.setAncestors(parent.getAncestors() + "," + parent.getId().toString());
|
||||
} else {
|
||||
costSubject.setAncestors("0");
|
||||
}
|
||||
costSubject.setCreateBy(user.getUserId().toString());
|
||||
costSubject.setCreateTime(new Date());
|
||||
return this.save(costSubject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateInfo(CostSubject costSubject) {
|
||||
UserInfo user = SecurityUtils.getUser();
|
||||
costSubject.setUpdateBy(user.getUserId().toString());
|
||||
costSubject.setUpdateTime(new Date());
|
||||
return this.updateById(costSubject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delInfo(CostSubject costSubject) {
|
||||
this.remove(Wrappers.<CostSubject>lambdaQuery().apply("find_in_set({0}, ancestors)", costSubject.getId()));
|
||||
return this.removeById(costSubject);
|
||||
}
|
||||
|
||||
private void getChildren(List<CostSubject> list, List<CostSubject> allList) {
|
||||
for (CostSubject costSubject : list) {
|
||||
List<CostSubject> childrenList = allList.stream().filter(a -> a.getParentId().toString().equals(costSubject.getId().toString())).collect(Collectors.toList());
|
||||
getChildren(childrenList, allList);
|
||||
costSubject.setChildren(childrenList);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.zhgd.xmgl.modules.cost.vo;
|
||||
|
||||
import com.zhgd.xmgl.modules.cost.entity.CostSubject;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "成本科目信息(VO)", description = "CostSubjectVo")
|
||||
public class CostSubjectVo extends CostSubject {
|
||||
|
||||
@ApiModelProperty(value = "项目SN")
|
||||
private String projectSn;
|
||||
}
|
||||
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.modules.project.entity.ProgressPanoramaNodePlan;
|
||||
import com.zhgd.xmgl.modules.project.entity.dto.ProgressPanoramaNodePlanDto;
|
||||
import com.zhgd.xmgl.modules.project.service.IProgressPanoramaNodePlanService;
|
||||
import com.zhgd.xmgl.util.MessageUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -37,6 +38,23 @@ public class ProgressPanoramaNodePlanController {
|
||||
@Autowired
|
||||
private IProgressPanoramaNodePlanService progressPanoramaNodePlanService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "分页列表查询进度-全景节点计划信息", notes = "分页列表查询进度-全景节点计划信息", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"),
|
||||
@ApiImplicitParam(name = "nodeName", value = "节点名称", paramType = "body", required = false, dataType = "String"),
|
||||
@ApiImplicitParam(name = "bidSectionId", value = "标段ID", paramType = "body", required = false, dataType = "String"),
|
||||
@ApiImplicitParam(name = "pageNo", value = "第几页", paramType = "body", required = true, dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页显示条数", paramType = "body", required = true, dataType = "Integer"),
|
||||
})
|
||||
@PostMapping(value = "/tree")
|
||||
public Result<IPage<ProgressPanoramaNodePlanDto>> queryTreeList(@RequestBody Map<String,Object> map) {
|
||||
return Result.success(progressPanoramaNodePlanService.selectProgressPanoramaNodePlanPageList(map));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
* @return
|
||||
@ -50,7 +68,7 @@ public class ProgressPanoramaNodePlanController {
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页显示条数", paramType = "body", required = true, dataType = "Integer"),
|
||||
})
|
||||
@PostMapping(value = "/list")
|
||||
public Result<IPage<EntityMap>> queryPageList(@RequestBody Map<String,Object> map) {
|
||||
public Result<IPage<ProgressPanoramaNodePlanDto>> queryPageList(@RequestBody Map<String,Object> map) {
|
||||
return Result.success(progressPanoramaNodePlanService.selectProgressPanoramaNodePlanPageList(map));
|
||||
}
|
||||
|
||||
@ -88,6 +106,12 @@ public class ProgressPanoramaNodePlanController {
|
||||
if(progressPanoramaNodePlanEntity==null) {
|
||||
result.error500(MessageUtil.get("notFindErr"));
|
||||
}else {
|
||||
ProgressPanoramaNodePlan parent = progressPanoramaNodePlanService.getById(progressPanoramaNodePlan.getParentId());
|
||||
if (parent != null) {
|
||||
progressPanoramaNodePlan.setAncestors(parent.getAncestors() + "," + parent.getId().toString());
|
||||
} else {
|
||||
progressPanoramaNodePlan.setAncestors("0");
|
||||
}
|
||||
boolean ok = progressPanoramaNodePlanService.updateById(progressPanoramaNodePlan);
|
||||
|
||||
if(ok) {
|
||||
|
||||
@ -155,5 +155,14 @@ public class ProgressPanoramaNodePlan implements Serializable {
|
||||
@Excel(name = "城润标段名称", width = 15)
|
||||
@ApiModelProperty(value = "城润标段名称")
|
||||
private String crSectionName;
|
||||
|
||||
/**
|
||||
* 父级ID
|
||||
*/
|
||||
@ApiModelProperty(value = "父级ID")
|
||||
private Long parentId;
|
||||
/**
|
||||
* 祖级关系
|
||||
*/
|
||||
@ApiModelProperty(value = "祖级关系")
|
||||
private String ancestors;
|
||||
}
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
package com.zhgd.xmgl.modules.project.entity.dto;
|
||||
|
||||
import com.zhgd.xmgl.modules.project.entity.ProgressPanoramaNodePlan;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "全景计划信息(DTO)", description = "ProgressPanoramaNodePlanDto")
|
||||
public class ProgressPanoramaNodePlanDto extends ProgressPanoramaNodePlan {
|
||||
|
||||
@ApiModelProperty(value = "项目分期ID")
|
||||
private String projectfId;
|
||||
|
||||
@ApiModelProperty(value = "项目分期名称")
|
||||
private String projectfName;
|
||||
|
||||
@ApiModelProperty(value = "子项信息")
|
||||
private List<ProgressPanoramaNodePlanDto> children;
|
||||
}
|
||||
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.modules.project.entity.ProgressPanoramaNodePlan;
|
||||
import com.zhgd.xmgl.modules.project.entity.dto.ProgressPanoramaNodePlanDto;
|
||||
import com.zhgd.xmgl.modules.project.entity.vo.KeyNodeEarlyWarningStatisticsVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@ -21,7 +22,7 @@ import java.util.Map;
|
||||
@Mapper
|
||||
public interface ProgressPanoramaNodePlanMapper extends BaseMapper<ProgressPanoramaNodePlan> {
|
||||
|
||||
List<EntityMap> selectProgressPanoramaNodePlanPageList(Page<EntityMap> page, @Param("param") Map<String, Object> map);
|
||||
List<ProgressPanoramaNodePlanDto> selectProgressPanoramaNodePlanPageList(Page page, @Param("param") Map<String, Object> map);
|
||||
|
||||
List<EntityMap> selectPanoramaNodePlanList(Map<String, Object> map);
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?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.zhgd.xmgl.modules.project.mapper.ProgressPanoramaNodePlanMapper">
|
||||
<select id="selectProgressPanoramaNodePlanPageList" resultType="com.zhgd.jeecg.common.mybatis.EntityMap">
|
||||
<select id="selectProgressPanoramaNodePlanPageList" resultType="com.zhgd.xmgl.modules.project.entity.dto.ProgressPanoramaNodePlanDto">
|
||||
SELECT a.*, b.projectf_id, b.projectf_name
|
||||
from progress_panorama_node_plan a
|
||||
LEFT JOIN progress_plan_bid_section b ON a.bid_section_id = b.id
|
||||
|
||||
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.modules.project.entity.ProgressPanoramaNodePlan;
|
||||
import com.zhgd.xmgl.modules.project.entity.dto.ProgressPanoramaNodePlanDto;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -18,7 +19,7 @@ import java.util.Map;
|
||||
*/
|
||||
public interface IProgressPanoramaNodePlanService extends IService<ProgressPanoramaNodePlan> {
|
||||
|
||||
IPage<EntityMap> selectProgressPanoramaNodePlanPageList(Map<String, Object> map);
|
||||
IPage<ProgressPanoramaNodePlanDto> selectProgressPanoramaNodePlanPageList(Map<String, Object> map);
|
||||
|
||||
void saveProgressPanoramaNodePlan(ProgressPanoramaNodePlan progressPanoramaNodePlan);
|
||||
|
||||
|
||||
@ -8,13 +8,17 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.modules.cost.entity.CostSubject;
|
||||
import com.zhgd.xmgl.modules.project.entity.ProgressPanoramaNodePlan;
|
||||
import com.zhgd.xmgl.modules.project.entity.ProgressPlanBidSection;
|
||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||
import com.zhgd.xmgl.modules.project.entity.dto.ProgressPanoramaNodePlanDto;
|
||||
import com.zhgd.xmgl.modules.project.mapper.ProgressPanoramaNodePlanMapper;
|
||||
import com.zhgd.xmgl.modules.project.mapper.ProgressPlanBidSectionMapper;
|
||||
import com.zhgd.xmgl.modules.project.mapper.ProjectMapper;
|
||||
import com.zhgd.xmgl.modules.project.service.IProgressPanoramaNodePlanService;
|
||||
import com.zhgd.xmgl.security.entity.UserInfo;
|
||||
import com.zhgd.xmgl.security.util.SecurityUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -42,11 +46,11 @@ public class ProgressPanoramaNodePlanServiceImpl extends ServiceImpl<ProgressPan
|
||||
private ProjectMapper projectMapper;
|
||||
|
||||
@Override
|
||||
public IPage<EntityMap> selectProgressPanoramaNodePlanPageList(Map<String, Object> map) {
|
||||
public IPage<ProgressPanoramaNodePlanDto> selectProgressPanoramaNodePlanPageList(Map<String, Object> map) {
|
||||
int pageNo = Integer.parseInt(map.getOrDefault("pageNo", 1).toString());
|
||||
int pageSize = Integer.parseInt(map.getOrDefault("pageSize", 10).toString());
|
||||
Page<EntityMap> page = new Page<>(pageNo, pageSize);
|
||||
List<EntityMap> list = progressPanoramaNodePlanMapper.selectProgressPanoramaNodePlanPageList(page, map);
|
||||
Page page = new Page<>(pageNo, pageSize);
|
||||
List<ProgressPanoramaNodePlanDto> list = progressPanoramaNodePlanMapper.selectProgressPanoramaNodePlanPageList(page, map);
|
||||
return page.setRecords(list);
|
||||
}
|
||||
|
||||
@ -59,6 +63,12 @@ public class ProgressPanoramaNodePlanServiceImpl extends ServiceImpl<ProgressPan
|
||||
// if(count>0){
|
||||
// throw new OpenAlertException(MessageUtil.get("uniqueExistErr"));
|
||||
// }
|
||||
ProgressPanoramaNodePlan parent = this.getById(progressPanoramaNodePlan.getParentId());
|
||||
if (parent != null) {
|
||||
progressPanoramaNodePlan.setAncestors(parent.getAncestors() + "," + parent.getId().toString());
|
||||
} else {
|
||||
progressPanoramaNodePlan.setAncestors("0");
|
||||
}
|
||||
progressPanoramaNodePlanMapper.insert(progressPanoramaNodePlan);
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user