Commit f1b2468a authored by tangwei's avatar tangwei

Merge branch 'developer' of http://172.16.10.76/moa/amos-boot-biz into developer

parents 997982dd 4fe29873
......@@ -64,6 +64,17 @@ public class MenuFrom {
this.name = name;
this.parentId = parentId;
}
public MenuFrom(String key, String name, String parentId) {
super();
this.id = key;
this.value = key;
this.key = key;
this.title = name;
this.label = name;
this.name = name;
this.parentId = parentId;
}
public MenuFrom() {
super();
}
......
spring.application.name=JCS
spring.application.name=JCS-tb
server.servlet.context-path=/jcs
server.port=11100
spring.profiles.active=dev
......@@ -22,3 +22,6 @@ spring.datasource.hikari.pool-name=DatebookHikariCP
spring.datasource.hikari.max-lifetime=120000
spring.datasource.hikari.connection-timeout=30000
spring.datasource.hikari.connection-test-query=SELECT 1
#mqtt-警情初报消息主题
mqtt.topic.alert.reporting=alertReporting
\ No newline at end of file
......@@ -7,13 +7,6 @@
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
</encoder>
</appender>
<!-- show parameters for hibernate sql 专为 Hibernate 定制
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" />
<logger name="org.hibernate.type.descriptor.sql.BasicExtractor" level="DEBUG" />
<logger name="org.hibernate.SQL" level="DEBUG" />
<logger name="org.hibernate.engine.QueryParameters" level="DEBUG" />
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="DEBUG"/>
<logger name="java.sql.Connection" level="DEBUG"/>
......@@ -23,25 +16,11 @@
<logger name="org.apache.activemq" level="INFO"/>
<logger name="org.springframework" level="DEBUG"/>
<logger name="org.typroject" level="DEBUG"/>
<logger name="com.yeejoin" level="DEBUG"/>
<!-- 日志输出级别 -->
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
<!--日志异步到数据库 -->
<!--<appender name="DB" class="ch.qos.logback.classic.db.DBAppender">-->
<!--&lt;!&ndash;日志异步到数据库 &ndash;&gt;-->
<!--<connectionSource class="ch.qos.logback.core.db.DriverManagerConnectionSource">-->
<!--&lt;!&ndash;连接池 &ndash;&gt;-->
<!--<dataSource class="com.mchange.v2.c3p0.ComboPooledDataSource">-->
<!--<driverClass>com.mysql.jdbc.Driver</driverClass>-->
<!--<url>jdbc:mysql://127.0.0.1:3306/databaseName</url>-->
<!--<user>root</user>-->
<!--<password>root</password>-->
<!--</dataSource>-->
<!--</connectionSource>-->
<!--</appender>-->
</configuration>
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!-- 控制台输出 -->
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<property name="LOG_HOME" value="log" />
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/jcs.log.%d{yyyy-MM-dd}.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>7</MaxHistory>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
</encoder>
<!--日志文件最大的大小-->
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>30mb</MaxFileSize>
</triggeringPolicy>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
</encoder>
</appender>
<!-- show parameters for hibernate sql 专为 Hibernate 定制
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" />
<logger name="org.hibernate.type.descriptor.sql.BasicExtractor" level="DEBUG" />
<logger name="org.hibernate.SQL" level="DEBUG" />
<logger name="org.hibernate.engine.QueryParameters" level="DEBUG" />
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="DEBUG"/>
<logger name="java.sql.Connection" level="DEBUG"/>
<logger name="java.sql.Statement" level="DEBUG"/>
<logger name="java.sql.PreparedStatement" level="DEBUG"/>
<logger name="com.baomidou.mybatisplus" level="DEBUG"/>
<logger name="com.apache.ibatis" level="INFO"/>
<logger name="org.mybatis" level="INFO" />
<logger name="java.sql.Connection" level="INFO"/>
<logger name="java.sql.Statement" level="INFO"/>
<logger name="java.sql.PreparedStatement" level="INFO"/>
<logger name="com.baomidou.mybatisplus" level="INFO"/>
<logger name="org.apache.activemq" level="INFO"/>
<logger name="org.typroject" level="INFO"/>
<logger name="com.yeejoin" level="INFO"/>
<logger name="org.springframework" level="INFO"/>
<!-- 日志输出级别 -->
<root level="INFO">
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
</root>
<!--日志异步到数据库 -->
<!--<appender name="DB" class="ch.qos.logback.classic.db.DBAppender">-->
<!--&lt;!&ndash;日志异步到数据库 &ndash;&gt;-->
<!--<connectionSource class="ch.qos.logback.core.db.DriverManagerConnectionSource">-->
<!--&lt;!&ndash;连接池 &ndash;&gt;-->
<!--<dataSource class="com.mchange.v2.c3p0.ComboPooledDataSource">-->
<!--<driverClass>com.mysql.jdbc.Driver</driverClass>-->
<!--<url>jdbc:mysql://127.0.0.1:3306/databaseName</url>-->
<!--<user>root</user>-->
<!--<password>root</password>-->
<!--</dataSource>-->
<!--</connectionSource>-->
<!--</appender>-->
</configuration>
......@@ -13,7 +13,7 @@ import lombok.EqualsAndHashCode;
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="WaterResourceCraneDto", description="")
@ApiModel(value="WaterResourceCraneDto", description="消防水鹤")
public class WaterResourceCraneDto extends BaseDto {
private static final long serialVersionUID = 1L;
......
......@@ -7,25 +7,22 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import java.util.List;
/**
*
*
* @author system_generator
* @date 2021-06-29
*/
* @author system_generator
* @date 2021-06-29
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="WaterResourceDto", description="")
@ApiModel(value = "WaterResourceDto", description = "水资源")
public class WaterResourceDto extends BaseDto {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "资源名称")
private String name;
@ApiModelProperty(value = "地址")
private String address;
......@@ -33,7 +30,10 @@ public class WaterResourceDto extends BaseDto {
private String latLang;
@ApiModelProperty(value = "资源类型(消火栓、消防水鹤、天然水源、消防水池)")
private String type;
private String resourceType;
@ApiModelProperty(value = "资源类型名称(消火栓、消防水鹤、天然水源、消防水池)")
private String resourceTypeName;
@ApiModelProperty(value = "所在建筑id")
private Long belongBuildingId;
......@@ -65,6 +65,12 @@ public class WaterResourceDto extends BaseDto {
@ApiModelProperty(value = "启用日期")
private Date enableDate;
@ApiModelProperty(value = "方位图集合")
private List<Object> orientationImgList;
@ApiModelProperty(value = "实景图集合")
private List<Object> realityImgList;
@ApiModelProperty(value = "方位图")
private String orientationImg;
......@@ -92,4 +98,123 @@ public class WaterResourceDto extends BaseDto {
@ApiModelProperty(value = "组织机构代码")
private String orgCode;
@ApiModelProperty(value = "资源id")
private Long resourceId;
@ApiModelProperty(value = "高度(cm)")
private Float height;
@ApiModelProperty(value = "水源可用状态类别代码")
private String statusCode;
@ApiModelProperty(value = "水源可用状态类别名称")
private String status;
@ApiModelProperty(value = "所属路段")
private String section;
@ApiModelProperty(value = "所属管网")
private String pipeNetwork;
@ApiModelProperty(value = "消防给水管网形式类型代码")
private String pipeTypeCode;
@ApiModelProperty(value = "消防给水管网形式类型名称")
private String pipeTypeName;
@ApiModelProperty(value = "管网直径(cm)")
private Float pipeDiameter;
@ApiModelProperty(value = "进水管直径(cm)")
private Float inletPipeDiameter;
@ApiModelProperty(value = "出水管直径(cm)")
private Float outletPipeDiameter;
@ApiModelProperty(value = "加水车道数量(个)")
private Integer waterfillingLaneNum;
@ApiModelProperty(value = "供水单位名称")
private String waterSupplyName;
@ApiModelProperty(value = "消火栓系统类型")
private String systemType;
@ApiModelProperty(value = "消火栓系统类型code")
private String systemTypeCode;
@ApiModelProperty(value = "消防设施状况分类")
private String facilitiesCategory;
@ApiModelProperty(value = "消防设施状况分类code")
private String facilitiesCategoryCode;
@ApiModelProperty(value = "道路路口路段简要情况")
private String roadJunctionInfo;
@ApiModelProperty(value = "消火栓放置形式")
private String placeForm;
@ApiModelProperty(value = "消火栓放置形式code")
private String placeFormCode;
@ApiModelProperty(value = "消防水带接口")
private String hoseConnection;
@ApiModelProperty(value = "消防水带接口code")
private String hoseConnectionCode;
@ApiModelProperty(value = "取水方式")
private String intakeForm;
@ApiModelProperty(value = "水源类型代码")
private String typeCode;
@ApiModelProperty(value = "水源类型")
private String type;
@ApiModelProperty(value = "容积(m³)")
private Float volume;
@ApiModelProperty(value = "面积(㎡)")
private Float area;
@ApiModelProperty(value = "水质情况")
private String qualitySituationInfo;
@ApiModelProperty(value = "四季变化简要情况")
private String seasonChangeInfo;
@ApiModelProperty(value = "有无枯水期")
private Boolean hasDrySeason;
@ApiModelProperty(value = "枯水期跨度简要情况")
private String dryPeriodSpan;
@ApiModelProperty(value = "取水高度(cm)")
private Float intakeHeight;
@ApiModelProperty(value = "水源标高差(cm)")
private Float elevationDifference;
@ApiModelProperty(value = "停车位置")
private String parkingPosition;
@ApiModelProperty(value = "停车数量(个)")
private Integer parkingNum;
@ApiModelProperty(value = "储水量容积物联编码")
private String iotWaterStorage;
@ApiModelProperty(value = "流量物联编码")
private String iotFlowRate;
@ApiModelProperty(value = "状态物联编码")
private String iotStatus;
@ApiModelProperty(value = "管网压力物联编码")
private String iotPipePressure;
@ApiModelProperty(value = "物联参数")
private WaterResourceIotDto waterResourceIotDto;
}
......@@ -13,7 +13,7 @@ import lombok.EqualsAndHashCode;
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="WaterResourceHydrantDto", description="")
@ApiModel(value="WaterResourceHydrantDto", description="消火栓")
public class WaterResourceHydrantDto extends BaseDto {
private static final long serialVersionUID = 1L;
......
......@@ -13,7 +13,7 @@ import lombok.EqualsAndHashCode;
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="WaterResourceIotDto", description="")
@ApiModel(value="WaterResourceIotDto", description="物联参数")
public class WaterResourceIotDto extends BaseDto {
private static final long serialVersionUID = 1L;
......@@ -21,7 +21,7 @@ public class WaterResourceIotDto extends BaseDto {
@ApiModelProperty(value = "主键id")
private Long sequencNbr;
private Long sequenceNbr;
@ApiModelProperty(value = "资源类型")
private String resourceType;
......
......@@ -13,7 +13,7 @@ import lombok.EqualsAndHashCode;
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="WaterResourceNaturalDto", description="")
@ApiModel(value="WaterResourceNaturalDto", description="天然水源")
public class WaterResourceNaturalDto extends BaseDto {
private static final long serialVersionUID = 1L;
......
......@@ -13,7 +13,7 @@ import lombok.EqualsAndHashCode;
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="WaterResourcePoolDto", description="")
@ApiModel(value="WaterResourcePoolDto", description="消防水池")
public class WaterResourcePoolDto extends BaseDto {
private static final long serialVersionUID = 1L;
......
......@@ -171,4 +171,10 @@ public class Aircraft extends BaseEntity {
*/
@TableField("remark")
private String remark;
/**
* 是否删除
*/
@TableField("is_delete")
private Boolean isDelete;
}
......@@ -42,8 +42,13 @@ public class WaterResource extends BaseEntity {
/**
* 资源类型(消火栓、消防水鹤、天然水源、消防水池)
*/
@TableField("type")
private String type;
@TableField("resource_type")
private String resourceType;
/**
* 资源类型名称(消火栓、消防水鹤、天然水源、消防水池)
*/
@TableField("resource_type_name")
private String resourceTypeName;
/**
* 所在建筑id
*/
......@@ -139,4 +144,9 @@ public class WaterResource extends BaseEntity {
*/
@TableField("org_code")
private String orgCode;
/**
* 是否启用
*/
@TableField("is_delete")
private Boolean isDelete;
}
......@@ -91,4 +91,9 @@ public class WaterResourceCrane extends BaseEntity {
*/
@TableField("rec_user_name")
private String recUserName;
/**
* 是否启用
*/
@TableField("is_delete")
private Boolean isDelete;
}
......@@ -116,4 +116,9 @@ public class WaterResourceHydrant extends BaseEntity {
*/
@TableField("rec_user_name")
private String recUserName;
/**
* 是否启用
*/
@TableField("is_delete")
private Boolean isDelete;
}
......@@ -22,11 +22,6 @@ public class WaterResourceIot extends BaseEntity {
/**
* 主键id
*/
@TableField("sequenc_nbr")
private Long sequencNbr;
/**
* 资源类型
*/
@TableField("resource_type")
......@@ -61,4 +56,9 @@ public class WaterResourceIot extends BaseEntity {
*/
@TableField("rec_user_name")
private String recUserName;
/**
* 是否启用
*/
@TableField("is_delete")
private Boolean isDelete;
}
......@@ -86,4 +86,9 @@ public class WaterResourceNatural extends BaseEntity {
*/
@TableField("rec_user_name")
private String recUserName;
/**
* 是否启用
*/
@TableField("is_delete")
private Boolean isDelete;
}
......@@ -91,4 +91,9 @@ public class WaterResourcePool extends BaseEntity {
*/
@TableField("rec_user_name")
private String recUserName;
/**
* 是否启用
*/
@TableField("is_delete")
private Boolean isDelete;
}
package com.yeejoin.amos.boot.module.jcs.api.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum WaterResourceTypeEnum {
消火栓("hydrant", "消火栓"),
消防水鹤("crane", "消防水鹤"),
消防水池("pool", "消防水池"),
天然水源("natural", "天然水源");
private String code;
private String name;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
......@@ -74,4 +74,12 @@ public interface EquipFeignClient {
*/
@RequestMapping(value = "/fire-fighting-system/list", method = RequestMethod.GET)
ResponseModel<Object> getFireSystemListAll();
/**
* 获取消防系统列表
*
* @return
*/
@RequestMapping(value = "/building/tree", method = RequestMethod.GET)
ResponseModel<Object> getBuildingTree();
}
......@@ -6,6 +6,8 @@ import lombok.experimental.Accessors;
import java.util.List;
import org.springframework.util.ObjectUtils;
/**
* @author fengwang
* @date 2021-06-19.
......@@ -14,12 +16,43 @@ import java.util.List;
@Accessors(chain = true)
@ApiModel(value="OrgMenuVo", description="树菜单")
public class OrgMenuVo {
public Long key;
public String title;
public Long parentId;
public boolean leaf = true;
public List<OrgMenuVo> children;
public String bizOrgType;
private Long key;
private Long value;
private String title;
private String name;
private Long parentId;
private Boolean leaf = true;
private Boolean isLeaf = true;
private List<OrgMenuVo> children;
private String bizOrgType;
private String bizOrgCode;
public Boolean getLeaf() {
return ObjectUtils.isEmpty(children);
}
public Boolean getIsLeaf() {
return ObjectUtils.isEmpty(children);
}
public Long getValue() {
return key;
}
public String getName() {
return title;
}
public OrgMenuVo(Long key, String title, Long parentId, String bizOrgType, boolean leaf, String bizOrgCode) {
super();
this.key = key;
this.title = title;
this.parentId = parentId;
this.bizOrgType = bizOrgType;
this.leaf = leaf;
this.bizOrgCode = bizOrgCode;
}
public OrgMenuVo(Long key, String title, Long parentId, String bizOrgType, boolean leaf) {
super();
this.key = key;
......
......@@ -15,6 +15,12 @@
<artifactId>amos-boot-module-jcs-api</artifactId>
<version>${amos-biz-boot.version}</version>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
</dependencies>
</project>
......@@ -74,10 +74,9 @@ public class AircraftController extends BaseController {
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/{ids}")
@DeleteMapping(value = "/batch")
@ApiOperation(httpMethod = "DELETE", value = "根据物理主键批量删除航空器信息", notes = "根据物理主键批量删除航空器信息")
public ResponseModel<List<Long>> deleteBySequenceNbr(HttpServletRequest request,
@PathVariable(value = "ids") String ids) throws Exception{
public ResponseModel<List<Long>> deleteBySequenceNbr(@RequestParam(value = "ids") String ids) throws Exception{
return ResponseHelper.buildResponse(aircraftServiceImpl.multDeleteAircraft(RequestContext.getAgencyCode(), ids));
}
......@@ -112,7 +111,7 @@ public class AircraftController extends BaseController {
Page<AircraftDto> page=new Page<AircraftDto>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(aircraftServiceImpl.queryForAircraftPage(page, aircraftModel, engineType, fuelType));
return ResponseHelper.buildResponse(aircraftServiceImpl.queryForAircraftPage(page, false, aircraftModel, engineType, fuelType));
}
}
......@@ -5,25 +5,31 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.*;
import com.yeejoin.amos.boot.biz.common.utils.Menu;
import com.yeejoin.amos.boot.biz.common.utils.MenuFrom;
import com.yeejoin.amos.boot.biz.common.utils.NameUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.biz.common.utils.TreeParser;
import com.yeejoin.amos.boot.module.jcs.api.entity.DataDictionary;
import com.yeejoin.amos.boot.module.jcs.api.vo.AlertFormVo;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.DataDictionaryServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.bouncycastle.jcajce.provider.asymmetric.ec.SignatureSpi.ecCVCDSA;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
......@@ -169,6 +175,26 @@ public class DataDictionaryController extends BaseController {
}
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/dataDictionary", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据字典类型查询字典2", notes = "根据字典类型查询字典2")
public ResponseModel<Object> getDictionary(@RequestParam String type) throws Exception {
QueryWrapper<DataDictionary> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", type);
queryWrapper.orderByAsc("sort_num");
if (redisUtils.hasKey(RedisKey.DATA_DICTIONARY_CODE + type)) {
Object obj = redisUtils.get(RedisKey.DATA_DICTIONARY_CODE + type);
return ResponseHelper.buildResponse(obj);
} else {
Collection<DataDictionary> list = iDataDictionaryService.list(queryWrapper);
List<Menu> menus = TreeParser.getTree(null, list, DataDictionary.class.getName(), "getCode", 0, "getName", "getParent");
redisUtils.set(RedisKey.DATA_DICTIONARY_CODE + type, JSON.toJSON(menus), time);
return ResponseHelper.buildResponse(menus);
}
}
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/gwmcDataDictionary/FireChemical/{type}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据字典类型查询危险品字典", notes = "根据字典类型查询危险品字典")
public ResponseModel<Object> gwmcDataDictionaryFireChemical( @PathVariable String type) throws Exception{
......
package com.yeejoin.amos.boot.module.jcs.biz.controller;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.MenuFrom;
import com.yeejoin.amos.boot.module.jcs.api.dto.FireSystemDto;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.EquipmentServiceImpl;
import io.swagger.annotations.Api;
......@@ -32,7 +33,14 @@ public class EquipmentController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/fireSystem/list")
@ApiOperation(value = "获取消防系统列表")
public ResponseModel<List<FireSystemDto>> getFireSystemList() {
public ResponseModel<List<MenuFrom>> getFireSystemList() {
return ResponseHelper.buildResponse(equipmentService.getFireSystemList());
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/building/tree")
@ApiOperation(value = "获取消防建筑树")
public ResponseModel<List<MenuFrom>> getBuildingList() {
return ResponseHelper.buildResponse(equipmentService.getBuildingList());
}
}
......@@ -4,18 +4,23 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jcs.api.dto.FireChemicalDto;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.FireChemicalServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.List;
......@@ -64,9 +69,9 @@ public class FireChemicalController extends BaseController {
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/{sequenceNbr}")
@DeleteMapping(value = "/batch")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除危化品", notes = "根据sequenceNbr删除危化品")
public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request, @PathVariable(value = "sequenceNbr") String sequenceNbr){
public ResponseModel<Boolean> deleteBySequenceNbr(@RequestParam(value = "ids") String sequenceNbr) {
@SuppressWarnings("rawtypes")
List lt = Arrays.asList(sequenceNbr.split(","));
......
......@@ -125,6 +125,7 @@ public class FireExpertsController extends BaseController {
FireExperts fireExperts = BeanDtoVoUtils.convert(fireExpertsDto, FireExperts.class);
Page<FireExperts> pageBean;
QueryWrapper<FireExperts> fireExpertsQueryWrapper = new QueryWrapper<>();
fireExpertsQueryWrapper.eq("is_delete", false);
Class<? extends FireExperts> aClass = fireExperts.getClass();
Arrays.stream(aClass.getDeclaredFields()).forEach(field -> {
try {
......@@ -171,7 +172,7 @@ public class FireExpertsController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "列表全部数据查询", notes = "列表全部数据查询")
@GetMapping(value = "/list")
public ResponseModel<List<FireExpertsDto>> selectForList() {
List<FireExpertsDto> fireExpertsDtoList = fireExpertsServiceImpl.queryForFireExpertsList();
List<FireExpertsDto> fireExpertsDtoList = fireExpertsServiceImpl.queryForFireExpertsList(false);
fireExpertsDtoList.stream().map(item -> {
item.setAge(BeanDtoVoUtils.getAge(item.getBirthdayTime()));
return item;
......
......@@ -138,12 +138,26 @@ public class OrgUsrController extends BaseController {
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/companyTree", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "获取单位部门树", notes = "获取单位部门树")
@ApiOperation(httpMethod = "GET", value = "获取单位部门树(key为物理主键)", notes = "获取单位部门树(key为物理主键)\"")
public ResponseModel< List<OrgMenuVo>>selectCompanyTree() throws Exception {
List<OrgMenuVo> menus = iOrgUsrService.getTree(null, iOrgUsrService.selectCompanyDepartmentMsg(), OrgUsr.class.getName(), "getSequenceNbr", 2, "getBizOrgName", "getParentId", "getBizOrgType");
return ResponseHelper.buildResponse(menus);
}
/**
*
* 获取单位部门树
* @param
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/orgTree", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "获取单位部门树(bizOrgCode为物理主键)", notes = "获取单位部门树(bizOrgCode为物理主键)\"")
public ResponseModel< List<OrgMenuVo>>selectCompanyTreeCode() throws Exception {
List<OrgMenuVo> menus = iOrgUsrService.buildTreeParallel(iOrgUsrService.selectCompanyDepartmentMsg());
return ResponseHelper.buildResponse(menus);
}
/**
* 列表分页查询
......
......@@ -15,13 +15,15 @@ import org.typroject.tyboot.core.foundation.exception.BaseException;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.StringUtil;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.annotation.Condition;
import org.typroject.tyboot.core.rdbms.annotation.Operator;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.DataNotFound;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 航空器信息服务实现类
......@@ -43,6 +45,8 @@ public class AircraftServiceImpl extends BaseService<AircraftDto, Aircraft, Airc
* @throws Exception
*/
public AircraftDto createAircraft(String agencyCode, AircraftDto aircraftDto) throws Exception {
aircraftDto.setIsDelete(false);
//持久化航空器信息
aircraftDto = this.createWithModel(aircraftDto);
//持久化航空器附件信息
......@@ -62,9 +66,9 @@ public class AircraftServiceImpl extends BaseService<AircraftDto, Aircraft, Airc
*/
public AircraftDto updateAircraft(String agencyCode, AircraftDto model) throws Exception {
AircraftDto oldModel = this.queryBySeq(model.getSequenceNbr());
if (ValidationUtil.isEmpty(oldModel))
if (ValidationUtil.isEmpty(oldModel)) {
throw new DataNotFound("找不到指定的航空器信息.");
}
//删除附件信息
Systemctl.fileInfoClient.deleteByAlias(agencyCode, Aircraft.class.getSimpleName(),
String.valueOf(model.getSequenceNbr()), null);
......@@ -113,11 +117,14 @@ public class AircraftServiceImpl extends BaseService<AircraftDto, Aircraft, Airc
public List<Long> multDeleteAircraft(String agencyCode, String ids) throws Exception {
List<Long> seqs = StringUtil.String2LongList(ids);
for (Long id : seqs) {
//删除附件信息
Systemctl.fileInfoClient.deleteByAlias(agencyCode, Aircraft.class.getSimpleName(),
String.valueOf(id), null);
//删除航空器信息
this.deleteBySeq(id);
AircraftDto aircraftDto = this.queryBySeq(id);
aircraftDto.setIsDelete(true);
this.updateWithModel(aircraftDto);
// //删除附件信息
// Systemctl.fileInfoClient.deleteByAlias(agencyCode, Aircraft.class.getSimpleName(),
// String.valueOf(id), null);
// //删除航空器信息
// this.deleteBySeq(id);
}
return seqs;
}
......@@ -131,9 +138,11 @@ public class AircraftServiceImpl extends BaseService<AircraftDto, Aircraft, Airc
* @param page
* @return
*/
public Page<AircraftDto> queryForAircraftPage(Page<AircraftDto> page, String aircraftModel,
public Page<AircraftDto> queryForAircraftPage(Page<AircraftDto> page,
Boolean isDelete,
@Condition(Operator.like) String aircraftModel,
String engineType, String fuelType) {
return this.queryForPage(page, null, false, aircraftModel, engineType, fuelType);
return this.queryForPage(page, null, false, isDelete, aircraftModel, engineType, fuelType);
}
/**
......
......@@ -31,12 +31,16 @@ import com.yeejoin.amos.boot.module.jcs.api.vo.PowerTransferCompanyVo;
import com.yeejoin.amos.boot.module.jcs.api.vo.SchedulingReportingVo;
import com.yeejoin.amos.boot.module.jcs.api.vo.TemplateVo;
import com.yeejoin.amos.boot.module.jcs.biz.rule.action.AlertCalledAction;
import com.yeejoin.amos.component.rule.config.ClazzUtils;
import com.yeejoin.amos.component.rule.config.RuleConfig;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.StringUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
......@@ -82,6 +86,12 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
@Autowired
private RedisUtils redisUtils;
@Autowired
private EmqKeeper emqKeeper;
@Value("${mqtt.topic.alert.reporting}")
private String topic;
@Override
public SchedulingReportingVo listSchedulingByParam(AlertSubmittedDto queryParam) {
SchedulingReportingVo schedulingReportingVo = new SchedulingReportingVo();
......@@ -153,11 +163,13 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
Set<String> mobiles = new HashSet<>();
HashMap<String, String> smsParams = new HashMap<>();
String alertCalledId = null;
// 根据id列表查询所有人员信息
List<Long> ids = StringUtil.String2LongList(sendIds);
if (object instanceof AlertCalledRo) {
AlertCalledRo calledRo = (AlertCalledRo) object;
String alertSubmittedId = calledRo.getAlertSubmittedId();
alertCalledId = calledRo.getSequenceNbr();
// 警情初报
if (alertSubmittedId == null) {
......@@ -223,6 +235,8 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
// 组织短信内容
// 调用短信发送接口
alertCalledAction.sendAlertCalleCmd(smsCode, mobiles, smsParams);
emqKeeper.getMqttClient().publish(topic, alertCalledId.getBytes(), RuleConfig.DEFAULT_QOS, false);
}
/**
......
package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import com.baomidou.mybatisplus.core.toolkit.BeanUtils;
import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.biz.common.utils.MenuFrom;
import com.yeejoin.amos.boot.biz.common.utils.TreeParser;
import com.yeejoin.amos.boot.module.jcs.api.dto.FireSystemDto;
import com.yeejoin.amos.boot.module.jcs.api.feign.EquipFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StopWatch;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
......@@ -21,20 +25,49 @@ public class EquipmentServiceImpl {
@Autowired
EquipFeignClient equipFeignClient;
public List<FireSystemDto> getFireSystemList() {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
public List<MenuFrom> getFireSystemList() {
ResponseModel<Object> response = equipFeignClient.getFireSystemListAll();
stopWatch.stop();
System.out.printf("耗时%f秒/n", stopWatch.getTotalTimeSeconds());
List<Map<String, Object>> fireSystemMapList = (List<Map<String, Object>>) response.getResult();
List<FireSystemDto> fireSystemDtoList = Lists.newArrayList();
List<MenuFrom> fireSystemDtoList = Lists.newArrayList();
fireSystemMapList.forEach(system -> {
FireSystemDto fireSystemDto = new FireSystemDto();
fireSystemDto.setId((String) system.get("id"));
fireSystemDto.setName((String) system.get("name"));
fireSystemDtoList.add(fireSystemDto);
MenuFrom menuFrom = new MenuFrom((String) system.get("id"), (String) system.get("name"), "0");
fireSystemDtoList.add(menuFrom);
});
return fireSystemDtoList;
}
public List<MenuFrom> getBuildingList() {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
ResponseModel<Object> response = equipFeignClient.getBuildingTree();
stopWatch.stop();
System.out.printf("耗时%f秒/n", stopWatch.getTotalTimeSeconds());
List<Map<String, Object>> buildingMapList = (List<Map<String, Object>>) response.getResult();
List<MenuFrom> buildingTreeList = Lists.newArrayList();
buildingMapList.forEach(building -> {
MenuFrom menuFrom = new MenuFrom((String) building.get("id"), "全部建筑", (String) building.get("parentId"));
List<Map<String, Object>> children = (List<Map<String, Object>>) building.get("children");
menuFrom.setChildren(parseTree(menuFrom, children));
menuFrom.setIsLeaf(false);
buildingTreeList.add(menuFrom);
});
return buildingTreeList.get(0).getChildren();
}
private List<MenuFrom> parseTree(MenuFrom parent, List<Map<String, Object>> children) {
List<MenuFrom> menuFromList = Lists.newArrayList();
if (!ValidationUtil.isEmpty(children)) {
children.forEach(child -> {
MenuFrom menuFrom = new MenuFrom((String) child.get("id"), (String) child.get("name"), (String) child.get("parentId"));
if (!ValidationUtil.isEmpty(child.get("children"))) {
parseTree(menuFrom, (List<Map<String, Object>>) child.get("children"));
} else {
parent.setIsLeaf(false);
}
menuFromList.add(menuFrom);
parent.setChildren(menuFromList);
});
}
return menuFromList;
}
}
......@@ -7,17 +7,21 @@ import com.yeejoin.amos.boot.module.jcs.api.mapper.FireExpertsMapper;
import com.yeejoin.amos.boot.module.jcs.api.service.IFireExpertsService;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.annotation.Condition;
import org.typroject.tyboot.core.rdbms.annotation.Operator;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.List;
/**
* 服务实现类
*消防专家
* @author system_generator
* @date 2021-06-25
*/
* 服务实现类
* 消防专家
*
* @author system_generator
* @date 2021-06-25
*/
@Service
public class FireExpertsServiceImpl extends BaseService<FireExpertsDto,FireExperts,FireExpertsMapper> implements IFireExpertsService {
public class FireExpertsServiceImpl extends BaseService<FireExpertsDto, FireExperts, FireExpertsMapper> implements IFireExpertsService {
/**
* 分页查询
*/
......@@ -28,7 +32,7 @@ public class FireExpertsServiceImpl extends BaseService<FireExpertsDto,FireExper
/**
* 列表查询 示例
*/
public List<FireExpertsDto> queryForFireExpertsList() {
return this.queryForList("" , false);
public List<FireExpertsDto> queryForFireExpertsList(@Condition(Operator.eq) Boolean isDelete) {
return this.queryForList("", false, isDelete);
}
}
......@@ -9,6 +9,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
......@@ -63,6 +64,37 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
return this.baseMapper.selectUpUnitByParam(id);
}
public static List<OrgMenuVo> buildTreeParallel(List<OrgUsr> list) {
List<OrgMenuVo> menuList = list.stream().map(o -> {
OrgMenuVo menu = new OrgMenuVo(o.getSequenceNbr(), o.getBizOrgName(), ObjectUtils.isEmpty(o.getParentId()) ? 0L :Long.valueOf(o.getParentId()), o.getBizOrgType(), false, o.getBizOrgCode());
return menu;
}).collect(Collectors.toList());
List<OrgMenuVo> result = new ArrayList<>();
Map<Long, OrgMenuVo> map = new HashMap<>(menuList.size());
menuList.forEach(e -> map.put(e.getKey(), e));
Set<? extends Map.Entry<Long, ? extends OrgMenuVo>> entries = map.entrySet();
entries.parallelStream().forEach(entry -> {
OrgMenuVo value = entry.getValue();
if (value != null) {
OrgMenuVo treeDto = map.get(value.getParentId());
if (treeDto != null) {
List<OrgMenuVo> children = treeDto.getChildren();
if (children == null) {
children = new ArrayList<>();
treeDto.setChildren(children);
}
children.add(value);
} else {
result.add(value);
}
}
});
return result;
}
@Override
public List<OrgMenuVo> getTree(Long topId, Collection entityList, String packageURL, String IDMethodName, int IDHierarchy, String NAMEMethodName, String PARENTIDMethodName, String OrgTypeMethodName) throws Exception {
List<OrgMenuVo> resultList = new ArrayList<>();
......@@ -455,7 +487,12 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
@Override
public List<OrgUsr> selectCompanyDepartmentMsg() {
return this.baseMapper.selectCompanyDepartmentMsg();
List<OrgUsr> list = this.baseMapper.selectCompanyDepartmentMsg();
if (list == null) {
return new ArrayList<>();
}
list = list.stream().filter(o -> !ObjectUtils.isEmpty(o)).collect(Collectors.toList());
return list;
}
@Override
......@@ -594,7 +631,11 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
List<FormValue> formValue = getFormValue(id);
OrgPersonFormVo orgPersonFormVo = new OrgPersonFormVo(formValue);
BeanUtils.copyProperties(orgUsr, orgPersonFormVo);
orgPersonFormVo.setParentName(getById(orgUsr.getParentId()).getBizOrgName());
OrgUsr parent = getById(orgUsr.getParentId());
if (!ObjectUtils.isEmpty(parent)) {
orgPersonFormVo.setParentName(parent.getBizOrgName());
}
return orgPersonFormVo;
}
......
......@@ -29,6 +29,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
......@@ -121,6 +122,7 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
ResponseModel<Object> result = equipFeignService.getFireCarListAll();
if (!ObjectUtils.isEmpty(result)) {
List<Map<String, Object>> fireCarListMapList = (List<Map<String, Object>>) result.getResult();
if (!ValidationUtil.isEmpty(fireCarListMapList)) {
fireCarListMapList.stream().filter(car -> ObjectUtils.isNotEmpty(car.get("teamId"))).forEach(car -> {
FireBrigadeResourceDto fireCarDto = (FireBrigadeResourceDto) Bean.mapToBean(car, FireBrigadeResourceDto.class);
// TODO 后期根据车物联状态来返回,现在为"在位=执勤","其他=出动"
......@@ -133,6 +135,7 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
fireCarDtoList.add(fireCarDto);
});
}
}
// 2.查询消防队伍列表
List<FireTeam> fullTimeFireBrigadeList = fireTeamService.list(new QueryWrapper<FireTeam>().eq("type_code",
......@@ -140,6 +143,7 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
if (!CollectionUtils.isEmpty(fullTimeFireBrigadeList)) {
Map<String, List<FireBrigadeResourceDto>> resultMap =
fireCarDtoList.stream().collect(Collectors.groupingBy(FireBrigadeResourceDto::getTeamId));
if (!ValidationUtil.isEmpty(fullTimeFireBrigadeList)) {
fullTimeFireBrigadeList.forEach(brigade -> {
if (!CollectionUtils.isEmpty(resultMap.get(brigade.getSequenceNbr().toString()))) {
FireBrigadeResourceDto fireCarResourceDto = new FireBrigadeResourceDto();
......@@ -157,6 +161,7 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
}
});
}
}
// 3.消防队伍-监控大队
List<FireBrigadeResourceDto> monitorFireBrigadeList = fireTeamService.listMonitorFireBrigade();
......
......@@ -4,29 +4,36 @@ import com.yeejoin.amos.boot.module.jcs.api.entity.WaterResource;
import com.yeejoin.amos.boot.module.jcs.api.mapper.WaterResourceMapper;
import com.yeejoin.amos.boot.module.jcs.api.service.IWaterResourceService;
import com.yeejoin.amos.boot.module.jcs.api.dto.WaterResourceDto;
import org.typroject.tyboot.core.rdbms.annotation.Condition;
import org.typroject.tyboot.core.rdbms.annotation.Operator;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
/**
* 服务实现类
*
* @author system_generator
* @date 2021-06-29
*/
* 服务实现类
*
* @author system_generator
* @date 2021-06-29
*/
@Service
public class WaterResourceServiceImpl extends BaseService<WaterResourceDto,WaterResource,WaterResourceMapper> implements IWaterResourceService {
public class WaterResourceServiceImpl extends BaseService<WaterResourceDto, WaterResource, WaterResourceMapper> implements IWaterResourceService {
/**
* 分页查询
*/
public Page<WaterResourceDto> queryForWaterResourcePage(Page<WaterResourceDto> page) {
return this.queryForPage(page, null, false);
public Page<WaterResourceDto> queryForWaterResourcePage(Page<WaterResourceDto> page,
@Condition(Operator.like) String name,
@Condition(Operator.eq) String resourceType,
@Condition(Operator.eq) Boolean isDelete) {
return this.queryForPage(page, null, false, name, resourceType, isDelete);
}
/**
* 列表查询 示例
*/
public List<WaterResourceDto> queryForWaterResourceList() {
return this.queryForList("" , false);
public List<WaterResourceDto> queryForWaterResourceList(@Condition(Operator.eq) Boolean isDelete) {
return this.queryForList("", false, isDelete);
}
}
......@@ -7,6 +7,7 @@ import com.yeejoin.amos.boot.module.jcs.api.entity.FireExperts;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.util.Calendar;
import java.util.Date;
......@@ -111,34 +112,23 @@ public class BeanDtoVoUtils {
});
}
//由出生日期获得年龄
// 根据LocalDate来计算年龄
public static int getAge(Date birthDay) {
if(birthDay == null){
if (birthDay == null) {
return 0;
}
LocalDate now = LocalDate.now();
Calendar cal = Calendar.getInstance();
if (cal.before(birthDay)) {
throw new IllegalArgumentException("出生日期小于当前时间,无效的日期!");
}
int yearNow = cal.get(Calendar.YEAR);
int monthNow = cal.get(Calendar.MONTH);
int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH);
cal.setTime(birthDay);
int yearBirth = cal.get(Calendar.YEAR);
int monthBirth = cal.get(Calendar.MONTH);
int monthBirth = cal.get(Calendar.MONTH) + 1;
int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH);
int age = yearNow - yearBirth;
if (monthNow <= monthBirth) {
if (monthNow == monthBirth) {
if (dayOfMonthNow < dayOfMonthBirth) age--;
} else {
age--;
}
LocalDate birth = LocalDate.of(yearBirth, monthBirth, dayOfMonthBirth);
if (birth.isAfter(now)) {
return 0;
}
int age = birth.until(now).getYears();
return age;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment