主要工程量完成情况详情表管理bug修复
This commit is contained in:
parent
62fe906fc9
commit
b44db0b369
@ -1,27 +1,17 @@
|
||||
package com.zhgd.xmgl.modules.baotou.controller;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gexin.fastjson.JSON;
|
||||
import com.zhgd.annotation.OperLog;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.xmgl.modules.baotou.entity.PipelineWeldingRecord;
|
||||
import com.zhgd.xmgl.modules.baotou.entity.vo.MainProjectCompleteDetailVo;
|
||||
import com.zhgd.xmgl.modules.baotou.service.IMainProjectCompleteDetailService;
|
||||
import com.zhgd.xmgl.util.ExcelUtils;
|
||||
import com.zhgd.xmgl.util.Fileutils;
|
||||
import com.zhgd.xmgl.util.MapUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.simpleframework.xml.core.Validate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -29,9 +19,6 @@ import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -83,28 +70,38 @@ public class MainProjectCompleteDetailController {
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param mainProjectCompleteDetail1
|
||||
* @param mainProjectCompleteDetail
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "主要工程量完成情况详情表管理", operType = "添加", operDesc = "添加主要工程量完成情况详情表信息")
|
||||
@ApiOperation(value = "添加主要工程量完成情况详情表信息", notes = "添加主要工程量完成情况详情表信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/add")
|
||||
public Result add(@RequestBody @Validate MainProjectCompleteDetailVo mainProjectCompleteDetail1) {
|
||||
mainProjectCompleteDetail1Service.add(mainProjectCompleteDetail1);
|
||||
public Result add(@RequestBody @Validate MainProjectCompleteDetailVo mainProjectCompleteDetail) {
|
||||
mainProjectCompleteDetail1Service.add(mainProjectCompleteDetail);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@OperLog(operModul = "主要工程量完成情况详情表管理", operType = "添加", operDesc = "工作流添加主要工程量完成情况详情表信息")
|
||||
@ApiOperation(value = "工作流添加主要工程量完成情况详情表信息", notes = "工作流添加主要工程量完成情况详情表信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/flow/add")
|
||||
public Result add(@RequestBody @Validate Map<String, Object> map) {
|
||||
log.info("工作流添加主要工程量完成情况详情表信息:{}", JSON.toJSONString(map));
|
||||
MainProjectCompleteDetailVo vo = new MainProjectCompleteDetailVo();
|
||||
mainProjectCompleteDetail1Service.edit(vo);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param mainProjectCompleteDetail1
|
||||
* @param mainProjectCompleteDetail
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "主要工程量完成情况详情表管理", operType = "编辑", operDesc = "编辑主要工程量完成情况详情表信息")
|
||||
@ApiOperation(value = "编辑主要工程量完成情况详情表信息", notes = "编辑主要工程量完成情况详情表信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/edit")
|
||||
public Result edit(@RequestBody MainProjectCompleteDetailVo mainProjectCompleteDetail1) {
|
||||
mainProjectCompleteDetail1Service.edit(mainProjectCompleteDetail1);
|
||||
public Result edit(@RequestBody MainProjectCompleteDetailVo mainProjectCompleteDetail) {
|
||||
mainProjectCompleteDetail1Service.edit(mainProjectCompleteDetail);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ -151,6 +148,7 @@ public class MainProjectCompleteDetailController {
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "deviceUnitIds", value = "装置ids(多个,分割)", paramType = "body", required = true, dataType = "String"),
|
||||
@ApiImplicitParam(name = "mainProjectCompletePeriodId", value = "主要工程量完成情况时间段id", paramType = "body", required = true, dataType = "String"),
|
||||
@ApiImplicitParam(name = "levelType", value = "时间级别:1月2周", paramType = "body", required = true, dataType = "String"),
|
||||
})
|
||||
@PostMapping(value = "/exportXls")
|
||||
public void exportXls(HttpServletRequest request, HttpServletResponse response, @RequestBody HashMap<String, Object> param) {
|
||||
|
||||
@ -1,17 +1,15 @@
|
||||
package com.zhgd.xmgl.modules.baotou.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
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;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
/**
|
||||
* @Description: 主要工程量完成情况详情表
|
||||
* @author: pds
|
||||
@ -65,9 +63,6 @@ public class MainProjectCompleteDetail implements Serializable {
|
||||
/**上报人*/
|
||||
@ApiModelProperty(value="上报人")
|
||||
private java.lang.Integer reportingPerson ;
|
||||
/**主要工程量完成情况总量id*/
|
||||
@ApiModelProperty(value="主要工程量完成情况总量id")
|
||||
private java.lang.Long mainProjectCompleteTotalId ;
|
||||
/**时间级别:1月2周*/
|
||||
@ApiModelProperty(value="时间级别:1月2周")
|
||||
private java.lang.Integer levelType ;
|
||||
|
||||
@ -7,7 +7,6 @@ import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class MainProjectCompleteDetailVo extends MainProjectCompleteDetail {
|
||||
@ -77,4 +76,11 @@ public class MainProjectCompleteDetailVo extends MainProjectCompleteDetail {
|
||||
private java.math.BigDecimal totalDesignQuantity;
|
||||
|
||||
private List<LinkedHashMap<String ,Object>> overviewList;
|
||||
|
||||
/**主要工程量完成情况总量id*/
|
||||
@ApiModelProperty(value="主要工程量完成情况总量id")
|
||||
private java.lang.Long mainProjectCompleteTotalId ;
|
||||
|
||||
@ApiModelProperty(value="装置单位名称")
|
||||
private java.lang.String deviceUnitName ;
|
||||
}
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
t.affiliated_unit,
|
||||
t.reporting_person,
|
||||
t.completed_quantity_this_week,
|
||||
t.main_project_complete_total_id,
|
||||
n.project_sn,
|
||||
n.project_quantity_name,
|
||||
n.level,
|
||||
@ -25,12 +24,10 @@
|
||||
mpcp.level_type,
|
||||
mpcp.year,
|
||||
mpcp.month,
|
||||
mpcp.which_week,
|
||||
mpct.total_design_quantity
|
||||
mpcp.which_week
|
||||
from main_project_complete_detail t
|
||||
left join main_project_complete_name n on n.id = t.main_project_complete_name_id
|
||||
left join main_project_complete_period mpcp on t.main_project_complete_period_id = mpcp.id
|
||||
left join main_project_complete_total mpct on mpct.id = t.main_project_complete_total_id
|
||||
where 1=1 and mpcp.level_type = #{param.levelType}
|
||||
<if test="param.deviceUnitId != null and param.deviceUnitId != ''">
|
||||
and t.device_unit_id = #{param.deviceUnitId}
|
||||
@ -44,6 +41,7 @@
|
||||
)t
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
<select id="queryById" resultType="com.zhgd.xmgl.modules.baotou.entity.vo.MainProjectCompleteDetailVo">
|
||||
select * from (
|
||||
select t.*
|
||||
@ -66,7 +64,6 @@
|
||||
t.affiliated_unit,
|
||||
t.reporting_person,
|
||||
ifnull(t.completed_quantity_this_week,0) as completed_quantity_this_week,
|
||||
t.main_project_complete_total_id,
|
||||
n.project_sn,
|
||||
n.project_quantity_name,
|
||||
n.level,
|
||||
@ -76,12 +73,15 @@
|
||||
mpcp.year,
|
||||
mpcp.month,
|
||||
mpcp.which_week,
|
||||
mpct.total_design_quantity
|
||||
du.device_unit_name
|
||||
from main_project_complete_detail t
|
||||
left join main_project_complete_name n on n.id = t.main_project_complete_name_id
|
||||
left join main_project_complete_period mpcp on t.main_project_complete_period_id = mpcp.id
|
||||
left join main_project_complete_total mpct on mpct.id = t.main_project_complete_total_id
|
||||
where 1=1 and mpcp.level_type = #{param.levelType}
|
||||
left join device_unit du on mpcp.device_unit_id = du.id
|
||||
where 1=1
|
||||
<if test="param.deviceUnitIds != null and param.deviceUnitIds != ''">
|
||||
and find_in_set(du.id,#{param.deviceUnitIds})
|
||||
</if>
|
||||
<if test="param.deviceUnitId != null and param.deviceUnitId != ''">
|
||||
and t.device_unit_id = #{param.deviceUnitId}
|
||||
</if>
|
||||
@ -91,6 +91,9 @@
|
||||
<if test="param.levelType != null and param.levelType != ''">
|
||||
and t.level_type = #{param.levelType}
|
||||
</if>
|
||||
<if test="param.mainProjectCompletePeriodId != null and param.mainProjectCompletePeriodId != ''">
|
||||
and t.main_project_complete_period_id = #{param.mainProjectCompletePeriodId}
|
||||
</if>
|
||||
)t
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@ -4,7 +4,9 @@ import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
@ -15,16 +17,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.xmgl.modules.baotou.entity.MainProjectCompleteDetail;
|
||||
import com.zhgd.xmgl.modules.baotou.entity.MainProjectCompleteName;
|
||||
import com.zhgd.xmgl.modules.baotou.entity.MainProjectCompletePeriod;
|
||||
import com.zhgd.xmgl.modules.baotou.entity.MainProjectCompleteTotal;
|
||||
import com.zhgd.xmgl.modules.baotou.entity.*;
|
||||
import com.zhgd.xmgl.modules.baotou.entity.vo.MainProjectCompleteDetailVo;
|
||||
import com.zhgd.xmgl.modules.baotou.mapper.MainProjectCompleteDetailMapper;
|
||||
import com.zhgd.xmgl.modules.baotou.service.IMainProjectCompleteDetailService;
|
||||
import com.zhgd.xmgl.modules.baotou.service.IMainProjectCompleteNameService;
|
||||
import com.zhgd.xmgl.modules.baotou.service.IMainProjectCompletePeriodService;
|
||||
import com.zhgd.xmgl.modules.baotou.service.IMainProjectCompleteTotalService;
|
||||
import com.zhgd.xmgl.modules.baotou.service.*;
|
||||
import com.zhgd.xmgl.util.*;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
@ -41,6 +37,8 @@ import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.afterturn.easypoi.excel.ExcelExportUtil.SHEET_NAME;
|
||||
|
||||
/**
|
||||
* @Description: 主要工程量完成情况详情表
|
||||
* @author: pds
|
||||
@ -57,6 +55,8 @@ public class MainProjectCompleteDetailServiceImpl extends ServiceImpl<MainProjec
|
||||
private MainProjectCompleteDetailMapper mainProjectCompleteDetailMapper;
|
||||
@Autowired
|
||||
private IMainProjectCompletePeriodService mainProjectCompletePeriodService;
|
||||
@Autowired
|
||||
private IDeviceUnitService deviceUnitService;
|
||||
|
||||
@Override
|
||||
public IPage<MainProjectCompleteDetailVo> queryPageList(HashMap<String, Object> param) {
|
||||
@ -114,7 +114,6 @@ public class MainProjectCompleteDetailServiceImpl extends ServiceImpl<MainProjec
|
||||
MainProjectCompleteTotal total = new MainProjectCompleteTotal();
|
||||
BeanUtil.copyProperties(vo, total);
|
||||
mainProjectCompleteTotalService.add(total);
|
||||
vo.setMainProjectCompleteTotalId(total.getId());
|
||||
|
||||
if (vo.getDeviceUnitId() != null && vo.getMainProjectCompletePeriodId() != null) {
|
||||
baseMapper.insert(vo);
|
||||
@ -138,7 +137,6 @@ public class MainProjectCompleteDetailServiceImpl extends ServiceImpl<MainProjec
|
||||
|
||||
MainProjectCompleteTotal total = new MainProjectCompleteTotal();
|
||||
BeanUtil.copyProperties(vo, total);
|
||||
total.setId(old.getMainProjectCompleteTotalId());
|
||||
mainProjectCompleteTotalService.saveObj(total);
|
||||
} else {
|
||||
add(vo);
|
||||
@ -176,10 +174,17 @@ public class MainProjectCompleteDetailServiceImpl extends ServiceImpl<MainProjec
|
||||
.eq(MainProjectCompleteName::getProjectSn, projectSn)
|
||||
.eq(StrUtil.isNotBlank(projectQuantityName), MainProjectCompleteName::getProjectQuantityName, projectQuantityName)
|
||||
);
|
||||
MainProjectCompletePeriod period = mainProjectCompletePeriodService.queryById(mainProjectCompletePeriodId);
|
||||
Integer year = period.getYear();
|
||||
Integer month = period.getMonth();
|
||||
Integer whichWeek = period.getWhichWeek();
|
||||
MainProjectCompletePeriod period = mainProjectCompletePeriodService.getById(mainProjectCompletePeriodId);
|
||||
List<MainProjectCompleteTotal> totalList = mainProjectCompleteTotalService.list(new LambdaQueryWrapper<MainProjectCompleteTotal>()
|
||||
.eq(MainProjectCompleteTotal::getDeviceUnitId, deviceUnitId));
|
||||
Integer year = -1;
|
||||
Integer month = -1;
|
||||
if (period != null) {
|
||||
year = period.getYear();
|
||||
month = period.getMonth();
|
||||
}
|
||||
Integer finalYear = year;
|
||||
Integer finalMonth = month;
|
||||
List<MainProjectCompleteDetailVo> list = new ArrayList<>();
|
||||
for (MainProjectCompleteName name : nameList) {
|
||||
MainProjectCompleteDetailVo vo = new MainProjectCompleteDetailVo();
|
||||
@ -188,27 +193,27 @@ public class MainProjectCompleteDetailServiceImpl extends ServiceImpl<MainProjec
|
||||
Optional<MainProjectCompleteDetailVo> op = alls.stream().filter(o -> Objects.equals(o.getMainProjectCompleteNameId(), vo.getMainProjectCompleteNameId()) && Objects.equals(o.getMainProjectCompletePeriodId(), period.getId())).findFirst();
|
||||
if (op.isPresent()) {
|
||||
BeanUtil.copyProperties(op.get(), vo);
|
||||
}else{
|
||||
} else {
|
||||
vo.setId(null);
|
||||
}
|
||||
Optional<MainProjectCompleteDetailVo> op1 = alls.stream().filter(o -> Objects.equals(o.getMainProjectCompleteNameId(), vo.getMainProjectCompleteNameId())).findFirst();
|
||||
Optional<MainProjectCompleteTotal> op1 = totalList.stream().filter(o -> Objects.equals(o.getMainProjectCompleteNameId(), vo.getMainProjectCompleteNameId())).findFirst();
|
||||
if (op1.isPresent()) {
|
||||
vo.setTotalDesignQuantity(op1.get().getTotalDesignQuantity());
|
||||
}
|
||||
if (Objects.equals(levelType, 2)) {
|
||||
vo.setCumulativeCompletedQuantityThisMonth(alls.stream().filter(o -> Objects.equals(o.getYear(), year) && Objects.equals(o.getMonth(), month)).map(MainProjectCompleteDetail::getCompletedQuantityThisWeek).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
vo.setCumulativeCompletedQuantityThisMonth(alls.stream().filter(o -> Objects.equals(o.getYear(), finalYear) && Objects.equals(o.getMonth(), finalMonth)).map(MainProjectCompleteDetail::getCompletedQuantityThisWeek).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
}
|
||||
if (Objects.equals(levelType, 2)) {
|
||||
vo.setCumulativeCompletedQuantityThisYear(alls.stream().filter(o -> Objects.equals(o.getYear(), year)).map(MainProjectCompleteDetail::getCompletedQuantityThisWeek).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
vo.setCumulativeCompletedQuantityThisYear(alls.stream().filter(o -> Objects.equals(o.getYear(), finalYear)).map(MainProjectCompleteDetail::getCompletedQuantityThisWeek).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
} else {
|
||||
vo.setCumulativeCompletedQuantityThisYear(alls.stream().filter(o -> Objects.equals(o.getYear(), year)).map(MainProjectCompleteDetail::getCompletedQuantityThisMonth).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
vo.setCumulativeCompletedQuantityThisYear(alls.stream().filter(o -> Objects.equals(o.getYear(), finalYear)).map(MainProjectCompleteDetail::getCompletedQuantityThisMonth).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
}
|
||||
if (Objects.equals(levelType, 2)) {
|
||||
vo.setCumulativeCompletedQuantity(alls.stream().filter(o -> NumberUtils.gt(o.getYear() + "", year + "") && (Objects.equals(o.getYear(), year) && NumberUtils.gt(o.getMonth() + "", month + ""))).map(MainProjectCompleteDetail::getCompletedQuantityThisWeek).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
vo.setCumulativeCompletedQuantity(alls.stream().filter(o -> NumberUtils.gt(o.getYear() + "", finalYear + "") && (Objects.equals(o.getYear(), finalYear) && NumberUtils.gt(o.getMonth() + "", finalMonth + ""))).map(MainProjectCompleteDetail::getCompletedQuantityThisWeek).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
} else {
|
||||
vo.setCumulativeCompletedQuantity(alls.stream().filter(o -> Objects.equals(o.getYear(), year)).map(MainProjectCompleteDetail::getCompletedQuantityThisMonth).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
vo.setCumulativeCompletedQuantity(alls.stream().filter(o -> Objects.equals(o.getYear(), finalYear)).map(MainProjectCompleteDetail::getCompletedQuantityThisMonth).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
}
|
||||
vo.setCumulativeArrival(alls.stream().filter(o -> Objects.equals(o.getYear(), year) && Objects.equals(o.getMonth(), month)).map(MainProjectCompleteDetail::getDeliveryThisPeriod).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
vo.setCumulativeArrival(alls.stream().filter(o -> Objects.equals(o.getYear(), finalYear) && Objects.equals(o.getMonth(), finalMonth)).map(MainProjectCompleteDetail::getDeliveryThisPeriod).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
list.add(vo);
|
||||
}
|
||||
int pageNo = Integer.parseInt(param.getOrDefault("pageNo", 1).toString());
|
||||
@ -230,30 +235,80 @@ public class MainProjectCompleteDetailServiceImpl extends ServiceImpl<MainProjec
|
||||
public void exportXls(HttpServletRequest request, HttpServletResponse response, HashMap<String, Object> param) {
|
||||
String deviceUnitIds = MapUtils.getString(param, "deviceUnitIds");
|
||||
String mainProjectCompletePeriodId = MapUtils.getString(param, "mainProjectCompletePeriodId");
|
||||
if (StrUtil.isBlank(deviceUnitIds) || StrUtil.isBlank(mainProjectCompletePeriodId)) {
|
||||
throw new OpenAlertException("deviceUnitIds和mainProjectCompletePeriodId不能为空");
|
||||
Integer levelType = MapUtils.getInteger(param, "levelType");
|
||||
if (StrUtil.isBlank(deviceUnitIds) || StrUtil.isBlank(mainProjectCompletePeriodId) || levelType == null) {
|
||||
throw new OpenAlertException("deviceUnitIds和mainProjectCompletePeriodId和levelType不能为空");
|
||||
}
|
||||
MainProjectCompletePeriod p1 = mainProjectCompletePeriodService.getById(mainProjectCompletePeriodId);
|
||||
MainProjectCompletePeriod completePeriod = mainProjectCompletePeriodService.getById(mainProjectCompletePeriodId);
|
||||
List<MainProjectCompletePeriod> periodList = mainProjectCompletePeriodService.list(new LambdaQueryWrapper<MainProjectCompletePeriod>()
|
||||
.apply("find_in_set(id,{0})", deviceUnitIds).eq(MainProjectCompletePeriod::getYear, p1.getYear()).eq(MainProjectCompletePeriod::getMonth, p1.getMonth()).eq(MainProjectCompletePeriod::getWhichWeek, p1.getWhichWeek()));
|
||||
List<MainProjectCompleteDetail> detailList = mainProjectCompleteDetailMapper.selectList(new LambdaQueryWrapper<MainProjectCompleteDetail>()
|
||||
.in(MainProjectCompleteDetail::getMainProjectCompletePeriodId, periodList.stream().map(MainProjectCompletePeriod::getId).collect(Collectors.toList())));
|
||||
.eq(MainProjectCompletePeriod::getLevelType, levelType)
|
||||
.eq(MainProjectCompletePeriod::getYear, completePeriod.getYear())
|
||||
.eq(MainProjectCompletePeriod::getMonth, completePeriod.getMonth())
|
||||
.eq(levelType == 2, MainProjectCompletePeriod::getWhichWeek, completePeriod.getWhichWeek())
|
||||
.in(MainProjectCompletePeriod::getDeviceUnitId, StrUtil.split(deviceUnitIds, ","))
|
||||
);
|
||||
List<MainProjectCompleteDetailVo> detailVos = baseMapper.queryAllList(param);
|
||||
param.put("mainProjectCompletePeriodId", null);
|
||||
List<MainProjectCompleteDetailVo> allDetailVos = baseMapper.queryAllList(param);
|
||||
List<MainProjectCompleteName> nameList = mainProjectCompleteNameService.list(new LambdaQueryWrapper<MainProjectCompleteName>()
|
||||
.eq(MainProjectCompleteName::getProjectSn, periodList.get(0).getProjectSn()));
|
||||
List<MainProjectCompleteName> treeNames = BeanUtil.copyToList(ListUtils.listToTree(JSONArray.parseArray(JSON.toJSONString(nameList)), "id", "parentId", "children"), MainProjectCompleteName.class);
|
||||
List<MainProjectCompleteTotal> totalList = mainProjectCompleteTotalService.list(new LambdaQueryWrapper<MainProjectCompleteTotal>()
|
||||
.in(MainProjectCompleteTotal::getDeviceUnitId, StrUtil.split(deviceUnitIds, ",")));
|
||||
List<DeviceUnit> unitList = deviceUnitService.list(new LambdaQueryWrapper<DeviceUnit>()
|
||||
.in(DeviceUnit::getId, StrUtil.split(deviceUnitIds, ",")));
|
||||
Map<Integer, List<Map<String, Object>>> realMap = new HashMap<>();
|
||||
List<Map<String, Object>> sheetList = new ArrayList<>();
|
||||
realMap.put(0, sheetList);
|
||||
try {
|
||||
for (MainProjectCompletePeriod period : periodList) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
|
||||
List<Map<String, Object>> listMap = new ArrayList<>();
|
||||
Integer i = 0;
|
||||
listTree(treeNames, listMap, i);
|
||||
this.setMapByListTree(treeNames, listMap, detailVos, allDetailVos, totalList, period, i, levelType);
|
||||
map.put("listMap", listMap);
|
||||
map.put(SHEET_NAME, unitList.stream().filter(o -> Objects.equals(o.getId(), period.getDeviceUnitId())).findFirst().get().getDeviceUnitName());
|
||||
sheetList.add(map);
|
||||
}
|
||||
|
||||
File out = FileUtil.file("C:\\Users\\Administrator\\Desktop\\mm.xlsx");
|
||||
//汇总
|
||||
int i = 0;
|
||||
HashMap<String, Object> totalMap = new HashMap<>();
|
||||
List<Map<String, Object>> totalListMap = new ArrayList<>();
|
||||
totalMap.put("listMap", totalListMap);
|
||||
totalMap.put(SHEET_NAME, "汇总表");
|
||||
for (MainProjectCompleteName name : nameList) {
|
||||
BigDecimal totalDesignQuantity = new BigDecimal("0");
|
||||
BigDecimal completedQuantityThisMonth = new BigDecimal("0");
|
||||
BigDecimal cumulativeCompletedQuantityThisYear = new BigDecimal("0");
|
||||
BigDecimal cumulativeCompletedQuantity = new BigDecimal("0");
|
||||
BigDecimal deliveryThisPeriod = new BigDecimal("0");
|
||||
BigDecimal cumulativeArrival = new BigDecimal("0");
|
||||
Map<String, Object> mp = new HashMap<>();
|
||||
mp.put("projectQuantityName", name.getProjectQuantityName());
|
||||
if (Objects.equals(name.getLevel(), 1)) {
|
||||
mp.put("number", ++i);
|
||||
} else {
|
||||
mp.put("number", null);
|
||||
}
|
||||
for (Map<String, Object> map : sheetList) {
|
||||
List<Map<String, Object>> listMap = (List<Map<String, Object>>) map.get("listMap");
|
||||
Map<String, Object> m = listMap.stream().filter(o -> Objects.equals(o.get("mainProjectCompleteNameId"), name.getId())).findFirst().get();
|
||||
totalDesignQuantity = NumberUtil.add(totalDesignQuantity, Convert.toBigDecimal(m.get("totalDesignQuantity")));
|
||||
completedQuantityThisMonth = NumberUtil.add(completedQuantityThisMonth, Convert.toBigDecimal(m.get("completedQuantityThisMonth")));
|
||||
cumulativeCompletedQuantityThisYear = NumberUtil.add(cumulativeCompletedQuantityThisYear, Convert.toBigDecimal(m.get("cumulativeCompletedQuantityThisYear")));
|
||||
cumulativeCompletedQuantity = NumberUtil.add(cumulativeCompletedQuantity, Convert.toBigDecimal(m.get("cumulativeCompletedQuantity")));
|
||||
deliveryThisPeriod = NumberUtil.add(deliveryThisPeriod, Convert.toBigDecimal(m.get("deliveryThisPeriod")));
|
||||
cumulativeArrival = NumberUtil.add(cumulativeArrival, Convert.toBigDecimal(m.get("cumulativeArrival")));
|
||||
}
|
||||
mp.put("totalDesignQuantity", totalDesignQuantity);
|
||||
mp.put("completedQuantityThisMonth", completedQuantityThisMonth);
|
||||
mp.put("cumulativeCompletedQuantityThisYear", cumulativeCompletedQuantityThisYear);
|
||||
mp.put("cumulativeCompletedQuantity", cumulativeCompletedQuantity);
|
||||
mp.put("deliveryThisPeriod", deliveryThisPeriod);
|
||||
mp.put("cumulativeArrival", cumulativeArrival);
|
||||
}
|
||||
sheetList.add(0, totalMap);
|
||||
File out = FileUtil.file("C:\\Users\\GUO\\Desktop\\mm.xlsx");
|
||||
// File out = Fileutils.getExportExcelTemplateFile("excel/焊接记录导出模版.xlsx");
|
||||
TemplateExportParams params = new TemplateExportParams(out.getAbsolutePath());
|
||||
Workbook workbook = ExcelExportUtil.exportExcelClone(realMap, params);
|
||||
@ -317,55 +372,58 @@ public class MainProjectCompleteDetailServiceImpl extends ServiceImpl<MainProjec
|
||||
}
|
||||
}
|
||||
|
||||
private void listTree(List<MainProjectCompleteName> treeNames, List<Map<String, Object>> listMap, Integer i) {
|
||||
MainProjectCompleteDetailVo vo = new MainProjectCompleteDetailVo();
|
||||
String projectQuantityName = vo.getProjectQuantityName();
|
||||
Integer level = vo.getLevel();
|
||||
Long parentId = vo.getParentId();
|
||||
String ancestors = vo.getAncestors();
|
||||
List<MainProjectCompleteDetailVo> children = vo.getChildren();
|
||||
String deviceName = vo.getDeviceName();
|
||||
String affiliatedUnitName = vo.getAffiliatedUnitName();
|
||||
String reportingPersonName = vo.getReportingPersonName();
|
||||
BigDecimal cumulativeCompletedQuantityThisMonth = vo.getCumulativeCompletedQuantityThisMonth();
|
||||
BigDecimal cumulativeCompletedQuantityThisYear = vo.getCumulativeCompletedQuantityThisYear();
|
||||
BigDecimal cumulativeCompletedQuantity = vo.getCumulativeCompletedQuantity();
|
||||
BigDecimal cumulativeArrival = vo.getCumulativeArrival();
|
||||
Integer levelType = vo.getLevelType();
|
||||
Integer year = vo.getYear();
|
||||
Integer month = vo.getMonth();
|
||||
Integer whichWeek = vo.getWhichWeek();
|
||||
BigDecimal totalDesignQuantity = vo.getTotalDesignQuantity();
|
||||
Long id = vo.getId();
|
||||
Long deviceUnitId = vo.getDeviceUnitId();
|
||||
Long mainProjectCompleteNameId = vo.getMainProjectCompleteNameId();
|
||||
Long mainProjectCompletePeriodId = vo.getMainProjectCompletePeriodId();
|
||||
String projectSn = vo.getProjectSn();
|
||||
Date createDate = vo.getCreateDate();
|
||||
Date updateDate = vo.getUpdateDate();
|
||||
BigDecimal completedQuantityThisWeek = vo.getCompletedQuantityThisWeek();
|
||||
BigDecimal completedQuantityThisMonth = vo.getCompletedQuantityThisMonth();
|
||||
BigDecimal deliveryThisPeriod = vo.getDeliveryThisPeriod();
|
||||
Integer affiliatedUnit = vo.getAffiliatedUnit();
|
||||
Integer reportingPerson = vo.getReportingPerson();
|
||||
Long mainProjectCompleteTotalId = vo.getMainProjectCompleteTotalId();
|
||||
|
||||
private void setMapByListTree(List<MainProjectCompleteName> treeNames, List<Map<String, Object>> listMap, List<MainProjectCompleteDetailVo> detailVos, List<MainProjectCompleteDetailVo> allDetailVos, List<MainProjectCompleteTotal> totalList, MainProjectCompletePeriod period, Integer i, Integer levelType) {
|
||||
for (MainProjectCompleteName name : treeNames) {
|
||||
BigDecimal cumulativeCompletedQuantityThisYear = null;
|
||||
BigDecimal cumulativeCompletedQuantity = null;
|
||||
BigDecimal cumulativeArrival = null;
|
||||
BigDecimal totalDesignQuantity = null;
|
||||
BigDecimal completedQuantityThisMonth = null;
|
||||
BigDecimal deliveryThisPeriod = null;
|
||||
Integer year = period.getYear();
|
||||
Integer month = period.getMonth();
|
||||
Optional<MainProjectCompleteDetailVo> op = detailVos.stream().filter(o -> Objects.equals(o.getMainProjectCompleteNameId(), name.getId()) && Objects.equals(o.getDeviceUnitId(), period.getDeviceUnitId())).findFirst();
|
||||
if (op.isPresent()) {
|
||||
MainProjectCompleteDetailVo vo = op.get();
|
||||
completedQuantityThisMonth = vo.getCompletedQuantityThisMonth();
|
||||
deliveryThisPeriod = vo.getDeliveryThisPeriod();
|
||||
}
|
||||
Optional<MainProjectCompleteTotal> op1 = totalList.stream().filter(o -> Objects.equals(o.getMainProjectCompleteNameId(), name.getId()) && Objects.equals(o.getDeviceUnitId(), period.getDeviceUnitId())).findFirst();
|
||||
if (op1.isPresent()) {
|
||||
totalDesignQuantity = op1.get().getTotalDesignQuantity();
|
||||
}
|
||||
// if (Objects.equals(levelType, 2)) {
|
||||
// vo.setCumulativeCompletedQuantityThisMonth(alls.stream().filter(o -> Objects.equals(o.getYear(), year) && Objects.equals(o.getMonth(), month)).map(MainProjectCompleteDetail::getCompletedQuantityThisWeek).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
// }
|
||||
if (Objects.equals(levelType, 2)) {
|
||||
cumulativeCompletedQuantityThisYear = allDetailVos.stream().filter(o -> Objects.equals(o.getYear(), year)).map(MainProjectCompleteDetail::getCompletedQuantityThisWeek).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
} else {
|
||||
cumulativeCompletedQuantityThisYear = allDetailVos.stream().filter(o -> Objects.equals(o.getYear(), year)).map(MainProjectCompleteDetail::getCompletedQuantityThisMonth).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
}
|
||||
if (Objects.equals(levelType, 2)) {
|
||||
cumulativeCompletedQuantity = allDetailVos.stream().filter(o -> NumberUtil.compare(o.getYear(), year) < 0 && (Objects.equals(o.getYear(), year) && NumberUtil.compare(o.getMonth(), month) < 0)).map(MainProjectCompleteDetail::getCompletedQuantityThisWeek).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
} else {
|
||||
cumulativeCompletedQuantity = allDetailVos.stream().filter(o -> NumberUtil.compare(o.getYear(), year) < 0 && (Objects.equals(o.getYear(), year) && NumberUtil.compare(o.getMonth(), month) < 0)).map(MainProjectCompleteDetail::getCompletedQuantityThisMonth).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
}
|
||||
cumulativeArrival = allDetailVos.stream().filter(o -> Objects.equals(o.getYear(), year) && Objects.equals(o.getMonth(), month)).map(MainProjectCompleteDetail::getDeliveryThisPeriod).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
Map<String, Object> mp = new HashMap<>();
|
||||
if (Objects.equals(name.getLevel(), 1)) {
|
||||
mp.put("number", ++i);
|
||||
} else {
|
||||
mp.put("number", null);
|
||||
}
|
||||
mp.put("projectQuantityName", projectQuantityName);
|
||||
mp.put("projectQuantityName", name.getProjectQuantityName());
|
||||
mp.put("totalDesignQuantity", totalDesignQuantity);
|
||||
mp.put("completedQuantityThisMonth", completedQuantityThisMonth);
|
||||
mp.put("cumulativeCompletedQuantityThisYear", cumulativeCompletedQuantityThisYear);
|
||||
mp.put("cumulativeCompletedQuantity", cumulativeCompletedQuantity);
|
||||
mp.put("deliveryThisPeriod", deliveryThisPeriod);
|
||||
mp.put("cumulativeArrival", cumulativeArrival);
|
||||
mp.put("mainProjectCompleteNameId", name.getId());
|
||||
mp.put("level", name.getLevel());
|
||||
listMap.add(mp);
|
||||
listTree(name.getChildren(), listMap, i);
|
||||
setMapByListTree(name.getChildren(), listMap, detailVos, allDetailVos, totalList, period, i, levelType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.zhgd.xmgl.modules.baotou.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@ -70,7 +71,12 @@ public class MainProjectCompleteTotalServiceImpl extends ServiceImpl<MainProject
|
||||
|
||||
@Override
|
||||
public void saveObj(MainProjectCompleteTotal mainProjectCompleteTotal) {
|
||||
if (mainProjectCompleteTotal.getId() != null) {
|
||||
MainProjectCompleteTotal one = mainProjectCompleteTotalMapper.selectOne(new LambdaQueryWrapper<MainProjectCompleteTotal>()
|
||||
.eq(MainProjectCompleteTotal::getDeviceUnitId, mainProjectCompleteTotal.getDeviceUnitId())
|
||||
.eq(MainProjectCompleteTotal::getMainProjectCompleteNameId, mainProjectCompleteTotal.getMainProjectCompleteNameId())
|
||||
);
|
||||
if (one != null) {
|
||||
mainProjectCompleteTotal.setId(one.getId());
|
||||
edit(mainProjectCompleteTotal);
|
||||
} else {
|
||||
add(mainProjectCompleteTotal);
|
||||
|
||||
@ -80,6 +80,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
http.authorizeRequests()
|
||||
//请求路径允许访问
|
||||
.antMatchers("/xmgl/mainProjectCompleteDetail/flow/add").permitAll()
|
||||
.antMatchers("/xmgl/workerAdmission/checkParam").permitAll()
|
||||
.antMatchers("/xmgl/pipelineMaterialInspection/flow/add").permitAll()
|
||||
.antMatchers("/xmgl/pipelinePressureTestBag/flow/add").permitAll()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user