| | |
| | | public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException { |
| | | Assert.jsonObjectHaveKey(reqJson, "memberId", "请求报文中未包含ownerId"); |
| | | Assert.jsonObjectHaveKey(reqJson, "name", "请求报文中未包含name"); |
| | | // Assert.jsonObjectHaveKey(reqJson, "age", "请求报文中未包含age"); |
| | | Assert.jsonObjectHaveKey(reqJson, "link", "请求报文中未包含link"); |
| | | Assert.jsonObjectHaveKey(reqJson, "sex", "请求报文中未包含sex"); |
| | | Assert.jsonObjectHaveKey(reqJson, "ownerTypeCd", "请求报文中未包含ownerTypeCd"); |
| | | Assert.jsonObjectHaveKey(reqJson, "communityId", "请求报文中未包含communityId"); |
| | | // Assert.jsonObjectHaveKey(paramIn, "idCard", "请求报文中未包含身份证号"); |
| | | Assert.judgeAttrValue(reqJson); |
| | | //获取手机号(判断手机号是否重复) |
| | | String link = reqJson.getString("link"); |
| | | if (!StringUtil.isEmpty(link) && link.contains("*")) { |
| | | OwnerDto ownerDto = new OwnerDto(); |
| | | ownerDto.setOwnerId(reqJson.getString("ownerId")); |
| | | //业主 |
| | | ownerDto.setOwnerTypeCd("1001"); |
| | | List<OwnerDto> ownerDtos = ownerInnerServiceSMOImpl.queryOwners(ownerDto); |
| | | Assert.listOnlyOne(ownerDtos, "查询业主信息错误!"); |
| | | link = ownerDtos.get(0).getLink(); |
| | | reqJson.put("link", link); |
| | | reqJson.put("link", ""); |
| | | } |
| | | //获取身份证号(判断身份证号是否重复) |
| | | String idCard = reqJson.getString("idCard"); |
| | | if (!StringUtil.isEmpty(idCard) && idCard.contains("*")) { |
| | | OwnerDto owner = new OwnerDto(); |
| | | owner.setOwnerId(reqJson.getString("ownerId")); |
| | | //业主 |
| | | owner.setOwnerTypeCd("1001"); |
| | | List<OwnerDto> owners = ownerInnerServiceSMOImpl.queryOwners(owner); |
| | | Assert.listOnlyOne(owners, "查询业主信息错误!"); |
| | | idCard = owners.get(0).getIdCard(); |
| | | reqJson.put("idCard", idCard); |
| | | reqJson.put("idCard", ""); |
| | | } |
| | | |
| | | if (reqJson.containsKey("ownerPhotoUrl")) { |
| | | String ownerPhotoUrl = reqJson.getString("ownerPhotoUrl"); |
| | | if (!StringUtil.isEmpty(ownerPhotoUrl) && ownerPhotoUrl.length() > 500) { |
| | | throw new CmdException("图片地址太长"); |
| | | } |
| | | if (!StringUtil.isEmpty(ownerPhotoUrl)) { |
| | | reqJson.put("faceUrl", ownerPhotoUrl); |
| | | } |
| | | } |
| | | |
| | | |
| | | String userValidate = MappingCache.getValue("USER_VALIDATE"); |
| | | if (!"ON".equals(userValidate)) { |
| | | return; |
| | | } |
| | | |
| | | OwnerDto curOwner = new OwnerDto(); |
| | | curOwner.setMemberId(reqJson.getString("memberId")); |
| | | |
| | | List<OwnerDto> curOwners = ownerInnerServiceSMOImpl.queryOwners(curOwner); |
| | | Assert.listOnlyOne(curOwners, "未查询到业主信息或查询到多条"); |
| | | |
| | | OwnerDto ownerDto = new OwnerDto(); |
| | | ownerDto.setLink(link); |
| | | ownerDto.setLink(curOwners.get(0).getLink()); |
| | | ownerDto.setCommunityId(reqJson.getString("communityId")); |
| | | List<OwnerDto> ownerDtos = ownerInnerServiceSMOImpl.queryAllOwners(ownerDto); |
| | | if (ownerDtos != null && ownerDtos.size() > 1) { |
| | | throw new IllegalArgumentException("手机号重复,请重新输入"); |
| | | } else if (ownerDtos != null && ownerDtos.size() == 1) { |
| | | for (OwnerDto owner : ownerDtos) { |
| | | if ((!StringUtil.isEmpty(reqJson.getString("ownerId")) && !owner.getOwnerId().equals(reqJson.getString("ownerId"))) || (!StringUtil.isEmpty(reqJson.getString("memberId")) && !owner.getMemberId().equals(reqJson.getString("memberId")))) { |
| | | if (!reqJson.getString("memberId").equals(owner.getMemberId())) { |
| | | throw new IllegalArgumentException("手机号重复,请重新输入"); |
| | | } |
| | | } |
| | | } |
| | | if (!StringUtil.isEmpty(idCard)) { |
| | | OwnerDto owner = new OwnerDto(); |
| | | owner.setIdCard(idCard); |
| | | owner.setCommunityId(reqJson.getString("communityId")); |
| | | List<OwnerDto> owners = ownerInnerServiceSMOImpl.queryAllOwners(owner); |
| | | if (owners != null && owners.size() > 1) { |
| | | throw new IllegalArgumentException("身份证号重复,请重新输入"); |
| | | } else if (owners != null && owners.size() == 1) { |
| | | for (OwnerDto ownerDto1 : owners) { |
| | | if ((!StringUtil.isEmpty(reqJson.getString("ownerId")) && !ownerDto1.getOwnerId().equals(reqJson.getString("ownerId"))) || (!StringUtil.isEmpty(reqJson.getString("memberId")) && !ownerDto1.getMemberId().equals(reqJson.getString("memberId")))) { |
| | | throw new IllegalArgumentException("身份证号重复,请重新输入"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | @Override |
| | | @Java110Transactional |
| | | public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException { |
| | | if (!reqJson.containsKey("ownerId") || OwnerDto.OWNER_TYPE_CD_OWNER.equals(reqJson.getString("ownerTypeCd"))) { |
| | | reqJson.put("ownerId", reqJson.getString("memberId")); |
| | | } |
| | | //这里注释 因为 有国外的手机号 不是11位 |
| | | // if (link.length() != 11) { |
| | | // throw new IllegalArgumentException("手机号输入不正确!"); |
| | | // } |
| | | if (reqJson.containsKey("ownerPhoto") && !StringUtils.isEmpty(reqJson.getString("ownerPhoto"))) { |
| | | editOwnerPhoto(reqJson); |
| | | } |
| | | |
| | | |
| | | //todo 修改 业主信息 |
| | | editOwner(reqJson); |
| | | OwnerPo ownerPo = BeanConvertUtil.covertBean(reqJson, OwnerPo.class); |
| | | int flag = ownerV1InnerServiceSMOImpl.updateOwner(ownerPo); |
| | | if (flag < 1) { |
| | | throw new CmdException("修改业主失败"); |
| | | } |
| | | |
| | | //todo 修改账户 |
| | | updateAccount(reqJson); |
| | | |
| | | JSONArray attrs = reqJson.getJSONArray("attrs"); |
| | | if (attrs == null || attrs.size() < 1) { |
| | | if (ListUtil.isNull(attrs)) { |
| | | return; |
| | | } |
| | | JSONObject attr = null; |
| | | int flag = 0; |
| | | for (int attrIndex = 0; attrIndex < attrs.size(); attrIndex++) { |
| | | attr = attrs.getJSONObject(attrIndex); |
| | | attr.put("memberId", reqJson.getString("memberId")); |
| | |
| | | updateOwnerAppUser(reqJson); |
| | | } |
| | | |
| | | public void editOwner(JSONObject paramInJson) { |
| | | OwnerDto ownerDto = new OwnerDto(); |
| | | ownerDto.setMemberId(paramInJson.getString("memberId")); |
| | | List<OwnerDto> ownerDtos = ownerInnerServiceSMOImpl.queryOwnerMembers(ownerDto); |
| | | Assert.listOnlyOne(ownerDtos, "未查询到业主信息或查询到多条"); |
| | | JSONObject businessOwner = new JSONObject(); |
| | | businessOwner.putAll(BeanConvertUtil.beanCovertMap(ownerDtos.get(0))); |
| | | businessOwner.putAll(paramInJson); |
| | | if (paramInJson.containsKey("wxPhoto")) { |
| | | businessOwner.put("link", paramInJson.getString("wxPhoto")); |
| | | } |
| | | businessOwner.put("state", ownerDtos.get(0).getState()); |
| | | OwnerPo ownerPo = BeanConvertUtil.covertBean(businessOwner, OwnerPo.class); |
| | | if (StringUtil.isEmpty(ownerPo.getIdCard())) { |
| | | ownerPo.setAge(null); |
| | | } |
| | | int flag = ownerV1InnerServiceSMOImpl.updateOwner(ownerPo); |
| | | if (flag < 1) { |
| | | throw new CmdException("修改业主失败"); |
| | | } |
| | | public void updateAccount(JSONObject paramInJson) { |
| | | |
| | | //todo 判断业主手机号和账户手机号是否相同,不相同修改账户手机号 |
| | | AccountDto accountDto = new AccountDto(); |
| | | accountDto.setObjId(ownerDtos.get(0).getMemberId()); |
| | | accountDto.setPartId(ownerDtos.get(0).getCommunityId()); |
| | | accountDto.setObjId(paramInJson.getString("memberId")); |
| | | accountDto.setPartId(paramInJson.getString("communityId")); |
| | | List<AccountDto> accountDtos = accountInnerServiceSMOImpl.queryAccounts(accountDto); |
| | | if (ListUtil.isNull(accountDtos)) { |
| | | return; |
| | |
| | | owner.setMemberId(paramInJson.getString("memberId")); |
| | | List<OwnerDto> owners = ownerInnerServiceSMOImpl.queryOwnerMembers(owner); |
| | | Assert.listOnlyOne(owners, "未查询到业主信息或查询到多条"); |
| | | /*if (accountDtos.get(0).getLink().equals(ownerDtos.get(0).getLink())) { |
| | | return; |
| | | }*/ |
| | | if (!accountDtos.get(0).getLink().equals(owners.get(0).getLink()) || !accountDtos.get(0).getAcctName().equals(owners.get(0).getName())) { |
| | | AccountPo accountPo = new AccountPo(); |
| | | accountPo.setAcctName(owners.get(0).getName()); |
| | | accountPo.setoLink(owners.get(0).getLink()); |
| | | accountPo.setAcctId(accountDtos.get(0).getAcctId()); |
| | | accountInnerServiceSMOImpl.updateAccount(accountPo); |
| | | } |
| | | /*AccountPo accountPo = new AccountPo(); |
| | | accountPo.setoLink(ownerDtos.get(0).getLink()); |
| | | accountPo.setAcctId(accountDtos.get(0).getAcctId()); |
| | | accountInnerServiceSMOImpl.updateAccount(accountPo);*/ |
| | | } |
| | | |
| | | public void editOwnerPhoto(JSONObject paramInJson) { |
| | | String _photo = paramInJson.getString("ownerPhoto"); |
| | | if (_photo.length() > 512) { |
| | | FileDto fileDto = new FileDto(); |
| | | fileDto.setFileId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_file_id)); |
| | | fileDto.setFileName(fileDto.getFileId()); |
| | | fileDto.setContext(_photo); |
| | | fileDto.setSuffix("jpeg"); |
| | | fileDto.setCommunityId(paramInJson.getString("communityId")); |
| | | _photo = fileInnerServiceSMOImpl.saveFile(fileDto); |
| | | } |
| | | FileRelDto fileRelDto = new FileRelDto(); |
| | | fileRelDto.setRelTypeCd("10000"); |
| | | fileRelDto.setObjId(paramInJson.getString("memberId")); |
| | | int flag = 0; |
| | | List<FileRelDto> fileRelDtos = fileRelInnerServiceSMOImpl.queryFileRels(fileRelDto); |
| | | if (fileRelDtos == null || fileRelDtos.size() == 0) { |
| | | JSONObject businessUnit = new JSONObject(); |
| | | businessUnit.put("fileRelId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_fileRelId)); |
| | | businessUnit.put("relTypeCd", "10000"); |
| | | businessUnit.put("saveWay", "table"); |
| | | businessUnit.put("objId", paramInJson.getString("memberId")); |
| | | businessUnit.put("fileRealName", _photo); |
| | | businessUnit.put("fileSaveName", _photo); |
| | | FileRelPo fileRelPo = BeanConvertUtil.covertBean(businessUnit, FileRelPo.class); |
| | | flag = fileRelInnerServiceSMOImpl.saveFileRel(fileRelPo); |
| | | if (flag < 1) { |
| | | throw new CmdException("保存文件失败"); |
| | | } |
| | | return; |
| | | } |
| | | JSONObject businessUnit = new JSONObject(); |
| | | businessUnit.putAll(BeanConvertUtil.beanCovertMap(fileRelDtos.get(0))); |
| | | businessUnit.put("fileRealName", _photo); |
| | | businessUnit.put("fileSaveName", _photo); |
| | | FileRelPo fileRelPo = BeanConvertUtil.covertBean(businessUnit, FileRelPo.class); |
| | | flag = fileRelInnerServiceSMOImpl.updateFileRel(fileRelPo); |
| | | if (flag < 1) { |
| | | throw new CmdException("保存文件失败"); |
| | | } |
| | | } |
| | | |