Commit 882b9c95 authored by Fuzy's avatar Fuzy

修正

parent bf12d4b9
package com.ruoyi.system.controller;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.model.power.dto.ElectricityIntoTheParameterDto;
import com.ruoyi.system.model.power.dto.PowerDisplayDto;
import com.ruoyi.system.service.PowerDisplayService;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -28,7 +29,7 @@ public class PowerDisplayController {
* @return
*/
@PostMapping("/peek")
public AjaxResult peek(@RequestBody List<PowerDisplayDto> powerDisplayDtoList) {
public AjaxResult peek(@RequestBody List<ElectricityIntoTheParameterDto> powerDisplayDtoList) {
powerDisplayService.peek(powerDisplayDtoList);
return new AjaxResult(200, "成功");
}
......
package com.ruoyi.system.mapper;
import com.ruoyi.system.model.power.dao.PowerClassificationQueryDao;
import com.ruoyi.system.model.power.dao.PowerControlDao;
import com.ruoyi.system.model.power.dto.PowerDisplayDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -14,5 +15,7 @@ import java.util.List;
public interface PowerDisplayMapper {
List<PowerClassificationQueryDao> selectClassificationToMid(@Param("id") String mindId);
void insert(List<PowerDisplayDto> list);
void insert(@Param("list") List<PowerDisplayDto> list);
List<PowerControlDao> selControl(@Param("id") String mindId);
}
......@@ -13,6 +13,8 @@ public class PowerClassificationQueryDao {
private String levelOneClassification;
// 二级分类
private String levelTwoClassification;
// 三级分类
private String levelThreeClassification;
// 项目名
private String classificationName;
......@@ -40,6 +42,14 @@ public class PowerClassificationQueryDao {
this.classificationName = classificationName;
}
public String getLevelThreeClassification() {
return levelThreeClassification;
}
public void setLevelThreeClassification(String levelThreeClassification) {
this.levelThreeClassification = levelThreeClassification;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
......
package com.ruoyi.system.model.power.dao;
import lombok.Data;
/**
* 2024/8/26
* 列与字段对照
*/
@Data
public class PowerControlDao {
private String column;
private String field;
}
package com.ruoyi.system.model.power.dto;
import lombok.Data;
import java.io.Serializable;
/**
* 2024/8/26
*/
@Data
public class ElectricityIntoTheParameterDto implements Serializable {
private String row;
private String coloumn;
private String value;
private String date;
private String mindId;
}
......@@ -46,4 +46,6 @@ public class PowerDisplayDto {
private String levelOneClassification;
// 二级分类
private String levelTwoClassification;
// 三级分类
private String levelThreeClassification;
}
package com.ruoyi.system.model.rule;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import java.io.Serializable;
import java.util.List;
public class RuleRequestModel implements Serializable {
......@@ -18,6 +16,26 @@ public class RuleRequestModel implements Serializable {
private JSONArray rules;
private String summary;
private String type;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}
public String getId() {
return id;
}
......
package com.ruoyi.system.service;
import com.ruoyi.system.model.power.dto.PowerDisplayDto;
import com.ruoyi.system.model.power.dto.ElectricityIntoTheParameterDto;
import java.util.List;
......@@ -8,5 +8,5 @@ import java.util.List;
* 2024/7/30
*/
public interface PowerDisplayService {
void peek(List<PowerDisplayDto> powerDisplayDtoList);
void peek(List<ElectricityIntoTheParameterDto> powerDisplayDtoList);
}
......@@ -2,14 +2,20 @@ package com.ruoyi.system.service.impl;
import com.ruoyi.system.mapper.PowerDisplayMapper;
import com.ruoyi.system.model.power.dao.PowerClassificationQueryDao;
import com.ruoyi.system.model.power.dao.PowerControlDao;
import com.ruoyi.system.model.power.dto.ElectricityIntoTheParameterDto;
import com.ruoyi.system.model.power.dto.PowerDisplayDto;
import com.ruoyi.system.service.PowerDisplayService;
import com.ruoyi.system.service.impl.saveOnTheLargeScreenPower.LinXi;
import com.ruoyi.system.service.impl.saveOnTheLargeScreenPower.SaveOnTheLargeScreenImpl;
import com.ruoyi.system.service.impl.saveOnTheLargeScreenPower.*;
import org.springframework.stereotype.Service;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
/**
* 2024/7/30
......@@ -23,16 +29,75 @@ public class PowerDisplayServiceImpl implements PowerDisplayService {
}
@Override
public void peek(List<PowerDisplayDto> powerDisplayDtoList) {
String mindId = powerDisplayDtoList.get(0).getMindId().replaceAll(" ", "");
public void peek(List<ElectricityIntoTheParameterDto> electricityIntoTheParameterDtoDtoList) {
String mindId = electricityIntoTheParameterDtoDtoList.get(0).getMindId().replaceAll(" ", "");
List<PowerControlDao> controlList = powerDisplayMapper.selControl(mindId);
List<PowerDisplayDto> powerDisplayDtoList = new ArrayList<>();
Class<PowerDisplayDto> powerDisplayDtoClass = PowerDisplayDto.class;
AtomicBoolean b = new AtomicBoolean(false);
electricityIntoTheParameterDtoDtoList.parallelStream().forEach(v -> {
PowerDisplayDto displayDto;
if (mindId.equals("011704") && v.getRow().equals("电价(含税)")) return;
if (powerDisplayDtoList.size() > 0) {
b.set(powerDisplayDtoList.parallelStream().anyMatch(a -> a.getClassificationName().equals(v.getRow())));
}
if (b.get()) {
displayDto = powerDisplayDtoList.parallelStream().filter(a -> a.getClassificationName().equals(v.getRow())).findFirst().get();
} else {
displayDto = new PowerDisplayDto();
displayDto.setClassificationName(v.getRow());
powerDisplayDtoList.add(displayDto);
}
Optional<PowerControlDao> first = controlList.parallelStream().filter(a -> a.getColumn().equals(v.getColoumn())).findFirst();
if (first.isPresent() && first.get().getColumn() != null && first.get().getField() != null) {
PowerControlDao powerControlDao = first.get();
try {
Method method = powerDisplayDtoClass.getMethod("set" + powerControlDao.getField(), String.class);
method.invoke(displayDto, v.getValue());
} catch (Exception e) {
e.printStackTrace();
}
}
b.set(false);
});
List<PowerClassificationQueryDao> dao = powerDisplayMapper.selectClassificationToMid(mindId);
SaveOnTheLargeScreenImpl saveOnTheLargeScreen = null;
List<String> asList = Arrays.asList("011704");
if (asList.contains(mindId)) {
List<String> linXi = Arrays.asList("011704");
List<String> lvJiaTuo = Arrays.asList("011702");
List<String> danHou = Arrays.asList("011204");
List<String> dongHuanTuo = Arrays.asList("010102");
if (linXi.contains(mindId)) {
List<ElectricityIntoTheParameterDto> collect = electricityIntoTheParameterDtoDtoList.parallelStream().filter(v -> v.getRow().equals("电价(含税)")).collect(Collectors.toList());
if (collect.size() != 0) {
collect.parallelStream().forEach(v -> {
Optional<PowerControlDao> first = controlList.parallelStream().filter(a -> a.getColumn().equals(v.getColoumn())).findFirst();
try {
if (first.isPresent()) {
PowerControlDao powerControlDao = first.get();
Method method = powerDisplayDtoClass.getMethod("set" + powerControlDao.getField(), String.class);
for (PowerDisplayDto displayDto : powerDisplayDtoList) {
method.invoke(displayDto, v.getValue());
}
}
} catch (Exception e) {
e.printStackTrace();
}
});
}
saveOnTheLargeScreen = new SaveOnTheLargeScreenImpl(new LinXi());
} else if (lvJiaTuo.contains(mindId)) {
saveOnTheLargeScreen = new SaveOnTheLargeScreenImpl(new LvJiaTuo());
} else if (danHou.contains(mindId)) {
saveOnTheLargeScreen = new SaveOnTheLargeScreenImpl(new DanHou());
} else if (dongHuanTuo.contains(mindId)) {
saveOnTheLargeScreen = new SaveOnTheLargeScreenImpl(new DongHuanTuo());
}
if (saveOnTheLargeScreen != null) {
List<PowerDisplayDto> list = saveOnTheLargeScreen.save(mindId, powerDisplayDtoList, dao);
list.parallelStream().forEach(v -> {
if (v.getLevelOneClassification() == null || "".equals(v.getLevelOneClassification()))
v.setLevelOneClassification("其他");
});
powerDisplayMapper.insert(list);
}
}
......
......@@ -2,22 +2,15 @@ package com.ruoyi.system.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.mapper.RuleMapper;
import com.ruoyi.system.model.rule.RuleModel;
import com.ruoyi.system.model.rule.RuleRequestModel;
import com.ruoyi.system.service.RuleService;
import org.springframework.stereotype.Service;
import java.io.DataInput;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.IntStream;
@Service
public class RuleServiceImpl implements RuleService {
......
package com.ruoyi.system.service.impl.saveOnTheLargeScreenPower;
import com.ruoyi.system.model.power.dao.PowerClassificationQueryDao;
import com.ruoyi.system.model.power.dto.PowerDisplayDto;
import java.math.BigDecimal;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* 2024/8/19
*/
public class DanHou implements SaveOnTheLargeScreen{
@Override
public List<PowerDisplayDto> save(String mindId, List<PowerDisplayDto> powerDisplayDtoList, List<PowerClassificationQueryDao> dao) {
powerDisplayDtoList.parallelStream().forEach(v -> {
for (PowerClassificationQueryDao queryDao : dao) {
if (v.getClassificationName() != null && v.getClassificationName().equals(queryDao.getClassificationName())) {
v.setLevelOneClassification(queryDao.getLevelOneClassification());
v.setLevelTwoClassification(queryDao.getLevelTwoClassification());
v.setLevelThreeClassification(queryDao.getLevelThreeClassification());
break;
}
}
});
Optional<PowerDisplayDto> first = powerDisplayDtoList.parallelStream().filter(v -> "合计".equals(v.getClassificationName()) && "辅助生产用电".equals(v.getLevelThreeClassification())).findFirst();
Optional<PowerDisplayDto> first1 = powerDisplayDtoList.parallelStream().filter(v -> "风选厂".equals(v.getClassificationName()) && "风选用电".equals(v.getLevelThreeClassification())).findFirst();
Optional<PowerDisplayDto> first4 = powerDisplayDtoList.parallelStream().filter(v -> "崔矿供应".equals(v.getClassificationName()) && "辅助生产用电".equals(v.getLevelThreeClassification())).findFirst();
Optional<PowerDisplayDto> first5 = powerDisplayDtoList.parallelStream().filter(v -> "南留庄供应".equals(v.getClassificationName()) && "辅助生产用电".equals(v.getLevelThreeClassification())).findFirst();
Optional<PowerDisplayDto> first6 = powerDisplayDtoList.parallelStream().filter(v -> "污水处理场".equals(v.getClassificationName()) && "辅助生产用电".equals(v.getLevelThreeClassification())).findFirst();
// 减排风
sub(first, first1);
// 加单侯矿供应
add(first, first4);
add(first, first5);
add(first, first6);
Optional<PowerDisplayDto> first2 = powerDisplayDtoList.parallelStream().filter(v -> "原煤电量".equals(v.getClassificationName()) && "生产用电".equals(v.getLevelThreeClassification())).findFirst();
Optional<PowerDisplayDto> first3 = powerDisplayDtoList.parallelStream().filter(v -> "各项小计".equals(v.getClassificationName()) && "排水用电".equals(v.getLevelThreeClassification())).findFirst();
List<PowerDisplayDto> collect = powerDisplayDtoList.parallelStream().filter(v -> "研发支出".equals(v.getLevelOneClassification())).collect(Collectors.toList());
// 减排水
sub(first2, first3);
// 减研发
if (first2.isPresent() && collect.size() != 0){
for (PowerDisplayDto dto : collect) {
sub(first2, Optional.of(dto));
}
}
return powerDisplayDtoList;
}
private void sub(Optional<PowerDisplayDto> first, Optional<PowerDisplayDto> first1) {
if (first.isPresent() && first1.isPresent()) {
PowerDisplayDto dto = first.get();
PowerDisplayDto dto1 = first1.get();
dto.setPowerTotal(new BigDecimal(dto.getPowerTotal()).subtract(new BigDecimal(dto1.getPowerTotal() != null && !"".equals(dto1.getPowerTotal()) ? dto1.getPowerTotal() : "0")) + "");
dto.setElectricityTotal(new BigDecimal(dto.getElectricityTotal()).subtract(new BigDecimal(dto1.getElectricityTotal() != null && !"".equals(dto1.getElectricityTotal()) ? dto1.getElectricityTotal() : "0")) + "");
}
}
private void add(Optional<PowerDisplayDto> first, Optional<PowerDisplayDto> first4) {
if (first.isPresent() && first4.isPresent()) {
PowerDisplayDto dto = first.get();
PowerDisplayDto dto1 = first4.get();
dto.setPowerTotal(new BigDecimal(dto.getPowerTotal()).add(new BigDecimal(dto1.getPowerTotal() != null && !"".equals(dto1.getPowerTotal()) ? dto1.getPowerTotal() : "0")) + "");
dto.setElectricityTotal(new BigDecimal(dto.getElectricityTotal()).add(new BigDecimal(dto1.getElectricityTotal() != null && !"".equals(dto1.getElectricityTotal()) ? dto1.getElectricityTotal() : "0")) + "");
}
}
}
package com.ruoyi.system.service.impl.saveOnTheLargeScreenPower;
import com.ruoyi.system.model.power.dao.PowerClassificationQueryDao;
import com.ruoyi.system.model.power.dto.PowerDisplayDto;
import java.math.BigDecimal;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* 2024/8/14
*/
public class LvJiaTuo implements SaveOnTheLargeScreen {
@Override
public List<PowerDisplayDto> save(String mindId, List<PowerDisplayDto> powerDisplayDtoList, List<PowerClassificationQueryDao> dao) {
powerDisplayDtoList.parallelStream().forEach(v -> {
for (PowerClassificationQueryDao queryDao : dao) {
if (v.getClassificationName() != null && v.getClassificationName().equals(queryDao.getClassificationName())) {
v.setLevelOneClassification(queryDao.getLevelOneClassification());
v.setLevelTwoClassification(queryDao.getLevelTwoClassification());
v.setLevelThreeClassification(queryDao.getLevelThreeClassification());
break;
}
}
});
List<PowerDisplayDto> rDExpendituresOnRawCoal = powerDisplayDtoList.parallelStream().filter(v -> v.getLevelOneClassification().equals("研发支出") && "原煤".equals(v.getLevelThreeClassification())).collect(Collectors.toList());
List<PowerDisplayDto> rDSpendingWashesCoal = powerDisplayDtoList.parallelStream().filter(v -> v.getLevelOneClassification().equals("研发支出") && "洗煤".equals(v.getLevelThreeClassification())).collect(Collectors.toList());
Optional<PowerDisplayDto> onRawCoal = powerDisplayDtoList.parallelStream().filter(v -> v.getClassificationName().equals("生产成本原煤线电费")).findFirst();
Optional<PowerDisplayDto> washesCoal = powerDisplayDtoList.parallelStream().filter(v -> v.getClassificationName().equals("生产成本洗煤线电费")).findFirst();
if (onRawCoal.isPresent()) {
PowerDisplayDto displayDto = onRawCoal.get();
for (PowerDisplayDto dto : rDExpendituresOnRawCoal) {
displayDto.setElectricityTotal(new BigDecimal(displayDto.getElectricityTotal()).subtract(new BigDecimal(dto.getElectricityTotal() != null ? dto.getElectricityTotal() : "0")) + "");
displayDto.setPowerTotal(new BigDecimal(displayDto.getPowerTotal()).subtract(new BigDecimal(dto.getPowerTotal() != null ? dto.getPowerTotal() : "0")) + "");
}
}
if (washesCoal.isPresent()) {
PowerDisplayDto displayDto = washesCoal.get();
for (PowerDisplayDto dto : rDSpendingWashesCoal) {
displayDto.setElectricityTotal(new BigDecimal(displayDto.getElectricityTotal()).subtract(new BigDecimal(dto.getElectricityTotal() != null ? dto.getElectricityTotal() : "0")) + "");
displayDto.setPowerTotal(new BigDecimal(displayDto.getPowerTotal()).subtract(new BigDecimal(dto.getPowerTotal() != null ? dto.getPowerTotal() : "0")) + "");
}
}
return powerDisplayDtoList;
}
}
......@@ -8,7 +8,8 @@
level_two_classification, classification_name,
power_total, power_tip, power_peak, power_flat, power_valley,
electricity_total, electricity_tip, electricity_peak, electricity_flat, electricity_valley,
electricity_price_tip, electricity_price_peak, electricity_price_flat, electricity_price_valley)
electricity_price_tip, electricity_price_peak, electricity_price_flat, electricity_price_valley,
level_three_classification)
values
<foreach collection="list" item="item" separator=",">
(#{item.dateColumn}, #{item.mindId}, #{item.levelOneClassification}, #{item.levelTwoClassification},
......@@ -17,7 +18,7 @@
, #{item.electricityTotal}, #{item.electricityTip}, #{item.electricityPeak}, #{item.electricityFlat},
#{item.electricityValley}
, #{item.electricityPriceTip}, #{item.electricityPricePeak}, #{item.electricityPriceFlat},
#{item.electricityPriceValley})
#{item.electricityPriceValley}, #{item.levelThreeClassification})
</foreach>
</insert>
......@@ -26,9 +27,15 @@
resultType="com.ruoyi.system.model.power.dao.PowerClassificationQueryDao">
select a.level_one_classification levelOneClassification,
a.level_two_classification levelTwoClassification,
a.classification_name classificationName
a.classification_name classificationName,
a.level_three_classification levelThreeClassification
from power_classification_query a
where a.mind_id = #{id}
and a.whether_it_is_enabled = '0';
</select>
<select id="selControl" resultType="com.ruoyi.system.model.power.dao.PowerControlDao">
select column_name column, field_name field
from wages_power_column_comparison
where mind_id = #{id} and type = '1'
</select>
</mapper>
\ No newline at end of file
......@@ -4,9 +4,9 @@
<insert id="save">
INSERT INTO
rule_sheet(template_id, rules, first_rule, second_rule)
rule_sheet(template_id, rules, first_rule, second_rule, summary_identification, type)
values
(#{rule.templateId}, #{s}, #{rule.firstRule}, #{rule.secondRule})
(#{rule.templateId}, #{s}, #{rule.firstRule}, #{rule.secondRule}, #{rule.summary}, #{rule.type})
</insert>
<update id="updateToId">
update rule_sheet set
......@@ -21,12 +21,18 @@
</if>
<if test="s != null and s != ''">
rules = #{s},
</if>
<if test="rule.summary != null and rule.summary != ''">
summary_identification = #{rule.summary},
</if>
<if test="rule.type != null and rule.type != ''">
type = #{rule.type},
</if>
id = #{rule.id}
where id = #{rule.id};
</update>
<select id="query" resultType="com.ruoyi.system.model.rule.RuleRequestModel">
select template_id as templateId, first_rule as firstRule, second_rule as secondRule
select template_id as templateId, first_rule as firstRule, second_rule as secondRule, summary_identification as summary, type
from rule_sheet
where template_id = #{id}
</select>
......
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