ProvidentFundStrategyServiceImpl.java 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. package cn.com.lzt.providentfundstrategy.service.impl;
  2. import cn.com.lzt.providentfundstrategy.service.ProvidentFundStrategyServiceI;
  3. import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
  4. import cn.com.lzt.providentfundstrategy.entity.ProvidentFundStrategyEntity;
  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("providentFundStrategyService")
  16. @Transactional
  17. public class ProvidentFundStrategyServiceImpl extends CommonServiceImpl implements ProvidentFundStrategyServiceI {
  18. public void delete(ProvidentFundStrategyEntity entity) throws Exception{
  19. super.delete(entity);
  20. //执行删除操作增强业务
  21. this.doDelBus(entity);
  22. }
  23. // 逻辑删除
  24. public void logicDel(ProvidentFundStrategyEntity entity) throws Exception{
  25. super.updateEntitie(entity);
  26. //执行更新操作增强业务
  27. this.doUpdateBus(entity);
  28. }
  29. public Serializable save(ProvidentFundStrategyEntity entity) throws Exception{
  30. Serializable t = super.save(entity);
  31. //执行新增操作增强业务
  32. this.doAddBus(entity);
  33. return t;
  34. }
  35. public void saveOrUpdate(ProvidentFundStrategyEntity entity) throws Exception{
  36. super.saveOrUpdate(entity);
  37. //执行更新操作增强业务
  38. this.doUpdateBus(entity);
  39. }
  40. /**
  41. * 新增操作增强业务
  42. * @param t
  43. * @return
  44. */
  45. private void doAddBus(ProvidentFundStrategyEntity t) throws Exception{
  46. //-----------------sql增强 start----------------------------
  47. //-----------------sql增强 end------------------------------
  48. //-----------------java增强 start---------------------------
  49. //-----------------java增强 end-----------------------------
  50. }
  51. /**
  52. * 更新操作增强业务
  53. * @param t
  54. * @return
  55. */
  56. private void doUpdateBus(ProvidentFundStrategyEntity t) throws Exception{
  57. //-----------------sql增强 start----------------------------
  58. //-----------------sql增强 end------------------------------
  59. //-----------------java增强 start---------------------------
  60. //-----------------java增强 end-----------------------------
  61. }
  62. /**
  63. * 删除操作增强业务
  64. * @param id
  65. * @return
  66. */
  67. private void doDelBus(ProvidentFundStrategyEntity t) throws Exception{
  68. //-----------------sql增强 start----------------------------
  69. //-----------------sql增强 end------------------------------
  70. //-----------------java增强 start---------------------------
  71. //-----------------java增强 end-----------------------------
  72. }
  73. private Map<String,Object> populationMap(ProvidentFundStrategyEntity t){
  74. Map<String,Object> map = new HashMap<String,Object>();
  75. map.put("id", t.getId());
  76. map.put("create_name", t.getCreateName());
  77. map.put("create_by", t.getCreateBy());
  78. map.put("create_date", t.getCreateDate());
  79. map.put("update_name", t.getUpdateName());
  80. map.put("update_by", t.getUpdateBy());
  81. map.put("update_date", t.getUpdateDate());
  82. map.put("sys_org_code", t.getSysOrgCode());
  83. map.put("sys_company_code", t.getSysCompanyCode());
  84. map.put("provident_fund_name", t.getProvidentFundName());
  85. map.put("base_pay", t.getBasePay());
  86. map.put("personal_ratio", t.getPersonalRatio());
  87. map.put("company_ratio", t.getCompanyRatio());
  88. map.put("start_time", t.getStartTime());
  89. map.put("end_time", t.getEndTime());
  90. map.put("remark", t.getRemark());
  91. map.put("status", t.getStatus());
  92. map.put("delete_flag", t.getDeleteFlag());
  93. return map;
  94. }
  95. /**
  96. * 替换sql中的变量
  97. * @param sql
  98. * @param t
  99. * @return
  100. */
  101. public String replaceVal(String sql,ProvidentFundStrategyEntity t){
  102. sql = sql.replace("#{id}",String.valueOf(t.getId()));
  103. sql = sql.replace("#{create_name}",String.valueOf(t.getCreateName()));
  104. sql = sql.replace("#{create_by}",String.valueOf(t.getCreateBy()));
  105. sql = sql.replace("#{create_date}",String.valueOf(t.getCreateDate()));
  106. sql = sql.replace("#{update_name}",String.valueOf(t.getUpdateName()));
  107. sql = sql.replace("#{update_by}",String.valueOf(t.getUpdateBy()));
  108. sql = sql.replace("#{update_date}",String.valueOf(t.getUpdateDate()));
  109. sql = sql.replace("#{sys_org_code}",String.valueOf(t.getSysOrgCode()));
  110. sql = sql.replace("#{sys_company_code}",String.valueOf(t.getSysCompanyCode()));
  111. sql = sql.replace("#{provident_fund_name}",String.valueOf(t.getProvidentFundName()));
  112. sql = sql.replace("#{base_pay}",String.valueOf(t.getBasePay()));
  113. sql = sql.replace("#{personal_ratio}",String.valueOf(t.getPersonalRatio()));
  114. sql = sql.replace("#{company_ratio}",String.valueOf(t.getCompanyRatio()));
  115. sql = sql.replace("#{start_time}",String.valueOf(t.getStartTime()));
  116. sql = sql.replace("#{end_time}",String.valueOf(t.getEndTime()));
  117. sql = sql.replace("#{remark}",String.valueOf(t.getRemark()));
  118. sql = sql.replace("#{status}",String.valueOf(t.getStatus()));
  119. sql = sql.replace("#{delete_flag}",String.valueOf(t.getDeleteFlag()));
  120. sql = sql.replace("#{UUID}",UUID.randomUUID().toString());
  121. return sql;
  122. }
  123. /**
  124. * 执行JAVA增强
  125. */
  126. private void executeJavaExtend(String cgJavaType,String cgJavaValue,Map<String,Object> data) throws Exception {
  127. if(StringUtil.isNotEmpty(cgJavaValue)){
  128. Object obj = null;
  129. try {
  130. if("class".equals(cgJavaType)){
  131. //因新增时已经校验了实例化是否可以成功,所以这块就不需要再做一次判断
  132. obj = MyClassLoader.getClassByScn(cgJavaValue).newInstance();
  133. }else if("spring".equals(cgJavaType)){
  134. obj = ApplicationContextUtil.getContext().getBean(cgJavaValue);
  135. }
  136. if(obj instanceof CgformEnhanceJavaInter){
  137. CgformEnhanceJavaInter javaInter = (CgformEnhanceJavaInter) obj;
  138. javaInter.execute("t_bus_provident_fund_strategy",data);
  139. }
  140. } catch (Exception e) {
  141. e.printStackTrace();
  142. throw new Exception("执行JAVA增强出现异常!");
  143. }
  144. }
  145. }
  146. }