f4f3a162 张雷

Merge remote-tracking branch 'origin/master' into master

2 个父辈 8298b226 34423309
......@@ -529,6 +529,8 @@ public class EquipmentController {
String isMeterage = equipmentDTO.getEquipmentInfo().getIsMeterage();//是否计量设备
String orderFiled = equipmentDTO.getOrderFiled();
boolean orderType = equipmentDTO.isOrderType();
String startTime = equipmentDTO.getStartTime();
String endTime = equipmentDTO.getEndTime();
List<String> equipmentLevelList = null;
Base base = BaseFactory.JOIN().select(EquipmentAsset.class).select(EquipmentInfo.class).select(EquipmentBrand.class).select(EquipmentCategory.class)
......@@ -555,7 +557,9 @@ 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())
.ge(StringUtils.isNotEmpty(startTime), "equipment_info.create_time", startTime)
.le(StringUtils.isNotEmpty(endTime), "equipment_info.create_time", endTime);
if (StringUtils.isNotEmpty(orderFiled)) {
base.orderBy(true,orderType,"equipment_info." + getFiledName(orderFiled));
}else {
......
......@@ -9,8 +9,10 @@ import com.skua.common.constant.BusinessConstant;
import com.skua.core.api.vo.Result;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.core.context.BaseContextHandler;
import com.skua.core.util.ConvertUtils;
import com.skua.modules.base.service.IBaseService;
import com.skua.modules.common.service.ICommonSqlService;
import com.skua.modules.equipment.service.IEquipmentAnalysisService;
import com.skua.modules.equipment.service.IEquipmentMaintainTaskService;
import com.skua.modules.equipment.service.IEquipmentRepairService;
import com.skua.modules.equipment.vo.EquipmentMaintainRepairReportVO;
......@@ -19,6 +21,7 @@ import com.skua.modules.equipment.vo.EquipmentRepairForm;
import com.skua.modules.system.entity.SysDepart;
import com.skua.modules.system.service.ISysDepartService;
import com.skua.tool.dfs.CaseWhen;
import com.skua.tool.util.DigitalUtils;
import com.skua.tool.util.JSUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -50,6 +53,8 @@ public class EquipmentInfoMonthReportController {
private IEquipmentRepairService equipmentRepairService;
@Autowired
private IBaseService baseService;
@Autowired
private IEquipmentAnalysisService equipmentAnalysisService;
@AutoLog(value = "设备月报-设备管理情况")
@ApiOperation(value = "设备月报-设备管理情况", notes = "设备月报-设备管理情况")
......@@ -243,7 +248,7 @@ public class EquipmentInfoMonthReportController {
sql += " left join (select t.depart_id , (sum(t.plan_cost)/10000) 'plan_cost' from equipment_maintain_plan t where t.release_status = '1' and t.start_time >= '"+startDate+" 00:00:00' and t.end_time <='"+endDate+" 23:59:59' group by t.depart_id )bbb on bbb.depart_id = d.id ";
sql += " left join ( select depart_id, (ifnull(sum(total_cost),0)/10000) 'repair_cost' from equipment_repair where reality_maintenance_end_time >= '"+startDate+" 00:00:00' and reality_maintenance_end_time <='"+endDate+" 23:59:59' group by depart_id ) ccc on ccc.depart_id = d.id ";
sql += " left join (select depart_id,count(1) 'repair_form_total_count' from equipment_repair where repair_date >= '"+startDate+" 00:00:00' and repair_date <='"+endDate+" 23:59:59' group by depart_id ) ddd on ddd.depart_id = d.id ";
sql += " left join ( select depart_id,count(1) 'repair_form_complete_count' from equipment_repair where finish_flag in ('ywx','yys') and reality_maintenance_end_time >= '"+startDate+" 00:00:00' and reality_maintenance_end_time <='"+endDate+" 23:59:59' group by depart_id ) eee on eee.depart_id = d.id ";
sql += " left join ( select depart_id,count(1) 'repair_form_complete_count' from equipment_repair where finish_flag in ('ywx','yys') and repair_date >= '"+startDate+" 00:00:00' and repair_date <='"+endDate+" 23:59:59' group by depart_id ) eee on eee.depart_id = d.id ";
sql += " left join (select depart_id,count(1) 'complete_count' from inspection_task where task_state = '2' and task_start_time >= '"+startDate+" 00:00:00' and task_end_time <='"+endDate+" 23:59:59' group by depart_id ) fff on fff.depart_id = d.id ";
sql += " left join (select depart_id,count(1) 'total_count' from inspection_task where task_start_time >= '"+startDate+" 00:00:00' and task_end_time <='"+endDate+" 23:59:59' group by depart_id ) ggg on ggg.depart_id = d.id ";
sql += " where d.depart_type = 1 ";
......@@ -251,8 +256,22 @@ public class EquipmentInfoMonthReportController {
sql += " and d.id in ("+ JSUtils.quoteEach(departIds,",") +") ";
}
sql += " order by aaa.intact desc ";
sql += " ) TTT where (TTT.intact+TTT.plan_cost+TTT.repair_cost+TTT.repair_form_complete_rate+TTT.repair_form_complete_count+TTT.inspection_complete_rate)>0";
return commonSqlService.queryForList(sql);
sql += " ) TTT where (TTT.intact+TTT.plan_cost+TTT.repair_cost+TTT.repair_form_complete_rate+TTT.repair_form_complete_count+TTT.inspection_complete_rate)>=0";
List<Map<String, Object>> queryMapList0 = commonSqlService.queryForList(sql);
List<Map<String, Object>> intactRateMapList = equipmentAnalysisService.equipmentInTactRateByDepart(new HashMap<String, Object>(){{
put("startTime", startDate + BusinessConstant.startTimeSuffix);
put("endTime", endDate + BusinessConstant.endTimeSuffix);
put("departId", departIds);
}});
for (Map<String, Object> item: queryMapList0) {
for (Map<String, Object> intactRateMap: intactRateMapList) {
if (item.get("depart_id").equals(intactRateMap.get("departId"))) {
item.put("intact", DigitalUtils.nPoint(ConvertUtils.getDouble(intactRateMap.get("intactRate"), 0) * 100, 2));
break;
}
}
}
return queryMapList0;
}
//2 设备大修、更新开展情况
private List<Map<String,Object>> equipmentMaintainList(String departIds,String startDate,String endDate){
......@@ -297,7 +316,7 @@ public class EquipmentInfoMonthReportController {
String sql ="select d.depart_name, aaa.* from (";
sql += " select t.id 'info_id', t.depart_id , t.equipment_name, t.asset_amount, di.item_text 'equipment_level' from equipment_info t ";
sql += " left join sys_dict_item di on di.item_value = t.equipment_level ";
sql += " where t.install_date >= '"+startDate+"' and t.install_date <= '"+endDate+"' ";
sql += " where t.create_time >= '"+startDate+"' and t.create_time <= '"+endDate+"' ";
sql += ")aaa left join sys_depart d on aaa.depart_id = d.id ";
if(StringUtils.isNotEmpty(departIds)){
sql += " and aaa.depart_id in ("+ JSUtils.quoteEach(departIds,",") +") ";
......
......@@ -24,4 +24,8 @@ public class EquipmentDTO {
private String orderFiled;//排序字段
private boolean orderType;//排序类型,true:升序,false:降序
private String startTime;
private String endTime;
}
......
......@@ -49,7 +49,7 @@ public class EquipmentAnalysisServiceImpl implements IEquipmentAnalysisService {
.in(StringUtils.isNotEmpty(departId), "depart_id", departIdList)
.groupBy("depart_id");
List<Map<String, Object>> equipmentInfoList = equipmentInfoService.listMaps(queryWrapper0);
// 机构 => 设备数量
// 机构 => 设备数量
Map<String, Integer> departId2EquipCountMap = equipmentInfoList.stream().collect(Collectors.toMap(item -> ConvertUtils.getString(item.get("depart_id")), item -> Integer.parseInt(ConvertUtils.getString(item.get("total"))), (v1, v2) -> v2));
// 查询设备的故障时间
QueryWrapper<EquipmentRepair> queryWrapper1 = new QueryWrapper<>();
......@@ -92,15 +92,17 @@ public class EquipmentAnalysisServiceImpl implements IEquipmentAnalysisService {
String tmpDepartId = entry.getKey();
int equipCount = entry.getValue();
// 计算完好率
long value0 = departId2Equip2FaultTimeMap.getOrDefault(tmpDepartId, new HashMap<>()).values().stream().mapToLong(item -> item).sum();
long value1 = equipCount * interval;
double intactRate = 1 - 1.0 * value0 / value1;
long faultSecond = departId2Equip2FaultTimeMap.getOrDefault(tmpDepartId, new HashMap<>()).values().stream().mapToLong(item -> item).sum();
long allSecond = equipCount * interval;
double intactRate = 1 - 1.0 * faultSecond / allSecond;
String departName = sysDepartDictMap.get(tmpDepartId);
// 结果
Map<String, Object> resMap = new HashMap<>(4);
resMap.put("departId", tmpDepartId);
resMap.put("departName", departName);
resMap.put("intactRate", intactRate);
resMap.put("faultSecond", faultSecond);
resMap.put("intactSecond", allSecond - faultSecond);
resMapList.add(resMap);
}
return resMapList;
......@@ -170,13 +172,15 @@ public class EquipmentAnalysisServiceImpl implements IEquipmentAnalysisService {
long interval = DateUtils.dateStr2Sec(timeRangeArray[1], BusinessConstant.dateFormat) - DateUtils.dateStr2Sec(timeRangeArray[0], BusinessConstant.dateFormat) + 1;
Map<String, Long> equip2FaultTimeMap = entry.getValue();
// 计算完好率
long value0 = equip2FaultTimeMap.values().stream().mapToLong(Long::longValue).sum();
long value1 = equipTotal * interval;
double intactRate = 1 - 1.0 * value0 / value1;
long faultSecond = equip2FaultTimeMap.values().stream().mapToLong(Long::longValue).sum();
long allSecond = equipTotal * interval;
double intactRate = 1 - 1.0 * faultSecond / allSecond;
// 结果
Map<String, Object> resMap = new HashMap<>(4);
resMap.put("time", timeRange);
resMap.put("intactRate", intactRate);
resMap.put("faultSecond", faultSecond);
resMap.put("intactSecond", allSecond - faultSecond);
resMapList.add(resMap);
}
return resMapList;
......
......@@ -3,6 +3,7 @@ package com.skua.modules.equipment.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.skua.common.constant.BusinessConstant;
import com.skua.core.context.BaseContextHandler;
import com.skua.core.util.ConvertUtils;
import com.skua.core.util.DoubleOperaUtils;
......@@ -10,9 +11,11 @@ import com.skua.modules.common.mapper.CommonSqlMapper;
import com.skua.modules.common.service.ICommonSqlService;
import com.skua.modules.equipment.dto.ReportStatisticsDTO;
import com.skua.modules.equipment.mapper.ProductionEquipmentMapper;
import com.skua.modules.equipment.service.IEquipmentAnalysisService;
import com.skua.modules.equipment.service.IProductionEquipmentService;
import com.skua.modules.equipment.vo.*;
import com.skua.tool.util.DateUtils;
import com.skua.tool.util.DigitalUtils;
import com.skua.tool.util.JSUtils;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;
......@@ -43,6 +46,8 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
private ProductionEquipmentMapper productionEquipmentMapper;
@Autowired
private ICommonSqlService commonSqlService;
@Autowired
private IEquipmentAnalysisService equipmentAnalysisService;
private static final String MONTH_START = "-01 00:00:00";
private static final String MONTH_END = "-31 23:59:59";
......@@ -74,6 +79,13 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
Double sbwhCost = 0d; //维护费用
Double sbbyCost = 0d;//保养费用
Double jjwxCost = 0d; //基建维修费用
// 开始时间往前推一个月,方便计算环比
String startTime0 = DateUtils.date2Str(DateUtils.prevMonth(DateUtils.str2Date(reportStatisticsDTO.getStartTime(), BusinessConstant.dateFormat)), BusinessConstant.dateFormat);
// endTime修改到本月月底
int days = DateUtils.lengthOfSomeMonth(Integer.parseInt(reportStatisticsDTO.getEndTime().split("-")[0]), Integer.parseInt(reportStatisticsDTO.getEndTime().split("-")[1]));
String endTime0 = reportStatisticsDTO.getEndTime().substring(0, 7) + "-" + days + BusinessConstant.endTimeSuffix;
//ab总数
Integer ABEquipmentNum = 0;
if (reportStatisticsDTO.getTimeUnit() != null && reportStatisticsDTO.getTimeUnit() == 3) {
......@@ -245,21 +257,36 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
}
}
List<Map<String, Object>> inTactRateMapList = equipmentAnalysisService.equipmentInTactRateByTime(new HashMap<String, Object>(){{
put("startTime", startTime0);
put("endTime", endTime0);
put("timeType", "month");
put("departId", "");
}});
productionEquipmentVO.setEquipmentNum(equipmentNum);
productionEquipmentVO.setAbEquipmentNum(ABEquipmentNum);
//本月新增
productionEquipmentVO.setIncrease(increase);
//设备完好率
BigDecimal bigDecimal = new BigDecimal(ConvertUtils.getDou(v,0d)*100).setScale(2, BigDecimal.ROUND_HALF_UP);
productionEquipmentVO.setEquipmentIntactRate(bigDecimal.toString() + "%");
// productionEquipmentVO.setEquipmentIntactRate(bigDecimal.toString() + "%");
productionEquipmentVO.setEquipmentIntactRate(DigitalUtils.nPoint(ConvertUtils.getDouble(inTactRateMapList.get(inTactRateMapList.size() - 1).get("intactRate"), 0D) * 100, 2) + "%");
//设备完好总台日
BigDecimal bigDecimal5 = new BigDecimal(goodDay).setScale(2, BigDecimal.ROUND_HALF_UP);
productionEquipmentVO.setEquipmentIntactDay(bigDecimal5.toString());
// productionEquipmentVO.setEquipmentIntactDay(bigDecimal5.toString());
// 从第2条开始算,因为开始时间往前推了一个月,方便计算环比
long okSecond = 0L;
for (int i = 1; i < inTactRateMapList.size(); i++) {
okSecond += Long.parseLong(ConvertUtils.getString(inTactRateMapList.get(i).get("intactSecond")));
}
productionEquipmentVO.setEquipmentIntactDay(DigitalUtils.nPoint(ConvertUtils.getDouble(okSecond, 0D) / 3600 / 24, 1));
//维护台次
productionEquipmentVO.setMaintainUnits(repairNum);
//设备完好率月环比
BigDecimal bigDecimal1 = new BigDecimal(goodDayRing).setScale(2, BigDecimal.ROUND_HALF_UP);
productionEquipmentVO.setEquipmentIntactRingRate(bigDecimal1.toString() + "%");
// productionEquipmentVO.setEquipmentIntactRingRate(bigDecimal1.toString() + "%");
productionEquipmentVO.setEquipmentIntactRingRate(DigitalUtils.nPoint(ConvertUtils.getDouble(inTactRateMapList.get(inTactRateMapList.size() - 2).get("intactRate"), 0D) * 100, 2) + "%");
//维修计划完成率
BigDecimal bigDecimal2 = new BigDecimal(repairCompleteRate).setScale(2, BigDecimal.ROUND_HALF_UP);
productionEquipmentVO.setRepairCompleteRate(bigDecimal2.toString() + "%");
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!