| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.annotation.Java110Cmd; |
| | | import com.java110.core.annotation.Java110Transactional; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.core.context.ICmdDataFlowContext; |
| | | import com.java110.core.event.cmd.Cmd; |
| | | import com.java110.core.event.cmd.CmdEvent; |
| | |
| | | import com.java110.dto.file.FileDto; |
| | | import com.java110.dto.file.FileRelDto; |
| | | import com.java110.dto.org.OrgStaffRelDto; |
| | | import com.java110.dto.store.StoreUserDto; |
| | | import com.java110.dto.user.UserDto; |
| | | import com.java110.intf.common.IFileInnerServiceSMO; |
| | | import com.java110.intf.common.IFileRelInnerServiceSMO; |
| | | import com.java110.intf.store.IOrgStaffRelV1InnerServiceSMO; |
| | | import com.java110.intf.store.IStoreUserV1InnerServiceSMO; |
| | | import com.java110.intf.user.IOrgStaffRelInnerServiceSMO; |
| | | import com.java110.intf.user.IUserInnerServiceSMO; |
| | | import com.java110.intf.user.IUserV1InnerServiceSMO; |
| | | import com.java110.po.file.FileRelPo; |
| | | import com.java110.po.org.OrgStaffRelPo; |
| | | import com.java110.po.store.StoreUserPo; |
| | | import com.java110.po.user.UserPo; |
| | | import com.java110.utils.exception.CmdException; |
| | | import com.java110.utils.util.Assert; |
| | |
| | | public class UserStaffModifyCmd extends Cmd { |
| | | @Autowired |
| | | private IFileInnerServiceSMO fileInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IFileRelInnerServiceSMO fileRelInnerServiceSMOImpl; |
| | | |
| | |
| | | @Autowired |
| | | private IOrgStaffRelV1InnerServiceSMO orgStaffRelV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IStoreUserV1InnerServiceSMO storeUserV1InnerServiceSMOImpl; |
| | | |
| | | @Override |
| | | public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException { |
| | | Assert.jsonObjectHaveKey(reqJson, "staffId", "请求参数中未包含员工 节点,请确认"); |
| | |
| | | @Java110Transactional |
| | | public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException { |
| | | if (reqJson.containsKey("photo") && !StringUtils.isEmpty(reqJson.getString("photo"))) { |
| | | FileDto fileDto = new FileDto(); |
| | | fileDto.setFileId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_file_id)); |
| | | fileDto.setFileName(fileDto.getFileId()); |
| | | fileDto.setContext(reqJson.getString("photo")); |
| | | fileDto.setSuffix("jpeg"); |
| | | fileDto.setCommunityId(reqJson.getString("communityId")); |
| | | String fileName = fileInnerServiceSMOImpl.saveFile(fileDto); |
| | | |
| | | if(reqJson.getString("photo").length()> 200){ |
| | | FileDto fileDto = new FileDto(); |
| | | fileDto.setFileId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_file_id)); |
| | | fileDto.setFileName(fileDto.getFileId()); |
| | | fileDto.setContext(reqJson.getString("photo")); |
| | | fileDto.setSuffix("jpeg"); |
| | | fileDto.setCommunityId(reqJson.getString("communityId")); |
| | | String fileName = fileInnerServiceSMOImpl.saveFile(fileDto); |
| | | |
| | | reqJson.put("photo",fileName); |
| | | } |
| | | |
| | | FileRelDto fileRelDto = new FileRelDto(); |
| | | fileRelDto.setRelTypeCd("12000"); |
| | |
| | | List<FileRelDto> fileRelDtos = fileRelInnerServiceSMOImpl.queryFileRels(fileRelDto); |
| | | if (fileRelDtos == null || fileRelDtos.size() == 0) { |
| | | JSONObject businessUnit = new JSONObject(); |
| | | businessUnit.put("fileRelId", "-1"); |
| | | businessUnit.put("fileRelId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_relId)); |
| | | businessUnit.put("relTypeCd", "12000"); |
| | | businessUnit.put("saveWay", "table"); |
| | | businessUnit.put("objId", reqJson.getString("userId")); |
| | | businessUnit.put("fileRealName", fileDto.getFileId()); |
| | | businessUnit.put("fileSaveName", fileName); |
| | | businessUnit.put("fileRealName", reqJson.getString("photo")); |
| | | businessUnit.put("fileSaveName", reqJson.getString("photo")); |
| | | FileRelPo fileRelPo = BeanConvertUtil.covertBean(businessUnit, FileRelPo.class); |
| | | int flag = fileRelInnerServiceSMOImpl.saveFileRel(fileRelPo); |
| | | if (flag < 1) { |
| | |
| | | } else { |
| | | JSONObject businessUnit = new JSONObject(); |
| | | businessUnit.putAll(BeanConvertUtil.beanCovertMap(fileRelDtos.get(0))); |
| | | businessUnit.put("fileRealName", fileDto.getFileId()); |
| | | businessUnit.put("fileSaveName", fileName); |
| | | businessUnit.put("fileRealName", reqJson.getString("photo")); |
| | | businessUnit.put("fileSaveName", reqJson.getString("photo")); |
| | | FileRelPo fileRelPo = BeanConvertUtil.covertBean(businessUnit, FileRelPo.class); |
| | | int flag = fileRelInnerServiceSMOImpl.updateFileRel(fileRelPo); |
| | | if (flag < 1) { |
| | |
| | | UserDto userDto = new UserDto(); |
| | | userDto.setTel(userPo.getTel()); |
| | | userDto.setUserFlag("1"); |
| | | userDto.setLevelCd("01"); //员工 |
| | | List<UserDto> users = userInnerServiceSMOImpl.getUsers(userDto); |
| | | if (users != null && users.size() > 0) { |
| | | for (UserDto user : users) { |
| | |
| | | if (flag < 1) { |
| | | throw new CmdException("保存员工 失败"); |
| | | } |
| | | |
| | | StoreUserDto storeUserDto = new StoreUserDto(); |
| | | storeUserDto.setUserId(userPo.getUserId()); |
| | | List<StoreUserDto> storeUserDtos = storeUserV1InnerServiceSMOImpl.queryStoreUsers(storeUserDto); |
| | | |
| | | if (storeUserDtos == null || storeUserDtos.size() < 1) { |
| | | return; |
| | | } |
| | | StoreUserPo storeUserPo = new StoreUserPo(); |
| | | storeUserPo.setRelCd(paramObj.getString("relCd")); |
| | | storeUserPo.setStoreUserId(storeUserDtos.get(0).getStoreUserId()); |
| | | |
| | | flag = storeUserV1InnerServiceSMOImpl.updateStoreUser(storeUserPo); |
| | | if (flag < 1) { |
| | | throw new CmdException("保存员工 失败"); |
| | | } |
| | | } |
| | | |
| | | |