UserTalentSubsidyServiceImpl.java 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. package cn.com.lzt.talentsubsidy.service.impl;
  2. import cn.com.lzt.talentsubsidy.service.UserTalentSubsidyServiceI;
  3. import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
  4. import cn.com.lzt.talentsubsidy.entity.UserTalentSubsidyEntity;
  5. import org.springframework.stereotype.Service;
  6. import org.springframework.transaction.annotation.Transactional;
  7. import java.util.HashMap;
  8. import java.util.Map;
  9. import java.util.UUID;
  10. import java.io.Serializable;
  11. import org.jeecgframework.core.util.ApplicationContextUtil;
  12. import org.jeecgframework.core.util.MyClassLoader;
  13. import org.jeecgframework.core.util.StringUtil;
  14. import org.jeecgframework.web.cgform.enhance.CgformEnhanceJavaInter;
  15. @Service("userTalentSubsidyService")
  16. @Transactional
  17. public class UserTalentSubsidyServiceImpl extends CommonServiceImpl implements UserTalentSubsidyServiceI {
  18. public void delete(UserTalentSubsidyEntity entity) throws Exception{
  19. super.delete(entity);
  20. //执行删除操作增强业务
  21. this.doDelBus(entity);
  22. }
  23. public Serializable save(UserTalentSubsidyEntity entity) throws Exception{
  24. Serializable t = super.save(entity);
  25. //执行新增操作增强业务
  26. this.doAddBus(entity);
  27. return t;
  28. }
  29. public void saveOrUpdate(UserTalentSubsidyEntity entity) throws Exception{
  30. super.saveOrUpdate(entity);
  31. //执行更新操作增强业务
  32. this.doUpdateBus(entity);
  33. }
  34. /**
  35. * 新增操作增强业务
  36. * @param t
  37. * @return
  38. */
  39. private void doAddBus(UserTalentSubsidyEntity t) throws Exception{
  40. //-----------------sql增强 start----------------------------
  41. //-----------------sql增强 end------------------------------
  42. //-----------------java增强 start---------------------------
  43. //-----------------java增强 end-----------------------------
  44. }
  45. /**
  46. * 更新操作增强业务
  47. * @param t
  48. * @return
  49. */
  50. private void doUpdateBus(UserTalentSubsidyEntity t) throws Exception{
  51. //-----------------sql增强 start----------------------------
  52. //-----------------sql增强 end------------------------------
  53. //-----------------java增强 start---------------------------
  54. //-----------------java增强 end-----------------------------
  55. }
  56. /**
  57. * 删除操作增强业务
  58. * @param id
  59. * @return
  60. */
  61. private void doDelBus(UserTalentSubsidyEntity t) throws Exception{
  62. //-----------------sql增强 start----------------------------
  63. //-----------------sql增强 end------------------------------
  64. //-----------------java增强 start---------------------------
  65. //-----------------java增强 end-----------------------------
  66. }
  67. private Map<String,Object> populationMap(UserTalentSubsidyEntity t){
  68. Map<String,Object> map = new HashMap<String,Object>();
  69. map.put("id", t.getId());
  70. map.put("create_name", t.getCreateName());
  71. map.put("create_by", t.getCreateBy());
  72. map.put("create_date", t.getCreateDate());
  73. map.put("update_name", t.getUpdateName());
  74. map.put("update_by", t.getUpdateBy());
  75. map.put("update_date", t.getUpdateDate());
  76. map.put("sys_org_code", t.getSysOrgCode());
  77. map.put("sys_company_code", t.getSysCompanyCode());
  78. map.put("bpm_status", t.getBpmStatus());
  79. map.put("talent_strategy_id", t.getTalentStrategyId());
  80. map.put("user_id", t.getUserid());
  81. map.put("money", t.getMoney());
  82. map.put("description", t.getDescription());
  83. return map;
  84. }
  85. /**
  86. * 替换sql中的变量
  87. * @param sql
  88. * @param t
  89. * @return
  90. */
  91. public String replaceVal(String sql,UserTalentSubsidyEntity t){
  92. sql = sql.replace("#{id}",String.valueOf(t.getId()));
  93. sql = sql.replace("#{create_name}",String.valueOf(t.getCreateName()));
  94. sql = sql.replace("#{create_by}",String.valueOf(t.getCreateBy()));
  95. sql = sql.replace("#{create_date}",String.valueOf(t.getCreateDate()));
  96. sql = sql.replace("#{update_name}",String.valueOf(t.getUpdateName()));
  97. sql = sql.replace("#{update_by}",String.valueOf(t.getUpdateBy()));
  98. sql = sql.replace("#{update_date}",String.valueOf(t.getUpdateDate()));
  99. sql = sql.replace("#{sys_org_code}",String.valueOf(t.getSysOrgCode()));
  100. sql = sql.replace("#{sys_company_code}",String.valueOf(t.getSysCompanyCode()));
  101. sql = sql.replace("#{bpm_status}",String.valueOf(t.getBpmStatus()));
  102. sql = sql.replace("#{talent_strategy_id}",String.valueOf(t.getTalentStrategyId()));
  103. sql = sql.replace("#{user_id}",String.valueOf(t.getUserid()));
  104. sql = sql.replace("#{money}",String.valueOf(t.getMoney()));
  105. sql = sql.replace("#{description}",String.valueOf(t.getDescription()));
  106. sql = sql.replace("#{UUID}",UUID.randomUUID().toString());
  107. return sql;
  108. }
  109. /**
  110. * 执行JAVA增强
  111. */
  112. private void executeJavaExtend(String cgJavaType,String cgJavaValue,Map<String,Object> data) throws Exception {
  113. if(StringUtil.isNotEmpty(cgJavaValue)){
  114. Object obj = null;
  115. try {
  116. if("class".equals(cgJavaType)){
  117. //因新增时已经校验了实例化是否可以成功,所以这块就不需要再做一次判断
  118. obj = MyClassLoader.getClassByScn(cgJavaValue).newInstance();
  119. }else if("spring".equals(cgJavaType)){
  120. obj = ApplicationContextUtil.getContext().getBean(cgJavaValue);
  121. }
  122. if(obj instanceof CgformEnhanceJavaInter){
  123. CgformEnhanceJavaInter javaInter = (CgformEnhanceJavaInter) obj;
  124. javaInter.execute("t_bus_user_talent_subsidy",data);
  125. }
  126. } catch (Exception e) {
  127. e.printStackTrace();
  128. throw new Exception("执行JAVA增强出现异常!");
  129. }
  130. }
  131. }
  132. }