DbdcUserService.java 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289
  1. package cn.com.taiji.zhongxiao.service;
  2. import java.math.BigDecimal;
  3. import java.sql.ResultSet;
  4. import java.sql.SQLException;
  5. import java.util.ArrayList;
  6. import java.util.Date;
  7. import java.util.HashMap;
  8. import java.util.List;
  9. import java.util.Map;
  10. import java.util.Set;
  11. import javax.inject.Inject;
  12. import javax.persistence.EntityManager;
  13. import javax.persistence.Query;
  14. import javax.persistence.criteria.CriteriaBuilder;
  15. import javax.persistence.criteria.CriteriaQuery;
  16. import javax.persistence.criteria.Join;
  17. import javax.persistence.criteria.Predicate;
  18. import javax.persistence.criteria.Root;
  19. import javax.sql.DataSource;
  20. import cn.com.taiji.zhongxiao.domain.TinfoClass;
  21. import cn.com.taiji.zhongxiao.domain.TshareApply;
  22. import cn.com.taiji.zhongxiao.domain.TshareApplyRepository;
  23. import org.apache.commons.codec.digest.DigestUtils;
  24. import org.slf4j.Logger;
  25. import org.slf4j.LoggerFactory;
  26. import org.springframework.beans.BeanUtils;
  27. import org.springframework.beans.factory.annotation.Autowired;
  28. import org.springframework.beans.factory.annotation.Value;
  29. import org.springframework.data.domain.Page;
  30. import org.springframework.data.domain.PageRequest;
  31. import org.springframework.data.domain.Sort;
  32. import org.springframework.data.domain.Sort.Direction;
  33. import org.springframework.data.domain.Sort.Order;
  34. import org.springframework.data.jpa.domain.Specification;
  35. import org.springframework.jdbc.core.JdbcTemplate;
  36. import org.springframework.jdbc.core.RowMapper;
  37. import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
  38. import org.springframework.stereotype.Service;
  39. import org.springframework.transaction.annotation.Propagation;
  40. import org.springframework.transaction.annotation.Transactional;
  41. import cn.com.taiji.sys.domain.Dept;
  42. import cn.com.taiji.sys.domain.DeptRepository;
  43. import cn.com.taiji.sys.domain.MenuRepository;
  44. import cn.com.taiji.sys.domain.Role;
  45. import cn.com.taiji.sys.domain.RoleMenuRepository;
  46. import cn.com.taiji.sys.domain.RoleUser;
  47. import cn.com.taiji.sys.domain.RoleUserPK;
  48. import cn.com.taiji.sys.domain.RoleUserRepository;
  49. import cn.com.taiji.sys.domain.User;
  50. import cn.com.taiji.sys.domain.UserRepository;
  51. import cn.com.taiji.sys.dto.LoginUserDto;
  52. import cn.com.taiji.sys.dto.OnlineUserDetail;
  53. import cn.com.taiji.sys.dto.OnlineUserDto;
  54. import cn.com.taiji.sys.dto.RoleDto;
  55. import cn.com.taiji.sys.dto.UserDto;
  56. import cn.com.taiji.util.Pagination;
  57. import cn.com.taiji.util.SpringUtil;
  58. import cn.com.taiji.util.ToolUtil;
  59. @Service
  60. public class DbdcUserService {
  61. private static final Logger log = LoggerFactory.getLogger(DbdcUserService.class);
  62. @Value("${admin_id}")
  63. String admin_id;
  64. @Inject
  65. JdbcTemplate jdbcTemplate;
  66. @Inject
  67. EntityManager em;
  68. @Value("${database_type}")
  69. String database_type;
  70. @Inject
  71. DataSource dataSource;
  72. @Inject
  73. DeptRepository deptRepository;
  74. @Autowired
  75. NamedParameterJdbcTemplate namedParameterJdbcTemplate;
  76. @Inject
  77. UserRepository userRepository;
  78. @Inject
  79. RoleUserRepository roleUserRepository;
  80. @Inject
  81. DbdcRoleService dbdcRoleService;
  82. @Inject
  83. RoleMenuRepository roleMenuRepository;
  84. @Inject
  85. TshareApplyRepository tshareApplyRepository;
  86. @Inject
  87. MenuRepository menuRepository;
  88. @Value("${xsjpg_roleid}")
  89. private String xsjpg_roleid;
  90. @Value("${sjpz_roleid}")
  91. private String sjpz_roleid;
  92. @Value("${fwkf_roleid}")
  93. private String fwkf_roleid;
  94. @Value("${zgbmgl_role}")
  95. private String zgbmgl_role;
  96. @Value("${bmsh_role}")
  97. String bmsh_role;
  98. @Value("${zgbmsh_role}")
  99. String zgbmsh_role;
  100. /**
  101. * 修改密码
  102. *
  103. * @param userId
  104. * @param password
  105. */
  106. @Transactional(propagation = Propagation.REQUIRED)
  107. public void savePwd(String userId, String password) {
  108. password = DigestUtils.sha256Hex(password);
  109. this.userRepository.updatePwd(userId, password, ToolUtil.date2Str(new Date(), "yyyy-MM-dd HH:mm:ss"));
  110. }
  111. public UserDto findById(String id) {
  112. if (id == null) {
  113. return new UserDto();
  114. }
  115. User user = this.userRepository.findOne(id);
  116. UserDto dto = new UserDto();
  117. if (user != null)
  118. BeanUtils.copyProperties(user, dto);
  119. String deptnames = "";
  120. String rolenames = "";
  121. if (dto != null && !ToolUtil.isNull(dto.getUserId())) {
  122. for (Dept dept : dto.getDepts()) {
  123. deptnames = deptnames + dept.getDeptName() + ",";
  124. }
  125. for (Role role : dto.getRoles()) {
  126. rolenames = rolenames + role.getRoleName() + ",";
  127. }
  128. }
  129. if (rolenames.length() > 0) {
  130. rolenames = rolenames.substring(0, rolenames.length() - 1);
  131. }
  132. if (deptnames.length() > 0) {
  133. deptnames = deptnames.substring(0, deptnames.length() - 1);
  134. }
  135. dto.setDeptnames(deptnames);
  136. dto.setRolenames(rolenames);
  137. return dto;
  138. }
  139. @Transactional(propagation = Propagation.REQUIRED)
  140. public void deleteUserRoleByUserId(String userId) {
  141. List<RoleUser> ru = roleUserRepository.findByUserId(userId);
  142. for (RoleUser u : ru) {
  143. roleUserRepository.delete(u);
  144. }
  145. }
  146. /**
  147. * 用户删除
  148. *
  149. * @param code
  150. */
  151. @Transactional(propagation = Propagation.REQUIRED)
  152. public void deleteUser(UserDto code) {
  153. User c = new User();
  154. BeanUtils.copyProperties(code, c);
  155. userRepository.delete(c);
  156. ;
  157. }
  158. public List<String> findRoleUserByUserId(String userid) {
  159. List<RoleUser> ru = roleUserRepository.findByUserId(userid);
  160. List<String> roleids = new ArrayList<String>();
  161. for (RoleUser r : ru) {
  162. String roleid = r.getId().getRoleId();
  163. roleids.add(roleid);
  164. }
  165. return roleids;
  166. }
  167. public List<String> findRolemenuByRoleId(String roleid) {
  168. List<String> roleids = roleMenuRepository.findMenuIdsByRoleId(roleid);
  169. return roleids;
  170. }
  171. public List<String> findAllUserByRole() {
  172. List<RoleUser> ru = roleUserRepository.findAll();
  173. List<String> userids = new ArrayList<String>();
  174. for (RoleUser r : ru) {
  175. String userid = r.getId().getUserId();
  176. if (!userids.contains(userid)) {
  177. userids.add(userid);
  178. }
  179. }
  180. return userids;
  181. }
  182. public List<RoleDto> findRoleByUserId(String id) {
  183. List<String> ru = new ArrayList<String>();
  184. List<RoleDto> list = new ArrayList<RoleDto>();
  185. ru = findRoleUserByUserId(id);
  186. for (int i = 0; i < ru.size(); i++) {
  187. Role role = dbdcRoleService.findRoleById(ru.get(i).toString());
  188. RoleDto dto = new RoleDto();
  189. BeanUtils.copyProperties(role, dto);
  190. list.add(dto);
  191. }
  192. return list;
  193. }
  194. public void insertRoleUser(RoleUserPK pk) {
  195. String userid = pk.getUserId();
  196. String roleids = pk.getRoleId();
  197. String[] role = roleids.split(",");
  198. // role.length
  199. for (int i = 0; i < role.length; i++) {
  200. if (role[i] != null && !"".equals(role[i])) {
  201. pk.setUserId(userid);
  202. pk.setRoleId(role[i]);
  203. RoleUser ru = new RoleUser();
  204. ru.setId(pk);
  205. roleUserRepository.save(ru);
  206. }
  207. }
  208. }
  209. public List<String> checkRolestr(String str) {
  210. String[] role = str.split(",");
  211. List<String> checkrole = new ArrayList<String>();
  212. for (int i = 0; i < role.length; i++) {
  213. if (role[i] != null && !"".equals(role[i])) {
  214. checkrole.add(role[i]);
  215. }
  216. }
  217. return checkrole;
  218. }
  219. /**
  220. *
  221. * @Description: 简要进行方法说明,并对基础数据类型的参数和返回值加以说明
  222. * @param dto
  223. * @param page
  224. * @return Pagination
  225. * @throws @author liujing
  226. * @date 2016年7月14日
  227. */
  228. public Pagination<UserDto> findAllUserList(final UserDto pr, Pagination<UserDto> pag, final String deptId,
  229. final String roleid, Map<String, Object> searchParameters) {
  230. List<Order> orders = new ArrayList<Sort.Order>();
  231. Order order = new Order(Direction.DESC, "updateTime");
  232. Order order1 = new Order(Direction.DESC, "userId");
  233. Order order2 = new Order(Direction.DESC, "userName");
  234. Order order3 = new Order(Direction.ASC, "usertype");
  235. orders.add(order3);
  236. orders.add(order);
  237. orders.add(order1);
  238. orders.add(order2);
  239. Sort sort = new Sort(orders);
  240. PageRequest request = new PageRequest(pag.getPageCurrentNum() - 1, pag.getPageSize(), sort);
  241. Page<User> page;
  242. page = userRepository.findAll(new Specification<User>() {
  243. @Override
  244. public Predicate toPredicate(Root<User> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
  245. List<Predicate> pl = new ArrayList<Predicate>();
  246. if (pr.getLoginName() != null && !"".equals(pr.getLoginName())) {
  247. pl.add(cb.like(root.<String>get("loginName"), "%" + pr.getLoginName() + "%"));
  248. }
  249. if (pr.getUserName() != null && !"".equals(pr.getUserName())) {
  250. pl.add(cb.like(root.<String>get("userName"), "%" + pr.getUserName() + "%"));
  251. }
  252. if (deptId != null) {
  253. pl.add(cb.like(root.<String>get("pdeptids"), "%" + deptId + "%"));
  254. }
  255. if (!ToolUtil.isNull(roleid)) {
  256. Join<User, Role> join = root.join("roles");
  257. pl.add(cb.equal(join.<String>get("roleId"), roleid));
  258. }
  259. if (!ToolUtil.isNull(pr.getDeptnames())) {
  260. Join<User, Dept> join2 = root.join("depts");
  261. pl.add(cb.like(join2.<String>get("deptName"), "%" + pr.getDeptnames() + "%"));
  262. }
  263. return cb.and(pl.toArray(new Predicate[0]));
  264. }
  265. }, request);
  266. List<User> dataList = page.getContent();
  267. List<UserDto> dtolsit = new ArrayList<UserDto>();
  268. for (User u : dataList) {
  269. UserDto code = new UserDto();
  270. String deptnames = "";
  271. String rolenames = "";
  272. BeanUtils.copyProperties(u, code);
  273. for (Dept dept : code.getDepts()) {
  274. deptnames = deptnames + dept.getDeptName() + ",";
  275. }
  276. for (Role role : code.getRoles()) {
  277. rolenames = rolenames + role.getRoleName() + ",";
  278. }
  279. if (rolenames.length() > 0) {
  280. rolenames = rolenames.substring(0, rolenames.length() - 1);
  281. }
  282. if (deptnames.length() > 0) {
  283. deptnames = deptnames.substring(0, deptnames.length() - 1);
  284. }
  285. code.setDeptnames(deptnames);
  286. code.setRolenames(rolenames);
  287. dtolsit.add(code);
  288. }
  289. pag.setPageResult(dtolsit);
  290. pag.setPageCount(page.getTotalPages());
  291. pag.setPageTotal((int) page.getTotalElements());
  292. return pag;
  293. }
  294. /**
  295. *
  296. * @Description: 更新用户信息
  297. * @param dto void
  298. * @throws @author user
  299. * @date 2016年7月14日
  300. */
  301. public void updateUser(UserDto dto) {
  302. User dt = new User();
  303. BeanUtils.copyProperties(dto, dt);
  304. userRepository.saveAndFlush(dt);
  305. }
  306. /**
  307. *
  308. * @Description: 后台添加用户
  309. * @param dto void
  310. * @throws @author user
  311. * @date 2016年7月14日
  312. */
  313. public void userInsert(UserDto dto) {
  314. User dt = new User();
  315. BeanUtils.copyProperties(dto, dt);
  316. dt.setPassword(dto.getPassword());
  317. userRepository.save(dt);
  318. }
  319. public String findUserByLoginName(String name) {
  320. User user = userRepository.findByLoginName(name);
  321. String message = "true";
  322. if (user != null) {
  323. message = "false";
  324. }
  325. return message;
  326. }
  327. @SuppressWarnings("unchecked")
  328. public Pagination findPaginationBySQL(String sql, List paramList, Pagination page) {
  329. List list = new ArrayList();
  330. Query query = em.createQuery(sql);
  331. int i = 1;
  332. for (Object obj : paramList) {
  333. query.setParameter(i++, obj);
  334. }
  335. int total = query.getResultList().size();
  336. page.setPageTotal(total);
  337. if (page.getPageSize() > 0 && page.getPageStartNo() >= 0) {
  338. int totalPage = ((int) page.getPageTotal() + page.getPageSize() - 1) / page.getPageSize();
  339. page.setPageCount(totalPage);
  340. query.setFirstResult(page.getPageStartNo());
  341. query.setMaxResults(page.getPageSize());
  342. }
  343. list = query.getResultList();
  344. page.setPageResult(list);
  345. return page;
  346. }
  347. public UserDto findByLoginName(String loginname) {
  348. // TODO Auto-generated method stub
  349. UserDto dto = new UserDto();
  350. User user = userRepository.findByLoginName(loginname);
  351. if (user != null) {
  352. BeanUtils.copyProperties(user, dto);
  353. }
  354. return dto;
  355. }
  356. public void updateUserByCid(String loginname, String cid, String company) {
  357. userRepository.updateUserByCid(loginname, cid, company);
  358. }
  359. public String comparePsw(UserDto dto, String oldpsw) {
  360. String password = DigestUtils.sha256Hex(oldpsw);
  361. String message;
  362. if (dto.getPassword().equals(password)) {
  363. message = "good";
  364. } else {
  365. message = "bad";
  366. }
  367. return message;
  368. }
  369. public void saveDeptUser(String deptid, String userId) {
  370. String[] deptids = deptid.split(",");
  371. for (String d : deptids) {
  372. List<Map<String, Object>> list = jdbcTemplate.queryForList(
  373. "select user_id from dept_user where user_id=? and dept_id=?", new Object[] { userId, d });
  374. if (list == null || list.size() == 0) {
  375. jdbcTemplate.execute("insert into dept_user(user_id,dept_id) values ('" + userId + "','" + d + "')");
  376. }
  377. }
  378. }
  379. @Transactional
  380. public void deleteDeptUser(String deptid, String userId) {
  381. String[] deptids = deptid.split(",");
  382. for (String d : deptids) {
  383. jdbcTemplate.execute("delete from dept_user where user_id ='" + userId + "'");
  384. }
  385. }
  386. /**
  387. *
  388. * @Description: 获取deptid的所有父节点id
  389. * @param deptid
  390. * @return String
  391. * @throws @author lijiezhi_pc
  392. * @date 2017年12月12日
  393. */
  394. public String getPdeptidsByDeptid(String deptid) {
  395. String pdeptids = "";
  396. if ("oracle".equals(database_type)) {
  397. List<Map<String, Object>> menuList = jdbcTemplate.queryForList(
  398. "select distinct(dept_id) from deptinfo start with instr(?,dept_id)>0 connect by prior parent_id=dept_id order by dept_id ",
  399. new Object[] { deptid });
  400. for (Map map : menuList) {
  401. pdeptids += map.get("dept_id") + ",";
  402. }
  403. } else if ("mysql".equals(database_type)) {
  404. List<Map<String, Object>> menuList = jdbcTemplate
  405. .queryForList("select parent_id from deptinfo where instr('" + deptid + "',dept_id)>0");
  406. while (menuList != null && menuList.size() > 0) {
  407. String ids = "";
  408. for (Map<String, Object> map : menuList) {
  409. ids = ids + "'" + map.get("parent_id") + "',";
  410. if (!pdeptids.contains(map.get("parent_id") + ""))
  411. pdeptids += map.get("parent_id") + ",";
  412. }
  413. if (!ToolUtil.isNull(ids)) {
  414. ids = ids.substring(0, ids.length() - 1);
  415. menuList = jdbcTemplate
  416. .queryForList("select parent_id from deptinfo where dept_id in (" + ids + ")");
  417. }
  418. }
  419. pdeptids = pdeptids + deptid + ",";
  420. }
  421. if (pdeptids.length() > 0) {
  422. pdeptids = pdeptids.substring(0, pdeptids.length() - 1);
  423. }
  424. return pdeptids;
  425. }
  426. public Pagination<OnlineUserDetail> findOnlineUserDetailList(UserDto dto, OnlineUserDto onLineUser,
  427. LoginUserDto loginUser, Pagination<OnlineUserDetail> pag) {
  428. StringBuffer sql = new StringBuffer(
  429. "select q.sessionid,q.login_name,q.last_request,p.ip_addr,p.creation_time,p.max_inactiveinterval,u.user_name from t_online_user q left join t_login_user p on q.sessionid=p.sessionid "
  430. + " left join userinfo u on u.login_name=q.login_name where p.creation_time is not null");
  431. List<String> paramList = new ArrayList<String>();
  432. if (!ToolUtil.isNull(dto.getUserName())) {
  433. sql.append(" AND u.user_name like '%" + dto.getUserName() + "%'");
  434. }
  435. if (!ToolUtil.isNull(dto.getLoginName())) {
  436. sql.append(" and q.login_name like '%" + dto.getLoginName() + "%'");
  437. }
  438. Object[] args = new Object[] {};
  439. int length = paramList.size();
  440. if (length > 0) {
  441. args = new Object[length];
  442. for (int i = 0; i < length; i++) {
  443. args[i] = paramList.get(i);
  444. }
  445. }
  446. sql.append(" order by p.creation_time,q.last_request");
  447. pag = pag.findPagination(sql.toString(), pag, args, new RowMapper<OnlineUserDetail>() {
  448. @Override
  449. public OnlineUserDetail mapRow(ResultSet rs, int rowNum) throws SQLException {
  450. OnlineUserDetail info = new OnlineUserDetail();
  451. OnlineUserDto online = new OnlineUserDto();
  452. LoginUserDto login = new LoginUserDto();
  453. UserDto user = new UserDto();
  454. online.setLastRequest(rs.getString("last_request"));
  455. online.setLoginName(rs.getString("login_name"));
  456. online.setSessionid(rs.getString("sessionid"));
  457. login.setCreationTime(rs.getString("creation_time"));
  458. login.setIpAddr(rs.getString("ip_addr"));
  459. login.setMaxInactiveInterval(rs.getString("max_inactiveinterval"));
  460. login.setSessionid(rs.getString("sessionid"));
  461. user.setUserName(rs.getString("user_name"));
  462. /*
  463. * info.setLogin(login); info.setOnline(online); info.setUser(user);
  464. */
  465. info.setSessionid(online.getSessionid());
  466. info.setLoginName(online.getLoginName());
  467. info.setLastRequest(online.getLastRequest());
  468. info.setIpAddr(login.getIpAddr());
  469. info.setCreationTime(login.getCreationTime());
  470. info.setMaxInactiveInterval(login.getMaxInactiveInterval());
  471. info.setUserName(user.getUserName());
  472. info.setStatus("在线");
  473. return info;
  474. }
  475. }, jdbcTemplate, database_type);
  476. return pag;
  477. }
  478. public void sendMsg() {
  479. List<Map<String, Object>> maplist = new ArrayList<>();
  480. maplist = jdbcTemplate.queryForList("select * from T_MESSAGEINFO where state='0'");
  481. for (Map<String, Object> map : maplist) {
  482. // try
  483. // {
  484. // URL u=new URL("http://210.76.72.40/oasms/SMInterface.aspx");
  485. // HttpURLConnection h=(HttpURLConnection)u.openConnection();
  486. // h.setDoOutput(true);
  487. // h.setRequestMethod("POST"); //设置为post请求
  488. // h.setRequestProperty("Content-Type","application/x-www-form-urlencoded"); //设置发送数据的类型
  489. // OutputStream out=h.getOutputStream();
  490. // String strMobile = "18933222233";
  491. // String strMsg = URLEncoder.encode("中文 !@#$%^&*()123");
  492. // String postData = "Account=ctgc01&PWD=ctgc01#gdic&Msg1="+strMsg+"&Mobile1="+strMobile;
  493. // out.write(postData.getBytes());
  494. // BufferedReader r = new BufferedReader(new InputStreamReader(h.getInputStream()));
  495. // String line = r.readLine();
  496. // if(line=="OK")
  497. // {
  498. //
  499. // }
  500. // else
  501. // {
  502. //
  503. // }
  504. // }
  505. // catch(Exception ex)
  506. // {
  507. //
  508. // }
  509. jdbcTemplate.update("update T_MESSAGEINFO set state='1' where id=?", map.get("id"));
  510. }
  511. }
  512. public void generateMessageInfo() {
  513. List<Map<String, Object>> infolist = new ArrayList<Map<String, Object>>();
  514. List<User> userList = userRepository.findAll();
  515. int length = userList.size();
  516. for (int i = 0; i < length; i++) {
  517. User user = userList.get(i);
  518. infolist = findReminderinfoByUser(user, "");
  519. if (infolist != null && infolist.size() > 0) {
  520. String message = "";
  521. int count = 0;
  522. for (Map<String, Object> map : infolist) {
  523. count += new BigDecimal(map.get("count") + "").intValue();
  524. message += map.get("message") + ",";
  525. }
  526. if (!ToolUtil.isNull(message)) {
  527. message = "您有" + count + "个待办,其中" + message + "请及时处理!";
  528. jdbcTemplate.update(
  529. "insert into t_messageinfo (id,user_id,user_name,phone_num,messageinfo,state,createtime,sendtime) values (?,?,?,?,?,?,?,?)",
  530. new Object[] { ToolUtil.getUUID(), user.getUserId(), user.getUserName(), user.getPhoneNum(),
  531. message, "0", ToolUtil.date2Str(new Date(), "yyyy-MM-dd HH:mm:ss"), null });
  532. }
  533. }
  534. }
  535. }
  536. public List<Map<String, Object>> findReminderinfoByUser(User userInfo, String type) {
  537. List<Map<String, Object>> infolist = new ArrayList<Map<String, Object>>();
  538. Set<Role> serRole = userInfo.getRoles();
  539. boolean flag = false;
  540. boolean flag_bmsh_role = false;
  541. boolean flag_zgbmsh_role = false;
  542. boolean flag_zgbmgl_role = false;
  543. for (Role role : serRole) {
  544. if (admin_id.equals(role.getRoleId())) {
  545. flag = true;
  546. }
  547. if (bmsh_role.equals(role.getRoleId())) {
  548. flag_bmsh_role = true;
  549. }
  550. if (zgbmsh_role.equals(role.getRoleId())) {
  551. flag_zgbmsh_role = true;
  552. }
  553. if (zgbmgl_role.equals(role.getRoleId())) {
  554. flag_zgbmgl_role = true;
  555. }
  556. }
  557. String deptids = "";
  558. String xzqhcodes = "";
  559. for (Dept dept : userInfo.getDepts()) {
  560. deptids = deptids + dept.getDeptId() + ",";
  561. xzqhcodes = xzqhcodes + dept.getXzqhcode();
  562. }
  563. if ("zc".equals(type)) {// 我的注册
  564. // 代码集注册:
  565. /**
  566. * select count(1) from t_codeset where creator=? and state in ('1','7') select
  567. * count(1) from t_codeset where creator=? and state in
  568. * ('2','3','4','5','6','7','8')
  569. */
  570. StringBuffer dmjzc = new StringBuffer("");
  571. Map mapdmjzc = new HashMap<>();
  572. StringBuffer dmjzc_zs = new StringBuffer("");
  573. Map mapdmjzc_zs = new HashMap<>();
  574. if (!flag) {
  575. dmjzc = new StringBuffer("select count(1) zs from t_codeset where creator=? and state in ('1','7')");
  576. mapdmjzc = jdbcTemplate.queryForMap(dmjzc.toString(), new Object[] { userInfo.getUserId() });
  577. dmjzc_zs = new StringBuffer(
  578. "select count(1) zs from t_codeset where creator=? and state in ('2','3','4','5','6','7','8')");
  579. mapdmjzc_zs = jdbcTemplate.queryForMap(dmjzc_zs.toString(), new Object[] { userInfo.getUserId() });
  580. } else {
  581. dmjzc = new StringBuffer("select count(1) zs from t_codeset where state in ('1','7')");
  582. mapdmjzc = jdbcTemplate.queryForMap(dmjzc.toString(), new Object[] {});
  583. dmjzc_zs = new StringBuffer(
  584. "select count(1) zs from t_codeset where state in ('2','3','4','5','6','7','8')");
  585. mapdmjzc_zs = jdbcTemplate.queryForMap(dmjzc_zs.toString(), new Object[] {});
  586. }
  587. Map resultMapdmjzc = new HashMap<String, Object>();
  588. resultMapdmjzc.put("info", "代码集注册:<font color=\"red\">" + mapdmjzc_zs.get("ZS") + "</font>个,待处理代码集注册:"
  589. + mapdmjzc.get("ZS")
  590. + "个,请到<a href-name=\"我的注册\" href-url=\"/tcodeSet/tcodeSet_list\"> <font color=\"green\">数据目录->目录规范->代码集注册->我的注册</font></a> 功能模块进行操作。");
  591. resultMapdmjzc.put("message", mapdmjzc.get("ZS") + "个代码集注册");
  592. resultMapdmjzc.put("count", mapdmjzc.get("ZS"));
  593. infolist.add(resultMapdmjzc);
  594. /**
  595. * 数据元注册: select count(1) from t_datameta where creator=? and state in
  596. * ('1','6','7') select count(1) from t_datameta where creator=?
  597. */
  598. StringBuffer sjyzc = new StringBuffer("");
  599. Map mapsjyzc = new HashMap<>();
  600. StringBuffer sjyzc_zs = new StringBuffer("");
  601. Map mapsjyzc_zs = new HashMap<>();
  602. if (!flag) {
  603. sjyzc = new StringBuffer(
  604. "select count(1) zs from t_datameta where creator=? and state in ('1','6','7')");
  605. mapsjyzc = jdbcTemplate.queryForMap(sjyzc.toString(), new Object[] { userInfo.getUserId() });
  606. sjyzc_zs = new StringBuffer("select count(1) zs from t_datameta where creator=?");
  607. mapsjyzc_zs = jdbcTemplate.queryForMap(sjyzc_zs.toString(), new Object[] { userInfo.getUserId() });
  608. } else {
  609. sjyzc = new StringBuffer("select count(1) zs from t_datameta where state in ('1','6','7')");
  610. mapsjyzc = jdbcTemplate.queryForMap(sjyzc.toString(), new Object[] {});
  611. sjyzc_zs = new StringBuffer("select count(1) zs from t_datameta ");
  612. mapsjyzc_zs = jdbcTemplate.queryForMap(sjyzc_zs.toString(), new Object[] {});
  613. }
  614. Map resultMapsjyzc = new HashMap<String, Object>();
  615. resultMapsjyzc.put("info", "数据元注册:<font color=\"red\">" + mapsjyzc_zs.get("ZS") + "</font>个,待处理数据元注册:"
  616. + mapsjyzc.get("ZS")
  617. + "个,请到<a href-name=\"数据元注册\" href-url=\"/DatametaController/datameta_listzc\"> <font color=\"green\">数据目录->目录规范->数据元管理->数据元注册</font></a> 功能模块进行操作。");
  618. resultMapsjyzc.put("message", mapsjyzc.get("ZS") + "个数据元注册");
  619. resultMapsjyzc.put("count", mapsjyzc.get("ZS"));
  620. infolist.add(resultMapsjyzc);
  621. /**
  622. * 信息类注册: select count(1) zs from t_infoclass where creator=? and inprocess in
  623. * ('0','1','2','3')
  624. */
  625. StringBuffer xxlzc = new StringBuffer("");
  626. Map mapxxlzc = new HashMap<>();
  627. if (!flag) {
  628. xxlzc = new StringBuffer(
  629. "select count(1) zs from t_infoclass where creator=? and inprocess in ('0','1','2','3')");
  630. mapxxlzc = jdbcTemplate.queryForMap(xxlzc.toString(), new Object[] { userInfo.getUserId() });
  631. } else {
  632. xxlzc = new StringBuffer("select count(1) zs from t_infoclass where inprocess in ('0','1','2','3')");
  633. mapxxlzc = jdbcTemplate.queryForMap(xxlzc.toString(), new Object[] {});
  634. }
  635. Map resultMapxxlzc = new HashMap<String, Object>();
  636. resultMapxxlzc.put("info", "信息类注册:<font color=\"red\">" + mapxxlzc.get("ZS")
  637. + "</font>个,请到<a href-name=\"信息类注册\" href-url=\"/tinfoclass/tinfoclass_zclist\"> <font color=\"green\">数据目录->目录规划->信息类管理->信息类注册</font></a> 功能模块进行操作。");
  638. resultMapxxlzc.put("message", mapxxlzc.get("ZS") + "个信息类注册");
  639. resultMapxxlzc.put("count", mapxxlzc.get("ZS"));
  640. infolist.add(resultMapxxlzc);
  641. /**
  642. * 服务注册: select count(1) zs from t_service_reginfo where creator=? and inprocess
  643. * in ('0','1','2','3') and isbg='0'
  644. */
  645. StringBuffer fwzc = new StringBuffer("");
  646. Map mapfwzc = new HashMap<>();
  647. if (!flag) {
  648. fwzc = new StringBuffer(
  649. "select count(1) zs from t_service_reginfo where creator=? and inprocess in ('0','1','2','3') and isbg='0'");
  650. mapfwzc = jdbcTemplate.queryForMap(fwzc.toString(), new Object[] { userInfo.getUserId() });
  651. } else {
  652. fwzc = new StringBuffer(
  653. "select count(1) zs from t_service_reginfo where inprocess in ('0','1','2','3') and isbg='0'");
  654. mapfwzc = jdbcTemplate.queryForMap(fwzc.toString(), new Object[] {});
  655. }
  656. Map resultMapfwzc = new HashMap<String, Object>();
  657. resultMapfwzc.put("info", "服务注册:<font color=\"red\">" + mapfwzc.get("ZS")
  658. + "</font>个,请到<a href-name=\"服务注册\" href-url=\"/reginfo/zclist\"> <font color=\"green\">服务管理->目录规划->服务注册</font></a> 功能模块进行操作。");
  659. resultMapfwzc.put("message", mapfwzc.get("ZS") + "个服务注册");
  660. resultMapfwzc.put("count", mapfwzc.get("ZS"));
  661. infolist.add(resultMapfwzc);
  662. return infolist;
  663. } else if ("apply".equals(type)) {
  664. /**
  665. * 已申请资源 select count(1) zs from t_shareapply q,t_infoclass p where
  666. * q.tinfoclassid=p.id and q.applyuserid=?
  667. */
  668. StringBuffer sqzy = new StringBuffer("");
  669. Map mapsqzy = new HashMap<>();
  670. if (!flag) {
  671. sqzy = new StringBuffer(
  672. "select count(1) zs from t_shareapply q,t_infoclass p where q.tinfoclassid=p.id and state!='4' and (q.applyuserid=? or instr(?,applydeptid)>0) and q.isrevoke is null");
  673. mapsqzy = jdbcTemplate.queryForMap(sqzy.toString(), new Object[] { userInfo.getUserId(),deptids });
  674. } else {
  675. sqzy = new StringBuffer(
  676. "select count(1) zs from t_shareapply q,t_infoclass p where q.tinfoclassid=p.id and state!='4'");
  677. mapsqzy = jdbcTemplate.queryForMap(sqzy.toString(), new Object[] {});
  678. }
  679. Map resultMapsqzy = new HashMap<String, Object>();
  680. resultMapsqzy.put("info", "已申请资源:<font color=\"red\">" + mapsqzy.get("ZS")
  681. + "</font>个,请到<a href-name=\"资源共享申请\" href-url=\"/tshareApply/tshareApply_list\"> <font color=\"green\">共享管理->共享申请->资源共享申请</font></a> 功能模块进行操作。");
  682. resultMapsqzy.put("message", mapsqzy.get("ZS") + "个申请资源");
  683. resultMapsqzy.put("count", mapsqzy.get("ZS"));
  684. infolist.add(resultMapsqzy);
  685. /**
  686. * 已申请服务 select count(1) zs from t_service_applyinfo p,t_service_reginfo r where
  687. * p.reqid=r.regid and p.inprocess!='4' and p.creator=?
  688. */
  689. List<String> paramList2 = new ArrayList<String>();
  690. StringBuffer sqfw = new StringBuffer(
  691. "select count(1) zs from t_service_applyinfo p,t_service_reginfo r where p.reqid=r.regid and p.inprocess!='4' ");
  692. if(flag_zgbmsh_role) {
  693. sqfw.append(" and (p.creator = ? or exists(select dept_id from deptinfo where instr(?,xzqhcode)>0 and dept_id=p.mingchengid)) ");
  694. paramList2.add(userInfo.getUserId());
  695. paramList2.add(deptids);
  696. }
  697. else if(flag_bmsh_role) {
  698. sqfw.append(" and (p.creator = ? or instr(?,p.mingchengid)>0) ");
  699. paramList2.add(userInfo.getUserId());
  700. paramList2.add(deptids);
  701. }
  702. else if(!flag) {
  703. sqfw.append(" and (p.creator = ?) ");
  704. paramList2.add(userInfo.getUserId());
  705. }
  706. Object[] args2 = new Object[] {};
  707. int length2 = paramList2.size();
  708. if (length2 > 0) {
  709. args2 = new Object[length2];
  710. for (int i = 0; i < length2; i++) {
  711. args2[i] = paramList2.get(i);
  712. }
  713. }
  714. Map map = jdbcTemplate.queryForMap(sqfw.toString(), args2);
  715. Map resultMap = new HashMap<String, Object>();
  716. resultMap.put("info", "已申请服务:<font color=\"red\">" + map.get("ZS")
  717. + "</font>个,请到<a href-name=\"服务调用申请\" href-url=\"/reginfo/applylist\"> <font color=\"green\">服务管理->服务申请->服务调用申请</font></a> 功能模块进行操作。");
  718. resultMap.put("message", map.get("ZS") + "个申请服务");
  719. resultMap.put("count", map.get("ZS"));
  720. infolist.add(resultMap);
  721. return infolist;
  722. } else if ("ys".equals(type)) {
  723. /**
  724. * 信息类已审 select count(1) zs from V_HISTASKLIST_T t,t_infoclass p where
  725. * t.proinstid=p.processid and p.id=t.busid and t.taskman =?
  726. */
  727. StringBuffer xxlys = new StringBuffer();
  728. Map mapxxlys = new HashMap<>();
  729. xxlys = new StringBuffer(
  730. "select count(1) zs from V_HISTASKLIST_T t,t_infoclass p where t.proinstid=p.processid and p.id=t.busid and t.taskman =?");
  731. mapxxlys = jdbcTemplate.queryForMap(xxlys.toString(), new Object[] { userInfo.getUserId() });
  732. Map resultMapxxlys = new HashMap<String, Object>();
  733. resultMapxxlys.put("info", "信息类已审:<font color=\"red\">" + mapxxlys.get("ZS")
  734. + "</font>个,请到<a href-name=\"我的已审\" href-url=\"/tinfoclass/tinfoclass_myyslist\"> <font color=\"green\">数据目录->目录规划->信息类管理->我的已审</font></a> 功能模块进行操作。");
  735. resultMapxxlys.put("message", mapxxlys.get("ZS") + "个信息类已审");
  736. resultMapxxlys.put("count", mapxxlys.get("ZS"));
  737. infolist.add(resultMapxxlys);
  738. /**
  739. * 服务已审 select count(1) zs from V_HISTASKLIST_T t,t_service_reginfo p where
  740. * t.proinstid=p.processid and p.regid=t.busid and t.taskman =?
  741. */
  742. StringBuffer fwys = new StringBuffer();
  743. Map mapfwys = new HashMap<>();
  744. fwys = new StringBuffer(
  745. "select count(1) zs from V_HISTASKLIST_T t,t_service_reginfo p where t.proinstid=p.processid and p.regid=t.busid and t.taskman =?");
  746. mapfwys = jdbcTemplate.queryForMap(fwys.toString(), new Object[] { userInfo.getUserId() });
  747. Map resultMapfwys = new HashMap<String, Object>();
  748. resultMapfwys.put("info", "服务注册已审:<font color=\"red\">" + mapfwys.get("ZS")
  749. + "</font>个,请到<a href-name=\"服务注册已审\" href-url=\"/reginfo/ysfwchecklist\"> <font color=\"green\">服务管理->服务审核->服务注册已审</font></a> 功能模块进行操作。");
  750. resultMapfwys.put("message", mapfwys.get("ZS") + "个服务注册已审");
  751. resultMapfwys.put("count", mapfwys.get("ZS"));
  752. infolist.add(resultMapfwys);
  753. /**
  754. * 资源申请已审 select count(1) zs from V_HISTASKLIST_T t,t_shareapply p where
  755. * t.proinstid=p.processid and p.id=t.busid and t.taskman =?
  756. */
  757. StringBuffer zysq = new StringBuffer();
  758. Map mapzysq = new HashMap<>();
  759. zysq = new StringBuffer(
  760. "select count(1) zs from V_HISTASKLIST_T t,t_shareapply p where t.proinstid=p.processid and p.id=t.busid and t.taskman =?");
  761. mapzysq = jdbcTemplate.queryForMap(zysq.toString(), new Object[] { userInfo.getUserId() });
  762. Map resultMapzysq = new HashMap<String, Object>();
  763. resultMapzysq.put("info", "资源申请已审:<font color=\"red\">" + mapzysq.get("ZS")
  764. + "</font>个,请到<a href-name=\"资源共享已审\" href-url=\"/tshareApply/tshareApply_yshlist\"> <font color=\"green\">共享管理->共享审核->资源共享已审</font></a> 功能模块进行操作。");
  765. resultMapzysq.put("message", mapzysq.get("ZS") + "个资源申请已审");
  766. resultMapzysq.put("count", mapzysq.get("ZS"));
  767. infolist.add(resultMapzysq);
  768. /**
  769. * 服务申请已审 select count(1) zs from V_HISTASKLIST_T t,t_service_applyinfo p where
  770. * t.proinstid=p.processid and p.applyid=t.busid and t.taskman =?
  771. */
  772. StringBuffer fwsq = new StringBuffer();
  773. Map mapfwsq = new HashMap<>();
  774. fwsq = new StringBuffer(
  775. "select count(1) zs from V_HISTASKLIST_T t,t_service_applyinfo p where t.proinstid=p.processid and p.applyid=t.busid and t.taskman =?");
  776. mapfwsq = jdbcTemplate.queryForMap(fwsq.toString(), new Object[] { userInfo.getUserId() });
  777. Map resultMapfwsq = new HashMap<String, Object>();
  778. resultMapfwsq.put("info", "服务申请已审:<font color=\"red\">" + mapfwsq.get("ZS")
  779. + "</font>个,请到<a href-name=\"服务申请已审\" href-url=\"/reginfo/ysapplychecklist\"> <font color=\"green\">服务管理->服务审核->服务申请已审</font></a> 功能模块进行操作。");
  780. resultMapfwsq.put("message", mapfwsq.get("ZS") + "个服务申请已审");
  781. resultMapfwsq.put("count", mapfwsq.get("ZS"));
  782. infolist.add(resultMapfwsq);
  783. return infolist;
  784. } else if ("dy".equals(type)) {
  785. /**
  786. * 我的订阅 select count(1) zs from subscribemanage t where t.state='1' and
  787. * t.createnameid =?
  788. */
  789. StringBuffer dy = new StringBuffer(
  790. "select count(1) zs from subscribemanage t,t_infoclass p where t.infoclassids=p.id and t.state='1' and t.createnameid =?");
  791. Map map = jdbcTemplate.queryForMap(dy.toString(), new Object[] { userInfo.getUserId() });
  792. Map resultMap = new HashMap<String, Object>();
  793. resultMap.put("info", "订阅资源:<font color=\"red\">" + map.get("ZS")
  794. + "</font>个,请到<a href-name=\"我的订阅\" href-url=\"/tinfoclass/mysubscri\"> <font color=\"green\">数据目录->目录规划->信息类管理->我的订阅</font></a> 功能模块进行操作。");
  795. resultMap.put("message", map.get("ZS") + "个资源订阅");
  796. resultMap.put("count", map.get("ZS"));
  797. infolist.add(resultMap);
  798. return infolist;
  799. } else {
  800. if (flag_zgbmsh_role) {
  801. Map ty = jdbcTemplate.queryForMap("select count(1) ZS from t_infoclass where disablestate=1 and inprocess='2' and LATESTVERSION='1' and instr(?,xzqhcode)>0", new Object[] {xzqhcodes});
  802. Map resultMapa = new HashMap<String, Object>();
  803. resultMapa.put("info", "您有<font color=\"red\">" + ty.get("ZS")
  804. + "</font>个信息类停用申请待审任务,请到<a href-name=\"信息类停启\" href-url=\"/tinfoclass/tinfoclass_tqlist\"> <font color=\"green\">数据目录管理->目录规划->信息类管理->信息类停启</font></a> 功能模块进行操作。");
  805. resultMapa.put("message", ty.get("ZS") + "个信息类停用申请待审任务");
  806. resultMapa.put("count", ty.get("ZS"));
  807. if(ty.get("ZS")!=null&&!"0".equals(String.valueOf(ty.get("ZS"))))
  808. infolist.add(resultMapa);
  809. }
  810. if (flag_zgbmgl_role || flag) {
  811. // 到期未停用
  812. List<TshareApply> tshareApplyList = tshareApplyRepository.findAll(new Specification<TshareApply>() {
  813. @Override
  814. public Predicate toPredicate(Root<TshareApply> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
  815. List<Predicate> pl = new ArrayList<Predicate>();
  816. pl.add(cb.isNull(root.get("isrevoke")));
  817. pl.add(cb.equal(root.<String>get("state"), "2"));
  818. pl.add(cb.equal(root.<String>get("actualize"), "2"));
  819. return cb.and(pl.toArray(new Predicate[0]));
  820. }
  821. });
  822. Map resultMapa = new HashMap<String, Object>();
  823. resultMapa.put("info", "您有<font color=\"red\">" + tshareApplyList.size()
  824. + "</font>个共享申请任务已到期,共享任务需停止,请到<a href-name=\"共享备案\" href-url=\"/tshareApply/tshareApply_balist\"> <font color=\"green\">数据共享管理-> 共享备案</font></a> 功能模块进行操作。");
  825. resultMapa.put("message", tshareApplyList.size() + "个共享任务需要停止");
  826. resultMapa.put("count", tshareApplyList.size());
  827. if (tshareApplyList.size() > 0) {
  828. infolist.add(resultMapa);
  829. }
  830. // 撤销未停用
  831. tshareApplyList = tshareApplyRepository.findAll(new Specification<TshareApply>() {
  832. @Override
  833. public Predicate toPredicate(Root<TshareApply> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
  834. List<Predicate> pl = new ArrayList<Predicate>();
  835. pl.add(cb.isNotNull(root.get("isrevoke")));
  836. pl.add(cb.equal(root.<String>get("state"), "2"));
  837. pl.add(cb.equal(root.<String>get("actualize"), "2"));
  838. return cb.and(pl.toArray(new Predicate[0]));
  839. }
  840. });
  841. resultMapa = new HashMap<String, Object>();
  842. resultMapa.put("info", "您有<font color=\"red\">" + tshareApplyList.size()
  843. + "</font>个共享申请任务撤销,共享任务需停止,请到<a href-name=\"共享备案\" href-url=\"/tshareApply/tshareApply_balist\"> <font color=\"green\">数据共享管理-> 共享备案</font></a> 功能模块进行操作。");
  844. resultMapa.put("message", tshareApplyList.size() + "个共享任务需要停止");
  845. resultMapa.put("count", tshareApplyList.size());
  846. if (tshareApplyList.size() > 0) {
  847. infolist.add(resultMapa);
  848. }
  849. }
  850. List<Map<String, Object>> hasPerssion = jdbcTemplate.queryForList("select m.menu_id from role_user p,ROLE_MENU q,menu m where p.user_id=? and p.ROLE_ID=q.role_id and m.menu_id=q.menu_id and m.MENU_URL=?", new Object[]{userInfo.getUserId(), "/tinfoclass/tinfoclass_hitchImplement"});
  851. if(hasPerssion!=null&&hasPerssion.size()>0) {
  852. Map ty = jdbcTemplate.queryForMap("select count(1) ZS from t_infoclass where HITCH_STATUS=1 and inprocess='2' and latestversion='1' and (implementation_state=0 or implementation_state is null)", new Object[] {});
  853. Map resultMapa = new HashMap<String, Object>();
  854. resultMapa.put("info", "您有<font color=\"red\">" + ty.get("ZS")
  855. + "</font>个信息类挂接实施任务,请到<a href-name=\"挂接实施\" href-url=\"/tinfoclass/tinfoclass_hitchImplement\"> <font color=\"green\">数据目录管理->目录规划->信息类管理->挂接实施</font></a> 功能模块进行操作。");
  856. resultMapa.put("message", ty.get("ZS") + "个信息类挂接实施任务");
  857. resultMapa.put("count", ty.get("ZS"));
  858. if(ty.get("ZS")!=null&&!"0".equals(String.valueOf(ty.get("ZS"))))
  859. infolist.add(resultMapa);
  860. }
  861. List<String> paramList = new ArrayList<String>();
  862. StringBuffer sqlBuffer = new StringBuffer(
  863. "select count(1)zs from t_service_applyinfo p where p.knowstate='1' and p.inprocess!='4'");
  864. if (flag_zgbmsh_role) {
  865. sqlBuffer.append(
  866. " and (p.creator = ? or exists(select dept_id from deptinfo where instr(?,xzqhcode)>0 and dept_id=p.mingchengid)) ");
  867. paramList.add(userInfo.getUserId());
  868. paramList.add(deptids);
  869. } else if (flag_bmsh_role) {
  870. sqlBuffer.append(" and (p.creator = ? or instr(?,p.mingchengid)>0) ");
  871. paramList.add(userInfo.getUserId());
  872. paramList.add(deptids);
  873. } else if (!flag) {
  874. sqlBuffer.append(" and (p.creator = ?) ");
  875. paramList.add(userInfo.getUserId());
  876. }
  877. Object[] args = new Object[] {};
  878. int length = paramList.size();
  879. if (length > 0) {
  880. args = new Object[length];
  881. for (int i = 0; i < length; i++) {
  882. args[i] = paramList.get(i);
  883. }
  884. }
  885. Map mapa = jdbcTemplate.queryForMap(sqlBuffer.toString(), args);
  886. Map resultMapa = new HashMap<String, Object>();
  887. resultMapa.put("info", "您申请的服务接口,现有<font color=\"red\">" + mapa.get("ZS")
  888. + "</font>个服务正在变更中,需要进行知悉反馈,请到<a href-name=\"服务调用申请\" href-url=\"/reginfo/applylist\"> <font color=\"green\">服务目录管理->服务申请->服务调用申请</font></a> 功能模块进行操作。");
  889. resultMapa.put("message", mapa.get("ZS") + "个变更待知悉反馈");
  890. resultMapa.put("count", mapa.get("ZS"));
  891. if(mapa.get("ZS")!=null&&!"0".equals(String.valueOf(mapa.get("ZS"))))
  892. infolist.add(resultMapa);
  893. Map mape = null;
  894. if (!flag) {
  895. mape = jdbcTemplate.queryForMap(
  896. "select count(1)zs from t_shareapply p where p.knowstate='1' and p.state!='4' and (applyuserid=? or instr(?,applydeptid)>0)",
  897. new Object[] { userInfo.getUserId(), deptids });
  898. } else {
  899. mape = jdbcTemplate.queryForMap(
  900. "select count(1)zs from t_shareapply p where p.knowstate='1' and p.state!='4' ", new Object[] {});
  901. }
  902. Map resultMape = new HashMap<String, Object>();
  903. resultMape.put("info", "您申请的目录信息,现有<font color=\"red\">" + mape.get("ZS")
  904. + "</font>个正在变更中,需要进行知悉反馈,请到<a href-name=\"数据共享申请\" href-url=\"/tshareApply/tshareApply_list\"> <font color=\"green\">数据共享管理->共享申请->数据共享申请</font></a> 功能模块进行操作。");
  905. resultMape.put("message", mape.get("ZS") + "个变更待知悉反馈");
  906. resultMape.put("count", mape.get("ZS"));
  907. if(mape.get("ZS")!=null&&!"0".equals(String.valueOf(mape.get("ZS"))))
  908. infolist.add(resultMape);
  909. if (flag_bmsh_role || flag) {
  910. StringBuffer sql_tcodeset_check = new StringBuffer(
  911. "select count(1) zs from t_codeset p where p.state='2' ");// 代码集审核
  912. Map map = null;
  913. if (flag) {
  914. map = jdbcTemplate.queryForMap(sql_tcodeset_check.toString(), new Object[] {});
  915. } else {
  916. sql_tcodeset_check.append("and instr(?,creator_org)>0");
  917. map = jdbcTemplate.queryForMap(sql_tcodeset_check.toString(), new Object[] { deptids });
  918. }
  919. if (map != null && !"0".equals(String.valueOf(map.get("ZS")))) {
  920. Map resultMap = new HashMap<String, Object>();
  921. resultMap.put("info", "您有<font color=\"red\">" + map.get("ZS")
  922. + "</font>个代码集部门审核任务,请到<a href-name=\"代码集审核\" href-url=\"/tcodeSet/tcodeSet_shlist\"> <font color=\"green\">数据目录->目录规范->代码集注册->代码集审核</font></a> 功能模块进行操作。");
  923. resultMap.put("message", map.get("ZS") + "个代码集审核任务");
  924. resultMap.put("count", map.get("ZS"));
  925. infolist.add(resultMap);
  926. }
  927. // 数据元审核待办
  928. Map map1 = null;
  929. if (flag) {
  930. StringBuffer sql_datameta_check = new StringBuffer(
  931. "select count(1) zs from t_datameta p where p.state='2' ");
  932. map1 = jdbcTemplate.queryForMap(sql_datameta_check.toString(), new Object[] {});
  933. } else {
  934. StringBuffer sql_datameta_check = new StringBuffer(
  935. "select count(1) zs from t_datameta p where p.state='2' and instr(?,creator_org)>0");
  936. map1 = jdbcTemplate.queryForMap(sql_datameta_check.toString(), new Object[] { deptids });
  937. }
  938. if (map1 != null && !"0".equals(String.valueOf(map1.get("ZS")))) {
  939. Map resultMap1 = new HashMap<String, Object>();
  940. resultMap1.put("info", "您有<font color=\"red\">" + map1.get("ZS")
  941. + "</font>个数据元审核任务,请到 <a href-name=\"数据元审核\" href-url=\"/DatametaController/datametaaudio_list?description=2,5\"><font color=\"green\">数据目录->目录规范->数据元管理->数据元审核</font></a> 功能模块进行操作。");
  942. resultMap1.put("message", map1.get("ZS") + "个数据元审核任务");
  943. resultMap1.put("count", map1.get("ZS"));
  944. infolist.add(resultMap1);
  945. }
  946. }
  947. if (flag_zgbmsh_role || flag) {
  948. // 主管部门信息类挂接审核
  949. StringBuffer gjcheck = new StringBuffer(
  950. " select count(1) zs from t_infoclass where inprocess='2' and LATESTVERSION='1' and (hitch_status=0 or hitch_status is null) and gjcheckstate='1' "); // 主管部门挂接审核
  951. Map mapgj = null;
  952. if (flag) {
  953. mapgj = jdbcTemplate.queryForMap(gjcheck.toString(), new Object[] {});
  954. } else {
  955. gjcheck.append("and instr(?,xzqhcode)>0");
  956. mapgj = jdbcTemplate.queryForMap(gjcheck.toString(), new Object[] { xzqhcodes });
  957. }
  958. if (mapgj != null && !"0".equals(String.valueOf(mapgj.get("ZS")))) {
  959. Map resultMapzg = new HashMap<String, Object>();
  960. resultMapzg.put("info", "您有<font color=\"red\">" + mapgj.get("ZS")
  961. + "</font>个信息类挂接审核任务,请到<a href-name=\"挂接待审\" href-url=\"/tinfohitchclass/tinfoclass_yslist2\"> <font color=\"green\">数据目录->目录规划->信息类管理->挂接待审</font></a> 功能模块进行操作。");
  962. resultMapzg.put("message", mapgj.get("ZS") + "个信息类挂接审核任务");
  963. resultMapzg.put("count", mapgj.get("ZS"));
  964. infolist.add(resultMapzg);
  965. }
  966. // 主管部门服务挂接审核
  967. String deptid = "cf6f00caea2c49d68c0ddb132e8f9727";// 网信办
  968. boolean isgjcheckdept = false;
  969. for (Dept dept : userInfo.getDepts()) {
  970. if (dept.getDeptId().equals(deptid)) {
  971. isgjcheckdept = true;
  972. }
  973. }
  974. if (isgjcheckdept) {
  975. StringBuffer fwgjcheck = new StringBuffer(
  976. " select count(1) zs from t_service_reginfo where latestversion='1' and inprocess='2' and isgj='0' and gjcheckstate='1' "); // 主管部门挂接审核
  977. Map mapfwgj = null;
  978. mapfwgj = jdbcTemplate.queryForMap(fwgjcheck.toString(), new Object[] {});
  979. if (mapfwgj != null && !"0".equals(String.valueOf(mapfwgj.get("ZS")))) {
  980. Map resultMapzg = new HashMap<String, Object>();
  981. resultMapzg.put("info", "您有<font color=\"red\">" + mapfwgj.get("ZS")
  982. + "</font>个服务挂接审核任务,请到<a href-name=\"服务挂接审核\" href-url=\"/reginfo/gjchecklist\"> <font color=\"green\">服务目录管理->服务挂接审核</font></a> 功能模块进行操作。");
  983. resultMapzg.put("message", mapfwgj.get("ZS") + "个服务挂接审核任务");
  984. resultMapzg.put("count", mapfwgj.get("ZS"));
  985. infolist.add(resultMapzg);
  986. }
  987. }
  988. StringBuffer sql_tcodeset_zgcheck = new StringBuffer(
  989. "select count(1) zs from t_codeset p where p.state='6' ");// 代码集审核
  990. Map mapzg = null;
  991. if (flag) {
  992. mapzg = jdbcTemplate.queryForMap(sql_tcodeset_zgcheck.toString(), new Object[] {});
  993. } else {
  994. sql_tcodeset_zgcheck.append("and instr(?,xzqhcode)>0");
  995. mapzg = jdbcTemplate.queryForMap(sql_tcodeset_zgcheck.toString(), new Object[] { xzqhcodes });
  996. }
  997. if (mapzg != null && !"0".equals(String.valueOf(mapzg.get("ZS")))) {
  998. Map resultMapzg = new HashMap<String, Object>();
  999. resultMapzg.put("info", "您有<font color=\"red\">" + mapzg.get("ZS")
  1000. + "</font>个代码集主管部门审核任务,请到<a href-name=\"代码集审核\" href-url=\"/tcodeSet/tcodeSet_shlist\"> <font color=\"green\">数据目录->目录规范->代码集注册->代码集审核</font></a> 功能模块进行操作。");
  1001. resultMapzg.put("message", mapzg.get("ZS") + "个代码集审核任务");
  1002. resultMapzg.put("count", mapzg.get("ZS"));
  1003. infolist.add(resultMapzg);
  1004. }
  1005. // 数据元审核待办
  1006. if (!flag) {
  1007. StringBuffer sql_datameta_check = new StringBuffer(
  1008. "select count(1) zs from t_datameta p where p.state='5' and instr(?,xzqhcode)>0");
  1009. Map map1 = jdbcTemplate.queryForMap(sql_datameta_check.toString(), new Object[] { xzqhcodes });
  1010. if (map1 != null && !"0".equals(String.valueOf(map1.get("ZS")))) {
  1011. Map resultMap1 = new HashMap<String, Object>();
  1012. resultMap1.put("info", "您有<font color=\"red\">" + map1.get("ZS")
  1013. + "</font>个数据元审核任务,请到 <a href-name=\"数据元审核\" href-url=\"/DatametaController/datametaaudio_list?description=2,5\"><font color=\"green\">数据目录->目录规范->数据元管理->数据元审核</font></a> 功能模块进行操作。");
  1014. resultMap1.put("message", map1.get("ZS") + "个数据元审核任务");
  1015. resultMap1.put("count", map1.get("ZS"));
  1016. infolist.add(resultMap1);
  1017. }
  1018. } else {
  1019. StringBuffer sql_datameta_check = new StringBuffer(
  1020. "select count(1) zs from t_datameta p where p.state='5'");
  1021. Map map1 = jdbcTemplate.queryForMap(sql_datameta_check.toString(), new Object[] {});
  1022. if (map1 != null && !"0".equals(String.valueOf(map1.get("ZS")))) {
  1023. Map resultMap1 = new HashMap<String, Object>();
  1024. resultMap1.put("info", "您有<font color=\"red\">" + map1.get("ZS")
  1025. + "</font>个数据元审核任务,请到 <a href-name=\"数据元审核\" href-url=\"/DatametaController/datametaaudio_list?description=2,5\"><font color=\"green\">数据目录->目录规范->数据元管理->数据元审核</font></a> 功能模块进行操作。");
  1026. resultMap1.put("message", map1.get("ZS") + "个数据元审核任务");
  1027. resultMap1.put("count", map1.get("ZS"));
  1028. infolist.add(resultMap1);
  1029. }
  1030. }
  1031. }
  1032. // 信息类待审核
  1033. StringBuffer sql_t_infoclass = new StringBuffer(
  1034. "select count(p.id) zs from v_tasklist t,t_infoclass p where t.PROC_INST_ID=p.processid and p.inprocess!='4' ");
  1035. Map map2 = null;
  1036. if (!flag) {
  1037. sql_t_infoclass.append("and (t.assignee =? or t.candidate=?)");
  1038. map2 = jdbcTemplate.queryForMap(sql_t_infoclass.toString(),
  1039. new Object[] { userInfo.getUserId(), userInfo.getUserId() });
  1040. } else {
  1041. map2 = jdbcTemplate.queryForMap(sql_t_infoclass.toString(), new Object[] {});
  1042. }
  1043. if (map2 != null && !"0".equals(String.valueOf(map2.get("ZS")))) {
  1044. Map resultMap2 = new HashMap<String, Object>();
  1045. resultMap2.put("info", "您有<font color=\"red\">" + map2.get("ZS")
  1046. + "</font>个信息类注册、变更审核任务,请到<a href-name=\"我的待审\" href-url=\"/tinfoclass/tinfoclass_zcshlist\"> <font color=\"green\">数据目录->目录规划->信息类管理->我的待审</font></a> 功能模块进行操作。");
  1047. resultMap2.put("message", map2.get("ZS") + "个信息类注册、变更审核任务");
  1048. resultMap2.put("count", map2.get("ZS"));
  1049. infolist.add(resultMap2);
  1050. }
  1051. // 服务注册待审核
  1052. StringBuffer sqlfwzc = new StringBuffer(
  1053. "select count(1) zs from v_tasklist t,t_service_reginfo p where t.PROC_INST_ID=p.processid and p.inprocess!='4' ");
  1054. Map mapfwzc = null;
  1055. if (!flag) {
  1056. sqlfwzc.append("and (t.assignee =? or t.candidate=?)");
  1057. mapfwzc = jdbcTemplate.queryForMap(sqlfwzc.toString(),
  1058. new Object[] { userInfo.getUserId(), userInfo.getUserId() });
  1059. } else {
  1060. mapfwzc = jdbcTemplate.queryForMap(sqlfwzc.toString(), new Object[] {});
  1061. }
  1062. if (mapfwzc != null && !"0".equals(String.valueOf(mapfwzc.get("ZS")))) {
  1063. Map resultMapfwzc = new HashMap<String, Object>();
  1064. resultMapfwzc.put("info", "您有<font color=\"red\">" + mapfwzc.get("ZS")
  1065. + "</font>服务注册待审任务,请到<a href-name=\"服务注册审核\" href-url=\"/reginfo/fwchecklist\"> <font color=\"green\">服务管理->服务审核->服务注册审核</font></a> 功能模块进行操作。");
  1066. resultMapfwzc.put("message", mapfwzc.get("ZS") + "个服务注册待审任务");
  1067. resultMapfwzc.put("count", mapfwzc.get("ZS"));
  1068. infolist.add(resultMapfwzc);
  1069. }
  1070. // 服务申请待审核
  1071. StringBuffer sqlfwsq = new StringBuffer(
  1072. "select count(1) zs from v_tasklist t,t_service_applyinfo p where t.PROC_INST_ID=p.processid and p.inprocess!='4' ");
  1073. Map mapfwsq = null;
  1074. if (!flag) {
  1075. sqlfwsq.append("and (t.assignee =? or t.candidate=?)");
  1076. mapfwsq = jdbcTemplate.queryForMap(sqlfwsq.toString(),
  1077. new Object[] { userInfo.getUserId(), userInfo.getUserId() });
  1078. } else {
  1079. mapfwsq = jdbcTemplate.queryForMap(sqlfwsq.toString(), new Object[] {});
  1080. }
  1081. if (mapfwsq != null && !"0".equals(String.valueOf(mapfwsq.get("ZS")))) {
  1082. Map resultMapfwsq = new HashMap<String, Object>();
  1083. resultMapfwsq.put("info", "您有<font color=\"red\">" + mapfwsq.get("ZS")
  1084. + "</font>服务申请待审任务,请到<a href-name=\"服务申请审核\" href-url=\"/reginfo/applychecklist\"> <font color=\"green\">服务管理->服务审核->服务申请审核</font></a> 功能模块进行操作。");
  1085. resultMapfwsq.put("message", mapfwsq.get("ZS") + "个服务申请待审任务");
  1086. resultMapfwsq.put("count", mapfwsq.get("ZS"));
  1087. infolist.add(resultMapfwsq);
  1088. }
  1089. if (flag_bmsh_role) {
  1090. // 信息类待挂接
  1091. StringBuffer sql_t_infoclass_dgj = new StringBuffer(
  1092. "select count(1) zs from t_infoclass where inprocess='2' and latestversion='1' and (hitch_status='0' or hitch_status is null) and ( creator=? or instr(?,providebmcode)>0) ");
  1093. Map map3 = jdbcTemplate.queryForMap(sql_t_infoclass_dgj.toString(),
  1094. new Object[] { userInfo.getUserId(), deptids });
  1095. if (map3 != null && !"0".equals(String.valueOf(map3.get("ZS")))) {
  1096. Map resultMap3 = new HashMap<String, Object>();
  1097. resultMap3.put("info", "您有<font color=\"red\">" + map3.get("ZS")
  1098. + "</font>信息类待挂接,请到<a href-name=\"待挂接列表\" href-url=\"/tinfohitchclass/tinfoclass_yslist0\"> <font color=\"green\">数据目录->目录规划->信息类管理->待挂接列表</font></a> 功能模块进行操作。");
  1099. resultMap3.put("message", map3.get("ZS") + "个信息类待挂接任务");
  1100. resultMap3.put("count", map3.get("ZS"));
  1101. infolist.add(resultMap3);
  1102. }
  1103. }
  1104. // 信息类变更任务
  1105. StringBuffer sql_t_infoclass_bgtask = new StringBuffer(
  1106. "select count(q.id) zs from t_changeapply p,t_infoclass q where p.state='2' and p.tinfoclassid=q.id and q.creator=? and (instr(?,q.providebmcode)>0 or instr(?,q.providecode)>0)");
  1107. Map map4 = jdbcTemplate.queryForMap(sql_t_infoclass_bgtask.toString(),
  1108. new Object[] { userInfo.getUserId(), deptids, deptids });
  1109. if (map4 != null && !"0".equals(String.valueOf(map4.get("ZS")))) {
  1110. Map resultMap4 = new HashMap<String, Object>();
  1111. resultMap4.put("info", "您有<font color=\"red\">" + map4.get("ZS")
  1112. + "</font>个变更任务,请到<a href-name=\"我的变更任务\" href-url=\"/tchangeApply/tchangeApply_tasklist\"> <font color=\"green\">数据目录->目录规划->信息类管理->我的变更任务</font></a> 功能模块进行操作。");
  1113. resultMap4.put("message", map4.get("ZS") + "个信息类变更任务");
  1114. resultMap4.put("count", map4.get("ZS"));
  1115. infolist.add(resultMap4);
  1116. }
  1117. // 资源共享审核
  1118. StringBuffer sql_t_infoclass_zygxsh = new StringBuffer(
  1119. "select count(1) zs from v_tasklist t,t_shareapply p where t.PROC_INST_ID=p.processid ");
  1120. Map map7 = null;
  1121. if (!flag) {
  1122. sql_t_infoclass_zygxsh.append("and (t.assignee =? or t.candidate=?)");
  1123. map7 = jdbcTemplate.queryForMap(sql_t_infoclass_zygxsh.toString(),
  1124. new Object[] { userInfo.getUserId(), userInfo.getUserId() });//
  1125. } else {
  1126. map7 = jdbcTemplate.queryForMap(sql_t_infoclass_zygxsh.toString(), new Object[] {});//
  1127. }
  1128. if (map7 != null && !"0".equals(String.valueOf(map7.get("ZS")))) {
  1129. Map resultMap7 = new HashMap<String, Object>();
  1130. resultMap7.put("info", "您有<font color=\"red\">" + map7.get("ZS")
  1131. + "</font>个资源共享申请待审任务,请到<a href-name=\"资源共享待审\" href-url=\"/tshareApply/tshareApply_shlist\"> <font color=\"green\">共享管理->共享审核->资源共享待审</font></a> 功能模块进行操作。");
  1132. resultMap7.put("message", map7.get("ZS") + "个资源共享审核");
  1133. resultMap7.put("count", map7.get("ZS"));
  1134. infolist.add(resultMap7);
  1135. }
  1136. }
  1137. return infolist;
  1138. }
  1139. public void deptSynJob() {
  1140. DataSource dataSource = (DataSource) SpringUtil.getBean("secondaryDataSource");
  1141. JdbcTemplate drds = new JdbcTemplate(dataSource);
  1142. List<Map<String, Object>> maplist = drds.queryForList(
  1143. "select id dept_id, parent_id,concat(parent_ids,',',id) pdeptids, name dept_name, sort dept_index, code remark,region_code xzqhcode, business_code ywbmcode, zip_code creditno from sys_office where issyn is null");
  1144. log.info("maplist==" + maplist.size());
  1145. Dept dept = new Dept();
  1146. List<Dept> deptlist = new ArrayList<Dept>();
  1147. Dept pdept = new Dept();
  1148. for (Map<String, Object> map : maplist) {
  1149. drds.update("update sys_office set issyn=? where id=?", new Object[] { "1", map.get("dept_id") });
  1150. pdept = deptRepository.findOne(map.get("parent_id") + "");
  1151. if (pdept != null && !"".equals(pdept.getDeptId())) {
  1152. dept = new Dept();
  1153. dept.setDeptId(map.get("dept_id") + "");
  1154. dept.setParent(pdept);
  1155. dept.setPdeptids(map.get("pdeptids") + "");
  1156. dept.setDeptName(map.get("dept_name") + "");
  1157. dept.setDeptIndex(Integer.parseInt(map.get("dept_index") + ""));
  1158. dept.setRemark(map.get("remark") + "");
  1159. dept.setXzqhcode(map.get("xzqhcode") + "");
  1160. dept.setYwbmcode(map.get("ywbmcode") + "");
  1161. dept.setCreditno(map.get("creditno") + "");
  1162. deptlist.add(dept);
  1163. }
  1164. }
  1165. log.info("deptlist==" + deptlist.size());
  1166. if (deptlist.size() > 0)
  1167. deptRepository.save(deptlist);
  1168. }
  1169. public String findUserByUserkey(String userkey, String userid) {
  1170. User user = userRepository.findByUserkey(userkey);
  1171. String message = "true";
  1172. if (user != null && !userid.equals(user.getUserId())) {
  1173. message = "false";
  1174. }
  1175. return message;
  1176. }
  1177. public UserDto findByUserkey(String userkey) {
  1178. // TODO Auto-generated method stub
  1179. UserDto dto = new UserDto();
  1180. User user = userRepository.findByUserkey(userkey);
  1181. if (user != null) {
  1182. BeanUtils.copyProperties(user, dto);
  1183. }
  1184. return dto;
  1185. }
  1186. }