package com.steerinfo.dil.controller; import com.alibaba.fastjson.JSON; import com.steerinfo.dil.feign.ESFeign; import com.steerinfo.dil.model.TmsshipShipLocation; import com.steerinfo.dil.service.ITmsshipShipLocationService; import com.steerinfo.dil.service.impl.TmsshipShipLocationServiceImpl; import com.steerinfo.dil.service.impl.TmsshipTotalResultServiceImpl; import com.steerinfo.dil.util.BaseRESTfulController; import com.steerinfo.dil.util.ColumnDataUtil; import com.steerinfo.dil.util.PageListAdd; import com.steerinfo.framework.controller.RESTfulResult; import com.steerinfo.framework.service.pagehelper.PageHelper; import com.steerinfo.framework.service.pagehelper.PageList; import com.steerinfo.framework.utils.collection.ListUtils; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.text.SimpleDateFormat; import java.util.*; import java.math.BigDecimal; /** * TmsshipShipLocation RESTful接口: * @author generator * @version 1.0-SNAPSHORT 2021-08-19 08:52 * 类描述 * 修订历史: * 日期:2021-08-19 * 作者:generator * 参考: * 描述:TmsshipShipLocation RESTful接口 * @see null * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved. */ @RestController @RequestMapping("/${api.version}/tmsshipshiplocations") public class TmsshipShipLocationController extends BaseRESTfulController { @Autowired TmsshipShipLocationServiceImpl tmsshipShipLocationService; @Autowired TmsshipTotalResultServiceImpl tmsshipTotalResultService; @Autowired ColumnDataUtil columnDataUtil; @Autowired ESFeign esFeign; /* *//** * 新增位置作业 * @param map * @return *//* @ApiOperation(value="新增位置作业", notes="根据TmsshipShipLocation对象创建") @ApiImplicitParams({ @ApiImplicitParam(name = "map",value = "位置作业字段",required = true,paramType = "java.util.Map") }) @PostMapping("/addShipLocation") public RESTfulResult addShipLocation(@RequestBody Map map) { int code = tmsshipShipLocationService.addShipLocationResult(map); return success(code); }*/ /** * 修改位置作业信息 * @param map * @return */ @ApiOperation(value="修改位置作业信息", notes="根据TmsshipShipLocation对象修改") @ApiImplicitParams({ @ApiImplicitParam(name = "tmsshipShipLocation",value = "位置作业字段",required = true,paramType = "TmsshipShipLocation") }) @PostMapping("/updateShipLocation") public RESTfulResult updateShipLocation(@RequestBody(required = false) Map map) { int code = tmsshipShipLocationService.updateShipLocation(map); return success(code); } /** * 删除位置作业信息 * @param locationId * @return */ @ApiOperation(value="删除位置作业信息") @ApiImplicitParams({ @ApiImplicitParam(name = "locationId",value = "位置作业字段",required = true,paramType = "BigDecimal") }) @PostMapping("/deleteShipLocation/{locationId}") public RESTfulResult deleteShipLocation(@PathVariable("locationId") BigDecimal locationId) { int code = tmsshipShipLocationService.deleteShipLocation(locationId); return success(code); } /** * 查询位置作业信息 * @param locationId * @return */ @ApiOperation(value="查询位置作业信息") @ApiImplicitParams({ @ApiImplicitParam(name = "mapVal",value = "位置作业字段",required = true,paramType = "java.util.Map") }) @PostMapping("/selectShipLocation/{locationId}") public RESTfulResult selectShipLocation(@PathVariable("locationId") BigDecimal locationId) { TmsshipShipLocation tmsshipShipLocation = tmsshipShipLocationService.selectShipLocation(locationId); return success(tmsshipShipLocation); } /** * 查询位置作业信息 * @param locationId * @return */ @ApiOperation(value="查询位置作业信息") @ApiImplicitParams({ @ApiImplicitParam(name = "mapVal",value = "位置作业字段",required = true,paramType = "java.util.Map") }) @PostMapping("/getShipLocation/{locationId}") public RESTfulResult getShipLocation(@PathVariable("locationId") BigDecimal locationId) { List> map = tmsshipShipLocationService.getShipLocation(locationId); return success(map); } /** * 展示位置作业信息列表 * @param mapVal * @return */ @ApiOperation(value="展示位置作业信息列表", notes="分页查询") @ApiImplicitParams({ @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"), @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer"), @ApiImplicitParam(name = "apiId", value = "59", required = false, dataType = "BigDecimal"), }) @PostMapping(value = "/getShipLocationList") public RESTfulResult getShipLocationList(@RequestBody(required = false) Map mapVal, String con ){ if (con!=null&&!"".equals(con)){ mapVal.put("con",con); } List> columnList = tmsshipShipLocationService.selectShipLocationList(mapVal); return success(columnList); } @ApiOperation(value="根据位置查询船舶状态") @PostMapping(value = "/getShipLocationStatus") public RESTfulResult getShipLocationStatus(String shipLocation){ Mapmap = tmsshipShipLocationService.getShipLocationStatus(shipLocation); return success(map); } @PostMapping(value = "/getWarnMsg") public RESTfulResult getWarnMsg(@RequestBody(required = false) Map mapVal) throws Exception { StringBuilder warnMsg = new StringBuilder(); List> columnList = tmsshipShipLocationService.selectShipLocationList(mapVal); List list = new ArrayList<>(); if(columnList != null && !columnList.isEmpty()) { for (Map map : columnList) { String locationRouteTime = map.get("locationRouteTime").toString(); if(locationRouteTime != null && !"".equals(locationRouteTime) ){ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date locationRouteTimeDate = sdf.parse(locationRouteTime); long starTime=locationRouteTimeDate.getTime(); long endTime=(new Date()).getTime(); long num=endTime-starTime;//时间戳相差的毫秒数 System.out.println("相差天数为:"+num/24/60/60/1000); //超过15天提醒 if((num/(24*60*60*1000)) > 15){ list.add(""+ map.get("materialName") +" \""+ map.get("foreignShipName") +"\" "+map.get("capacityName") +" 离岗日期"+ map.get("locationRouteTime") +" 离岗已超过十五天,请确定船舶状态; "); } } } } if(list.isEmpty()){ warnMsg.append("暂无警告"); } else { for (int i = 0; i < list.size(); i++) { int k=i+1; if(k == 1){ warnMsg.append("警告:"); } warnMsg.append(k).append("、").append(list.get(i)); } } return success(warnMsg); } }