Browse Source

Merge branch 'demo_' of http://123.60.19.203:8088/hitch/hitch-sb into demo_

guarantee-lsq 2 years ago
parent
commit
46e3a51350

+ 1 - 1
platform-iec/src/main/java/com/platform/iec/IecApplication.java

@@ -35,7 +35,7 @@ public class IecApplication implements CommandLineRunner {
         log.info("启动主服务,监听iec……………………………………");
         Iec104Config iec104Config  = new Iec104Config();
         iec104Config.setFrameAmountMax((short) 1);
-        iec104Config.setTerminnalAddress((short) 1);
+        iec104Config.setTerminnalAddress((short) 2);
         Iec104MasterFactory.createTcpClientMaster(Iec104Util.host, Iec104Util.port).setDataHandler(new MasterSysDataHandler()).setConfig(iec104Config).run();
         Thread.sleep(1000000);
     }

+ 38 - 0
platform-iec/src/main/java/com/ydl/iec/iec104/common/BasicInstruction104.java

@@ -181,4 +181,42 @@ public class BasicInstruction104 {
 		MessageDetail ruleDetail104 = new MessageDetail(control);
 		return ruleDetail104;
 	}
+
+
+	/**
+	 *
+	 * @Title: getGeneralCallRuleDetail104
+	 * @Description: 电度总召唤指令
+	 * @param @return
+	 * @param @throws IOException
+	 * @return MessageDetail
+	 * @throws
+	 */
+	public static MessageDetail getGeneralCallRuleDetail104Degree() {
+		TypeIdentifierEnum typeIdentifierEnum = TypeIdentifierEnum.generalCallDegree;
+		int sq = 0;
+		boolean isContinuous = sq == 0 ? false : true;
+		// 接收序号
+		short accept = 0;
+		// 发送序号
+		short send = 0;
+		byte[] control = Iec104Util.getIcontrol(accept, send);
+		// 传输原因
+		short transferReason = 6;
+		boolean isTest = false;
+		boolean isPn = true;
+		// 终端地址 实际发生的时候会被替换
+		short terminalAddress = 1;
+		// 消息地址 总召唤地址为0
+		int messageAddress = 0;
+		QualifiersEnum qualifiers = QualifiersEnum.generalCallGroupingQualifiersDegree;
+		List<MessageInfo> messages = new ArrayList<>();
+//		MessageInfo message = new MessageInfo();
+//		message.setQualifiersType(qualifiers);
+//		message.setMessageInfos(new byte[] {});
+//		messages.add(message);
+		MessageDetail ruleDetail104 = new MessageDetail(control, typeIdentifierEnum, isContinuous, isTest, isPn, transferReason,
+				terminalAddress, messageAddress, messages, null, qualifiers);
+		return ruleDetail104;
+	}
 }

+ 41 - 0
platform-iec/src/main/java/com/ydl/iec/iec104/core/ScheduledTaskPool.java

@@ -49,15 +49,27 @@ public class ScheduledTaskPool {
 	 * 发送总召唤指令状态
 	 */
 	private Boolean senGeneralCallStatus = false;
+	/**
+	 * 发送总召唤指令状态
+	 */
+	private Boolean senGeneralCallStatusDegree = false;
 	/**
 	 * 启动指令收到确认后固定时间内发送总召唤指令
 	 */
 	private Thread generalCallTThread;
+	/**
+	 * 启动指令收到确认后固定时间内发送电度总召唤指令
+	 */
+	private Thread generalCallTThreadDegree;
 
 	public Thread getGeneralCallTThread(){
 		return generalCallTThread;
 	}
 
+	public Thread getGeneralCallTThreadDegree(){
+		return generalCallTThreadDegree;
+	}
+
 	public ScheduledTaskPool(ChannelHandlerContext ctx) {
 		this.ctx = ctx;
 	}
@@ -175,4 +187,33 @@ public class ScheduledTaskPool {
 		}
 	}
 
+	/**
+	 *
+	 * @Title: sendGeneralCall
+	 * @Description: 发送电度总召唤
+	 */
+	public void sendGeneralCallDegree() {
+		synchronized (senGeneralCallStatusDegree) {
+			if (generalCallTThreadDegree != null && generalCallTThreadDegree.getState() == Thread.State.TERMINATED) {
+				senGeneralCallStatusDegree = true;
+				generalCallTThreadDegree.start();
+			} else if (generalCallTThreadDegree == null) {
+				senGeneralCallStatusDegree = true;
+				generalCallTThreadDegree = new Thread(() -> {
+					LOGGER.error("sendTestStatus: " + sendTestStatus);
+					while (sendTestStatus) {
+						try {
+							LOGGER.error("发送电度总召唤指令");
+							ctx.channel().writeAndFlush(BasicInstruction104.getGeneralCallRuleDetail104Degree());
+							Thread.sleep(1000 * 60 * 15);// 15分钟
+						} catch (Exception e) {
+							e.printStackTrace();
+						}
+					}
+				});
+				generalCallTThreadDegree.start();
+			}
+		}
+	}
+
 }

+ 4 - 0
platform-iec/src/main/java/com/ydl/iec/iec104/enums/QualifiersEnum.java

@@ -18,6 +18,10 @@ public enum QualifiersEnum {
 	 * 总召唤限定词 支持 老版的分组
 	 */
 	generalCallGroupingQualifiers(TypeIdentifierEnum.generalCall, 0x14),
+	/**
+	 * 电度总召唤限定词 支持 老版的分组
+	 */
+	generalCallGroupingQualifiersDegree(TypeIdentifierEnum.generalCallDegree, 0x45),
 	/**
 	 * 复位进程限定词
 	 */

+ 4 - 0
platform-iec/src/main/java/com/ydl/iec/iec104/enums/TypeIdentifierEnum.java

@@ -70,6 +70,10 @@ public enum TypeIdentifierEnum {
 	 * 召唤命令
 	 */
 	generalCall(0x64, 0),
+	/**
+	 * 电度召唤命令
+	 */
+	generalCallDegree(0x65, 0),
 	/**
 	 * 时钟同步
 	 */

+ 1 - 0
platform-iec/src/main/java/com/ydl/iec/iec104/server/master/handler/SysUframeClientHandler.java

@@ -71,6 +71,7 @@ public class SysUframeClientHandler extends ChannelInboundHandlerAdapter {
 		if (uControlEnum == UControlEnum.TESTFR_YES) {
 			LOGGER.info("收到测试确认指令");
 			Iec104ThreadLocal.getScheduledTaskPool().sendGeneralCall();
+			Iec104ThreadLocal.getScheduledTaskPool().sendGeneralCallDegree();
 		} else if (uControlEnum == UControlEnum.STOPDT_YES) {
 			LOGGER.info("收到停止确认指令");
 		} else if (uControlEnum == UControlEnum.STARTDT_YES) {

+ 40 - 0
platform-rest/src/main/java/com/platform/rest/controller/bigScreen/SbInfoScreenController.java

@@ -0,0 +1,40 @@
+package com.platform.rest.controller.bigScreen;
+
+import com.platform.common.util.R;
+import com.platform.dao.entity.sb.SbInfo;
+import com.platform.rest.log.annotation.SysLog;
+import com.platform.service.big.BigScreenSbInfoService;
+import com.platform.service.sb.SbInfoService;
+import com.platform.service.upms.SysFileService;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * @Description 融资项目 控制器
+ * @Author future
+ * @Date 2020-02-02 17:28:36
+ * @Version Copyright (c) 2019,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@Slf4j
+@RestController
+@AllArgsConstructor
+@RequestMapping("/big/screens")
+public class SbInfoScreenController {
+
+    private final BigScreenSbInfoService bigScreenSbInfoService;
+
+    /**
+     * 根据线路进行汇总展示
+     *
+     * @return R
+     */
+    @GetMapping("/sb/{lineNum}")
+    public R getGroupByLine(@PathVariable Integer lineNum) {
+        return new R<>(bigScreenSbInfoService.getGroupByLine(lineNum));
+    }
+
+}

+ 75 - 0
platform-service/src/main/java/com/platform/service/big/BigScreenSbInfoService.java

@@ -0,0 +1,75 @@
+package com.platform.service.big;
+
+import com.alibaba.fastjson.JSONObject;
+import com.platform.dao.bean.MyVOPage;
+import com.platform.dao.dto.sb.SbInfoDTO;
+import com.platform.dao.entity.sb.SbInfo;
+import com.platform.dao.vo.report.SbInfoTypeReportVO;
+import com.platform.dao.vo.sb.*;
+import com.platform.service.base.IBaseService;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.time.LocalDate;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description 设备基础信息 service
+ * @Author liuyu
+ * @Date 2020-04-21 21:05:46
+ * @Version Copyright (c) 2019,北京乾元坤和科技有限公司 All rights reserved.
+ */
+public interface BigScreenSbInfoService extends IBaseService<SbInfo, SbInfoDTO> {
+
+    /**
+     * 根据线路分组,返回设备列表,遥测数据明细
+     * {
+     *     lineNum: 1,
+     *     lineName: '梅康一路',
+     *     sbList:[ {
+     *       sbName: ''
+     *       sbNo: '',
+     *       sbId: '',
+     *       measureList: [
+         *       {
+     *              description: '电压',
+         *          result: '0.11',
+         *          unit: 'KV',
+         *          type: '1'
+     *            },
+     *            {
+ *                    description: '电压',
+ *                    result: '0.11',
+ *                    unit: 'KV',
+ *                    type: '1'
+     *             },
+     *         ]
+     *     },
+     *     {
+ *             sbName: ''
+ *             sbNo: '',
+ *             sbId: '',
+ *             measureList: [
+ *                 {
+ *                    description: '电压',
+ *                    result: '0.11',
+ *                    unit: 'KV',
+ *                    type: '1'
+ *                  },
+ *                  {
+ *                      description: '电压',
+ *                      result: '0.11',
+ *                      unit: 'KV',
+ *                      type: '1'
+ *                   },
+ *               ]
+ *           },
+          ]
+      }
+
+     * @param lineNum
+     * @return
+     */
+    JSONObject getGroupByLine(Integer lineNum);
+}

+ 151 - 0
platform-service/src/main/java/com/platform/service/big/impl/BigScreenSbInfoServiceImpl.java

@@ -0,0 +1,151 @@
+package com.platform.service.big.impl;
+
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.date.DateUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageHelper;
+import com.platform.activiti.bean.ActObj;
+import com.platform.activiti.enums.ActApplyEnum;
+import com.platform.common.cache.ConfigCache;
+import com.platform.common.constant.CommonConstants;
+import com.platform.common.enums.DataFilterTypeEnum;
+import com.platform.common.enums.DictTypeEnum;
+import com.platform.common.enums.ResultCode;
+import com.platform.common.exception.BusinessException;
+import com.platform.common.model.UserInfo;
+import com.platform.common.util.*;
+import com.platform.dao.bean.MyVOPage;
+import com.platform.dao.dto.check.CheckStandardDTO;
+import com.platform.dao.dto.part.PartInfoDTO;
+import com.platform.dao.dto.sb.SbInfoDTO;
+import com.platform.dao.dto.sb.SbModelSpareBomDTO;
+import com.platform.dao.dto.upms.SysDeptDTO;
+import com.platform.dao.dto.upms.SysUserDeptDTO;
+import com.platform.dao.dto.workplace.WorkplaceBacklogDTO;
+import com.platform.dao.dto.workplace.WorkplaceBacklogUserDTO;
+import com.platform.dao.entity.check.CheckStandard;
+import com.platform.dao.entity.firm.FirmProducer;
+import com.platform.dao.entity.part.PartInfo;
+import com.platform.dao.entity.part.PartType;
+import com.platform.dao.entity.remote.RemoteMeasure;
+import com.platform.dao.entity.repair.RepairApplicationForm;
+import com.platform.dao.entity.sb.*;
+import com.platform.dao.entity.upms.*;
+import com.platform.dao.enums.*;
+import com.platform.dao.mapper.check.CheckStandardMapper;
+import com.platform.dao.mapper.firm.FirmProducerMapper;
+import com.platform.dao.mapper.part.PartInfoMapper;
+import com.platform.dao.mapper.part.PartTypeMapper;
+import com.platform.dao.mapper.remote.RemoteDegreeMapper;
+import com.platform.dao.mapper.remote.RemoteMeasureMapper;
+import com.platform.dao.mapper.repair.RepairApplicationFormMapper;
+import com.platform.dao.mapper.sb.*;
+import com.platform.dao.mapper.upms.SysDeptMapper;
+import com.platform.dao.mapper.upms.SysDictMapper;
+import com.platform.dao.mapper.upms.SysUserMapper;
+import com.platform.dao.mapper.workplace.WorkplaceBacklogUserMapper;
+import com.platform.dao.util.CustomExcelImportUtil;
+import com.platform.dao.util.ExcelUtil;
+import com.platform.dao.util.MessageTemplateUtil;
+import com.platform.dao.util.UserUtil;
+import com.platform.dao.util.compare.FieldComparedUtils;
+import com.platform.dao.vo.SysUserDeptVO;
+import com.platform.dao.vo.SysUserVO;
+import com.platform.dao.vo.export.sb.ExportSbInfoVO;
+import com.platform.dao.vo.query.upms.SysDeptVO;
+import com.platform.dao.vo.report.SbInfoTypeReportVO;
+import com.platform.dao.vo.sb.*;
+import com.platform.service.base.impl.BaseServiceImpl;
+import com.platform.service.big.BigScreenSbInfoService;
+import com.platform.service.business.ActivitiBusinessService;
+import com.platform.service.check.CheckStandardService;
+import com.platform.service.event.WorkplaceBacklogEvent;
+import com.platform.service.part.PartInfoService;
+import com.platform.service.sb.SbInfoService;
+import com.platform.service.sb.SbModelSpareBomService;
+import com.platform.service.upms.SysDeptRelationService;
+import com.platform.service.upms.SysDeptService;
+import com.platform.service.upms.SysFileService;
+import com.platform.service.upms.SysUserDeptService;
+import com.platform.service.util.CodeFileUtils;
+import com.platform.service.util.ExecuteSql;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.ibatis.exceptions.TooManyResultsException;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.multipart.MultipartFile;
+import tk.mybatis.mapper.weekend.Weekend;
+import tk.mybatis.mapper.weekend.WeekendCriteria;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * @Description 设备基础信息 service 实现类
+ * @Author liuyu
+ * @Date 2020-04-21 21:05:46
+ * @Version Copyright (c) 2019,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@AllArgsConstructor
+@Service("bigScreenSbInfoService")
+@Slf4j
+public class BigScreenSbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbInfoDTO> implements BigScreenSbInfoService {
+    private final RemoteMeasureMapper remoteMeasureMapper;
+    private final RemoteDegreeMapper remoteDegreeMapper;
+    private final SysDictMapper sysDictMapper;
+
+    @Override
+    public JSONObject getGroupByLine(Integer lineNum) {
+        Weekend<SysDict> weekend = new Weekend<>(SysDict.class);
+        WeekendCriteria<SysDict, Object> weekendCriteria = weekend.weekendCriteria();
+        weekendCriteria.andEqualTo(SysDict::getType, DictTypeEnum.REMOTE_LINE).andEqualTo(SysDict::getValue, lineNum);
+        SysDict sysDict = sysDictMapper.selectOneByExample(weekend);
+        if (sysDict == null) {
+            throw new BusinessException("请在数据字典配置设备电力线路,数据值:" + lineNum);
+        }
+        SbInfo sbInfo = new SbInfo();
+        sbInfo.setBaoyangTimes(lineNum);
+        List<SbInfo> list = mapper.select(sbInfo);
+        List<String> ids = list.stream().map(SbInfo::getId).collect(Collectors.toList());
+        // 查询所有的遥测点位
+        Weekend<RemoteMeasure> remoteDegreeWeekend = new Weekend<>(RemoteMeasure.class);
+        WeekendCriteria<RemoteMeasure, Object> remoteDegreeObjectWeekendCriteria = remoteDegreeWeekend.weekendCriteria();
+        remoteDegreeObjectWeekendCriteria.andIn(RemoteMeasure::getSbId, ids);
+        List<RemoteMeasure> remoteMeasureList = remoteMeasureMapper.selectByExample(remoteDegreeWeekend);
+        JSONObject obj = new JSONObject();
+        if(CollectionUtil.isNotEmpty(list)){
+            obj.put("lineNum", lineNum);
+            obj.put("lineName", sysDict.getLabel());
+            JSONArray array = new JSONArray();
+            obj.put("sbList", array);
+            for(SbInfo info : list){
+                JSONObject jsonObject = new JSONObject();
+                array.add(jsonObject);
+                jsonObject.put("sbId", info.getId());
+                jsonObject.put("sbNo", info.getNo());
+                jsonObject.put("sbName", info.getName());
+                JSONArray remoteMeasureArray = new JSONArray();
+                jsonObject.put("measureList", remoteMeasureArray);
+                for(RemoteMeasure remoteMeasure : remoteMeasureList){
+                    if(remoteMeasure.getSbId().equals(info.getId())){
+                        JSONObject remoteMeasureObject = new JSONObject();
+                        remoteMeasureObject.put("description", remoteMeasure.getDescription());
+                        remoteMeasureObject.put("result", remoteMeasure.getResult());
+                        remoteMeasureObject.put("unit", remoteMeasure.getUnit());
+                        remoteMeasureObject.put("type", remoteMeasure.getType());
+                        remoteMeasureArray.add(remoteMeasureObject);
+                    }
+                }
+            }
+        }
+        return obj;
+    }
+}