Commit be82430d authored by xixinzhao's avatar xixinzhao

Merge branch 'develop_dl' into develop_0419

# Conflicts: # amos-boot-module/amos-boot-module-biz/amos-boot-module-jcs-biz/src/main/java/com/yeejoin/amos/boot/module/jcs/biz/service/impl/ExcelServiceImpl.java # amos-boot-module/amos-boot-module-biz/amos-boot-module-patrol-biz/src/main/java/com/yeejoin/amos/patrol/business/controller/PlanController.java # amos-boot-module/amos-boot-module-biz/amos-boot-module-patrol-biz/src/main/java/com/yeejoin/amos/patrol/business/controller/RouteController.java # amos-boot-module/amos-boot-module-biz/amos-boot-module-patrol-biz/src/main/java/com/yeejoin/amos/patrol/business/dao/repository/IRouteDao.java # amos-boot-module/amos-boot-module-biz/amos-boot-module-patrol-biz/src/main/java/com/yeejoin/amos/patrol/business/dto/InputItemExcelDto.java # amos-boot-system-patrol/src/main/resources/db/mapper/dbTemplate_input_item.xml
parents 5c402bbc 099be078
...@@ -29,6 +29,8 @@ public interface DataDictionaryMapper extends BaseMapper<DataDictionary> { ...@@ -29,6 +29,8 @@ public interface DataDictionaryMapper extends BaseMapper<DataDictionary> {
* @return * @return
*/ */
public DataDictionary getByCode(String code,String type); public DataDictionary getByCode(String code,String type);
public DataDictionary getByType(@Param("type") String type);
public List<DataDictionary> getFireTeamTypeTree(String bizOrgCode); public List<DataDictionary> getFireTeamTypeTree(String bizOrgCode);
......
...@@ -116,6 +116,13 @@ WHERE ...@@ -116,6 +116,13 @@ WHERE
cdd.type = 'XFSYLX' cdd.type = 'XFSYLX'
</select> </select>
<select id="getByType" resultType="com.yeejoin.amos.boot.biz.common.entity.DataDictionary">
SELECT
*
FROM
cb_data_dictionary cbb
WHERE
cbb.is_delete = 0 and cbb.type = #{type}
</select>
</mapper> </mapper>
...@@ -266,8 +266,8 @@ public class OrgUsrTPDlExcelDto{ ...@@ -266,8 +266,8 @@ public class OrgUsrTPDlExcelDto{
@ApiModelProperty(value = "平台单位id") @ApiModelProperty(value = "平台单位id")
private String companySeqs; private String companySeqs;
@ExplicitConstraint(indexNum = 16, sourceClass = CommonExplicitConstraint.class, method = "getdeptSeqsList") @ExplicitConstraint(indexNum = 16, sourceClass = CommonExplicitConstraint.class, method = "getdeptSeqsList")
@ExcelProperty(value = "平台部门id", index = 16) @ExcelProperty(value = "平台部门", index = 16)
@ApiModelProperty(value = "平台部门id") @ApiModelProperty(value = "平台部门")
private String deptSeqs; private String deptSeqs;
@ExcelIgnore @ExcelIgnore
@ApiModelProperty(value = "邮箱") @ApiModelProperty(value = "邮箱")
......
package com.yeejoin.equipmanage.common.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import com.yeejoin.equipmanage.common.entity.publics.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* 车量里程表
*
* @author duanwei
* @date 2023-02-01
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="WlCarMileage对象", description="车量里程表")
public class WlCarMileageDto extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "iot编码")
private String iotCode;
@ApiModelProperty(value = "里程km")
private Double travel;
@ApiModelProperty(value = "日期")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date date;
@ApiModelProperty(value = "开始时间")
private String startTime;
@ApiModelProperty(value = "结束时间")
private String endTime;
@ApiModelProperty(value = "耗时")
private Long takeTime;
@ApiModelProperty(value = "开始地址")
private String startName;
@ApiModelProperty(value = "结束地址")
private String endName;
@ApiModelProperty(value = "开始精度")
private Double startLongitude;
@ApiModelProperty(value = "开始纬度")
private Double startLatitude;
@ApiModelProperty(value = "结束精度")
private Double endLongitude;
@ApiModelProperty(value = "结束纬度")
private Double endLatitude;
@ApiModelProperty(value = "开始速度km/h")
private Integer startSpeed;
@ApiModelProperty(value = "结束速度km/h")
private Integer endSpeed;
@TableField(exist = false)
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date filterDate;
@TableField(exist = false)
private String name;
@TableField(exist = false)
private String time;
@TableField(exist = false)
private long carId;
@TableField(exist = false)
private String startFullTime;
@TableField(exist = false)
private String endFullTime;
}
...@@ -2,6 +2,7 @@ package com.yeejoin.equipmanage.common.entity; ...@@ -2,6 +2,7 @@ package com.yeejoin.equipmanage.common.entity;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.yeejoin.equipmanage.common.entity.publics.BaseEntity; import com.yeejoin.equipmanage.common.entity.publics.BaseEntity;
import com.yeejoin.equipmanage.common.entity.vo.EquipmentOnCarAppVO; import com.yeejoin.equipmanage.common.entity.vo.EquipmentOnCarAppVO;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
...@@ -22,7 +23,7 @@ import java.util.List; ...@@ -22,7 +23,7 @@ import java.util.List;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Accessors(chain = true) @Accessors(chain = true)
@TableName("wl_car") @TableName(value="wl_car",autoResultMap = true)
@ApiModel(value = "Car对象", description = "消防车信息") @ApiModel(value = "Car对象", description = "消防车信息")
public class Car extends BaseEntity { public class Car extends BaseEntity {
...@@ -176,4 +177,61 @@ public class Car extends BaseEntity { ...@@ -176,4 +177,61 @@ public class Car extends BaseEntity {
@TableField(exist = false) @TableField(exist = false)
private String iotStatus; private String iotStatus;
@TableField(exist = false)
private Long categoryId;
@TableField(exist = false)
private String importStr;
@TableField(exist = false)
private Integer totalTravel;
@TableField(exist = false)
private double longitude;
@TableField(exist = false)
private double latitude;
@TableField(exist = false)
private Integer speed;
@ApiModelProperty(value = "配备方式")
private String deployment;
@ApiModelProperty(value = "配备日期")
private String deployDate;
@ApiModelProperty(value = "配备日期区间")
@TableField(typeHandler = FastjsonTypeHandler.class )
private List<String> deployDateRange;
@ApiModelProperty(value = "排量")
private String displacement;
@ApiModelProperty(value = "车辆产权单位")
private String ownership;
@ApiModelProperty(value = "编号")
private String code;
@ApiModelProperty(value = "扩展字段1")
private String extra1;
@ApiModelProperty(value = "扩展字段2")
private String extra2;
@ApiModelProperty(value = "扩展字段3")
private String extra3;
@ApiModelProperty(value = "扩展字段4")
private String extra4;
@TableField(exist = false)
private String iotMeasurement;
@TableField(exist = false)
private String iotDeviceName;
} }
package com.yeejoin.equipmanage.common.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.yeejoin.equipmanage.common.entity.publics.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* 车量里程表
*
* @author duanwei
* @date 2023-02-01
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="WlCarMileage对象", description="车量里程表")
public class WlCarMileage extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "iot编码")
private String iotCode;
@ApiModelProperty(value = "里程km")
private Double travel;
@ApiModelProperty(value = "日期")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date date;
@ApiModelProperty(value = "开始时间")
private Date startTime;
@ApiModelProperty(value = "结束时间")
private Date endTime;
@ApiModelProperty(value = "耗时")
private Long takeTime;
@ApiModelProperty(value = "开始地址")
private String startName;
@ApiModelProperty(value = "结束地址")
private String endName;
@ApiModelProperty(value = "开始精度")
private Double startLongitude;
@ApiModelProperty(value = "开始纬度")
private Double startLatitude;
@ApiModelProperty(value = "结束精度")
private Double endLongitude;
@ApiModelProperty(value = "结束纬度")
private Double endLatitude;
@ApiModelProperty(value = "开始速度km/h")
private Integer startSpeed;
@ApiModelProperty(value = "结束速度km/h")
private Integer endSpeed;
@TableField(exist = false)
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date filterDate;
@TableField(exist = false)
private String name;
@TableField(exist = false)
private String time;
@TableField(exist = false)
private long carId;
@TableField(exist = false)
private boolean complete = false;
}
package com.yeejoin.equipmanage.common.entity.dto;
import com.yeejoin.equipmanage.common.dto.WlCarMileageDto;
import lombok.Data;
import java.util.List;
@Data
public class CarTravelDto {
Long total;
String totalTime;
Integer totalTravel;
List<WlCarMileageDto> records;
}
package com.yeejoin.equipmanage.common.entity.dto;
import lombok.Data;
@Data
public class CommonFile {
private static final long serialVersionUID = 1L;
private String url;
private String name;
private String uid;
private String status;
}
...@@ -65,4 +65,17 @@ public class EquipTypeAmountPageDTO extends BaseDTO<EquipmentSpecific> { ...@@ -65,4 +65,17 @@ public class EquipTypeAmountPageDTO extends BaseDTO<EquipmentSpecific> {
@ApiModelProperty(value = "缺陷管理新增页面用,其余地方可忽略 1-是缺陷管理 0-不是") @ApiModelProperty(value = "缺陷管理新增页面用,其余地方可忽略 1-是缺陷管理 0-不是")
private Integer isDefect; private Integer isDefect;
@ApiModelProperty(value = "关键字-地图用")
private String keyword;
@ApiModelProperty(value = "页数-地图用")
private Integer current;
@ApiModelProperty(value = "分页大小-地图用")
private Integer size;
@ApiModelProperty(value = "车牌号")
private String carNum;
} }
package com.yeejoin.equipmanage.common.entity.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.yeejoin.equipmanage.common.entity.*;
import com.yeejoin.equipmanage.common.entity.dto.CommonFile;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
@Data
public class CarMessage {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id")
private Long id;
@ApiModelProperty(value = "名称")
private String name;
@ApiModelProperty(value = "车牌号")
private String carNum;
@ApiModelProperty(value = "车辆类型")
private Long equipmentId;
@ApiModelProperty(value = "车辆状态")
private String carState;
@ApiModelProperty(value = "品牌")
private String brand;
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "规格型号")
private String standard;
@ApiModelProperty(value = "底盘品牌")
private String chassisBrand;
@ApiModelProperty(value = "厂商id")
private Long manufacturerId;
@ApiModelProperty(value = "底盘国别")
private String chassisCountry;
@ApiModelProperty(value = "国别")
private String country;
@ApiModelProperty(value = "进口国产")
private Boolean isImport;
@ApiModelProperty(value = "二维码")
private String qrCode;
@ApiModelProperty(value = "全部二维码含类型标识03#qrCode")
private String fullQrCode;
@ApiModelProperty(value = "保养周期")
private BigDecimal maintenanceCycle;
@ApiModelProperty(value = "3c认证")
private Boolean cccAuth;
@ApiModelProperty(value = "负责人")
private Long creatorId;
@ApiModelProperty(value = "组织机构")
private String orgCode;
@ApiModelProperty(value = "公司名")
private String companyName;
@ApiModelProperty(value = "部门code")
private String departmentOrgcode;
@ApiModelProperty(value = "部门名")
private String departmentName;
@ApiModelProperty(value = "物联编码")
private String iotCode;
@ApiModelProperty(value = "所属单位id(来源于平台)")
private String agencyId;
@ApiModelProperty(value = "所属队伍id(来源于平台)")
private String teamId;
@ApiModelProperty(value = "队伍名称(冗余字段来源于平台)")
private String teamName;
@ApiModelProperty(value = "机构/部门名称")
private String bizOrgName;
@ApiModelProperty(value = "机构编码")
private String bizOrgCode;
@ApiModelProperty(value = "图片")
@TableField(exist = false)
private List<CommonFile> img;
@ApiModelProperty(value = "视频")
@TableField(exist = false)
private List<UploadFile> video;
@ApiModelProperty(value = "证书")
@TableField(exist = false)
private List<CommonFile> certification;
@ApiModelProperty(value = "说明")
@TableField(exist = false)
private List<UploadFile> instruction;
@TableField(exist = false)
private Equipment equipment;
@TableField(exist = false)
private String manufacturerName;
@TableField(exist = false)
private String countryName;
@TableField(exist = false)
private String chassisCountryName;
@TableField(exist = false)
private ManufacturerInfo manufacturerInfo;
@TableField(exist = false)
private List<CarProperty> carPropertyList;
@TableField(exist = false)
private List<Journal> journals;
@TableField(exist = false)
private List<EquipmentOnCarAppVO> EquipmentsOnCar;
@TableField(exist = false)
@ApiModelProperty(value = "扩展字段")
private String ext;
@TableField(exist = false)
private String unitName;
@TableField(exist = false)
private Unit unit;
@ApiModelProperty(value = "证书")
@TableField(exist = false)
private String iotStatus;
@TableField(exist = false)
private Long categoryId;
@TableField(exist = false)
private String importStr;
@TableField(exist = false)
private Integer totalTravel;
@TableField(exist = false)
private double longitude;
@TableField(exist = false)
private double latitude;
@TableField(exist = false)
private Integer speed;
@ApiModelProperty(value = "配备方式")
private String deployment;
@ApiModelProperty(value = "配备日期")
private String deployDate;
@ApiModelProperty(value = "配备日期区间")
@TableField(typeHandler = FastjsonTypeHandler.class )
private List<String> deployDateRange;
@ApiModelProperty(value = "排量")
private String displacement;
@ApiModelProperty(value = "车辆产权单位")
private String ownership;
@ApiModelProperty(value = "编号")
private String code;
@ApiModelProperty(value = "扩展字段1")
private String extra1;
@ApiModelProperty(value = "扩展字段2")
private String extra2;
@ApiModelProperty(value = "扩展字段3")
private String extra3;
@ApiModelProperty(value = "扩展字段4")
private String extra4;
@TableField(exist = false)
private String iotMeasurement;
@TableField(exist = false)
private String iotDeviceName;
}
...@@ -55,4 +55,10 @@ public class EquipTypeImgAmountVO { ...@@ -55,4 +55,10 @@ public class EquipTypeImgAmountVO {
@ApiModelProperty(value = "所在建筑") @ApiModelProperty(value = "所在建筑")
private String belongBuildName; private String belongBuildName;
@ApiModelProperty(value = "经度")
private Double longitude;
@ApiModelProperty(value = "纬度")
private Double latitude;
} }
package com.yeejoin.equipmanage.common.utils;
public class CoordinateUtil {
// WGS84标准参考椭球中的地球长半径(单位:米)
private static final double EARH_RADIUS_WGS84 = 6378137.0;
public static double distance(double lat1, double lng1, double lat2, double lng2) {
double radLat1 = Math.toRadians(lat1);
double radLat2 = Math.toRadians(lat2);
double a = radLat1 - radLat2;
double b = Math.toRadians(lng1) - Math.toRadians(lng2);
double s = 2 * Math.asin(Math.sqrt(
Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
return s * EARH_RADIUS_WGS84;
}
}
...@@ -221,6 +221,47 @@ public class QRCodeUtil { ...@@ -221,6 +221,47 @@ public class QRCodeUtil {
return encoder.encodeToString(outputStream.toByteArray()); return encoder.encodeToString(outputStream.toByteArray());
} }
/**
* 根据二维码信息,生成二维码图片 用户excel,word等导出图片 可自定义图片大小
*
* @param content
* @return
*/
public static byte[] generateQRCodeImageByteData(String content, int size) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
Hashtable<EncodeHintType, Object> hints = new Hashtable<EncodeHintType, Object>();
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
hints.put(EncodeHintType.CHARACTER_SET, CHARSET);
hints.put(EncodeHintType.MARGIN, 1);
BitMatrix bitMatrix = new MultiFormatWriter().encode(
content
, BarcodeFormat.QR_CODE
, size
, size,
hints);
int width = bitMatrix.getWidth();
int height = bitMatrix.getHeight();
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
image.setRGB(x, y, bitMatrix.get(x, y) ? 0xFF000000 : 0xFFFFFFFF);
}
}
ImageIO.write(image, "png", out);
return out.toByteArray();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(genQrCodeBase64Png("101",100,100)); System.out.println(genQrCodeBase64Png("101",100,100));
System.out.println(genQrCodeBase64PngWithWord("101",100,100,"sd",100)); System.out.println(genQrCodeBase64PngWithWord("101",100,100,"sd",100));
......
...@@ -12,6 +12,13 @@ ...@@ -12,6 +12,13 @@
<artifactId>amos-boot-module-patrol-api</artifactId> <artifactId>amos-boot-module-patrol-api</artifactId>
<dependencies> <dependencies>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.3.10</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> <artifactId>spring-boot-starter-data-jpa</artifactId>
......
package com.yeejoin.amos.patrol.core.common.request;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.net.NetUtil;
import cn.hutool.core.util.IdUtil;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.id.IdentifierGenerator;
import org.springframework.beans.factory.annotation.Value;
import javax.annotation.PostConstruct;
import java.io.Serializable;
/**
* @description:
* @author: tw
* @createDate: 2023/4/10
*/
public class MyIdGeneratorConfig implements IdentifierGenerator {
/**
* 终端ID
*/
@Value("${generator.worker_id}")
public long WORKER_ID;
/**
* 数据中心id
*/
@Value("${generator.datacenter_id}")
public long DATACENTER_ID;
private Snowflake snowflake = IdUtil.createSnowflake(WORKER_ID, DATACENTER_ID);
@PostConstruct
public void init() {
WORKER_ID = NetUtil.ipv4ToLong(NetUtil.getLocalhostStr());
}
public synchronized long snowflakeId() {
return snowflake.nextId();
}
public synchronized long snowflakeId(long workerId, long datacenterId) {
Snowflake snowflake = IdUtil.createSnowflake(workerId, datacenterId);
return snowflake.nextId();
}
@Override
public Serializable generate(SharedSessionContractImplementor session, Object object)
throws HibernateException {
return snowflakeId(WORKER_ID, DATACENTER_ID);
}
}
...@@ -2,6 +2,7 @@ package com.yeejoin.amos.patrol.dao.entity; ...@@ -2,6 +2,7 @@ package com.yeejoin.amos.patrol.dao.entity;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener; import org.springframework.data.jpa.domain.support.AuditingEntityListener;
...@@ -35,7 +36,11 @@ public class BasicEntity implements Serializable{ ...@@ -35,7 +36,11 @@ public class BasicEntity implements Serializable{
private Date createDate; private Date createDate;
@Id @Id
@GeneratedValue(strategy=GenerationType.IDENTITY) @GeneratedValue(generator = "myIdGeneratorConfig",
strategy = GenerationType.AUTO)
@GenericGenerator(
name = "myIdGeneratorConfig",
strategy = "com.yeejoin.amos.patrol.core.common.request.MyIdGeneratorConfig")
@Column(name = "ID",nullable=false,unique=true) @Column(name = "ID",nullable=false,unique=true)
public long getId() { public long getId() {
return id; return id;
......
...@@ -625,33 +625,31 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp ...@@ -625,33 +625,31 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
// 2021-09-16 // 2021-09-16
if (null != t.get("amosOrgId") && StringUtils.isNotEmpty(t.get("amosOrgId").toString())) { if (null != t.get("amosOrgId") && StringUtils.isNotEmpty(t.get("amosOrgId").toString())) {
amosIds.add(t.get("amosOrgId").toString()); amosIds.add(t.get("amosOrgId").toString());
String chargePersonId = iOrgUsrService.getIdNumberByAmosId(t.get("amosOrgId").toString()); if (!ObjectUtils.isEmpty(t.get("certificateTypeValue")) && "120".equals(t.get("certificateTypeValue").toString())) {
t.put("chargePersonId", chargePersonId); t.put("chargePersonId", t.get("certificatesNumber"));
}
} else { } else {
t.put("chargePersonId", null); t.put("chargePersonId", null);
} }
if (!ObjectUtils.isEmpty(t.get("state"))) {
DataDictionary gwmc = dataDictionaryService.getByCode(t.get("state").toString(), "RYZT");
if (!ObjectUtils.isEmpty(gwmc)) {
t.put("stateName", gwmc.getName());
} else {
t.put("stateName", t.get("state"));
}
}
}); });
List<DataDictionary> dictList = dataDictionaryService.getByType("RYZT");
Map<String, String> dictMap = dictList.stream().collect(Collectors.toMap(DataDictionary::getCode, DataDictionary::getName));
Map<String, AgencyUserModel> collect = new HashMap<>();
if (CollectionUtils.isNotEmpty(amosIds)) { if (CollectionUtils.isNotEmpty(amosIds)) {
String join = String.join(",", amosIds); String join = String.join(",", amosIds);
List<AgencyUserModel> amosUser = Privilege.agencyUserClient.queryByIds(join, false).getResult(); List<AgencyUserModel> amosUser = Privilege.agencyUserClient.queryByIds(join, false).getResult();
Map<String, AgencyUserModel> collect = amosUser.stream().collect(Collectors.toMap(AgencyUserModel::getUserId, t -> t)); collect = amosUser.stream().collect(Collectors.toMap(AgencyUserModel::getUserId, t -> t));
list.stream().forEach(t -> {
if (null != t.get("amosOrgId") && StringUtils.isNotEmpty(t.get("amosOrgId").toString()) && collect.containsKey(t.get("amosOrgId").toString())) {
t.put("amosOrgCode", collect.get(t.get("amosOrgId").toString()).getRealName());
}
});
} }
Map<String, AgencyUserModel> finalCollect = collect;
list.forEach(t -> {
if (!ObjectUtils.isEmpty(finalCollect) && null != t.get("amosOrgId") && StringUtils.isNotEmpty(t.get("amosOrgId").toString()) && finalCollect.containsKey(t.get("amosOrgId").toString())) {
t.put("amosOrgCode", finalCollect.get(t.get("amosOrgId").toString()).getRealName());
}
if (!ObjectUtils.isEmpty(t.get("state"))) {
t.put("stateName", dictMap.getOrDefault(t.get("state").toString(), t.get("state").toString()));
}
});
if(!positionType.equals("")) { if(!positionType.equals("")) {
String positionTypeFine = positionType; String positionTypeFine = positionType;
list = list.stream().filter(e-> !ObjectUtils.isEmpty(e.get("positionType")) && String.valueOf(e.get("positionType")).contains(positionTypeFine)).collect(Collectors.toList()); list = list.stream().filter(e-> !ObjectUtils.isEmpty(e.get("positionType")) && String.valueOf(e.get("positionType")).contains(positionTypeFine)).collect(Collectors.toList());
...@@ -721,41 +719,38 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp ...@@ -721,41 +719,38 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
List<Map<String, Object>> list = this.baseMapper.selectPersonList(map); List<Map<String, Object>> list = this.baseMapper.selectPersonList(map);
//处理循环中的远程调用(原有逻辑不变) //处理循环中的远程调用(原有逻辑不变)
List<String> amosIds = new ArrayList<>(); List<String> amosIds = new ArrayList<>();
list.stream().forEach(t -> { list.forEach(t -> {
// BUG2886 因为前期沟通 人员code 可能会发生改变 所以 现在接口code 不再保存,查询数据时通过接口重新赋值 by kongfm // BUG2886 因为前期沟通 人员code 可能会发生改变 所以 现在接口code 不再保存,查询数据时通过接口重新赋值 by kongfm
// 2021-09-16 // 2021-09-16
if (null != t.get("amosOrgId") && StringUtils.isNotEmpty(t.get("amosOrgId").toString())) { if (null != t.get("amosOrgId") && StringUtils.isNotEmpty(t.get("amosOrgId").toString())) {
amosIds.add(t.get("amosOrgId").toString()); amosIds.add(t.get("amosOrgId").toString());
if (!ObjectUtils.isEmpty(t.get("certificateTypeValue")) && "120".equals(t.get("certificateTypeValue").toString())) {
String chargePersonId = iOrgUsrService.getIdNumberByAmosId(t.get("amosOrgId").toString()); t.put("chargePersonId", t.get("certificatesNumber"));
t.put("chargePersonId", chargePersonId); }
} else { } else {
t.put("chargePersonId", null); t.put("chargePersonId", null);
} }
if (!ObjectUtils.isEmpty(t.get("state"))) {
DataDictionary gwmc = dataDictionaryService.getByCode(t.get("state").toString(), "RYZT");
if (!ObjectUtils.isEmpty(gwmc)) {
t.put("stateName", gwmc.getName());
} else {
t.put("stateName", t.get("state"));
}
}
}); });
List<DataDictionary> dictList = dataDictionaryService.getByType("RYZT");
Map<String, String> dictMap = dictList.stream().collect(Collectors.toMap(DataDictionary::getCode, DataDictionary::getName));
Map<String, AgencyUserModel> collect = new HashMap<>();
if (CollectionUtils.isNotEmpty(amosIds)) { if (CollectionUtils.isNotEmpty(amosIds)) {
String join = String.join(",", amosIds); String join = String.join(",", amosIds);
List<AgencyUserModel> amosUser = Privilege.agencyUserClient.queryByIds(join, false).getResult(); List<AgencyUserModel> amosUser = Privilege.agencyUserClient.queryByIds(join, false).getResult();
Map<String, AgencyUserModel> collect = amosUser.stream().collect(Collectors.toMap(AgencyUserModel::getUserId, t -> t)); collect = amosUser.stream().collect(Collectors.toMap(AgencyUserModel::getUserId, t -> t));
list.stream().forEach(t -> { }
if (null != t.get("amosOrgId") && StringUtils.isNotEmpty(t.get("amosOrgId").toString()) && collect.containsKey(t.get("amosOrgId").toString())) { Map<String, AgencyUserModel> finalCollect = collect;
t.put("amosOrgCode", collect.get(t.get("amosOrgId").toString()).getRealName()); list.forEach(t -> {
if (!ObjectUtils.isEmpty(finalCollect) && null != t.get("amosOrgId") && StringUtils.isNotEmpty(t.get("amosOrgId").toString()) && finalCollect.containsKey(t.get("amosOrgId").toString())) {
t.put("amosOrgCode", finalCollect.get(t.get("amosOrgId").toString()).getRealName());
}
if (!ObjectUtils.isEmpty(t.get("state"))) {
t.put("stateName", dictMap.getOrDefault(t.get("state").toString(), t.get("state").toString()));
} }
}); });
}
/* Bug2652 根据名字和工号模糊查询失效 已添加模糊匹配 2021-09-01 陈召 结束 */ /* Bug2652 根据名字和工号模糊查询失效 已添加模糊匹配 2021-09-01 陈召 结束 */
pageBean.setRecords(list); pageBean.setRecords(list);
return pageBean; return pageBean;
} }
......
package com.yeejoin.equipmanage.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @program: api
* @description:
* @author: duanwei
* @create: 2019-12-13 11:16
**/
@Order(Ordered.HIGHEST_PRECEDENCE)
@Configuration
public class CORSFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse;
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Methods", "POST,GET,OPTIONS,PUT,DELETE,PATCH,HEAD");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Headers",
"Origin, X-Requested-With, X-Access-Token, X-Api-Key, Content-Type, Accept, Cache-Control,appkey,token,product");
//response.setHeader("Access-Control-Allow-Headers","*");
if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
response.setStatus(HttpServletResponse.SC_OK);
} else {
filterChain.doFilter(servletRequest, servletResponse);
}
}
@Override
public void destroy() {
}
}
package com.yeejoin.equipmanage.controller; package com.yeejoin.equipmanage.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...@@ -7,11 +8,14 @@ import com.yeejoin.amos.boot.biz.common.bo.ReginParams; ...@@ -7,11 +8,14 @@ import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.dto.OrgMenuDto; import com.yeejoin.amos.boot.biz.common.dto.OrgMenuDto;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.equipmanage.common.dto.CarInfoDto; import com.yeejoin.equipmanage.common.dto.CarInfoDto;
import com.yeejoin.equipmanage.common.dto.CarStatusInfoDto; import com.yeejoin.equipmanage.common.dto.CarStatusInfoDto;
import com.yeejoin.equipmanage.common.entity.*; import com.yeejoin.equipmanage.common.entity.*;
import com.yeejoin.equipmanage.common.entity.dto.CommonFile;
import com.yeejoin.equipmanage.common.entity.publics.CommonResponse; import com.yeejoin.equipmanage.common.entity.publics.CommonResponse;
import com.yeejoin.equipmanage.common.entity.vo.CarIndexVo; import com.yeejoin.equipmanage.common.entity.vo.CarIndexVo;
import com.yeejoin.equipmanage.common.entity.vo.CarMessage;
import com.yeejoin.equipmanage.common.entity.vo.EquipmentOnCarAppVO; import com.yeejoin.equipmanage.common.entity.vo.EquipmentOnCarAppVO;
import com.yeejoin.equipmanage.common.enums.*; import com.yeejoin.equipmanage.common.enums.*;
import com.yeejoin.equipmanage.common.utils.*; import com.yeejoin.equipmanage.common.utils.*;
...@@ -27,6 +31,7 @@ import io.swagger.annotations.ApiParam; ...@@ -27,6 +31,7 @@ import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
...@@ -169,7 +174,23 @@ public class CarController extends AbstractBaseController { ...@@ -169,7 +174,23 @@ public class CarController extends AbstractBaseController {
// Car carInstance = iCarService.saveCar(user, car, carInfo, carpList); // Car carInstance = iCarService.saveCar(user, car, carInfo, carpList);
// saveFile(carInstance); 图片视频后期统一处理 // saveFile(carInstance); 图片视频后期统一处理
//如果默认有id值则认为是更新
if (car.getId() != null) {
Car car1 = this.iCarService.getById(car.getId());
if (car.getOrgCode() != null && !car.getBizOrgCode().equals(car1.getBizOrgCode())) {
FeignClientResult<Map<String, Object>> result = Privilege.companyClient
.queryByOrgcode(car.getBizOrgCode());
System.out.println("==============================" + JSONObject.toJSONString(result.getResult()));
if (result.getResult() != null && result.getResult().containsKey("compnay")) {
Map<String, String> map = (Map<String, String>) result.getResult().get("compnay");
car.setBizOrgName(map.get("companyName"));
}
}
Car car2 = updateCar(car);
CarController controllerProxy = SpringUtils.getBean(CarController.class);
controllerProxy.refreshAllCount();
return car2;
}
// 验证车辆code唯一性 // 验证车辆code唯一性
String iotCode = car.getIotCode(); String iotCode = car.getIotCode();
if(StringUtils.isNotEmpty(iotCode) && StringUtils.isNotEmpty(iotCode.trim())){ if(StringUtils.isNotEmpty(iotCode) && StringUtils.isNotEmpty(iotCode.trim())){
...@@ -183,7 +204,7 @@ public class CarController extends AbstractBaseController { ...@@ -183,7 +204,7 @@ public class CarController extends AbstractBaseController {
} }
car.setQrCode(QRCodeUtil.generateQRCode()); car.setQrCode(QRCodeUtil.generateQRCode());
List<CarProperty> carPropertyList = car.getCarPropertyList(); List<CarProperty> carPropertyList = car.getCarPropertyList();
if (carPropertyList.size() > 0) { if (carPropertyList != null && carPropertyList.size() > 0) {
carPropertyList.forEach(x -> { carPropertyList.forEach(x -> {
QueryWrapper<EquipmentIndex> queryWrapper = new QueryWrapper<>(); QueryWrapper<EquipmentIndex> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id", x.getEquipmentIndexId()); queryWrapper.eq("id", x.getEquipmentIndexId());
...@@ -198,6 +219,18 @@ public class CarController extends AbstractBaseController { ...@@ -198,6 +219,18 @@ public class CarController extends AbstractBaseController {
} }
}); });
} }
if (ObjectUtils.isEmpty(car.getName())) {
Equipment equipment = iEquipmentService.getById(car.getEquipmentId());
car.setName(equipment != null ? equipment.getName() : null);
}
if (ObjectUtils.isEmpty(car.getBizOrgName()) && !ObjectUtils.isEmpty(car.getBizOrgCode())) {
FeignClientResult<Map<String, Object>> result = Privilege.companyClient.queryByOrgcode(car.getBizOrgCode());
System.out.println("==============================" + JSONObject.toJSONString(result.getResult()));
if (result.getResult() != null && result.getResult().containsKey("compnay")) {
Map<String, String> map = (Map<String, String>) result.getResult().get("compnay");
car.setBizOrgName(map.get("companyName"));
}
}
Car car2 = iCarService.saveOne(car); Car car2 = iCarService.saveOne(car);
CarController controllerProxy = SpringUtils.getBean(CarController.class); CarController controllerProxy = SpringUtils.getBean(CarController.class);
controllerProxy.refreshAllCount(); controllerProxy.refreshAllCount();
...@@ -327,6 +360,18 @@ public class CarController extends AbstractBaseController { ...@@ -327,6 +360,18 @@ public class CarController extends AbstractBaseController {
if (!ObjectUtils.isEmpty(car.getTeamId())){ if (!ObjectUtils.isEmpty(car.getTeamId())){
jcsFeign.getUserCar(car.getId(),car.getTeamId()); jcsFeign.getUserCar(car.getId(),car.getTeamId());
} }
if (ObjectUtils.isEmpty(car.getName())) {
Equipment equipment = iEquipmentService.getById(car.getEquipmentId());
car.setName(equipment != null ? equipment.getName() : null);
}
if (ObjectUtils.isEmpty(car.getBizOrgName()) && !ObjectUtils.isEmpty(car.getBizOrgCode())) {
FeignClientResult<Map<String, Object>> result = Privilege.companyClient.queryByOrgcode(car.getBizOrgCode());
System.out.println("==============================" + JSONObject.toJSONString(result.getResult()));
if (result.getResult() != null && result.getResult().containsKey("compnay")) {
Map<String, String> map = (Map<String, String>) result.getResult().get("compnay");
car.setBizOrgName(map.get("companyName"));
}
}
Car car1 = iCarService.updateOneById(car); Car car1 = iCarService.updateOneById(car);
CarController controllerProxy = SpringUtils.getBean(CarController.class); CarController controllerProxy = SpringUtils.getBean(CarController.class);
controllerProxy.refreshAllCount(); controllerProxy.refreshAllCount();
...@@ -378,6 +423,36 @@ public class CarController extends AbstractBaseController { ...@@ -378,6 +423,36 @@ public class CarController extends AbstractBaseController {
} }
/** /**
* 电建项目-车辆信息详情(表单组件格式导致白屏修复)
* @param request
* @param id
* @return
*/
@RequestMapping(value = "getMessage/{id}", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public CarMessage getMessage(HttpServletRequest request, @PathVariable Long id) {
CarMessage carMessage = new CarMessage();
Car car = iCarService.selectOneById(id);
BeanUtils.copyProperties(car, carMessage, "img");
ArrayList<CommonFile> commonFiles = new ArrayList<>();
car.getImg().forEach(item -> {
CommonFile commonFile = new CommonFile();
BeanUtils.copyProperties(item, commonFile);
commonFiles.add(commonFile);
});
ArrayList<CommonFile> certifications = new ArrayList<>();
car.getCertification().forEach(item -> {
CommonFile commonFile = new CommonFile();
BeanUtils.copyProperties(item, commonFile);
certifications.add(commonFile);
});
carMessage.setImg(commonFiles);
carMessage.setCertification(certifications);
return carMessage;
}
/**
* 根据id查询 * 根据id查询
* *
* @param carIds * @param carIds
...@@ -1308,4 +1383,18 @@ public class CarController extends AbstractBaseController { ...@@ -1308,4 +1383,18 @@ public class CarController extends AbstractBaseController {
FeignClientResult<List<OrgMenuDto>> menusList = jcsFeign.getCompanyDeptTreeWithAuth(iotAuthKey, null); FeignClientResult<List<OrgMenuDto>> menusList = jcsFeign.getCompanyDeptTreeWithAuth(iotAuthKey, null);
return ResponseHelper.buildResponse(menusList.getResult()); return ResponseHelper.buildResponse(menusList.getResult());
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/getQRCode", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "获取二维码图片", notes = "获取二维码图片")
public ResponseModel<Object> getQRCode(long id) throws Exception {
return ResponseHelper.buildResponse(iCarService.getQRCode(id));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/location", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "获取二维码图片", notes = "获取二维码图片")
public ResponseModel<Object> location() throws Exception {
return ResponseHelper.buildResponse(iCarService.location());
}
} }
package com.yeejoin.equipmanage.controller;
import lombok.Data;
import java.util.List;
@Data
public class Coordinate {
//经纬度
private List<Double> lnglat;
//车速
private double speed;
//时间
private long time;
// 转角
private double direction;
}
...@@ -31,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -31,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -199,6 +200,29 @@ public class FireFightingSystemController extends AbstractBaseController { ...@@ -199,6 +200,29 @@ public class FireFightingSystemController extends AbstractBaseController {
return result; return result;
} }
/**
* 装备卡片批量删除
*
* @return
*/
@DeleteMapping(value = "/delEquipmentSpecificByIds")
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "DELETE", value = "装备卡片批量删除")
@Transactional
public ResponseModel delEquipmentSpecific(@RequestBody List<Long> specificIds) {
if (CollectionUtils.isEmpty(specificIds)) {
throw new BadRequest("所选装备不能为空");
}
Set<String> bizOrgCodes = new HashSet<>();
specificIds.forEach(specId -> {
EquipmentSpecific equipmentSpecific = equipmentSpecificSerivce.getById(specId);
equipmentSpecificSerivce.delEquipmentSpecificByIdNew(equipmentSpecific);
bizOrgCodes.add(equipmentSpecific.getBizOrgCode());
});
bizOrgCodes.forEach(this::refreshCount);
return CommonResponseUtil.success(Boolean.TRUE);
}
private void refreshCount(String bizOrgCode) { private void refreshCount(String bizOrgCode) {
equipmentSpecificSerivce.refreshStaData(); equipmentSpecificSerivce.refreshStaData();
...@@ -339,6 +363,50 @@ public class FireFightingSystemController extends AbstractBaseController { ...@@ -339,6 +363,50 @@ public class FireFightingSystemController extends AbstractBaseController {
} }
@GetMapping(value = "/getEquipTypeAmountCar")
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "九大类下装备,通过code截取", notes = "九大类下装备信息列表")
public IPage<EquipTypeImgAmountVO> getEquipTypeAmountCarByGet(EquipTypeAmountPageDTO equipTypeAmountPage) {
String[] result = hierarchy.split(",");
Map<Integer, Integer> map = new HashMap<>();
for (int i = 0; i < result.length; i++) {
map.put(i, Integer.valueOf(result[i]));
}
if(equipTypeAmountPage.getCurrent()!=null&&equipTypeAmountPage.getSize()!=null)
{
equipTypeAmountPage.setPage(new Page<>(equipTypeAmountPage.getCurrent(),equipTypeAmountPage.getSize()));
}
if (StringUtil.isNotEmpty(equipTypeAmountPage.getEquipmentClassificationCode())) {
QueryWrapper<EquipmentCategory> equipmentCategoryQueryWrapper = new QueryWrapper<>();
equipmentCategoryQueryWrapper.eq("code", equipTypeAmountPage.getEquipmentClassificationCode());
equipmentCategoryQueryWrapper.eq("industry_code", equipTypeAmountPage.getIndustryCode());
EquipmentCategory equipmentCategory = equipmentCategoryService.getOne(equipmentCategoryQueryWrapper);
if (equipmentCategory == null) {
throw new RuntimeException("装备定义code有误");
}
int inhierarchy = 1;
for (int i = 0; i < result.length + 1; i++) {
//进来先判断是否默认就是空,如果为空第一层
if (equipmentCategory.getParentId() == null) {
//判断是否是最下面的子节点
if (i >= 4) {
inhierarchy = 8;
} else {
inhierarchy = map.get(i);
}
break;
} else {
//查找到循环几次为空
equipmentCategory = equipmentCategoryService.getById(equipmentCategory.getParentId());
}
}
return fireFightingSystemService.getColaCategoryAmountCarList(inhierarchy, equipTypeAmountPage.getEquipmentClassificationCode().substring(0, inhierarchy), equipTypeAmountPage);
} else {
return fireFightingSystemService.getColaCategoryAmountCarList(0, null, equipTypeAmountPage);
}
}
@PostMapping(value = "/iot/getEquipTypeAmount") @PostMapping(value = "/iot/getEquipTypeAmount")
......
package com.yeejoin.equipmanage.controller;
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.equipmanage.common.dto.WlCarMileageDto;
import com.yeejoin.equipmanage.common.entity.WlCarMileage;
import com.yeejoin.equipmanage.common.entity.dto.CarTravelDto;
import com.yeejoin.equipmanage.common.utils.NameUtils;
import com.yeejoin.equipmanage.service.IWlCarMileageService;
import com.yeejoin.equipmanage.utils.BeanUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* 车量里程表
*
* @author duanwei
* @date 2023-02-01
*/
@RestController
@Api(tags = "车量里程表Api")
@RequestMapping(value = "/wl-car-mileage", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class WlCarMileageController {
@Autowired
IWlCarMileageService iWlCarMileageService;
/**
* 新增车量里程表
*
* @return
*/
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增车量里程表", notes = "新增车量里程表")
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
public boolean saveWlCarMileage(HttpServletRequest request, @RequestBody WlCarMileage wlCarMileage) {
return iWlCarMileageService.save(wlCarMileage);
}
/**
* 根据id删除
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
public boolean deleteById(HttpServletRequest request, @PathVariable Long id) {
return iWlCarMileageService.removeById(id);
}
/**
* 修改车量里程表
*
* @return
*/
@RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改车量里程表", notes = "修改车量里程表")
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
public boolean updateByIdWlCarMileage(HttpServletRequest request, @RequestBody WlCarMileage wlCarMileage) {
return iWlCarMileageService.updateById(wlCarMileage);
}
/**
* 根据id查询
*
* @param id
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
public WlCarMileage selectById(HttpServletRequest request, @PathVariable Long id) {
return iWlCarMileageService.getById(id);
}
/**
* 列表分页查询
*
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
public IPage<WlCarMileage> listPage(String pageNum, String pageSize, WlCarMileage wlCarMileage) {
Page<WlCarMileage> pageBean;
QueryWrapper<WlCarMileage> wlCarMileageQueryWrapper = new QueryWrapper<>();
Class<? extends WlCarMileage> aClass = wlCarMileage.getClass();
Arrays.stream(aClass.getDeclaredFields()).forEach(field -> {
try {
field.setAccessible(true);
Object o = field.get(wlCarMileage);
if (o != null) {
Class<?> type = field.getType();
String name = NameUtils.camel2Underline(field.getName());
if (type.equals(Integer.class)) {
Integer fileValue = (Integer) field.get(wlCarMileage);
wlCarMileageQueryWrapper.eq(name, fileValue);
} else if (type.equals(Long.class)) {
Long fileValue = (Long) field.get(wlCarMileage);
wlCarMileageQueryWrapper.eq(name, fileValue);
} else if (type.equals(String.class)) {
String fileValue = (String) field.get(wlCarMileage);
wlCarMileageQueryWrapper.eq(name, fileValue);
} else if (type.equals(Date.class)) {
Date fileValue = (Date) field.get(wlCarMileage);
wlCarMileageQueryWrapper.eq(name, fileValue);
} else {
String fileValue = (String) field.get(wlCarMileage);
wlCarMileageQueryWrapper.eq(name, fileValue);
}
}
} catch (Exception e) {
}
});
IPage<WlCarMileage> page;
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
} else {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
page = iWlCarMileageService.page(pageBean, wlCarMileageQueryWrapper);
return page;
}
/**
* 列表分页查询
*
* @return
*/
@RequestMapping(value = "/page", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
public CarTravelDto page(Integer pageNum, Integer pageSize, WlCarMileage wlCarMileage) {
Page<WlCarMileage> pageBean;
if (pageNum == null || pageSize == null) {
pageBean = new Page<>(0, Long.MAX_VALUE);
} else {
pageBean = new Page<>(pageNum, pageSize);
}
//只查询已完成的轨迹
wlCarMileage.setComplete(true);
Page<WlCarMileage> page = iWlCarMileageService.page(pageBean, wlCarMileage);
SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
CarTravelDto carTravelDto = new CarTravelDto();
carTravelDto.setTotal(page.getTotal());
long totalTime = 0;
int totalTravel = 0;
List<WlCarMileageDto> list = new ArrayList<WlCarMileageDto>();
for (WlCarMileage wl : page.getRecords()) {
WlCarMileageDto wlCarMileageDto = new WlCarMileageDto();
wl.setTime(millisToStringShort(wl.getTakeTime()));
totalTravel += wl.getTravel();
totalTime += wl.getTakeTime();
BeanUtil.copyPropertiesIgnoreNull(wl, wlCarMileageDto);
wlCarMileageDto.setStartTime(sdf.format(wl.getStartTime()));
wlCarMileageDto.setEndTime(sdf.format(wl.getEndTime()));
list.add(wlCarMileageDto);
}
carTravelDto.setRecords(list);
// // 初始化format格式
// SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
// // 设置时区,跳过此步骤会默认设置为"GMT+08:00" 得到的结果会多出来8个小时
// dateFormat.setTimeZone(TimeZone.getTimeZone("GMT+00:00"));
//
// String timeStr = dateFormat.format(totalTime);
carTravelDto.setTotalTime(millisToStringShort(totalTime));
carTravelDto.setTotalTravel(totalTravel);
return carTravelDto;
}
public String millisToStringShort(long millis) {
StringBuffer strBuilder = new StringBuffer();
long temp = millis;
long hper = 60 * 60 * 1000;
long mper = 60 * 1000;
long sper = 1000;
if (temp / hper > 0) {
if ((temp / hper) < 10) {
strBuilder.append(0);
}
strBuilder.append(temp / hper).append(":");
} else {
strBuilder.append("00").append(":");
}
temp = temp % hper;
if (temp / mper > 0) {
if ((temp / mper) < 10) {
strBuilder.append(0);
}
strBuilder.append(temp / mper).append(":");
} else {
strBuilder.append("00").append(":");
}
temp = temp % mper;
if (temp / sper > 0) {
if ((temp / sper) < 10) {
strBuilder.append(0);
}
strBuilder.append(temp / sper);
} else {
strBuilder.append("00");
}
return strBuilder.toString();
}
/**
* 获取轨迹
*
* @return
*/
@RequestMapping(value = "/travel", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "获取轨迹", notes = "获取轨迹")
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
public List<Coordinate> travel(long id) {
return iWlCarMileageService.getCoordinateList(id);
}
/**
* 获取日历
*
* @return
*/
@RequestMapping(value = "/calendar", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "获取日历", notes = "获取日历")
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
public Map<String, Boolean> calendar(@RequestParam("id") long id,
@DateTimeFormat(pattern = "yyyy-MM") @RequestParam("date") Date date) {
return iWlCarMileageService.getCalender(id, date);
}
}
...@@ -2,9 +2,12 @@ package com.yeejoin.equipmanage.fegin; ...@@ -2,9 +2,12 @@ package com.yeejoin.equipmanage.fegin;
import com.yeejoin.equipmanage.common.entity.dto.IndexLogsRequest; import com.yeejoin.equipmanage.common.entity.dto.IndexLogsRequest;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.Date;
import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -71,4 +74,10 @@ public interface IotFeign { ...@@ -71,4 +74,10 @@ public interface IotFeign {
@RequestMapping(value = "v1/livedata/index/logs", method = RequestMethod.POST, consumes = "application/json") @RequestMapping(value = "v1/livedata/index/logs", method = RequestMethod.POST, consumes = "application/json")
ResponseModel<Map<String ,Object>> getEquipAlarmLog(@RequestBody IndexLogsRequest indexLogsRequest ); ResponseModel<Map<String ,Object>> getEquipAlarmLog(@RequestBody IndexLogsRequest indexLogsRequest );
@GetMapping("/v1/livedata/common/list")
ResponseModel<List<Object>> getLiveData(@RequestParam("measurement") String measurement,
@RequestParam("deviceName") String deviceName,
@RequestParam("timeStart") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date timeStart,
@RequestParam("timeEnd") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")Date timeEnd);
} }
package com.yeejoin.equipmanage.listener;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.equipmanage.common.entity.Car;
import com.yeejoin.equipmanage.common.entity.WlCarMileage;
import com.yeejoin.equipmanage.common.utils.CoordinateUtil;
import com.yeejoin.equipmanage.fegin.IotFeign;
import com.yeejoin.equipmanage.service.ICarService;
import com.yeejoin.equipmanage.service.IWlCarMileageService;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.component.emq.EmqxListener;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@Component
public class CarIotListener extends EmqxListener {
@Autowired
private IWlCarMileageService iWlCarMileageService;
@Autowired
private ICarService iCarService;
@Autowired
private IotFeign iotFeign;
private final String GUIDE_KEY = "813684495d9a3981dd2c7694916fe404";
private final String GUIDE_URL = "https://restapi.amap.com/v3/geocode/regeo?";
@Autowired
private EmqKeeper emqkeeper;
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Override
public void processMessage(String topic, MqttMessage message) throws Exception {
JSONObject jsonObject = JSONObject.parseObject(message.toString());
if (jsonObject.containsKey("startUp") || jsonObject.containsKey("FireCar_Longitude")) {
System.out.println(topic);
System.out.println(message);
String measurement = topic.split("/")[0];
String deviceName = topic.split("/")[1];
String iotCode = measurement + deviceName;
if (jsonObject.containsKey("startUp")) {
if (jsonObject.getBooleanValue("startUp")) {
WlCarMileage wlCarMileage = new WlCarMileage();
wlCarMileage.setIotCode(iotCode);
wlCarMileage.setDate(new Date());
// 获取开始坐标
double startLongitude = jsonObject.getDoubleValue("FireCar_Longitude");
double startLatitude = jsonObject.getDoubleValue("FireCar_Latitude");
// String currentTime = "20"+jsonObject.getString("currentTime");
wlCarMileage.setStartLongitude(startLongitude);
wlCarMileage.setStartLatitude(startLatitude);
// Date startTime = UTCToCST();
Date startTime = new Date(jsonObject.getLong("time"));
wlCarMileage.setStartTime(startTime);
wlCarMileage.setStartName(getAddress(startLongitude, startLatitude));
wlCarMileage.setStartSpeed(jsonObject.getIntValue("FireCar_Speed"));
try {
iWlCarMileageService.save(wlCarMileage);
} catch (Exception e) {
e.printStackTrace();
iWlCarMileageService.save(wlCarMileage);
}
} else {
// 获取结束坐标
WlCarMileage last = iWlCarMileageService
.getOne(new LambdaQueryWrapper<WlCarMileage>().eq(WlCarMileage::getIotCode, iotCode)
.isNull(WlCarMileage::getEndLongitude).isNull(WlCarMileage::getEndLatitude)
.orderByDesc(WlCarMileage::getStartTime).last("limit 1"));
ResponseModel<List<Object>> result = iotFeign.getLiveData(measurement, deviceName,
last.getStartTime(), new Date(new Date().getTime() + 2000));
List<Object> list = result.getResult();
if (list != null && list.size() > 0) {
// 获取最后一个有坐标的数据
JSONObject lastObj = null;
// 过滤空坐标
List<Object> filterList = new ArrayList<Object>();
for (int i = 0; i < list.size(); i++) {
JSONObject Obj = JSONObject.parseObject(JSONObject.toJSONString(list.get(i)));
if (Obj.get("FireCar_Longitude") != null && Obj.get("FireCar_Latitude") != null
&& Obj.getDoubleValue("FireCar_Longitude") != 0
&& Obj.getDoubleValue("FireCar_Latitude") != 0) {
filterList.add(list.get(i));
// 获取第一个不为空的坐标
if (lastObj == null) {
lastObj = Obj;
}
}
}
// JSONObject lastObj =
// JSONObject.parseObject(JSONObject.toJSONString(list.get(list.size() - 1)));
if (lastObj == null) {
lastObj = new JSONObject();
lastObj.put("FireCar_Longitude", 0.0);
lastObj.put("FireCar_Latitude", 0.0);
lastObj.put("time", 0);
lastObj.put("FireCar_Speed", 0);
}
double endLongitude = lastObj.getDoubleValue("FireCar_Longitude");
double endLatitude = lastObj.getDoubleValue("FireCar_Latitude");
// 230215180624
// Date endTime =UTCToCST(lastObj.getString("time"));
Date endTime = new Date(jsonObject.getLong("time"));
long takeTime = (endTime.getTime()/1000*1000) - (last.getStartTime().getTime()/1000*1000) ;
last.setEndLongitude(endLongitude);
last.setEndLatitude(endLatitude);
last.setEndTime(endTime);
last.setEndName(getAddress(endLongitude, endLatitude));
last.setEndSpeed(lastObj.getIntValue("FireCar_Speed"));
last.setTakeTime(takeTime);
double travel = 0.0;
// 获取里程
for (int i = 0; i < filterList.size() - 1; i++) {
JSONObject start = JSONObject.parseObject(JSONObject.toJSONString(filterList.get(i)));
JSONObject end = JSONObject.parseObject(JSONObject.toJSONString(filterList.get(i + 1)));
travel += CoordinateUtil.distance(start.getDoubleValue("FireCar_Latitude"),
start.getDoubleValue("FireCar_Longitude"), end.getDoubleValue("FireCar_Latitude"),
end.getDoubleValue("FireCar_Longitude"));
}
last.setTravel(new BigDecimal(travel/1000).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
try {
iWlCarMileageService.updateById(last);
} catch (Exception e) {
iWlCarMileageService.updateById(last);
}
}
}
} else if (jsonObject.containsKey("FireCar_Longitude")) {
if (jsonObject.containsKey("FireCar_Longitude") && jsonObject.containsKey("FireCar_Latitude")) {
// 获取开始坐标
double startLongitude = jsonObject.getDoubleValue("FireCar_Longitude");
double startLatitude = jsonObject.getDoubleValue("FireCar_Latitude");
int direction = jsonObject.getIntValue("direction");
// 地图推送消息
Car car = iCarService.getOne(new LambdaQueryWrapper<Car>().eq(Car::getIotCode, iotCode));
if (car != null && startLongitude != 0 && startLatitude != 0) {
JSONArray sendArr = new JSONArray();
JSONObject sendObj = new JSONObject();
sendObj.put("id", String.valueOf(car.getId()));
sendObj.put("direction", direction);
sendObj.put("longitude", String.valueOf(startLongitude));
sendObj.put("latitude", String.valueOf(startLatitude));
sendObj.put("carNum", car.getCarNum());
sendObj.put("bizOrgName", car.getBizOrgName());
sendArr.add(sendObj);
MqttMessage mqttMessage = new MqttMessage();
mqttMessage.setPayload(sendArr.toJSONString().getBytes());
car.setLongitude(startLongitude);
car.setLatitude(startLatitude);
iCarService.updateById(car);
emqkeeper.getMqttClient().publish("car/location", mqttMessage);
}
}
}
}
}
public String getAddress(double longitude, double lantitude) {
StringBuilder api = new StringBuilder(GUIDE_URL);
api.append("key=").append(GUIDE_KEY).append("&location=").append(longitude).append(",").append(lantitude)
.append("&radius=1000").append("&batch=false").append("&extensions=base").append("&roadlevel=0")
.append("&batch=false");
StringBuilder res = new StringBuilder();
BufferedReader in = null;
try {
System.out.println(api.toString());
URL url = new URL(api.toString());
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
String line;
while ((line = in.readLine()) != null) {
res.append(line).append("\n");
}
JSONObject object = JSONObject.parseObject(res.toString());
System.out.println(object);
JSONObject regeocode = object.getJSONObject("regeocode");
String address = regeocode.getString("formatted_address");
if ("[]".equals(address)) {
System.out.println("===============无效坐标:" + longitude + "," + lantitude);
address = "无效坐标";
}
res = new StringBuilder(address);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return res.toString();
}
public Date UTCToCST(String UTCStr) throws ParseException {
Date date = sdf.parse(UTCStr);
System.out.println("UTC时间: " + date);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.HOUR, calendar.get(Calendar.HOUR) + 8);
return calendar.getTime();
}
}
package com.yeejoin.equipmanage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.equipmanage.common.entity.WlCarMileage;
import org.apache.ibatis.annotations.Param;
/**
* 车量里程表 Mapper 接口
*
* @author duanwei
* @date 2023-02-01
*/
public interface WlCarMileageMapper extends BaseMapper<WlCarMileage> {
Page<WlCarMileage> page(Page<WlCarMileage> page,@Param("wlCarMileage") WlCarMileage wlCarMileage);
Integer totalMileage(String iotCode);
}
...@@ -185,4 +185,8 @@ public interface ICarService extends IService<Car> { ...@@ -185,4 +185,8 @@ public interface ICarService extends IService<Car> {
* iot装备更新redis 统计数据 * iot装备更新redis 统计数据
*/ */
void iotrefreshStaData(); void iotrefreshStaData();
IPage getQRCode(Long id);
List<Car> location();
} }
...@@ -75,6 +75,12 @@ public interface IEquipmentSpecificSerivce extends IService<EquipmentSpecific> { ...@@ -75,6 +75,12 @@ public interface IEquipmentSpecificSerivce extends IService<EquipmentSpecific> {
Boolean delEquipmentSpecific(Long id); Boolean delEquipmentSpecific(Long id);
/** /**
* 批量清除调用
* @param equipmentSpecific 装备信息
*/
Boolean delEquipmentSpecificByIdNew(EquipmentSpecific equipmentSpecific);
/**
* 组装组态使用的卡片数据 * 组装组态使用的卡片数据
* *
* @param id * @param id
......
package com.yeejoin.equipmanage.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yeejoin.equipmanage.common.entity.WlCarMileage;
import com.yeejoin.equipmanage.controller.Coordinate;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 车量里程表 服务类
*
* @author duanwei
* @date 2023-02-01
*/
public interface IWlCarMileageService extends IService<WlCarMileage> {
Page<WlCarMileage> page(Page<WlCarMileage> page, WlCarMileage wlCarMileage);
Integer totalMileage(String iotCode);
List<Coordinate> getCoordinateList(long id);
Map<String,Boolean> getCalender(long id,Date date);
}
...@@ -17,6 +17,7 @@ import com.yeejoin.amos.component.feign.config.InnerInvokException; ...@@ -17,6 +17,7 @@ import com.yeejoin.amos.component.feign.config.InnerInvokException;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege; import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.equipmanage.common.datasync.entity.FireVehicle; import com.yeejoin.equipmanage.common.datasync.entity.FireVehicle;
import com.yeejoin.equipmanage.common.dto.CarFusionDto; import com.yeejoin.equipmanage.common.dto.CarFusionDto;
import com.yeejoin.equipmanage.common.dto.CarInfoDto; import com.yeejoin.equipmanage.common.dto.CarInfoDto;
...@@ -35,6 +36,7 @@ import com.yeejoin.equipmanage.mapper.*; ...@@ -35,6 +36,7 @@ import com.yeejoin.equipmanage.mapper.*;
import com.yeejoin.equipmanage.remote.RemoteSecurityService; import com.yeejoin.equipmanage.remote.RemoteSecurityService;
import com.yeejoin.equipmanage.service.*; import com.yeejoin.equipmanage.service.*;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.http.entity.ContentType;
import org.gavaghan.geodesy.Ellipsoid; import org.gavaghan.geodesy.Ellipsoid;
import org.gavaghan.geodesy.GeodeticCalculator; import org.gavaghan.geodesy.GeodeticCalculator;
import org.gavaghan.geodesy.GlobalCoordinates; import org.gavaghan.geodesy.GlobalCoordinates;
...@@ -42,17 +44,22 @@ import org.springframework.beans.BeanUtils; ...@@ -42,17 +44,22 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.function.Consumer; import java.util.function.Consumer;
...@@ -149,6 +156,9 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS ...@@ -149,6 +156,9 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
@Value("${systemctl.sync.switch}") @Value("${systemctl.sync.switch}")
private Boolean syncSwitch; private Boolean syncSwitch;
@Autowired
private IWlCarMileageService iWlCarMileageService;
/** /**
* 当前登录用户信息 * 当前登录用户信息
*/ */
...@@ -1326,13 +1336,38 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS ...@@ -1326,13 +1336,38 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
equipment.setEquipmentCategory(equipmentCategoryMapper.selectById(equipment.getCategoryId())); equipment.setEquipmentCategory(equipmentCategoryMapper.selectById(equipment.getCategoryId()));
} }
car.setEquipment(equipment); car.setEquipment(equipment);
car.setCountryName(iSystemDicService.getOne(new QueryWrapper<SystemDic>().eq("id", car.getCountry())).getName()); if( car.getCountry()!=null) {
car.setChassisCountryName( car.setCountryName(
iSystemDicService.getOne(new QueryWrapper<SystemDic>().eq("id", car.getChassisCountry())).getName()); iSystemDicService.getOne(new QueryWrapper<SystemDic>().eq("id", car.getCountry())).getName());
car.setJournals(journalService.list(new QueryWrapper<Journal>().eq("car_id", car.getId()).orderByAsc("create_date"))); }
if (!ObjectUtils.isEmpty(car.getChassisCountry())) {
car.setChassisCountryName(iSystemDicService
.getOne(new QueryWrapper<SystemDic>().eq("id", car.getChassisCountry())).getName());
}
car.setJournals(
journalService.list(new QueryWrapper<Journal>().eq("car_id", car.getId()).orderByAsc("create_date")));
car.setEquipmentsOnCar(this.baseMapper.selectEquipmentOnCarAppList(car.getId())); car.setEquipmentsOnCar(this.baseMapper.selectEquipmentOnCarAppList(car.getId()));
List<Equipment> equipment1 = iEquipmentService.listByCategoryId(equipment.getCategoryId()); List<Equipment> equipment1 = iEquipmentService.listByCategoryId(equipment.getCategoryId());
car.setUnit(equipment1.get(0).getUnit()); car.setUnit(equipment1.get(0).getUnit());
car.setCategoryId(equipment.getCategoryId());
if(car.getIsImport()!=null)
{
car.setImportStr(car.getIsImport() ? "进口" : "国产");
}
if (!ObjectUtils.isEmpty(car.getIotCode())) {
Integer totalTravel = iWlCarMileageService.totalMileage(car.getIotCode());
car.setTotalTravel(totalTravel);
WlCarMileage last = iWlCarMileageService
.getOne(new LambdaQueryWrapper<WlCarMileage>().eq(WlCarMileage::getIotCode, car.getIotCode())
.orderByDesc(WlCarMileage::getEndTime).last("limit 1"));
car.setSpeed(last != null ? last.getEndSpeed() : null);
//产品 和 设备 各8位
if(car.getIotCode().length()>=16)
{
car.setIotMeasurement(car.getIotCode().substring(0, 8));
car.setIotDeviceName(car.getIotCode().substring(8, car.getIotCode().length()));
}
}
return car; return car;
} }
...@@ -1638,4 +1673,44 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS ...@@ -1638,4 +1673,44 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
private String iotbuildKey(Map<String, Object> row) { private String iotbuildKey(Map<String, Object> row) {
return SourcesStatisticsImpl.PREFIX_CATEGORY_COUNT + row.get("bizOrgCode").toString() + "_" + SourceTypeEnum.IOT.getCode() + "_" + row.get("categoryCode").toString(); return SourcesStatisticsImpl.PREFIX_CATEGORY_COUNT + row.get("bizOrgCode").toString() + "_" + SourceTypeEnum.IOT.getCode() + "_" + row.get("categoryCode").toString();
} }
@Override
public IPage getQRCode(Long id) {
Car car = this.getById(id);
if (car == null) {
return null;
}
String url = "";
JSONObject jsonObject = new JSONObject();
byte[] bytes = QRCodeUtil.generateQRCodeImageByteData(car.getQrCode(),200);
InputStream inputStream = new ByteArrayInputStream(bytes);
try {
MultipartFile file = new MockMultipartFile(car.getQrCode() + ".jpg", car.getQrCode() + ".jpg",
ContentType.APPLICATION_OCTET_STREAM.toString(), inputStream);
FeignClientResult<Map<String, String>> date = Systemctl.fileStorageClient.updateCommonFileFree(file,
"jxiop/qrcode");
if (date != null) {
Map<String, String> map = date.getResult();
Iterator<String> it = map.keySet().iterator();
String urlString = it.next();
jsonObject.put("fileUrl", urlString);
jsonObject.put("fileName", car.getQrCode());
}
} catch (IOException e) {
e.printStackTrace();
}
List list = new ArrayList();
list.add(jsonObject);
IPage page = new Page(1, 100);
page.setRecords(list);
return page;
}
@Override
public List<Car> location() {
List<Car> list = this.list();
return list;
}
} }
...@@ -49,6 +49,7 @@ import org.springframework.util.CollectionUtils; ...@@ -49,6 +49,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.DateTimeUtil; import org.typroject.tyboot.core.foundation.utils.DateTimeUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.IOException; import java.io.IOException;
...@@ -1010,6 +1011,52 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM ...@@ -1010,6 +1011,52 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
} }
} }
@Override
public Boolean delEquipmentSpecificByIdNew(EquipmentSpecific equipmentSpecific) {
Long id = equipmentSpecific.getId();
QueryWrapper<StockDetail> stockDetailQueryWrapper = new QueryWrapper<>();
stockDetailQueryWrapper.eq("equipment_specific_id", equipmentSpecific.getId());
if (stockDetailService.count(stockDetailQueryWrapper) > 0) {
throw new BadRequest("所选设备中存在已入库设备,无法删除,请重新选择,装备名称:" + equipmentSpecific.getName());
}
String code = this.getSystemCodeBySpeId(equipmentSpecific.getSystemId());
int res = this.baseMapper.deleteById(id);
if (StringUtil.isNotEmpty(code)) {
this.integrationPageSysDataRefresh(code);
}
if (res > 0 && Boolean.TRUE.equals(syncSwitch)) {
//数据同步
delEquipmentSpecificSyncData(id);
}
//判断装备表剩余数量,无剩余删除模板
QueryWrapper<EquipmentSpecific> wrapper = new QueryWrapper<>();
wrapper.eq("equipment_detail_id", equipmentSpecific.getEquipmentDetailId());
List<String> sys = this.baseMapper.selectSystemList(id);
List<String> build = this.baseMapper.selectBuildList(id);
String sysErrorMeg = "";
String buildErrorMeg = "";
if (!CollectionUtils.isEmpty(sys) || !CollectionUtils.isEmpty(build)) {
for (String s : sys) {
sysErrorMeg = sysErrorMeg.equals("") ? s : sysErrorMeg + "," + s;
}
for (String s : build) {
buildErrorMeg = buildErrorMeg.equals("") ? s : buildErrorMeg + "," + s;
}
sysErrorMeg = sysErrorMeg.equals("") ? sysErrorMeg : "系统:" + sysErrorMeg + ",";
buildErrorMeg = buildErrorMeg.equals("") ? buildErrorMeg : "建筑:" + buildErrorMeg + ",";
throw new BadRequest("所选设备中有与" + sysErrorMeg + buildErrorMeg + "存在绑定关系,无法删除,装备名称:" + equipmentSpecific.getName());
}
if (this.baseMapper.selectCount(wrapper) == 0) {
equipmentDetailService.removeById(equipmentSpecific.getEquipmentDetailId());
}
if (res > 0) {
// 删除设备动态表单扩展属性
return formInstanceEquipService.deleteInstanceById(id);
} else {
return false;
}
}
private String getSystemCodeBySpeId(String sysIds) { private String getSystemCodeBySpeId(String sysIds) {
if (StringUtil.isNotEmpty(sysIds)) { if (StringUtil.isNotEmpty(sysIds)) {
List<FireFightingSystemEntity> sys = fireFightingSystemMapper.getFightingSysByIds(sysIds.split(",")); List<FireFightingSystemEntity> sys = fireFightingSystemMapper.getFightingSysByIds(sysIds.split(","));
......
...@@ -27,11 +27,9 @@ import com.yeejoin.equipmanage.common.entity.*; ...@@ -27,11 +27,9 @@ import com.yeejoin.equipmanage.common.entity.*;
import com.yeejoin.equipmanage.common.entity.dto.EquipTypeAmountPageDTO; import com.yeejoin.equipmanage.common.entity.dto.EquipTypeAmountPageDTO;
import com.yeejoin.equipmanage.common.entity.vo.*; import com.yeejoin.equipmanage.common.entity.vo.*;
import com.yeejoin.equipmanage.common.enums.*; import com.yeejoin.equipmanage.common.enums.*;
import com.yeejoin.equipmanage.common.utils.ChartsUtils; import com.yeejoin.equipmanage.common.utils.*;
import com.yeejoin.equipmanage.common.utils.DateUtils;
import com.yeejoin.equipmanage.common.utils.StringUtil;
import com.yeejoin.equipmanage.common.utils.WordTemplateUtils;
import com.yeejoin.equipmanage.common.vo.*; import com.yeejoin.equipmanage.common.vo.*;
import com.yeejoin.equipmanage.controller.EquipmentDetailController;
import com.yeejoin.equipmanage.fegin.JcsFeign; import com.yeejoin.equipmanage.fegin.JcsFeign;
import com.yeejoin.equipmanage.mapper.*; import com.yeejoin.equipmanage.mapper.*;
import com.yeejoin.equipmanage.remote.RemoteSecurityService; import com.yeejoin.equipmanage.remote.RemoteSecurityService;
...@@ -162,6 +160,9 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste ...@@ -162,6 +160,9 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
@Value("${redis_equip_type_count}") @Value("${redis_equip_type_count}")
private String equipTypeAndCount; private String equipTypeAndCount;
@Autowired
IWlCarMileageService iWlCarMileageService;
@Override @Override
public List<EquipCountBySystemVO> getEquipCountBySystemId(Long systemId) { public List<EquipCountBySystemVO> getEquipCountBySystemId(Long systemId) {
return this.baseMapper.getEquipCountBySystemId(systemId); return this.baseMapper.getEquipCountBySystemId(systemId);
...@@ -912,6 +913,7 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste ...@@ -912,6 +913,7 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
if (!x.getEqtype().startsWith("4") && StringUtil.isNotEmpty(x.getAmount())) { if (!x.getEqtype().startsWith("4") && StringUtil.isNotEmpty(x.getAmount())) {
x.setAmount(x.getAmount().split("\\.")[0]); x.setAmount(x.getAmount().split("\\.")[0]);
} }
x.setType(null);
}); });
return list; return list;
} }
...@@ -1218,12 +1220,17 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste ...@@ -1218,12 +1220,17 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
@Override @Override
public Object getEquipmentTypeAndCount(String bizOrgCode) { public Object getEquipmentTypeAndCount(String bizOrgCode) {
// if (redisUtils.hasKey(equipTypeAndCount + bizOrgCode)) { if (redisUtils.hasKey(equipTypeAndCount + bizOrgCode)) {
// return JSONArray.parseArray( return refreshEquipmentTypeAndCount(bizOrgCode);
// JSONArray.toJSONString(redisUtils.get(equipTypeAndCount + bizOrgCode)), EquipmentCategory.class); } else {
// } else { if (redisUtils.hasKey(equipTypeAndCount + bizOrgCode)) {
return refreshEquipmentTypeAndCount(bizOrgCode);
}
syncDataService.saveOrUpdateEquipIotCodeRedisData(null);
EquipmentDetailController controllerProxy = SpringUtils.getBean(EquipmentDetailController.class);
controllerProxy.refreshCount(bizOrgCode);
}
return refreshEquipmentTypeAndCount(bizOrgCode); return refreshEquipmentTypeAndCount(bizOrgCode);
// }
} }
@Override @Override
......
package com.yeejoin.equipmanage.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yeejoin.equipmanage.common.entity.Car;
import com.yeejoin.equipmanage.common.entity.WlCarMileage;
import com.yeejoin.equipmanage.common.utils.HttpUtil;
import com.yeejoin.equipmanage.controller.Coordinate;
import com.yeejoin.equipmanage.fegin.IotFeign;
import com.yeejoin.equipmanage.mapper.WlCarMileageMapper;
import com.yeejoin.equipmanage.service.ICarService;
import com.yeejoin.equipmanage.service.IWlCarMileageService;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* 车量里程表 服务实现类
*
* @author duanwei
* @date 2023-02-01
*/
@Service
public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlCarMileage>
implements IWlCarMileageService {
@Autowired
IotFeign iotFeign;
@Autowired
ICarService iCarService;
private final String GUIDE_KEY = "813684495d9a3981dd2c7694916fe404";
private final String GUIDE_URL = "https://restapi.amap.com/v4/grasproad/driving?";
@Override
public Page<WlCarMileage> page(Page<WlCarMileage> page, WlCarMileage wlCarMileage) {
return this.baseMapper.page(page, wlCarMileage);
}
@Override
public Integer totalMileage(String iotCode) {
return this.baseMapper.totalMileage(iotCode);
}
@Override
public List<Coordinate> getCoordinateList(long id) {
double speed = 0;
WlCarMileage wlCarMileage = this.getById(id);
String iotCode = wlCarMileage.getIotCode();
String measurement = "0THMcLKR";
String deviceName = iotCode.replace(measurement, "");
// 由于iot存在毫秒故结束时间要+1秒 iot+1秒有bug还是查不到 +2秒
ResponseModel<List<Object>> result = iotFeign.getLiveData(measurement, deviceName, wlCarMileage.getStartTime(),
new Date(wlCarMileage.getEndTime().getTime()));
List<Object> list = result.getResult();
List<Coordinate> coordinateList = new ArrayList<Coordinate>();
if (list != null) {
DateFormat format1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
DateFormat format2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
for (Object object : list) {
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(object));
if (jsonObject.get("FireCar_Longitude") != null && jsonObject.get("FireCar_Latitude") != null) {
Coordinate coordinate = new Coordinate();
List<Double> lnglat = new ArrayList<Double>();
lnglat.add(jsonObject.getDoubleValue("FireCar_Longitude"));
lnglat.add(jsonObject.getDoubleValue("FireCar_Latitude"));
coordinate.setLnglat(lnglat);
coordinate.setSpeed(jsonObject.getDoubleValue("FireCar_Speed"));
speed = speed + jsonObject.getDoubleValue("FireCar_Speed");
String time = jsonObject.getString("time");
if (time.length() > 20) {
try {
coordinate.setTime(format1.parse(jsonObject.getString("time")).getTime());
} catch (ParseException e) {
e.printStackTrace();
}
} else {
try {
coordinate.setTime(format2.parse(jsonObject.getString("time")).getTime());
} catch (ParseException e) {
e.printStackTrace();
}
}
double direction = jsonObject.getDoubleValue("direction");
if (!ObjectUtils.isEmpty(direction)){
coordinate.setDirection(jsonObject.getDoubleValue("direction"));
}else {
coordinate.setDirection(0);
}
coordinateList.add(coordinate);
}
}
}
// 倒序坐标变为正序
Collections.reverse(coordinateList);
// 坐标轨迹纠偏
double avgSpeed = speed / coordinateList.size();
double count = Double.valueOf(coordinateList.size()) / 500;
int ceil = (int) Math.ceil(count);
ArrayList<Coordinate> resultList = new ArrayList<>();
for (int i = 1; i <= ceil; i++) {
if (i == ceil) {
List<Coordinate> coordinates = coordinateList.subList(500 * (i - 1), coordinateList.size());
List<Coordinate> check = check(coordinates, avgSpeed);
resultList.addAll(check);
} else {
List<Coordinate> coordinates = coordinateList.subList(500 * (i - 1), 500 + (i - 1) * 500);
List<Coordinate> check = check(coordinates, avgSpeed);
resultList.addAll(check);
}
}
return resultList;
}
private List<Coordinate> check(List<Coordinate> list, double avgSpeed) {
ArrayList<Coordinate> coordinates = new ArrayList<>();
JSONArray objects = new JSONArray();
int count = 0;
for (Coordinate coordinate : list) {
JSONObject jsonObject = new JSONObject();
// 经度
jsonObject.put("x", coordinate.getLnglat().get(0));
// 纬度
jsonObject.put("y", coordinate.getLnglat().get(1));
// 角度
jsonObject.put("ag", coordinate.getDirection());
// 速度
jsonObject.put("sp", coordinate.getSpeed());
// 时间
if (count == 0) {
jsonObject.put("tm", coordinate.getTime() / 1000);
} else {
jsonObject.put("tm", 3 * count);
}
count += 1;
objects.add(jsonObject);
}
String s = objects.toJSONString();
StringBuilder api = new StringBuilder(GUIDE_URL);
api.append("key=").append(GUIDE_KEY);
String result = null;
try {
result = HttpUtil.post(api.toString(), s);
} catch (IOException | NoSuchAlgorithmException | KeyStoreException | KeyManagementException e) {
e.printStackTrace();
}
if (result != null) {
Map<String, Object> jsonObject = (Map<String, Object>) JSONObject.parseObject(result);
if (jsonObject.containsKey("data")) {
JSONObject data3 = JSONObject.parseObject(jsonObject.get("data").toString());
JSONArray points1 = JSONArray.parseArray(data3.get("points").toString());
points1.forEach(item -> {
JSONObject jsonObject1 = JSONObject.parseObject(item.toString());
List<Double> doubles = new ArrayList<>();
Coordinate coordinate = new Coordinate();
doubles.add(Double.valueOf(jsonObject1.get("x").toString()));
doubles.add(Double.valueOf(jsonObject1.get("y").toString()));
coordinate.setLnglat(doubles);
coordinate.setSpeed(avgSpeed);
coordinates.add(coordinate);
});
}
}
return coordinates;
}
@Override
public Map<String, Boolean> getCalender(long id, Date date) {
List<String> daylist = new ArrayList<String>();
Map<String, Boolean> map = new HashMap<>();
Car car = iCarService.getById(id);
if (car == null || car.getIotCode() == null || date == null) {
return map;
}
Calendar c = Calendar.getInstance();
// 获取上一个月
c.setTime(date);
c.add(Calendar.MONTH, -1);
daylist.addAll(getDayByMonth(c.getTime()));
// 获取当月
c.setTime(date);
daylist.addAll(getDayByMonth(c.getTime()));
// 获取下一个月
c.setTime(date);
c.add(Calendar.MONTH, 1);
daylist.addAll(getDayByMonth(c.getTime()));
List<Map<String, Object>> hasList = this.listMaps(new QueryWrapper<WlCarMileage>()
.select("COUNT(1) AS count,date").lambda().eq(WlCarMileage::getIotCode, car.getIotCode())
.between(WlCarMileage::getDate, daylist.get(0), daylist.get(daylist.size() - 1))
.groupBy(WlCarMileage::getDate));
Map<String, Object> hasMap = new HashMap<>();
for (Map<String, Object> mapOne : hasList) {
hasMap.put(String.valueOf(mapOne.get("date")), mapOne.get("count"));
}
for (String day : daylist) {
boolean has = false;
if (hasMap.containsKey(day)) {
has = true;
}
map.put(day, has);
}
return map;
}
public static List<String> getDayByMonth(Date date) {
List<String> data = new ArrayList<>();
try {
Calendar c = Calendar.getInstance();
c.setTime(date);
// 获取当前的年份
int year = c.get(Calendar.YEAR);
// 获取当前的月份(需要加1才是现在的月份)
int month = c.get(Calendar.MONTH) + 1;
// 获取本月的总天数
int dayCount = c.getActualMaximum(Calendar.DAY_OF_MONTH);
// 定义时间格式
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// 开始日期为当前年月拼接1号
Date startDate = sdf.parse(year + "-" + month + "-01");
// 结束日期为当前年月拼接该月最大天数
Date endDate = sdf.parse(year + "-" + month + "-" + dayCount);
// 设置calendar的开始日期
c.setTime(startDate);
// 当前时间小于等于设定的结束时间
while (c.getTime().compareTo(endDate) <= 0) {
String time = sdf.format(c.getTime());
data.add(time);
// 当前日期加1
c.add(Calendar.DATE, 1);
}
} catch (ParseException e) {
e.printStackTrace();
}
return data;
}
}
...@@ -484,7 +484,7 @@ public class ExcelServiceImpl { ...@@ -484,7 +484,7 @@ public class ExcelServiceImpl {
} }
@Transactional @Transactional
public Object commonUpload(MultipartFile multipartFile, ExcelDto excelDto, String uuidString, HttpServletRequest equest) throws Exception { public Object commonUpload(MultipartFile multipartFile, ExcelDto excelDto, String uuidString, HttpServletRequest equest) throws Exception {
switch (excelDto.getType()) { switch (excelDto.getType()) {
......
...@@ -37,6 +37,25 @@ ...@@ -37,6 +37,25 @@
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.1.1</version>
<exclusions>
<exclusion>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.yeejoin</groupId> <groupId>com.yeejoin</groupId>
<artifactId>amos-component-rule</artifactId> <artifactId>amos-component-rule</artifactId>
<exclusions> <exclusions>
......
package com.yeejoin.amos.patrol.business.controller; package com.yeejoin.amos.patrol.business.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.patrol.business.constants.XJConstant; import com.yeejoin.amos.patrol.business.constants.XJConstant;
...@@ -239,8 +241,12 @@ public class PlanController extends AbstractBaseController { ...@@ -239,8 +241,12 @@ public class PlanController extends AbstractBaseController {
public CommonResponse queryPointById(@ApiParam(value = "计划id", required = true) @PathVariable(name = "id") Long id) { public CommonResponse queryPointById(@ApiParam(value = "计划id", required = true) @PathVariable(name = "id") Long id) {
Plan plan = planService.queryPlanById(id); Plan plan = planService.queryPlanById(id);
Object ob= plan!=null?ToJson.tojson(plan):null; String json=plan!=null? JSON.toJSONString(plan):null;
return CommonResponseUtil.success(ob); JSONObject obj=json!=null?JSON.parseObject(json):null;
if(obj!=null){
obj.put("id",obj.get("id").toString());
}
return CommonResponseUtil.success(obj);
} }
......
...@@ -303,7 +303,9 @@ public class InputItemExcelDto extends BaseDto { ...@@ -303,7 +303,9 @@ public class InputItemExcelDto extends BaseDto {
} }
public void setKeyPartsType(String keyPartsType) { public void setKeyPartsType(String keyPartsType) {
// this.keyPartsType = StringUtils.isEmpty(keyPartsType) ? "1":keyPartsType; // this.keyPartsType = StringUtils.isEmpty(keyPartsType) ? "1":keyPartsType;
this.keyPartsType =StringUtils.isNotEmpty(keyPartsType) ? (keyPartsType.equals("是")?"0":"1") :keyPartsType; this.keyPartsType =StringUtils.isNotEmpty(keyPartsType) ? (keyPartsType.equals("是")?"0":"1") :keyPartsType;
} }
......
...@@ -614,7 +614,11 @@ public class CheckServiceImpl implements ICheckService { ...@@ -614,7 +614,11 @@ public class CheckServiceImpl implements ICheckService {
imgList.add(img); imgList.add(img);
} }
} }
List<CheckInput> checkInputList = checkInputDao.saveAll(checkItemList); List<CheckInput> checkInputList = new ArrayList<>();
for (CheckInput checkInput : checkItemList) {
checkInputDao.saveAndFlush(checkInput);
checkInputList.add(checkInput);
}
//规则请求结果 //规则请求结果
checkInputList.forEach(checkInput -> { checkInputList.forEach(checkInput -> {
InputItem inputItem = inputItemDao.findById(checkInput.getInputId()).get(); InputItem inputItem = inputItemDao.findById(checkInput.getInputId()).get();
......
package com.yeejoin; package com.yeejoin;
import com.yeejoin.amos.boot.biz.common.utils.oConvertUtils; import com.yeejoin.amos.boot.biz.common.utils.oConvertUtils;
import com.yeejoin.equipmanage.listener.CarIotListener;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
...@@ -18,6 +21,7 @@ import org.springframework.core.env.Environment; ...@@ -18,6 +21,7 @@ import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler; import org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler;
import java.net.InetAddress; import java.net.InetAddress;
...@@ -39,6 +43,12 @@ public class AmostEquipApplication { ...@@ -39,6 +43,12 @@ public class AmostEquipApplication {
private static final Logger logger = LoggerFactory.getLogger(AmostEquipApplication.class); private static final Logger logger = LoggerFactory.getLogger(AmostEquipApplication.class);
@Autowired
private EmqKeeper emqKeeper;
@Autowired
private CarIotListener carIotListener;
public static void main(String[] args) throws UnknownHostException { public static void main(String[] args) throws UnknownHostException {
ConfigurableApplicationContext context = SpringApplication.run(AmostEquipApplication.class, args); ConfigurableApplicationContext context = SpringApplication.run(AmostEquipApplication.class, args);
Environment env = context.getEnvironment(); Environment env = context.getEnvironment();
...@@ -56,4 +66,14 @@ public class AmostEquipApplication { ...@@ -56,4 +66,14 @@ public class AmostEquipApplication {
RestTemplate restTemplate(){ RestTemplate restTemplate(){
return new RestTemplate(); return new RestTemplate();
} }
/**
* 初始化MQTT
*
* @throws MqttException
*/
@Bean
void initMqtt() throws MqttException {
emqKeeper.getMqttClient().subscribe("+/+/property", 1, carIotListener);
}
} }
...@@ -3086,4 +3086,72 @@ ...@@ -3086,4 +3086,72 @@
create index index_equipment_code on wl_equipment_specific_alarm_log (`equipment_code`); create index index_equipment_code on wl_equipment_specific_alarm_log (`equipment_code`);
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="ls" id="202300406-1" >
<preConditions onFail="MARK_RAN">
<not>
<tableExists tableName="wl_car_mileage"/>
</not>
</preConditions>
<comment>add wl_car_mileage</comment>
<sql>
CREATE TABLE `wl_car_mileage` (
`id` bigint(0) NOT NULL,
`iot_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'iot编码',
`travel` double(11, 1) NULL DEFAULT NULL COMMENT '里程km',
`date` date NULL DEFAULT NULL COMMENT '日期',
`start_time` datetime(0) NULL DEFAULT NULL COMMENT '开始时间',
`end_time` datetime(0) NULL DEFAULT NULL COMMENT '结束时间',
`take_time` bigint(0) NULL DEFAULT NULL COMMENT '耗时',
`start_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '开始地址',
`end_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '结束地址',
`start_longitude` double(20, 6) NULL DEFAULT NULL COMMENT '开始精度',
`start_latitude` double(20, 6) NULL DEFAULT NULL COMMENT '开始纬度',
`end_longitude` double(20, 6) NULL DEFAULT NULL COMMENT '结束精度',
`end_latitude` double(20, 6) NULL DEFAULT NULL COMMENT '结束纬度',
`start_speed` int(0) NULL DEFAULT NULL COMMENT '开始速度km/h',
`end_speed` int(0) NULL DEFAULT NULL COMMENT '结束速度km/h',
`create_date` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '车量里程表' ROW_FORMAT = Dynamic;
</sql>
</changeSet>
<changeSet author="ls" id="202300406-2" >
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="wl_car" columnName="deployment"/>
</not>
</preConditions>
<comment>wl_car add displacement,ownership,code,extra1,extra2,extra3,extra4,longitude,latitude</comment>
<sql>
ALTER TABLE `wl_car`
ADD COLUMN `deployment` varchar(255) NULL COMMENT '配备方式';
ALTER TABLE `wl_car`
ADD COLUMN `deploy_date` varchar(50) NULL COMMENT '配备日期';
ALTER TABLE `wl_car`
ADD COLUMN `deploy_date_range` varchar(100) NULL COMMENT '配备日期区间';
ALTER TABLE `wl_car`
ADD COLUMN `displacement` varchar(255) NULL COMMENT '排量';
ALTER TABLE `wl_car`
ADD COLUMN `ownership` varchar(255) NULL COMMENT '车辆产权单位';
ALTER TABLE `wl_car`
ADD COLUMN `code` varchar(255) NULL COMMENT '编号';
ALTER TABLE `wl_car`
ADD COLUMN `extra1` varchar(255) NULL COMMENT '扩展字段1';
ALTER TABLE `wl_car`
ADD COLUMN `extra2` varchar(255) NULL COMMENT '扩展字段2';
ALTER TABLE `wl_car`
ADD COLUMN `extra3` varchar(255) NULL COMMENT '扩展字段3';
ALTER TABLE `wl_car`
ADD COLUMN `extra4` varchar(255) NULL COMMENT '扩展字段4';
ALTER TABLE `wl_car`
ADD COLUMN `longitude` double(20, 6) NULL COMMENT '经度';
ALTER TABLE `wl_car`
ADD COLUMN `latitude` double(20, 6) NULL COMMENT '纬度';
</sql>
</changeSet>
</databaseChangeLog> </databaseChangeLog>
\ No newline at end of file
...@@ -1870,6 +1870,7 @@ ...@@ -1870,6 +1870,7 @@
wlai.`name` manufacturerName, wlai.`name` manufacturerName,
wlc.car_num as code, wlc.car_num as code,
wlc.iot_code as iotCode, wlc.iot_code as iotCode,
wlc.car_num,
CASE CASE
wlc.car_state wlc.car_state
WHEN '1' THEN WHEN '1' THEN
...@@ -1886,7 +1887,9 @@ ...@@ -1886,7 +1887,9 @@
wlc.create_date as createDate, wlc.create_date as createDate,
'2' as eqtype, '2' as eqtype,
wlc.biz_org_code as bizOrgCode, wlc.biz_org_code as bizOrgCode,
wlc.biz_org_name as bizOrgName wlc.biz_org_name as bizOrgName,
wlc.longitude,
wlc.latitude
FROM FROM
wl_car wlc wl_car wlc
LEFT JOIN wl_equipment wle ON wle.id = wlc.equipment_id LEFT JOIN wl_equipment wle ON wle.id = wlc.equipment_id
...@@ -1918,6 +1921,12 @@ ...@@ -1918,6 +1921,12 @@
<if test="equipTypeAmountPage.iotCode!=null and equipTypeAmountPage.iotCode!=''"> <if test="equipTypeAmountPage.iotCode!=null and equipTypeAmountPage.iotCode!=''">
AND wlc.iot_code LIKE CONCAT('%',#{equipTypeAmountPage.iotCode},'%') AND wlc.iot_code LIKE CONCAT('%',#{equipTypeAmountPage.iotCode},'%')
</if> </if>
<if test="equipTypeAmountPage.carNum!=null and equipTypeAmountPage.carNum!=''">
And wlc.car_num LIKE CONCAT('%',#{equipTypeAmountPage.carNum},'%')
</if>
<if test="equipTypeAmountPage.keyword!=null and equipTypeAmountPage.keyword!=''">
And (wlc.`NAME` LIKE CONCAT('%',#{equipTypeAmountPage.keyword},'%') OR wlc.car_num LIKE CONCAT('%',#{equipTypeAmountPage.keyword},'%'))
</if>
)s2 )s2
<if test="equipTypeAmountPage.warehouseStructureName!=null and equipTypeAmountPage.warehouseStructureName!=''"> <if test="equipTypeAmountPage.warehouseStructureName!=null and equipTypeAmountPage.warehouseStructureName!=''">
where s2.full_name LIKE CONCAT('%',#{equipTypeAmountPage.warehouseStructureName},'%') where s2.full_name LIKE CONCAT('%',#{equipTypeAmountPage.warehouseStructureName},'%')
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace="com.yeejoin.equipmanage.mapper.WlCarMileageMapper">
<select id="totalMileage" resultType="Integer">
SELECT SUM(travel) FROM wl_car_mileage WHERE iot_code = #{iotCode}
</select>
<select id="page"
resultType="com.yeejoin.equipmanage.common.entity.WlCarMileage">
SELECT
wl_car_mileage.id,
wl_car_mileage.iot_code,
travel,
date,
start_time,
end_time,
take_time,
start_name,
end_name,
start_longitude,
start_latitude,
end_longitude,
end_latitude,
start_speed,
end_speed,
wl_car_mileage.create_date,
date AS name
FROM wl_car_mileage
LEFT JOIN wl_car ON wl_car.iot_code = wl_car_mileage.iot_code
<where>
<if test="wlCarMileage.carId != null">
AND wl_car.id = #{wlCarMileage.carId}
</if>
<if test="wlCarMileage.iotCode != null">
AND wl_car_mileage.iot_code = #{wlCarMileage.iotCode}
</if>
<if test="wlCarMileage.filterDate != null">
AND wl_car_mileage.date = #{wlCarMileage.filterDate}
</if>
<if test="wlCarMileage.complete">
AND wl_car_mileage.start_time IS NOT NULL AND wl_car_mileage.end_time IS NOT NULL
</if>
</where>
</select>
</mapper>
...@@ -67,4 +67,9 @@ equipment.hierarchy=1,2,4,6 ...@@ -67,4 +67,9 @@ equipment.hierarchy=1,2,4,6
management.security.enabled=true management.security.enabled=true
spring.security.user.name=admin spring.security.user.name=admin
spring.security.user.password=a1234560 spring.security.user.password=a1234560
\ No newline at end of file
#雪花算法参数 终端ID
generator.worker_id=1
#雪花算法参数 数据中心id
generator.datacenter_id=1
\ No newline at end of file
...@@ -394,6 +394,7 @@ ...@@ -394,6 +394,7 @@
'四级' '四级'
ELSE ELSE
'五级' '五级'
END )AS level,
IFNULL(a.key_parts_type,1) AS keyPartsType, IFNULL(a.key_parts_type,1) AS keyPartsType,
IFNULL(a.custom_type,1) AS customType, IFNULL(a.custom_type,1) AS customType,
a.risk_desc, a.risk_desc,
......
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