06d9148b 张雷

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

2 个父辈 8f8f02cf 59db7a64
......@@ -71,7 +71,9 @@ public class DateUtils {
};
public static void main(String[] args) {
System.out.println( formatDate("2024-01","yyyy-MM"));
System.out.println( );
System.out.println(getHbMonth(formatDate("2024-01-01","yyyy-MM")));
}
/***
* 字符串日期格式化
......@@ -591,6 +593,8 @@ public class DateUtils {
return previousMonth.format(formatter); // 环比
}
/**
* 获取同比时间
* @param date
......
......@@ -43,7 +43,7 @@
<!-- 根据入库单ids,获取水厂结算单详情-->
<select id="queryWaterDepartSettlementByMaterialIds" resultType="com.skua.modules.erp.vo.ErpSettlementItemVO">
select d.depart_name, dc.contract_name ,dc.project_name, dc.contract_code, dm.distribut_price 'unit_price' , pm.good_brand , pm.good_origin, mf.jishu_file_path, mf.appearance_info, mf.matched_info ,mf.handle_msg,mf.sender_sign,mf.receiver_sign, dm.tax_amount ,
round(dm.distribut_price * mi.material_num,2) total_price, round(pm.distribut_price * mi.material_num *100 /(100+ ifnull(dm.tax_amount,0)) ,2) total_price_tax,
round(dm.distribut_price * mi.material_num,2) total_price, round(pm.unit_price * mi.material_num *100 /(100+ ifnull(dm.tax_amount,0)) ,2) total_price_tax,
mi.depart_id , mi.distribut_contract_id ,mi.purchase_contract_id, mi.material_num,
mi.arrive_time ,mi.remark,mi.sparepart_type,mi.sparepart_id,mi.sparepart_name,mi.sparepart_code,mi.specification, mi.measuring_unit,mi.good_code,mi.id 'material_in_id'
from erp_material_in mi
......
......@@ -115,7 +115,7 @@ public class OperationReportServiceImpl implements IOperationReportService {
//水电耗高于控制目标--水务公司列表
dataViewName4411 = ReportViewUtil.buildView(ReportConstant.view4411,"ydh,dhcmbzyy", departId, seasonTimeVO.getStartTime(), seasonTimeVO.getEndTime());
sql = "select * from ( ";
sql += " select d.depart_name 'departName', aaa.depart_id , avg(aaa.ydh) realConsume , IFNULL(tc.target_power,2) 'targetConsume' ,GROUP_CONCAT(aaa.dhcmbzyy) 'causeAnalysis' from "+ dataViewName4411+" aaa";;
sql += " select d.depart_name 'departName', aaa.depart_id , round(avg(aaa.ydh),2) realConsume , IFNULL(tc.target_power,2) 'targetConsume' ,GROUP_CONCAT(aaa.dhcmbzyy) 'causeAnalysis' from "+ dataViewName4411+" aaa";;
sql += " left join report_target_config tc on (tc.depart_id = aaa.depart_id and tc.target_year='2024')";
sql += " left join sys_depart d on d.id = aaa.depart_id ";
sql += " group by aaa.depart_id )bbb where bbb.realConsume > bbb.targetConsume ";
......@@ -126,7 +126,7 @@ public class OperationReportServiceImpl implements IOperationReportService {
//药剂成本高于控制目标--水务公司列表
dataViewName4411 = ReportViewUtil.buildView(ReportConstant.view4411,"yyh,yhcyqyy", departId, seasonTimeVO.getStartTime(), seasonTimeVO.getEndTime());
sql = "select * from ( ";
sql += " select d.depart_name 'departName', aaa.depart_id , avg(aaa.yyh) realConsume , IFNULL(tc.target_drug,2) 'targetConsume' ,GROUP_CONCAT(aaa.yhcyqyy) 'causeAnalysis' from "+ dataViewName4411+" aaa";;
sql += " select d.depart_name 'departName', aaa.depart_id , round(avg(aaa.yyh),2) realConsume , IFNULL(tc.target_drug,2) 'targetConsume' ,GROUP_CONCAT(aaa.yhcyqyy) 'causeAnalysis' from "+ dataViewName4411+" aaa";;
sql += " left join report_target_config tc on (tc.depart_id = aaa.depart_id and tc.target_year='2024')";
sql += " left join sys_depart d on d.id = aaa.depart_id ";
sql += " group by aaa.depart_id )bbb where bbb.realConsume > bbb.targetConsume ";
......
......@@ -163,10 +163,10 @@ public class EquipmentCenterController {
@AutoLog(value = "设备中心-MTTR&MTBF详情")
@ApiOperation(value = "设备中心-MTTR&MTBF详情", notes = "设备中心-MTTR&MTBF详情")
@GetMapping(value = "/equipmentMFDetails")
public Result<List<Map>> equipmentMFDetails(ReportStatisticsDTO reportStatisticsDTO) {
Result<List<Map>> result = new Result<List<Map>>();
public Result<List<ContrastDetailVO>> equipmentMFDetails(ReportStatisticsDTO reportStatisticsDTO) {
Result<List<ContrastDetailVO>> result = new Result<List<ContrastDetailVO>>();
setDepartIds(reportStatisticsDTO);
List<Map> equipmentMFDetails = iProductionEquipmentService.getEquipmentMFDetails(reportStatisticsDTO);
List<ContrastDetailVO> equipmentMFDetails = iProductionEquipmentService.getEquipmentMFDetailsNew(reportStatisticsDTO.getDepartIds(),reportStatisticsDTO.getStartTime(),reportStatisticsDTO.getEndTime());
result.setResult(equipmentMFDetails);
result.setSuccess(true);
return result;
......
......@@ -54,6 +54,9 @@ public class ReportStatisticsDTO {
@ApiModelProperty(value = "1总公司2分公司3厂站")
private Integer isCompany;
@ApiModelProperty(value = "分类数量")
private String totalCount;
@ApiModelProperty(value = "去年同比开始时间")
private String lastYearStartTime;
......
......@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.skua.modules.equipment.dto.ReportStatisticsDTO;
import com.skua.modules.equipment.entity.SysUser;
import com.skua.modules.equipment.pojo.Equipment;
import com.skua.modules.equipment.vo.ContrastDetailVO;
import com.skua.modules.equipment.vo.EquipmentNewMaintenancePlanVO;
import com.skua.modules.equipment.vo.EquipmentStatisticsCountVO;
import com.skua.modules.equipment.vo.ProportionStatisticsVO;
......@@ -134,6 +135,8 @@ public interface ProductionEquipmentMapper {
//一年MTBF
List<Map> getOneYearMTBF();
//MTBF 详情
public List<ContrastDetailVO> getEquipmentMFDetailsNew(@Param("departIds") String departIds, @Param("startTime")String startTime, @Param("endTime")String endTime);
//半年完成率
List<Map> getHalfIntactCompleteRate();
......
......@@ -146,7 +146,7 @@
<select id="getLevelByTime" resultType="com.skua.modules.equipment.vo.ProportionStatisticsVO"
parameterType="com.skua.modules.equipment.dto.ReportStatisticsDTO">
select aaa.item_text as category, ifnull(COUNT( ei.id ),0) AS'hour' from equipment_info ei
select ei.equipment_level ,aaa.item_text as category, ifnull(COUNT( ei.id ),0) AS'hour' from equipment_info ei
left join (
select t.item_value , t.item_text from sys_dict_item t where t.dict_id in (select id from sys_dict where dict_code = 'equipment-equipment_level')
) aaa on aaa.item_value = ei.equipment_level
......@@ -164,46 +164,25 @@
</select>
<select id="getTypeByTime" parameterType="com.skua.modules.equipment.dto.ReportStatisticsDTO"
resultType="com.skua.modules.equipment.vo.ProportionStatisticsVO">
SELECT
t1.des as category,
t1.equipmentNum as hour,
CONCAT( ROUND( IFNULL( t1.equipmentNum, 0 ) / t2.equipmentTotal, 3 )* 100, '%' ) AS proportion
FROM
(
SELECT
ec.des,
COUNT( ei.id ) equipmentNum
SELECT ei.equipment_type,
ec.des as category,
ifnull(COUNT( ei.id ),0) as hour,
CONCAT( ROUND( IFNULL( COUNT( ei.id ), 0 ) / ${totalCount}, 2 )* 100, '%' ) AS proportion
FROM
equipment_info ei
LEFT JOIN equipment_category ec ON ec.id = ei.equipment_type
LEFT JOIN sys_dict_item sdi ON sdi.item_value = ei.equipment_level
WHERE
ei.del_flag = 1
AND sdi.dict_id = '77c2f3bd6d16dec67f2ea11d84b6000e'
<if test="equipmentLevel !=null and equipmentLevel !=''">
AND sdi.item_text = #{equipmentLevel}
and ei.equipment_level = #{equipmentLevel}
<if test="startTime != null ">
and ei.create_time &gt;= #{startTime}
</if>
<if test="endTime !=null and endTime !=''">
AND ei.create_time &lt;= #{endTime}
<if test="endTime != null ">
and ei.create_time &lt;= #{endTime}
</if>
GROUP BY
ei.equipment_type
) t1,(
SELECT
count( ei.id ) AS equipmentTotal
FROM
equipment_info ei
LEFT JOIN sys_dict_item sdi ON sdi.item_value = ei.equipment_level
WHERE
ei.del_flag = 1
AND sdi.dict_id = '77c2f3bd6d16dec67f2ea11d84b6000e'
<if test="equipmentLevel !=null and equipmentLevel !=''">
AND sdi.item_text = #{equipmentLevel}
</if>
<if test="endTime !=null and endTime !=''">
AND ei.create_time &lt;= #{endTime}
</if>
) t2
</select>
<select id="getEquipmentStatisticsDetailsHeadquarters"
resultType="com.skua.modules.equipment.vo.EquipmentNewMaintenancePlanVO"
......@@ -682,6 +661,43 @@
MONTH DESC
) AS t
</select>
<select id="getEquipmentMFDetailsNew" resultType="com.skua.modules.equipment.vo.ContrastDetailVO">
select d.depart_name ,aaa.runTime , bbb.*,(SELECT COUNT( id ) AS increase FROM equipment_info ei WHERE ei.del_flag = 1 ) AS increase
from sys_depart d
left join (
SELECT eor.factory_id ,IFNULL( SUM( SUBSTRING( run_time, 1, 2 ) ), 0 ) / 24 AS runTime
FROM equipment_operation_record eor
WHERE 1=1
<if test="startDate != null and startDate != ''">
and eor.create_time &gt;= #{startDate}
</if>
<if test="endDate != null and endDate != ''">
and eor.create_time &lt;= #{endDate}
</if>
group by eor.factory_id
)aaa on aaa.factory_id = d.id
left join (
SELECT er.depart_id,COUNT( DISTINCT info_id ) AS equips,COUNT( er.id ) AS failures, round( IFNULL(SUM( UNIX_TIMESTAMP( er.reality_maintenance_end_time )- UNIX_TIMESTAMP( er.repair_date ) ),0)/60/60/24 ,2) AS downtime
FROM equipment_repair er
WHERE er.del_flag = 1
<if test="startDate != null and startDate != ''">
and er.create_time &gt;= #{startDate}
</if>
<if test="endDate != null and endDate != ''">
and er.create_time &lt;= #{endDate}
</if>
AND
)bbb on bbb.depart_id = d.id
where d.depart_type = 1
<if test="departIds != null ">
and d.depart_id in(${departIds})
</if>
</select>
<select id="getHalfIntactCompleteRate" resultType="java.util.Map">
SELECT t.MONTH AS month,
(
......
......@@ -48,9 +48,11 @@ public interface IProductionEquipmentService {
//MF
List<ContrastVO> getEquipmentMF(ReportStatisticsDTO reportStatisticsDTO);
// MF 详情
List<Map> getEquipmentMFDetails(ReportStatisticsDTO reportStatisticsDTO);
public List<ContrastDetailVO> getEquipmentMFDetailsNew(String departIds,String startTime,String endTime);
//维护完成率趋势
List<ContrastVO> getMaintainCompleteRate(ReportStatisticsDTO reportStatisticsDTO);
//维护完成率趋势详情
......
......@@ -75,12 +75,12 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
//总数
equipmentNum = productionEquipmentMapper.getEquipmentNum("1970-01-01 00:00:00", reportStatisticsDTO.getEndTime(), null);
//ab总数
ABEquipmentNum = productionEquipmentMapper.getEquipmentNum("1970-01-01 00:00:00", reportStatisticsDTO.getEndTime(), "C");
ABEquipmentNum = productionEquipmentMapper.getEquipmentNum("1970-01-01 00:00:00", reportStatisticsDTO.getEndTime(), "C");
//这个月新增
increase = productionEquipmentMapper.getEquipmentNum(reportStatisticsDTO.getStartTime(), reportStatisticsDTO.getEndTime(), null);
DateFormat format = new SimpleDateFormat("yyyy-MM");
String lastMonth = null;
Date parse = null;
// DateFormat format = new SimpleDateFormat("yyyy-MM");
String lastMonth = DateUtils.getHbMonth(DateUtils.formatDate(reportStatisticsDTO.getStartTime(),"yyyy-MM"));
/* Date parse = null;
try {
parse = format.parse(reportStatisticsDTO.getTime());
Calendar calendar = Calendar.getInstance();
......@@ -89,7 +89,8 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
lastMonth = format.format(calendar.getTime());
} catch (Exception e) {
e.getMessage();
}
}*/
//设备完好率
//求总停机天数
Map downtime = productionEquipmentMapper.getDowntime(reportStatisticsDTO.getStartTime(), reportStatisticsDTO.getEndTime());
......@@ -97,7 +98,10 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
if (null != downtime.get("downtime")) {
downtime1 = downtime.get("downtime").toString();
}
v = (increase * 30 - Double.parseDouble(downtime1)) / (increase * 30);
if (increase > 0) {
v = (increase * 30 - Double.parseDouble(downtime1)) / (increase * 30);
}
repairNum = downtime.get("repairNum").toString();
goodDay = 30 - Double.parseDouble(downtime1);
//上月的设备完好率
......@@ -119,7 +123,10 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
repairPlanNum = productionEquipmentMapper.getTaskNum(reportStatisticsDTO.getTime() + MONTH_START, reportStatisticsDTO.getTime() + MONTH_END, null);
//维护完成台数
repairCompleteNum = productionEquipmentMapper.getTaskNum(reportStatisticsDTO.getTime() + MONTH_START, reportStatisticsDTO.getTime() + MONTH_END, 1);
repairCompleteRate = (double) repairCompleteNum / repairPlanNum * 100;
if(repairPlanNum != null && repairPlanNum.intValue() > 0 ){
repairCompleteRate = (double) repairCompleteNum / repairPlanNum * 100;
}
//环比
Integer repairNum1 = productionEquipmentMapper.getTaskNum(lastMonth + MONTH_START, lastMonth + MONTH_END, null);
Integer finish = productionEquipmentMapper.getTaskNum(lastMonth + MONTH_START, lastMonth + MONTH_END, 1);
......@@ -164,7 +171,10 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
} else {
downtime1 = downtime.get("downtime").toString();
}
v = (increase * 365 - Double.parseDouble(downtime1)) / (increase * 365);
if(increase > 0){
v = (increase * 365 - Double.parseDouble(downtime1)) / (increase * 365);
}
repairNum = downtime.get("repairNum").toString();
goodDay = 365 - Double.parseDouble(downtime1);
//上一年的设备完好率
......@@ -191,7 +201,10 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
repairPlanNum = productionEquipmentMapper.getTaskNum(reportStatisticsDTO.getTime() + YEAR_START, reportStatisticsDTO.getTime() + YEAR_END, null);
//维护完成台数
repairCompleteNum = productionEquipmentMapper.getTaskNum(reportStatisticsDTO.getTime() + YEAR_START, reportStatisticsDTO.getTime() + YEAR_END, 1);
repairCompleteRate = (double) repairCompleteNum / repairPlanNum * 100;
if(repairPlanNum != null && repairPlanNum.intValue() > 0 ){
repairCompleteRate = (double) repairCompleteNum / repairPlanNum * 100;
}
//环比
Integer repairNum1 = productionEquipmentMapper.getTaskNum(lastYear + YEAR_START, lastYear + YEAR_END, null);
Integer finish = productionEquipmentMapper.getTaskNum(lastYear + YEAR_START, lastYear + YEAR_END, 1);
......@@ -258,7 +271,8 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
List<ProportionStatisticsVO> levelByTime = productionEquipmentMapper.getLevelByTime(reportStatisticsDTO);
if (levelByTime.size() > 0) {
levelByTime.forEach(l -> {
reportStatisticsDTO.setEquipmentLevel(l.getCategory());
reportStatisticsDTO.setEquipmentLevel(l.getEquipmentLevel());
reportStatisticsDTO.setTotalCount(l.getHour());
List<ProportionStatisticsVO> typeByTime = productionEquipmentMapper.getTypeByTime(reportStatisticsDTO);
l.setProportionStatisticsVOList(typeByTime);
});
......@@ -304,7 +318,7 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
reportStatisticsDTO1.setStartTime(reportStatisticsDTO.getStartTime());
reportStatisticsDTO1.setEndTime(reportStatisticsDTO.getEndTime());
List<Map> levelByHeadquarters = productionEquipmentMapper.getLevelByHeadquarters(reportStatisticsDTO1);
e.setType(finalN);
e.setType(finalN);
if (levelByHeadquarters.size() > 0) {
levelByHeadquarters.forEach(l -> {
String equipmentLevel = (String) l.get("equipmentLevel");
......@@ -389,7 +403,7 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
List<Map<String,Object>> mapList = commonSqlService.queryForList(dict_sql);
List<String> categoryNameList = new ArrayList<>();
List<String> categoryIdList = new ArrayList<>();*/
String startTime;
/* String startTime;
String endTime = DateUtils.getDateByAfterMonth(0);//当前日期
if (6 == reportStatisticsDTO.getTimeUnit()) {
startTime = DateUtils.getDateByAfterMonth(-6);
......@@ -397,7 +411,7 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
startTime = DateUtils.getDateByAfterMonth(-12);
}
reportStatisticsDTO.setStartTime(startTime);
reportStatisticsDTO.setEndTime(endTime);
reportStatisticsDTO.setEndTime(endTime);*/
return productionEquipmentMapper.getEquipmentStatisticsDetailsNew(pageList,reportStatisticsDTO);
}
@Override
......@@ -657,8 +671,8 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
//平均修复时间
List<Map> MTTR = new ArrayList<>();
if (6 == reportStatisticsDTO.getTimeUnit()) {
MTBF = productionEquipmentMapper.getHalfIntactMTBF(); //平均故障时间
MTTR = productionEquipmentMapper.getHalfIntactMTTR();
MTBF = productionEquipmentMapper.getHalfIntactMTBF(); //平均故障时间 半年MTBF
MTTR = productionEquipmentMapper.getHalfIntactMTTR();//半年MTTR
} else {
MTBF = productionEquipmentMapper.getOneYearMTBF();
MTTR = productionEquipmentMapper.getOneYearMTTR();
......@@ -801,6 +815,10 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
return listMF;
}
public List<ContrastDetailVO> getEquipmentMFDetailsNew(String departIds,String startTime,String endTime) {
return productionEquipmentMapper.getEquipmentMFDetailsNew(departIds, startTime, endTime);
}
@Override
public List<ContrastVO> getMaintainCompleteRate(ReportStatisticsDTO reportStatisticsDTO) {
List<ContrastVO> contrastVOS = new ArrayList<>();
......@@ -837,7 +855,7 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
Double v = 0.00;
if (!"0".equals(planNum1)) {
v = Double.parseDouble(completeNum1) / Double.parseDouble(planNum1) * 100;
//保留两位小数
//保留两位小数
v = DoubleOperaUtils.bigDecimalRound(v,2);
}
contrastVO.setMaintainNum(v.toString());
......
package com.skua.modules.equipment.vo;
import com.skua.core.util.DoubleOperaUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
/***************************
*<pre>
* @Project Name : cdxr
* @Package : com.skua.modules.equipment.vo
* @File Name : ContrastVO
* @Author : luowei
* @Date : 2022/11/17 11:12
* @Purpose :对比
* @History :
*</pre>
***************************/
@Data
@ApiModel(value="设备分析:MTTR&MTBF详情", description="设备分析:MTTR&MTBF详情")
public class ContrastDetailVO {
//月份
@ApiModelProperty(value = "厂站名称")
private String departName;
@ApiModelProperty(value = "运行时间")
private String runTime;
@ApiModelProperty(value = "故障数")
private String failures;
@ApiModelProperty(value = "故障设备数量")
private String equips;
@ApiModelProperty(value = "停机时间")
private String downtime;
@ApiModelProperty(value = "设备总数量")
private String increase;
//维修
@ApiModelProperty(value = "维修")
private Double repairNum;
//保养
@ApiModelProperty(value = "保养")
private Double maintainNum;
public Double getRepairNum() {
repairNum = 0.00d;
if (StringUtils.isNotEmpty(failures) && StringUtils.isNotEmpty(equips) && !failures.equals("0") && !equips.equals("0")) {
repairNum = Double.parseDouble(runTime) / Integer.parseInt(failures) / Integer.parseInt(equips);
repairNum = DoubleOperaUtils.bigDecimalRound(repairNum,2);
}
return repairNum;
}
public Double getMaintainNum() {
maintainNum =0.00d;
if (StringUtils.isNotEmpty(increase) && !increase.equals("0")) {
maintainNum = Double.parseDouble(downtime) / Integer.parseInt(increase);
maintainNum = DoubleOperaUtils.bigDecimalRound(maintainNum,2);
}
return maintainNum;
}
}
......@@ -19,6 +19,8 @@ import java.util.List;
public class ProportionStatisticsVO {
//类别
private String category;
//类别等级id
private String equipmentLevel;
//占比
private String proportion = "0%";
// 小时
......
......@@ -53,4 +53,11 @@ public class InspectionTaskOverviewDetailVO {
}
return processedAbnormalRate;
}
public Integer getNormalInspectionTaskCount() {
normalInspectionTaskCount = checkedInspectionTaskCount - abnormalInspectionTaskCount;
return normalInspectionTaskCount;
}
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!