From 1b937b59056f4c375e7f6f17960d2ae865dcace1 Mon Sep 17 00:00:00 2001 From: zhanghan11 Date: Wed, 26 Jun 2024 17:57:06 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/PatrolTaskWorkorderMapper.xml | 13 +- .../EhmsEamEquipmentsInfomationMapper.java | 4 + .../IEhmsEamEquipmentsInfomationService.java | 2 +- ...hmsEamEquipmentsInfomationServiceImpl.java | 153 ++++++------ .../eam/EhmsEamEquipmentsInfomationMapper.xml | 229 +++++++++++++----- 5 files changed, 262 insertions(+), 139 deletions(-) diff --git a/ehms-server/ehms-patrol/src/main/resources/mapper/PatrolTaskWorkorderMapper.xml b/ehms-server/ehms-patrol/src/main/resources/mapper/PatrolTaskWorkorderMapper.xml index ebc5ee2..9a4d4e5 100644 --- a/ehms-server/ehms-patrol/src/main/resources/mapper/PatrolTaskWorkorderMapper.xml +++ b/ehms-server/ehms-patrol/src/main/resources/mapper/PatrolTaskWorkorderMapper.xml @@ -3,7 +3,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -43,8 +43,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" from patrol_task_workorder a left join patrol_task b on a.task_id=b.id left join ehms_eam_equipments_infomation c on a.equip_id=c.id - + and workorder_code between #{params.beginWorkorderCode} and #{params.endWorkorderCode} + and a.workorder_code like concat('%', #{workorderCode}, '%') and a.workorder_status like concat('%', #{workorderStatus}, '%') and a.workorder_type like concat('%', #{workorderType}, '%') and c.equip_name like concat('%', #{equipName}, '%') @@ -64,7 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" order by a.dispatch_time desc - + - + insert into patrol_task_workorder @@ -156,7 +157,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from patrol_task_workorder where id in + delete from patrol_task_workorder where id in #{id} @@ -177,4 +178,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" FROM patrol_task_workorder - \ No newline at end of file + diff --git a/ehms-server/ehms-system/src/main/java/com/inspur/eam/mapper/EhmsEamEquipmentsInfomationMapper.java b/ehms-server/ehms-system/src/main/java/com/inspur/eam/mapper/EhmsEamEquipmentsInfomationMapper.java index f79f3b8..16b0082 100644 --- a/ehms-server/ehms-system/src/main/java/com/inspur/eam/mapper/EhmsEamEquipmentsInfomationMapper.java +++ b/ehms-server/ehms-system/src/main/java/com/inspur/eam/mapper/EhmsEamEquipmentsInfomationMapper.java @@ -94,4 +94,8 @@ public interface EhmsEamEquipmentsInfomationMapper * @return */ List getNoDataTermInfo(); + List> getPatrol(); + List> getClassList(); + List> getFileList(); + List> getLocationList(); } diff --git a/ehms-server/ehms-system/src/main/java/com/inspur/eam/service/IEhmsEamEquipmentsInfomationService.java b/ehms-server/ehms-system/src/main/java/com/inspur/eam/service/IEhmsEamEquipmentsInfomationService.java index c67b084..38eb517 100644 --- a/ehms-server/ehms-system/src/main/java/com/inspur/eam/service/IEhmsEamEquipmentsInfomationService.java +++ b/ehms-server/ehms-system/src/main/java/com/inspur/eam/service/IEhmsEamEquipmentsInfomationService.java @@ -95,5 +95,5 @@ public interface IEhmsEamEquipmentsInfomationService * 获取首页charts统计数据 * @return */ - public Map> loadChartsData(); + public Map loadChartsData(); } diff --git a/ehms-server/ehms-system/src/main/java/com/inspur/eam/service/impl/EhmsEamEquipmentsInfomationServiceImpl.java b/ehms-server/ehms-system/src/main/java/com/inspur/eam/service/impl/EhmsEamEquipmentsInfomationServiceImpl.java index f82421e..c22bfbd 100644 --- a/ehms-server/ehms-system/src/main/java/com/inspur/eam/service/impl/EhmsEamEquipmentsInfomationServiceImpl.java +++ b/ehms-server/ehms-system/src/main/java/com/inspur/eam/service/impl/EhmsEamEquipmentsInfomationServiceImpl.java @@ -23,15 +23,17 @@ import javax.validation.Validator; import java.beans.Transient; import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.stream.Collectors; /** * @Author zhangjunwen * @create 2022/11/2 */ @Service -public class EhmsEamEquipmentsInfomationServiceImpl implements IEhmsEamEquipmentsInfomationService -{ +public class EhmsEamEquipmentsInfomationServiceImpl implements IEhmsEamEquipmentsInfomationService { @Resource private EhmsEamEquipmentsInfomationMapper ehmsEamEquipmentsInfomationMapper; @@ -54,10 +56,9 @@ public class EhmsEamEquipmentsInfomationServiceImpl implements IEhmsEamEquipment * @return 资产管理系统设备信息 */ @Override - public EhmsEamEquipmentsInfomation selectEhmsEamEquipmentsInfomationById(String id) - { + public EhmsEamEquipmentsInfomation selectEhmsEamEquipmentsInfomationById(String id) { EhmsEamEquipmentsInfomation result = ehmsEamEquipmentsInfomationMapper.selectEhmsEamEquipmentsInfomationById(id); - if (result.getId() != null){ + if (result.getId() != null) { SysDept dept = sysDeptMapper.selectDeptById(result.getEquipLocationId()); result.setEquipLocation(dept.getDeptName()); } @@ -71,10 +72,9 @@ public class EhmsEamEquipmentsInfomationServiceImpl implements IEhmsEamEquipment * @return 资产管理系统设备信息 */ @Override - public List selectEhmsEamEquipmentsInfomationList(EhmsEamEquipmentsInfomation ehmsEamEquipmentsInfomation) - { + public List selectEhmsEamEquipmentsInfomationList(EhmsEamEquipmentsInfomation ehmsEamEquipmentsInfomation) { List resultList = ehmsEamEquipmentsInfomationMapper.selectEhmsEamEquipmentsInfomationList(ehmsEamEquipmentsInfomation); - if(resultList.size() != 0){ + if (resultList.size() != 0) { for (EhmsEamEquipmentsInfomation eamEquipmentsInfomation : resultList) { SysDept dept = sysDeptMapper.selectDeptById(eamEquipmentsInfomation.getEquipLocationId()); eamEquipmentsInfomation.setEquipLocation(dept.getDeptName()); @@ -91,8 +91,7 @@ public class EhmsEamEquipmentsInfomationServiceImpl implements IEhmsEamEquipment * @return 资产管理系统设备信息 */ @Override - public List selectLifeList(EhmsEamEquipmentsInfomation ehmsEamEquipmentsInfomation) - { + public List selectLifeList(EhmsEamEquipmentsInfomation ehmsEamEquipmentsInfomation) { List resultList = ehmsEamEquipmentsInfomationMapper.selectLifeList(ehmsEamEquipmentsInfomation); return resultList; @@ -100,14 +99,14 @@ public class EhmsEamEquipmentsInfomationServiceImpl implements IEhmsEamEquipment /** * 根据时间查询设备信息 + * * @return */ @Override - public List selectEhmsEamEquipmentsInfomationListByDate(String startDate,String endDate) - { + public List selectEhmsEamEquipmentsInfomationListByDate(String startDate, String endDate) { //TODO 对查询出来的设备组织id查询器组织名再赋值 - List resultList = ehmsEamEquipmentsInfomationMapper.selectEhmsEamEquipmentsInfomationListByDate(startDate,endDate); - if(resultList.size() != 0){ + List resultList = ehmsEamEquipmentsInfomationMapper.selectEhmsEamEquipmentsInfomationListByDate(startDate, endDate); + if (resultList.size() != 0) { for (EhmsEamEquipmentsInfomation eamEquipmentsInfomation : resultList) { SysDept dept = sysDeptMapper.selectDeptById(eamEquipmentsInfomation.getEquipLocationId()); eamEquipmentsInfomation.setEquipLocation(dept.getDeptName()); @@ -119,12 +118,12 @@ public class EhmsEamEquipmentsInfomationServiceImpl implements IEhmsEamEquipment /** * 导入数据 * - * @param facilityList 设备信息 + * @param facilityList 设备信息 * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据 * @return 结果 */ @Override - public String importEamEquipmentsInfomation(List facilityList, Boolean isUpdateSupport){ + public String importEamEquipmentsInfomation(List facilityList, Boolean isUpdateSupport) { if (StringUtils.isNull(facilityList) || facilityList.size() == 0) { throw new ServiceException("导入数据不能为空!"); } @@ -144,7 +143,7 @@ public class EhmsEamEquipmentsInfomationServiceImpl implements IEhmsEamEquipment deptSelect.setDeptName(ehmsEamEquipmentsInfomation.getEquipLocation()); System.err.println(deptSelect); List deptList = sysDeptMapper.selectDeptList(deptSelect); - if(deptList.size() > 1 || deptList.size() == 0){ + if (deptList.size() > 1 || deptList.size() == 0) { throw new Exception("组织不存在请重新填写"); } ehmsEamEquipmentsInfomation.setEquipLocationId(deptList.get(0).getDeptId()); @@ -183,24 +182,23 @@ public class EhmsEamEquipmentsInfomationServiceImpl implements IEhmsEamEquipment */ @Override @Transient - public int insertEhmsEamEquipmentsInfomation(EhmsEamEquipmentsInfomation ehmsEamEquipmentsInfomation) - { + public int insertEhmsEamEquipmentsInfomation(EhmsEamEquipmentsInfomation ehmsEamEquipmentsInfomation) { ehmsEamEquipmentsInfomation.setId(GetUUID.getUUID()); ehmsEamEquipmentsInfomation.setParentEquipId("0"); EhmsEamEquipmentsClass findClass = new EhmsEamEquipmentsClass(); findClass.setClassName(ehmsEamEquipmentsInfomation.getEquipClass()); List findClassList = ehmsEamEquipmentsClassMapper.selectEhmsEamEquipmentsClassList(findClass); - if (findClassList.size() == 0){ + if (findClassList.size() == 0) { ehmsEamEquipmentsInfomation.setEquipClassId(null); } ehmsEamEquipmentsInfomation.setEquipClassId(findClassList.get(0).getId()); - if(ehmsEamEquipmentsInfomation.getEquipStatus() == 1){ + if (ehmsEamEquipmentsInfomation.getEquipStatus() == 1) { ehmsEamEquipmentsInfomation.setIsRunning("1"); } //如果闲置状态就插入闲置设备表 - if(ehmsEamEquipmentsInfomation.getEquipStatus() == 2){ + if (ehmsEamEquipmentsInfomation.getEquipStatus() == 2) { EhmsEamEquipIdleRecord idleRecord = new EhmsEamEquipIdleRecord(); idleRecord.setId(GetUUID.getUUID()); idleRecord.setEquipInfoId(ehmsEamEquipmentsInfomation.getId()); @@ -220,10 +218,9 @@ public class EhmsEamEquipmentsInfomationServiceImpl implements IEhmsEamEquipment */ @Override @Transient - public int updateEhmsEamEquipmentsInfomation(EhmsEamEquipmentsInfomation ehmsEamEquipmentsInfomation) - { - System.err.println("是否变化;"+ehmsEamEquipmentsInfomation.getIsChange()); - if("是".equals(ehmsEamEquipmentsInfomation.getIsChange()) && ehmsEamEquipmentsInfomation.getEquipStatus() == 2){ + public int updateEhmsEamEquipmentsInfomation(EhmsEamEquipmentsInfomation ehmsEamEquipmentsInfomation) { + System.err.println("是否变化;" + ehmsEamEquipmentsInfomation.getIsChange()); + if ("是".equals(ehmsEamEquipmentsInfomation.getIsChange()) && ehmsEamEquipmentsInfomation.getEquipStatus() == 2) { //插入闲置 EhmsEamEquipIdleRecord idleRecord = new EhmsEamEquipIdleRecord(); idleRecord.setId(GetUUID.getUUID()); @@ -233,12 +230,12 @@ public class EhmsEamEquipmentsInfomationServiceImpl implements IEhmsEamEquipment idleRecord.setIdleStartDate(sdf.format(new Date())); ehmsEamEquipIdleRecordMapper.insertEhmsEamEquipIdleRecord(idleRecord); } - if("改变".equals(ehmsEamEquipmentsInfomation.getIsChange())){ + if ("改变".equals(ehmsEamEquipmentsInfomation.getIsChange())) { EhmsEamEquipIdleRecord record = new EhmsEamEquipIdleRecord(); record.setEquipInfoId(ehmsEamEquipmentsInfomation.getId()); //通过设备信息id查询闲置设备id List recordList = ehmsEamEquipIdleRecordMapper.selectEhmsEamEquipIdleRecordList(record); - if(recordList.size() == 0 || recordList.size() >1){ + if (recordList.size() == 0 || recordList.size() > 1) { return 0; } EhmsEamEquipIdleRecord idleRecord = recordList.get(0); @@ -250,7 +247,7 @@ public class EhmsEamEquipmentsInfomationServiceImpl implements IEhmsEamEquipment EhmsEamEquipmentsClass findClass = new EhmsEamEquipmentsClass(); findClass.setClassName(ehmsEamEquipmentsInfomation.getEquipClass()); List findClassList = ehmsEamEquipmentsClassMapper.selectEhmsEamEquipmentsClassList(findClass); - if (findClassList.size() == 0){ + if (findClassList.size() == 0) { ehmsEamEquipmentsInfomation.setEquipClassId(null); } ehmsEamEquipmentsInfomation.setEquipClassId(findClassList.get(0).getId()); @@ -264,8 +261,7 @@ public class EhmsEamEquipmentsInfomationServiceImpl implements IEhmsEamEquipment * @return 结果 */ @Override - public int deleteEhmsEamEquipmentsInfomationByIds(String[] ids) - { + public int deleteEhmsEamEquipmentsInfomationByIds(String[] ids) { return ehmsEamEquipmentsInfomationMapper.deleteEhmsEamEquipmentsInfomationByIds(ids); } @@ -276,74 +272,89 @@ public class EhmsEamEquipmentsInfomationServiceImpl implements IEhmsEamEquipment * @return 结果 */ @Override - public int deleteEhmsEamEquipmentsInfomationById(String id) - { + public int deleteEhmsEamEquipmentsInfomationById(String id) { return ehmsEamEquipmentsInfomationMapper.deleteEhmsEamEquipmentsInfomationById(id); } /** * 获取首页设备统计数据 + * * @return */ @Override - public Map getEqNum() { - Map rs = new HashMap<>(); - List> l = ehmsEamEquipmentsInfomationMapper.getEqNum(); + public Map getEqNum() { + Map rs = new HashMap<>(); + List> l = ehmsEamEquipmentsInfomationMapper.getEqNum(); int total = 0; int run = 0; int notRun = 0; - if(null != l && l.size()>0){ - for(Map i : l){ - if(i.get("isRunning").equals("1")){ + if (null != l && l.size() > 0) { + for (Map i : l) { + if (i.get("isRunning").equals("1")) { run += Integer.parseInt(i.get("num").toString()); - }else if(i.get("isRunning").equals("0")){ + } else if (i.get("isRunning").equals("0")) { notRun += Integer.parseInt(i.get("num").toString()); } total += Integer.parseInt(i.get("num").toString()); } } - rs.put("total",String.valueOf(total)); - rs.put("run",String.valueOf(run)); - rs.put("notRun",String.valueOf(notRun)); + rs.put("total", String.valueOf(total)); + rs.put("run", String.valueOf(run)); + rs.put("notRun", String.valueOf(notRun)); return rs; } /** * 获取首页charts统计数据 + * * @return */ @Override - public Map> loadChartsData() { - Map> rs = new HashMap<>(); - List dateList = new ArrayList(); - List runTimeList = new ArrayList(); - List shutdownRateList = new ArrayList(); - List> l = ehmsEamEquipmentsInfomationMapper.getEqNum(); - int num = 0; - for(int i=0; i loadChartsData() { + Map rs = new HashMap<>(); + // 获取前三个月份 + List monthList = new ArrayList<>(); + List dailyList = new ArrayList<>(); + List meterReadingList = new ArrayList<>(); + List professionalList = new ArrayList<>(); + LocalDate currentDate = LocalDate.now(); + for (int i = 0; i < 3; i++) { + monthList.add(Integer.parseInt(currentDate.format(DateTimeFormatter.ofPattern("MM")))); + currentDate = currentDate.minusMonths(1); + dailyList.add(0); + meterReadingList.add(0); + professionalList.add(0); } - String startDate = DateUtils.parseDateToStr("YYYY-MM-dd",DateUtils.getAfterTime(DateUtils.getNowDate(),-20)); - List> runTime = ehmsEamEquipmentsInfomationMapper.getRunTime(startDate); - Map runTimeMap = new HashMap<>(); - for(int i=0;i> patrolList = ehmsEamEquipmentsInfomationMapper.getPatrol(); + for(Map pmap : patrolList){ + + if("日常巡检".equals(pmap.get("name").toString())){ + dailyList.set(monthList.indexOf(Integer.parseInt(pmap.get("month").toString())),Integer.parseInt(pmap.get("num").toString())); + } + + if("抄表巡检".equals(pmap.get("name").toString())){ + meterReadingList.set(monthList.indexOf(Integer.parseInt(pmap.get("month").toString())),Integer.parseInt(pmap.get("num").toString())); + } + + if("专业巡检".equals(pmap.get("name").toString())){ + professionalList.set(monthList.indexOf(Integer.parseInt(pmap.get("month").toString())),Integer.parseInt(pmap.get("num").toString())); } } - rs.put("dateList",dateList); - rs.put("runTimeList",runTimeList); - rs.put("shutdownRateList",shutdownRateList); + rs.put("monthList",monthList); + rs.put("dailyList", dailyList); + rs.put("meterReadingList", meterReadingList); + rs.put("professionalList", professionalList); + // 分类饼图数据 + List> classList = ehmsEamEquipmentsInfomationMapper.getClassList(); + rs.put("classList", classList); + // 文件饼图数据 + List> fileList = ehmsEamEquipmentsInfomationMapper.getFileList(); + rs.put("fileList", fileList); + // 设备分布饼图数据 + List> locationList = ehmsEamEquipmentsInfomationMapper.getLocationList(); + rs.put("locationList", locationList); return rs; } } diff --git a/ehms-server/ehms-system/src/main/resources/mapper/eam/EhmsEamEquipmentsInfomationMapper.xml b/ehms-server/ehms-system/src/main/resources/mapper/eam/EhmsEamEquipmentsInfomationMapper.xml index ecb26e0..ff87f01 100644 --- a/ehms-server/ehms-system/src/main/resources/mapper/eam/EhmsEamEquipmentsInfomationMapper.xml +++ b/ehms-server/ehms-system/src/main/resources/mapper/eam/EhmsEamEquipmentsInfomationMapper.xml @@ -5,21 +5,21 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -28,31 +28,57 @@ - select a.id, equip_id, equip_name, equip_specifications, equip_class, equip_serial_num, equip_manufacturer, equip_production_date, equip_status,area_name, equip_location_id, fixed_assets_num, parent_equip_id,equip_manager_id,u.user_name as equipManager,is_running,equip_class_id from ehms_eam_equipments_infomation a - left join sys_user u on u.user_id = a.equip_manager_id + select a.id, + equip_id, + equip_name, + equip_specifications, + equip_class, + equip_serial_num, + equip_manufacturer, + equip_production_date, + equip_status, + area_name, + equip_location_id, + fixed_assets_num, + parent_equip_id, + equip_manager_id, + u.user_name as equipManager, + is_running, + equip_class_id + from ehms_eam_equipments_infomation a + left join sys_user u on u.user_id = a.equip_manager_id - - and id = #{id} - and equip_id = #{equipId} - and equip_name like concat('%', #{equipName}, '%') - and equip_specifications = #{equipSpecifications} - and equip_class = #{equipClass} - and equip_serial_num = #{equipSerialNum} - and equip_manufacturer = #{equipManufacturer} - and equip_production_date = #{equipProductionDate} - and equip_status = #{equipStatus} - and equip_location_id = #{equipLocationId} - and fixed_assets_num = #{fixedAssetsNum} - and parent_equip_id = #{parentEquipId} - and equip_manager_id = #{equipManagerId} - and area_name = #{areaName} - and equip_class_id = #{equipClassId} + and id = #{id} + and equip_id = #{equipId} + and equip_name like concat('%', #{equipName}, '%') + and equip_specifications = + #{equipSpecifications} + + and equip_class = #{equipClass} + and equip_serial_num = #{equipSerialNum} + and equip_manufacturer = + #{equipManufacturer} + + and equip_production_date = + #{equipProductionDate} + + and equip_status = #{equipStatus} + and equip_location_id = #{equipLocationId} + + and fixed_assets_num = #{fixedAssetsNum} + and parent_equip_id = #{parentEquipId} + and equip_manager_id = #{equipManagerId} + and area_name = #{areaName} + and equip_class_id = #{equipClassId} - select temp.*,(temp.theory_life - temp.run_time - temp.consume_time) left_time from( SELECT a.id, @@ -73,37 +99,47 @@ a.equip_class_id, a.theory_life, ROUND( TIMESTAMPDIFF( HOUR, a.equip_production_date, now())* 0.7 ) run_time, - ( SELECT count( 1 )* 180 FROM ehms_maintenance_work_order t WHERE t.equ_number = a.equip_id )+a.time consume_time + ( SELECT count( 1 )* 180 FROM ehms_maintenance_work_order t WHERE t.equ_number = a.equip_id )+a.time + consume_time FROM ehms_eam_equipments_infomation a ) as temp - and id = #{id} - and equip_id = #{equipId} - and equip_name like concat('%', #{equipName}, '%') - and equip_specifications = #{equipSpecifications} - and equip_class = #{equipClass} - and equip_serial_num = #{equipSerialNum} - and equip_manufacturer = #{equipManufacturer} - and equip_production_date = #{equipProductionDate} - and equip_status = #{equipStatus} - and equip_location_id = #{equipLocationId} - and fixed_assets_num = #{fixedAssetsNum} - and parent_equip_id = #{parentEquipId} - and equip_manager_id = #{equipManagerId} - and area_name = #{areaName} - and equip_class_id = #{equipClassId} + and id = #{id} + and equip_id = #{equipId} + and equip_name like concat('%', #{equipName}, '%') + and equip_specifications = + #{equipSpecifications} + + and equip_class = #{equipClass} + and equip_serial_num = #{equipSerialNum} + and equip_manufacturer = + #{equipManufacturer} + + and equip_production_date = + #{equipProductionDate} + + and equip_status = #{equipStatus} + and equip_location_id = #{equipLocationId} + + and fixed_assets_num = #{fixedAssetsNum} + and parent_equip_id = #{parentEquipId} + and equip_manager_id = #{equipManagerId} + and area_name = #{areaName} + and equip_class_id = #{equipClassId} order by equip_class - where a.id = #{id} - - - where equip_production_date >= #{startDate} AND equip_production_date <= #{endDate} @@ -172,7 +208,9 @@ - delete from ehms_eam_equipments_infomation where id = #{id} + delete + from ehms_eam_equipments_infomation + where id = #{id} @@ -183,18 +221,87 @@ - \ No newline at end of file + + + + + +