|
@@ -1,14 +1,26 @@
|
|
|
package com.sckj.opc.service;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.sckj.common.core.PageResult;
|
|
|
+import com.sckj.common.validate.commons.PageValidate;
|
|
|
import com.sckj.opc.dto.OPCPointDTO;
|
|
|
import com.sckj.opc.entity.OPCPoint;
|
|
|
import com.sckj.opc.mapper.OPCPointMapper;
|
|
|
+import com.sckj.opc.validate.TOpcPointCreateValidate;
|
|
|
+import com.sckj.opc.validate.TOpcPointSearchValidate;
|
|
|
+import com.sckj.opc.validate.TOpcPointUpdateValidate;
|
|
|
+import com.sckj.opc.vo.TOpcPointDetailVo;
|
|
|
+import com.sckj.opc.vo.TOpcPointListedVo;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.Assert;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @Author feng
|
|
@@ -16,12 +28,142 @@ import java.util.Map;
|
|
|
* @Description TODO
|
|
|
*/
|
|
|
@Service
|
|
|
-public class OPCPointServiceImpl extends ServiceImpl<OPCPointMapper, OPCPoint> {
|
|
|
+public class OPCPointServiceImpl extends ServiceImpl<OPCPointMapper, OPCPoint> {
|
|
|
|
|
|
@Resource
|
|
|
- OPCPointMapper opcPointMapper;
|
|
|
+ OPCPointMapper tOpcPointMapper;
|
|
|
|
|
|
- public OPCPointDTO selectInfoWithServer(OPCPoint opcPoint){
|
|
|
- return opcPointMapper.selectInfoWithServer(opcPoint);
|
|
|
+ public OPCPointDTO selectInfoWithServer(OPCPoint opcPoint) {
|
|
|
+ return tOpcPointMapper.selectInfoWithServer(opcPoint);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * OPC订阅点列表
|
|
|
+ *
|
|
|
+ * @param pageValidate 分页参数
|
|
|
+ * @param searchValidate 搜索参数
|
|
|
+ * @return PageResult<TOpcPointListedVo>
|
|
|
+ * @author LikeAdmin
|
|
|
+ */
|
|
|
+
|
|
|
+ public PageResult<TOpcPointListedVo> list(PageValidate pageValidate, TOpcPointSearchValidate searchValidate) {
|
|
|
+ Integer page = pageValidate.getPageNo();
|
|
|
+ Integer limit = pageValidate.getPageSize();
|
|
|
+
|
|
|
+ QueryWrapper<OPCPoint> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.orderByDesc("id");
|
|
|
+
|
|
|
+ tOpcPointMapper.setSearch(queryWrapper, searchValidate, new String[]{
|
|
|
+ "=:namespaceIndex@namespace_index:int",
|
|
|
+ "=:opcServerId@opc_server_id:long",
|
|
|
+ "=:status:str",
|
|
|
+ "=:period:int",
|
|
|
+ "like:pointName@point_name:str",
|
|
|
+ "=:dataType@data_type:str",
|
|
|
+ "like:pointDesc@point_desc:str",
|
|
|
+ "=:opcProtocol@opc_protocol:str",
|
|
|
+ "=:remark:str",
|
|
|
+ });
|
|
|
+
|
|
|
+ IPage<OPCPoint> iPage = tOpcPointMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
|
|
+
|
|
|
+ List<TOpcPointListedVo> list = new LinkedList<>();
|
|
|
+ for (OPCPoint item : iPage.getRecords()) {
|
|
|
+ TOpcPointListedVo vo = new TOpcPointListedVo();
|
|
|
+ BeanUtils.copyProperties(item, vo);
|
|
|
+ list.add(vo);
|
|
|
+ }
|
|
|
+
|
|
|
+ return PageResult.iPageHandle(iPage.getTotal(), iPage.getCurrent(), iPage.getSize(), list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * OPC订阅点详情
|
|
|
+ *
|
|
|
+ * @param id 主键参数
|
|
|
+ * @return OPCPoint
|
|
|
+ * @author LikeAdmin
|
|
|
+ */
|
|
|
+
|
|
|
+ public TOpcPointDetailVo detail(Integer id) {
|
|
|
+ OPCPoint model = tOpcPointMapper.selectOne(
|
|
|
+ new QueryWrapper<OPCPoint>()
|
|
|
+ .eq("id", id)
|
|
|
+ .last("limit 1"));
|
|
|
+
|
|
|
+ Assert.notNull(model, "数据不存在");
|
|
|
+
|
|
|
+ TOpcPointDetailVo vo = new TOpcPointDetailVo();
|
|
|
+ BeanUtils.copyProperties(model, vo);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * OPC订阅点新增
|
|
|
+ *
|
|
|
+ * @param createValidate 参数
|
|
|
+ * @author LikeAdmin
|
|
|
+ */
|
|
|
+
|
|
|
+ public void add(TOpcPointCreateValidate createValidate) {
|
|
|
+ OPCPoint model = new OPCPoint();
|
|
|
+ model.setNamespaceIndex(createValidate.getNamespaceIndex());
|
|
|
+ model.setOpcServerId(createValidate.getOpcServerId());
|
|
|
+ model.setStatus(createValidate.getStatus());
|
|
|
+ model.setPeriod(createValidate.getPeriod());
|
|
|
+ model.setPointName(createValidate.getPointName());
|
|
|
+ model.setDataType(createValidate.getDataType());
|
|
|
+ model.setPointDesc(createValidate.getPointDesc());
|
|
|
+ model.setOpcProtocol(createValidate.getOpcProtocol());
|
|
|
+ model.setRemark(createValidate.getRemark());
|
|
|
+ tOpcPointMapper.insert(model);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * OPC订阅点编辑
|
|
|
+ *
|
|
|
+ * @param updateValidate 参数
|
|
|
+ * @author LikeAdmin
|
|
|
+ */
|
|
|
+
|
|
|
+ public void edit(TOpcPointUpdateValidate updateValidate) {
|
|
|
+ OPCPoint model = tOpcPointMapper.selectOne(
|
|
|
+ new QueryWrapper<OPCPoint>()
|
|
|
+ .eq("id", updateValidate.getId())
|
|
|
+ .last("limit 1"));
|
|
|
+
|
|
|
+ Assert.notNull(model, "数据不存在!");
|
|
|
+
|
|
|
+ model.setId(updateValidate.getId());
|
|
|
+ model.setNamespaceIndex(updateValidate.getNamespaceIndex());
|
|
|
+ model.setOpcServerId(updateValidate.getOpcServerId());
|
|
|
+ model.setStatus(updateValidate.getStatus());
|
|
|
+ model.setPeriod(updateValidate.getPeriod());
|
|
|
+ model.setPointName(updateValidate.getPointName());
|
|
|
+ model.setDataType(updateValidate.getDataType());
|
|
|
+ model.setPointDesc(updateValidate.getPointDesc());
|
|
|
+ model.setOpcProtocol(updateValidate.getOpcProtocol());
|
|
|
+ model.setRemark(updateValidate.getRemark());
|
|
|
+ tOpcPointMapper.updateById(model);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * OPC订阅点删除
|
|
|
+ *
|
|
|
+ * @param id 主键ID
|
|
|
+ * @author LikeAdmin
|
|
|
+ */
|
|
|
+
|
|
|
+ public void del(Integer id) {
|
|
|
+ OPCPoint model = tOpcPointMapper.selectOne(
|
|
|
+ new QueryWrapper<OPCPoint>()
|
|
|
+ .eq("id", id)
|
|
|
+ .last("limit 1"));
|
|
|
+
|
|
|
+ Assert.notNull(model, "数据不存在!");
|
|
|
+
|
|
|
+ tOpcPointMapper.delete(new QueryWrapper<OPCPoint>().eq("id", id));
|
|
|
+ }
|
|
|
+
|
|
|
}
|