|
|
@@ -0,0 +1,72 @@
|
|
|
+package com.java110.community.cmd.community;
|
|
|
+
|
|
|
+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.community.CommunityMemberDto;
|
|
|
+import com.java110.dto.data.DatabusDataDto;
|
|
|
+import com.java110.dto.owner.OwnerDto;
|
|
|
+import com.java110.intf.community.ICommunityMemberV1InnerServiceSMO;
|
|
|
+import com.java110.intf.job.IDataBusInnerServiceSMO;
|
|
|
+import com.java110.intf.user.IOwnerV1InnerServiceSMO;
|
|
|
+import com.java110.utils.exception.CmdException;
|
|
|
+import com.java110.utils.util.Assert;
|
|
|
+import com.java110.utils.util.ListUtil;
|
|
|
+import com.java110.vo.ResultVo;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+
|
|
|
+import java.text.ParseException;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 同步小区数据到物联网项目
|
|
|
+ */
|
|
|
+@Java110Cmd(serviceCode = "community.sendCommunityToIot")
|
|
|
+public class SendCommunityToIotCmd extends Cmd {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ICommunityMemberV1InnerServiceSMO communityMemberV1InnerServiceSMOImpl;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IOwnerV1InnerServiceSMO ownerV1InnerServiceSMOImpl;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IDataBusInnerServiceSMO dataBusInnerServiceSMOImpl;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
|
|
|
+
|
|
|
+ Assert.hasKeyAndValue(reqJson, "communityId", "未包含小区ID");
|
|
|
+
|
|
|
+ //todo 查询小区是否存在物业公司
|
|
|
+ CommunityMemberDto communityMemberDto = new CommunityMemberDto();
|
|
|
+ communityMemberDto.setCommunityId(reqJson.getString("communityId"));
|
|
|
+ communityMemberDto.setMemberTypeCd(CommunityMemberDto.MEMBER_TYPE_PROPERTY);
|
|
|
+ List<CommunityMemberDto> communityMemberDtos = communityMemberV1InnerServiceSMOImpl.queryCommunityMembers(communityMemberDto);
|
|
|
+
|
|
|
+ if (ListUtil.isNull(communityMemberDtos)) {
|
|
|
+ throw new CmdException("小区未关联物业公司,不能同步数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ //todo 检查小区中是否存在业主信息
|
|
|
+
|
|
|
+ OwnerDto ownerDto = new OwnerDto();
|
|
|
+ ownerDto.setCommunityId(reqJson.getString("communityId"));
|
|
|
+ int count = ownerV1InnerServiceSMOImpl.queryOwnersCount(ownerDto);
|
|
|
+
|
|
|
+ if (count < 1) {
|
|
|
+ throw new CmdException("小区中不存在业主信息,请您先维护物业基础数据后,再同步");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
|
|
|
+
|
|
|
+ dataBusInnerServiceSMOImpl.databusData(new DatabusDataDto(DatabusDataDto.BUSINESS_TYPE_SEND_COMMUNITY_DATA_TO_IOT, reqJson));
|
|
|
+
|
|
|
+ context.setResponseEntity(ResultVo.success());
|
|
|
+
|
|
|
+ }
|
|
|
+}
|