Commit dc845199 authored by suhuiguang's avatar suhuiguang

Merge branch 'dev_upgrade' of http://172.16.10.76/station/YeeAmosFireAutoSysRoot into dev_upgrade

parents 0556e442 045181bf
......@@ -78,6 +78,11 @@ public class ExcelController extends BaseController {
@ApiParam(value = "data:导出数据;model:导出模板", required = true) @RequestParam String exportType,
@ApiParam(value = "point:监测点;equipment:设备", required = true) @RequestParam String modelName,
@ApiParam(value = "查询条件") @RequestBody(required = false) Map<String, Object> paramsMap) {
ReginParams reginParams =getSelectedOrgInfo();
String orgCode = getOrgCode(reginParams);
paramsMap.put("compCode", orgCode);
String fileName = UUID.randomUUID().toString() + ".xls";
String title = "监测点";
Class cls = null;
......
......@@ -39,6 +39,13 @@ public class FireSourceController extends BaseController {
@ApiOperation(httpMethod = "POST", value = "添加消防装备", notes = "添加消防装备")
@RequestMapping(value = "", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse create(@RequestBody FireEquipment fireEquipment) throws Exception {
if(fireEquipment.getId() == 0l) {//新增
Boolean existByCode = iFireEquipService.isExistByCode(fireEquipment.getCode());
if(existByCode){
return CommonResponseUtil.failure("设备编号重复,请重试!");
}
}
ReginParams reginParams = getSelectedOrgInfo();
String compCode = getOrgCode(reginParams);
fireEquipment.setCreateBy(getUserId());
......@@ -62,7 +69,6 @@ public class FireSourceController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "查询单个消防装备", notes = "查询单个消防装备")
@RequestMapping(value = "/{id}", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse query(@PathVariable Long id) {
return CommonResponseUtil.success(iFireEquipService.queryOne(id));
}
......
......@@ -139,6 +139,13 @@ public class FireStationController extends BaseController {
// || StringUtils.isEmpty(fireStation.getPosition3d())
|| StringUtils.isEmpty(fireStation.getCode()))
throw new Exception("数据校验失败.");
long id = fireStation.getId();
if(id == 0l) {//新增
Boolean existByCode = iFireStationService.isExistByCode(fireStation.getCode());
if(existByCode) {
throw new Exception("改编号已存在,请重试!");
}
}
ReginParams reginParams =getSelectedOrgInfo();
String compCode=getOrgCode(reginParams);
fireStation.setCreateBy(getUserId());
......
package com.yeejoin.amos.fas.business.controller;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import java.util.Map;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.itextpdf.text.pdf.PdfStructTreeController.returnType;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@RestController
@RequestMapping("/api/weather")
@Api(tags="天气api")
public class WeatherController extends BaseController {
@ApiOperation(httpMethod = "GET",value = "天气查询", notes = "天气查询")
@GetMapping("/{address}")
public CommonResponse getWeather(@PathVariable("address") String address) {
String result = "";
BufferedReader in = null;
try {
String urlNameString = "http://t.weather.sojson.com/api/weather/city/" + address;
URL realUrl = new URL(urlNameString);
// 打开和URL之间的连接
URLConnection connection = realUrl.openConnection();
// 设置通用的请求属性
connection.setRequestProperty("accept", "*/*");
connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
// 建立实际的连接
connection.connect();
// 获取所有响应头字段
Map<String, List<String>> map = connection.getHeaderFields();
// 定义 BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(
connection.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送GET请求出现异常!" + e);
return CommonResponseUtil.failure(e.getCause().toString());
}
// 使用finally块来关闭输入流
finally {
try {
if (in != null) {
in.close();
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
return CommonResponseUtil.success(JSONObject.parse(result));
}
}
......@@ -8,4 +8,6 @@ public interface FireStationEquipmentMapper extends BaseMapper {
Map queryRelation(@Param( "fireStationId") Long fireStationId, @Param( "fireEquipmentId")Long fireEquipmentId);
void updateNumberById(@Param( "stationEquiId") Long stationEquiId, @Param( "diff") Double diff);
}
......@@ -18,4 +18,6 @@ public interface IFireEquipmentDao extends BaseDao<FireEquipment, Long> {
@Query(value = "SELECT count(1) FROM `f_fire_station_equipment` WHERE fire_equipment_id in ?1", nativeQuery = true)
int countAssociatedEquipStationByIds(String[] ids);
Optional<FireEquipment> findByCode(String code);
}
......@@ -10,4 +10,6 @@ import com.yeejoin.amos.fas.dao.entity.FireStation;
public interface IFireStationDao extends BaseDao<FireStation, Long> {
Optional<FireStation> findById(Long id);
Optional<FireStation> findByCode(String code);
}
......@@ -6,13 +6,13 @@ public class FireEquipmentParam {
private Long id;
@Excel(name = "机构编号")
@Excel(name = "机构编号(必填)")
private String orgCode;
@Excel(name = "编号", orderNum = "1")
private String code;
@Excel(name = "装备分类", replace = {"设备类_0", "耗材类_1", "视频监控_2", "灭火器材_3"}, orderNum = "2")
@Excel(name = "装备分类(设备类_0,耗材类_1,视频监控_2,灭火器材_3)", replace = {"设备类_0", "耗材类_1", "视频监控_2", "灭火器材_3"}, orderNum = "2")
private Integer equipClassify;
@Excel(name = "装备类型", orderNum = "3")
......@@ -24,7 +24,7 @@ public class FireEquipmentParam {
@Excel(name = "三维楼层", orderNum = "5")
private String floor3d;
@Excel(name = "是否室内", replace = {"否_0", "是_1"}, orderNum = "6")
@Excel(name = "是否室内(必填 0/1)", replace = {"否_0", "是_1"}, orderNum = "6")
private Integer isIndoor;
@Excel(name = "装备名称", orderNum = "7")
......
......@@ -8,30 +8,30 @@ public class FireEquipmentPointParam {
private Long id;
@Excel(name = "名称", orderNum = "1", width = 50)
@Excel(name = "名称", orderNum = "2", width = 50)
private String name;
@Excel(name = "编号", orderNum = "2", width = 12)
@Excel(name = "编号", orderNum = "1", width = 12)
private String code;
@Excel(name = "消防装备编号", orderNum = "3", width = 15)
@Excel(name = "消防装备编号", orderNum = "8", width = 15)
private String fireEquipmentCode;
@Excel(name = "消防装备名称", orderNum = "4", width = 50)
@Excel(name = "绑定消防装备名称", orderNum = "7", width = 50)
private String fireEquipmentName;
private Long fireEquipmentId;
@Excel(name = "类型", replace = {"模拟量_ANALOGUE", "开关量_SWITCH"}, orderNum = "5")
@Excel(name = "数据类型", replace = {"模拟量_ANALOGUE", "开关量_SWITCH"}, orderNum = "3")
private String type;
@Excel(name = "值", replace = {"是_true", "否_false"}, orderNum = "6", width = 12)
@Excel(name = "状态", replace = {"是_true", "否_false"}, orderNum = "5", width = 12)
private String value;
@Excel(name = "单位", orderNum = "7", width = 12)
@Excel(name = "单位", orderNum = "6", width = 12)
private String unit;
@Excel(name = "告警类型", replace = {"火灾告警_1", "电源开关_2", "换流变_6", "液位_3", "流量_4", "容量_5", "故障告警_7"}, orderNum = "8")
@Excel(name = "指标类型", replace = {"火灾告警_1", "电源开关_2", "换流变_6", "液位_3", "流量_4", "容量_5", "故障告警_7"}, orderNum = "4")
private Long alarmType;
......
......@@ -193,4 +193,11 @@ public class FireEquipServiceImpl implements IFireEquipService {
public int countAssociatedEquipStationByIds(String[] ids) {
return iFireEquipmentDao.countAssociatedEquipStationByIds(ids);
}
@Override
public Boolean isExistByCode(String code) {
Optional<FireEquipment> optional = iFireEquipmentDao.findByCode(code);
return optional.isPresent();
}
}
......@@ -69,18 +69,40 @@ public class FireStationServiceImpl implements IFireStationService {
fireEquipment=fireEquipment1.get();
}
Map map = fireStationEquipmentMapper.queryRelation(fireStationFireEquipment.getFireStationId(),
fireStationFireEquipment.getFireEquipmentId());
if (fireStation == null)
throw new Exception("找不到指定的消防站");
if (fireEquipment == null)
throw new Exception("消防设备不存在");
if (!CollectionUtils.isEmpty(map))
throw new Exception("绑定关系已经存在.");
// if (!CollectionUtils.isEmpty(map))
// throw new Exception("绑定关系已经存在.");
Map map = fireStationEquipmentMapper.queryRelation(fireStationFireEquipment.getFireStationId(),
fireStationFireEquipment.getFireEquipmentId());
if (!CollectionUtils.isEmpty(map)) {
if(fireEquipment.getEquipClassify() == 1) {//耗材类
Long stationEquiId = (Long) map.get("id");
Double number = (Double) map.get("number");//当前数量
Double number2 = fireStationFireEquipment.getNumber();//添加的数量
Double number3 = (double)fireEquipment.getNumber();//库存
Double diff = number3 - number2;
if(diff < 0){
throw new Exception("添加数量超过现有数量!.");
}else {
Double curNumber = number + number2;
fireStationEquipmentMapper.updateNumberById(stationEquiId,curNumber);
fireEquipment.setNumber(diff.intValue());
iFireEquipmentDao.saveAndFlush(fireEquipment);
}
}
}else {
fireStationFireEquipment = iFireStationEquipmentDao.save(fireStationFireEquipment);
}
}
return fireStationFireEquipments;
}
......@@ -203,4 +225,10 @@ public class FireStationServiceImpl implements IFireStationService {
return result;
}
@Override
public Boolean isExistByCode(String code) {
Optional<FireStation> optional = iFireStationDao.findByCode(code);
return optional.isPresent();
}
}
......@@ -46,4 +46,6 @@ public interface IFireEquipService {
* @return
*/
int countAssociatedEquipStationByIds(String[] ids);
Boolean isExistByCode(String code);
}
......@@ -72,4 +72,6 @@ public interface IFireStationService {
*/
Map queryForEuqimentListById(Long id);
Boolean isExistByCode(String code);
}
......@@ -33,7 +33,7 @@ spring.data.mongodb.uri = mongodb://172.16.11.33:27017/iecmonitor
params.remoteRuleUrl=http://magintursh.xicp.net:18080/
params.remoteWebsocketUrl=http://172.16.10.91:10600/
spring.redis.database=5
spring.redis.database=1
spring.redis.host=172.16.11.33
spring.redis.port=6379
spring.redis.password=1234560
......
......@@ -24,6 +24,8 @@ spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
spring.jpa.database-platform = org.hibernate.dialect.MySQLDialect
spring.jpa.open-in-view = true
spring.jackson.time-zone=GMT+8
#mybatis mapper file
mybatis.mapper-locations = classpath:db/mapper/*.xml
# mybatis entity package
......
......@@ -14,4 +14,9 @@
se.fire_equipment_id = ${fireEquipmentId}
AND se.fire_station_id = ${fireStationId};
</select>
<update id="updateNumberById">
update f_fire_station_equipment set number = #{diff}
where id = #{stationEquiId}
</update>
</mapper>
\ No newline at end of file
......@@ -68,6 +68,8 @@
a.is_indoor as isIndoor,
a.org_code AS orgCode,
a.position3d,
a.ue4_rotation as ue4Rotation,
a.ue4_location as ue4Location,
a.photo_path AS photoPath,
a.risk_source_id as riskSourceId
FROM
......
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