executeTemplate.vm 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package com.miniframe.bisiness.$tools.toLower($!map.get("code"));
  2. import java.util.Map;
  3. import com.miniframe.core.ExecProcessFlow;
  4. #set ( $package = "system.model."+$tools.toUpper($!map.get("交易编码"))+"BaseModel")
  5. import com.miniframe.generate.business.$package;
  6. import com.miniframe.tools.XIFileUtils;
  7. import java.io.File;
  8. import java.io.RandomAccessFile;
  9. import java.math.BigDecimal;
  10. import java.nio.channels.FileChannel;
  11. import java.nio.channels.FileLock;
  12. /**
  13. * $!map.get("name"),“$!map.get("交易名称")”逻辑处理(重新生成不覆盖)。
  14. */
  15. public class $tools.toUpper($!map.get("交易编码"))Service extends $tools.toUpper($!map.get("交易编码"))BaseModel implements ExecProcessFlow {
  16. private static final long serialVersionUID = -7051358269847459502L;
  17. /**
  18. * $!map.get("name"),“$!map.get("交易名称")”业务核心处理
  19. */
  20. public void transExecute() throws Exception {
  21. }
  22. /**
  23. * $!map.get("name"),“$!map.get("交易名称")”业务前处理
  24. */
  25. public void preTransFlow() throws Exception {
  26. //this.validater();
  27. }
  28. /**
  29. * $!map.get("name"),“$!map.get("交易名称")”业务后处理
  30. */
  31. public void afterTransFlow() throws Exception {
  32. }
  33. /**
  34. * $!map.get("name"),“$!map.get("交易名称")”逻辑入口处理方法
  35. */
  36. @SuppressWarnings("rawtypes")
  37. @Override
  38. public Map execute(Map vars) throws Exception {
  39. this.setTransMap(vars);
  40. File file = XIFileUtils.getAbsolutePath(this.getClass().getSimpleName() + ".pid").toFile();
  41. RandomAccessFile raf = null;
  42. FileChannel fc = null;
  43. FileLock fl = null;
  44. try {
  45. raf = new RandomAccessFile(file, "rw");
  46. fc = raf.getChannel();
  47. try {
  48. fl = fc.tryLock();
  49. if (fl != null) {
  50. preTransFlow();// 执行业务开始的规则检查和校验
  51. transExecute();// 执行核心业务段
  52. afterTransFlow();// 执行核心逻辑完成后的收尾逻辑
  53. }
  54. } catch (Exception e) {
  55. } finally {
  56. //获得文件锁权限后,进行相应的操作
  57. if (fl != null) {
  58. fl.release();
  59. }
  60. fc.close();
  61. raf.close();
  62. }
  63. } catch (Exception e) {
  64. }
  65. return this.getTransMap();
  66. }
  67. }