Commit 64babde0 authored by lcl's avatar lcl

工料汇总相关

parent 58eeba6c
package com.dsk.cscec.controller; package com.dsk.cscec.controller;
import com.dsk.common.annotation.RepeatSubmit;
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.core.domain.R;
import com.dsk.common.excel.ExcelUtils; import com.dsk.cscec.domain.CbQuantitySummaryActual;
import com.dsk.common.exception.ServiceException;
import com.dsk.cscec.domain.CbQuantitySummary;
import com.dsk.cscec.domain.bo.CbProjectBaseBo; import com.dsk.cscec.domain.bo.CbProjectBaseBo;
import com.dsk.cscec.domain.bo.CbQuantitySummaryListBo;
import com.dsk.cscec.domain.vo.CbQuantitySummaryListVo;
import com.dsk.cscec.service.ICbQuantitySummaryService; import com.dsk.cscec.service.ICbQuantitySummaryService;
import com.dsk.system.domain.vo.SysUserImportVo;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import sun.reflect.generics.tree.Tree;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeMap;
import java.util.stream.Collectors;
/** /**
* 成本-工料汇总基本表(CbQuantitySummary)表控制层 * 成本-工料汇总基本表(CbQuantitySummary)表控制层
...@@ -35,10 +31,11 @@ public class CbQuantitySummaryController extends BaseController { ...@@ -35,10 +31,11 @@ public class CbQuantitySummaryController extends BaseController {
/** /**
* 工料汇总科目树 * 工料汇总科目树
*
* @return * @return
*/ */
@GetMapping(value = "/subjectTree") @GetMapping(value = "/subjectTree")
public R<Map<String, Object>> subjectTree(@PathVariable CbProjectBaseBo bo){ public R<Map<String, Object>> subjectTree(CbProjectBaseBo bo) {
return R.ok(baseService.subjectTree(bo)); return R.ok(baseService.subjectTree(bo));
} }
...@@ -46,30 +43,45 @@ public class CbQuantitySummaryController extends BaseController { ...@@ -46,30 +43,45 @@ public class CbQuantitySummaryController extends BaseController {
* 已记录月份集合 * 已记录月份集合
*/ */
@GetMapping(value = "/monthList") @GetMapping(value = "/monthList")
public R<List<String>> monthList(@PathVariable CbProjectBaseBo bo){ public R<List<String>> monthList(CbQuantitySummaryListBo bo) {
return R.ok(baseService.monthList(bo)); return R.ok(baseService.monthList(bo));
} }
/**
* 科目月份列表
*/
@GetMapping(value = "/subjectList")
public R<List<CbQuantitySummaryListVo>> subjectList(CbQuantitySummaryListBo bo) {
return R.ok(baseService.subjectList(bo));
}
/**
* 更新月成本信息
*/
@PutMapping(value = "/updateActual")
@RepeatSubmit
public R<Void> updateActual(@RequestBody List<CbQuantitySummaryActual> list) {
baseService.updateActual(list);
return R.ok();
}
/**
* 数据推送
*/
@PutMapping(value = "/pushData")
@RepeatSubmit
public R<Void> pushData(@RequestBody CbQuantitySummaryActual bo) {
baseService.pushData(bo);
return R.ok();
}
/** /**
* 数据导入 * 数据导入
*/ */
@PostMapping(value = "/importData") @PostMapping(value = "/importData")
public R<Void> importFile(@RequestPart("file") MultipartFile file) throws Exception { public R<Void> importFile(@RequestPart("file") MultipartFile file) throws Exception {
//识别Excel内容 baseService.dataDealWith(new CbProjectBaseBo());
List<CbQuantitySummary> importList = new ExcelUtils<>(CbQuantitySummary.class).importExcelAllSheet(file.getInputStream(), 1); return R.ok();
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));
} }
} }
......
...@@ -32,7 +32,7 @@ public class CbQuantitySummary implements Serializable { ...@@ -32,7 +32,7 @@ public class CbQuantitySummary implements Serializable {
* 序号 * 序号
*/ */
@Excel(name = "序号") @Excel(name = "序号")
private String number; private Integer number;
/** /**
* 成本阶段(0:标前成本 1:标后成本 2:转固成本) * 成本阶段(0:标前成本 1:标后成本 2:转固成本)
*/ */
...@@ -130,6 +130,10 @@ public class CbQuantitySummary implements Serializable { ...@@ -130,6 +130,10 @@ public class CbQuantitySummary implements Serializable {
* 创建时间 * 创建时间
*/ */
private Date createTime; private Date createTime;
/**
* 项目成本文件id
*/
private Long cbProjectFileId;
} }
...@@ -2,6 +2,7 @@ package com.dsk.cscec.domain; ...@@ -2,6 +2,7 @@ package com.dsk.cscec.domain;
import java.util.Date; import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
...@@ -21,8 +22,8 @@ public class CbQuantitySummaryActual implements Serializable { ...@@ -21,8 +22,8 @@ public class CbQuantitySummaryActual implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@TableId(value = "id") @TableId(value = "id", type = IdType.INPUT)
private Long id; private String id;
/** /**
* 成本汇总基本数据id * 成本汇总基本数据id
*/ */
...@@ -32,9 +33,9 @@ public class CbQuantitySummaryActual implements Serializable { ...@@ -32,9 +33,9 @@ public class CbQuantitySummaryActual implements Serializable {
*/ */
private Double quantities; private Double quantities;
/** /**
* 单位 * 本月用料单位
*/ */
private String unit; private String quantitiesUnit;
/** /**
* 换算后本月用料 * 换算后本月用料
*/ */
...@@ -47,6 +48,9 @@ public class CbQuantitySummaryActual implements Serializable { ...@@ -47,6 +48,9 @@ public class CbQuantitySummaryActual implements Serializable {
* 采购单价 * 采购单价
*/ */
private Double purchaseUnitPrice; private Double purchaseUnitPrice;
/**
* 创建时间
*/
private Date createTime; private Date createTime;
/** /**
* 推送时间 * 推送时间
...@@ -57,9 +61,21 @@ public class CbQuantitySummaryActual implements Serializable { ...@@ -57,9 +61,21 @@ public class CbQuantitySummaryActual implements Serializable {
*/ */
private String recordDate; private String recordDate;
/** /**
* 推送数据json * 推送工程量
*/
private Double pushQuantities;
/**
* IPM项目编码
*/
private String ipmProjectCode;
/**
* IPM合同编码
*/
private String ipmContractCode;
/**
* IPM作业编码
*/ */
private String pushDataJson; private String ipmJobCode;
} }
package com.dsk.cscec.domain.bo;
import lombok.Data;
/**
* @Author lcl
* @Data 2024/2/6 13:37
*/
@Data
public class CbQuantitySummaryListBo extends CbProjectBaseBo {
/**
* 成本科目
*/
private String cbSubjectName;
/**
* 记录月份
*/
private String recordDate;
}
package com.dsk.cscec.domain.vo;
import lombok.Data;
import java.util.Date;
/**
* @Author lcl
* @Data 2024/2/6 14:46
*/
@Data
public class CbQuantitySummaryListVo {
private Long id;
/**
* 成本科目名称(合约规划)
*/
private String cbSubjectName;
/**
* 公司编码
*/
private String companyNo;
/**
* 集团编码
*/
private String orgNo;
/**
* 成本名称
*/
private String cbName;
/**
* 工作内容
*/
private String jobContent;
/**
* 计算规则
*/
private String calculationRule;
/**
* 计量单位
*/
private String unit;
/**
* 材料说明
*/
private String materialDescription;
/**
* 指导价格
*/
private String guidePrice;
/**
* 投标选用单价(不含税)
*/
private Double bidUnitPrice;
/**
* 单价差额
*/
private Double unitPriceDifference;
/**
* 数量
*/
private Double quantity;
/**
* 合价(不含税)
*/
private Double combinedPrice;
/**
* 合价(含税)
*/
private Double combinedPriceTax;
/**
* 品牌名称
*/
private String brandName;
/**
* 投标选用来源
*/
private String bidSource;
/**
* 备注
*/
private String remark;
/**
* 工程量(本月用料)
*/
private Double quantities;
/**
* 单位
*/
private String quantitiesUnit;
/**
* 换算后本月用料
*/
private Double conversionQuantities;
/**
* 换算单位
*/
private String conversionUnit;
/**
* 采购单价
*/
private Double purchaseUnitPrice;
/**
* 创建时间
*/
private Date createTime;
/**
* 截至本月总量
*/
private Double totalQuantities;
/**
* 本月已填写成本Id
*/
private String actualId;
/**
* 推送工程量
*/
private Double pushQuantities;
/**
* IPM项目编码
*/
private String ipmProjectCode;
/**
* IPM合同编码
*/
private String ipmContractCode;
/**
* IPM作业编码
*/
private String ipmJobCode;
}
...@@ -3,6 +3,8 @@ package com.dsk.cscec.mapper; ...@@ -3,6 +3,8 @@ 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 com.dsk.cscec.domain.bo.CbProjectBaseBo;
import com.dsk.cscec.domain.bo.CbQuantitySummaryListBo;
import com.dsk.cscec.domain.vo.CbQuantitySummaryListVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -22,5 +24,9 @@ public interface CbQuantitySummaryMapper extends BaseMapper<CbQuantitySummary> { ...@@ -22,5 +24,9 @@ public interface CbQuantitySummaryMapper extends BaseMapper<CbQuantitySummary> {
int selectOtherSubjectCount(CbProjectBaseBo bo); int selectOtherSubjectCount(CbProjectBaseBo bo);
List<String> selectMonthList(CbQuantitySummaryListBo bo);
List<CbQuantitySummaryListVo> selectListBySubject(CbQuantitySummaryListBo bo);
} }
...@@ -2,7 +2,10 @@ package com.dsk.cscec.service; ...@@ -2,7 +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.CbQuantitySummaryActual;
import com.dsk.cscec.domain.bo.CbProjectBaseBo; import com.dsk.cscec.domain.bo.CbProjectBaseBo;
import com.dsk.cscec.domain.bo.CbQuantitySummaryListBo;
import com.dsk.cscec.domain.vo.CbQuantitySummaryListVo;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -17,7 +20,21 @@ public interface ICbQuantitySummaryService extends IService<CbQuantitySummary> { ...@@ -17,7 +20,21 @@ public interface ICbQuantitySummaryService extends IService<CbQuantitySummary> {
Map<String, Object> subjectTree(CbProjectBaseBo bo); Map<String, Object> subjectTree(CbProjectBaseBo bo);
List<String> monthList(CbProjectBaseBo bo); List<String> monthList(CbQuantitySummaryListBo bo);
List<CbQuantitySummaryListVo> subjectList(CbQuantitySummaryListBo bo);
void updateActual(List<CbQuantitySummaryActual> list);
void pushData(CbQuantitySummaryActual bo);
/**
* 数据处理
*/
void dataDealWith(CbProjectBaseBo bo);
} }
package com.dsk.cscec.service.impl; package com.dsk.cscec.service.impl;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsk.common.excel.ExcelUtils;
import com.dsk.common.exception.ServiceException;
import com.dsk.cscec.domain.CbQuantitySummary; import com.dsk.cscec.domain.CbQuantitySummary;
import com.dsk.cscec.domain.CbQuantitySummaryActual;
import com.dsk.cscec.domain.bo.CbProjectBaseBo; import com.dsk.cscec.domain.bo.CbProjectBaseBo;
import com.dsk.cscec.domain.bo.CbQuantitySummaryListBo;
import com.dsk.cscec.domain.vo.CbQuantitySummaryListVo;
import com.dsk.cscec.mapper.CbQuantitySummaryMapper; import com.dsk.cscec.mapper.CbQuantitySummaryMapper;
import com.dsk.cscec.service.ICbQuantitySummaryActualService;
import com.dsk.cscec.service.ICbQuantitySummaryService; import com.dsk.cscec.service.ICbQuantitySummaryService;
import jodd.bean.BeanException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -19,18 +33,23 @@ import java.util.stream.Collectors; ...@@ -19,18 +33,23 @@ import java.util.stream.Collectors;
* @author lcl * @author lcl
* @since 2024-02-05 11:06:56 * @since 2024-02-05 11:06:56
*/ */
@Slf4j
@Service @Service
public class CbQuantitySummaryServiceImpl extends ServiceImpl<CbQuantitySummaryMapper, CbQuantitySummary> implements ICbQuantitySummaryService { public class CbQuantitySummaryServiceImpl extends ServiceImpl<CbQuantitySummaryMapper, CbQuantitySummary> implements ICbQuantitySummaryService {
@Autowired
private ICbQuantitySummaryActualService actualService;
@Override @Override
public Map<String, Object> subjectTree(CbProjectBaseBo bo) { public Map<String, Object> subjectTree(CbProjectBaseBo bo) {
Map<String, Object> resultMap = new HashMap<>(); Map<String, Object> resultMap = new HashMap<>();
List<Map<String, Object>> list = baseMapper.selectSubject(bo); List<Map<String, Object>> list = baseMapper.selectSubject(bo);
if (!ObjectUtils.isEmpty(list)) { if (!ObjectUtils.isEmpty(list)) {
Map<String, Map<String, Map<String, List<Map<String, Object>>>>> map = list.stream().collect( Map<String, Map<String, Map<String, List<Map<String, Object>>>>> map = list.stream()
Collectors.groupingBy(item -> item.get("one").toString(), .collect(
Collectors.groupingBy(item -> item.get("two").toString(), Collectors.groupingBy(item -> item.get("one").toString(),
Collectors.groupingBy(item -> item.get("three").toString())))); Collectors.groupingBy(item -> item.get("two").toString(),
Collectors.groupingBy(item -> item.get("three").toString()))));
resultMap.put("房建类成本科目", map); resultMap.put("房建类成本科目", map);
} }
int otherSubjectCount = baseMapper.selectOtherSubjectCount(bo); int otherSubjectCount = baseMapper.selectOtherSubjectCount(bo);
...@@ -41,8 +60,73 @@ public class CbQuantitySummaryServiceImpl extends ServiceImpl<CbQuantitySummaryM ...@@ -41,8 +60,73 @@ public class CbQuantitySummaryServiceImpl extends ServiceImpl<CbQuantitySummaryM
} }
@Override @Override
public List<String> monthList(CbProjectBaseBo bo) { public List<String> monthList(CbQuantitySummaryListBo bo) {
return null; return baseMapper.selectMonthList(bo);
}
@Override
public List<CbQuantitySummaryListVo> subjectList(CbQuantitySummaryListBo bo) {
return baseMapper.selectListBySubject(bo);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateActual(List<CbQuantitySummaryActual> list) {
if (ObjectUtils.isEmpty(list)) throw new BeanException("数据不能为空");
for (CbQuantitySummaryActual actual : list) {
if (ObjectUtils.isEmpty(actual.getCbQuantitySummaryId())) throw new BeanException("基础数据id不能为空!");
if (ObjectUtils.isEmpty(actual.getQuantities())) throw new BeanException("工程量(本月用料)不能为空!");
if (ObjectUtils.isEmpty(actual.getRecordDate())) throw new BeanException("填写月份不能为空!");
actual.setId(ObjectUtils.isEmpty(actual.getId()) ? SecureUtil.md5(actual.getCbQuantitySummaryId() + actual.getRecordDate()) : actual.getId());
boolean b = actualService.saveOrUpdate(actual);
if (!b) {
log.error("CbQuantitySummaryServiceImpl.updateActual() data insert error! data:" + JSONUtil.toJsonStr(actual));
throw new ServiceException("数据添加错误!");
}
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void pushData(CbQuantitySummaryActual bo) {
//数据记录
if(ObjectUtils.isEmpty(bo.getId())) throw new BeanException("id不能为空!");
if(ObjectUtils.isEmpty(bo.getPushQuantities())) throw new BeanException("推送工程量不能为空!");
if(ObjectUtils.isEmpty(bo.getIpmProjectCode())) throw new BeanException("IPM项目编码不能为空!");
if(ObjectUtils.isEmpty(bo.getIpmContractCode())) throw new BeanException("IPM合同编码不能为空!");
if(ObjectUtils.isEmpty(bo.getIpmJobCode())) throw new BeanException("IPM作业编码不能为空!");
boolean update = actualService.updateById(bo);
if(!update){
log.error("CbQuantitySummaryServiceImpl.pushData() data update error! data:" + JSONUtil.toJsonStr(bo));
throw new ServiceException("数据添加错误!");
}
//TODO 推送数据
}
@Override
public void dataDealWith(CbProjectBaseBo bo) {
//识别Excel内容
List<CbQuantitySummary> importList = new ArrayList<>();
try {
importList = new ExcelUtils<>(CbQuantitySummary.class).importExcelAllSheet(new FileInputStream(""), 1);
} catch (Exception e) {
e.printStackTrace();
}
if (importList.isEmpty()) {
throw new ServiceException("表格中不存在待导入数据!");
}
importList = importList.stream().parallel()
.filter(item -> !ObjectUtils.isEmpty(item.getCbName()))
.peek(item -> {
item.setProjectId(1L);
item.setCbStage(0);
item.setCbProjectFileId(1L);
}).collect(Collectors.toList());
if (importList.isEmpty()) {
throw new ServiceException("表格中不存在有效数据数据!");
}
} }
} }
...@@ -21,4 +21,32 @@ ...@@ -21,4 +21,32 @@
where cqs.project_id = #{projectId} and cqs.cb_stage = #{cbStage} and cs1.id is null where cqs.project_id = #{projectId} and cqs.cb_stage = #{cbStage} and cs1.id is null
</select> </select>
<select id="selectMonthList" resultType="java.lang.String">
select
cqsa.record_date
from cb_quantity_summary cqs
join cb_quantity_summary_actual cqsa on cqs.id = cqsa.cb_quantity_summary_id
where cqs.project_id = #{projectId} and cqs.cb_stage = #{cbStage} and cqs.cb_subject_name = #{cbSubjectName}
group by cqsa.record_date
order by cqsa.record_date
</select>
<select id="selectListBySubject" resultType="com.dsk.cscec.domain.vo.CbQuantitySummaryListVo">
select a.*, ifnull(sum(a.quantities),0) totalQuantities from (
select
cqs.id, cqs.cb_subject_name, cqs.company_no, cqs.org_no, cqs.cb_name, cqs.job_content, cqs.calculation_rule,
cqs.unit, cqs.material_description, cqs.guide_price, cqs.bid_unit_price, cqs.unit_price_difference, cqs.quantity,
cqs.combined_price, cqs.combined_price_tax, cqs.brand_name, cqs.bid_source, cqs.remark, cqs.`number`, cqsa.quantities,
cqsa.quantities_unit, cqsa.conversion_quantities, cqsa.conversion_unit, cqsa.purchase_unit_price, cqsa.create_time,
cqsa.id actualId, cqsa.ipm_project_code, cqsa.ipm_contract_code, cqsa.ipm_job_code, cqsa.push_quantities
from cb_quantity_summary cqs
left join cb_quantity_summary_actual cqsa on cqs.id = cqsa.cb_quantity_summary_id
where cqs.project_id = #{projectId} and cqs.cb_stage = #{cbStage} and cqs.cb_subject_name = #{cbSubjectName}
<if test="recordDate != null and recordDate != ''"> and cqsa.record_date &lt;= #{recordDate} </if>
order by cqsa.record_date desc
) a
group by a.id
order by a.`number` asc
</select>
</mapper> </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