1b5fb347b9be5d5e59f34319bad9f850b9e3d673.svn-base 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package cn.com.goldenwater.dcproj.service.impl.tac;
  2. import cn.com.goldenwater.core.service.AbstractCrudService;
  3. import cn.com.goldenwater.dcproj.dao.TacObjSubject515Dao;
  4. import cn.com.goldenwater.dcproj.dao.TacObjSubjectDao;
  5. import cn.com.goldenwater.dcproj.model.TacObjSubject;
  6. import cn.com.goldenwater.dcproj.param.TacObjSubjectParam;
  7. import cn.com.goldenwater.dcproj.service.TacObjSubjectService;
  8. import org.apache.commons.lang3.StringUtils;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.data.redis.core.RedisTemplate;
  11. import org.springframework.stereotype.Service;
  12. import org.springframework.transaction.annotation.Transactional;
  13. import java.util.List;
  14. import java.util.concurrent.TimeUnit;
  15. /**
  16. * @author lune
  17. * @date 2019-6-19
  18. */
  19. @Service
  20. @Transactional
  21. public class TacObjSubjectServiceImpl extends AbstractCrudService<TacObjSubject, TacObjSubjectParam> implements TacObjSubjectService {
  22. @Autowired
  23. private TacObjSubjectDao tacObjSubjectDao;
  24. @Autowired
  25. private TacObjSubject515Dao tacObjSubject515Dao;
  26. @Autowired
  27. private RedisTemplate redisTemplate;
  28. public TacObjSubjectServiceImpl(TacObjSubjectDao tacObjSubjectDao) {
  29. super(tacObjSubjectDao);
  30. this.tacObjSubjectDao = tacObjSubjectDao;
  31. }
  32. @Override
  33. public String selectCount() {
  34. return tacObjSubjectDao.selectCount() + "";
  35. }
  36. @Override
  37. public List<TacObjSubject> listType() {
  38. return tacObjSubjectDao.listType();
  39. }
  40. @Override
  41. public TacObjSubject getOne(String str) {
  42. if(StringUtils.isBlank(str)){
  43. return new TacObjSubject();
  44. }
  45. TacObjSubject objSubject= (TacObjSubject) redisTemplate.opsForValue().get("tac_obj_subject_"+str);
  46. if(objSubject==null){
  47. synchronized (this){
  48. objSubject= (TacObjSubject) redisTemplate.opsForValue().get("tac_obj_subject_"+str);
  49. if(objSubject==null) {
  50. objSubject = tacObjSubjectDao.get(str);
  51. if (objSubject != null) {
  52. redisTemplate.opsForValue().set("tac_obj_subject_"+str, objSubject, 10, TimeUnit.MINUTES);
  53. }else{
  54. objSubject=tacObjSubject515Dao.get(str);
  55. }
  56. }
  57. }
  58. }
  59. return objSubject;
  60. }
  61. }