Commit e359df7a authored by jichao's avatar jichao

改bug

parent ceefdd7c
...@@ -18,10 +18,8 @@ public interface BusTeamRepository extends BaseMapper<BusTeam>{ ...@@ -18,10 +18,8 @@ public interface BusTeamRepository extends BaseMapper<BusTeam>{
@Select("<script>select a.*,count(1) teamNumber,sum(b.BLD_AREA) area from bus_team a,bus_project b where " + @Select("<script>select a.*,count(1) teamNumber,sum(b.BLD_AREA) area from bus_team a left join bus_project b " +
" case when a.TEAM_TYPE = '1' then a.TEAM_ID=b.TEAM_ID_ON else a.TEAM_ID=b.TEAM_ID_OFF end" + "on case when a.TEAM_TYPE = '1' then a.TEAM_ID=b.TEAM_ID_ON else a.TEAM_ID=b.TEAM_ID_OFF end where TEAM_TYPE = #{type} GROUP BY a.TEAM_ID</script>")
"<if test=\"type != null\"> and TEAM_TYPE = #{type}</if>" +
" GROUP BY a.TEAM_ID</script>")
@ResultMap(value = "BaseResultMap" ) @ResultMap(value = "BaseResultMap" )
List<BusTeam> selectByTeamId(@Param("type") String type); List<BusTeam> selectByTeamId(@Param("type") String type);
......
package org.rcisoft.business.mainte.adaptive;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import org.json.JSONObject;
public class AddressUtils {
/**
* @param args
*/
public static void main(String[] args) {
AddressUtils addressUtils = new AddressUtils();
String ip = "125.36.118.195";
String address = "";
try {
address = addressUtils.getAddress("ip="+ip, "utf-8");
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(address);
}
/**
* 获取地址
* @param params
* @param encoding
* @return
* @throws Exception
*/
public static String getAddress(String params, String encoding) throws Exception{
String path = "http://ip.taobao.com/service/getIpInfo.php";
String returnStr = getRs(path, params, encoding);
JSONObject json=null;
if(returnStr != null){
json = new JSONObject(returnStr);
if("0".equals(json.get("code").toString())){
StringBuffer buffer = new StringBuffer();
//buffer.append(decodeUnicode(json.optJSONObject("data").getString("country")));//国家
//buffer.append(decodeUnicode(json.optJSONObject("data").getString("area")));//地区
// buffer.append(decodeUnicode(json.optJSONObject("data").getString("region")));//省份
buffer.append(decodeUnicode(json.optJSONObject("data").getString("city")));//市区
// buffer.append(decodeUnicode(json.optJSONObject("data").getString("county")));//地区
// buffer.append(decodeUnicode(json.optJSONObject("data").getString("isp")));//ISP公司
System.out.println(buffer.toString());
return buffer.toString();
}else{
return "获取地址失败";
}
}
return null;
}
/**
* 从url获取结果
* @param path
* @param params
* @param encoding
* @return
*/
public static String getRs(String path, String params, String encoding){
URL url = null;
HttpURLConnection connection = null;
try {
url = new URL(path);
connection = (HttpURLConnection)url.openConnection();// 新建连接实例
connection.setConnectTimeout(2000);// 设置连接超时时间,单位毫�?
connection.setReadTimeout(2000);// 设置读取数据超时时间,单位毫�?
connection.setDoInput(true);// 是否打开输出�? true|false
connection.setDoOutput(true);// 是否打开输入流true|false
connection.setRequestMethod("POST");// 提交方法POST|GET
connection.setUseCaches(false);// 是否缓存true|false
connection.connect();// 打开连接端口
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
out.writeBytes(params);
out.flush();
out.close();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(),encoding));
StringBuffer buffer = new StringBuffer();
String line = "";
while ((line = reader.readLine())!= null) {
buffer.append(line);
}
reader.close();
return buffer.toString();
} catch (Exception e) {
e.printStackTrace();
}finally{
connection.disconnect();// 关闭连接
}
return null;
}
/**
* 字符转码
* @param theString
* @return
*/
public static String decodeUnicode(String theString){
char aChar;
int len = theString.length();
StringBuffer buffer = new StringBuffer(len);
for (int i = 0; i < len;) {
aChar = theString.charAt(i++);
if(aChar == '\\'){
aChar = theString.charAt(i++);
if(aChar == 'u'){
int val = 0;
for(int j = 0; j < 4; j++){
aChar = theString.charAt(i++);
switch (aChar) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
val = (val << 4) + aChar - '0';
break;
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
val = (val << 4) + 10 + aChar - 'a';
break;
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
val = (val << 4) + 10 + aChar - 'A';
break;
default:
throw new IllegalArgumentException(
"Malformed encoding.");
}
}
buffer.append((char) val);
}else{
if(aChar == 't'){
aChar = '\t';
}
if(aChar == 'r'){
aChar = '\r';
}
if(aChar == 'n'){
aChar = '\n';
}
if(aChar == 'f'){
aChar = '\f';
}
buffer.append(aChar);
}
}else{
buffer.append(aChar);
}
}
return buffer.toString();
}
}
\ No newline at end of file
...@@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
/** /**
* Created by JiChao on 2018/4/28. * Created by JiChao on 2018/4/28.
* 运维--自适应模块 * 运维--自适应模块
...@@ -45,6 +47,16 @@ public class AdaptiveController { ...@@ -45,6 +47,16 @@ public class AdaptiveController {
return Result.builder(new PersistModel(1), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, adaptiveServiceImpl.buildingAdaptation(proId, year, month, day)); return Result.builder(new PersistModel(1), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, adaptiveServiceImpl.buildingAdaptation(proId, year, month, day));
} }
/**
* 根据ip查询气象信息
* @return
*/
@ApiOperation(value="根据ip查询气象信息", notes="根据ip查询气象信息")
@RequestMapping("/weather")
public Result weather(HttpServletRequest request, @RequestParam String ip) {
return Result.builder(new PersistModel(1), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, adaptiveServiceImpl.weather(request, ip));
}
@ApiOperation(value="实际温度定时任务测试", notes="实际温度定时任务测试") @ApiOperation(value="实际温度定时任务测试", notes="实际温度定时任务测试")
@RequestMapping("/temperature") @RequestMapping("/temperature")
public Result temperature() { public Result temperature() {
......
...@@ -5,7 +5,9 @@ import org.rcisoft.business.mainte.adaptive.vo.ClimateAdaptation; ...@@ -5,7 +5,9 @@ import org.rcisoft.business.mainte.adaptive.vo.ClimateAdaptation;
import org.rcisoft.business.mainte.adaptive.vo.Params; import org.rcisoft.business.mainte.adaptive.vo.Params;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* Created by JiChao on 2018/4/28. * Created by JiChao on 2018/4/28.
...@@ -45,4 +47,11 @@ public interface AdaptiveService { ...@@ -45,4 +47,11 @@ public interface AdaptiveService {
*/ */
PersistModel temperature(); PersistModel temperature();
/**
* 根据ip查询气象信息
* @param request
* @return
*/
Map<String, Object> weather(HttpServletRequest request, String ip);
} }
...@@ -98,6 +98,13 @@ public class BusProjectController extends PaginationController<BusProject> { ...@@ -98,6 +98,13 @@ public class BusProjectController extends PaginationController<BusProject> {
busProjectServiceImpl.queryBusProjectByUser(map)); busProjectServiceImpl.queryBusProjectByUser(map));
} }
@ApiOperation(value="更改 是否接收数据 标志位", notes="更改 是否接收数据 标志位")
@RequestMapping(value = "/receiveData")
public Result receiveData(@RequestParam String proId, @RequestParam Integer receiveData) {
Integer result = busProjectServiceImpl.receiveData(proId, receiveData);
return Result.builder(new PersistModel(result), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, result);
}
@InitBinder @InitBinder
public void initBinder(WebDataBinder webDataBinder, WebRequest webRequest) { public void initBinder(WebDataBinder webDataBinder, WebRequest webRequest) {
DateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); DateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
......
...@@ -83,5 +83,7 @@ public class BusProject{ ...@@ -83,5 +83,7 @@ public class BusProject{
private String sysNm; private String sysNm;
private String online; private String online;
private Integer receiveData;
} }
...@@ -51,4 +51,11 @@ public interface BusProjectService { ...@@ -51,4 +51,11 @@ public interface BusProjectService {
List<Map<String,Object>> queryBusProjectByUser(Map<String,Object> map); List<Map<String,Object>> queryBusProjectByUser(Map<String,Object> map);
/**
* 更改 是否接收数据 标志位
* @param receiveData
* @return
*/
Integer receiveData(String proId, Integer receiveData);
} }
...@@ -60,6 +60,7 @@ public class BusProjectServiceImpl implements BusProjectService { ...@@ -60,6 +60,7 @@ public class BusProjectServiceImpl implements BusProjectService {
bus.setProId(busProject.getProId()); bus.setProId(busProject.getProId());
bus.setSysNm("暖通空调"); bus.setSysNm("暖通空调");
bus.setOnline("1"); bus.setOnline("1");
busProject.setReceiveData(0);
if(findByParam(bus)!=null && findByParam(bus).size()>0){ if(findByParam(bus)!=null && findByParam(bus).size()>0){
line = 0; line = 0;
message = "网关编号重复,项目新增失败"; message = "网关编号重复,项目新增失败";
...@@ -205,4 +206,16 @@ public class BusProjectServiceImpl implements BusProjectService { ...@@ -205,4 +206,16 @@ public class BusProjectServiceImpl implements BusProjectService {
return projectRepository.queryBusProjectByUser(map); return projectRepository.queryBusProjectByUser(map);
} }
@Override
public Integer receiveData(String proId, Integer receiveData) {
//更改的对象
BusProject busProject = new BusProject();
busProject.setReceiveData(receiveData);
//条件
Example example = new Example(BusProject.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("proId", proId);
return projectRepository.updateByExampleSelective(busProject, example);
}
} }
...@@ -36,7 +36,7 @@ public interface BusProjectAreaRepository extends BaseMapper<BusProjectArea> { ...@@ -36,7 +36,7 @@ public interface BusProjectAreaRepository extends BaseMapper<BusProjectArea> {
* @param proId * @param proId
* @return * @return
*/ */
@Select("<script>select * from bus_project_area where pro_id = #{proId}</script>") @Select("<script>select * from bus_project_area where pro_id = #{proId} order by type asc</script>")
List<Map<String,Object>> queryBusProjectArea(@Param("proId") String proId); List<Map<String,Object>> queryBusProjectArea(@Param("proId") String proId);
} }
...@@ -326,13 +326,36 @@ public class OverViewServiceImpl implements OverViewService { ...@@ -326,13 +326,36 @@ public class OverViewServiceImpl implements OverViewService {
@Override @Override
public List<EnergyCountMVo> countDailyPrice(String proId, Integer date) { public List<EnergyCountMVo> countDailyPrice(String proId, Integer date) {
//返回值
List<EnergyCountMVo> resultList = new ArrayList<>();
for (int i = 0; i < 24; i++) {
EnergyCountMVo e = new EnergyCountMVo();
e.setHour(String.valueOf(i));
e.setMoney(new BigDecimal(0));
resultList.add(e);
}
Map<String, String> cal = this.getTime(date); Map<String, String> cal = this.getTime(date);
EnergyCountMVo e = new EnergyCountMVo(); EnergyCountMVo e = new EnergyCountMVo();
e.setProId(proId); e.setProId(proId);
e.setYear(cal.get("year")); e.setYear(cal.get("year"));
e.setMon(cal.get("month")); e.setMon(cal.get("month"));
e.setDay(cal.get("day")); e.setDay(cal.get("day"));
return energyCountMRepository.countDailyPrice(e); List<EnergyCountMVo> list = energyCountMRepository.countDailyPrice(e);
if (list != null) {
for (int i = 0; i < list.size(); i++) {
EnergyCountMVo energyCountMVo = list.get(i);
String hour = energyCountMVo.getHour();
for (int j = 0; j < resultList.size(); j++) {
EnergyCountMVo energyCountMVo1 = resultList.get(j);
String r_hour = energyCountMVo1.getHour();
if (StringUtils.equals(r_hour, hour)) {
energyCountMVo1.setMoney(energyCountMVo.getMoney());
break;
}
}
}
}
return resultList;
} }
@Override @Override
......
...@@ -56,4 +56,11 @@ public interface TotalOriginalService { ...@@ -56,4 +56,11 @@ public interface TotalOriginalService {
String queryDevByPro(String jwnum); String queryDevByPro(String jwnum);
/**
* 查询是否需要保存数据的标志
* @param proId
* @return
*/
Integer findReceiveData(String proId);
} }
package org.rcisoft.business.totaloriginal.service.impl; package org.rcisoft.business.totaloriginal.service.impl;
import org.rcisoft.business.manage.dao.ProjectRepository;
import org.rcisoft.business.manage.entity.BusProject;
import org.rcisoft.business.totaloriginal.dao.TotalSensorRepository; import org.rcisoft.business.totaloriginal.dao.TotalSensorRepository;
import org.rcisoft.business.totaloriginal.entity.TotalSensor; import org.rcisoft.business.totaloriginal.entity.TotalSensor;
import org.rcisoft.core.util.UserUtil; import org.rcisoft.core.util.UserUtil;
...@@ -35,6 +37,8 @@ public class TotalOriginalServiceImpl implements TotalOriginalService { ...@@ -35,6 +37,8 @@ public class TotalOriginalServiceImpl implements TotalOriginalService {
private TotalOriginalRepository totalOriginalRepository; private TotalOriginalRepository totalOriginalRepository;
@Autowired @Autowired
private TotalSensorRepository totalSensorRepository; private TotalSensorRepository totalSensorRepository;
@Autowired
private ProjectRepository projectRepository;
/** /**
...@@ -122,4 +126,12 @@ public class TotalOriginalServiceImpl implements TotalOriginalService { ...@@ -122,4 +126,12 @@ public class TotalOriginalServiceImpl implements TotalOriginalService {
return devStr; return devStr;
} }
@Override
public Integer findReceiveData(String proId) {
BusProject busProject = new BusProject();
busProject.setProId(proId);
BusProject busProject1 = projectRepository.selectOne(busProject);
return busProject1.getReceiveData();
}
} }
...@@ -38,6 +38,14 @@ public class MqttClient { ...@@ -38,6 +38,14 @@ public class MqttClient {
try { try {
JSONObject jb = JSONArray.parseObject(content.substring(1,content.length()-1)); JSONObject jb = JSONArray.parseObject(content.substring(1,content.length()-1));
String jwnum = jb.getString("PHONE");//网关编号 String jwnum = jb.getString("PHONE");//网关编号
//根据网关(proId)判断,如果不需要接收数据,直接退出
Integer receiveData = totalService.findReceiveData(jwnum);
if (receiveData == 0) {
System.out.println("--------------------------------------------------------当前项目不需要存储数据------------------------------------------------------------------");
return;
}
String time = jb.getString("TIME");//时间 String time = jb.getString("TIME");//时间
JSONObject jbody = jb.getJSONObject("body");//数据体 JSONObject jbody = jb.getJSONObject("body");//数据体
//String time = DateUtil.getSimepleDate("yyyyMMddHHmmss",new Date()); //String time = DateUtil.getSimepleDate("yyyyMMddHHmmss",new Date());
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
<result column="ENERGY_POTENTIAL" jdbcType="DECIMAL" property="energyPotential"/> <result column="ENERGY_POTENTIAL" jdbcType="DECIMAL" property="energyPotential"/>
<result column="TOPOLOGY" jdbcType="VARCHAR" property="topology"/> <result column="TOPOLOGY" jdbcType="VARCHAR" property="topology"/>
<result column="SHUT_POWER" jdbcType="DECIMAL" property="shutPower"/> <result column="SHUT_POWER" jdbcType="DECIMAL" property="shutPower"/>
<result column="RECEIVE_DATA" jdbcType="DECIMAL" property="receiveData"/>
</resultMap> </resultMap>
<!--<cache type="${corePackag!}.util.RedisCache"/>--> <!--<cache type="${corePackag!}.util.RedisCache"/>-->
......
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