大屏定位信息代码提交
This commit is contained in:
parent
d6434ff805
commit
90210e0ac4
|
|
@ -0,0 +1,38 @@
|
|||
package com.bonus.sgzb.config;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 返回异常枚举类
|
||||
* @Author ma_sh
|
||||
* @create 2024/3/29 14:43
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ExceptionEnum {
|
||||
|
||||
PARAM_NULL(1001, "参数为空"),
|
||||
IOT_CODE_DUPLICATE(1002, "设备编号重复"),
|
||||
IOT_TO_DELETE(1003, "该iot设备绑定相关类型设备,无法删除"),
|
||||
SUCCESS(200, "操作成功"),
|
||||
SAVE_TO_DATABASE(500, "新增保存失败,请联系管理员!!!"),
|
||||
DELETE_TO_DATABASE(500, "删除失败,请联系管理员!!!"),
|
||||
BIND_TO_DATABASE(500, "绑定失败,请联系管理员!!!"),
|
||||
UN_BIND_TO_DATABASE(500, "解绑失败,请联系管理员!!!"),
|
||||
UPDATE_TO_DATABASE(500, "修改失败,请联系管理员!!!"),
|
||||
|
||||
RETURN_DATA_IS_EMPTY(501, "返回数据为空!!"),
|
||||
IOT_ENCODING_ERROR(502, "输入的IOT编码有误,请输入正确的编码!!!");
|
||||
private Integer code;
|
||||
|
||||
private String msg;
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
|
@ -7,12 +7,10 @@ import com.bonus.sgzb.common.log.enums.BusinessType;
|
|||
import com.bonus.sgzb.largeScreen.domain.*;
|
||||
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
|
||||
|
|
@ -231,4 +229,12 @@ public class LargeScreenController extends BaseController {
|
|||
public AjaxResult getMaintenanceWarning() {
|
||||
return service.getMaintenanceWarning();
|
||||
}
|
||||
|
||||
|
||||
@Log(title = "获取iot编码绑定设备", businessType = BusinessType.QUERY)
|
||||
@GetMapping("getIotMaCodeMachine")
|
||||
public AjaxResult getIotMaCodeMachine() {
|
||||
List<IotMaCodeMachine> iotMaCodeMachine = service.getIotMaCodeMachine();
|
||||
return AjaxResult.success(iotMaCodeMachine);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
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;
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
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 maStatus;
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
private String projectId;
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
private String projectName;
|
||||
/**
|
||||
* 定位设备名称
|
||||
*/
|
||||
private String iotMachinetName;
|
||||
/**
|
||||
* iot设备编码
|
||||
*/
|
||||
private String iotCode;
|
||||
/**
|
||||
* 绑定状态
|
||||
*/
|
||||
private String bindStatus;
|
||||
/**
|
||||
* 当前位置
|
||||
*/
|
||||
private IotLocationVo iotLocationVo;
|
||||
}
|
||||
|
|
@ -171,4 +171,6 @@ public interface LargeScreenMapper {
|
|||
* @return
|
||||
*/
|
||||
List<AccessVo> getRepairList(ParamsDto dto);
|
||||
|
||||
List<IotMaCodeMachine> getIotMaCodeMachine();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.bonus.sgzb.largeScreen.service;
|
|||
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.sgzb.largeScreen.domain.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 10488
|
||||
* 大屏
|
||||
|
|
@ -166,4 +168,6 @@ public interface ILargeScreenService {
|
|||
* @return
|
||||
*/
|
||||
AjaxResult getMaintenanceChartByMonth(ParamsDto dto);
|
||||
|
||||
List<IotMaCodeMachine> getIotMaCodeMachine();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,16 @@
|
|||
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.config.ExceptionEnum;
|
||||
import com.bonus.sgzb.largeScreen.domain.*;
|
||||
import com.bonus.sgzb.largeScreen.mapper.LargeScreenMapper;
|
||||
import com.bonus.sgzb.largeScreen.service.ILargeScreenService;
|
||||
|
|
@ -14,6 +23,7 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -30,6 +40,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);
|
||||
|
|
@ -97,6 +110,7 @@ public class LargeScreenServiceImpl implements ILargeScreenService {
|
|||
|
||||
/**
|
||||
* 领料数据详情
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -119,6 +133,7 @@ public class LargeScreenServiceImpl implements ILargeScreenService {
|
|||
|
||||
/**
|
||||
* 退料数据详情
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -141,6 +156,7 @@ public class LargeScreenServiceImpl implements ILargeScreenService {
|
|||
|
||||
/**
|
||||
* 施工机具/安全工器具总保有量详情
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -163,6 +179,7 @@ public class LargeScreenServiceImpl implements ILargeScreenService {
|
|||
|
||||
/**
|
||||
* 新购验收入库分析详情
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -196,6 +213,7 @@ public class LargeScreenServiceImpl implements ILargeScreenService {
|
|||
|
||||
/**
|
||||
* 方法抽取,统一赋值
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
private void extracted(ParamsDto dto) {
|
||||
|
|
@ -209,6 +227,7 @@ public class LargeScreenServiceImpl implements ILargeScreenService {
|
|||
|
||||
/**
|
||||
* 当月报废分析详情
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -240,6 +259,7 @@ public class LargeScreenServiceImpl implements ILargeScreenService {
|
|||
|
||||
/**
|
||||
* 当月领料分析详情
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -270,6 +290,7 @@ public class LargeScreenServiceImpl implements ILargeScreenService {
|
|||
|
||||
/**
|
||||
* 当月退料分析详情
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -300,6 +321,7 @@ public class LargeScreenServiceImpl implements ILargeScreenService {
|
|||
|
||||
/**
|
||||
* 当月维修分析详情
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -330,6 +352,7 @@ public class LargeScreenServiceImpl implements ILargeScreenService {
|
|||
|
||||
/**
|
||||
* 当月维修分析详情列表
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -341,6 +364,63 @@ public class LargeScreenServiceImpl implements ILargeScreenService {
|
|||
return AjaxResult.success(objectHashMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IotMaCodeMachine> getIotMaCodeMachine() {
|
||||
List<IotMaCodeMachine> iotMaCodeMachine = mapper.getIotMaCodeMachine();
|
||||
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);
|
||||
//对返回的结果进行解析
|
||||
IotLocationVo iotLocationVo = resultDataHandler(res);
|
||||
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.setCallat(StringHelper.conversionBigDecimal(jsonObject.getString("callat")));
|
||||
iotLocationVo.setCallon(StringHelper.conversionBigDecimal(jsonObject.getString("callon")));
|
||||
}
|
||||
}
|
||||
}
|
||||
return iotLocationVo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getTotalOwnership() {
|
||||
List<TotalOwnershipVo> list = new ArrayList<>();
|
||||
|
|
@ -536,6 +616,7 @@ public class LargeScreenServiceImpl implements ILargeScreenService {
|
|||
|
||||
/**
|
||||
* 方法抽取
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -885,5 +885,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
ORDER BY
|
||||
tt.create_time DESC
|
||||
</select>
|
||||
<select id="getIotMaCodeMachine" resultType="com.bonus.sgzb.largeScreen.domain.IotMaCodeMachine">
|
||||
SELECT
|
||||
im.iot_code as iotCode,
|
||||
bpl.lot_id as projectId,
|
||||
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 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
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -10,7 +10,7 @@ public class IotLocationVo {
|
|||
|
||||
/** iot设备ID */
|
||||
@ApiModelProperty(value = "iot设备ID")
|
||||
private Long iotId;
|
||||
private String iotId;
|
||||
|
||||
/** 经度 */
|
||||
@ApiModelProperty(value = "经度")
|
||||
|
|
|
|||
|
|
@ -529,7 +529,7 @@ public class IotMachineServiceImpl implements IotMachineService {
|
|||
JSONArray jsonArray = JSON.parseArray(records);
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject jsonObject = JSONObject.from(jsonArray.getJSONObject(i));
|
||||
iotLocationVo.setIotId(StringHelper.conversionLong(jsonObject.getString("deviceid")));
|
||||
iotLocationVo.setIotId(jsonObject.getString("deviceid"));
|
||||
iotLocationVo.setCallat(StringHelper.conversionBigDecimal(jsonObject.getString("callat")));
|
||||
iotLocationVo.setCallon(StringHelper.conversionBigDecimal(jsonObject.getString("callon")));
|
||||
}
|
||||
|
|
@ -537,8 +537,4 @@ public class IotMachineServiceImpl implements IotMachineService {
|
|||
}
|
||||
return iotLocationVo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue