包头bug修复
This commit is contained in:
parent
7abc221575
commit
7b1ed8a26a
@ -1,5 +1,6 @@
|
||||
package com.zhgd.xmgl.modules.baotou.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@ -156,8 +157,15 @@ public class ContractorMonthlyTitleController {
|
||||
@PostMapping(value = "/bindList")
|
||||
public Result<List<Long>> bindList(@ApiIgnore @RequestBody HashMap<String, Object> param) {
|
||||
String userId = MapUtils.getString(param, "userId");
|
||||
contractorMonthlyConfigService.remove(new LambdaQueryWrapper<ContractorMonthlyConfig>()
|
||||
.eq(ContractorMonthlyConfig::getUserId, userId));
|
||||
Integer type = MapUtils.getInteger(param, "type");
|
||||
List<Long> titleIds = contractorMonthlyTitleService.list(new LambdaQueryWrapper<ContractorMonthlyTitle>()
|
||||
.eq(ContractorMonthlyTitle::getType, type)).stream().map(ContractorMonthlyTitle::getId).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(titleIds)) {
|
||||
contractorMonthlyConfigService.remove(new LambdaQueryWrapper<ContractorMonthlyConfig>()
|
||||
.in(ContractorMonthlyConfig::getTitleId, titleIds)
|
||||
.eq(ContractorMonthlyConfig::getUserId, userId)
|
||||
);
|
||||
}
|
||||
JSONArray array = JSONArray.parseArray(JSON.toJSONString(param.get("titleIdList")));
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
String s = array.getString(i);
|
||||
|
||||
@ -30,8 +30,8 @@ public class ContractorMonthlyDetail implements Serializable {
|
||||
/**承包商项自组月报周报计划(word和excel版)id*/
|
||||
@ApiModelProperty(value="承包商项自组月报周报计划(word和excel版)id")
|
||||
private java.lang.Long periodId ;
|
||||
/**1:三月人力滚动计划;2:三月机械滚动计划;3:人力汇总表;4:机械汇总表;5:工程量报表;6:计划工程量报表;7:月报;*/
|
||||
@ApiModelProperty(value="1:三月人力滚动计划;2:三月机械滚动计划;3:人力汇总表;4:机械汇总表;5:工程量报表;6:计划工程量报表;7:月报;")
|
||||
/**1:三月人力滚动计划;2:三月机械滚动计划;3:人力汇总表;4:机械汇总表;5:工程量报表;6:计划工程量报表;7:月报;8:项目计划;*/
|
||||
@ApiModelProperty(value="1:三月人力滚动计划;2:三月机械滚动计划;3:人力汇总表;4:机械汇总表;5:工程量报表;6:计划工程量报表;7:月报;8:项目计划;")
|
||||
private java.lang.Integer contentType ;
|
||||
/**内容*/
|
||||
@ApiModelProperty(value="内容")
|
||||
|
||||
@ -51,9 +51,6 @@ public class ContractorMonthlyQuantity implements Serializable {
|
||||
/**更新时间*/
|
||||
@ApiModelProperty(value="更新时间")
|
||||
private java.util.Date updateTime ;
|
||||
/**1承包商2项目组**/
|
||||
@ApiModelProperty(value="1承包商2项目组")
|
||||
private java.lang.Integer type ;
|
||||
/**1工程量2计划工程量*/
|
||||
@ApiModelProperty(value="1工程量2计划工程量")
|
||||
private java.lang.Integer designType;
|
||||
|
||||
@ -33,9 +33,6 @@ public class ContractorMonthlyTitle implements Serializable {
|
||||
/**word标题名称*/
|
||||
@ApiModelProperty(value="word标题名称")
|
||||
private java.lang.String wordName ;
|
||||
/**所属项目SN*/
|
||||
@ApiModelProperty(value="所属项目SN")
|
||||
private java.lang.String projectSn ;
|
||||
/**父级id*/
|
||||
@ApiModelProperty(value="父级id")
|
||||
private java.lang.Long parentId ;
|
||||
|
||||
@ -51,4 +51,5 @@ public class ProjectHomeManage implements Serializable {
|
||||
/**更新时间*/
|
||||
@ApiModelProperty(value="更新时间")
|
||||
private java.util.Date updateTime ;
|
||||
private java.lang.Integer sort ;
|
||||
}
|
||||
|
||||
@ -57,8 +57,10 @@ public class ProjectHomeWork implements Serializable {
|
||||
/**更新时间*/
|
||||
@ApiModelProperty(value="更新时间")
|
||||
private java.util.Date updateTime ;
|
||||
private java.lang.Integer sort ;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value="操作内容")
|
||||
private List<ProjectHomeWork> opList;
|
||||
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package com.zhgd.xmgl.modules.baotou.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
@ -26,7 +27,10 @@ import com.zhgd.xmgl.modules.worker.entity.EnterpriseInfo;
|
||||
import com.zhgd.xmgl.modules.worker.service.impl.EnterpriseInfoServiceImpl;
|
||||
import com.zhgd.xmgl.security.util.SecurityUtils;
|
||||
import com.zhgd.xmgl.util.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.tuple.ImmutableTriple;
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
@ -46,6 +50,7 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Slf4j
|
||||
public class ContractorMonthlyDetailServiceImpl extends ServiceImpl<ContractorMonthlyDetailMapper, ContractorMonthlyDetail> implements IContractorMonthlyDetailService {
|
||||
@Autowired
|
||||
private IContractorMonthlyDetailService contractorMonthlyDetailService;
|
||||
@ -151,6 +156,27 @@ public class ContractorMonthlyDetailServiceImpl extends ServiceImpl<ContractorMo
|
||||
throw new OpenAlertException("计划不存在");
|
||||
}
|
||||
this.removeMonthWordEdit(detail, p);
|
||||
if (contentType != 7) {
|
||||
//把excel的p改成t,存在v中
|
||||
JSONObject rootJo = JSON.parseObject(detail.getContent());
|
||||
JSONObject cellData = getCellData(rootJo);
|
||||
for (int i = 0; i < cellData.size(); i++) {
|
||||
JSONObject rowJo = cellData.getJSONObject(i + "");
|
||||
if (rowJo != null) {
|
||||
for (int col = 0; col < rowJo.size(); col++) {
|
||||
JSONObject colJo = rowJo.getJSONObject(col + "");
|
||||
if (colJo.containsKey("p")) {
|
||||
String s = Optional.ofNullable(colJo.getJSONObject("p")).map(m -> m.getJSONObject("body")).map(m -> m.getString("dataStream")).orElse(null);
|
||||
if (StrUtil.isNotBlank(s)) {
|
||||
colJo.put("t", 1);
|
||||
colJo.put("v", s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
detail.setContent(JSON.toJSONString(rootJo));
|
||||
}
|
||||
if (CollUtil.isEmpty(details)) {
|
||||
this.add(detail);
|
||||
} else {
|
||||
@ -164,7 +190,6 @@ public class ContractorMonthlyDetailServiceImpl extends ServiceImpl<ContractorMo
|
||||
int length = SheetUtils.getColDataLength(this.getCellData(rootJo), 3, "B");
|
||||
ContractorMonthlyQuantity quantity = contractorMonthlyQuantityService.getOne(new LambdaQueryWrapper<ContractorMonthlyQuantity>()
|
||||
.eq(ContractorMonthlyQuantity::getPeriodId, p.getId())
|
||||
.eq(ContractorMonthlyQuantity::getType, p.getType())
|
||||
.eq(ContractorMonthlyQuantity::getDesignType, designType)
|
||||
);
|
||||
ContractorMonthlyDesign design = contractorMonthlyDesignService.getOne(new LambdaQueryWrapper<ContractorMonthlyDesign>()
|
||||
@ -209,7 +234,6 @@ public class ContractorMonthlyDetailServiceImpl extends ServiceImpl<ContractorMo
|
||||
}
|
||||
quantity.setArriveGoods(JSON.toJSONString(arriveList));
|
||||
quantity.setRemarks(JSON.toJSONString(remarkList));
|
||||
quantity.setType(p.getType());
|
||||
quantity.setDesignType(designType);
|
||||
contractorMonthlyQuantityService.save(quantity);
|
||||
} else {
|
||||
@ -221,7 +245,6 @@ public class ContractorMonthlyDetailServiceImpl extends ServiceImpl<ContractorMo
|
||||
}
|
||||
quantity.setArriveGoods(JSON.toJSONString(arriveList));
|
||||
quantity.setRemarks(JSON.toJSONString(remarkList));
|
||||
quantity.setType(p.getType());
|
||||
quantity.setDesignType(designType);
|
||||
contractorMonthlyQuantityService.updateById(quantity);
|
||||
}
|
||||
@ -293,10 +316,10 @@ public class ContractorMonthlyDetailServiceImpl extends ServiceImpl<ContractorMo
|
||||
@Override
|
||||
public void agree(HashMap<String, Object> param) {
|
||||
String periodId = MapUtils.getString(param, "periodId");
|
||||
ContractorMonthlyPeriod p1 = contractorMonthlyPeriodService.getById(periodId);
|
||||
p1.setStatus(3);
|
||||
contractorMonthlyPeriodService.updateById(p1);
|
||||
ProjectGroup group = projectGroupService.getById(p1.getGroupId());
|
||||
ContractorMonthlyPeriod ctPeriod = contractorMonthlyPeriodService.getById(periodId);
|
||||
ctPeriod.setStatus(3);
|
||||
contractorMonthlyPeriodService.updateById(ctPeriod);
|
||||
ProjectGroup group = projectGroupService.getById(ctPeriod.getGroupId());
|
||||
//这个供应商的detail
|
||||
List<ContractorMonthlyDetail> details1 = contractorMonthlyDetailMapper.selectList(new LambdaQueryWrapper<ContractorMonthlyDetail>()
|
||||
.eq(ContractorMonthlyDetail::getPeriodId, periodId));
|
||||
@ -306,17 +329,17 @@ public class ContractorMonthlyDetailServiceImpl extends ServiceImpl<ContractorMo
|
||||
continue;
|
||||
}
|
||||
//复制给项目组
|
||||
long gId = p1.getGroupId();
|
||||
Long unitId = p1.getDeviceId();
|
||||
long gId = ctPeriod.getGroupId();
|
||||
Long unitId = ctPeriod.getDeviceId();
|
||||
List<ContractorMonthlyPeriod> periods = contractorMonthlyPeriodService.list(new LambdaQueryWrapper<ContractorMonthlyPeriod>()
|
||||
.eq(ContractorMonthlyPeriod::getType, 2)
|
||||
.eq(ContractorMonthlyPeriod::getGroupId, gId)
|
||||
.eq(ContractorMonthlyPeriod::getDeviceId, unitId)
|
||||
.eq(ContractorMonthlyPeriod::getYear, p1.getYear())
|
||||
.eq(ContractorMonthlyPeriod::getMonth, p1.getMonth())
|
||||
.eq(ContractorMonthlyPeriod::getWhichWeek, p1.getWhichWeek())
|
||||
.eq(ContractorMonthlyPeriod::getLevelType, p1.getLevelType())
|
||||
.eq(ContractorMonthlyPeriod::getProjectSn, p1.getProjectSn())
|
||||
.eq(ContractorMonthlyPeriod::getYear, ctPeriod.getYear())
|
||||
.eq(ContractorMonthlyPeriod::getMonth, ctPeriod.getMonth())
|
||||
.eq(ContractorMonthlyPeriod::getWhichWeek, ctPeriod.getWhichWeek())
|
||||
.eq(ContractorMonthlyPeriod::getLevelType, ctPeriod.getLevelType())
|
||||
.eq(ContractorMonthlyPeriod::getProjectSn, ctPeriod.getProjectSn())
|
||||
);
|
||||
ContractorMonthlyPeriod period;
|
||||
if (CollUtil.isEmpty(periods)) {
|
||||
@ -324,10 +347,10 @@ public class ContractorMonthlyDetailServiceImpl extends ServiceImpl<ContractorMo
|
||||
period.setGroupId(gId);
|
||||
period.setDeviceId(unitId);
|
||||
period.setType(2);
|
||||
period.setYear(p1.getYear());
|
||||
period.setMonth(p1.getMonth());
|
||||
period.setWhichWeek(p1.getWhichWeek());
|
||||
period.setLevelType(p1.getLevelType());
|
||||
period.setYear(ctPeriod.getYear());
|
||||
period.setMonth(ctPeriod.getMonth());
|
||||
period.setWhichWeek(ctPeriod.getWhichWeek());
|
||||
period.setLevelType(ctPeriod.getLevelType());
|
||||
period.setProjectSn(detail.getProjectSn());
|
||||
contractorMonthlyPeriodService.save(period);
|
||||
} else {
|
||||
@ -381,12 +404,13 @@ public class ContractorMonthlyDetailServiceImpl extends ServiceImpl<ContractorMo
|
||||
if (Objects.equals(contentType, 1) || Objects.equals(contentType, 2)) {
|
||||
JSONObject toCellDataJo = this.getCellData(rootJo);
|
||||
JSONObject fromCellDataJo = this.getCellData(JSON.parseObject(content));
|
||||
buildToCellDataForOne(toCellDataJo, fromCellDataJo);
|
||||
this.buildToCellDataForOne(toCellDataJo, fromCellDataJo);
|
||||
} else if (Objects.equals(contentType, 3) || Objects.equals(contentType, 4)) {
|
||||
JSONObject toCellDataJo = this.getCellData(rootJo);
|
||||
JSONObject fromCellDataJo = this.getCellData(JSON.parseObject(content));
|
||||
buildToCellDataForThree(toCellDataJo, fromCellDataJo);
|
||||
this.buildToCellDataForThree(toCellDataJo, fromCellDataJo, rootJo);
|
||||
}
|
||||
d2.setType(2);
|
||||
d2.setContent(JSON.toJSONString(rootJo));
|
||||
baseMapper.updateById(d2);
|
||||
}
|
||||
@ -396,7 +420,7 @@ public class ContractorMonthlyDetailServiceImpl extends ServiceImpl<ContractorMo
|
||||
//保存工程量
|
||||
int designType = contentType == 5 ? 1 : 2;
|
||||
List<ContractorMonthlyDesign> designs = contractorMonthlyDesignService.list(new LambdaQueryWrapper<ContractorMonthlyDesign>()
|
||||
.eq(ContractorMonthlyDesign::getDeviceId, p1.getDeviceId())
|
||||
.eq(ContractorMonthlyDesign::getDeviceId, ctPeriod.getDeviceId())
|
||||
.eq(ContractorMonthlyDesign::getDesignType, designType)
|
||||
);
|
||||
if (CollUtil.isNotEmpty(designs)) {
|
||||
@ -418,24 +442,24 @@ public class ContractorMonthlyDetailServiceImpl extends ServiceImpl<ContractorMo
|
||||
}
|
||||
}
|
||||
|
||||
List<ContractorMonthlyQuantity> quantityList = contractorMonthlyQuantityService.list(new LambdaQueryWrapper<ContractorMonthlyQuantity>()
|
||||
.eq(ContractorMonthlyQuantity::getPeriodId, p1.getId())
|
||||
ContractorMonthlyQuantity quantity = contractorMonthlyQuantityService.getOne(new LambdaQueryWrapper<ContractorMonthlyQuantity>()
|
||||
.eq(ContractorMonthlyQuantity::getPeriodId, ctPeriod.getId())
|
||||
.eq(ContractorMonthlyQuantity::getDesignType, designType)
|
||||
);
|
||||
if (CollUtil.isNotEmpty(quantityList)) {
|
||||
Optional<ContractorMonthlyQuantity> op = quantityList.stream().filter(o -> o.getType() == 1).findFirst();
|
||||
if (op.isPresent()) {
|
||||
ContractorMonthlyQuantity cd = this.getGroupQuantity(p1, designType);
|
||||
Optional<ContractorMonthlyQuantity> op1 = quantityList.stream().filter(o -> o.getType() == 2).findFirst();
|
||||
if (op1.isPresent()) {
|
||||
cd.setId(op1.get().getId());
|
||||
cd.setType(2);
|
||||
contractorMonthlyQuantityService.updateById(cd);
|
||||
} else {
|
||||
cd.setId(null);
|
||||
cd.setType(2);
|
||||
contractorMonthlyQuantityService.save(cd);
|
||||
}
|
||||
if (quantity != null) {
|
||||
ContractorMonthlyQuantity cd = this.getGroupQuantity(ctPeriod, designType);
|
||||
ContractorMonthlyQuantity groupQuantity = contractorMonthlyQuantityService.getOne(new LambdaQueryWrapper<ContractorMonthlyQuantity>()
|
||||
.eq(ContractorMonthlyQuantity::getPeriodId, period.getId())
|
||||
.eq(ContractorMonthlyQuantity::getDesignType, designType)
|
||||
);
|
||||
if (groupQuantity != null) {
|
||||
cd.setId(groupQuantity.getId());
|
||||
cd.setPeriodId(period.getId());
|
||||
contractorMonthlyQuantityService.updateById(cd);
|
||||
} else {
|
||||
cd.setId(null);
|
||||
cd.setPeriodId(period.getId());
|
||||
contractorMonthlyQuantityService.save(cd);
|
||||
}
|
||||
}
|
||||
|
||||
@ -451,9 +475,7 @@ public class ContractorMonthlyDetailServiceImpl extends ServiceImpl<ContractorMo
|
||||
Integer levelType = period.getLevelType();
|
||||
ContractorMonthlyQuantity monthlyQuantity = new ContractorMonthlyQuantity();
|
||||
monthlyQuantity.setProjectSn(period.getProjectSn());
|
||||
monthlyQuantity.setPeriodId(periodId);
|
||||
Integer type = period.getType();
|
||||
monthlyQuantity.setType(type);
|
||||
monthlyQuantity.setDesignType(designType);
|
||||
//查询所有的period
|
||||
List<ContractorMonthlyPeriod> periodList = contractorMonthlyPeriodService.list(new LambdaQueryWrapper<ContractorMonthlyPeriod>()
|
||||
@ -463,7 +485,6 @@ public class ContractorMonthlyDetailServiceImpl extends ServiceImpl<ContractorMo
|
||||
if (CollUtil.isNotEmpty(periodList)) {
|
||||
List<ContractorMonthlyQuantity> quantityList = contractorMonthlyQuantityService.list(new LambdaQueryWrapper<ContractorMonthlyQuantity>()
|
||||
.eq(ContractorMonthlyQuantity::getDesignType, designType)
|
||||
.eq(ContractorMonthlyQuantity::getType, type)
|
||||
.in(ContractorMonthlyQuantity::getPeriodId, periodList.stream().map(ContractorMonthlyPeriod::getId).collect(Collectors.toList())));
|
||||
int month = DateUtil.month(new Date());
|
||||
int year = DateUtil.year(new Date());
|
||||
@ -490,81 +511,139 @@ public class ContractorMonthlyDetailServiceImpl extends ServiceImpl<ContractorMo
|
||||
return monthlyQuantity;
|
||||
}
|
||||
|
||||
private void buildToCellDataForThree(JSONObject toCellDataJo, JSONObject fromCellDataJo) {
|
||||
//插入一列:columnCount+1,mergeData[].endColumn+1,cellData挪动,columnData(哪行多宽)
|
||||
String addEnterprise = fromCellDataJo.getJSONObject("4").getJSONObject("3").getString("v");
|
||||
private void buildToCellDataForThree(JSONObject toCellDataJo, JSONObject fromCellDataJo, JSONObject rootJo) {
|
||||
SheetUtils.setDefaultStyle(rootJo);
|
||||
List<String> addEnterprises = new ArrayList<>();
|
||||
JSONObject enterpriseRow = toCellDataJo.getJSONObject("4");
|
||||
boolean add = true;
|
||||
Integer addCol = enterpriseRow.size();
|
||||
Integer replaceCol = null;
|
||||
for (int col = 3; col < enterpriseRow.size(); col++) {
|
||||
JSONObject jo = enterpriseRow.getJSONObject(col + "");
|
||||
if (Objects.equals(jo.getString("v"), addEnterprise)) {
|
||||
add = false;
|
||||
replaceCol = col;
|
||||
}
|
||||
addEnterprises.add(jo.getString("v"));
|
||||
}
|
||||
List<JSONObject> fromJoList = new ArrayList<>();
|
||||
for (int row = 4; row < fromCellDataJo.size(); row++) {
|
||||
JSONObject jo = fromCellDataJo.getJSONObject(row + "");
|
||||
JSONObject jo1 = jo.getJSONObject("3");
|
||||
fromJoList.add(jo1);
|
||||
}
|
||||
if (add) {
|
||||
//添加到最后一列
|
||||
for (int row = 4; row < toCellDataJo.size(); row++) {
|
||||
JSONObject jo = toCellDataJo.getJSONObject(row + "");
|
||||
jo.put(addCol + "", fromJoList.get(row - 4));
|
||||
int colIndex = 0;
|
||||
for (String addEnterprise : addEnterprises) {
|
||||
String fromCol = SheetUtils.getIndexOfCol(3 + colIndex++);
|
||||
//插入一列:columnCount+1,mergeData[].endColumn+1,cellData挪动,columnData(哪行多宽)
|
||||
boolean add = true;
|
||||
Integer addCol = enterpriseRow.size();
|
||||
Integer replaceCol = null;
|
||||
for (int col = 3; col < enterpriseRow.size(); col++) {
|
||||
JSONObject jo = enterpriseRow.getJSONObject(col + "");
|
||||
if (Objects.equals(jo.getString("v"), addEnterprise)) {
|
||||
add = false;
|
||||
replaceCol = col;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int row = 4; row < toCellDataJo.size(); row++) {
|
||||
JSONObject jo = toCellDataJo.getJSONObject(row + "");
|
||||
jo.put(replaceCol + "", fromJoList.get(row - 4));
|
||||
List<JSONObject> fromJoList = new ArrayList<>();
|
||||
List<JSONObject> fromKeyJoList = new ArrayList<>();
|
||||
for (int row = 6; row < fromCellDataJo.size(); row++) {
|
||||
fromJoList.add(SheetUtils.getColJsonObject(fromCellDataJo, row, fromCol + ""));
|
||||
fromKeyJoList.add(SheetUtils.getColJsonObject(fromCellDataJo, row, "B"));
|
||||
}
|
||||
//清空这列
|
||||
Integer col = null;
|
||||
if (add) {
|
||||
//添加到最后一列
|
||||
col = addCol;
|
||||
} else {
|
||||
col = replaceCol;
|
||||
}
|
||||
for (int i = 6; i < toCellDataJo.size(); i++) {
|
||||
SheetUtils.setCol(toCellDataJo, i, col, "", 3, 2);
|
||||
}
|
||||
SheetUtils.setCol(toCellDataJo, 4, col, addEnterprise, 2, 1);
|
||||
SheetUtils.setColFunction(toCellDataJo, 5, col, "=SUM(" + SheetUtils.getIndexOfCol(col) + 7 + ":" + SheetUtils.getIndexOfCol(col) + "999)", 3);
|
||||
for (int i = 0; i < fromKeyJoList.size(); i++) {
|
||||
JSONObject keyJo = fromKeyJoList.get(i);
|
||||
JSONObject fromJo = fromJoList.get(i);
|
||||
boolean done = false;
|
||||
for (int row = 6; row < toCellDataJo.size(); row++) {
|
||||
String v = SheetUtils.getColVal(toCellDataJo, row, "B");
|
||||
if (Objects.equals(v, keyJo.getString("v"))) {
|
||||
if (fromJo != null) {
|
||||
SheetUtils.setCol(toCellDataJo, row, col, fromJo.getString("v"), 3, 2);
|
||||
}
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!done) {
|
||||
//添加到最后一行
|
||||
SheetUtils.setCol(toCellDataJo, toCellDataJo.size(), "A", toCellDataJo.size() - 6 + "", 2, 2);
|
||||
SheetUtils.setCol(toCellDataJo, toCellDataJo.size(), "B", keyJo.getString("v"), 1, 1);
|
||||
SheetUtils.setColFunction(toCellDataJo, toCellDataJo.size(), "C", "=SUM(C" + (toCellDataJo.size() - 1) + ":XFD" + (toCellDataJo.size() - 1) + ")", 3);
|
||||
if (fromJo != null) {
|
||||
SheetUtils.setCol(toCellDataJo, toCellDataJo.size(), col, fromJo.getString("v"), 3, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buildToCellDataForOne(JSONObject toCellDataJo, JSONObject fromCellDataJo) {
|
||||
String addEnterprise = fromCellDataJo.getJSONObject("7").getJSONObject("1").getString("v");
|
||||
//key=7开始
|
||||
boolean add = true;
|
||||
int enterpriseNum = 0;
|
||||
Integer from = null;
|
||||
Integer to = null;
|
||||
for (int i = 7; i < toCellDataJo.size(); i++) {
|
||||
JSONObject jo = toCellDataJo.getJSONObject(i + "");
|
||||
if (jo.getJSONObject("1") != null && StrUtil.isNotBlank(jo.getJSONObject("1").getString("v"))) {
|
||||
if (from != null && to == null) {
|
||||
List<Triple<String, Integer, Integer>> addEnterprises = new ArrayList<>();
|
||||
String lastName = null;
|
||||
Integer lastBegin = null;
|
||||
for (int i = 7; i < fromCellDataJo.size(); i++) {
|
||||
//key=7开始
|
||||
String v = SheetUtils.getColVal(fromCellDataJo, i, "B");
|
||||
if (StrUtil.isNotBlank(v)) {
|
||||
if (lastName != null) {
|
||||
Triple<String, Integer, Integer> t = new ImmutableTriple<>(lastName, lastBegin, i - 1);
|
||||
addEnterprises.add(t);
|
||||
}
|
||||
lastName = v;
|
||||
lastBegin = i;
|
||||
}
|
||||
if (i == fromCellDataJo.size() - 1) {
|
||||
Triple<String, Integer, Integer> t = new ImmutableTriple<>(lastName, lastBegin, i);
|
||||
addEnterprises.add(t);
|
||||
}
|
||||
}
|
||||
for (Triple<String, Integer, Integer> triple : addEnterprises) {
|
||||
String addEnterprise = triple.getLeft();
|
||||
Integer begin = triple.getMiddle();
|
||||
Integer end = triple.getRight();
|
||||
boolean add = true;
|
||||
int enterpriseNum = 0;
|
||||
Integer from = null;
|
||||
Integer to = null;
|
||||
for (int i = 7; i < toCellDataJo.size(); i++) {
|
||||
JSONObject jo = toCellDataJo.getJSONObject(i + "");
|
||||
if (jo != null && jo.getJSONObject("1") != null && StrUtil.isNotBlank(jo.getJSONObject("1").getString("v"))) {
|
||||
if (from != null && to == null) {
|
||||
to = i - 1;
|
||||
}
|
||||
enterpriseNum++;
|
||||
}
|
||||
if (jo != null && jo.getJSONObject("1") != null && Objects.equals(addEnterprise, jo.getJSONObject("1").getString("v"))) {
|
||||
//覆盖
|
||||
from = i;
|
||||
add = false;
|
||||
}
|
||||
if (toCellDataJo.size() - 1 == i && from != null && to == null) {
|
||||
to = i - 1;
|
||||
}
|
||||
enterpriseNum++;
|
||||
}
|
||||
if (jo.getJSONObject("1") != null && Objects.equals(addEnterprise, jo.getJSONObject("1").getString("v"))) {
|
||||
//覆盖
|
||||
from = i;
|
||||
add = false;
|
||||
JSONObject fromJo = new JSONObject();
|
||||
for (int i = begin; i <= end; i++) {
|
||||
JSONObject jo = fromCellDataJo.getJSONObject(i + "");
|
||||
if (add) {
|
||||
String cn = NumberUtils.int2chineseNum(enterpriseNum + 1);
|
||||
JSONObject jo1 = jo.getJSONObject("0");
|
||||
jo1.put("v", cn);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (toCellDataJo.size() - 1 == i && from != null && to == null) {
|
||||
to = i - 1;
|
||||
int j = 0;
|
||||
for (int i = begin; i <= end; i++) {
|
||||
JSONObject jo = fromCellDataJo.getJSONObject(i + "");
|
||||
fromJo.put(j++ + "", jo);
|
||||
}
|
||||
}
|
||||
JSONObject fromJo = new JSONObject();
|
||||
int j = 0;
|
||||
boolean run = false;
|
||||
for (int i = 7; i < fromCellDataJo.size(); i++) {
|
||||
JSONObject jo = fromCellDataJo.getJSONObject(i + "");
|
||||
if (add && !run) {
|
||||
String cn = NumberUtils.int2chineseNum(enterpriseNum + 1);
|
||||
JSONObject jo1 = jo.getJSONObject("0");
|
||||
jo1.put("v", cn);
|
||||
run = true;
|
||||
if (add) {
|
||||
SheetUtils.addRows(fromJo, toCellDataJo);
|
||||
} else {
|
||||
SheetUtils.replaceRows(fromJo, toCellDataJo, from, to);
|
||||
}
|
||||
fromJo.put(j++ + "", jo);
|
||||
}
|
||||
if (add) {
|
||||
SheetUtils.addRows(fromJo, toCellDataJo);
|
||||
} else {
|
||||
SheetUtils.replaceRows(fromJo, toCellDataJo, from, to);
|
||||
}
|
||||
}
|
||||
|
||||
@ -608,6 +687,9 @@ public class ContractorMonthlyDetailServiceImpl extends ServiceImpl<ContractorMo
|
||||
tempType = 7;
|
||||
} else if (contentType == 6 && levelType == 2) {
|
||||
tempType = 8;
|
||||
} else if (contentType == 8){
|
||||
//项目计划
|
||||
tempType = 14;
|
||||
}
|
||||
ContractorMonthlyTemplate template = contractorMonthlyTemplateService.getById(tempType);
|
||||
content = template.getContent();
|
||||
@ -628,26 +710,28 @@ public class ContractorMonthlyDetailServiceImpl extends ServiceImpl<ContractorMo
|
||||
Date date = new Date();
|
||||
DateTime s1 = DateUtil.offsetDay(date, -7);
|
||||
DateTime s2 = DateUtil.offsetDay(date, 7);
|
||||
content = content.replace("{{lastWeek}}", DateUtil.formatDateTime(DateUtil.beginOfWeek(s1)) + "~" + DateUtil.formatDateTime(DateUtil.endOfWeek(s1)));
|
||||
content = content.replace("{{thisWeek}}", DateUtil.formatDateTime(DateUtil.beginOfWeek(date)) + "~" + DateUtil.formatDateTime(DateUtil.endOfWeek(date)));
|
||||
content = content.replace("{{nextWeek}}", DateUtil.formatDateTime(DateUtil.beginOfWeek(s2)) + "~" + DateUtil.formatDateTime(DateUtil.endOfWeek(s2)));
|
||||
content = content.replace("{{lastWeek}}", DateUtil.formatDate(DateUtil.beginOfWeek(s1)) + "~" + DateUtil.formatDate(DateUtil.endOfWeek(s1)));
|
||||
content = content.replace("{{thisWeek}}", DateUtil.formatDate(DateUtil.beginOfWeek(date)) + "~" + DateUtil.formatDate(DateUtil.endOfWeek(date)));
|
||||
content = content.replace("{{nextWeek}}", DateUtil.formatDate(DateUtil.beginOfWeek(s2)) + "~" + DateUtil.formatDate(DateUtil.endOfWeek(s2)));
|
||||
content = content.replace("{{enterpriseName}}", en);
|
||||
|
||||
//取上周的
|
||||
ContractorMonthlyPeriod p1 = contractorMonthlyPeriodService.getBeforePeriod(period);
|
||||
ContractorMonthlyPeriod beforeP = contractorMonthlyPeriodService.queryByEntity(p1);
|
||||
if (beforeP != null) {
|
||||
ContractorMonthlyDetail detail1 = contractorMonthlyDetailMapper.selectOne(new LambdaQueryWrapper<ContractorMonthlyDetail>()
|
||||
.eq(ContractorMonthlyDetail::getContentType, contentType)
|
||||
.eq(ContractorMonthlyDetail::getPeriodId, beforeP.getId()));
|
||||
if (detail1 != null) {
|
||||
JSONObject toJo = JSON.parseObject(content);
|
||||
JSONObject toCellDataJo = getCellData(toJo);
|
||||
JSONObject fromCellDataJo = getCellData(JSON.parseObject(detail1.getContent()));
|
||||
int fl = SheetUtils.getColDataLength(fromCellDataJo, 8, 5);
|
||||
int tl = SheetUtils.getColDataLength(toCellDataJo, 8, 5);
|
||||
SheetUtils.replaceArea(fromCellDataJo, toCellDataJo, 8, 5, fl + 7, 7, 8, 2, tl + 7, 4);
|
||||
content = JSON.toJSONString(toJo);
|
||||
if (contentType == 1 || contentType == 2) {
|
||||
ContractorMonthlyPeriod p1 = contractorMonthlyPeriodService.getBeforePeriod(period);
|
||||
ContractorMonthlyPeriod beforeP = contractorMonthlyPeriodService.queryByEntity(p1);
|
||||
if (beforeP != null) {
|
||||
ContractorMonthlyDetail detail1 = contractorMonthlyDetailMapper.selectOne(new LambdaQueryWrapper<ContractorMonthlyDetail>()
|
||||
.eq(ContractorMonthlyDetail::getContentType, contentType)
|
||||
.eq(ContractorMonthlyDetail::getPeriodId, beforeP.getId()));
|
||||
if (detail1 != null) {
|
||||
JSONObject toJo = JSON.parseObject(content);
|
||||
JSONObject toCellDataJo = getCellData(toJo);
|
||||
JSONObject fromCellDataJo = getCellData(JSON.parseObject(detail1.getContent()));
|
||||
int fl = SheetUtils.getColDataLength(fromCellDataJo, 8, 5);
|
||||
int tl = SheetUtils.getColDataLength(toCellDataJo, 8, 5);
|
||||
SheetUtils.replaceAreaForQuantity(fromCellDataJo, toCellDataJo, 8, 5, fl + 7, 7, 8, 2, tl + 7, 4);
|
||||
content = JSON.toJSONString(toJo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -663,11 +747,12 @@ public class ContractorMonthlyDetailServiceImpl extends ServiceImpl<ContractorMo
|
||||
List<Long> titleIds = contractorMonthlyConfigService.list(new LambdaQueryWrapper<ContractorMonthlyConfig>()
|
||||
.eq(ContractorMonthlyConfig::getUserId, SecurityUtils.getUser().getUserId())).stream().map(ContractorMonthlyConfig::getTitleId).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(titleIds)) {
|
||||
Map<String, ContractorMonthlyTitle> titleMap = contractorMonthlyTitleService.list(new LambdaQueryWrapper<ContractorMonthlyTitle>()
|
||||
List<ContractorMonthlyTitle> titles = contractorMonthlyTitleService.list(new LambdaQueryWrapper<ContractorMonthlyTitle>()
|
||||
.eq(ContractorMonthlyTitle::getType, levelType)
|
||||
.in(ContractorMonthlyTitle::getId, titleIds)
|
||||
).stream().map(o -> {
|
||||
o.setWordName(o.getWordName().replace(" ", ""));
|
||||
);
|
||||
Map<String, ContractorMonthlyTitle> titleMap = titles.stream().map(o -> {
|
||||
o.setWordName(o.getWordName().replace(" ", "").replaceAll("\\u00A0+", ""));
|
||||
return o;
|
||||
}).collect(Collectors.toMap(ContractorMonthlyTitle::getWordName, Function.identity(), (o, o2) -> o));
|
||||
JSONObject rootJo = JSON.parseObject(content);
|
||||
@ -704,6 +789,11 @@ public class ContractorMonthlyDetailServiceImpl extends ServiceImpl<ContractorMo
|
||||
content = JSON.toJSONString(rootJo);
|
||||
}
|
||||
}
|
||||
JSONObject rootJo1 = JSONObject.parseObject(content);
|
||||
if (rootJo1 != null && contentType != 7) {
|
||||
SheetUtils.setDefaultStyle(rootJo1);
|
||||
content = JSON.toJSONString(rootJo1);
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
@ -726,7 +816,14 @@ public class ContractorMonthlyDetailServiceImpl extends ServiceImpl<ContractorMo
|
||||
designType = 2;
|
||||
}
|
||||
JSONObject toJo = JSON.parseObject(content);
|
||||
List<Integer> greens = new ArrayList<>();
|
||||
JSONObject toCellDataJo = getCellData(toJo);
|
||||
for (int i = 3; i < toCellDataJo.size(); i++) {
|
||||
String v = Optional.ofNullable(toCellDataJo.getJSONObject(i + "")).map(m -> m.getJSONObject("0")).map(m -> m.getString("v")).orElse(null);
|
||||
if (StrUtil.isNotBlank(v)) {
|
||||
greens.add(i);
|
||||
}
|
||||
}
|
||||
//设计总量
|
||||
ContractorMonthlyDesign design = contractorMonthlyDesignService.getOne(new LambdaQueryWrapper<ContractorMonthlyDesign>()
|
||||
.eq(ContractorMonthlyDesign::getDeviceId, deviceId)
|
||||
@ -736,17 +833,17 @@ public class ContractorMonthlyDetailServiceImpl extends ServiceImpl<ContractorMo
|
||||
if (design != null) {
|
||||
List<String> list = JSON.parseObject(design.getQuantity(), new TypeReference<List<String>>() {
|
||||
});
|
||||
SheetUtils.setColDataList(toCellDataJo, 3, "C", list);
|
||||
SheetUtils.setColDataListForQuantity(toCellDataJo, 3, "C", list, greens);
|
||||
}
|
||||
//查询所有的period
|
||||
List<ContractorMonthlyPeriod> periodList = contractorMonthlyPeriodService.list(new LambdaQueryWrapper<ContractorMonthlyPeriod>()
|
||||
.eq(ContractorMonthlyPeriod::getDeviceId, deviceId)
|
||||
.eq(ContractorMonthlyPeriod::getGroupId, groupId)
|
||||
.eq(ContractorMonthlyPeriod::getType, type)
|
||||
.eq(type == 1, ContractorMonthlyPeriod::getEnterpriseId, enterpriseId)
|
||||
);
|
||||
if (CollUtil.isNotEmpty(periodList)) {
|
||||
List<ContractorMonthlyQuantity> quantityList = contractorMonthlyQuantityService.list(new LambdaQueryWrapper<ContractorMonthlyQuantity>()
|
||||
.eq(ContractorMonthlyQuantity::getType, type)
|
||||
.eq(ContractorMonthlyQuantity::getDesignType, designType)
|
||||
.in(ContractorMonthlyQuantity::getPeriodId, periodList.stream().map(ContractorMonthlyPeriod::getId).collect(Collectors.toList())));
|
||||
Optional<ContractorMonthlyQuantity> op = quantityList.stream().filter(o -> Objects.equals(o.getPeriodId(), periodId)).collect(Collectors.toList()).stream().findAny();
|
||||
@ -759,47 +856,47 @@ public class ContractorMonthlyDetailServiceImpl extends ServiceImpl<ContractorMo
|
||||
if (levelType == 2) {
|
||||
//周
|
||||
String wmQuantity = quantity.getWeekQuantity();
|
||||
SheetUtils.setColDataList(toCellDataJo, 3, "D", wmQuantity);
|
||||
SheetUtils.setColDataListForQuantity(toCellDataJo, 3, "D", wmQuantity, greens);
|
||||
//本月完成量
|
||||
List<Long> pids1 = periodList.stream().filter(o -> isLessOrEqual(o, year, month, whichWeek)).map(ContractorMonthlyPeriod::getId).collect(Collectors.toList());
|
||||
List<String> months = quantityList.stream().filter(o -> pids1.contains(o.getPeriodId())).map(ContractorMonthlyQuantity::getWeekQuantity).collect(Collectors.toList());
|
||||
SheetUtils.setColDataList(toCellDataJo, 3, "E", this.sumListJson(months));
|
||||
SheetUtils.setColDataListForQuantity(toCellDataJo, 3, "E", this.sumListJson(months), greens);
|
||||
//本年累计完成量
|
||||
List<Long> pids2 = periodList.stream().filter(o -> isLessOrEqual(o, year, month, whichWeek)).map(ContractorMonthlyPeriod::getId).collect(Collectors.toList());
|
||||
List<String> years = quantityList.stream().filter(o -> pids2.contains(o.getPeriodId())).map(ContractorMonthlyQuantity::getWeekQuantity).collect(Collectors.toList());
|
||||
SheetUtils.setColDataList(toCellDataJo, 3, "F", this.sumListJson(years));
|
||||
SheetUtils.setColDataListForQuantity(toCellDataJo, 3, "F", this.sumListJson(years), greens);
|
||||
//开累完成量
|
||||
List<String> alls = quantityList.stream().map(ContractorMonthlyQuantity::getWeekQuantity).collect(Collectors.toList());
|
||||
SheetUtils.setColDataList(toCellDataJo, 3, "G", this.sumListJson(alls));
|
||||
SheetUtils.setColDataListForQuantity(toCellDataJo, 3, "G", this.sumListJson(alls), greens);
|
||||
//本期到货
|
||||
String arriveGoods = quantity.getArriveGoods();
|
||||
SheetUtils.setColDataList(toCellDataJo, 3, "H", arriveGoods);
|
||||
SheetUtils.setColDataListForQuantity(toCellDataJo, 3, "H", arriveGoods, greens);
|
||||
//累计到货
|
||||
List<String> arriveAlls = quantityList.stream().map(ContractorMonthlyQuantity::getArriveGoods).collect(Collectors.toList());
|
||||
SheetUtils.setColDataList(toCellDataJo, 3, "I", this.sumListJson(arriveAlls));
|
||||
SheetUtils.setColDataListForQuantity(toCellDataJo, 3, "I", this.sumListJson(arriveAlls), greens);
|
||||
//备注
|
||||
String remarks = quantity.getRemarks();
|
||||
SheetUtils.setColDataList(toCellDataJo, 3, "J", remarks);
|
||||
SheetUtils.setColDataListForQuantity(toCellDataJo, 3, "J", remarks, greens);
|
||||
} else {
|
||||
//月
|
||||
//本月完成量
|
||||
SheetUtils.setColDataList(toCellDataJo, 3, "D", quantity.getMonthQuantity());
|
||||
SheetUtils.setColDataListForQuantity(toCellDataJo, 3, "D", quantity.getMonthQuantity(), greens);
|
||||
//本年累计完成量
|
||||
List<Long> pids2 = periodList.stream().filter(o -> isLessOrEqual(o, year, month, whichWeek)).map(ContractorMonthlyPeriod::getId).collect(Collectors.toList());
|
||||
List<String> years = quantityList.stream().filter(o -> pids2.contains(o.getPeriodId())).map(ContractorMonthlyQuantity::getMonthQuantity).collect(Collectors.toList());
|
||||
SheetUtils.setColDataList(toCellDataJo, 3, "E", this.sumListJson(years));
|
||||
SheetUtils.setColDataListForQuantity(toCellDataJo, 3, "E", this.sumListJson(years), greens);
|
||||
//开累完成量
|
||||
List<String> alls = quantityList.stream().map(ContractorMonthlyQuantity::getMonthQuantity).collect(Collectors.toList());
|
||||
SheetUtils.setColDataList(toCellDataJo, 3, "F", this.sumListJson(alls));
|
||||
SheetUtils.setColDataListForQuantity(toCellDataJo, 3, "F", this.sumListJson(alls), greens);
|
||||
//本期到货
|
||||
String arriveGoods = quantity.getArriveGoods();
|
||||
SheetUtils.setColDataList(toCellDataJo, 3, "G", arriveGoods);
|
||||
SheetUtils.setColDataListForQuantity(toCellDataJo, 3, "G", arriveGoods, greens);
|
||||
//累计到货
|
||||
List<String> arriveAlls = quantityList.stream().map(ContractorMonthlyQuantity::getArriveGoods).collect(Collectors.toList());
|
||||
SheetUtils.setColDataList(toCellDataJo, 3, "H", this.sumListJson(arriveAlls));
|
||||
SheetUtils.setColDataListForQuantity(toCellDataJo, 3, "H", this.sumListJson(arriveAlls), greens);
|
||||
//备注
|
||||
String remarks = quantity.getRemarks();
|
||||
SheetUtils.setColDataList(toCellDataJo, 3, "I", remarks);
|
||||
SheetUtils.setColDataListForQuantity(toCellDataJo, 3, "I", remarks, greens);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -882,7 +979,7 @@ public class ContractorMonthlyDetailServiceImpl extends ServiceImpl<ContractorMo
|
||||
content = detail.getContent();
|
||||
}
|
||||
ContractorMonthlyTitle title = contractorMonthlyTitleService.getById(titleId);
|
||||
String wordName = title.getWordName().replace(" ", "");
|
||||
String wordName = title.getWordName().replaceAll("\\u00A0+", "").replace(" ", "");
|
||||
JSONObject rootJo = JSON.parseObject(content);
|
||||
JSONArray mainJa = rootJo.getJSONArray("main");
|
||||
JSONArray newMainJa = new JSONArray();
|
||||
@ -911,7 +1008,7 @@ public class ContractorMonthlyDetailServiceImpl extends ServiceImpl<ContractorMo
|
||||
if (!levels.contains(level1)) {
|
||||
newMainJa.add(jo);
|
||||
} else {
|
||||
if (levels.indexOf(level) <= levels.indexOf(level1)) {
|
||||
if (levels.contains(level) /*<= levels.indexOf(level1)*/) {
|
||||
break;
|
||||
}
|
||||
newMainJa.add(jo);
|
||||
@ -952,7 +1049,7 @@ public class ContractorMonthlyDetailServiceImpl extends ServiceImpl<ContractorMo
|
||||
}
|
||||
String content = detail.getContent();
|
||||
ContractorMonthlyTitle title = contractorMonthlyTitleService.getById(titleId);
|
||||
String wordName = title.getWordName().replace(" ", "");
|
||||
String wordName = title.getWordName().replaceAll("\\u00A0+", "").replace(" ", "");
|
||||
JSONObject rootJo = JSON.parseObject(content);
|
||||
JSONArray mainJa = rootJo.getJSONArray("main");
|
||||
JSONArray newMainJa = new JSONArray();
|
||||
@ -983,8 +1080,13 @@ public class ContractorMonthlyDetailServiceImpl extends ServiceImpl<ContractorMo
|
||||
} else {
|
||||
String level1 = jo.getString("level");
|
||||
if (needRead) {
|
||||
if (levels.contains(level1) && levels.indexOf(level) >= levels.indexOf(level1)) {
|
||||
if (levels.contains(level1) /*&& levels.indexOf(level) >= levels.indexOf(level1)*/) {
|
||||
needRead = false;
|
||||
//补充换行
|
||||
String str = Convert.toStr(jo.get("value"));
|
||||
if (!str.contains("\n") && !str.contains("\r\n")) {
|
||||
newMainJa.add(new JoBuilder().put("value", "\n").build());
|
||||
}
|
||||
newMainJa.add(jo);
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -48,7 +48,7 @@ public class ContractorMonthlyTitleServiceImpl extends ServiceImpl<ContractorMon
|
||||
|
||||
private QueryWrapper<ContractorMonthlyTitle> getQueryWrapper(HashMap<String, Object> param) {
|
||||
QueryWrapper<ContractorMonthlyTitle> queryWrapper = QueryGenerator.initPageQueryWrapper(ContractorMonthlyTitle.class, param, true);
|
||||
queryWrapper.orderByDesc(RefUtil.fieldNameUlc(ContractorMonthlyTitle::getId));
|
||||
queryWrapper.orderByAsc(RefUtil.fieldNameUlc(ContractorMonthlyTitle::getSort));
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ package com.zhgd.xmgl.modules.baotou.service.impl;
|
||||
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.xmgl.modules.baotou.entity.ProjectHomeManage;
|
||||
import com.zhgd.xmgl.modules.baotou.entity.ProjectHomeWork;
|
||||
import com.zhgd.xmgl.modules.baotou.mapper.ProjectHomeManageMapper;
|
||||
import com.zhgd.xmgl.modules.baotou.service.IProjectHomeManageService;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -44,7 +45,7 @@ public class ProjectHomeManageServiceImpl extends ServiceImpl<ProjectHomeManageM
|
||||
|
||||
private QueryWrapper<ProjectHomeManage> getQueryWrapper(HashMap<String, Object> param) {
|
||||
QueryWrapper<ProjectHomeManage> queryWrapper = QueryGenerator.initPageQueryWrapper(ProjectHomeManage.class, param, true);
|
||||
queryWrapper.orderByDesc(RefUtil.fieldNameUlc(ProjectHomeManage::getId));
|
||||
queryWrapper.orderByAsc(RefUtil.fieldNameUlc(ProjectHomeManage::getSort));
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ public class ProjectHomeWorkServiceImpl extends ServiceImpl<ProjectHomeWorkMappe
|
||||
|
||||
private QueryWrapper<ProjectHomeWork> getQueryWrapper(HashMap<String, Object> param) {
|
||||
QueryWrapper<ProjectHomeWork> queryWrapper = QueryGenerator.initPageQueryWrapper(ProjectHomeWork.class, param, true);
|
||||
queryWrapper.orderByDesc(RefUtil.fieldNameUlc(ProjectHomeWork::getId));
|
||||
queryWrapper.orderByAsc(RefUtil.fieldNameUlc(ProjectHomeWork::getSort));
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
|
||||
@ -9,8 +9,19 @@ import com.gexin.fastjson.TypeReference;
|
||||
import java.util.*;
|
||||
|
||||
public class SheetUtils {
|
||||
|
||||
static List<String> letterList = Arrays.asList("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
|
||||
/**
|
||||
* 居中和加边框
|
||||
*/
|
||||
static String centerStyle = "cwv4pm";
|
||||
/**
|
||||
* 靠右对齐和加边框
|
||||
*/
|
||||
static String rightStyle = "cyqt7m";
|
||||
static String leftStyle = "poyh2f";
|
||||
/**
|
||||
* 绿色工程量
|
||||
*/
|
||||
static String greenQuantityStyle = "uh17gs";
|
||||
|
||||
public static JSONObject addRows(JSONObject fromJo, JSONObject toJo) {
|
||||
for (int i = 0; i < fromJo.size(); i++) {
|
||||
@ -100,6 +111,39 @@ public class SheetUtils {
|
||||
return add;
|
||||
}
|
||||
|
||||
public static JSONObject replaceAreaForQuantity(JSONObject fromCellDataJo, JSONObject toCellDataJo, int i1, int i2, int i3, int i4, int j1, int j2, int j3, int j4) {
|
||||
JSONObject add = BeanUtil.toBean(toCellDataJo, JSONObject.class);
|
||||
//是否扩容
|
||||
int diffCol = i4 - i2 - (j4 - j2);
|
||||
int diffRow = i3 - i1 - (j3 - j1);
|
||||
for (int row = 0; row < toCellDataJo.size(); row++) {
|
||||
JSONObject jo = toCellDataJo.getJSONObject(row + "");
|
||||
JSONObject nr = new JSONObject();
|
||||
for (int col = 0; col < jo.size(); col++) {
|
||||
nr.put(col + "", jo.getJSONObject(col + ""));
|
||||
}
|
||||
if (diffRow > 0 && row > j3) {
|
||||
add.put(row + diffRow + "", nr);
|
||||
} else {
|
||||
add.put(row + "", nr);
|
||||
}
|
||||
}
|
||||
int fromRow = i1;
|
||||
for (int row = j1; row <= j3; row++) {
|
||||
int fromCol = i2;
|
||||
JSONObject nr = add.getJSONObject(row + "");
|
||||
for (int col = j2; col <= j4; col++) {
|
||||
nr.put(col + "", fromCellDataJo.getJSONObject(fromRow + "").getJSONObject(fromCol + ""));
|
||||
fromCol++;
|
||||
}
|
||||
fromRow++;
|
||||
add.put(row + "", nr);
|
||||
}
|
||||
toCellDataJo.clear();
|
||||
toCellDataJo.putAll(add);
|
||||
return add;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取col连续不为空的数量
|
||||
*
|
||||
@ -125,7 +169,33 @@ public class SheetUtils {
|
||||
}
|
||||
|
||||
public static String getColNum(String col) {
|
||||
return letterList.indexOf(col) + "";
|
||||
char[] chars = col.toCharArray();
|
||||
int res = 0;
|
||||
for (char c : chars) {
|
||||
res = res * 26 + (c - 'A' + 1);
|
||||
}
|
||||
return res - 1 + "";
|
||||
}
|
||||
|
||||
/**
|
||||
* description: 列号从1开始,如:0 对应 A列,26对应AA列
|
||||
*
|
||||
* @param value Excel列号
|
||||
*/
|
||||
public static String getIndexOfCol(int value) {
|
||||
// 转26进制 0-25
|
||||
int calculateValue = value;
|
||||
// 取高位
|
||||
int high = calculateValue / 26;
|
||||
// 取低位
|
||||
int low = calculateValue % 26;
|
||||
// 低位可直接取出对应的字母
|
||||
String transStr = String.valueOf((char) (low + 65));
|
||||
if (high > 0) {
|
||||
// 高位递归取出字母
|
||||
transStr = getIndexOfCol(high) + transStr;
|
||||
}
|
||||
return transStr;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -151,13 +221,34 @@ public class SheetUtils {
|
||||
*/
|
||||
public static List<String> getColDataList(JSONObject cellData, int row, String col, int length) {
|
||||
List<String> list = new ArrayList<>();
|
||||
for (int r = row; r < length; r++) {
|
||||
for (int r = row; r < length + row; r++) {
|
||||
JSONObject jo = cellData.getJSONObject(r + "");
|
||||
list.add(Optional.ofNullable(jo.getJSONObject(getColNum(col))).map(m -> m.getString("v")).orElse(null));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static void setColDataListForQuantity(JSONObject toCellDataJo, int row, String col, List<String> addList, List<Integer> greens) {
|
||||
for (int r = row; r < row + addList.size(); r++) {
|
||||
JSONObject jo = toCellDataJo.getJSONObject(r + "");
|
||||
Map<String, Object> map = new MapBuilder<String, Object>().put("v", addList.get(r - row)).put("t", 2).build();
|
||||
if (greens.contains(r)) {
|
||||
map.put("s", greenQuantityStyle);
|
||||
} else {
|
||||
map.put("s", centerStyle);
|
||||
}
|
||||
if (jo != null) {
|
||||
jo.put(getColNum(col), map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void setColDataListForQuantity(JSONObject toCellDataJo, int row, String col, String jsonStr, List<Integer> greens) {
|
||||
List<String> addList = JSON.parseObject(jsonStr, new TypeReference<List<String>>() {
|
||||
});
|
||||
setColDataListForQuantity(toCellDataJo, row, col, addList, greens);
|
||||
}
|
||||
|
||||
public static void setColDataList(JSONObject toCellDataJo, int row, String col, List<String> addList) {
|
||||
for (int r = row; r < row + addList.size(); r++) {
|
||||
JSONObject jo = toCellDataJo.getJSONObject(r + "");
|
||||
@ -167,9 +258,179 @@ public class SheetUtils {
|
||||
}
|
||||
|
||||
public static void setColDataList(JSONObject toCellDataJo, int row, String col, String jsonStr) {
|
||||
List<String> addList = JSON.parseObject(jsonStr,new TypeReference<List<String>>(){});
|
||||
List<String> addList = JSON.parseObject(jsonStr, new TypeReference<List<String>>() {
|
||||
});
|
||||
setColDataList(toCellDataJo, row, col, addList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取val
|
||||
*/
|
||||
public static String getColVal(JSONObject cellData, int row, String d) {
|
||||
return Optional.ofNullable(cellData.getJSONObject(row + "")).map(m -> m.getJSONObject(getColNum(d))).map(m -> m.getString("v")).orElse(null);
|
||||
}
|
||||
|
||||
public static JSONObject getColJsonObject(JSONObject cellData, int row, String col) {
|
||||
return Optional.ofNullable(cellData.getJSONObject(row + "")).map(m -> m.getJSONObject(getColNum(col))).orElse(null);
|
||||
}
|
||||
|
||||
public static void setCol(JSONObject cellData, int row, String col, String v, int center, int t) {
|
||||
setCol(cellData, row, Integer.parseInt(getColNum(col)), v, center, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cellData
|
||||
* @param row
|
||||
* @param col
|
||||
* @param v
|
||||
* @param center
|
||||
* @param t 1 表示字符串,2 表示数字,3 表示布尔值,4 表示强制文本
|
||||
*/
|
||||
public static void setCol(JSONObject cellData, int row, int col, String v, int center, int t) {
|
||||
cellData.putIfAbsent(row + "", new JoBuilder().build());
|
||||
String s;
|
||||
if (Objects.equals(center, 1)) {
|
||||
s = leftStyle;
|
||||
} else if (Objects.equals(center, 3)) {
|
||||
s = rightStyle;
|
||||
} else {
|
||||
s = centerStyle;
|
||||
}
|
||||
cellData.getJSONObject(row + "").put(col + "", new JoBuilder().put("s", s).put("t", t).put("v", v).build());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cellData
|
||||
* @param row
|
||||
* @param col
|
||||
* @param v
|
||||
* @param center 1左 2中 3右
|
||||
*/
|
||||
public static void setColFunction(JSONObject cellData, int row, int col, String v, int center) {
|
||||
cellData.putIfAbsent(row + "", new JoBuilder().build());
|
||||
String s;
|
||||
if (Objects.equals(center, 1)) {
|
||||
s = leftStyle;
|
||||
} else if (Objects.equals(center, 3)) {
|
||||
s = rightStyle;
|
||||
} else {
|
||||
s = centerStyle;
|
||||
}
|
||||
cellData.getJSONObject(row + "").put(col + "", new JoBuilder().put("s", s).put("t", 2).put("f", v).build());
|
||||
}
|
||||
|
||||
public static void setColFunction(JSONObject cellData, int row, String col, String v, int center) {
|
||||
setColFunction(cellData, row, Integer.parseInt(getColNum(col)), v, center);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置默认样式
|
||||
*
|
||||
* @param rootJo
|
||||
*/
|
||||
public static void setDefaultStyle(JSONObject rootJo) {
|
||||
JSONObject styles = rootJo.getJSONObject("styles");
|
||||
styles.put(leftStyle, JSON.parseObject(getStyle(1)));
|
||||
styles.put(centerStyle, JSON.parseObject(getStyle(2)));
|
||||
styles.put(rightStyle, JSON.parseObject(getStyle(3)));
|
||||
String gs = "{\n" +
|
||||
" \"ff\": \"Arial\",\n" +
|
||||
" \"fs\": 11,\n" +
|
||||
" \"it\": 0,\n" +
|
||||
" \"bl\": 0,\n" +
|
||||
" \"ul\": {\n" +
|
||||
" \"s\": 0,\n" +
|
||||
" \"cl\": {\n" +
|
||||
" \"rgb\": \"rgb(0,0,0)\"\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" \"st\": {\n" +
|
||||
" \"s\": 0,\n" +
|
||||
" \"cl\": {\n" +
|
||||
" \"rgb\": \"rgb(0,0,0)\"\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" \"ol\": {\n" +
|
||||
" \"s\": 0,\n" +
|
||||
" \"cl\": {\n" +
|
||||
" \"rgb\": \"rgb(0,0,0)\"\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" \"tr\": {\n" +
|
||||
" \"a\": 0,\n" +
|
||||
" \"v\": 0\n" +
|
||||
" },\n" +
|
||||
" \"td\": 0,\n" +
|
||||
" \"cl\": {\n" +
|
||||
" \"rgb\": \"rgb(0,0,0)\"\n" +
|
||||
" },\n" +
|
||||
" \"bg\": {\n" +
|
||||
" \"rgb\": \"rgb(204,255,204)\"\n" +
|
||||
" },\n" +
|
||||
" \"ht\": 2,\n" +
|
||||
" \"vt\": 2,\n" +
|
||||
" \"tb\": 3,\n" +
|
||||
" \"pd\": {\n" +
|
||||
" \"t\": 0,\n" +
|
||||
" \"b\": 2,\n" +
|
||||
" \"l\": 2,\n" +
|
||||
" \"r\": 2\n" +
|
||||
" },\n" +
|
||||
" \"bd\": {\n" +
|
||||
" \"r\": {\n" +
|
||||
" \"cl\": {\n" +
|
||||
" \"rgb\": \"rgb(0,0,0)\"\n" +
|
||||
" },\n" +
|
||||
" \"s\": 1\n" +
|
||||
" },\n" +
|
||||
" \"b\": {\n" +
|
||||
" \"cl\": {\n" +
|
||||
" \"rgb\": \"rgb(0,0,0)\"\n" +
|
||||
" },\n" +
|
||||
" \"s\": 1\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
styles.put(greenQuantityStyle, JSON.parseObject(gs));
|
||||
}
|
||||
|
||||
/**
|
||||
* 有边框和居中、靠右对齐等
|
||||
*
|
||||
* @param ht
|
||||
* @return
|
||||
*/
|
||||
private static String getStyle(int ht) {
|
||||
String s = "{\n" +
|
||||
" \"bd\": {\n" +
|
||||
" \"t\": {\n" +
|
||||
" \"s\": 1,\n" +
|
||||
" \"cl\": {\n" +
|
||||
" \"rgb\": \"#000000\"\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" \"b\": {\n" +
|
||||
" \"s\": 1,\n" +
|
||||
" \"cl\": {\n" +
|
||||
" \"rgb\": \"#000000\"\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" \"l\": {\n" +
|
||||
" \"s\": 1,\n" +
|
||||
" \"cl\": {\n" +
|
||||
" \"rgb\": \"#000000\"\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" \"r\": {\n" +
|
||||
" \"s\": 1,\n" +
|
||||
" \"cl\": {\n" +
|
||||
" \"rgb\": \"#000000\"\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" \"ht\": " + ht + ",\n" +
|
||||
"\"vt\": 2" +
|
||||
"}";
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user