9a2d14c5 康伟

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	sk-module-equipment/src/main/java/com/skua/modules/equipment/entity/EquipmentInfo.java
2 个父辈 8eff13c1 9910378a
正在显示 20 个修改的文件 包含 390 行增加52 行删除
......@@ -287,7 +287,7 @@ public class SysCommandCentreController {
List<String> yaXisList = new ArrayList<String>();
yaXisList.addAll(fyList) ;//费用
yaXisList.addAll( waterList) ;//水
yaXisList.addAll(waterList) ;//水
stackedAreaChartDataVO.setYAxis( yaXisList );
Result<StackedAreaChartDataVO> result = new Result<>();
......
package com.skua.modules.digitaltwins;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.skua.core.api.vo.Result;
import com.skua.core.api.vo.TransTreeModel;
import com.skua.core.api.vo.TreeData;
import com.skua.core.context.SpringContextUtils;
import com.skua.core.util.ConvertUtils;
import com.skua.core.util.TreeUtils;
import com.skua.modules.equipment.entity.EquipmentInfo;
import com.skua.modules.equipment.service.IEquipmentInfoService;
import com.skua.modules.system.datestandard.entity.SysMonitorMetricInfo;
import com.skua.modules.system.datestandard.service.ISysMonitorMetricInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
/**
* <pre>
* 设备中心
* </pre>
* @author Li Yuanyuan
* @version V0.1, 2024年8月5日 下午5:02:16
*/
@Slf4j
@Api(tags="/数字孪生/设备中心")
@RestController
@RequestMapping("/v1/digital/equipmentAnalysis")
public class DigitalEquipmentController {
@Autowired
private IEquipmentInfoService equipmentInfoService;
@Autowired
private ISysMonitorMetricInfoService sysMonitorMetricInfoService;
/**
* 智能报警按构筑物统计
* @return
* @throws ParseException
* @author Li Yuanyuan, 2024年8月6日 下午2:54:53
* @Description: TODO(这里描述这个方法的需求变更情况)
*/
@ApiOperation(value="构筑物设备树", notes="构造构筑物和设备分组树")
@GetMapping(value = "/getEquipmentTree")
public Result<List<TreeData>> getEquipmentTree() throws ParseException{
Result<List<TreeData>> result = new Result<List<TreeData>>();
JdbcTemplate masterDB = (JdbcTemplate) SpringContextUtils.getBean("master");
//使用sql统计
String sql = "SELECT id,struct_name AS title,'root' AS pid,'struct' as tree_type FROM sys_struct_dict \r\n" +
"UNION ALL\r\n" +
"SELECT id,equipment_name,structures AS pid,'equipment' as tree_type FROM equipment_info where digital_twins_struct_code!='' and digital_twins_struct_code is not null";
List<Map<String,Object>> dataList = masterDB.queryForList(sql);
List<TransTreeModel> transTreeModels = dataList.stream().map(bo -> convertToTreeModel(bo)).collect(Collectors.toList());
List<TreeData> treeList=TreeUtils.buildTreeForParentId(transTreeModels, "root");
result.setResult(treeList);
result.setSuccess(true);
return result;
}
/**
* 将SysDcodeConfig对象数据填充到TransTreeModel中
* @param dataMap
* @return
*/
private TransTreeModel convertToTreeModel(Map<String,Object> dataMap) {
TransTreeModel transTreeModel = new TransTreeModel();
transTreeModel.setId(ConvertUtils.getString(dataMap.get("id")));
transTreeModel.setPid(ConvertUtils.getString(dataMap.get("pid")));
transTreeModel.setTitle(ConvertUtils.getString(dataMap.get("title")));
Map<String,String> map=new HashMap<String,String>();
map.put("treeType", ConvertUtils.getString(dataMap.get("tree_type")));
transTreeModel.setMap(map);
return transTreeModel;
}
/**
* 根据传入的构筑物id或设备id获取相关设备运行状态
* @param treeType
* @param ids
* @return
*/
@ApiOperation(value = "设备-设备运行状态", notes = "设备-设备运行状态,根据构筑物id/设备id获取设备状态【0停止/1运行/2故障】")
@GetMapping(value = "/queryEquipmentStatusById")
public Result<Map<String,Object>> queryEquipmentStatusById(@RequestParam(value = "treeType") String treeType,@RequestParam(value = "ids") String ids) {
Result<Map<String,Object>> result = new Result<>();
//结果接收对象
Map<String,Object> resultMap = new HashMap<String,Object>();
List<EquipmentInfo> equipmentInfoList = new ArrayList<EquipmentInfo>();
//判断参数类型,如果是构筑物类型,则先获取设备id集合,如果是设备类型,则直接使用
if("struct".equals(treeType)) {
QueryWrapper<EquipmentInfo> equipmentQueryWrapper = new QueryWrapper<>();
equipmentQueryWrapper.isNotNull("digital_twins_struct_code");
equipmentQueryWrapper.ne("digital_twins_struct_code", "");
equipmentInfoList = equipmentInfoService.list(equipmentQueryWrapper);
}else {
List<String> idList = Arrays.asList(ids.split(","));
QueryWrapper<EquipmentInfo> equipmentQueryWrapper = new QueryWrapper<>();
equipmentQueryWrapper.in("id", idList);
equipmentInfoList = equipmentInfoService.list(equipmentQueryWrapper);
}
//获取已关联设备的运行状态点
List<String> equipmentIdList = new ArrayList<>();
for(EquipmentInfo equipmentInfo : equipmentInfoList) {
equipmentIdList.add(equipmentInfo.getId());
}
//根据设备id集合获取设备运行点位
QueryWrapper<SysMonitorMetricInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("metric_type", "1");
queryWrapper.ne("metric_express1", "");
queryWrapper.isNotNull("metric_express1");
queryWrapper.in("equipment_code", equipmentIdList);
List<SysMonitorMetricInfo> sysMonitorMetricInfoList = sysMonitorMetricInfoService.list(queryWrapper);
List<String> equipmentRunPointList = new ArrayList<>();
Map<String,String> equipmentToPointMap = new HashMap<String,String>();
for(SysMonitorMetricInfo sysMonitorMetricInfo : sysMonitorMetricInfoList) {
equipmentRunPointList.add(sysMonitorMetricInfo.getId());
equipmentToPointMap.put(sysMonitorMetricInfo.getEquipmentCode(), sysMonitorMetricInfo.getId());
}
Map<String, Map<String, Object>> tempEquipmentStateMap = sysMonitorMetricInfoService.getEquipRunState(equipmentRunPointList);
for(EquipmentInfo equipmentInfo : equipmentInfoList) {
String equipmentId = equipmentInfo.getId();
String point = equipmentToPointMap.get(equipmentId);
Map<String, Object> tempMap = tempEquipmentStateMap.get(point);
if(tempMap!=null&&tempMap.size()>0) {
resultMap.put(equipmentInfo.getId(), ConvertUtils.getString(tempMap.get("value")));
}else{
resultMap.put(equipmentInfo.getId(), "-1");
}
}
result.setResult(resultMap);
return result;
}
}
......@@ -336,7 +336,7 @@
SELECT
RIGHT(LEFT( v.time, 7 ),2) AS time,
v2.sjwscll,
v2.rwscll,
f.pro_scale AS rwscll,
v2.scsj,
ROUND(v2.scsj*f.pro_scale,2) AS wsclnl,
ROUND( SUM( v.DLHJ ) / 10000, 2 ) AS dl,
......
......@@ -11,7 +11,6 @@ import com.skua.modules.custom.mapper.FCustomReportDatasetMapper;
import com.skua.modules.custom.service.IFCustomReportDatasetService;
import com.skua.modules.custom.vo.DepartWeekReportVO;
import com.skua.modules.custom.vo.FCustomReportDatasetVO;
import java.text.DecimalFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
......@@ -22,14 +21,12 @@ import com.skua.modules.report.vo.*;
import com.skua.modules.report.vo.largeScreen.*;
import com.skua.tool.util.DateUtils;
import com.skua.tool.util.JSUtils;
import io.swagger.annotations.ApiModelProperty;
import io.micrometer.core.instrument.util.TimeUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import javax.annotation.Resource;
/**
......@@ -42,6 +39,8 @@ public class FCustomReportDatasetServiceImpl extends ServiceImpl<FCustomReportDa
private FCustomReportDatasetMapper mapper;
@Resource
private CommonSqlMapper commonSqlMapper;
private static DecimalFormat df = new DecimalFormat("#.##");
/* (non-Javadoc)
* @see com.skua.modules.custom.service.IFCustomReportDatasetService#getFillReportList()
*/
......@@ -111,7 +110,7 @@ public class FCustomReportDatasetServiceImpl extends ServiceImpl<FCustomReportDa
" round(ifnull(v5.dlhj/tb.clsl_tb,0)/10000,2) qntqdh, " +
" round(100*(v4.dlhj-ifnull(v5.dlhj,0))/ifnull(v5.dlhj,v4.dlhj),2) as dhdbbhl, " +
" v6.dhgyqntqyy, " +
" round(v4.yjhl/sum(v1.CSL),2) as yyh, " +
" round(v6.yyf/sum(v1.CSL),2) as yyh, " +
" v6.yyf," +
" round(ifnull(v5.yjhl/tb.clsl_tb/10000,0),2) qntqyh, " +
" round(100*(v4.yjhl-ifnull(v5.yjhl,0))/ifnull(v5.yjhl,v4.yjhl),2) as yhdbbhl, " +
......@@ -603,21 +602,54 @@ public class FCustomReportDatasetServiceImpl extends ServiceImpl<FCustomReportDa
public Map<String, Object> reportWeekShow(String dataTime, String week) {
Map<String, Object> map = new HashMap<>();
List<DepartWeekReportVO> list = new ArrayList<>();
List<DepartWeekReportVO> hbList = new ArrayList<>();
Map<String,String> weekMap = getWeekDate(dataTime,week);
String startDate = weekMap.get("start");
String endDate = weekMap.get("end");
String startDateHb = getBeforeDate(startDate,7);
String endDateHb = getBeforeDate(endDate,7);
String field3a24 = ReportConstant.fieldDl + "," + ReportConstant.fieldYj + "," + ReportConstant.fieldWnl;
String dataViewName3a24 = ReportViewUtil.buildView(ReportConstant.view3a24, field3a24, "", startDate, endDate);
String dataViewName2119 = ReportViewUtil.buildView(ReportConstant.view2119,ReportConstant.fieldClsl, "", startDate, endDate);
list = mapper.getWeekReportData(startDate, endDate, dataViewName3a24, dataViewName2119);
String dataViewName3a24Hb = ReportViewUtil.buildView(ReportConstant.view3a24, field3a24, "", startDateHb, endDateHb);
String dataViewName2119Hb = ReportViewUtil.buildView(ReportConstant.view2119,ReportConstant.fieldClsl, "", startDateHb, endDateHb);
hbList = mapper.getWeekReportData(startDateHb, endDateHb, dataViewName3a24Hb, dataViewName2119Hb);
Map<String, Object> totalMap = getTotalData(list);
Map<String, Object> totalMapHb = getTotalData(hbList);
map.put("start", startDate);//开始时间
map.put("end", endDate);//结束时间
map.put("zclsl", "776");//处理水量合计
map.put("rjclsl", "110.7");//日均处理水量
map.put("rjclsl_hb", "2");//较上周增减量
map.put("dsdh", "0.329");//吨水电耗
map.put("dsdh_hb", "0.002");//吨水电耗较上周增减量
map.put("cnl", "3978.8");//产泥量
String zclsl = totalMap.getOrDefault("zclsl","0").toString();
map.put("zclsl", zclsl);//处理水量合计
String rjclsl = totalMap.getOrDefault("rjclsl","0").toString();
map.put("rjclsl", rjclsl);//日均处理水量
String rjclslHb = totalMapHb.getOrDefault("rjclsl","0").toString();
String rjclslStr = "";//文字描述
String dsdhStr = "";//文字描述
//较上周增减量 rjclsl - rjclslHb
if(Double.parseDouble(rjclsl)-Double.parseDouble(rjclslHb) > 0){
rjclslStr = "+"+df.format(Double.parseDouble(rjclsl)-Double.parseDouble(rjclslHb))+"万吨/日";
}else if(Double.parseDouble(rjclsl)-Double.parseDouble(rjclslHb) < 0){
rjclslStr = df.format(Double.parseDouble(rjclsl)-Double.parseDouble(rjclslHb))+"万吨/日";
}else{
rjclslStr = "持平";
}
map.put("rjclsl_hb", rjclslStr);
String dsdh = totalMap.getOrDefault("dsdh","0").toString();
map.put("dsdh", dsdh);//吨水电耗
String dsdhHb = totalMapHb.getOrDefault("dsdh","0").toString();
//吨水电耗较上周增减量 dsdh - dsdhHb
if(Double.parseDouble(dsdh)-Double.parseDouble(dsdhHb) > 0){
dsdhStr = "+"+df.format(Double.parseDouble(dsdh)-Double.parseDouble(dsdhHb))+"Kwh/吨";
}else if(Double.parseDouble(dsdh)-Double.parseDouble(dsdhHb) < 0){
dsdhStr = df.format(Double.parseDouble(dsdh)-Double.parseDouble(dsdhHb))+"Kwh/吨";
}else{
dsdhStr = "持平";
}
map.put("dsdh_hb", dsdhStr);
String cnl = totalMap.getOrDefault("cnl","0").toString();
map.put("cnl", cnl);//产泥量
map.put("list", list);
map.put("scqk", "(1)本周暂无生产情况说明");//生产情况
map.put("wxqk", "(1)本周暂无设备大修、更新情况");//
......@@ -625,4 +657,46 @@ public class FCustomReportDatasetServiceImpl extends ServiceImpl<FCustomReportDa
map.put("qt", "(1)本周暂无其他情况说明");//其他
return map;
}
private Map<String, Object> getTotalData(List<DepartWeekReportVO> list) {
Map<String, Object> map = new HashMap<>();
int num = 0;//计数
double zclsl = 0.00;//处理水量
double dsdh = 0.00;//吨水电耗
double cnl = 0.00;//产泥量
for (DepartWeekReportVO departWeekReportVO : list) {
num = num+1;
if(ConvertUtils.isNotEmpty(departWeekReportVO.getClsl())){
zclsl = zclsl + Double.parseDouble(departWeekReportVO.getClsl());
}
if(ConvertUtils.isNotEmpty(departWeekReportVO.getDsdh())){
dsdh = dsdh + Double.parseDouble(departWeekReportVO.getDsdh());
}
if(ConvertUtils.isNotEmpty(departWeekReportVO.getWnl())){
cnl = cnl + Double.parseDouble(departWeekReportVO.getWnl());
}
}
map.put("zclsl", df.format(zclsl));//处理水量合计
map.put("rjclsl", df.format(zclsl/num));//日均处理水量
map.put("dsdh", df.format(dsdh/num));//吨水电耗
map.put("cnl", df.format(cnl));//产泥量
return map;
}
/**
* 获取n天前的日期
* @param day
* @param num
* @return
*/
public static String getBeforeDate(String day,int num) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
try {
LocalDate date = LocalDate.parse(day, formatter);
LocalDate daysAgo = date.minusDays(num);
return daysAgo.format(formatter);
} catch (Exception e) {
return day;
}
}
}
......
......@@ -6,6 +6,7 @@ import com.skua.common.constant.ReportConstant;
import com.skua.common.report.ReportViewUtil;
import com.skua.core.context.BaseContextHandler;
import com.skua.core.context.SpringContextUtils;
import com.skua.core.util.ConvertUtils;
import com.skua.core.util.DateUtils;
import com.skua.modules.custom.service.IFCustomReportDatasetService;
import com.skua.modules.dataAnalysis.mapper.PowerAnalysisNewMapper;
......@@ -30,10 +31,10 @@ public class PowerAnalysisNewServiceImpl implements IPowerAnalysisNewService {
private PowerAnalysisNewMapper powerAnalysisNewMapper;
@Autowired
private WaterCountAnalysisNewMapper waterCountAnalysisNewMapper;
@Autowired
private IFCustomReportDatasetService fCustomReportDatasetService;
//时间格式
public static final SimpleDateFormat yyyyMM = new SimpleDateFormat("yyyy-MM");
//格式化小数
private static DecimalFormat df = new DecimalFormat("#.##");
/**
* 功能描述: <br>电耗分析统计
......@@ -53,6 +54,12 @@ public class PowerAnalysisNewServiceImpl implements IPowerAnalysisNewService {
//本月总的电耗,处理水量,吨水电耗
Map result = powerAnalysisNewMapper.totalPowerConsumptionAnalysis(thisDataViewName3a24, thisDataViewName2119,
lastDataViewName3a24, lastDataViewName2119, thisMonth, lastMonth, departIds);
List<Map<String, Object>> thisList = powerAnalysisNewMapper.powerConsumptionDistribution(thisDataViewName3a24,thisDataViewName2119, thisMonth, departIds);
List<Map<String, Object>> lastList = powerAnalysisNewMapper.powerConsumptionDistribution(lastDataViewName3a24,lastDataViewName2119, lastMonth, departIds);
result = updateDSDH(result,thisList,lastList);
//向前6个月的电耗,处理水量分布
String precedingTime = getSixMonth(thisMonth);
String start = precedingTime+"-01";
......@@ -60,14 +67,47 @@ public class PowerAnalysisNewServiceImpl implements IPowerAnalysisNewService {
String dataViewName3a24 = ReportViewUtil.buildView(ReportConstant.view3a24,"DLHJ", departIds, start, end);
String dataViewName2119 = ReportViewUtil.buildView(ReportConstant.view2119,"CSL", departIds, start, end);
List<Map> SixMonthPowerConsumption = powerAnalysisNewMapper.querySixMonthPowerConsumption(dataViewName3a24, dataViewName2119, start, end, departIds);
resultMap.put("totalResult", result);
resultMap.put("dataList", SixMonthPowerConsumption);
return resultMap;
}
//更新吨水电耗计算逻辑
private Map updateDSDH(Map result, List<Map<String, Object>> thisList, List<Map<String, Object>> lastList) {
int thisnNum = 0;int lastNum = 0;//平均值计数
double thisDsdh = 0.00;double lastDsdh = 0.00;//吨水电耗
String bydsdh = "0.00";String sydsdh = "0.00";
for (Map<String, Object> map : thisList) {
if(ConvertUtils.isNotEmpty(map.get("ydl"))&&ConvertUtils.isNotEmpty(map.get("clsl"))){
if(!"0.0".equals(String.valueOf(map.get("ydl")))&&!"0.0".equals(String.valueOf(map.get("clsl")))){
thisDsdh = thisDsdh + Double.parseDouble(map.get("dsdh").toString());
thisnNum = thisnNum + 1;
}
}
}
if(thisnNum > 0){
bydsdh = df.format(thisDsdh/thisnNum);
result.put("BYDSHDL",bydsdh);
}
for (Map<String, Object> map : lastList) {
if(ConvertUtils.isNotEmpty(map.get("ydl"))&&ConvertUtils.isNotEmpty(map.get("clsl"))){
if(!"0.0".equals(String.valueOf(map.get("ydl")))&&!"0.0".equals(String.valueOf(map.get("clsl")))){
lastDsdh = lastDsdh + Double.parseDouble(map.get("dsdh").toString());
lastNum = lastNum + 1;
}
}
}
if(lastNum > 0){
sydsdh = df.format(lastDsdh/lastNum);
result.put("SYDSHDL",sydsdh);
}
bydsdh = result.get("BYDSHDL").toString();
sydsdh = result.get("SYDSHDL").toString();
result.put("DSHDLCZ",df.format(Double.parseDouble(bydsdh)-Double.parseDouble(sydsdh)));
return result;
}
public static String getSixMonth(String month) {
try {
Date currdate = yyyyMM.parse(month);
......@@ -87,7 +127,7 @@ public class PowerAnalysisNewServiceImpl implements IPowerAnalysisNewService {
String dataViewName3a24 = ReportViewUtil.buildViewLike(ReportConstant.view3a24,"DLHJ", departIds, time);
String dataViewName2119 = ReportViewUtil.buildViewLike(ReportConstant.view2119,"CSL", departIds, time);
Map<String, Object> result = new HashMap<>();
List<Map<String, Object>> distributionMap = powerAnalysisNewMapper.powerConsumptionDistribution(dataViewName3a24,dataViewName2119,time,departIds);
List<Map<String, Object>> distributionList = powerAnalysisNewMapper.powerConsumptionDistribution(dataViewName3a24,dataViewName2119,time,departIds);
List<Map<String, Object>> keys = Lists.newArrayList();
Integer count1 = 0, count2 = 0, count3 = 0, count4 = 0;
Map<String, Object> tmp1 = Maps.newTreeMap();
......@@ -107,7 +147,7 @@ public class PowerAnalysisNewServiceImpl implements IPowerAnalysisNewService {
tmp4.put("name", "高电耗");
tmp4.put("id", "4");
for (Map<String, Object> v : distributionMap) {
for (Map<String, Object> v : distributionList) {
Double dsdh = (Double) v.get("dsdh");
if (dsdh > 0.7) {
count4++;
......@@ -128,7 +168,7 @@ public class PowerAnalysisNewServiceImpl implements IPowerAnalysisNewService {
keys.add(tmp3);
keys.add(tmp4);
result.put("distributionMap", keys);
result.put("factoryDistributionList", distributionMap);
result.put("factoryDistributionList", distributionList);
return result;
}
......
......@@ -54,7 +54,7 @@
<select id="getFyData" resultType="com.skua.modules.report.vo.ReportDateTrendVO">
SELECT
t.month AS time,
ROUND( SUM( IFNULL(t.cost,0) ), 2 ) AS value
ROUND( SUM( IFNULL(t.cost,0) )/10000, 2 ) AS value
FROM
report_electric_cost t
WHERE
......
......@@ -7,6 +7,7 @@ import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.json.JSONObject;
import com.skua.core.context.BaseContextHandler;
import com.skua.core.query.QueryGenerator;
import org.apache.commons.lang.StringUtils;
......@@ -176,6 +177,12 @@ public class EquipmentController {
public Result<List<EquipmentStatisticVO>> statisticsCtrl(EquipmentStatisticDTO equipmentStatisticDTO) throws Exception {
Result<List<EquipmentStatisticVO>> result = new Result<>();
List<EquipmentStatisticVO> voList = new ArrayList<>();
String departs = "";//机构
if(ConvertUtils.isNotEmpty(equipmentStatisticDTO.getDepartId())){
departs = equipmentStatisticDTO.getDepartId();
}else{
departs = BaseContextHandler.getDeparts();
}
// 统计 departId => 所属机构
if (equipmentStatisticDTO.getShowDepartId()) {
List<Map<String, Object>> departIdMapList = WrapperFactory.joinWrapper()
......@@ -185,6 +192,7 @@ public class EquipmentController {
.innerJoin(EquipmentExt.class, EquipmentExt.class.getDeclaredField("infoId"), EquipmentInfo.class.getDeclaredField("id"))
.where()
.eq(StringUtils.isNotEmpty(equipmentStatisticDTO.getIsSpecial()), "is_special", equipmentStatisticDTO.getIsSpecial())
.in(true,"depart_id", Arrays.asList(departs.split(",")))
.groupBy(true, "depart_id")
.queryWrapperForList();
EquipmentStatisticVO departIdVO = new EquipmentStatisticVO();
......@@ -213,6 +221,7 @@ public class EquipmentController {
.innerJoin(EquipmentExt.class, EquipmentExt.class.getDeclaredField("infoId"), EquipmentInfo.class.getDeclaredField("id"))
.where()
.eq(StringUtils.isNotEmpty(equipmentStatisticDTO.getIsSpecial()), "is_special", equipmentStatisticDTO.getIsSpecial())
.in(true,"depart_id", Arrays.asList(departs.split(",")))
.groupBy(true, "asset_type")
.queryWrapperForList();
EquipmentStatisticVO assetTypeVO = new EquipmentStatisticVO();
......@@ -238,6 +247,7 @@ public class EquipmentController {
.innerJoin(EquipmentExt.class, EquipmentExt.class.getDeclaredField("infoId"), EquipmentInfo.class.getDeclaredField("id"))
.where()
.eq(StringUtils.isNotEmpty(equipmentStatisticDTO.getIsSpecial()), "is_special", equipmentStatisticDTO.getIsSpecial())
.in(true,"depart_id", Arrays.asList(departs.split(",")))
.eq(true, "asset_type", "assets-material-type")
.groupBy(true, "supplies_type")
.queryWrapperForList();
......@@ -264,6 +274,7 @@ public class EquipmentController {
.leftJoin(EquipmentExt.class, EquipmentExt.class.getDeclaredField("infoId"), EquipmentInfo.class.getDeclaredField("id"))
.where()
.eq(StringUtils.isNotEmpty(equipmentStatisticDTO.getIsSpecial()), "is_special", equipmentStatisticDTO.getIsSpecial())
.in(true,"depart_id", Arrays.asList(departs.split(",")))
.groupBy(true, "equipment_top_type")
.queryWrapperForList();
EquipmentStatisticVO equipmentTypeVO = new EquipmentStatisticVO();
......@@ -502,9 +513,8 @@ public class EquipmentController {
.like(StringUtils.isNotEmpty(equipmentCode), "equipment_code", equipmentCode)
.eq(StringUtils.isNotEmpty(equipmentStatus), "equipment_status", equipmentStatus)
.like(StringUtils.isNotEmpty(installPosition), EquipmentInfo::getInstallPosition, installPosition)
.eq(StringUtils.isNotEmpty(equipmentDTO.getEquipmentInfo().getId()), "equipment_info.id", equipmentDTO.getEquipmentInfo().getId());
.eq(StringUtils.isNotEmpty(equipmentDTO.getEquipmentInfo().getId()), "equipment_info.id", equipmentDTO.getEquipmentInfo().getId())
.orderBy(true,false,"equipment_info.create_time");
Page<Map<String, Object>> mapPage = (Page<Map<String, Object>>) base.queryForPage(new Page<>(equipmentDTO.getPageNo(), equipmentDTO.getPageSize()));
// 转义
......@@ -818,4 +828,19 @@ public class EquipmentController {
return result;
}
@ApiOperation(value = "设备台账-孪生体批量配置", notes = "设备台账-孪生体批量配置")
@PostMapping(value = "/batchConfigDigitaltwins")
public Result<String> batchConfigDigitaltwins(@RequestBody JSONObject jsonObject) {
Result<String> result = new Result<>();
try {
equipmentInfoService.batchConfigDigitaltwins(jsonObject);
result.setSuccess(true);
result.setResult("批量配置成功");
} catch (Exception e) {
e.printStackTrace();
result.error500("批量配置失败");
}
return result;
}
}
......
......@@ -120,7 +120,7 @@ public class EquipmentInController {
private ThreadPoolTaskExecutor taskExecutor;
@Autowired
private ISuppliesWarehouseService suppliesWarehouseService;
@CustomExceptionAnno(description = "入库-详情")
@AutoLog(value = "入库-详情")
......@@ -147,7 +147,7 @@ public class EquipmentInController {
"\tINNER JOIN equipment_in_child AS eic ON ei.id = eic.in_id\n" +
"\tLEFT JOIN equipment_sparepart_supplies AS es ON eic.sparepart_id = es.id\n" +
"\tLEFT JOIN equipment_sparepart_type tp ON es.sparepart_type = tp.id\n" +
" WHERE ei.id in( '" + inId + "')";
List<Map<String, Object>> mapList = iCommonSqlService.queryForList(sql);
JSONObject jsonObject = sysCommonDictService.translateTDictValue(equipmentIn);
......@@ -175,7 +175,6 @@ public class EquipmentInController {
Result<IPage<EquipmentInVO>> result = new Result<>();
EquipmentIn equipmentIn = BeanExtUtils.bean2Bean(equipmentInDTO, EquipmentIn.class);
QueryWrapper<EquipmentIn> queryWrapper = QueryGenerator.initQueryWrapper(equipmentIn, req.getParameterMap());
if (StringUtils.isNotEmpty(equipmentInDTO.getStartTime())) {
queryWrapper.ge("in_date", equipmentInDTO.getStartTime() + " 00:00:00");
}
......@@ -190,8 +189,8 @@ public class EquipmentInController {
Page<EquipmentInVO> voPage = new Page<>(pageNo, pageSize);
Page<EquipmentIn> page = new Page<EquipmentIn>(pageNo, pageSize);
IPage<EquipmentIn> equipmentInIPage = equipmentInService.page(page, queryWrapper);
List<EquipmentIn> totalList = equipmentInService.list(queryWrapper);
IPage<EquipmentIn> equipmentInIPage = page.setRecords(totalList);
List<EquipmentIn> equipmentInList = equipmentInIPage.getRecords();
equipmentInList.stream().map(data -> "'" + data.getId() + "'").collect(Collectors.joining(","));
......@@ -199,7 +198,8 @@ public class EquipmentInController {
if ("departIdName".equals(targetFieldName) && srcFieldVal != null) {
return sysDepartVal2KeyMap.getOrDefault(srcFieldVal, "");
} else if ("sparepartName".equals(targetFieldName)) {
String sql2 = "select es.sparepart_name as sparepartName ,es.sparepart_type from equipment_sparepart_supplies as es inner join (select sparepart_id from equipment_in_child where in_id = '" + srcFieldVal + "') as tmp on es.id = tmp.sparepart_id";
String sql2 = "select es.sparepart_name as sparepartName ,es.sparepart_type from equipment_sparepart_supplies as es " +
"inner join (select sparepart_id from equipment_in_child where in_id = '" + srcFieldVal + "') as tmp on es.id = tmp.sparepart_id";
List<Map<String, Object>> sparePartList = iCommonSqlService.queryForList(sql2);
Map<String, Integer> name2CountMap = new HashMap<>();
if (sparePartList != null && !sparePartList.isEmpty() && sparePartList.get(0) != null) {
......@@ -225,7 +225,7 @@ public class EquipmentInController {
if (StringUtils.isNotEmpty(equipmentInDTO.getSparepartName())) {
equipmentInVOList = equipmentInVOList.stream().filter(item -> item.getSparepartName().contains(equipmentInDTO.getSparepartName())).collect(Collectors.toList());
}
voPage.setTotal(equipmentInIPage.getTotal());
voPage.setTotal(page.getTotal());
voPage.setRecords(equipmentInVOList);
result.setResult(voPage);
return result;
......
......@@ -34,4 +34,9 @@ public class EquipmentStatisticDTO {
*/
private String isSpecial;
/**
* 所属厂区
*/
private String departId;
}
......
......@@ -290,7 +290,7 @@ public class EquipmentInfo {
@ApiModelProperty(value = "企业负责人")
private String enterpriseManager;
@ApiModelProperty(value = "数字孪生模型区域编码")
private java.lang.String digitalTwinsStructCode;
}
......
......@@ -23,4 +23,5 @@ public interface EquipmentInfoMapper extends BaseMapper<EquipmentInfo> {
*/
List<EquipmentInfoForMonitorVO> queryCustomPageList(Page<EquipmentInfoForMonitorVO> pageList, EquipmentInfoForMonitorVO equipmentInfoForMonitorVO);
void clearDigitaltwins();
}
......
......@@ -23,6 +23,9 @@
</if>
<if test="equipmentInfoForMonitorVO.equipmentName!=null and equipmentInfoForMonitorVO.equipmentName!=''">
and a.equipment_name LIKE CONCAT(CONCAT('%', #{equipmentInfoForMonitorVO.equipmentName}),'%')
</if>
</if>
</select>
</mapper>
\ No newline at end of file
<update id="clearDigitaltwins">
update equipment_info set digital_twins_struct_code = ''
</update>
</mapper>
......
......@@ -4,6 +4,7 @@ import java.io.IOException;
import java.util.List;
import java.util.Map;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.skua.core.api.vo.Result;
......@@ -84,4 +85,6 @@ public interface IEquipmentInfoService extends IService<EquipmentInfo> {
void importExcel(MultipartFile file, String departId) throws Exception;
String reCreateQrCode(String id);
void batchConfigDigitaltwins(JSONObject jsonObject);
}
......
......@@ -9,6 +9,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.skua.core.context.BaseContextHandler;
import com.skua.core.excel.CustomExcelUtil;
......@@ -340,4 +341,23 @@ public class EquipmentInfoServiceImpl extends ServiceImpl<EquipmentInfoMapper, E
return qrCodePath;
}
@Override
public void batchConfigDigitaltwins(JSONObject json) {
List<String> idList = (List<String>)json.get("equip_id_list");
//清空孪生体配置数据
equipmentInfoMapper.clearDigitaltwins();
//组装需要更新的设备集合
List<EquipmentInfo> equipmentInfoList = new ArrayList<EquipmentInfo>();
EquipmentInfo equipmentInfo = null;
for(String id : idList) {
equipmentInfo = new EquipmentInfo();
equipmentInfo.setId(id);
equipmentInfo.setDigitalTwinsStructCode(id);
equipmentInfoList.add(equipmentInfo);
}
if(equipmentInfoList!=null&&equipmentInfoList.size()>0) {
this.updateBatchById(equipmentInfoList);
}
}
}
......
......@@ -113,6 +113,8 @@ public class ShiroConfig {
// filterChainDefinitionMap.put("/v1/report/reportDisplay/**", "anon");
filterChainDefinitionMap.put("/v1/sys/factoryMonitorData/**", "anon");
filterChainDefinitionMap.put("/sys/dict/getDictItems/**", "anon");
//数字孪生设备、孪生体批量关联
filterChainDefinitionMap.put("/equipment/batchConfigDigitaltwins", "anon");
//性能监控
filterChainDefinitionMap.put("/actuator/metrics/**", "anon");
filterChainDefinitionMap.put("/actuator/httptrace/**", "anon");
......@@ -124,6 +126,7 @@ public class ShiroConfig {
//flowable工作流权限过滤
filterChainDefinitionMap.put("/process/diagram-view", "anon");
filterChainDefinitionMap.put("/process/resource-view","anon");//工作流流程图
// filterChainDefinitionMap.put("/report/headerConfig/**","anon");
filterChainDefinitionMap.put("/v1/monitor/**","anon");//点表初始化导入
filterChainDefinitionMap.put("/example/**","anon");
......
......@@ -76,6 +76,24 @@ public class SysDepartController {
return result;
}
/**
* 查询数据 查出所有厂区
* @return
*/
@RequestMapping(value = "/getDepartList", method = RequestMethod.GET)
public Result<List<SysDepart>> getDepartList() {
Result<List<SysDepart>> result = new Result<>();
try {
String departIds = BaseContextHandler.getDeparts();
List<SysDepart> list = sysDepartService.getDepartList(departIds);
result.setResult(list);
result.setSuccess(true);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return result;
}
@ApiOperation(value="无token获取全部机构", notes="无token获取全部机构")
@RequestMapping(value = "/getTreeList", method = RequestMethod.GET)
public Result<List<SysDepartTreeModel>> getTreeList() {
......
......@@ -88,14 +88,6 @@ public class SysFactoryUserInfoController {
HttpServletRequest req) {
Result<IPage<SysFactoryUserInfo>> result = new Result<IPage<SysFactoryUserInfo>>();
Page<SysFactoryUserInfo> page = new Page<SysFactoryUserInfo>(pageNo, pageSize);
// QueryWrapper<SysFactoryUserInfo> queryWrapper = QueryGenerator.initQueryWrapper(sysFactoryUserInfo, req.getParameterMap());
// String departIds = BaseContextHandler.getDeparts();
// String[] departIdArray = departIds.split(",");
// if(StringUtils.isEmpty(sysFactoryUserInfo.getDepartId())&&StringUtils.isNotBlank(departIds)) {
// queryWrapper.in("depart_id", departIdArray);
// }
// queryWrapper.eq(StringUtils.isNotEmpty(sysFactoryUserInfo.getDepartId()),"depart_id",sysFactoryUserInfo.getDepartId());
// IPage<SysFactoryUserInfo> pageList = sysFactoryUserInfoService.page(page, queryWrapper);
IPage<SysFactoryUserInfo> pageList = sysFactoryUserInfoService.getPage(page, sysFactoryUserInfo);
result.setSuccess(true);
result.setResult(pageList);
......@@ -109,13 +101,6 @@ public class SysFactoryUserInfoController {
Result<Map<String,Object>> result = new Result<Map<String,Object>>();
Map<String,Object> map = new HashMap<>();
int female = 0;int male = 0;
// QueryWrapper<SysFactoryUserInfo> queryWrapper = new QueryWrapper<>();
// String departIds = BaseContextHandler.getDeparts();
// String[] departIdArray = departIds.split(",");
// if(StringUtils.isEmpty(sysFactoryUserInfo.getDepartId())&&StringUtils.isNotBlank(departIds)) {
// queryWrapper.in("depart_id", departIdArray);
// }
// queryWrapper.eq(StringUtils.isNotEmpty(sysFactoryUserInfo.getDepartId()),"depart_id",sysFactoryUserInfo.getDepartId());
List<SysFactoryUserInfo> list = sysFactoryUserInfoService.getList(sysFactoryUserInfo);
if(list.size()>0){
map.put("total", list.size());
......
......@@ -183,4 +183,6 @@ public interface ISysDepartService extends IService<SysDepart>{
List<SysDepart> queryUserDepartList(String userId);
List<SysDepartTreeModel> getTreeList();
List<SysDepart> getDepartList(String departIds);
}
......
......@@ -24,6 +24,7 @@ import com.skua.modules.system.util.FindsDepartsChildrenUtil;
import com.skua.modules.system.vo.DepartTree;
import com.skua.modules.system.vo.SysDeptUserVO;
import com.skua.tool.dfs.MapDFS;
import com.skua.tool.util.JSUtils;
import io.netty.util.internal.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -590,4 +591,15 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
return listResult;
}
@Override
public List<SysDepart> getDepartList(String departIds) {
List<SysDepart> list = new ArrayList<>();
QueryWrapper<SysDepart> queryWrapper = new QueryWrapper<>();
queryWrapper.in("id", departIds.split(","));
queryWrapper.eq("depart_type","1");
queryWrapper.orderByAsc("depart_order");
list = sysDepartMapper.selectList(queryWrapper);
return list;
}
}
......
......@@ -3,6 +3,7 @@ package com.skua.modules.system.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.skua.core.context.BaseContextHandler;
import com.skua.modules.common.service.ICommonSqlService;
import com.skua.modules.system.entity.SysFactoryUserInfo;
import com.skua.modules.system.entity.SysUser;
import com.skua.modules.system.mapper.SysFactoryUserInfoMapper;
......@@ -24,6 +25,8 @@ public class SysFactoryUserInfoServiceImpl extends ServiceImpl<SysFactoryUserInf
@Autowired
private SysFactoryUserInfoMapper sysFactoryUserInfoMapper;
@Autowired
private ICommonSqlService commonSqlService;
@Override
public IPage<SysFactoryUserInfo> getPage(Page<SysFactoryUserInfo> page, SysFactoryUserInfo sysFactoryUserInfo) {
......@@ -38,7 +41,8 @@ public class SysFactoryUserInfoServiceImpl extends ServiceImpl<SysFactoryUserInf
List<SysFactoryUserInfo> list = new ArrayList<>();
String departIds = BaseContextHandler.getDeparts();
if(StringUtils.isNotEmpty(sysFactoryUserInfo.getDepartId())){
departIds = sysFactoryUserInfo.getDepartId();
String departId = sysFactoryUserInfo.getDepartId();
departIds = commonSqlService.getChildDepartId(departId);
}
list = sysFactoryUserInfoMapper.getList(departIds,sysFactoryUserInfo.getUserName());
return list;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!