e062bec7 康伟

kangwei :设备运行时间报表接口

1 个父辈 a0c024ef
...@@ -22,9 +22,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -22,9 +22,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
22 import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 22 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
23 import com.skua.modules.ajh.service.IAjhMeetingService; 23 import com.skua.modules.ajh.service.IAjhMeetingService;
24 import com.skua.modules.ajh.vo.AjhMeetingSendVO; 24 import com.skua.modules.ajh.vo.AjhMeetingSendVO;
25 import com.skua.modules.system.entity.SysDepart;
26 import com.skua.modules.system.entity.SysUser;
27 import com.skua.modules.system.service.ISysDepartService;
28 import com.skua.modules.system.service.ISysUserService;
25 import com.skua.tool.util.QRCodeUtil; 29 import com.skua.tool.util.QRCodeUtil;
26 import lombok.extern.slf4j.Slf4j; 30 import lombok.extern.slf4j.Slf4j;
27 31
32 import org.apache.commons.lang3.StringUtils;
28 import org.jeecgframework.poi.excel.ExcelImportUtil; 33 import org.jeecgframework.poi.excel.ExcelImportUtil;
29 import org.jeecgframework.poi.excel.def.NormalExcelConstants; 34 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
30 import org.jeecgframework.poi.excel.entity.ExportParams; 35 import org.jeecgframework.poi.excel.entity.ExportParams;
...@@ -61,6 +66,11 @@ public class AjhMeetingSendController { ...@@ -61,6 +66,11 @@ public class AjhMeetingSendController {
61 @Value("${skua.web-url}") 66 @Value("${skua.web-url}")
62 private String webUrl; 67 private String webUrl;
63 68
69 @Autowired
70 private ISysUserService userService;
71 @Autowired
72 private ISysDepartService departService;
73
64 /** 74 /**
65 * <pre> 75 * <pre>
66 * 分页列表查询 76 * 分页列表查询
...@@ -77,8 +87,8 @@ public class AjhMeetingSendController { ...@@ -77,8 +87,8 @@ public class AjhMeetingSendController {
77 @ApiOperation(value="会议记录-分页列表查询", notes="会议记录-分页列表查询") 87 @ApiOperation(value="会议记录-分页列表查询", notes="会议记录-分页列表查询")
78 @GetMapping(value = "/list") 88 @GetMapping(value = "/list")
79 public Result<IPage<AjhMeetingSend>> queryPageList(AjhMeetingSend ajhMeetingSend, 89 public Result<IPage<AjhMeetingSend>> queryPageList(AjhMeetingSend ajhMeetingSend,
80 @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, 90 @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
81 @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) { 91 @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
82 Result<IPage<AjhMeetingSend>> result = new Result<IPage<AjhMeetingSend>>(); 92 Result<IPage<AjhMeetingSend>> result = new Result<IPage<AjhMeetingSend>>();
83 refreshMeetStatus();//刷新会议状态 93 refreshMeetStatus();//刷新会议状态
84 QueryWrapper<AjhMeetingSend> queryWrapper = new QueryWrapper<>(); 94 QueryWrapper<AjhMeetingSend> queryWrapper = new QueryWrapper<>();
...@@ -336,6 +346,17 @@ public class AjhMeetingSendController { ...@@ -336,6 +346,17 @@ public class AjhMeetingSendController {
336 public Result<AjhMeetingSend> queryById(@RequestParam(name="id",required=true) String id) { 346 public Result<AjhMeetingSend> queryById(@RequestParam(name="id",required=true) String id) {
337 Result<AjhMeetingSend> result = new Result<AjhMeetingSend>(); 347 Result<AjhMeetingSend> result = new Result<AjhMeetingSend>();
338 AjhMeetingSend ajhMeetingSend = ajhMeetingSendService.getById(id); 348 AjhMeetingSend ajhMeetingSend = ajhMeetingSendService.getById(id);
349 if(ajhMeetingSend != null ){
350 if(StringUtils.isNotEmpty(ajhMeetingSend.getMeetCompere())){
351 SysUser sysUser = userService.getById(ajhMeetingSend.getMeetCompere());
352 ajhMeetingSend.setMeetCompereName( sysUser.getRealname());
353 }
354
355 if(StringUtils.isNotEmpty(ajhMeetingSend.getDepartId()) && StringUtils.isEmpty(ajhMeetingSend.getDepartName())){
356 SysDepart depart = departService.getById(ajhMeetingSend.getDepartId());
357 ajhMeetingSend.setDepartName( depart.getDepartName());
358 }
359 }
339 if(ajhMeetingSend==null) { 360 if(ajhMeetingSend==null) {
340 result.error500("未找到对应实体"); 361 result.error500("未找到对应实体");
341 }else { 362 }else {
...@@ -345,7 +366,7 @@ public class AjhMeetingSendController { ...@@ -345,7 +366,7 @@ public class AjhMeetingSendController {
345 return result; 366 return result;
346 } 367 }
347 368
348 /** 369 /**
349 * <pre> 370 * <pre>
350 * 导出excel 371 * 导出excel
351 * </pre> 372 * </pre>
...@@ -356,33 +377,33 @@ public class AjhMeetingSendController { ...@@ -356,33 +377,33 @@ public class AjhMeetingSendController {
356 * @Description: TODO(这里描述这个方法的需求变更情况) 377 * @Description: TODO(这里描述这个方法的需求变更情况)
357 */ 378 */
358 379
359 @RequestMapping(value = "/exportXls") 380 @RequestMapping(value = "/exportXls")
360 public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) { 381 public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
361 // Step.1 组装查询条件 382 // Step.1 组装查询条件
362 QueryWrapper<AjhMeetingSend> queryWrapper = null; 383 QueryWrapper<AjhMeetingSend> queryWrapper = null;
363 try { 384 try {
364 String paramsStr = request.getParameter("paramsStr"); 385 String paramsStr = request.getParameter("paramsStr");
365 if (ConvertUtils.isNotEmpty(paramsStr)) { 386 if (ConvertUtils.isNotEmpty(paramsStr)) {
366 String deString = URLDecoder.decode(paramsStr, "UTF-8"); 387 String deString = URLDecoder.decode(paramsStr, "UTF-8");
367 AjhMeetingSend ajhMeetingSend = JSON.parseObject(deString, AjhMeetingSend.class); 388 AjhMeetingSend ajhMeetingSend = JSON.parseObject(deString, AjhMeetingSend.class);
368 queryWrapper = QueryGenerator.initQueryWrapper(ajhMeetingSend, request.getParameterMap()); 389 queryWrapper = QueryGenerator.initQueryWrapper(ajhMeetingSend, request.getParameterMap());
369 } 390 }
370 } catch (UnsupportedEncodingException e) { 391 } catch (UnsupportedEncodingException e) {
371 e.printStackTrace(); 392 e.printStackTrace();
372 } 393 }
373 394
374 //Step.2 AutoPoi 导出Excel 395 //Step.2 AutoPoi 导出Excel
375 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); 396 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
376 List<AjhMeetingSend> pageList = ajhMeetingSendService.list(queryWrapper); 397 List<AjhMeetingSend> pageList = ajhMeetingSendService.list(queryWrapper);
377 //导出文件名称 398 //导出文件名称
378 mv.addObject(NormalExcelConstants.FILE_NAME, "会议记录列表"); 399 mv.addObject(NormalExcelConstants.FILE_NAME, "会议记录列表");
379 mv.addObject(NormalExcelConstants.CLASS, AjhMeetingSend.class); 400 mv.addObject(NormalExcelConstants.CLASS, AjhMeetingSend.class);
380 mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("会议记录列表数据", "", "会议记录列表")); 401 mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("会议记录列表数据", "", "会议记录列表"));
381 mv.addObject(NormalExcelConstants.DATA_LIST, pageList); 402 mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
382 return mv; 403 return mv;
383 } 404 }
384 405
385 /** 406 /**
386 * <pre> 407 * <pre>
387 * 通过excel导入数据 408 * 通过excel导入数据
388 * </pre> 409 * </pre>
...@@ -392,33 +413,33 @@ public class AjhMeetingSendController { ...@@ -392,33 +413,33 @@ public class AjhMeetingSendController {
392 * @author 开发者姓名, 开发时间 413 * @author 开发者姓名, 开发时间
393 * @Description: TODO(这里描述这个方法的需求变更情况) 414 * @Description: TODO(这里描述这个方法的需求变更情况)
394 */ 415 */
395 @RequestMapping(value = "/importExcel", method = RequestMethod.POST) 416 @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
396 public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { 417 public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
397 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; 418 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
398 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); 419 Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
399 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { 420 for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
400 MultipartFile file = entity.getValue();// 获取上传文件对象 421 MultipartFile file = entity.getValue();// 获取上传文件对象
401 ImportParams params = new ImportParams(); 422 ImportParams params = new ImportParams();
402 params.setTitleRows(2); 423 params.setTitleRows(2);
403 params.setHeadRows(1); 424 params.setHeadRows(1);
404 params.setNeedSave(true); 425 params.setNeedSave(true);
405 try { 426 try {
406 List<AjhMeetingSend> listAjhMeetingSends = ExcelImportUtil.importExcel(file.getInputStream(), AjhMeetingSend.class, params); 427 List<AjhMeetingSend> listAjhMeetingSends = ExcelImportUtil.importExcel(file.getInputStream(), AjhMeetingSend.class, params);
407 ajhMeetingSendService.saveBatch(listAjhMeetingSends); 428 ajhMeetingSendService.saveBatch(listAjhMeetingSends);
408 return Result.ok("文件导入成功!数据行数:" + listAjhMeetingSends.size()); 429 return Result.ok("文件导入成功!数据行数:" + listAjhMeetingSends.size());
409 } catch (Exception e) { 430 } catch (Exception e) {
410 log.error(e.getMessage(),e); 431 log.error(e.getMessage(),e);
411 return Result.error("文件导入失败:"+e.getMessage()); 432 return Result.error("文件导入失败:"+e.getMessage());
412 } finally { 433 } finally {
413 try { 434 try {
414 file.getInputStream().close(); 435 file.getInputStream().close();
415 } catch (IOException e) { 436 } catch (IOException e) {
416 e.printStackTrace(); 437 e.printStackTrace();
417 } 438 }
418 } 439 }
419 } 440 }
420 return Result.ok("文件导入失败!"); 441 return Result.ok("文件导入失败!");
421 } 442 }
422 443
423 /** 444 /**
424 * 导出doc文件 445 * 导出doc文件
......
...@@ -130,6 +130,11 @@ public class AjhMeetingSend { ...@@ -130,6 +130,11 @@ public class AjhMeetingSend {
130 @TableField(exist = false) 130 @TableField(exist = false)
131 @ApiModelProperty(value = "机构名称") 131 @ApiModelProperty(value = "机构名称")
132 private java.lang.String departName; 132 private java.lang.String departName;
133
134 @TableField(exist = false)
135 @ApiModelProperty(value = "主持人")
136 private java.lang.String meetCompereName;
137
133 /**邀请人数*/ 138 /**邀请人数*/
134 @Excel(name = "邀请人数", width = 15,orderNum = "7") 139 @Excel(name = "邀请人数", width = 15,orderNum = "7")
135 @TableField(exist = false) 140 @TableField(exist = false)
...@@ -146,8 +151,5 @@ public class AjhMeetingSend { ...@@ -146,8 +151,5 @@ public class AjhMeetingSend {
146 @ApiModelProperty(value = "会议内容") 151 @ApiModelProperty(value = "会议内容")
147 private String meetContentHtml; 152 private String meetContentHtml;
148 153
149 public String getMeetContentHtml() { 154
150 meetContentHtml = BaseUtil.delHTMLTag( this.getMeetContent());
151 return meetContentHtml;
152 }
153 } 155 }
......
1 package com.skua.modules.erp.controller;
2
3 import cn.hutool.core.util.RandomUtil;
4 import com.skua.common.util.ChineseInital;
5 import com.skua.core.api.vo.Result;
6 import com.skua.core.aspect.annotation.AutoLog;
7 import com.skua.core.context.SpringContextUtils;
8 import com.skua.core.service.IFactoryInfoService;
9 import com.skua.core.util.ConvertUtils;
10 import com.skua.core.util.DateUtils;
11 import com.skua.modules.equipment.vo.EquipmentRealTimeVO;
12 import com.skua.modules.erp.vo.MetricInfoVO;
13 import com.skua.modules.erp.vo.RealTimeHistoryDataVO;
14 import io.swagger.annotations.Api;
15 import io.swagger.annotations.ApiOperation;
16 import org.apache.commons.lang.StringUtils;
17 import org.springframework.beans.factory.annotation.Autowired;
18 import org.springframework.dao.DataAccessException;
19 import org.springframework.jdbc.core.BeanPropertyRowMapper;
20 import org.springframework.jdbc.core.JdbcTemplate;
21 import org.springframework.web.bind.annotation.GetMapping;
22 import org.springframework.web.bind.annotation.RequestMapping;
23 import org.springframework.web.bind.annotation.RequestParam;
24 import org.springframework.web.bind.annotation.RestController;
25 import java.util.*;
26
27 @Api(tags="设备-设备运行台时报表")
28 @RestController
29 @RequestMapping("/test/metricInfo")
30 public class TestMetricInfoController {
31
32 @Autowired
33 private IFactoryInfoService iFactoryInfoService;
34
35
36 @AutoLog(value = "设备-设备运行台时报表")
37 @ApiOperation(value = "设备-设备运行台时报表", notes = "设备-设备运行台时报表")
38 @GetMapping(value = "/realTimeHistoryData")
39 public Result<RealTimeHistoryDataVO> equipRealTimeHistoryDataCtrl(@RequestParam(value = "departId") String departId,
40 @RequestParam(value = "startTime") String startTime,
41 @RequestParam(value = "endTime") String endTime) {
42 Result<RealTimeHistoryDataVO> result = new Result<>();
43 RealTimeHistoryDataVO realTimeHistoryDataVO = new RealTimeHistoryDataVO();
44 //String fields = "TCSWSCLC_PLC300_Tag182,TCSWSCLC_PLC300_Tag185";
45 JdbcTemplate masterDB = (JdbcTemplate)SpringContextUtils.getBean("master");
46 String metricInfoSql = "select ei.equipment_name , t.metric_express1 'gzExpress' , t.metric_express2 'yxExpress' ,t.metric_express3 'tzExpress' from sys_monitor_metric_info t ";
47 metricInfoSql += " left join equipment_info ei on ei.id = t.equipment_code ";
48 metricInfoSql += " where t.metric_type = 1 and t.depart_id = '"+departId+"' and t.equipment_code > 0 " ;
49 List<MetricInfoVO> metricInfoVOList = masterDB.query(metricInfoSql,new BeanPropertyRowMapper<MetricInfoVO>(MetricInfoVO.class));
50
51 //StringBuffer fields= new StringBuffer();
52 String fields = "";
53 if(metricInfoVOList != null ){
54 for(MetricInfoVO metricInfoVO : metricInfoVOList){
55 String equipmentName = metricInfoVO.getEquipmentName().replaceAll("[^\\u4e00-\\u9fa5]", "");
56 String equipmentCode = ChineseInital.getAllFirstLetter(equipmentName)+"_"+ RandomUtil.randomNumbers(2);
57 metricInfoVO.setEquipmentName(equipmentName );
58 metricInfoVO.setEquipmentCode(equipmentCode );
59 if(StringUtils.isNotEmpty(metricInfoVO.getGzExpress())){
60 fields += metricInfoVO.getGzExpress()+",";
61 }
62 if(StringUtils.isNotEmpty(metricInfoVO.getYxExpress())){
63 fields += metricInfoVO.getYxExpress()+",";
64 }
65 if(StringUtils.isNotEmpty(metricInfoVO.getTzExpress())){
66 fields += metricInfoVO.getTzExpress()+",";
67 }
68 }
69 }
70
71 if (fields.endsWith(",")) {
72 fields = fields.substring(0, fields.length() - 1);
73 }
74 List<Map<String, Object>> pgDataList = iFactoryInfoService.queryFactoryInfos(departId, fields, startTime, endTime, "1");
75
76 List<Map<String, Object>> dataList = null;
77 if(pgDataList != null ) {
78 dataList = new ArrayList<>(pgDataList.size());
79 Map<String, Object> dataMap = null;
80 //elect ts as time,nm as monitorId,v as monitorValue
81 String equipmentCode = null;
82 for (Map<String, Object> paramMap : pgDataList) {
83 dataMap = new HashMap<>();
84 dataMap.put("time",DateUtils.formatTime(Long.parseLong(paramMap.get("time") + "000")) );
85 for(MetricInfoVO metricInfoVO : metricInfoVOList){
86 dataMap.put( metricInfoVO.getEquipmentCode()+"_YX" , ConvertUtils.getString(paramMap.get(metricInfoVO.getYxExpress())));//运行
87 dataMap.put( metricInfoVO.getEquipmentCode()+"_GZ" , ConvertUtils.getString(paramMap.get(metricInfoVO.getGzExpress())));//故障
88 dataMap.put( metricInfoVO.getEquipmentCode()+"_ZT" ,60 - ConvertUtils.getDouble(paramMap.get(metricInfoVO.getYxExpress()),0) - ConvertUtils.getDouble(paramMap.get(metricInfoVO.getGzExpress()) ,0) );//暂停
89 }
90
91 dataList.add( dataMap );
92 }
93 }
94 /* //拼装数据
95 Map<String, Map<String,String>> linkedHashMap = new LinkedHashMap<String, Map<String,String>>();//返回数据结果
96 String timeTemp = null;
97 Map<String,String> dataMap = null;
98 if(pgDataList != null ){
99 //elect ts as time,nm as monitorId,v as monitorValue
100 for( Map<String, Object> paramMap : pgDataList){
101 timeTemp = DateUtils.formatTime(Long.parseLong(paramMap.get("time") + "000"));
102 dataMap = linkedHashMap.get(timeTemp);
103 if(dataMap == null ){
104 dataMap = new HashMap<>();
105 dataMap.put("time",timeTemp);
106 for (Map.Entry<String, String> entry : nameMap.entrySet()) {
107 dataMap.put(entry.getKey(),"0");
108 }
109 }
110 // 使用For-Each迭代entries,通过Map.entrySet遍历key和value
111 for (Map.Entry<String, String> entry : nameMap.entrySet()) {
112 System.out.println("entry.getKey()" +entry.getKey()+ "****"+"paramMap.get() = "+paramMap.get(entry.getKey()));
113 if(entry.getKey().equals( ConvertUtils.getString(paramMap.get(entry.getKey())) )){
114 dataMap.put( entry.getValue() , ConvertUtils.getString(paramMap.get(entry.getKey())));
115 }
116 }
117 linkedHashMap.put(timeTemp,dataMap);
118 }
119 }*/
120
121 realTimeHistoryDataVO.setHeadList( metricInfoVOList);
122 realTimeHistoryDataVO.setDataList( dataList );
123 result.setResult( realTimeHistoryDataVO);
124 return result;
125 }
126
127 }
1 package com.skua.modules.erp.vo;
2
3 import cn.hutool.core.util.RandomUtil;
4 import com.skua.common.util.ChineseInital;
5 import io.swagger.annotations.ApiModel;
6 import io.swagger.annotations.ApiModelProperty;
7 import lombok.Data;
8 import lombok.EqualsAndHashCode;
9 import lombok.experimental.Accessors;
10
11 @Data
12 @EqualsAndHashCode(callSuper = false)
13 @Accessors(chain = true)
14 @ApiModel(value="sys_monitor_metric_info对象", description="数据项管理")
15 public class MetricInfoVO {
16 @ApiModelProperty(value = "名称")
17 private String equipmentName;//
18
19 @ApiModelProperty(value = "设备编码")
20 private java.lang.String equipmentCode;
21 @ApiModelProperty(value = "故障表达式")
22 private String gzExpress;
23 @ApiModelProperty(value = "运行表达式")
24 private String yxExpress;
25 @ApiModelProperty(value = "停止编码")
26 private String tzExpress;
27
28
29 }
1 package com.skua.modules.erp.vo;
2
3 import io.swagger.annotations.ApiModel;
4 import io.swagger.annotations.ApiModelProperty;
5 import lombok.Data;
6 import lombok.EqualsAndHashCode;
7 import lombok.experimental.Accessors;
8
9 import java.util.List;
10 import java.util.Map;
11
12 @Data
13 @EqualsAndHashCode(callSuper = false)
14 @Accessors(chain = true)
15 @ApiModel(value="设备运行台时报表对象", description="设备运行台时报表对象")
16 public class RealTimeHistoryDataVO {
17
18 @ApiModelProperty(value = "表头集合")
19 private List<MetricInfoVO> headList;
20
21
22 @ApiModelProperty(value = "列表集合数据")
23 private List<Map<String, Object>> dataList;
24
25 }
...@@ -110,8 +110,6 @@ public class EquipmentController { ...@@ -110,8 +110,6 @@ public class EquipmentController {
110 @Autowired 110 @Autowired
111 private ISysStructDictService sysStructDictService; 111 private ISysStructDictService sysStructDictService;
112 @Autowired 112 @Autowired
113 private ISysMetricDictService sysMetricDictService;
114 @Autowired
115 private IFactoryInfoService iFactoryInfoService; 113 private IFactoryInfoService iFactoryInfoService;
116 @Autowired 114 @Autowired
117 private IPgQueryService pgQueryService; 115 private IPgQueryService pgQueryService;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!