| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384 |
- package com.goafanti.user.service.impl;
- import java.text.ParseException;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.UUID;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.cache.annotation.Cacheable;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import com.goafanti.app.bo.UserBasicInfo;
- import com.goafanti.common.bo.userDaysBo;
- import com.goafanti.common.constant.AFTConstants;
- import com.goafanti.common.dao.CopyrightInfoMapper;
- import com.goafanti.common.dao.OrgIntellectualPropertyMapper;
- import com.goafanti.common.dao.OrganizationIdentityMapper;
- import com.goafanti.common.dao.PatentInfoMapper;
- import com.goafanti.common.dao.TechProjectMapper;
- import com.goafanti.common.dao.UserIdentityMapper;
- import com.goafanti.common.dao.UserMapper;
- import com.goafanti.common.enums.UserType;
- import com.goafanti.common.model.OrganizationIdentity;
- import com.goafanti.common.model.User;
- import com.goafanti.common.model.UserIdentity;
- import com.goafanti.common.utils.DateUtils;
- import com.goafanti.core.mybatis.BaseMybatisDao;
- import com.goafanti.core.mybatis.page.Pagination;
- import com.goafanti.core.shiro.token.TokenManager;
- import com.goafanti.user.bo.OrgListBo;
- import com.goafanti.user.bo.OrgPartnerDetailBo;
- import com.goafanti.user.bo.OrgUnitNames;
- import com.goafanti.user.bo.StarAndExpertListBo;
- import com.goafanti.user.bo.StarListBo;
- import com.goafanti.user.bo.UserDownLoadBo;
- import com.goafanti.user.bo.UserNames;
- import com.goafanti.user.bo.UserPageHomeBo;
- import com.goafanti.user.bo.UserPartnerDetailBo;
- import com.goafanti.user.service.UserService;
- @Service
- public class UserServiceImpl extends BaseMybatisDao<UserMapper> implements UserService {
- @Autowired
- private UserMapper userMapper;
- @Autowired
- private OrganizationIdentityMapper organizationIdentityMapper;
- @Autowired
- private UserIdentityMapper userIdentityMapper;
- @Autowired
- private PatentInfoMapper patentInfoMapper;
- @Autowired
- private CopyrightInfoMapper copyrightInfoMapper;
- @Autowired
- private TechProjectMapper techProjectMapper;
- @Autowired
- private OrgIntellectualPropertyMapper orgIntellectualPropertyMapper;
- @Override
- @Transactional
- public User insertRegister(User user, String unitName, String userName) {
- userMapper.insert(user);
- if (null != user.getType() && UserType.ORGANIZATION.getCode().equals(user.getType())) {
- OrganizationIdentity organizationIdentity = new OrganizationIdentity();
- organizationIdentity.setUid(user.getId());
- organizationIdentity.setUnitName(StringUtils.isBlank(unitName) ? "" : unitName);
- organizationIdentity.setId(UUID.randomUUID().toString());
- organizationIdentity.setIdentityType(0);
- organizationIdentity.setAuditStatus(0);
- organizationIdentity.setProcess(0);
- organizationIdentity.setWrongCount(0);
- organizationIdentity.setListed(0);
- organizationIdentity.setListedType(0);
- organizationIdentityMapper.insert(organizationIdentity);
- }
- if (null != user.getType() && UserType.PERSONAL.getCode().equals(user.getType())) {
- UserIdentity ui = new UserIdentity();
- ui.setId(UUID.randomUUID().toString());
- ui.setUid(user.getId());
- ui.setAuditStatus(0);
- ui.setProcess(0);
- ui.setWrongCount(0);
- ui.setUsername(StringUtils.isBlank(userName) ? "" : userName);
- userIdentityMapper.insert(ui);
- }
- return user;
- }
- @Override
- public User selectByMobieAndType(String mobile, Integer type) {
- return userMapper.selectByMobieAndType(mobile, type);
- }
- @Override
- public User selectByPrimaryKey(String id) {
- return userMapper.selectByPrimaryKey(id);
- }
- @Override
- public int updateByPrimaryKeySelective(User u) {
- return userMapper.updateByPrimaryKeySelective(u);
- }
- @Override
- public User insert(User user) {
- userMapper.insert(user);
- return user;
- }
- @Override
- public UserPageHomeBo selectUserPageHomeBoByUserId(String uid) {
- UserPageHomeBo bo = userMapper.selectUserPageHomeBoByUserId(uid);
- bo.setPatentNum(patentInfoMapper.findPatentInfoNumByUid(uid));
- bo.setCopyrightNum(copyrightInfoMapper.findCopyrightInfoNumByUid(uid));
- bo.setTechProjectNum(techProjectMapper.findTechProjectNumByUid(uid));
- bo.setIntellectualPropertyNum(orgIntellectualPropertyMapper.findIntellectualPropertyNum(uid));
- return bo;
- }
- @Override
- public UserDownLoadBo selectUserDownLoadBoByUserId(String id) {
- return userMapper.selectUserDownLoadBoByUserId(id);
- }
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<OrgListBo> selectUserByAid(Integer number, String mobile, Integer auditStatus, String auditName,
- String email, String aid, String startCreateTime, String endCreateTime, Integer type, Integer pageNo,
- Integer pageSize) {
- Map<String, Object> params = new HashMap<>();
- if (StringUtils.isNotBlank(startCreateTime)) {
- try {
- params.put("startCreateTime", DateUtils.parseDate(startCreateTime, AFTConstants.YYYYMMDD));
- } catch (ParseException e) {
- }
- }
- if (StringUtils.isNotBlank(endCreateTime)) {
- try {
- params.put("endCreateTime",
- DateUtils.addDays(DateUtils.parseDate(endCreateTime, AFTConstants.YYYYMMDD), 1));
- } catch (ParseException e) {
- }
- }
- if (null != number) {
- params.put("number", number);
- }
- if (StringUtils.isNotBlank(mobile)) {
- params.put("mobile", mobile);
- }
- if (null != auditStatus) {
- params.put("auditStatus", auditStatus);
- }
- if (StringUtils.isNotBlank(auditName)) {
- params.put("auditName", auditName);
- }
- if (StringUtils.isNotBlank(email)) {
- params.put("email", email);
- }
- if (!TokenManager.hasRole(AFTConstants.SUPERADMIN)) {
- params.put("aid", aid);
- }
- if (pageNo == null || pageNo < 0) {
- pageNo = 1;
- }
- if (pageSize == null || pageSize < 0 || pageSize > 10) {
- pageSize = 10;
- }
- if (UserType.PERSONAL.getCode().equals(type)) {
- return (Pagination<OrgListBo>) findPage("findUserByAidWithParamsListByPage", "findUserByAidWithParamsCount",
- params, pageNo, pageSize);
- } else if (UserType.ORGANIZATION.getCode().equals(type)) {
- return (Pagination<OrgListBo>) findPage("findOrgByAidWithParamsListByPage", "findOrgByAidWithParamsCount",
- params, pageNo, pageSize);
- }
- return null;
- }
- @Override
- public List<OrgUnitNames> selectDemandUnitNames() {
- String aid = TokenManager.getAdminId();
- if (TokenManager.hasRole(AFTConstants.MANAGERADMIN)) {
- return organizationIdentityMapper.selectManagerUnitNames(aid);
- } else {
- if (TokenManager.hasRole(AFTConstants.SUPERADMIN)) {
- aid = null;
- }
- return organizationIdentityMapper.selectAllOrgIndentity(aid);
- }
- }
- @Override
- public List<UserNames> selectDemandUserNames() {
- String aid = TokenManager.getAdminId();
- if (TokenManager.hasRole(AFTConstants.MANAGERADMIN)) {
- return userIdentityMapper.selectManagerUserNames(aid);
- } else {
- if (TokenManager.hasRole(AFTConstants.SUPERADMIN)) {
- aid = null;
- }
- return userIdentityMapper.selectAllUserNames(aid);
- }
- }
- @Override
- public Map<String, String> selectAchievementUserOwner(String name) {
- String aid = TokenManager.getAdminId();
- if (TokenManager.hasRole(AFTConstants.MANAGERADMIN)) {
- return disposeAchievementUserOwner(userIdentityMapper.selectManagerAchievementUserOwner(aid, name));
- } else {
- if (TokenManager.hasRole(AFTConstants.SUPERADMIN) || TokenManager.hasRole(AFTConstants.TECHBROKER)
- || TokenManager.hasRole(AFTConstants.AUDITORADMIN)) {
- aid = null;
- }
- return disposeAchievementUserOwner(userIdentityMapper.selectAchievementUserOwner(aid, name));
- }
- }
- public List<OrgUnitNames> selectAchievementOrgOwner(String name) {
- String aid = TokenManager.getAdminId();
- if (TokenManager.hasRole(AFTConstants.MANAGERADMIN)) {
- return organizationIdentityMapper.selectManagerAchievementOrgOwner(aid, name);
- } else {
- if (TokenManager.hasRole(AFTConstants.SUPERADMIN) || TokenManager.hasRole(AFTConstants.TECHBROKER)
- || TokenManager.hasRole(AFTConstants.AUDITORADMIN)) {
- aid = null;
- }
- return organizationIdentityMapper.selectAchievementOrgOwner(aid, name);
- }
- }
- private Map<String, String> disposeAchievementUserOwner(List<UserNames> list) {
- Map<String, String> map = new HashMap<>();
- if (null != list && list.size() > 0) {
- for (UserNames u : list) {
- map.put(u.getUid(), u.getUsername() + " " + u.getMobile());
- }
- }
- return map;
- }
- @Override
- public String findUserNameByNameAndMobile(String name, String mobile) {
- return userMapper.findUserByNameAndMobile(name, mobile);
- }
- @Override
- public String findOrgNameByNameAndMobile(String name, String mobile) {
- return userMapper.findOrgByNameAndMobile(name, mobile);
- }
- @Override
- public UserPartnerDetailBo findUserPartnerDetail(String uid) {
- return userMapper.findUserPartnerDetail(uid);
- }
- @Override
- public OrgPartnerDetailBo findOrgPartnerDetail(String uid) {
- return userMapper.findOrgPartnerDetail(uid);
- }
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<StarListBo> listStar(Integer number, String engagedField, String username,
- String professionalTitle, String workUnit, Integer pNo, Integer pSize) {
- Map<String, Object> params = new HashMap<>();
- if (null != number) {
- params.put("number", number);
- }
- if (StringUtils.isNotBlank(engagedField)) {
- params.put("engagedField", engagedField);
- }
- if (StringUtils.isNotBlank(username)) {
- params.put("username", username);
- }
- if (StringUtils.isNotBlank(professionalTitle)) {
- params.put("professionalTitle", professionalTitle);
- }
- if (StringUtils.isNotBlank(workUnit)) {
- params.put("workUnit", workUnit);
- }
- if (pNo == null || pNo < 0) {
- pNo = 1;
- }
- if (pSize == null || pSize < 0 || pSize > 10) {
- pSize = 10;
- }
- return (Pagination<StarListBo>) findPage("findStarListByPage", "findStarCount", params, pNo, pSize);
- }
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<StarAndExpertListBo> listStarAndExpert(Integer number, String engagedField, String username,
- String professionalTitle, String workUnit, Integer pNo, Integer pSize) {
- Map<String, Object> params = new HashMap<>();
- if (null != number) {
- params.put("number", number);
- }
- if (StringUtils.isNotBlank(engagedField)) {
- params.put("engagedField", engagedField);
- }
- if (StringUtils.isNotBlank(username)) {
- params.put("username", username);
- }
- if (StringUtils.isNotBlank(professionalTitle)) {
- params.put("professionalTitle", professionalTitle);
- }
- if (StringUtils.isNotBlank(workUnit)) {
- params.put("workUnit", workUnit);
- }
- if (pNo == null || pNo < 0) {
- pNo = 1;
- }
- if (pSize == null || pSize < 0 || pSize > 10) {
- pSize = 10;
- }
- return (Pagination<StarAndExpertListBo>) findPage("findStarAndExpertListByPage", "findStarAndExpertCount",
- params, pNo, pSize);
- }
- @Override
- @Cacheable(value = "UserNumberCache", key = "'UserNumberCache:UID:'+#userId")
- public String selectNumberByPrimaryKey(String userId) {
- return String.valueOf(userMapper.selectNumberByPrimaryKey(userId));
- }
- @Override
- public List<UserPartnerDetailBo> findUserPartner() {
- return userMapper.findUserPartner();
- }
- @Override
- public UserBasicInfo selectBaseInfo() {
- if(TokenManager.getToken() instanceof User)return userMapper.selectBaseInfo(TokenManager.getUserId());
- return null;
- }
- @Override
- public User selectByNumber(String easemobName) {
-
- return userMapper.selectByNumber(easemobName);
- }
-
- @Override
- public List<User> selectUserByRoleName(String roleName1,String roleName2){
- return userMapper.selectUserByRoleName(roleName1,roleName2);
- }
- @Override
- public void pushReleaseUserChannel(List<userDaysBo> newCList,Integer type) {
- userMapper.updateReleaseUserChannel(newCList,type);
-
- }
-
-
- }
|