0b6b9df7 康伟

kangwei:备统计分析功能调试

       设备统计详情接口
       设备完好率详情接口
       维护维修费用
       维护维修费用详情接口
1 个父辈 0cd11034
......@@ -364,18 +364,19 @@ public class JSUtils {
public static String quoteEach(String str,String splitStr) {
if( str != null && str.length() > 0 ){
String[] items = str.split(splitStr);
StringBuilder sb = new StringBuilder();
String result = "";
for (int i = 0; i < items.length; i++) {
if (i > 0) {
sb.append(", ");
if(StringUtils.isNotEmpty(items[i])){
if(result.length()>0) result +=",";
result += "'"+items[i]+"'";
}
sb.append('\'').append(items[i]).append('\'');
}
return sb.toString();
return result;
}
return str;
}
/***
* 计算时间的前几个月的月份
* @param month
......@@ -395,7 +396,15 @@ public class JSUtils {
}
public static void main(String[] args) {
System.out.println(getMonthBytime(-12,"2024-12"));
//System.out.println(getMonthBytime(-12,"2024-12"));
String str = "11,22,33,44";
System.out.println(quoteEach(str,",") );
str = ",11,,33,44";
System.out.println(quoteEach(str,",") );
str = ",11,22,33,44,,";
System.out.println(quoteEach(str,",") );
str = "11,,,44";
System.out.println(quoteEach(str,",") );
}
/* ScriptEngine se = new ScriptEngineManager().getEngineByName("JavaScript");
......
package com.skua.modules.material.controller;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.skua.core.api.vo.Result;
import com.skua.core.aspect.AutoLogAspect;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.core.context.BaseContextHandler;
import com.skua.core.context.SpringContextUtils;
import com.skua.core.query.QueryGenerator;
import com.skua.core.util.ConvertUtils;
import com.skua.core.util.DateUtils;
import com.skua.modules.erp.entity.ApproveRecord;
import com.skua.modules.erp.entity.ErpSettlement;
import com.skua.modules.erp.vo.PurchaseContractVO;
import com.skua.modules.common.service.ICommonSqlService;
import com.skua.modules.material.entity.MaterialInfo;
import com.skua.modules.material.entity.MaterialInfoHandleRecord;
import com.skua.modules.material.entity.MaterialInformation;
import com.skua.modules.material.service.IMaterialInfoHandleRecordService;
import com.skua.modules.material.service.IMaterialInfoService;
import com.skua.modules.material.vo.MaterialInfoStatisticsVO;
......@@ -39,13 +36,10 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.*;
/**
......@@ -66,6 +60,8 @@ public class MaterialInfoController {
private IMaterialInfoHandleRecordService materialInfoHandleRecordService;
@Resource
private ISysDepartService departService;
@Autowired
private ICommonSqlService commonSqlService;
/**
* 分页列表查询
......@@ -106,6 +102,8 @@ public class MaterialInfoController {
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
Result<IPage<MaterialInfo>> result = new Result<IPage<MaterialInfo>>();
Page<MaterialInfo> page = new Page<MaterialInfo>(pageNo, pageSize);
QueryWrapper<MaterialInfo> queryWrapper = QueryGenerator.initQueryWrapper(materialInfo, req.getParameterMap());
......@@ -117,6 +115,33 @@ public class MaterialInfoController {
return result;
}
@AutoLog(value = "厂区资料管理-上级制度")
@ApiOperation(value = "厂区资料管理-上级制度", notes = "厂区资料管理-上级制度")
@GetMapping(value = "/superiorList")
public Result<IPage<MaterialInfo>> querySuperiorList(MaterialInfo materialInfo,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
Result<IPage<MaterialInfo>> result = new Result<IPage<MaterialInfo>>();
Page<MaterialInfo> page = new Page<MaterialInfo>(pageNo, pageSize);
QueryWrapper<MaterialInfo> queryWrapper = QueryGenerator.initQueryWrapper(materialInfo, req.getParameterMap());
String sql = "SELECT CONCAT(a.parent_id ,',' ,b.parent_id) FROM sys_depart a";
sql += "LEFT JOIN sys_depart b ON a.parent_id = b.id WHERE a.id = '"+BaseContextHandler.getRealDepartId()+"'";
String departIds = commonSqlService.queryForString( sql );
departIds = JSUtils.quoteEach(departIds,",");
if(StringUtils.isNotEmpty(departIds)){
queryWrapper.in("depart_id", departIds);
}
// QueryWrapper<MaterialInfo> queryWrapper = getMaterialInfoQueryWrapper(materialInfo);
queryWrapper.orderByDesc("create_time");
IPage<MaterialInfo> pageList = materialInfoService.page(page, queryWrapper);
result.setSuccess(true);
result.setResult(pageList);
return result;
}
@AutoLog(value = "厂区资料管理-待审核列表")
@ApiOperation(value = "厂区资料管理-待审核列表", notes = "厂区资料管理-待审核列表")
@GetMapping(value = "/unAuditList")
......
......@@ -4,12 +4,16 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.skua.core.api.vo.Result;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.core.context.BaseContextHandler;
import com.skua.modules.equipment.dto.ReportStatisticsDTO;
import com.skua.modules.equipment.service.IProductionEquipmentService;
import com.skua.modules.equipment.vo.*;
import com.skua.modules.system.service.ISysDepartService;
import com.skua.tool.util.JSUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -26,12 +30,15 @@ import java.util.Map;
public class EquipmentCenterController {
@Autowired
private IProductionEquipmentService iProductionEquipmentService;
@Autowired
private ISysDepartService departService;
@AutoLog(value = "设备中心-顶部总览")
@ApiOperation(value = "设备中心-顶部总览", notes = "设备中心-顶部总览")
@GetMapping(value = "/topOverview")
public Result<ProductionEquipmentVO> topOverview(ReportStatisticsDTO reportStatisticsDTO) {
Result<ProductionEquipmentVO> result = new Result<ProductionEquipmentVO>();
setDepartIds(reportStatisticsDTO);
ProductionEquipmentVO productionEquipmentVO = iProductionEquipmentService.getProductionEquipmentVO(reportStatisticsDTO);
result.setResult(productionEquipmentVO);
return result;
......@@ -42,6 +49,7 @@ public class EquipmentCenterController {
@GetMapping(value = "/equipmentStatistics")
public Result<FaultStatisticsVO> equipmentStatistics(ReportStatisticsDTO reportStatisticsDTO) {
Result<FaultStatisticsVO> result = new Result<>();
setDepartIds(reportStatisticsDTO);
FaultStatisticsVO equipmentStatistics = iProductionEquipmentService.getEquipmentStatistics(reportStatisticsDTO);
result.setResult(equipmentStatistics);
result.setSuccess(true);
......@@ -56,17 +64,34 @@ public class EquipmentCenterController {
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
Result<IPage<EquipmentNewMaintenancePlanVO>> result = new Result<IPage<EquipmentNewMaintenancePlanVO>>();
Page<EquipmentNewMaintenancePlanVO> pageList = new Page<EquipmentNewMaintenancePlanVO>(pageNo, pageSize);
setDepartIds(reportStatisticsDTO);
pageList = iProductionEquipmentService.getEquipmentStatisticsDetails(pageList, reportStatisticsDTO);
result.setSuccess(true);
result.setResult(pageList);
return result;
}
@AutoLog(value = "设备中心-设备统计详情(新)")
@ApiOperation(value = "设备中心-设备统计详情(新)", notes = "设备中心-设备统计详情(新)")
@GetMapping(value = "/equipmentStatisticsDetailsNew")
public Result<IPage<EquipmentStatisticsCountVO>> equipmentStatisticsDetailsNew(ReportStatisticsDTO reportStatisticsDTO,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
Result<IPage<EquipmentStatisticsCountVO>> result = new Result<IPage<EquipmentStatisticsCountVO>>();
Page<EquipmentStatisticsCountVO> page = new Page<EquipmentStatisticsCountVO>(pageNo, pageSize);
setDepartIds(reportStatisticsDTO);//设置departIds
IPage<EquipmentStatisticsCountVO> pageList =iProductionEquipmentService.getEquipmentStatisticsDetailsNew(page, reportStatisticsDTO);
result.setSuccess(true);
result.setResult(pageList);
return result;
}
@AutoLog(value = "设备中心-设备状态")
@ApiOperation(value = "设备中心-设备状态", notes = "设备中心-设备状态")
@GetMapping(value = "/equipmentState")
public Result<List<TOPTenVO>> equipmentState(ReportStatisticsDTO reportStatisticsDTO) {
Result<List<TOPTenVO>> result = new Result<>();
setDepartIds(reportStatisticsDTO);
List<TOPTenVO> equipmentState = iProductionEquipmentService.getEquipmentState(reportStatisticsDTO);
result.setSuccess(true);
result.setResult(equipmentState);
......@@ -81,6 +106,7 @@ public class EquipmentCenterController {
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
Result<IPage<EquipmentNewMaintenancePlanVO>> result = new Result<IPage<EquipmentNewMaintenancePlanVO>>();
Page<EquipmentNewMaintenancePlanVO> pageList = new Page<EquipmentNewMaintenancePlanVO>(pageNo, pageSize);
setDepartIds(reportStatisticsDTO);
pageList = iProductionEquipmentService.getEquipmentStateDetails(pageList, reportStatisticsDTO);
result.setSuccess(true);
result.setResult(pageList);
......@@ -92,6 +118,7 @@ public class EquipmentCenterController {
@GetMapping(value = "/equipmentIntactRate")
public Result<List<ContrastVO>> equipmentIntactRate(ReportStatisticsDTO reportStatisticsDTO) {
Result<List<ContrastVO>> result = new Result<List<ContrastVO>>();
setDepartIds(reportStatisticsDTO);
List<ContrastVO> equipmentIntactRate = iProductionEquipmentService.getEquipmentIntactRate(reportStatisticsDTO);
result.setSuccess(true);
result.setResult(equipmentIntactRate);
......@@ -103,17 +130,30 @@ public class EquipmentCenterController {
@GetMapping(value = "/equipmentIntactRateDetails")
public Result<List<Map>> equipmentIntactRateDetails(ReportStatisticsDTO reportStatisticsDTO) {
Result<List<Map>> result = new Result<List<Map>>();
setDepartIds(reportStatisticsDTO);
List<Map> equipmentIntactRateDetails = iProductionEquipmentService.getEquipmentIntactRateDetails(reportStatisticsDTO);
result.setResult(equipmentIntactRateDetails);
result.setSuccess(true);
return result;
}
@AutoLog(value = "设备中心-设备完好率详情(新)")
@ApiOperation(value = "设备中心-设备完好率详情(新)", notes = "设备中心-设备完好率详情(新)")
@GetMapping(value = "/equipmentIntactRateDetailsNew")
public Result<List<Map>> equipmentIntactRateDetailsNew(ReportStatisticsDTO reportStatisticsDTO) {
Result<List<Map>> result = new Result<List<Map>>();
setDepartIds(reportStatisticsDTO);
List<Map> equipmentIntactRateDetails = iProductionEquipmentService.getEquipmentIntactRateDetailsNew(reportStatisticsDTO);
result.setResult(equipmentIntactRateDetails);
result.setSuccess(true);
return result;
}
@AutoLog(value = "设备中心-MTTR&MTBF")
@ApiOperation(value = "设备中心-MTTR&MTBF", notes = "设备中心-MTTR&MTBF")
@GetMapping(value = "/equipmentMF")
public Result<List<ContrastVO>> equipmentMF(ReportStatisticsDTO reportStatisticsDTO) {
Result<List<ContrastVO>> result = new Result<List<ContrastVO>>();
setDepartIds(reportStatisticsDTO);
List<ContrastVO> equipmentMF = iProductionEquipmentService.getEquipmentMF(reportStatisticsDTO);
result.setResult(equipmentMF);
result.setSuccess(true);
......@@ -125,6 +165,7 @@ public class EquipmentCenterController {
@GetMapping(value = "/equipmentMFDetails")
public Result<List<Map>> equipmentMFDetails(ReportStatisticsDTO reportStatisticsDTO) {
Result<List<Map>> result = new Result<List<Map>>();
setDepartIds(reportStatisticsDTO);
List<Map> equipmentMFDetails = iProductionEquipmentService.getEquipmentMFDetails(reportStatisticsDTO);
result.setResult(equipmentMFDetails);
result.setSuccess(true);
......@@ -136,6 +177,7 @@ public class EquipmentCenterController {
@GetMapping(value = "/maintainCompleteRate")
public Result<List<ContrastVO>> maintainCompleteRate(ReportStatisticsDTO reportStatisticsDTO) {
Result<List<ContrastVO>> result = new Result<List<ContrastVO>>();
setDepartIds(reportStatisticsDTO);
List<ContrastVO> maintainCompleteRate = iProductionEquipmentService.getMaintainCompleteRate(reportStatisticsDTO);
result.setResult(maintainCompleteRate);
result.setSuccess(true);
......@@ -147,6 +189,7 @@ public class EquipmentCenterController {
@GetMapping(value = "/maintainCompleteRateDetails")
public Result<List<Map>> maintainCompleteRateDetails(ReportStatisticsDTO reportStatisticsDTO) {
Result<List<Map>> result = new Result<>();
setDepartIds(reportStatisticsDTO);
List<Map> maintainCompleteRateDetails = iProductionEquipmentService.getMaintainCompleteRateDetails(reportStatisticsDTO);
result.setResult(maintainCompleteRateDetails);
result.setSuccess(true);
......@@ -158,6 +201,7 @@ public class EquipmentCenterController {
@GetMapping(value = "/maintainRepairCost")
public Result<List<ContrastVO>> maintainRepairCost(ReportStatisticsDTO reportStatisticsDTO) {
Result<List<ContrastVO>> result = new Result<List<ContrastVO>>();
setDepartIds(reportStatisticsDTO);
List<ContrastVO> maintainCompleteRate = iProductionEquipmentService.getContrastCost(reportStatisticsDTO);
result.setResult(maintainCompleteRate);
result.setSuccess(true);
......@@ -169,9 +213,24 @@ public class EquipmentCenterController {
@GetMapping(value = "/maintainRepairCostDetails")
public Result<List<Map>> maintainRepairCostDetails(ReportStatisticsDTO reportStatisticsDTO) {
Result<List<Map>> result = new Result<>();
setDepartIds(reportStatisticsDTO);
List<Map> contrastCostDetails = iProductionEquipmentService.getContrastCostDetails(reportStatisticsDTO);
result.setResult(contrastCostDetails);
result.setSuccess(true);
return result;
}
/***
* 设置查询条件的departIds属性
* @param reportStatisticsDTO
*/
private void setDepartIds(ReportStatisticsDTO reportStatisticsDTO){
String departIds = null;
if (StringUtils.isNotEmpty(reportStatisticsDTO.getFactoryId())) {
departIds = departService.getChildDepartId(reportStatisticsDTO.getFactoryId());
}else{
departIds = BaseContextHandler.getDeparts();
}
reportStatisticsDTO.setDepartIds(JSUtils.quoteEach(departIds,","));
}
}
......
package com.skua.modules.equipment.dto;
import com.skua.modules.equipment.vo.IndexVO;
import com.skua.tool.util.DateUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
......@@ -46,7 +48,22 @@ public class ReportStatisticsDTO {
List<IndexVO> outOfGinseng;
@ApiModelProperty(value = "时间")
private String time;
@ApiModelProperty(value = "部门集合")
private String departIds;
@ApiModelProperty(value = "1总公司2分公司3厂站")
private Integer isCompany;
public String getTime() {
if(StringUtils.isEmpty(time)){//判断time如果为空,获取starttime的年份数据,否则获取当前年
if( StringUtils.isNotEmpty(startTime) ){
time = DateUtils.getDateYear(startTime)+"";
}else{
time = DateUtils.getCurrentYear()+"";
}
}
return time;
}
}
......
package com.skua.modules.equipment.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
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.EquipmentNewMaintenancePlanVO;
import com.skua.modules.equipment.vo.EquipmentStatisticsCountVO;
import com.skua.modules.equipment.vo.ProportionStatisticsVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -34,7 +38,8 @@ public interface ProductionEquipmentMapper {
//获取维修费用
Double getRepairCost(@Param("startTime") String startTime, @Param("endTime") String endTime);
//获取维修费用 2024-1227 获取维修费用:来源维修表
// Double getRepairNewCost( @Param("departIds") String departIds, @Param("startTime") String startTime, @Param("endTime") String endTime);
//获取维护任务数量 status 1:已完成 0:未完成
Integer getTaskNum(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("status") Integer status);
......@@ -56,6 +61,8 @@ public interface ProductionEquipmentMapper {
//厂获取生产设备总台数详情
List<EquipmentNewMaintenancePlanVO> getEquipmentStatisticsDetailsFactory(ReportStatisticsDTO reportStatisticsDTO);
//厂获取生产设备总台数详情(新)
IPage<EquipmentStatisticsCountVO> getEquipmentStatisticsDetailsNew(Page<EquipmentStatisticsCountVO> page, @Param("param") ReportStatisticsDTO reportStatisticsDTO);
//总公司获取等级分类
List<Map> getLevelByHeadquarters(ReportStatisticsDTO reportStatisticsDTO);
......@@ -141,10 +148,10 @@ public interface ProductionEquipmentMapper {
List<Map> getOneYearCompleteYearOnYearRate();
//半年维修维护费用对比
List<Map> getHalfIntactContrastCost();
List<Map> getHalfIntactContrastCost(@Param("departIds") String departIds);
//一年维修维护费用对比
List<Map> getOneYearContrastCost();
List<Map> getOneYearContrastCost(@Param("departIds") String departIds);
//总公司获取停机时间
List<Map> getDownTimeByMonthHeadquarters(ReportStatisticsDTO reportStatisticsDTO);
......@@ -180,4 +187,8 @@ public interface ProductionEquipmentMapper {
List<Map>getRepairCostByHeadquarters(ReportStatisticsDTO reportStatisticsDTO);
List<Map>getRepairCostByBranchOffice(ReportStatisticsDTO reportStatisticsDTO);
List<Map>getRepairCostByFactory(ReportStatisticsDTO reportStatisticsDTO);
//设备中心-维护维修费用详情
List<Map> getContrastCostDetails(ReportStatisticsDTO reportStatisticsDTO);
//设备完好率详情(新)
List<Map> getEquipmentIntactRateDetailsNew(ReportStatisticsDTO reportStatisticsDTO);
}
......
......@@ -107,39 +107,60 @@
and #{endTime}
</if>
</select>
<select id="getEquipmentStatisticsDetailsNew" resultType="com.skua.modules.equipment.vo.EquipmentStatisticsCountVO">
select d.depart_name , d.id 'depart_id',
ifnull(ccc.category_value1 , 0 ) category_value1,
ifnull(ccc.category_value2 , 0 ) category_value2,
ifnull(ccc.category_value3 , 0 ) category_value3
from sys_depart d
left join (
select bbb.depart_id,
ifnull((CASE WHEN equipment_level = '2421538a0286b491ffb863db92fe6cbf' THEN bbb.hour END),0) 'category_value1',
ifnull((CASE WHEN equipment_level = '6bf727eb7e7cca6a95c694dab0036b2c' THEN bbb.hour END),0) 'category_value2',
ifnull((CASE WHEN equipment_level = 'a64bfc58110d2c105a6026e8bd02c232' THEN bbb.hour END),0) 'category_value3'
from (
select ei.depart_id , ei.equipment_level , ifnull(COUNT( ei.id ),0) AS'hour' from equipment_info ei
where 1=1
<if test="param.startTime != null ">
and ei.create_time &gt;= #{param.startTime}
</if>
<if test="param.endTime != null ">
and ei.create_time &lt;= #{param.endTime}
</if>
<if test="param.departIds != null ">
and ei.depart_id in(${param.departIds})
</if>
group by ei.depart_id , ei.equipment_level
)bbb group by bbb.depart_id
)ccc on ccc.depart_id = d.id
where d.depart_type = 1
<if test="param.departIds != null ">
and d.id in (${param.departIds})
</if>
order by ccc.category_value1 desc
</select>
<select id="getLevelByTime" resultType="com.skua.modules.equipment.vo.ProportionStatisticsVO"
parameterType="com.skua.modules.equipment.dto.ReportStatisticsDTO">
SELECT
t1.des as category,
t1.equipmentNum as hour,
CONCAT( ROUND( IFNULL( t1.equipmentNum, 0 ) / t2.equipmentTotal, 3 )* 100, '%' ) AS proportion
FROM
(
SELECT
sdi.item_text AS des,
COUNT( ei.id ) AS equipmentNum
FROM
equipment_info ei
LEFT JOIN sys_dict_item sdi ON sdi.item_value = ei.equipment_level
WHERE
sdi.dict_id = '77c2f3bd6d16dec67f2ea11d84b6000e'
<if test="endTime !=null and endTime !=''">
AND ei.create_time &lt;= #{endTime}
select 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
where 1=1
<if test="startTime != null ">
and ei.create_time &gt;= #{startTime}
</if>
GROUP BY
ei.equipment_level
) t1,(
SELECT
count( 1 ) AS equipmentTotal
FROM
equipment_info
WHERE
1=1
<if test="endTime !=null and endTime !=''">
AND create_time &lt;= #{endTime}
<if test="endTime != null ">
and ei.create_time &lt;= #{endTime}
</if>
) t2
<if test="departIds != null ">
and ei.depart_id in(${departIds})
</if>
group by ei.equipment_level
</select>
<select id="getTypeByTime" parameterType="com.skua.modules.equipment.dto.ReportStatisticsDTO"
resultType="com.skua.modules.equipment.vo.ProportionStatisticsVO">
......@@ -793,7 +814,7 @@
FROM
equipment_maintain_task emt LEFT JOIN equipment_task_cost etc ON etc.task_id=emt.id
WHERE
LEFT ( emt.maintain_time, 7 ) = t.MONTH AND emt.del_flag = 0
LEFT ( emt.maintain_time, 7 ) = t.MONTH AND emt.del_flag = 0 and emt.depart_id in(${departIds})
) AS maintainCost,
(
SELECT
......@@ -802,7 +823,7 @@
equipment_repair er
WHERE
LEFT ( er.create_time, 7 ) = t.MONTH
AND er.del_flag = 1
AND er.del_flag = 1 and er.depart_id in(${departIds})
) AS repairCost
FROM
(
......@@ -824,7 +845,7 @@
FROM
equipment_maintain_task emt LEFT JOIN equipment_task_cost etc ON etc.task_id=emt.id
WHERE
LEFT ( emt.maintain_time, 7 ) = t.MONTH AND emt.del_flag = 0
LEFT ( emt.maintain_time, 7 ) = t.MONTH AND emt.del_flag = 0 and emt.depart_id in(${departIds})
) AS maintainCost,
(
SELECT
......@@ -833,7 +854,7 @@
equipment_repair er
WHERE
LEFT ( er.create_time, 7 ) = t.MONTH
AND er.del_flag = 1
AND er.del_flag = 1 and er.depart_id in(${departIds})
) AS repairCost
FROM
(
......@@ -847,6 +868,45 @@
MONTH DESC
) AS t
</select>
<!--维护维修费用详情 -->
<select id="getContrastCostDetails" resultType="java.util.Map">
select d.id depart_id , d.depart_name ,ifnull(aaa.maintainCost,0) maintainCost,ifnull(bbb.repairCost,0) repairCost from sys_depart d
left join (
SELECT emt.depart_id , IFNULL(sum(etc.material_cost+etc.maintenance_cost+etc.labor_cost+etc.machinery_cost+etc.service_cost+etc.wastage_cost+etc.other_cost),0) maintainCost
FROM equipment_maintain_task emt LEFT JOIN equipment_task_cost etc ON etc.task_id=emt.id
WHERE emt.del_flag = 0 and emt.maintain_time &gt;= #{startTime} and emt.maintain_time &lt;= #{endTime}
group by emt.depart_id
) aaa on aaa.depart_id = d.id
left join (
SELECT er.depart_id, IFNULL(SUM(er.total_cost),0) repairCost
FROM equipment_repair er
WHERE er.del_flag = 1 and er.create_time &gt;= #{startTime} and er.create_time &lt;= #{endTime}
group by er.depart_id
)bbb on bbb.depart_id = d.id
where d.depart_type = 1
and d.id in (${departIds})
</select>
<!-- 设备完好率详情(新)-->
<select id="getEquipmentIntactRateDetailsNew" resultType="java.util.Map">
select d.id depart_id , d.depart_name ,round(ifnull(aaa.intact,0),2) 'intact', round(ifnull(bbb.percentage,0),2) 'percentage' from sys_depart d
left join (
SELECT er.depart_id ,ifnull(( COUNT(id)*30 - IFNULL( SUM( UNIX_TIMESTAMP( reality_maintenance_end_time )- UNIX_TIMESTAMP( repair_date ) )/ 60 / 60 / 24, 0 ) ) *100/ (COUNT(id)*30) , 0) 'intact'
FROM equipment_repair er
WHERE er.del_flag = 1 and er.create_time &gt;= #{startTime} and er.create_time &lt;= #{endTime}
group by er.depart_id
) aaa on aaa.depart_id = d.id
left join (
SELECT er.depart_id , ifnull(( COUNT(id)*30 - IFNULL( SUM( UNIX_TIMESTAMP( reality_maintenance_end_time )- UNIX_TIMESTAMP( repair_date ) )/ 60 / 60 / 24, 0 ) ) *100/ (COUNT(id)*30) , 0) 'percentage'
FROM equipment_repair er
WHERE er.del_flag = 1 and er.create_time &gt;= #{startTime} and er.create_time &lt;= #{endTime}
group by er.depart_id
)bbb on bbb.depart_id = d.id
where d.depart_type = 1 and d.id in (${departIds})
order by aaa.intact desc
</select>
<select id="getDownTimeByMonthHeadquarters" resultType="java.util.Map"
parameterType="com.skua.modules.equipment.dto.ReportStatisticsDTO">
SELECT sd1.depart_name AS departName,sd1.id as departId,
......@@ -1117,6 +1177,8 @@
GROUP BY
sd1.id
</select>
<select id="getMaintainCostByHeadquarters" parameterType="com.skua.modules.equipment.dto.ReportStatisticsDTO"
resultType="java.util.Map">
SELECT
......
package com.skua.modules.equipment.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.skua.modules.equipment.dto.ReportStatisticsDTO;
import com.skua.modules.equipment.vo.*;
......@@ -19,6 +20,7 @@ import java.util.Map;
*</pre>
***************************/
public interface IProductionEquipmentService {
//设备中心-顶部总览
ProductionEquipmentVO getProductionEquipmentVO(ReportStatisticsDTO reportStatisticsDTO);
//设备统计
......@@ -27,6 +29,9 @@ public interface IProductionEquipmentService {
//设备统计详情
Page<EquipmentNewMaintenancePlanVO> getEquipmentStatisticsDetails(Page<EquipmentNewMaintenancePlanVO> pageList, ReportStatisticsDTO reportStatisticsDTO);
//设备统计详情(new)
IPage<EquipmentStatisticsCountVO> getEquipmentStatisticsDetailsNew(Page<EquipmentStatisticsCountVO> pageList, ReportStatisticsDTO reportStatisticsDTO);
//获取设备状态
List<TOPTenVO> getEquipmentState(ReportStatisticsDTO reportStatisticsDTO);
......@@ -38,6 +43,8 @@ public interface IProductionEquipmentService {
//设备完好率详情
List<Map> getEquipmentIntactRateDetails(ReportStatisticsDTO reportStatisticsDTO);
List<Map> getEquipmentIntactRateDetailsNew(ReportStatisticsDTO reportStatisticsDTO);
//MF
List<ContrastVO> getEquipmentMF(ReportStatisticsDTO reportStatisticsDTO);
......
/*
package com.skua.modules.equipment.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.skua.core.context.BaseContextHandler;
import com.skua.core.util.DoubleOperaUtils;
import com.skua.modules.equipment.dto.ReportStatisticsDTO;
import com.skua.modules.equipment.mapper.ProductionEquipmentMapper;
import com.skua.modules.equipment.service.IProductionEquipmentService;
import com.skua.modules.equipment.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
*/
/***************************
*<pre>
* @Project Name : cdxr
* @Package : com.skua.modules.equipment.service.impl
* @File Name : ProductionEquipmentServiceImpl
* @Author : luowei
* @Date : 2022/12/5 15:24
* @Purpose :
* @History :
*</pre>
***************************//*
@Service
@Transactional
public class BAK_ProductionEquipmentServiceImpl implements IProductionEquipmentService {
@Autowired
private ProductionEquipmentMapper productionEquipmentMapper;
private static final String MONTH_START = "-01 00:00:00";
private static final String MONTH_END = "-31 23:59:59";
private static final String YEAR_START = "-01-01 00:00:00";
private static final String YEAR_END = "-12-31 23:59:59";
private static final String C = "一般设备(C类)";
private static final String B = "主要设备(B类)";
private static final String A = "重点设备(A类)";
@Override
public ProductionEquipmentVO getProductionEquipmentVO(ReportStatisticsDTO reportStatisticsDTO) {
ProductionEquipmentVO productionEquipmentVO = new ProductionEquipmentVO();
Integer increase = 0;
Integer equipmentNum = 0;
double v = 1.00;
String repairNum = null;
Double goodDay = 0.00;
Double goodDayRing = 0.00;
Integer repairPlanNum = 0;
Integer repairCompleteNum = 0;
Double repairCompleteRate = 0.00;
Double repairCompleteRing = 0.00;
Double repairCost = 0.00;
Double maintainCost = 0.00;
Double totalCost = 0.00;
Double costRing = 0.00;
//ab总数
Integer ABEquipmentNum = 0;
if (reportStatisticsDTO.getTimeUnit() != null && reportStatisticsDTO.getTimeUnit() == 3) {
if (reportStatisticsDTO.getTime()==null){
reportStatisticsDTO.setTime(reportStatisticsDTO.getEndTime().substring(0,7));
}
//总数
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");
//这个月新增
increase = productionEquipmentMapper.getEquipmentNum(reportStatisticsDTO.getStartTime(), reportStatisticsDTO.getEndTime(), null);
DateFormat format = new SimpleDateFormat("yyyy-MM");
String lastMonth = null;
Date parse = null;
try {
parse = format.parse(reportStatisticsDTO.getTime());
Calendar calendar = Calendar.getInstance();
calendar.setTime(parse);
calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1);
lastMonth = format.format(calendar.getTime());
} catch (Exception e) {
e.getMessage();
}
//设备完好率
//求总停机天数
Map downtime = productionEquipmentMapper.getDowntime(reportStatisticsDTO.getStartTime(), reportStatisticsDTO.getEndTime());
String downtime1 = "0.00";
if (null != downtime.get("downtime")) {
downtime1 = downtime.get("downtime").toString();
}
v = (increase * 30 - Double.parseDouble(downtime1)) / (increase * 30);
repairNum = downtime.get("repairNum").toString();
goodDay = 30 - Double.parseDouble(downtime1);
//上月的设备完好率
Map downtime2 = productionEquipmentMapper.getDowntime(lastMonth + MONTH_START, lastMonth + MONTH_END);
String downtime3 = "0.00";
if (null != downtime2.get("downtime")) {
downtime3 = downtime2.get("downtime").toString();
}
Integer increase1 = productionEquipmentMapper.getEquipmentNum(lastMonth + MONTH_START, lastMonth + MONTH_END, null);
Double v1 = 0.00;
if (increase1 > 0) {
v1 = (increase1 * 30 - Double.parseDouble(downtime3)) / (increase1 * 30);
}
if (v1 > 0) {
goodDayRing = (v - v1) / v1 * 100;
}
//维修计划完成率
//维护计划台数
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;
//环比
Integer repairNum1 = productionEquipmentMapper.getTaskNum(lastMonth + MONTH_START, lastMonth + MONTH_END, null);
Integer finish = productionEquipmentMapper.getTaskNum(lastMonth + MONTH_START, lastMonth + MONTH_END, 1);
Double lastRepairCompleteRate = 0.00;
if (repairNum1 > 0) {
lastRepairCompleteRate = (double) finish / repairNum1 * 100;
}
if (lastRepairCompleteRate > 0) {
repairCompleteRing = (repairCompleteRate - lastRepairCompleteRate) / lastRepairCompleteRate * 100;
}
//维护维修费用
//维修费
repairCost = productionEquipmentMapper.getRepairCost(reportStatisticsDTO.getTime() + MONTH_START, reportStatisticsDTO.getTime() + MONTH_END);
//保养费
maintainCost = productionEquipmentMapper.getMaintainCost(reportStatisticsDTO.getTime() + MONTH_START, reportStatisticsDTO.getTime() + MONTH_END);
totalCost = repairCost + maintainCost;
//环比
Double repairCost1 = productionEquipmentMapper.getRepairCost(lastMonth + MONTH_START, lastMonth + MONTH_END);
Double maintainCost1 = productionEquipmentMapper.getMaintainCost(lastMonth + MONTH_START, lastMonth + MONTH_END);
if (repairCost1 + maintainCost1 > 0) {
costRing = (totalCost - (repairCost1 + maintainCost1)) / (repairCost1 + maintainCost1) * 100;
}
} else {
if (reportStatisticsDTO.getTime()==null){
reportStatisticsDTO.setTime(reportStatisticsDTO.getEndTime().substring(0,4));
}
//总数
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");
if (null == reportStatisticsDTO.getTime()) {
Calendar cal = Calendar.getInstance();
reportStatisticsDTO.setTime(String.valueOf(cal.get(Calendar.YEAR)));
}
increase = productionEquipmentMapper.getEquipmentNum(reportStatisticsDTO.getTime() + YEAR_START, reportStatisticsDTO.getTime() + YEAR_END, null);
//设备完好率
//求总停机天数
Map downtime = productionEquipmentMapper.getDowntime(reportStatisticsDTO.getTime() + YEAR_START, reportStatisticsDTO.getTime() + YEAR_END);
String downtime1 = null;
if (downtime.get("downtime") == null) {
downtime1 = "0.00";
} else {
downtime1 = downtime.get("downtime").toString();
}
v = (increase * 365 - Double.parseDouble(downtime1)) / (increase * 365);
repairNum = downtime.get("repairNum").toString();
goodDay = 365 - Double.parseDouble(downtime1);
//上一年的设备完好率
Integer lastYear = Integer.parseInt(reportStatisticsDTO.getTime()) - 1;
Map downtime2 = productionEquipmentMapper.getDowntime(lastYear + YEAR_START, lastYear + YEAR_END);
String downtime3 = null;
if (null == downtime2.get("downtime")) {
downtime3 = "0.00";
} else {
downtime3 = downtime2.get("downtime").toString();
}
Integer increase1 = productionEquipmentMapper.getEquipmentNum(lastYear + YEAR_START, lastYear + YEAR_END, null);
Double v1 = 0.00;
if (increase1 > 0) {
v1 = (increase1 * 365 - Double.parseDouble(downtime3)) / (increase1 * 365);
}
if (v1 > 0) {
goodDayRing = (v - v1) / v1 * 100;
}
//维修计划完成率
//维护计划台数
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;
//环比
Integer repairNum1 = productionEquipmentMapper.getTaskNum(lastYear + YEAR_START, lastYear + YEAR_END, null);
Integer finish = productionEquipmentMapper.getTaskNum(lastYear + YEAR_START, lastYear + YEAR_END, 1);
Double lastRepairCompleteRate = 0.00;
if (repairNum1 > 0) {
lastRepairCompleteRate = (double) finish / repairNum1 * 100;
}
if (lastRepairCompleteRate > 0) {
repairCompleteRing = (repairCompleteRate - lastRepairCompleteRate) / lastRepairCompleteRate * 100;
}
//维护维修费用
//维修费
repairCost = productionEquipmentMapper.getRepairCost(reportStatisticsDTO.getTime() + YEAR_START, reportStatisticsDTO.getTime() + YEAR_END);
//保养费
maintainCost = productionEquipmentMapper.getMaintainCost(reportStatisticsDTO.getTime() + YEAR_START, reportStatisticsDTO.getTime() + YEAR_END);
totalCost = repairCost + maintainCost;
//环比
Double repairCost1 = productionEquipmentMapper.getRepairCost(lastYear + YEAR_START, lastYear + YEAR_END);
Double maintainCost1 = productionEquipmentMapper.getMaintainCost(lastYear + YEAR_START, lastYear + YEAR_END);
if (repairCost1 + maintainCost1 > 0) {
costRing = (totalCost - (repairCost1 + maintainCost1)) / (repairCost1 + maintainCost1) * 100;
}
}
productionEquipmentVO.setEquipmentNum(equipmentNum);
productionEquipmentVO.setAbEquipmentNum(ABEquipmentNum);
//本月新增
productionEquipmentVO.setIncrease(increase);
//设备完好率
BigDecimal bigDecimal = new BigDecimal(v*100).setScale(2, BigDecimal.ROUND_HALF_UP);
productionEquipmentVO.setEquipmentIntactRate(bigDecimal.toString() + "%");
//设备完好总台日
BigDecimal bigDecimal5 = new BigDecimal(goodDay).setScale(2, BigDecimal.ROUND_HALF_UP);
productionEquipmentVO.setEquipmentIntactDay(bigDecimal5.toString());
//维护台次
productionEquipmentVO.setMaintainUnits(repairNum);
//设备完好率月环比
BigDecimal bigDecimal1 = new BigDecimal(goodDayRing).setScale(2, BigDecimal.ROUND_HALF_UP);
productionEquipmentVO.setEquipmentIntactRingRate(bigDecimal1.toString() + "%");
//维修计划完成率
BigDecimal bigDecimal2 = new BigDecimal(repairCompleteRate).setScale(2, BigDecimal.ROUND_HALF_UP);
productionEquipmentVO.setRepairCompleteRate(bigDecimal2.toString() + "%");
//维护计划
productionEquipmentVO.setRepairPlan(repairPlanNum.toString());
//维护完成
productionEquipmentVO.setRepairComplete(repairCompleteNum.toString());
//维修计划完成月环比
BigDecimal bigDecimal3 = new BigDecimal(repairCompleteRing).setScale(2, BigDecimal.ROUND_HALF_UP);
productionEquipmentVO.setRepairCompleteRingRate(bigDecimal3.toString() + "%");
//维护维修费用
productionEquipmentVO.setRepairMaintainCost(totalCost.toString());
//维修费用
productionEquipmentVO.setRepairCost(repairCost.toString());
//维护
productionEquipmentVO.setMaintainCost(maintainCost.toString());
//环比
BigDecimal bigDecimal4 = new BigDecimal(costRing).setScale(2, BigDecimal.ROUND_HALF_UP);
productionEquipmentVO.setRepairMaintainCostRingRate(bigDecimal4.toString() + "%");
return productionEquipmentVO;
}
@Override
public FaultStatisticsVO getEquipmentStatistics(ReportStatisticsDTO reportStatisticsDTO) {
FaultStatisticsVO faultStatisticsVO = new FaultStatisticsVO();
List<ProportionStatisticsVO> levelByTime = productionEquipmentMapper.getLevelByTime(reportStatisticsDTO);
if (levelByTime.size() > 0) {
levelByTime.forEach(l -> {
reportStatisticsDTO.setEquipmentLevel(l.getCategory());
List<ProportionStatisticsVO> typeByTime = productionEquipmentMapper.getTypeByTime(reportStatisticsDTO);
l.setProportionStatisticsVOList(typeByTime);
});
}
faultStatisticsVO.setLevel(levelByTime);
return faultStatisticsVO;
}
@Override
public Page<EquipmentNewMaintenancePlanVO> getEquipmentStatisticsDetails(Page<EquipmentNewMaintenancePlanVO> pageList, ReportStatisticsDTO reportStatisticsDTO) {
int n = 0;
//前端传入公司id和需要展示的层级
if (StrUtil.isEmpty(reportStatisticsDTO.getCompanyId()) && null == reportStatisticsDTO.getIsCompany()) {
String realFactoryId = (String) BaseContextHandler.get("realFactoryId");
reportStatisticsDTO.setCompanyId(realFactoryId);
String orgCode = BaseContextHandler.getOrgCode();
n = orgCode.length() - orgCode.replaceAll("A", "").length();
} else {
n = reportStatisticsDTO.getIsCompany();
}
List<EquipmentNewMaintenancePlanVO> equipmentStatistics = new ArrayList<>();
if (n == 1) {
equipmentStatistics = productionEquipmentMapper.getEquipmentStatisticsDetailsHeadquarters(reportStatisticsDTO);
int finalN = n;
equipmentStatistics.forEach(e -> {
ReportStatisticsDTO reportStatisticsDTO1 = new ReportStatisticsDTO();
reportStatisticsDTO1.setCompanyId(e.getCompanyId());
reportStatisticsDTO1.setStartTime(reportStatisticsDTO.getStartTime());
reportStatisticsDTO1.setEndTime(reportStatisticsDTO.getEndTime());
List<Map> levelByHeadquarters = productionEquipmentMapper.getLevelByHeadquarters(reportStatisticsDTO1);
e.setType(finalN);
if (levelByHeadquarters.size() > 0) {
levelByHeadquarters.forEach(l -> {
String equipmentLevel = (String) l.get("equipmentLevel");
if (equipmentLevel.equals(A)) {
e.setAClass(equipmentLevel);
} else if (equipmentLevel.equals(B)) {
e.setBClass(equipmentLevel);
} else {
e.setCClass(equipmentLevel);
}
});
} else {
e.setAClass("0");
e.setBClass("0");
e.setCClass("0");
}
});
} else if (n == 2) {
equipmentStatistics = productionEquipmentMapper.getEquipmentStatisticsDetailsBranchOffice(reportStatisticsDTO);
int finalN1 = n;
equipmentStatistics.forEach(e -> {
e.setType(finalN1);
ReportStatisticsDTO reportStatisticsDTO1 = new ReportStatisticsDTO();
reportStatisticsDTO1.setCompanyId(e.getCompanyId());
reportStatisticsDTO1.setStartTime(reportStatisticsDTO.getStartTime());
reportStatisticsDTO1.setEndTime(reportStatisticsDTO.getEndTime());
List<Map> levelByBranchOffice = productionEquipmentMapper.getLevelByBranchOffice(reportStatisticsDTO1);
if (levelByBranchOffice.size() > 0) {
levelByBranchOffice.forEach(l -> {
String equipmentLevel = (String) l.get("equipmentLevel");
if (equipmentLevel.equals(A)) {
e.setAClass(equipmentLevel);
} else if (equipmentLevel.equals(B)) {
e.setBClass(equipmentLevel);
} else {
e.setCClass(equipmentLevel);
}
});
} else {
e.setAClass("0");
e.setBClass("0");
e.setCClass("0");
}
});
} else {
equipmentStatistics = productionEquipmentMapper.getEquipmentStatisticsDetailsFactory(reportStatisticsDTO);
int finalN2 = n;
equipmentStatistics.forEach(e -> {
e.setType(finalN2);
ReportStatisticsDTO reportStatisticsDTO1 = new ReportStatisticsDTO();
reportStatisticsDTO1.setCompanyId(e.getCompanyId());
reportStatisticsDTO1.setStartTime(reportStatisticsDTO.getStartTime());
reportStatisticsDTO1.setEndTime(reportStatisticsDTO.getEndTime());
List<Map> levelByBranchOffice = productionEquipmentMapper.getLevelByBranchOffice(reportStatisticsDTO1);
if (levelByBranchOffice.size() > 0) {
levelByBranchOffice.forEach(l -> {
String equipmentLevel = (String) l.get("equipmentLevel");
if (equipmentLevel.equals(A)) {
e.setAClass(equipmentLevel);
} else if (equipmentLevel.equals(B)) {
e.setBClass(equipmentLevel);
} else {
e.setCClass(equipmentLevel);
}
});
} else {
e.setAClass("0");
e.setBClass("0");
e.setCClass("0");
}
});
}
return pageList.setRecords(equipmentStatistics);
}
@Override
public List<TOPTenVO> getEquipmentState(ReportStatisticsDTO reportStatisticsDTO) {
List<TOPTenVO> list = new ArrayList<>();
TOPTenVO topTenVO = new TOPTenVO();
reportStatisticsDTO.setEquipmentType("wxdd");
Integer equipmentStatus = productionEquipmentMapper.getEquipmentStatus(reportStatisticsDTO);
topTenVO.setFactoryName("待修");
topTenVO.setNum(equipmentStatus.toString());
list.add(topTenVO);
TOPTenVO topTenVO1 = new TOPTenVO();
reportStatisticsDTO.setEquipmentType("sbwx");
Integer equipmentStatus1 = productionEquipmentMapper.getEquipmentStatus(reportStatisticsDTO);
topTenVO1.setFactoryName("在修");
topTenVO1.setNum(equipmentStatus1.toString());
list.add(topTenVO1);
return list;
}
@Override
public Page<EquipmentNewMaintenancePlanVO> getEquipmentStateDetails(Page<EquipmentNewMaintenancePlanVO> pageList, ReportStatisticsDTO reportStatisticsDTO) {
int n = 0;
//前端传入公司id和需要展示的层级
if (StrUtil.isEmpty(reportStatisticsDTO.getCompanyId()) && null == reportStatisticsDTO.getIsCompany()) {
String realFactoryId = (String) BaseContextHandler.get("realFactoryId");
reportStatisticsDTO.setCompanyId(realFactoryId);
String orgCode = BaseContextHandler.getOrgCode();
n = orgCode.length() - orgCode.replaceAll("A", "").length();
} else {
n = reportStatisticsDTO.getIsCompany();
}
List<EquipmentNewMaintenancePlanVO> equipmentStatistics = new ArrayList<>();
if (n == 1) {
equipmentStatistics = productionEquipmentMapper.getEquipmentStatisticsDetailsHeadquarters(reportStatisticsDTO);
equipmentStatistics.forEach(e -> {
ReportStatisticsDTO reportStatisticsDTO1 = new ReportStatisticsDTO();
reportStatisticsDTO1.setCompanyId(e.getCompanyId());
reportStatisticsDTO1.setStartTime(reportStatisticsDTO.getStartTime());
reportStatisticsDTO1.setEndTime(reportStatisticsDTO.getEndTime());
List<Map> statusByHeadquarters = productionEquipmentMapper.getStatusByHeadquarters(reportStatisticsDTO1);
if (statusByHeadquarters.size() > 0) {
statusByHeadquarters.forEach(s -> {
String accessState = (String) s.get("accessState");
String repairNum = String.valueOf(s.get("repairNum"));
if ("wxdd".equals(accessState)) {
e.setWaiting(repairNum);
} else if ("sbwx".equals(accessState)) {
e.setRepairing(repairNum);
}
});
}
});
} else if (n == 2) {
equipmentStatistics = productionEquipmentMapper.getEquipmentStatisticsDetailsBranchOffice(reportStatisticsDTO);
equipmentStatistics.forEach(e -> {
ReportStatisticsDTO reportStatisticsDTO1 = new ReportStatisticsDTO();
reportStatisticsDTO1.setCompanyId(e.getCompanyId());
reportStatisticsDTO1.setStartTime(reportStatisticsDTO.getStartTime());
reportStatisticsDTO1.setEndTime(reportStatisticsDTO.getEndTime());
List<Map> statusByBranchOffice = productionEquipmentMapper.getStatusByBranchOffice(reportStatisticsDTO1);
if (statusByBranchOffice.size() > 0) {
statusByBranchOffice.forEach(s -> {
String accessState = (String) s.get("accessState");
String repairNum = (String) s.get("repairNum");
if ("wxdd".equals(accessState)) {
e.setWaiting(repairNum);
} else if ("sbwx".equals(accessState)) {
e.setRepairing(repairNum);
}
});
}
});
} else {
equipmentStatistics = productionEquipmentMapper.getEquipmentStatisticsDetailsFactory(reportStatisticsDTO);
equipmentStatistics.forEach(e -> {
ReportStatisticsDTO reportStatisticsDTO1 = new ReportStatisticsDTO();
reportStatisticsDTO1.setCompanyId(e.getCompanyId());
reportStatisticsDTO1.setStartTime(reportStatisticsDTO.getStartTime());
reportStatisticsDTO1.setEndTime(reportStatisticsDTO.getEndTime());
List<Map> statusByBranchOffice = productionEquipmentMapper.getStatusByBranchOffice(reportStatisticsDTO1);
if (statusByBranchOffice.size() > 0) {
statusByBranchOffice.forEach(s -> {
String accessState = (String) s.get("accessState");
String repairNum = (String) s.get("repairNum");
if ("wxdd".equals(accessState)) {
e.setWaiting(repairNum);
} else if ("sbwx".equals(accessState)) {
e.setRepairing(repairNum);
}
});
}
});
}
return pageList.setRecords(equipmentStatistics);
}
@Override
public List<ContrastVO> getEquipmentIntactRate(ReportStatisticsDTO reportStatisticsDTO) {
List<ContrastVO> list = new ArrayList<>();
List<Map> rate = null;
List<Map> onYearRate = new ArrayList<>();
if (reportStatisticsDTO.getTimeUnit() == 6) {
rate = productionEquipmentMapper.getHalfIntactRate();
onYearRate = productionEquipmentMapper.getHalfIntactYearOnYearRate();
} else {
rate = productionEquipmentMapper.getOneYearRate();
onYearRate = productionEquipmentMapper.getOneYearYearOnYearRate();
}
List<Map> yearOnYear = onYearRate;
rate.forEach(h -> {
ContrastVO contrastVO = new ContrastVO();
String month = (String) h.get("month");
String lastYear = (String) h.get("lastYear");
String d = h.get("downtime").toString();
Double downtime = Double.parseDouble(d);
Long increase = (Long) h.get("increase");
double v = 0.00;
if (increase > 0) {
v = DoubleOperaUtils.bigDecimalRound((increase * 30 - downtime) / (increase * 30), 2)*100;
}
contrastVO.setMonth(month);
contrastVO.setRepairNum(v + "%");
yearOnYear.forEach(y -> {
String lastYear1 = (String) y.get("lastYear");
if (lastYear1.equals(lastYear)) {
Long increase1 = (Long) y.get("increase");
String d1 = y.get("downtime").toString();
Double downtime1 = Double.parseDouble(d1);
double v1 = 0.00;
if (increase1 > 0) {
v1 = DoubleOperaUtils.bigDecimalRound((increase1 * 30 - downtime1) / (increase1 * 30),2)*100;
}
contrastVO.setMaintainNum(v1 + "%");
}
});
list.add(contrastVO);
});
return list;
}
@Override
public List<Map> getEquipmentIntactRateDetails(ReportStatisticsDTO reportStatisticsDTO) {
List<Map> list = new ArrayList<>();
int n = 0;
String lastMonth = null;
//前端传入公司id和需要展示的层级
if (StrUtil.isEmpty(reportStatisticsDTO.getCompanyId()) && null == reportStatisticsDTO.getIsCompany()) {
String realFactoryId = (String) BaseContextHandler.get("realFactoryId");
reportStatisticsDTO.setCompanyId(realFactoryId);
String orgCode = BaseContextHandler.getOrgCode();
n = orgCode.length() - orgCode.replaceAll("A", "").length();
} else {
n = reportStatisticsDTO.getIsCompany();
}
Date parse = null;
DateFormat format = new SimpleDateFormat("yyyy-MM");
try {
parse = format.parse(reportStatisticsDTO.getTime());
Calendar calendar = Calendar.getInstance();
calendar.setTime(parse);
calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - 1);
calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) + 1);
lastMonth = format.format(calendar.getTime());
} catch (Exception e) {
e.getMessage();
}
List<Map> downTimeByMonthHeadquarters = null;
List<Map> equipmentNumByMonthHeadquarters = null;
List<Map> downTimeByMonthHeadquartersLastYear = null;
List<Map> equipmentNumByMonthHeadquartersLastYear = null;
if (n == 1) {
downTimeByMonthHeadquarters = productionEquipmentMapper.getDownTimeByMonthHeadquarters(reportStatisticsDTO);
equipmentNumByMonthHeadquarters = productionEquipmentMapper.getEquipmentNumByMonthHeadquarters(reportStatisticsDTO);
reportStatisticsDTO.setTime(lastMonth);
downTimeByMonthHeadquartersLastYear = productionEquipmentMapper.getDownTimeByMonthHeadquarters(reportStatisticsDTO);
equipmentNumByMonthHeadquartersLastYear = productionEquipmentMapper.getEquipmentNumByMonthHeadquarters(reportStatisticsDTO);
} else if (n == 2) {
downTimeByMonthHeadquarters = productionEquipmentMapper.getDownTimeByBranchOffice(reportStatisticsDTO);
equipmentNumByMonthHeadquarters = productionEquipmentMapper.getEquipmentNumByBranchOffice(reportStatisticsDTO);
reportStatisticsDTO.setTime(lastMonth);
downTimeByMonthHeadquartersLastYear = productionEquipmentMapper.getDownTimeByBranchOffice(reportStatisticsDTO);
equipmentNumByMonthHeadquartersLastYear = productionEquipmentMapper.getEquipmentNumByBranchOffice(reportStatisticsDTO);
} else {
downTimeByMonthHeadquarters = productionEquipmentMapper.getDownTimeByFactory(reportStatisticsDTO);
equipmentNumByMonthHeadquarters = productionEquipmentMapper.getEquipmentNumByFactory(reportStatisticsDTO);
reportStatisticsDTO.setTime(lastMonth);
downTimeByMonthHeadquartersLastYear = productionEquipmentMapper.getDownTimeByFactory(reportStatisticsDTO);
equipmentNumByMonthHeadquartersLastYear = productionEquipmentMapper.getEquipmentNumByFactory(reportStatisticsDTO);
}
List<Map> finalEquipmentNumByMonthHeadquarters = equipmentNumByMonthHeadquarters;
List<Map> finalDownTimeByMonthHeadquartersLastYear = downTimeByMonthHeadquartersLastYear;
List<Map> finalEquipmentNumByMonthHeadquartersLastYear = equipmentNumByMonthHeadquartersLastYear;
int finalN = n;
downTimeByMonthHeadquarters.forEach(d -> {
Map map = new HashMap<>();
String departName = d.get("departName").toString();
String departId = d.get("departId").toString();
String downtime = d.get("downtime").toString();
finalEquipmentNumByMonthHeadquarters.forEach(e -> {
String companyName = e.get("companyName").toString();
String equipmentNum = e.get("equipmentNum").toString();
if (companyName.equals(departName)) {
//Double v = (Integer.parseInt(equipmentNum) * 30 - (Integer.parseInt(equipmentNum) * Double.parseDouble(downtime))) / (Integer.parseInt(equipmentNum) * 30);
Double v = (Integer.parseInt(equipmentNum) * 30 - Double.parseDouble(downtime)) / (Integer.parseInt(equipmentNum) * 30)*100;
v = DoubleOperaUtils.bigDecimalRound(v, 2);
map.put("departName", departName);
map.put("departId", departId);
map.put("intact", v);
map.put("percentage", 0.00);
map.put("type", finalN);
}
});
finalDownTimeByMonthHeadquartersLastYear.forEach(d1 -> {
String departName1 = d1.get("departName").toString();
String downtime1 = d1.get("downtime").toString();
if (departName1.equals(departName)) {
finalEquipmentNumByMonthHeadquartersLastYear.forEach(e1 -> {
String companyName1 = e1.get("companyName").toString();
String equipmentNum1 = e1.get("equipmentNum").toString();
if (companyName1.equals(departName1)) {
//Double v1 = (Integer.parseInt(equipmentNum1) * 30 - (Integer.parseInt(equipmentNum1) * Double.parseDouble(downtime1))) / Integer.parseInt(equipmentNum1) * 30;
Double v1 = (Integer.parseInt(equipmentNum1) * 30 - Double.parseDouble(downtime1)) / (Integer.parseInt(equipmentNum1) * 30)*100;
v1 = DoubleOperaUtils.bigDecimalRound(v1, 2);
map.put("percentage", v1);
}
});
}
});
list.add(map);
});
return list;
}
@Override
public List<ContrastVO> getEquipmentMF(ReportStatisticsDTO reportStatisticsDTO) {
List<ContrastVO> contrastVOS = new ArrayList<>();
//平均故障时间
List<Map> MTBF = new ArrayList<>();
//平均修复时间
List<Map> MTTR = new ArrayList<>();
if (reportStatisticsDTO.getTimeUnit() == 6) {
MTBF = productionEquipmentMapper.getHalfIntactMTBF();
MTTR = productionEquipmentMapper.getHalfIntactMTTR();
} else {
MTBF = productionEquipmentMapper.getOneYearMTBF();
MTTR = productionEquipmentMapper.getOneYearMTTR();
}
List<Map> finalMTTR = MTTR;
MTBF.forEach(h -> {
//循环平均故障时间
ContrastVO contrastVO = new ContrastVO();
//月份
String month = h.get("month").toString();
//运行时间
String runTime = h.get("runTime").toString();
//故障数
String failures = h.get("failures").toString();
//故障设备数量
String equips = h.get("equips").toString();
contrastVO.setMonth(month);
Double d = 0.00;
if (!failures.equals("0") && !equips.equals("0")) {
d = Double.parseDouble(runTime) / Integer.parseInt(failures) / Integer.parseInt(equips);
d = DoubleOperaUtils.bigDecimalRound(d,2);
}
contrastVO.setRepairNum(d.toString());
finalMTTR.forEach(o -> {
String month1 = o.get("month").toString();
if (month.equals(month1)) {
//停机时间
String downtime = o.get("downtime").toString();
if(Double.parseDouble(downtime) < 0){
downtime = "0.00";
}
//设备总数量
String increase = o.get("increase").toString();
// String equips1 = o.get("equips").toString();
// Double d1 = Double.parseDouble(runTime1) / Integer.parseInt(failures1) / Integer.parseInt(equips1);
Double d1 = Double.parseDouble(downtime) / Integer.parseInt(increase);
d1 = DoubleOperaUtils.bigDecimalRound(d1,2);
contrastVO.setMaintainNum(d1.toString());
}
});
contrastVOS.add(contrastVO);
});
return contrastVOS;
}
@Override
public List<Map> getEquipmentMFDetails(ReportStatisticsDTO reportStatisticsDTO) {
List<Map> list = new ArrayList<>();
int n = 0;
String lastMonth = null;
List<Map> listMF = new ArrayList<>();
//前端传入公司id和需要展示的层级
if (StrUtil.isEmpty(reportStatisticsDTO.getCompanyId()) && null == reportStatisticsDTO.getIsCompany()) {
String realFactoryId = (String) BaseContextHandler.get("realFactoryId");
reportStatisticsDTO.setCompanyId(realFactoryId);
String orgCode = BaseContextHandler.getOrgCode();
n = orgCode.length() - orgCode.replaceAll("A", "").length();
} else {
n = reportStatisticsDTO.getIsCompany();
}
List<Map> failures = new ArrayList<>();
List<Map> runTime = new ArrayList<>();
List<Map> faultEquipment = new ArrayList<>();
if (n == 1) {
failures = productionEquipmentMapper.getFailuresByHeadquarters(reportStatisticsDTO);
runTime = productionEquipmentMapper.getRunTimeByHeadquarters(reportStatisticsDTO);
faultEquipment = productionEquipmentMapper.getFaultEquipmentByHeadquarters(reportStatisticsDTO);
} else if (n == 2) {
failures = productionEquipmentMapper.getFailuresByBranchOffice(reportStatisticsDTO);
runTime = productionEquipmentMapper.getRunTimeByBranchOffice(reportStatisticsDTO);
faultEquipment = productionEquipmentMapper.getFaultEquipmentByBranchOffice(reportStatisticsDTO);
} else {
failures = productionEquipmentMapper.getFailuresByFactory(reportStatisticsDTO);
runTime = productionEquipmentMapper.getRunTimeByFactory(reportStatisticsDTO);
faultEquipment = productionEquipmentMapper.getFaultEquipmentByFactory(reportStatisticsDTO);
}
List<Map> finalRunTime = runTime;
List<Map> finalFailures = failures;
int finalN = n;
faultEquipment.forEach(f -> {
Map map = new HashMap<>();
String departName = f.get("departName").toString();
String departId = f.get("departId").toString();
String faultEquipment1 = f.get("faultEquipment").toString();
map.put("departName", departName);
map.put("departId", departId);
map.put("type", finalN);
map.put("MTBF", 0);
finalRunTime.forEach(r -> {
String runTime1 = r.get("runTime").toString();
String departName1 = r.get("departName").toString();
if (departName.equals(departName1)) {
finalFailures.forEach(f1 -> {
String failures1 = f1.get("failures").toString();
String departName2 = f1.get("departName").toString();
if (departName2.equals(departName1)) {
Double v = Double.parseDouble(runTime1) / Integer.parseInt(failures1) / Integer.parseInt(faultEquipment1);
v = DoubleOperaUtils.bigDecimalRound(v, 2);
map.put("MTBF", v);
}
});
}
});
listMF.add(map);
});
List<Map> downTime = new ArrayList<>();
List<Map> equipmentNum = new ArrayList<>();
if (n == 1) {
downTime = productionEquipmentMapper.getDownTimeByMonthHeadquarters(reportStatisticsDTO);
equipmentNum = productionEquipmentMapper.getEquipmentNumByMonthHeadquarters(reportStatisticsDTO);
} else if (n == 2) {
downTime = productionEquipmentMapper.getDownTimeByBranchOffice(reportStatisticsDTO);
equipmentNum = productionEquipmentMapper.getEquipmentNumByBranchOffice(reportStatisticsDTO);
} else {
downTime = productionEquipmentMapper.getDownTimeByFactory(reportStatisticsDTO);
equipmentNum = productionEquipmentMapper.getEquipmentNumByFactory(reportStatisticsDTO);
}
List<Map> finalDownTime = downTime;
List<Map> finalEquipmentNum = equipmentNum;
listMF.forEach(l -> {
String departName1 = l.get("departName").toString();
l.put("MTTR", 0);
finalDownTime.forEach(d -> {
String departName = d.get("departName").toString();
String downtime = d.get("downtime").toString();
if (departName1.equals(departName)) {
finalEquipmentNum.forEach(e -> {
String equipmentNum1 = e.get("equipmentNum").toString();
String companyName = e.get("companyName").toString();
if (companyName.equals(departName)) {
Double v1 = Double.parseDouble(downtime) / Integer.parseInt(equipmentNum1);
v1 = DoubleOperaUtils.bigDecimalRound(v1, 2);
l.put("MTTR", v1);
}
});
}
});
});
return listMF;
}
@Override
public List<ContrastVO> getMaintainCompleteRate(ReportStatisticsDTO reportStatisticsDTO) {
List<ContrastVO> contrastVOS = new ArrayList<>();
List<Map> completeRate = new ArrayList<>();
List<Map> completeYearOnYearRate = new ArrayList<>();
if (reportStatisticsDTO.getTimeUnit() == 6) {
completeRate = productionEquipmentMapper.getHalfIntactCompleteRate();
completeYearOnYearRate = productionEquipmentMapper.getHalfIntactCompleteYearOnYearRate();
} else {
completeRate = productionEquipmentMapper.getOneYearCompleteRate();
completeYearOnYearRate = productionEquipmentMapper.getOneYearCompleteYearOnYearRate();
}
List<Map> finalCompleteYearOnYearRate = completeYearOnYearRate;
completeRate.forEach(c -> {
ContrastVO contrastVO = new ContrastVO();
String month = c.get("month").toString();
String m = month.substring(5);
String planNum = c.get("planNum").toString();
String completeNum = c.get("completeNum").toString();
contrastVO.setMonth(month);
Double d = 0.00;
if (!"0".equals(planNum)) {
d = Double.parseDouble(completeNum) / Double.parseDouble(planNum) * 100;
//保留两位小数
d = DoubleOperaUtils.bigDecimalRound(d,2);
}
contrastVO.setRepairNum(d.toString());
finalCompleteYearOnYearRate.forEach(y -> {
String month1 = y.get("month").toString();
String m1 = month1.substring(5);
if (m1.equals(m)) {
String planNum1 = y.get("planNum").toString();
String completeNum1 = y.get("completeNum").toString();
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());
}
});
contrastVOS.add(contrastVO);
});
return contrastVOS;
}
@Override
public List<Map> getMaintainCompleteRateDetails(ReportStatisticsDTO reportStatisticsDTO) {
List<Map> list = new ArrayList<>();
int n = 0;
String lastMonth = null;
//前端传入公司id和需要展示的层级
if (StrUtil.isEmpty(reportStatisticsDTO.getCompanyId()) && null == reportStatisticsDTO.getIsCompany()) {
String realFactoryId = (String) BaseContextHandler.get("realFactoryId");
reportStatisticsDTO.setCompanyId(realFactoryId);
String orgCode = BaseContextHandler.getOrgCode();
n = orgCode.length() - orgCode.replaceAll("A", "").length();
} else {
n = reportStatisticsDTO.getIsCompany();
}
Date parse = null;
DateFormat format = new SimpleDateFormat("yyyy-MM");
try {
parse = format.parse(reportStatisticsDTO.getTime());
Calendar calendar = Calendar.getInstance();
calendar.setTime(parse);
calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - 1);
calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) + 1);
lastMonth = format.format(calendar.getTime());
} catch (Exception e) {
e.getMessage();
}
List<Map> maintainPlanByHeadquarters = new ArrayList<>();
List<Map> maintainPlanByHeadquarters1 = new ArrayList<>();
List<Map> maintainPlanByHeadquarters2 = new ArrayList<>();
List<Map> maintainPlanByHeadquarters3 = new ArrayList<>();
if (n == 1) {
maintainPlanByHeadquarters = productionEquipmentMapper.getMaintainPlanByHeadquarters(reportStatisticsDTO);
reportStatisticsDTO.setLabelType(2);
maintainPlanByHeadquarters1 = productionEquipmentMapper.getMaintainPlanByHeadquarters(reportStatisticsDTO);
reportStatisticsDTO.setTime(lastMonth);
reportStatisticsDTO.setLabelType(null);
maintainPlanByHeadquarters2 = productionEquipmentMapper.getMaintainPlanByHeadquarters(reportStatisticsDTO);
reportStatisticsDTO.setLabelType(2);
maintainPlanByHeadquarters3 = productionEquipmentMapper.getMaintainPlanByHeadquarters(reportStatisticsDTO);
} else if (n == 2) {
maintainPlanByHeadquarters = productionEquipmentMapper.getMaintainPlanByBranchOffice(reportStatisticsDTO);
reportStatisticsDTO.setLabelType(2);
maintainPlanByHeadquarters1 = productionEquipmentMapper.getMaintainPlanByBranchOffice(reportStatisticsDTO);
reportStatisticsDTO.setTime(lastMonth);
reportStatisticsDTO.setLabelType(null);
maintainPlanByHeadquarters2 = productionEquipmentMapper.getMaintainPlanByBranchOffice(reportStatisticsDTO);
reportStatisticsDTO.setLabelType(2);
maintainPlanByHeadquarters3 = productionEquipmentMapper.getMaintainPlanByBranchOffice(reportStatisticsDTO);
} else {
maintainPlanByHeadquarters = productionEquipmentMapper.getMaintainPlanByFactory(reportStatisticsDTO);
reportStatisticsDTO.setLabelType(2);
maintainPlanByHeadquarters1 = productionEquipmentMapper.getMaintainPlanByFactory(reportStatisticsDTO);
reportStatisticsDTO.setTime(lastMonth);
reportStatisticsDTO.setLabelType(null);
maintainPlanByHeadquarters2 = productionEquipmentMapper.getMaintainPlanByFactory(reportStatisticsDTO);
reportStatisticsDTO.setLabelType(2);
maintainPlanByHeadquarters3 = productionEquipmentMapper.getMaintainPlanByFactory(reportStatisticsDTO);
}
List<Map> finalMaintainPlanByHeadquarters = maintainPlanByHeadquarters1;
List<Map> finalMaintainPlanByHeadquarters1 = maintainPlanByHeadquarters2;
List<Map> finalMaintainPlanByHeadquarters2 = maintainPlanByHeadquarters3;
int finalN = n;
maintainPlanByHeadquarters.forEach(m -> {
Map map = new HashMap<>();
String departName = m.get("departName").toString();
String departId = m.get("departId").toString();
String planNum = m.get("planNum").toString();
map.put("departName", departName);
map.put("departId", departId);
map.put("complete", 0);
map.put("lastYearComplete", 0);
map.put("type", finalN);
finalMaintainPlanByHeadquarters.forEach(m1 -> {
String departName1 = m1.get("departName").toString();
if (departName.equals(departName1)) {
String planNum1 = m1.get("planNum").toString();
Double v = Integer.parseInt(planNum1) / Integer.parseInt(planNum) * 100.00;
map.put("complete", v);
}
});
finalMaintainPlanByHeadquarters1.forEach(m2 -> {
String departName1 = m2.get("departName").toString();
if (departName1.equals(departName)) {
String planNum1 = m2.get("planNum").toString();
finalMaintainPlanByHeadquarters2.forEach(m3 -> {
String departName2 = m3.get("departName").toString();
if (departName2.equals(departName1)) {
String planNum2 = m3.get("planNum").toString();
Double o = Integer.parseInt(planNum2) / Integer.parseInt("planNum1") * 100.00;
map.put("lastYearComplete", o);
}
});
}
});
list.add(map);
});
return list;
}
//维修维护费用对比
@Override
public List<ContrastVO> getContrastCost(ReportStatisticsDTO reportStatisticsDTO) {
List<ContrastVO> list = new ArrayList<>();
List<Map> contrastCost = new ArrayList<>();
if (reportStatisticsDTO.getTimeUnit() == 6) {//半年
contrastCost = productionEquipmentMapper.getHalfIntactContrastCost(reportStatisticsDTO.getDepartIds());
} else {
contrastCost = productionEquipmentMapper.getOneYearContrastCost(reportStatisticsDTO.getDepartIds());
}
contrastCost.forEach(c -> {
ContrastVO contrastVO = new ContrastVO();
String month = c.get("month").toString();
String maintainCost = c.get("maintainCost").toString();
String repairCost = c.get("repairCost").toString();
contrastVO.setMonth(month);
contrastVO.setMaintainNum(maintainCost);
contrastVO.setRepairNum(repairCost);
list.add(contrastVO);
});
return list;
}
//维护维修费用详情
@Override
public List<Map> getContrastCostDetails(ReportStatisticsDTO reportStatisticsDTO) {
return productionEquipmentMapper.getContrastCostDetails(reportStatisticsDTO);
}
*/
/* @Override
public List<Map> getContrastCostDetails(ReportStatisticsDTO reportStatisticsDTO) {
List<Map> list = new ArrayList<>();
int n = 0;
String lastMonth = null;
//前端传入公司id和需要展示的层级
if (StrUtil.isEmpty(reportStatisticsDTO.getCompanyId()) && null == reportStatisticsDTO.getIsCompany()) {
String realFactoryId = (String) BaseContextHandler.get("realFactoryId");
reportStatisticsDTO.setCompanyId(realFactoryId);
String orgCode = BaseContextHandler.getOrgCode();
n = orgCode.length() - orgCode.replaceAll("A", "").length();
} else {
n = reportStatisticsDTO.getIsCompany();
}
List<Map> maintainCost = new ArrayList<>();
List<Map> repairCost = new ArrayList<>();
if (n == 1) {
maintainCost = productionEquipmentMapper.getMaintainCostByHeadquarters(reportStatisticsDTO);
repairCost = productionEquipmentMapper.getRepairCostByHeadquarters(reportStatisticsDTO);
} else if (n == 2) {
maintainCost = productionEquipmentMapper.getMaintainCostByBranchOffice(reportStatisticsDTO);
repairCost = productionEquipmentMapper.getRepairCostByBranchOffice(reportStatisticsDTO);
} else {
maintainCost = productionEquipmentMapper.getMaintainCostByFactory(reportStatisticsDTO);//维护金额
repairCost = productionEquipmentMapper.getRepairCostByFactory(reportStatisticsDTO);
}
List<Map> finalRepairCost = repairCost;
if (maintainCost.size() > repairCost.size()) {
int finalN = n;
maintainCost.forEach(m -> {
Map map = new HashMap<>();
String departName = m.get("departName").toString();
String departId = m.get("departId").toString();
String maintainCost1 = m.get("maintainCost").toString();
map.put("departName", departName);
map.put("departId", departId);
map.put("maintainCost", maintainCost1);
map.put("repairCost", 0);
map.put("type", finalN);
finalRepairCost.forEach(r -> {
String departName1 = r.get("departName").toString();
String repairCost1 = r.get("repairCost").toString();
if (departName1.equals(departName)) {
map.put("repairCost", repairCost1);
}
});
list.add(map);
});
} else {
List<Map> finalMaintainCost = maintainCost;
int finalN1 = n;
repairCost.forEach(r -> {
Map map = new HashMap<>();
String departName1 = r.get("departName").toString();
String departId = r.get("departId").toString();
map.put("departId", departId);
//String repairCost1 = r.get("repairCost").toString();
String repairCost1 = ConvertUtils.getString(r.get("repairCost"));
map.put("departName", departName1);
map.put("repairCost", repairCost1);
map.put("maintainCost", 0);
map.put("type", finalN1);
finalMaintainCost.forEach(m -> {
String departName = m.get("departName").toString();
String maintainCost1 = m.get("maintainCost").toString();
if (departName1.equals(departName)) {
map.put("maintainCost", maintainCost1);
}
});
list.add(map);
});
}
return list;
}*//*
}
*/
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.core.context.BaseContextHandler;
import com.skua.core.util.ConvertUtils;
import com.skua.core.util.DoubleOperaUtils;
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.IProductionEquipmentService;
import com.skua.modules.equipment.vo.*;
import com.skua.tool.util.JSUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -34,6 +37,7 @@ import java.util.*;
public class ProductionEquipmentServiceImpl implements IProductionEquipmentService {
@Autowired
private ProductionEquipmentMapper productionEquipmentMapper;
private static final String MONTH_START = "-01 00:00:00";
private static final String MONTH_END = "-31 23:59:59";
private static final String YEAR_START = "-01-01 00:00:00";
......@@ -163,6 +167,8 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
goodDay = 365 - Double.parseDouble(downtime1);
//上一年的设备完好率
Integer lastYear = Integer.parseInt(reportStatisticsDTO.getTime()) - 1;
Map downtime2 = productionEquipmentMapper.getDowntime(lastYear + YEAR_START, lastYear + YEAR_END);
String downtime3 = null;
if (null == downtime2.get("downtime")) {
......@@ -248,12 +254,28 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
public FaultStatisticsVO getEquipmentStatistics(ReportStatisticsDTO reportStatisticsDTO) {
FaultStatisticsVO faultStatisticsVO = new FaultStatisticsVO();
List<ProportionStatisticsVO> levelByTime = productionEquipmentMapper.getLevelByTime(reportStatisticsDTO);
if (levelByTime.size() > 0) {
/*if (levelByTime.size() > 0) {
levelByTime.forEach(l -> {
reportStatisticsDTO.setEquipmentLevel(l.getCategory());
List<ProportionStatisticsVO> typeByTime = productionEquipmentMapper.getTypeByTime(reportStatisticsDTO);
l.setProportionStatisticsVOList(typeByTime);
});
}*/
Double equipmentTotal = 0d;
//获取总记录数
if(levelByTime != null && !levelByTime.isEmpty()){
for(ProportionStatisticsVO statisticsVO : levelByTime){
equipmentTotal = equipmentTotal + ConvertUtils.getDouble( statisticsVO.getHour(),0d) ;
}
}
//计算比例
if(equipmentTotal.doubleValue() > 0 ){
// CONCAT( ROUND( IFNULL( t1.equipmentNum, 0 ) / t2.equipmentTotal, 3 )* 100, '%' ) AS proportion
equipmentTotal = equipmentTotal * 0.01d;
for(ProportionStatisticsVO statisticsVO : levelByTime){
statisticsVO.setProportion(JSUtils.divide(statisticsVO.getHour(),equipmentTotal));
}
}
faultStatisticsVO.setLevel(levelByTime);
return faultStatisticsVO;
......@@ -357,6 +379,17 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
return pageList.setRecords(equipmentStatistics);
}
@Override
public IPage<EquipmentStatisticsCountVO> getEquipmentStatisticsDetailsNew(Page<EquipmentStatisticsCountVO> pageList, ReportStatisticsDTO reportStatisticsDTO) {
/* String dict_sql = "select t.item_value as 'id' , t.item_text , 'name' from sys_dict_item t where t.dict_id in (select id from sys_dict where dict_code = 'equipment-equipment_level') order by t.id asc ";
List<Map<String,Object>> mapList = commonSqlService.queryForList(dict_sql);
List<String> categoryNameList = new ArrayList<>();
List<String> categoryIdList = new ArrayList<>();*/
return productionEquipmentMapper.getEquipmentStatisticsDetailsNew(pageList,reportStatisticsDTO);
}
@Override
public List<TOPTenVO> getEquipmentState(ReportStatisticsDTO reportStatisticsDTO) {
List<TOPTenVO> list = new ArrayList<>();
......@@ -453,7 +486,7 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
}
return pageList.setRecords(equipmentStatistics);
}
//设备完好率
@Override
public List<ContrastVO> getEquipmentIntactRate(ReportStatisticsDTO reportStatisticsDTO) {
List<ContrastVO> list = new ArrayList<>();
......@@ -463,8 +496,8 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
rate = productionEquipmentMapper.getHalfIntactRate();
onYearRate = productionEquipmentMapper.getHalfIntactYearOnYearRate();
} else {
rate = productionEquipmentMapper.getOneYearRate();
onYearRate = productionEquipmentMapper.getOneYearYearOnYearRate();
rate = productionEquipmentMapper.getOneYearRate();//一年完好率
onYearRate = productionEquipmentMapper.getOneYearYearOnYearRate();//一年同比
}
List<Map> yearOnYear = onYearRate;
rate.forEach(h -> {
......@@ -497,7 +530,7 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
});
return list;
}
//设备完好率详情
@Override
public List<Map> getEquipmentIntactRateDetails(ReportStatisticsDTO reportStatisticsDTO) {
List<Map> list = new ArrayList<>();
......@@ -529,27 +562,27 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
List<Map> downTimeByMonthHeadquartersLastYear = null;
List<Map> equipmentNumByMonthHeadquartersLastYear = null;
if (n == 1) {
downTimeByMonthHeadquarters = productionEquipmentMapper.getDownTimeByMonthHeadquarters(reportStatisticsDTO);
equipmentNumByMonthHeadquarters = productionEquipmentMapper.getEquipmentNumByMonthHeadquarters(reportStatisticsDTO);
downTimeByMonthHeadquarters = productionEquipmentMapper.getDownTimeByMonthHeadquarters(reportStatisticsDTO);//总公司获取停机时间
equipmentNumByMonthHeadquarters = productionEquipmentMapper.getEquipmentNumByMonthHeadquarters(reportStatisticsDTO);//总公司获取设备数量
reportStatisticsDTO.setTime(lastMonth);
downTimeByMonthHeadquartersLastYear = productionEquipmentMapper.getDownTimeByMonthHeadquarters(reportStatisticsDTO);
equipmentNumByMonthHeadquartersLastYear = productionEquipmentMapper.getEquipmentNumByMonthHeadquarters(reportStatisticsDTO);
downTimeByMonthHeadquartersLastYear = productionEquipmentMapper.getDownTimeByMonthHeadquarters(reportStatisticsDTO);//总公司获取停机时间
equipmentNumByMonthHeadquartersLastYear = productionEquipmentMapper.getEquipmentNumByMonthHeadquarters(reportStatisticsDTO);//总公司获取设备数量
} else if (n == 2) {
downTimeByMonthHeadquarters = productionEquipmentMapper.getDownTimeByBranchOffice(reportStatisticsDTO);
downTimeByMonthHeadquarters = productionEquipmentMapper.getDownTimeByBranchOffice(reportStatisticsDTO);//分公司
equipmentNumByMonthHeadquarters = productionEquipmentMapper.getEquipmentNumByBranchOffice(reportStatisticsDTO);
reportStatisticsDTO.setTime(lastMonth);
downTimeByMonthHeadquartersLastYear = productionEquipmentMapper.getDownTimeByBranchOffice(reportStatisticsDTO);
equipmentNumByMonthHeadquartersLastYear = productionEquipmentMapper.getEquipmentNumByBranchOffice(reportStatisticsDTO);
} else {
downTimeByMonthHeadquarters = productionEquipmentMapper.getDownTimeByFactory(reportStatisticsDTO);
equipmentNumByMonthHeadquarters = productionEquipmentMapper.getEquipmentNumByFactory(reportStatisticsDTO);
downTimeByMonthHeadquarters = productionEquipmentMapper.getDownTimeByFactory(reportStatisticsDTO);//厂站 停机时间
equipmentNumByMonthHeadquarters = productionEquipmentMapper.getEquipmentNumByFactory(reportStatisticsDTO);// 厂站信息
reportStatisticsDTO.setTime(lastMonth);
downTimeByMonthHeadquartersLastYear = productionEquipmentMapper.getDownTimeByFactory(reportStatisticsDTO);
equipmentNumByMonthHeadquartersLastYear = productionEquipmentMapper.getEquipmentNumByFactory(reportStatisticsDTO);
}
List<Map> finalEquipmentNumByMonthHeadquarters = equipmentNumByMonthHeadquarters;
List<Map> finalDownTimeByMonthHeadquartersLastYear = downTimeByMonthHeadquartersLastYear;
List<Map> finalEquipmentNumByMonthHeadquartersLastYear = equipmentNumByMonthHeadquartersLastYear;
List<Map> finalDownTimeByMonthHeadquartersLastYear = downTimeByMonthHeadquartersLastYear;//总公司获取停机时间
List<Map> finalEquipmentNumByMonthHeadquartersLastYear = equipmentNumByMonthHeadquartersLastYear;//总公司获取设备数量
int finalN = n;
downTimeByMonthHeadquarters.forEach(d -> {
Map map = new HashMap<>();
......@@ -593,6 +626,10 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
return list;
}
//设备完好率详情(新)
public List<Map> getEquipmentIntactRateDetailsNew(ReportStatisticsDTO reportStatisticsDTO) {
return productionEquipmentMapper.getEquipmentIntactRateDetailsNew(reportStatisticsDTO);
}
@Override
public List<ContrastVO> getEquipmentMF(ReportStatisticsDTO reportStatisticsDTO) {
List<ContrastVO> contrastVOS = new ArrayList<>();
......@@ -891,14 +928,15 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
return list;
}
//维修维护费用对比
@Override
public List<ContrastVO> getContrastCost(ReportStatisticsDTO reportStatisticsDTO) {
List<ContrastVO> list = new ArrayList<>();
List<Map> contrastCost = new ArrayList<>();
if (reportStatisticsDTO.getTimeUnit() == 6) {
contrastCost = productionEquipmentMapper.getHalfIntactContrastCost();
if (reportStatisticsDTO.getTimeUnit() == 6) {//半年
contrastCost = productionEquipmentMapper.getHalfIntactContrastCost(reportStatisticsDTO.getDepartIds());
} else {
contrastCost = productionEquipmentMapper.getOneYearContrastCost();
contrastCost = productionEquipmentMapper.getOneYearContrastCost(reportStatisticsDTO.getDepartIds());
}
contrastCost.forEach(c -> {
ContrastVO contrastVO = new ContrastVO();
......@@ -913,8 +951,14 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
return list;
}
//维护维修费用详情
@Override
public List<Map> getContrastCostDetails(ReportStatisticsDTO reportStatisticsDTO) {
return productionEquipmentMapper.getContrastCostDetails(reportStatisticsDTO);
}
/* @Override
public List<Map> getContrastCostDetails(ReportStatisticsDTO reportStatisticsDTO) {
List<Map> list = new ArrayList<>();
int n = 0;
String lastMonth = null;
......@@ -936,7 +980,7 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
maintainCost = productionEquipmentMapper.getMaintainCostByBranchOffice(reportStatisticsDTO);
repairCost = productionEquipmentMapper.getRepairCostByBranchOffice(reportStatisticsDTO);
} else {
maintainCost = productionEquipmentMapper.getMaintainCostByFactory(reportStatisticsDTO);
maintainCost = productionEquipmentMapper.getMaintainCostByFactory(reportStatisticsDTO);//维护金额
repairCost = productionEquipmentMapper.getRepairCostByFactory(reportStatisticsDTO);
}
List<Map> finalRepairCost = repairCost;
......@@ -987,6 +1031,6 @@ public class ProductionEquipmentServiceImpl implements IProductionEquipmentServi
}
return list;
}
}*/
}
......
package com.skua.modules.equipment.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @auther kangwei
* @create 2024-12-27-15:32
*/
@Data
@ApiModel(value = "设备统计数量对象", description = "设备统计数量对象")
public class EquipmentStatisticsCountVO {
@ApiModelProperty(value = "厂站名称")
private String departName;
@ApiModelProperty(value = "厂站编号")
private String departId;
@ApiModelProperty(value = "分类1数量")
private String categoryValue1;
@ApiModelProperty(value = "分类2数量")
private String categoryValue2;
@ApiModelProperty(value = "分类3数量")
private String categoryValue3;
}
......@@ -20,7 +20,7 @@ public class ProportionStatisticsVO {
//类别
private String category;
//占比
private String proportion;
private String proportion = "0%";
// 小时
private String hour;
//设备中心的设备统计用
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!