Commit b316410d43ff1386529e1c3661673c71b5b59341
Merge branch 'branch_0808' of http://192.168.1.195:9998/ZTEITS-Developers/zteits…
…-bcp-portal.git into branch_0808
Showing
2 changed files
with
161 additions
and
0 deletions
src/main/java/com/zteits/irain/portal/web/fangle/FangleEqpController.java
0 → 100644
| 1 | +package com.zteits.irain.portal.web.fangle; | ||
| 2 | + | ||
| 3 | +import java.text.ParseException; | ||
| 4 | +import java.text.SimpleDateFormat; | ||
| 5 | +import java.util.Date; | ||
| 6 | +import java.util.HashMap; | ||
| 7 | +import java.util.Map; | ||
| 8 | +import java.util.Map.Entry; | ||
| 9 | + | ||
| 10 | +import org.slf4j.Logger; | ||
| 11 | +import org.slf4j.LoggerFactory; | ||
| 12 | +import org.springframework.beans.BeanUtils; | ||
| 13 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 14 | +import org.springframework.beans.factory.annotation.Value; | ||
| 15 | +import org.springframework.web.bind.annotation.RequestBody; | ||
| 16 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 17 | +import org.springframework.web.bind.annotation.RequestMethod; | ||
| 18 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 19 | +import org.springframework.web.bind.annotation.RestController; | ||
| 20 | + | ||
| 21 | +import com.alibaba.dubbo.common.utils.StringUtils; | ||
| 22 | +import com.alibaba.fastjson.JSON; | ||
| 23 | +import com.alibaba.fastjson.JSONArray; | ||
| 24 | +import com.alibaba.fastjson.JSONObject; | ||
| 25 | +import com.clouds.common.utils.ExceptionUtil; | ||
| 26 | +import com.clouds.common.web.BizController; | ||
| 27 | +import com.zteits.clouds.api.apibase.bean.BaseInfo; | ||
| 28 | +import com.zteits.clouds.api.apibase.bean.BizResult; | ||
| 29 | +import com.zteits.clouds.api.apibase.constants.ErrorType; | ||
| 30 | +import com.zteits.clouds.api.apibase.exception.BizException; | ||
| 31 | +import com.zteits.clouds.api.dto.park.param.BerthStateRequest; | ||
| 32 | +import com.zteits.clouds.api.dto.park.param.EqpHeartBeatRequest; | ||
| 33 | +import com.zteits.clouds.api.dto.park.param.EqpLogRequest; | ||
| 34 | +import com.zteits.clouds.api.dto.park.param.InParkingRequest; | ||
| 35 | +import com.zteits.clouds.api.dto.park.param.OutParkingRequest; | ||
| 36 | +import com.zteits.clouds.api.dto.park.param.InterfaceLogSaveRequest; | ||
| 37 | +import com.zteits.clouds.api.service.park.EqpBerthsService; | ||
| 38 | +import com.zteits.clouds.api.service.park.InterfaceLogService; | ||
| 39 | +import com.zteits.irain.portal.common.AESPlus; | ||
| 40 | +import com.zteits.irain.portal.common.HttpClientTutorial; | ||
| 41 | +import com.zteits.irain.portal.constant.IRainResultEnum; | ||
| 42 | +import com.zteits.irain.portal.constant.ParkConstant.InterfaceLog; | ||
| 43 | +import com.zteits.irain.portal.service.interfaces.inoutparklot.InOutParkLotReportService; | ||
| 44 | +import com.zteits.irain.portal.service.interfaces.inoutparklot.param.RecordInParkLotRequest; | ||
| 45 | +import com.zteits.irain.portal.service.interfaces.inoutparklot.param.RecordOutParkLotRequest; | ||
| 46 | +import com.zteits.irain.portal.vo.irain.IRainResponseVO; | ||
| 47 | + | ||
| 48 | +import io.swagger.annotations.Api; | ||
| 49 | +import io.swagger.annotations.ApiOperation; | ||
| 50 | + | ||
| 51 | +/** | ||
| 52 | + * Copyright: Copyright (c) 2017 ZTE-ITS | ||
| 53 | + * | ||
| 54 | + * @ClassName: FangleEqpController.java | ||
| 55 | + * @Description:方格尔设备同步 | ||
| 56 | + * @version: v1.0.0 | ||
| 57 | + * @author: wangfei | ||
| 58 | + * @date: 2017年4月20日 下午17:51:45 | ||
| 59 | + * Modification History: | ||
| 60 | + * Date Author Version Description | ||
| 61 | + *---------------------------------------------------------* | ||
| 62 | + * 2017年8月21日 wangfei v1.0.0 创建 | ||
| 63 | + */ | ||
| 64 | +@Api(value="方格尔设备同步",description="方格尔设备同步") | ||
| 65 | +@RestController | ||
| 66 | +@RequestMapping("/fangle") | ||
| 67 | +public class FangleEqpController extends BizController{ | ||
| 68 | + | ||
| 69 | + | ||
| 70 | + private static final Logger logger = LoggerFactory.getLogger(FangleEqpController.class); | ||
| 71 | + @Value("${project.syscode}") | ||
| 72 | + private String sysCode; | ||
| 73 | + @Autowired | ||
| 74 | + private EqpBerthsService eqpBerthsService; | ||
| 75 | + | ||
| 76 | + @ApiOperation("泊位信息同步") | ||
| 77 | + @RequestMapping(value = "/synBerthInfo",method = RequestMethod.POST) | ||
| 78 | + public BizResult<Map<String, String>> synBerthInfo(@RequestBody String param){ | ||
| 79 | + logger.info("同步入参:" + param); | ||
| 80 | + | ||
| 81 | + JSONObject jsonObject = JSONObject.parseObject(param); | ||
| 82 | + String reqList = jsonObject.getString("pushdata"); | ||
| 83 | + JSONArray jsonArray = JSON.parseArray(reqList); | ||
| 84 | + BerthStateRequest request = JSON.parseObject(jsonArray.getString(0),BerthStateRequest.class); | ||
| 85 | + BaseInfo info = new BaseInfo(); | ||
| 86 | + request.setBaseRequest(info); | ||
| 87 | + request.setSysCode(sysCode); | ||
| 88 | + //数据转换 | ||
| 89 | + EqpLogRequest eqpLogRequest = new EqpLogRequest(); | ||
| 90 | + BeanUtils.copyProperties(request, eqpLogRequest); | ||
| 91 | + eqpLogRequest.setBerthOutNo(request.getBerthcode()); | ||
| 92 | + eqpLogRequest.setEqpType(1);//地磁 | ||
| 93 | + if(request.getBerthstatus().equals("1") || request.getBerthstatus().equals("2")){ | ||
| 94 | + eqpLogRequest.setEqpStatus("1");//设备状态 1-正常 | ||
| 95 | + } | ||
| 96 | + if(request.getBerthstatus().equals("3")){ | ||
| 97 | + eqpLogRequest.setEqpStatus("0");//设备状态 0-故障 | ||
| 98 | + } | ||
| 99 | + if(request.getBerthstatus().equals("2")){ | ||
| 100 | + eqpLogRequest.setBerthState("0");//泊位状态 0-空闲 | ||
| 101 | + } | ||
| 102 | + if(request.getBerthstatus().equals("1")){ | ||
| 103 | + eqpLogRequest.setBerthState("1");//泊位状态 1- 占用 | ||
| 104 | + } | ||
| 105 | + eqpLogRequest.setElectricity(request.getElectricity()); | ||
| 106 | + eqpLogRequest.setVoltag(request.getVoltage()); | ||
| 107 | + | ||
| 108 | + BizResult<Map<String, String>> result = eqpBerthsService.synBerthState(eqpLogRequest); | ||
| 109 | + return result; | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + @ApiOperation("设备心跳信息同步") | ||
| 113 | + @RequestMapping(value = "/synEqpHeartBeatInfo",method = RequestMethod.POST) | ||
| 114 | + public BizResult<Map<String, String>> synEqpHeartBeatInfo(@RequestBody String param){ | ||
| 115 | + logger.info("同步入参:" + param); | ||
| 116 | + | ||
| 117 | + JSONObject jsonObject = JSONObject.parseObject(param); | ||
| 118 | + String reqList = jsonObject.getString("pushdata"); | ||
| 119 | + JSONArray jsonArray = JSON.parseArray(reqList); | ||
| 120 | + EqpHeartBeatRequest request = JSON.parseObject(jsonArray.getString(0),EqpHeartBeatRequest.class); | ||
| 121 | + BaseInfo info = new BaseInfo(); | ||
| 122 | + request.setBaseRequest(info); | ||
| 123 | + request.setSysCode(sysCode); | ||
| 124 | + | ||
| 125 | + //数据转换 | ||
| 126 | + EqpLogRequest eqpLogRequest = new EqpLogRequest(); | ||
| 127 | + BeanUtils.copyProperties(request, eqpLogRequest); | ||
| 128 | + eqpLogRequest.setEqpNo(request.getEquipmentCode()); | ||
| 129 | + if(request.getEquipmentType().equals("1")){ | ||
| 130 | + eqpLogRequest.setEqpType(4);//设备类型 4-车检器 | ||
| 131 | + } | ||
| 132 | + if(request.getEquipmentType().equals("2")){ | ||
| 133 | + eqpLogRequest.setEqpType(5);//设备类型 5-网关 | ||
| 134 | + } | ||
| 135 | + if(request.getEquipmentType().equals("3")){ | ||
| 136 | + eqpLogRequest.setEqpType(6);//设备类型 6-中继器 | ||
| 137 | + } | ||
| 138 | + if(request.getEquipmentStatus().equals("1")){ | ||
| 139 | + eqpLogRequest.setEqpStatus("1");//设备状态 1-正常 | ||
| 140 | + } | ||
| 141 | + if(request.getEquipmentStatus().equals("2")){ | ||
| 142 | + eqpLogRequest.setEqpStatus("0");//设备状态 0-故障 | ||
| 143 | + } | ||
| 144 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); | ||
| 145 | + Date date; | ||
| 146 | + try { | ||
| 147 | + date = sdf.parse(request.getPushTime()); | ||
| 148 | + eqpLogRequest.setHeartbeatTime(date); | ||
| 149 | + } catch (ParseException e) { | ||
| 150 | + e.printStackTrace(); | ||
| 151 | + } | ||
| 152 | + BizResult<Map<String, String>> result = eqpBerthsService.synBerthState(eqpLogRequest); | ||
| 153 | + return result; | ||
| 154 | + } | ||
| 155 | + | ||
| 156 | +} |
src/main/resources/dubbo/dubbo-park-consumer.xml
| @@ -138,4 +138,9 @@ | @@ -138,4 +138,9 @@ | ||
| 138 | version="${spring.dubbo.provider.version}" | 138 | version="${spring.dubbo.provider.version}" |
| 139 | timeout="30000"/> | 139 | timeout="30000"/> |
| 140 | 140 | ||
| 141 | + <!-- 泊位状态同步 --> | ||
| 142 | + <dubbo:reference id="eqpBerthsService" interface="com.zteits.clouds.api.service.park.EqpBerthsService" | ||
| 143 | + version="${spring.dubbo.provider.version}" | ||
| 144 | + timeout="30000"/> | ||
| 145 | + | ||
| 141 | </beans> | 146 | </beans> |
| 142 | \ No newline at end of file | 147 | \ No newline at end of file |