package com.landtool.lanbase.modules.log.controller; import cn.hutool.core.date.DateTime; import com.alibaba.fastjson.JSONObject; import com.landtool.lanbase.common.utils.PageUtils; import com.landtool.lanbase.common.utils.Query; import com.landtool.lanbase.common.utils.Result; import com.landtool.lanbase.modules.log.entity.LogAction; import com.landtool.lanbase.modules.log.entity.LogKettleJob; import com.landtool.lanbase.modules.log.entity.LogKettleStepcount; import com.landtool.lanbase.modules.log.entity.LogKettleStepcountJoinYear; import com.landtool.lanbase.modules.log.service.LogActionService; import com.landtool.lanbase.modules.log.service.LogKettleStepcountService; import com.landtool.lanbase.modules.sys.controller.AbstractController; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.math.BigDecimal; import java.sql.Date; import java.util.List; import java.util.Map; @RestController @RequestMapping("/log/kettlestepcount") @Api(value = "", tags = {"日志"}) public class LogKettleStepcountController extends AbstractController{ @Autowired private LogKettleStepcountService logKettleStepcountService; /** * 列表 */ @com.landtool.lanbase.common.annotation.LogAction("数据抽取,抽取日志,抽取日志列表查询,查询") @RequestMapping(value="/list",method ={RequestMethod.POST, RequestMethod.GET}) @RequiresPermissions("org_user_admin") @ApiOperation( value = "系统模块操作日志", notes = "系统模块操作日志列表" ) public Result list(@ApiParam(name="params",value="",required=true)@RequestParam Map params){ //查询列表数据 Query query = new Query(params); List actionList = logKettleStepcountService.queryList(query); actionList.stream().forEach(s->{ long endTime = s.getEndDate().getTime(); long startTime = s.getStartDate().getTime(); Double totalTime=((double) (endTime-startTime)/1000/60);//不足0.5取值0.5 ,大于0.5小于1 取值 1 if(totalTime.compareTo(0.50)>=0&&totalTime.compareTo(1.0)<=0){ totalTime=1.0; }else if(totalTime.compareTo(0.5)<0){ totalTime=0.5; }else { //大于 1.0 的取值保留小数点后2位 totalTime = new BigDecimal(totalTime.toString()).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue(); } s.setTotalTime(totalTime); }); int total = logKettleStepcountService.queryTotal(query); PageUtils pageUtil = new PageUtils(actionList, total, query.getLimit(), query.getPage()); return Result.ok().put("page", pageUtil); } /** * 信息 */ @GetMapping("/info/{channelid}") public Result info(@ApiParam(name="channelid",value="",required=true)@PathVariable("channelid") String channelid){ LogKettleStepcount logKettleStepcount = logKettleStepcountService.queryObject(channelid); String result = ""; if (logKettleStepcount != null) { result = logKettleStepcount.getLogfield(); } return Result.ok().put("result", result); } @RequestMapping(value="/getechartdata",method ={RequestMethod.POST}) public Result getechartdata(@ApiParam(name="params",value="",required=true)@RequestParam Map params){ Query query = new Query(params); Integer yearBeg = DateTime.now().year()-9; Integer yearFin = DateTime.now().year(); if(params.get("logdatebegin").equals("") && params.get("logdatefinish").equals("")){ params.put("logdatebegin", DateTime.now().year()-9); } if(!params.get("logdatebegin").equals("") && !params.get("logdatefinish").equals("")){ yearBeg = Integer.valueOf(params.get("logdatebegin").toString()); yearFin = Integer.valueOf(params.get("logdatefinish").toString()); } if(!params.get("logdatebegin").equals("") && params.get("logdatefinish").equals("")){ yearBeg = Integer.valueOf(params.get("logdatebegin").toString()); yearFin = yearBeg + 9; params.replace("logdatefinish",yearFin); } if(!params.get("logdatefinish").equals("") && params.get("logdatebegin").equals("")){ yearFin = Integer.valueOf(params.get("logdatefinish").toString()); yearBeg = yearFin-9; params.replace("logdatebegin",yearBeg); } List list = logKettleStepcountService.queryLinesByYear(query); String legendData = ""; String inData = ""; String outData = ""; String rsb = ""; for (int i = yearBeg; i <= yearFin; i++) { legendData += "'" + i + "年',"; boolean isExits = false; for (int j=0;j 0 ? inData.substring(0,inData.length()-1):inData; outData = outData.length() > 0 ? outData.substring(0,outData.length()-1):outData; rsb = "{legendData:[" + legendData + "],seriesData:[[" + inData + "],[" + outData + "]]}"; return Result.ok().put("data",rsb); } }