Commit c30b95e5 authored by yff's avatar yff

Merge branch 'master' of gitlab.gavelinfo.com:gavelinfo/kwell-mes

parents 8f8a95a1 fc051672
......@@ -108,6 +108,18 @@ public class UpointController extends BaseController {
return buildReturnData(records, DataPointItem.class);
}
/**
* 获取温度,湿度
* @param param
* @return
*/
@RequestMapping(value = "queryweatherpoint", method = RequestMethod.POST)
@ResponseBody
public Object queryweatherpoint(@RequestBody JSONObject param) {
List<DataPointItem> records = upointService.queryweatherpoint();
return buildReturnData(records, DataPointItem.class);
}
@ResourcePermissions(SystemOperation.BottonResource.EXPORT)
@RequestMapping(value = BaseURL.EXPORT, method = RequestMethod.POST)
@ResponseBody
......
......@@ -14,4 +14,6 @@ public interface UpointService extends BaseEditService {
public RecordSet<UpointVO> query(UpointCondition condition);
public List<DataPointItem> queryringpoint();
public List<DataPointItem> queryweatherpoint();
}
package com.gavel.kwell.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.gavel.common.base.entity.BaseEntity;
import com.gavel.common.base.service.impl.BaseEditServiceImpl;
import com.gavel.common.utils.NumberUtils;
import com.gavel.common.utils.RedisConnection;
import com.gavel.common.utils.StringUtils;
import com.gavel.kwell.dao.UpointDao;
import com.gavel.kwell.persistent.Upoint;
import com.gavel.kwell.service.UpointService;
......@@ -49,37 +47,60 @@ public class UpointServiceImpl extends BaseEditServiceImpl implements UpointServ
}
@Override
public boolean postValid(BaseEntity entity) {
if(entity!=null && entity instanceof Upoint) {
Upoint uplcpoint = (Upoint) entity;
if(StringUtils.equals(uplcpoint.getType(), PointTypeEnum.WORK.getId())){
if(StringUtils.isEmpty(uplcpoint.getSign())){
throwReturnMessage("当选择类型为生产点位,合格标志不能为空!");
return false;
}
public List<DataPointItem> queryringpoint() {
try {
List<Upoint> ponitList = upointDao.queryList(PointTypeEnum.RIGN.getId());
if(ponitList==null || ponitList.size()==0){
logger.error("点位信息未配置,请检查!");
return new ArrayList<>();
}
}
return true;
}
List<String> tagList=ponitList.stream().map(Upoint::getCode).collect(Collectors.toList());
@Override
public void beforePost(BaseEntity entity) {
if(entity!=null && entity instanceof Upoint) {
Upoint uplcpoint = (Upoint) entity;
if(!StringUtils.equals(uplcpoint.getType(), PointTypeEnum.WORK.getId())){
uplcpoint.setSign("");
Map<String, Object> valueMap = redisConnection.multiGet(tagList);
if (valueMap == null || valueMap.size()==0 ) {
logger.error("读取采集点信息失败!");
return ponitList.stream().map( (Upoint p) -> new DataPointItem(p.getCode(),p.getName())).collect(Collectors.toList());
}
List<DataPointItem> dataPointItems = new ArrayList<DataPointItem>();
for(Upoint uplcpoint : ponitList){
DataPointItem item = new DataPointItem(uplcpoint.getCode(),uplcpoint.getName());
if(valueMap.containsKey(uplcpoint.getCode())){
String jsonStr = (String)valueMap.get(uplcpoint.getCode());
try {
JSONObject json = JSONObject.parseObject(jsonStr);
item.setTimestamp(json.getLong("time"));
int quality = json.getInteger("quality");
Integer value = json.getInteger("value");
if(NumberUtils.isZero(quality)){
value=-1;
}
item.setValue(value);
} catch (Exception e) {
logger.error(e.getMessage() + ": " + jsonStr);
}
}
dataPointItems.add(item);
}
return dataPointItems;
} catch (Exception e) {
logger.error("数据点采集出错!", e);
}
return new ArrayList<>();
}
@Override
public List<DataPointItem> queryringpoint() {
public List<DataPointItem> queryweatherpoint() {
try {
List<Upoint> ponitList = upointDao.queryList(PointTypeEnum.RIGN.getId());
List<Upoint> ponitList = upointDao.queryList(PointTypeEnum.WEATHER.getId());
if(ponitList==null || ponitList.size()==0){
logger.error("点位信息未配置,请检查!");
return new ArrayList<>();
......@@ -106,7 +127,7 @@ public class UpointServiceImpl extends BaseEditServiceImpl implements UpointServ
int quality = json.getInteger("quality");
Integer value = json.getInteger("value");
if(NumberUtils.isZero(quality)){
value=-1;
value=-1;
}
item.setValue(value);
} catch (Exception e) {
......@@ -121,17 +142,5 @@ public class UpointServiceImpl extends BaseEditServiceImpl implements UpointServ
logger.error("数据点采集出错!", e);
}
return new ArrayList<>();
/* List<DataPointItem> dataPointItems = new ArrayList<DataPointItem>();
dataPointItems.add(new DataPointItem("R1",new Date().getTime(),1,"R1",0));
dataPointItems.add(new DataPointItem("R2",new Date().getTime(),1,"R2",0));
dataPointItems.add(new DataPointItem("R3",new Date().getTime(),1,"R3",0));
dataPointItems.add(new DataPointItem("R4",new Date().getTime(),1,"R4",1));
dataPointItems.add(new DataPointItem("R5",new Date().getTime(),1,"R5",1));
dataPointItems.add(new DataPointItem("R6",new Date().getTime(),1,"R6",1));
dataPointItems.add(new DataPointItem("R7",new Date().getTime(),1,"R7",-1));
dataPointItems.add(new DataPointItem("R8",new Date().getTime(),1,"R8",-1));
return dataPointItems;*/
}
}
......@@ -8,8 +8,7 @@ import java.util.List;
public enum PointTypeEnum {
RIGN("RIGN", "手环点位"),
WEATHER("WEATHER","温湿度点位"),
WORK("WORK","生产点位");
WEATHER("WEATHER","温湿度点位");
private String id;
private String name;
......
......@@ -22,7 +22,7 @@
<div class="gui-col-sm12">
<label class="gui-form-label">类型:</label>
<div class="gui-input-block">
<input type="text" name="type" data-toggle="gui-textbox" data-options="" readonly>
<input type="text" name="type" data-toggle="gui-textbox" data-options="">
</div>
</div>
</div>
......
......@@ -21,6 +21,12 @@
<input type="text" name="condition" class="gui-textbox" style="width: 100%">
</div>
</div>
<div class="gui-col-sm3">
<label class="gui-form-label">类型:</label>
<div class="gui-input-block">
<input type="text" name="type" class="gui-textbox" style="width: 100%">
</div>
</div>
</li>
</ul>
<span class="toolbar-search-span"><a class="toolbar-search" href="javascript:void(0)"></a></span>
......
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