TBLogisticsServiceImpl.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. package cn.com.lzt.logistics.service.impl;
  2. import cn.com.lzt.logistics.service.TBLogisticsServiceI;
  3. import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
  4. import cn.com.lzt.logistics.entity.TBLogisticsEntity;
  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("tBLogisticsService")
  16. @Transactional
  17. public class TBLogisticsServiceImpl extends CommonServiceImpl implements TBLogisticsServiceI {
  18. public void delete(TBLogisticsEntity entity) throws Exception{
  19. super.delete(entity);
  20. //执行删除操作增强业务
  21. this.doDelBus(entity);
  22. }
  23. public Serializable save(TBLogisticsEntity entity) throws Exception{
  24. Serializable t = super.save(entity);
  25. //执行新增操作增强业务
  26. this.doAddBus(entity);
  27. return t;
  28. }
  29. public void saveOrUpdate(TBLogisticsEntity 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(TBLogisticsEntity t) throws Exception{
  40. }
  41. /**
  42. * 更新操作增强业务
  43. * @param t
  44. * @return
  45. */
  46. private void doUpdateBus(TBLogisticsEntity t) throws Exception{
  47. }
  48. /**
  49. * 删除操作增强业务
  50. * @param id
  51. * @return
  52. */
  53. private void doDelBus(TBLogisticsEntity t) throws Exception{
  54. }
  55. private Map<String,Object> populationMap(TBLogisticsEntity t){
  56. Map<String,Object> map = new HashMap<String,Object>();
  57. map.put("id", t.getId());
  58. map.put("create_name", t.getCreateName());
  59. map.put("create_by", t.getCreateBy());
  60. map.put("create_date", t.getCreateDate());
  61. map.put("update_name", t.getUpdateName());
  62. map.put("update_by", t.getUpdateBy());
  63. map.put("update_date", t.getUpdateDate());
  64. map.put("company_name", t.getCompanyName());
  65. map.put("company_code", t.getCompanyCode());
  66. map.put("contact_person", t.getContactPerson());
  67. map.put("mobile_phone", t.getMobilePhone());
  68. map.put("office_phone", t.getOfficePhone());
  69. map.put("email", t.getEmail());
  70. map.put("fax", t.getFax());
  71. map.put("address", t.getAddress());
  72. map.put("status", t.getStatus());
  73. map.put("delete_flag", t.getDeleteFlag());
  74. return map;
  75. }
  76. /**
  77. * 替换sql中的变量
  78. * @param sql
  79. * @param t
  80. * @return
  81. */
  82. public String replaceVal(String sql,TBLogisticsEntity t){
  83. sql = sql.replace("#{id}",String.valueOf(t.getId()));
  84. sql = sql.replace("#{create_name}",String.valueOf(t.getCreateName()));
  85. sql = sql.replace("#{create_by}",String.valueOf(t.getCreateBy()));
  86. sql = sql.replace("#{create_date}",String.valueOf(t.getCreateDate()));
  87. sql = sql.replace("#{update_name}",String.valueOf(t.getUpdateName()));
  88. sql = sql.replace("#{update_by}",String.valueOf(t.getUpdateBy()));
  89. sql = sql.replace("#{update_date}",String.valueOf(t.getUpdateDate()));
  90. sql = sql.replace("#{company_name}",String.valueOf(t.getCompanyName()));
  91. sql = sql.replace("#{company_code}",String.valueOf(t.getCompanyCode()));
  92. sql = sql.replace("#{contact_person}",String.valueOf(t.getContactPerson()));
  93. sql = sql.replace("#{mobile_phone}",String.valueOf(t.getMobilePhone()));
  94. sql = sql.replace("#{office_phone}",String.valueOf(t.getOfficePhone()));
  95. sql = sql.replace("#{email}",String.valueOf(t.getEmail()));
  96. sql = sql.replace("#{fax}",String.valueOf(t.getFax()));
  97. sql = sql.replace("#{address}",String.valueOf(t.getAddress()));
  98. sql = sql.replace("#{status}",String.valueOf(t.getStatus()));
  99. sql = sql.replace("#{delete_flag}",String.valueOf(t.getDeleteFlag()));
  100. sql = sql.replace("#{UUID}",UUID.randomUUID().toString());
  101. return sql;
  102. }
  103. /**
  104. * 执行JAVA增强
  105. */
  106. private void executeJavaExtend(String cgJavaType,String cgJavaValue,Map<String,Object> data) throws Exception {
  107. // if(StringUtil.isNotEmpty(cgJavaValue)){
  108. // Object obj = null;
  109. // try {
  110. // if("class".equals(cgJavaType)){
  111. // //因新增时已经校验了实例化是否可以成功,所以这块就不需要再做一次判断
  112. // obj = MyClassLoader.getClassByScn(cgJavaValue).newInstance();
  113. // }else if("spring".equals(cgJavaType)){
  114. // obj = ApplicationContextUtil.getContext().getBean(cgJavaValue);
  115. // }
  116. // if(obj instanceof CgformEnhanceJavaInter){
  117. // CgformEnhanceJavaInter javaInter = (CgformEnhanceJavaInter) obj;
  118. // javaInter.execute(data);
  119. // }
  120. // } catch (Exception e) {
  121. // e.printStackTrace();
  122. // throw new Exception("执行JAVA增强出现异常!");
  123. // }
  124. // }
  125. }
  126. }