|
|
@@ -0,0 +1,55 @@
|
|
|
+package com.java110.job.cmd.iot;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.java110.core.annotation.Java110Cmd;
|
|
|
+import com.java110.core.context.ICmdDataFlowContext;
|
|
|
+import com.java110.core.event.cmd.Cmd;
|
|
|
+import com.java110.core.event.cmd.CmdEvent;
|
|
|
+import com.java110.dto.owner.OwnerDto;
|
|
|
+import com.java110.intf.user.IOwnerInnerServiceSMO;
|
|
|
+import com.java110.intf.user.IOwnerV1InnerServiceSMO;
|
|
|
+import com.java110.job.adapt.hcIotNew.http.ISendIot;
|
|
|
+import com.java110.utils.exception.CmdException;
|
|
|
+import com.java110.utils.util.Assert;
|
|
|
+import com.java110.vo.ResultVo;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+
|
|
|
+import java.text.ParseException;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Java110Cmd(serviceCode = "iot.openAccessControlDoor")
|
|
|
+public class OpenAccessControlDoorCmd extends Cmd {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IOwnerInnerServiceSMO ownerInnerServiceSMOImpl;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISendIot sendIotImpl;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
|
|
|
+ Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含小区信息");
|
|
|
+ Assert.hasKeyAndValue(reqJson, "machineCode", "请求报文中未包含设备信息");
|
|
|
+ Assert.hasKeyAndValue(reqJson, "memberId", "请求报文中未包含员工");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
|
|
|
+ OwnerDto ownerDto = new OwnerDto();
|
|
|
+ ownerDto.setCommunityId(reqJson.getString("communityId"));
|
|
|
+ ownerDto.setMemberId(reqJson.getString("memberId"));
|
|
|
+ List<OwnerDto> ownerDtos = ownerInnerServiceSMOImpl.queryOwnerMembers(ownerDto);
|
|
|
+ Assert.listOnlyOne(ownerDtos, "存在多条业主数据或未找到业主数据");
|
|
|
+
|
|
|
+ reqJson.put("link",ownerDtos.get(0).getLink());
|
|
|
+ reqJson.put("iotApiCode","openAccessControlDoorBmoImpl");
|
|
|
+
|
|
|
+ ResultVo resultVo = sendIotImpl.post("/iot/api/common.openCommonApi", reqJson);
|
|
|
+
|
|
|
+ if (resultVo.getCode() != ResultVo.CODE_OK) {
|
|
|
+ throw new CmdException(resultVo.getMsg());
|
|
|
+ }
|
|
|
+
|
|
|
+ context.setResponseEntity(ResultVo.createResponseEntity(resultVo));
|
|
|
+ }
|
|
|
+}
|