zhangherong
2025-05-06 915a2e40175c6390802af1257e57effea5fd02ef
art: 设备管理-看板接口-点检、周保统计接口
已添加2个文件
已修改9个文件
261 ■■■■■ 文件已修改
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamDashboardController.java 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EamInspectionOrderMapper.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EamWeekMaintenanceOrderMapper.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EamInspectionOrderMapper.xml 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EamWeekMaintenanceOrderMapper.xml 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEamInspectionOrderService.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEamWeekMaintenanceOrderService.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamInspectionOrderServiceImpl.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/vo/EquipmentInspectionStatistics.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/vo/EquipmentMaintenanceStatistics.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamDashboardController.java
@@ -9,7 +9,11 @@
import org.jeecg.modules.eam.constant.EquipmentRepairStatus;
import org.jeecg.modules.eam.entity.EamEquipment;
import org.jeecg.modules.eam.service.IEamEquipmentService;
import org.jeecg.modules.eam.service.IEamInspectionOrderService;
import org.jeecg.modules.eam.service.IEamReportRepairService;
import org.jeecg.modules.eam.service.IEamWeekMaintenanceOrderService;
import org.jeecg.modules.eam.vo.EquipmentInspectionStatistics;
import org.jeecg.modules.eam.vo.EquipmentMaintenanceStatistics;
import org.jeecg.modules.eam.vo.EquipmentRepairStatistics;
import org.jeecg.modules.eam.vo.EquipmentStatusStatistics;
import org.springframework.beans.factory.annotation.Autowired;
@@ -30,6 +34,10 @@
    private IEamEquipmentService eamEquipmentService;
    @Autowired
    private IEamReportRepairService reportRepairService;
    @Autowired
    private IEamInspectionOrderService inspectionOrderService;
    @Autowired
    private IEamWeekMaintenanceOrderService weekMaintenanceOrderService;
    @ApiOperation(value = "看板接口-维保状态统计", notes = "看板接口-维保状态统计")
    @GetMapping(value = "/equipmentStatusStatistics")
@@ -87,4 +95,60 @@
        resultList.sort(Comparator.comparing(EquipmentRepairStatistics::getMonthStr));
        return Result.ok(resultList);
    }
    @ApiOperation(value = "看板接口-点检统计", notes = "看板接口-点检统计")
    @GetMapping(value = "/equipmentInspectionStatistics")
    public Result<?> equipmentInspectionStatistics(@RequestParam(required = false, value = "productionId") String productionId) {
        //统计结束日期
        LocalDate today = LocalDate.now();
        LocalDate localDate = today.minusMonths(5);
        //统计开始日期
        LocalDate firstOfMonth = DateUtils.getFirstOfMonth(localDate);
        //初始化返回值
        Map<String, EquipmentInspectionStatistics> statisticsMap = new HashMap<>();
        List<String> monthsBetween = DateUtils.getMonthsBetween(firstOfMonth, today);
        monthsBetween.forEach(month -> {
            statisticsMap.put(month, new EquipmentInspectionStatistics(month));
        });
        List<EquipmentInspectionStatistics> list = inspectionOrderService.equipmentInspectionStatistics(productionId, firstOfMonth, today);
        for (EquipmentInspectionStatistics statistics : list) {
            if (statisticsMap.containsKey(statistics.getMonthStr())) {
                statisticsMap.put(statistics.getMonthStr(), statistics);
            }
        }
        List<EquipmentInspectionStatistics> resultList = new ArrayList<>(statisticsMap.values());
        //排序
        resultList.sort(Comparator.comparing(EquipmentInspectionStatistics::getMonthStr));
        return Result.ok(resultList);
    }
    @ApiOperation(value = "看板接口-周保统计", notes = "看板接口-周保统计")
    @GetMapping(value = "/equipmentMaintenanceStatistics")
    public Result<?> equipmentMaintenanceStatistics(@RequestParam(required = false, value = "productionId") String productionId) {
        //统计结束日期
        LocalDate today = LocalDate.now();
        LocalDate localDate = today.minusMonths(5);
        //统计开始日期
        LocalDate firstOfMonth = DateUtils.getFirstOfMonth(localDate);
        //初始化返回值
        Map<String, EquipmentMaintenanceStatistics> statisticsMap = new HashMap<>();
        List<String> monthsBetween = DateUtils.getMonthsBetween(firstOfMonth, today);
        monthsBetween.forEach(month -> {
            statisticsMap.put(month, new EquipmentMaintenanceStatistics(month));
        });
        List<EquipmentMaintenanceStatistics> list = weekMaintenanceOrderService.equipmentMaintenanceStatistics(productionId, firstOfMonth, today);
        for (EquipmentMaintenanceStatistics statistics : list) {
            if (statisticsMap.containsKey(statistics.getMonthStr())) {
                statisticsMap.put(statistics.getMonthStr(), statistics);
            }
        }
        List<EquipmentMaintenanceStatistics> resultList = new ArrayList<>(statisticsMap.values());
        //排序
        resultList.sort(Comparator.comparing(EquipmentMaintenanceStatistics::getMonthStr));
        return Result.ok(resultList);
    }
}
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EamInspectionOrderMapper.java
@@ -8,6 +8,9 @@
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.eam.entity.EamInspectionOrder;
import org.jeecg.modules.eam.entity.EamWeekMaintenanceOrder;
import org.jeecg.modules.eam.vo.EquipmentInspectionStatistics;
import java.util.List;
/**
 * @Description: ç‚¹æ£€å·¥å•
@@ -24,4 +27,13 @@
     * @return
     */
    IPage<EamInspectionOrder> queryPageList(Page<EamInspectionOrder> page, @Param(Constants.WRAPPER) QueryWrapper<EamInspectionOrder> queryWrapper);
    /**
     * ç‚¹æ£€ç»Ÿè®¡
     * @param productionIds
     * @param start
     * @param end
     * @return
     */
    List<EquipmentInspectionStatistics> equipmentInspectionStatistics(@Param("productionIds") List<String> productionIds, @Param("start") String start, @Param("end") String end);
}
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EamWeekMaintenanceOrderMapper.java
@@ -7,6 +7,9 @@
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.eam.entity.EamWeekMaintenanceOrder;
import org.jeecg.modules.eam.vo.EquipmentMaintenanceStatistics;
import java.util.List;
/**
 * @Description: å‘¨ä¿å·¥å•
@@ -22,4 +25,13 @@
     * @return
     */
    IPage<EamWeekMaintenanceOrder> queryPageList(IPage<EamWeekMaintenanceOrder> page, @Param(Constants.WRAPPER) Wrapper<EamWeekMaintenanceOrder> queryWrapper);
    /**
     * ä¿å…»ç»Ÿè®¡
     * @param productionIds
     * @param start
     * @param end
     * @return
     */
    List<EquipmentMaintenanceStatistics> equipmentMaintenanceStatistics(@Param("productionIds") List<String> productionIds, @Param("start") String start, @Param("end") String end);
}
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EamInspectionOrderMapper.xml
@@ -9,4 +9,24 @@
        on wmo.equipment_id = e.id
        ${ew.customSqlSegment}
    </select>
    <select id="equipmentInspectionStatistics"
            resultType="org.jeecg.modules.eam.vo.EquipmentInspectionStatistics">
        select FORMAT(err.inspection_date, 'yyyy-MM') as monthStr,
        COUNT(1) as planNumber,
        SUM(CASE WHEN err.inspection_status = 'COMPLETE' THEN 1 ELSE 0 END) as completeNumber
        from eam_inspection_order err
        inner join eam_equipment e
        on err.equipment_id = e.id
        where err.inspection_status != 'ABOLISH' and err.del_flag = 0 and e.del_flag = 0
        <if test="productionIds != null">
            AND e.org_id IN
            <foreach collection="productionIds" item="productionId" index="index" open="(" close=")" separator=",">
                #{productionId}
            </foreach>
        </if>
        and err.inspection_date &gt;= #{start}
        and err.inspection_date &lt; #{end}
        group by FORMAT(err.inspection_date, 'yyyy-MM')
    </select>
</mapper>
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EamWeekMaintenanceOrderMapper.xml
@@ -9,4 +9,24 @@
        on wmo.equipment_id = e.id
        ${ew.customSqlSegment}
    </select>
    <select id="equipmentMaintenanceStatistics"
            resultType="org.jeecg.modules.eam.vo.EquipmentMaintenanceStatistics">
        select FORMAT(err.maintenance_date, 'yyyy-MM') as monthStr,
        COUNT(1) as planNumber,
        SUM(CASE WHEN err.maintenance_status = 'COMPLETE' THEN 1 ELSE 0 END) as completeNumber
        from eam_week_maintenance_order err
        inner join eam_equipment e
        on err.equipment_id = e.id
        where err.maintenance_status != 'ABOLISH' and err.del_flag = 0 and e.del_flag = 0
        <if test="productionIds != null">
            AND e.org_id IN
            <foreach collection="productionIds" item="productionId" index="index" open="(" close=")" separator=",">
                #{productionId}
            </foreach>
        </if>
        and err.maintenance_date &gt;= #{start}
        and err.maintenance_date &lt; #{end}
        group by FORMAT(err.maintenance_date, 'yyyy-MM')
    </select>
</mapper>
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEamInspectionOrderService.java
@@ -7,7 +7,9 @@
import org.jeecg.modules.eam.entity.EamInspectionOrder;
import org.jeecg.modules.eam.request.EamInspectionOrderQuery;
import org.jeecg.modules.eam.request.EamInspectionOrderRequest;
import org.jeecg.modules.eam.vo.EquipmentInspectionStatistics;
import java.time.LocalDate;
import java.util.List;
/**
@@ -82,4 +84,13 @@
     * @return
     */
    List<EamInspectionOrder> selectUnCompleteOrder(String expiredDate);
    /**
     * ç‚¹æ£€ç»Ÿè®¡
     * @param productionId
     * @param firstOfMonth
     * @param today
     * @return
     */
    List<EquipmentInspectionStatistics> equipmentInspectionStatistics(String productionId, LocalDate firstOfMonth, LocalDate today);
}
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEamWeekMaintenanceOrderService.java
@@ -6,7 +6,9 @@
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.eam.request.EamWeekMaintenanceQuery;
import org.jeecg.modules.eam.request.EamWeekMaintenanceRequest;
import org.jeecg.modules.eam.vo.EquipmentMaintenanceStatistics;
import java.time.LocalDate;
import java.util.List;
/**
@@ -59,4 +61,13 @@
     * @return
     */
    List<EamWeekMaintenanceOrder> selectUnCompleteOrder(String expiredDate);
    /**
     * ä¿å…»ç»Ÿè®¡
     * @param productionId
     * @param firstOfMonth
     * @param today
     * @return
     */
    List<EquipmentMaintenanceStatistics> equipmentMaintenanceStatistics(String productionId, LocalDate firstOfMonth, LocalDate today);
}
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamInspectionOrderServiceImpl.java
@@ -33,6 +33,8 @@
import org.jeecg.modules.eam.request.EamInspectionOrderQuery;
import org.jeecg.modules.eam.request.EamInspectionOrderRequest;
import org.jeecg.modules.eam.service.*;
import org.jeecg.modules.eam.vo.EquipmentInspectionStatistics;
import org.jeecg.modules.eam.vo.EquipmentRepairStatistics;
import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness;
import org.jeecg.modules.flowable.apithird.business.service.impl.FlowMyBusinessServiceImpl;
import org.jeecg.modules.flowable.apithird.service.FlowCallBackServiceI;
@@ -40,6 +42,7 @@
import org.jeecg.modules.flowable.service.IFlowDefinitionService;
import org.jeecg.modules.flowable.service.IFlowTaskService;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.service.IMdcProductionService;
import org.jeecg.modules.system.service.IMdcUserProductionService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -47,6 +50,7 @@
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
@@ -83,6 +87,8 @@
    private IEamReportRepairService eamReportRepairService;
    @Autowired
    private IEamEquipmentExtendService eamEquipmentExtendService;
    @Autowired
    private IMdcProductionService mdcProductionService;
    @Override
    public IPage<EamInspectionOrder> queryPageList(Page<EamInspectionOrder> page, EamInspectionOrderQuery query) {
@@ -148,6 +154,27 @@
    }
    @Override
    public List<EquipmentInspectionStatistics> equipmentInspectionStatistics(String productionId, LocalDate firstOfMonth, LocalDate today) {
        if (StringUtils.isNotBlank(productionId)) {
            //车间编码不为空
            List<String> productIds = mdcProductionService.recursionChildren(productionId);
            if (CollectionUtil.isEmpty(productIds)) {
                return Collections.emptyList();
            }
            List<EquipmentInspectionStatistics> list = this.baseMapper.equipmentInspectionStatistics(productIds, firstOfMonth.toString(), today.plusDays(1).toString());
            if (CollectionUtil.isEmpty(list)) {
                return Collections.emptyList();
            }
            return list;
        }
        List<EquipmentInspectionStatistics> list = this.baseMapper.equipmentInspectionStatistics(null, firstOfMonth.toString(), today.plusDays(1).toString());
        if (CollectionUtil.isEmpty(list)) {
            return Collections.emptyList();
        }
        return list;
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean addInspectionOrder(EamInspectionOrderRequest eamInspectionOrderRequest) {
        EamInspectionOrder eamInspectionOrder = new EamInspectionOrder();
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java
@@ -30,12 +30,15 @@
import org.jeecg.modules.eam.request.EamWeekMaintenanceQuery;
import org.jeecg.modules.eam.request.EamWeekMaintenanceRequest;
import org.jeecg.modules.eam.service.*;
import org.jeecg.modules.eam.vo.EquipmentInspectionStatistics;
import org.jeecg.modules.eam.vo.EquipmentMaintenanceStatistics;
import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness;
import org.jeecg.modules.flowable.apithird.business.service.IFlowMyBusinessService;
import org.jeecg.modules.flowable.apithird.service.FlowCallBackServiceI;
import org.jeecg.modules.flowable.apithird.service.FlowCommonService;
import org.jeecg.modules.flowable.service.IFlowDefinitionService;
import org.jeecg.modules.flowable.service.IFlowTaskService;
import org.jeecg.modules.system.service.IMdcProductionService;
import org.jeecg.modules.system.service.ISysUserService;
import org.jeecg.modules.system.vo.UserSelector;
import org.springframework.beans.factory.annotation.Autowired;
@@ -43,6 +46,7 @@
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
@@ -80,6 +84,8 @@
    private IEamReportRepairService eamReportRepairService;
    @Autowired
    private IEamEquipmentExtendService eamEquipmentExtendService;
    @Autowired
    private IMdcProductionService mdcProductionService;
    @Override
    @Transactional(rollbackFor = Exception.class)
@@ -499,6 +505,27 @@
        return eamWeekMaintenanceOrderMapper.selectList(queryWrapper);
    }
    @Override
    public List<EquipmentMaintenanceStatistics> equipmentMaintenanceStatistics(String productionId, LocalDate firstOfMonth, LocalDate today) {
        if (StringUtils.isNotBlank(productionId)) {
            //车间编码不为空
            List<String> productIds = mdcProductionService.recursionChildren(productionId);
            if (CollectionUtil.isEmpty(productIds)) {
                return Collections.emptyList();
            }
            List<EquipmentMaintenanceStatistics> list = this.baseMapper.equipmentMaintenanceStatistics(productIds, firstOfMonth.toString(), today.plusDays(1).toString());
            if (CollectionUtil.isEmpty(list)) {
                return Collections.emptyList();
            }
            return list;
        }
        List<EquipmentMaintenanceStatistics> list = this.baseMapper.equipmentMaintenanceStatistics(null, firstOfMonth.toString(), today.plusDays(1).toString());
        if (CollectionUtil.isEmpty(list)) {
            return Collections.emptyList();
        }
        return list;
    }
    private boolean isUserAuthorized(FlowMyBusiness flowMyBusiness, LoginUser user) {
        List<String> todoUsers = JSON.parseArray(flowMyBusiness.getTodoUsers(), String.class);
        return todoUsers != null && todoUsers.contains(user.getUsername());
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/vo/EquipmentInspectionStatistics.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,28 @@
package org.jeecg.modules.eam.vo;
import lombok.Data;
import java.io.Serializable;
@Data
public class EquipmentInspectionStatistics implements Serializable {
    /**
     * æœˆä»½
     */
    private String monthStr;
    /**
     * è®¡åˆ’æ•°
     */
    private Integer planNumber;
    /**
     * å®Œæˆæ•°
     */
    private Integer completeNumber;
    public EquipmentInspectionStatistics(){}
    public EquipmentInspectionStatistics(String monthStr){
        this.monthStr = monthStr;
        this.planNumber = 0;
        this.completeNumber = 0;
    }
}
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/vo/EquipmentMaintenanceStatistics.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,29 @@
package org.jeecg.modules.eam.vo;
import lombok.Data;
import java.io.Serializable;
@Data
public class EquipmentMaintenanceStatistics implements Serializable {
    /**
     * æœˆä»½
     */
    private String monthStr;
    /**
     * è®¡åˆ’æ•°
     */
    private Integer planNumber;
    /**
     * å®Œæˆæ•°
     */
    private Integer completeNumber;
    public EquipmentMaintenanceStatistics(){}
    public EquipmentMaintenanceStatistics(String monthStr){
        this.monthStr = monthStr;
        this.planNumber = 0;
        this.completeNumber = 0;
    }
}