old mode 100755
new mode 100644
| File was renamed from service-api/src/main/java/com/java110/api/listener/owner/SaveOwnerListener.java |
| | |
| | | package com.java110.api.listener.owner; |
| | | package com.java110.user.cmd.owner; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.api.bmo.owner.IOwnerBMO; |
| | | import com.java110.api.bmo.ownerAttr.IOwnerAttrBMO; |
| | | import com.java110.api.listener.AbstractServiceApiPlusListener; |
| | | import com.java110.core.annotation.Java110Listener; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.core.event.service.api.ServiceDataFlowEvent; |
| | | import com.java110.core.annotation.Java110Cmd; |
| | | import com.java110.core.annotation.Java110Transactional; |
| | | import com.java110.core.context.ICmdDataFlowContext; |
| | | import com.java110.core.event.cmd.AbstractServiceCmdListener; |
| | | import com.java110.core.event.cmd.CmdEvent; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.core.factory.SendSmsFactory; |
| | | import com.java110.dto.file.FileDto; |
| | | import com.java110.dto.msg.SmsDto; |
| | | import com.java110.dto.owner.OwnerDto; |
| | | import com.java110.intf.common.IFileInnerServiceSMO; |
| | | import com.java110.intf.common.IFileRelInnerServiceSMO; |
| | | import com.java110.intf.common.ISmsInnerServiceSMO; |
| | | import com.java110.intf.community.IOwnerRoomRelV1InnerServiceSMO; |
| | | import com.java110.intf.community.IOwnerV1InnerServiceSMO; |
| | | import com.java110.intf.fee.IFeeConfigInnerServiceSMO; |
| | | import com.java110.intf.user.IOwnerAttrInnerServiceSMO; |
| | | import com.java110.intf.user.IOwnerInnerServiceSMO; |
| | | import com.java110.po.file.FileRelPo; |
| | | import com.java110.po.owner.OwnerAttrPo; |
| | | import com.java110.po.owner.OwnerPo; |
| | | import com.java110.po.owner.OwnerRoomRelPo; |
| | | import com.java110.utils.cache.MappingCache; |
| | | import com.java110.utils.constant.ServiceCodeConstant; |
| | | import com.java110.utils.exception.CmdException; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | | import com.java110.utils.util.StringUtil; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import com.java110.core.log.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpMethod; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @ClassName SaveOwnerListener |
| | | * @Description 保存小区楼信息 |
| | | * @Author wuxw |
| | | * @Date 2019/4/26 14:51 |
| | | * @Version 1.0 |
| | | * add by wuxw 2019/4/26 |
| | | **/ |
| | | |
| | | @Java110Listener("saveOwnerListener") |
| | | public class SaveOwnerListener extends AbstractServiceApiPlusListener { |
| | | |
| | | @Autowired |
| | | private IOwnerBMO ownerBMOImpl; |
| | | @Java110Cmd(serviceCode = "owner.saveOwner") |
| | | public class SaveOwnerCmd extends AbstractServiceCmdListener { |
| | | |
| | | @Autowired |
| | | private IOwnerInnerServiceSMO ownerInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IOwnerAttrBMO ownerAttrBMOImpl; |
| | | |
| | | @Autowired |
| | | private ISmsInnerServiceSMO smsInnerServiceSMOImpl; |
| | |
| | | private IFileInnerServiceSMO fileInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IFileRelInnerServiceSMO fileRelInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl; |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(SaveOwnerListener.class); |
| | | @Autowired |
| | | private IOwnerV1InnerServiceSMO ownerV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IOwnerAttrInnerServiceSMO ownerAttrInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IOwnerRoomRelV1InnerServiceSMO ownerRoomRelV1InnerServiceSMOImpl; |
| | | |
| | | @Override |
| | | public String getServiceCode() { |
| | | return ServiceCodeConstant.SERVICE_CODE_SAVE_OWNER; |
| | | } |
| | | |
| | | @Override |
| | | public HttpMethod getHttpMethod() { |
| | | return HttpMethod.POST; |
| | | } |
| | | |
| | | @Override |
| | | protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) { |
| | | public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException { |
| | | Assert.jsonObjectHaveKey(reqJson, "name", "请求报文中未包含name"); |
| | | Assert.jsonObjectHaveKey(reqJson, "userId", "请求报文中未包含userId"); |
| | | Assert.jsonObjectHaveKey(reqJson, "age", "请求报文中未包含age"); |
| | |
| | | } |
| | | |
| | | @Override |
| | | protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) { |
| | | @Java110Transactional |
| | | public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException { |
| | | String userValidate = MappingCache.getValue("USER_VALIDATE"); |
| | | if ((!reqJson.containsKey("source") || !"BatchImport".equals(reqJson.getString("source"))) && "ON".equals(userValidate)) { |
| | | //获取手机号(判断手机号是否重复) |
| | |
| | | } |
| | | //生成memberId |
| | | generateMemberId(reqJson); |
| | | //添加小区楼 |
| | | ownerBMOImpl.addOwner(reqJson, context); |
| | | // if ("1001".equals(reqJson.getString("ownerTypeCd"))) { |
| | | // //小区楼添加到小区中 |
| | | // ownerBMOImpl.addCommunityMember(reqJson, context); |
| | | // } |
| | | JSONObject businessOwner = new JSONObject(); |
| | | businessOwner.putAll(reqJson); |
| | | businessOwner.put("state", "2000"); |
| | | OwnerPo ownerPo = BeanConvertUtil.covertBean(businessOwner, OwnerPo.class); |
| | | int flag = ownerV1InnerServiceSMOImpl.saveOwner(ownerPo); |
| | | if (flag < 1) { |
| | | throw new CmdException("保存业主失败"); |
| | | } |
| | | //有房屋信息,则直接绑定房屋和 业主的关系 |
| | | if (reqJson.containsKey("roomId")) { |
| | | //添加单元信息 |
| | | ownerBMOImpl.sellRoom(reqJson, context); |
| | | //添加物业费用信息 |
| | | //ownerBMOImpl.addPropertyFee(reqJson, context); |
| | | JSONObject businessUnit = new JSONObject(); |
| | | businessUnit.putAll(reqJson); |
| | | businessUnit.put("relId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_relId)); |
| | | OwnerRoomRelPo ownerRoomRelPo = BeanConvertUtil.covertBean(businessUnit, OwnerRoomRelPo.class); |
| | | flag = ownerRoomRelV1InnerServiceSMOImpl.saveOwnerRoomRel(ownerRoomRelPo); |
| | | if (flag < 1) { |
| | | throw new CmdException("保存业主房屋关系失败"); |
| | | } |
| | | } |
| | | if (reqJson.containsKey("ownerPhoto") && !StringUtils.isEmpty(reqJson.getString("ownerPhoto"))) { |
| | | FileDto fileDto = new FileDto(); |
| | |
| | | reqJson.put("ownerPhotoId", fileDto.getFileId()); |
| | | reqJson.put("fileSaveName", fileName); |
| | | |
| | | ownerBMOImpl.addOwnerPhoto(reqJson, context); |
| | | JSONObject businessUnit = new JSONObject(); |
| | | businessUnit.put("fileRelId", "-1"); |
| | | businessUnit.put("relTypeCd", "10000"); |
| | | businessUnit.put("saveWay", "table"); |
| | | businessUnit.put("objId", reqJson.getString("memberId")); |
| | | businessUnit.put("fileRealName", reqJson.getString("ownerPhotoId")); |
| | | businessUnit.put("fileSaveName", reqJson.getString("fileSaveName")); |
| | | FileRelPo fileRelPo = BeanConvertUtil.covertBean(businessUnit, FileRelPo.class); |
| | | flag = fileRelInnerServiceSMOImpl.saveFileRel(fileRelPo); |
| | | if (flag < 1) { |
| | | throw new CmdException("保存业主房屋关系失败"); |
| | | } |
| | | } |
| | | |
| | | dealOwnerAttr(reqJson, context); |
| | | |
| | | dealOwnerAttr(reqJson, cmdDataFlowContext); |
| | | } |
| | | |
| | | /** |
| | |
| | | private void generateMemberId(JSONObject paramObj) { |
| | | String memberId = GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_ownerId); |
| | | paramObj.put("memberId", memberId); |
| | | if (!paramObj.containsKey("ownerId") || "1001".equals(paramObj.getString("ownerTypeCd"))) { |
| | | if (!paramObj.containsKey("ownerId") || OwnerDto.OWNER_TYPE_CD_OWNER.equals(paramObj.getString("ownerTypeCd"))) { |
| | | paramObj.put("ownerId", memberId); |
| | | } |
| | | } |
| | | |
| | | private void dealOwnerAttr(JSONObject paramObj, DataFlowContext context) { |
| | | private void dealOwnerAttr(JSONObject paramObj, ICmdDataFlowContext cmdDataFlowContext) { |
| | | |
| | | if (!paramObj.containsKey("attrs")) { |
| | | return; |
| | |
| | | return; |
| | | } |
| | | |
| | | |
| | | int flag = 0; |
| | | JSONObject attr = null; |
| | | for (int attrIndex = 0; attrIndex < attrs.size(); attrIndex++) { |
| | | attr = attrs.getJSONObject(attrIndex); |
| | | attr.put("communityId", paramObj.getString("communityId")); |
| | | attr.put("memberId", paramObj.getString("memberId")); |
| | | ownerAttrBMOImpl.addOwnerAttr(attr, context); |
| | | attr.put("attrId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_attrId)); |
| | | OwnerAttrPo ownerAttrPo = BeanConvertUtil.covertBean(attr, OwnerAttrPo.class); |
| | | flag = ownerAttrInnerServiceSMOImpl.saveOwnerAttr(ownerAttrPo); |
| | | if (flag < 1) { |
| | | throw new CmdException("保存业主房屋关系失败"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public IFileInnerServiceSMO getFileInnerServiceSMOImpl() { |
| | | return fileInnerServiceSMOImpl; |
| | | } |
| | | |
| | | public void setFileInnerServiceSMOImpl(IFileInnerServiceSMO fileInnerServiceSMOImpl) { |
| | | this.fileInnerServiceSMOImpl = fileInnerServiceSMOImpl; |
| | | } |
| | | } |