工程管理
This commit is contained in:
parent
bf287b5728
commit
1746861212
|
|
@ -102,6 +102,11 @@ public class HttpStatus
|
|||
*/
|
||||
public static final String LAST_POSITION_URL = "http://gps51.com/webapi?action=lastposition&token=";
|
||||
|
||||
/**
|
||||
*iot设备获取地址
|
||||
*/
|
||||
public static final String REPORT_OF_FLINE = "http://gps51.com/webapi?action=reportoffline&token=";
|
||||
|
||||
/**
|
||||
*iot查询行程地址
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -4,16 +4,15 @@ import com.bonus.sgzb.common.core.web.controller.BaseController;
|
|||
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.sgzb.common.log.annotation.Log;
|
||||
import com.bonus.sgzb.common.log.enums.BusinessType;
|
||||
import com.bonus.sgzb.largeScreen.domain.IotMaCodeMachine;
|
||||
import com.bonus.sgzb.largeScreen.domain.PageResultVo;
|
||||
import com.bonus.sgzb.largeScreen.domain.ParamsDto;
|
||||
import com.bonus.sgzb.largeScreen.service.ILargeScreenService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 10488
|
||||
|
|
@ -77,6 +76,19 @@ public class LargeScreenController extends BaseController {
|
|||
return service.getEquipmentDisByMap(dto);
|
||||
}
|
||||
|
||||
@Log(title = "获取工程经纬度、地址",businessType = BusinessType.QUERY)
|
||||
@GetMapping("getEquipmentDis")
|
||||
public AjaxResult getEquipmentDis(ParamsDto dto) {
|
||||
return service.getEquipmentDis(dto);
|
||||
}
|
||||
|
||||
|
||||
@Log(title = "获取iot编码绑定设备", businessType = BusinessType.QUERY)
|
||||
@GetMapping("getIotMaCodeMachine")
|
||||
public AjaxResult getIotMaCodeMachine(String province) {
|
||||
List<IotMaCodeMachine> iotMaCodeMachine = service.getIotMaCodeMachine(province);
|
||||
return AjaxResult.success(iotMaCodeMachine);
|
||||
}
|
||||
@Log(title = "施工机具/安全工器具总保有量",businessType = BusinessType.QUERY)
|
||||
@PostMapping("getTotalOwnership")
|
||||
public AjaxResult getTotalOwnership() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
package com.bonus.sgzb.largeScreen.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class IotLocationVo {
|
||||
|
||||
/** iot设备ID */
|
||||
@ApiModelProperty(value = "iot设备ID")
|
||||
private String iotId;
|
||||
|
||||
/** 经度 */
|
||||
@ApiModelProperty(value = "经度")
|
||||
private BigDecimal callon;
|
||||
|
||||
/** 经度 */
|
||||
@ApiModelProperty(value = "纬度")
|
||||
private BigDecimal callat;
|
||||
|
||||
/** 开始时间 */
|
||||
@ApiModelProperty(value = "开始时间")
|
||||
private String beginTime;
|
||||
|
||||
/** 结束时间 */
|
||||
@ApiModelProperty(value = "结束时间")
|
||||
private String endTime;
|
||||
|
||||
/** 详细地址 */
|
||||
@ApiModelProperty(value = "详细地址")
|
||||
private String address;
|
||||
|
||||
|
||||
/** 报警时间 */
|
||||
@ApiModelProperty(value = "报警时间")
|
||||
private String startAlarmTime;
|
||||
|
||||
/** 报警内容 */
|
||||
@ApiModelProperty(value = "报警内容")
|
||||
private String startAlarm;
|
||||
/** 电量百分比 */
|
||||
@ApiModelProperty(value = "电量百分比")
|
||||
private Double voltagepercent;
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
package com.bonus.sgzb.largeScreen.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author:liang.chao
|
||||
* @Date:2024/8/19 - 10:00
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class IotMaCodeMachine {
|
||||
/**
|
||||
* 机具编码
|
||||
*/
|
||||
private String maCode;
|
||||
/**
|
||||
* 类型型号
|
||||
*/
|
||||
private String typeName;
|
||||
/**
|
||||
* 规格型号
|
||||
*/
|
||||
private String typeModelName;
|
||||
/**
|
||||
* 机具状态
|
||||
*/
|
||||
private String maStatus;
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
private String projectId;
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
private String projectName;
|
||||
/**
|
||||
* 定位设备名称
|
||||
*/
|
||||
private String iotMachinetName;
|
||||
/**
|
||||
* iot设备编码
|
||||
*/
|
||||
private String iotCode;
|
||||
/**
|
||||
* 绑定状态
|
||||
*/
|
||||
private String bindStatus;
|
||||
/**
|
||||
* 省份
|
||||
*/
|
||||
private String province;
|
||||
/**
|
||||
* 协议id
|
||||
*/
|
||||
private String agreementId;
|
||||
/**
|
||||
* 当前位置
|
||||
*/
|
||||
private IotLocationVo iotLocationVo;
|
||||
}
|
||||
|
|
@ -172,4 +172,8 @@ public interface LargeScreenMapper {
|
|||
* @return
|
||||
*/
|
||||
List<AccessVo> getRepairList(ParamsDto dto);
|
||||
|
||||
List<EquipmentDisVo> getEquipmentDis(ParamsDto dto);
|
||||
|
||||
List<IotMaCodeMachine> getIotMaCodeMachine(String province);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
package com.bonus.sgzb.largeScreen.service;
|
||||
|
||||
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.sgzb.largeScreen.domain.IotMaCodeMachine;
|
||||
import com.bonus.sgzb.largeScreen.domain.PageResultVo;
|
||||
import com.bonus.sgzb.largeScreen.domain.ParamsDto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 10488
|
||||
* 大屏
|
||||
|
|
@ -167,4 +170,8 @@ public interface ILargeScreenService {
|
|||
* @return
|
||||
*/
|
||||
AjaxResult getMaintenanceChartByMonth(ParamsDto dto);
|
||||
|
||||
AjaxResult getEquipmentDis(ParamsDto dto);
|
||||
|
||||
List<IotMaCodeMachine> getIotMaCodeMachine(String province);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,20 @@
|
|||
package com.bonus.sgzb.largeScreen.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.bonus.sgzb.common.core.constant.HttpStatus;
|
||||
import com.bonus.sgzb.common.core.constant.TokenConstants;
|
||||
import com.bonus.sgzb.common.core.utils.DateTimeHelper;
|
||||
import com.bonus.sgzb.common.core.utils.HttpHelper;
|
||||
import com.bonus.sgzb.common.core.utils.StringHelper;
|
||||
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.sgzb.common.redis.service.RedisService;
|
||||
import com.bonus.sgzb.largeScreen.domain.*;
|
||||
import com.bonus.sgzb.largeScreen.mapper.LargeScreenMapper;
|
||||
import com.bonus.sgzb.largeScreen.service.ILargeScreenService;
|
||||
import com.bonus.sgzb.largeScreen.util.CommonUtil;
|
||||
import com.bonus.sgzb.material.config.ExceptionEnum;
|
||||
import com.bonus.sgzb.material.domain.EquipmentDis;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
|
@ -15,6 +24,7 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -31,6 +41,9 @@ public class LargeScreenServiceImpl implements ILargeScreenService {
|
|||
@Autowired
|
||||
private CommonUtil commonUtil;
|
||||
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
|
||||
@Override
|
||||
public AjaxResult getMaterialReqData() {
|
||||
HashMap<Object, Object> map = new HashMap<>(2);
|
||||
|
|
@ -343,6 +356,89 @@ public class LargeScreenServiceImpl implements ILargeScreenService {
|
|||
return AjaxResult.success(objectHashMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getEquipmentDis(ParamsDto dto) {
|
||||
List<EquipmentDisVo> equipmentDis = mapper.getEquipmentDis(dto);
|
||||
return AjaxResult.success(equipmentDis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IotMaCodeMachine> getIotMaCodeMachine(String province) {
|
||||
List<IotMaCodeMachine> iotMaCodeMachine = mapper.getIotMaCodeMachine(province);
|
||||
for (IotMaCodeMachine maCodeMachine : iotMaCodeMachine) {
|
||||
getLocation(maCodeMachine);
|
||||
}
|
||||
return iotMaCodeMachine;
|
||||
}
|
||||
|
||||
public void getLocation(IotMaCodeMachine iotMaCodeMachine) {
|
||||
log.info("getLocation:{}", iotMaCodeMachine);
|
||||
if (iotMaCodeMachine == null || iotMaCodeMachine.getIotCode() == null) {
|
||||
throw new RuntimeException(ExceptionEnum.PARAM_NULL.getMsg());
|
||||
}
|
||||
List<String> list = new ArrayList<>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
//从redis中获取token
|
||||
String redisCode = redisService.getCacheObject(TokenConstants.TOKEN_LOCATION);
|
||||
//如果token为空,先去调登录接口,获取token
|
||||
if (redisCode == null) {
|
||||
redisCode = HttpHelper.getIotToken();
|
||||
redisService.setCacheObject(TokenConstants.TOKEN_LOCATION, redisCode, 23L, TimeUnit.HOURS);
|
||||
}
|
||||
map.clear();
|
||||
list.add(iotMaCodeMachine.getIotCode());
|
||||
map.put("deviceids", list);
|
||||
String param = JSON.toJSONString(map);
|
||||
String res = HttpHelper.doPost(HttpStatus.LAST_POSITION_URL + redisCode, param);
|
||||
String res1 = HttpHelper.doPost(HttpStatus.REPORT_OF_FLINE + redisCode, param);
|
||||
//对返回的结果进行解析
|
||||
IotLocationVo iotLocationVo = resultDataHandler(res);
|
||||
String address = resultDataHandler1(res1);
|
||||
iotLocationVo.setAddress(address);
|
||||
iotMaCodeMachine.setIotLocationVo(iotLocationVo);
|
||||
}
|
||||
|
||||
private IotLocationVo resultDataHandler(String res) {
|
||||
if (res == null) {
|
||||
throw new RuntimeException(ExceptionEnum.RETURN_DATA_IS_EMPTY.getMsg());
|
||||
}
|
||||
IotLocationVo iotLocationVo = new IotLocationVo();
|
||||
JSONObject object = JSONObject.parseObject(res);
|
||||
String status = object.getString("status");
|
||||
String cause = object.getString("cause");
|
||||
if ("0".equals(status) && "OK".equals(cause)) {
|
||||
String records = object.getString("records");
|
||||
//判断返回结果是否为空
|
||||
if (records != null) {
|
||||
JSONArray jsonArray = JSON.parseArray(records);
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject jsonObject = JSONObject.from(jsonArray.getJSONObject(i));
|
||||
iotLocationVo.setIotId(jsonObject.getString("deviceid"));
|
||||
iotLocationVo.setVoltagepercent(Double.valueOf(jsonObject.getString("voltagepercent")));
|
||||
iotLocationVo.setCallat(StringHelper.conversionBigDecimal(jsonObject.getString("callat")));
|
||||
iotLocationVo.setCallon(StringHelper.conversionBigDecimal(jsonObject.getString("callon")));
|
||||
}
|
||||
}
|
||||
}
|
||||
return iotLocationVo;
|
||||
}
|
||||
|
||||
private String resultDataHandler1(String res) {
|
||||
if (res == null) {
|
||||
throw new RuntimeException(ExceptionEnum.RETURN_DATA_IS_EMPTY.getMsg());
|
||||
}
|
||||
String address = "";
|
||||
JSONObject object = JSONObject.parseObject(res);
|
||||
String status = object.getString("status");
|
||||
String cause = object.getString("cause");
|
||||
if ("0".equals(status) && "OK".equals(cause)) {
|
||||
JSONObject addressmap = object.getJSONObject("addressmap");
|
||||
for (String s : addressmap.keySet()) {
|
||||
address = addressmap.get(s).toString();
|
||||
}
|
||||
}
|
||||
return address;
|
||||
}
|
||||
@Override
|
||||
public AjaxResult getTotalOwnership() {
|
||||
List<TotalOwnershipVo> list = new ArrayList<>();
|
||||
|
|
|
|||
|
|
@ -869,5 +869,42 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
ORDER BY
|
||||
tt.create_time DESC
|
||||
</select>
|
||||
<select id="getEquipmentDis" resultType="com.bonus.sgzb.largeScreen.domain.EquipmentDisVo">
|
||||
select longitude,
|
||||
lot_id as lotId,
|
||||
latitude,
|
||||
lot_name as lotName,
|
||||
address,
|
||||
province
|
||||
from bm_project_lot where province = #{province}
|
||||
</select>
|
||||
<select id="getIotMaCodeMachine" resultType="com.bonus.sgzb.largeScreen.domain.IotMaCodeMachine">
|
||||
SELECT
|
||||
im.iot_code as iotCode,
|
||||
mt.type_name as typeModelName,
|
||||
mt1.type_name as typeName,
|
||||
bpl.lot_id as projectId,
|
||||
sai.agreement_id as agreementId,
|
||||
bpl.lot_name as projectName,
|
||||
sd.name as maStatus,
|
||||
mm.type_id,
|
||||
mm.ma_code,
|
||||
mm.ma_id
|
||||
FROM
|
||||
iot_machine im
|
||||
LEFT JOIN iot_machine_bind imb ON imb.iot_id = im.id
|
||||
LEFT JOIN ma_machine mm ON imb.ma_code = mm.ma_code
|
||||
left join ma_type mt on mm.type_id = mt.type_id
|
||||
left join ma_type mt1 on mt1.type_id = mt.parent_id
|
||||
LEFT JOIN sys_dic sd on mm.ma_status = sd.id
|
||||
LEFT JOIN slt_agreement_info sai ON mm.type_id = sai.type_id
|
||||
AND mm.ma_id = sai.ma_id
|
||||
AND mm.ma_id is not null
|
||||
LEFT JOIN bm_agreement_info bai ON sai.agreement_id = bai.agreement_id
|
||||
LEFT JOIN bm_project_lot bpl ON bai.project_id = bpl.lot_id
|
||||
WHERE
|
||||
im.bind_status = 0
|
||||
AND imb.unbind_time IS NULL and sai.`status` = 0 and bpl.province = #{province}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue