ArticleFlowService.java 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851
  1. package space.apps.moudules.website.services.flow;
  2. import java.util.HashMap;
  3. import java.util.HashSet;
  4. import java.util.List;
  5. import java.util.Map;
  6. import java.util.Set;
  7. import org.apache.logging.log4j.LogManager;
  8. import org.apache.logging.log4j.Logger;
  9. import apps.pojo.Article;
  10. import apps.pojo.ArticleCopy;
  11. import apps.pojo.Audit;
  12. import apps.pojo.Department;
  13. import space.apps.common.ConstVars.dataStatusCode;
  14. import space.apps.moudules.website.common.ConstVars.articleStatusCode;
  15. import space.apps.moudules.website.util.ArticleUtil;
  16. import space.core.apps.bpm.bean.BpmApp;
  17. import space.core.apps.bpm.bean.StartChangeProcess;
  18. import space.core.apps.bpm.bean.StartDisableProces;
  19. import space.core.apps.bpm.bean.StartEnableProces;
  20. import space.core.apps.bpm.bean.StartProcess;
  21. import space.core.apps.bpm.utils.BpmAppUtil;
  22. import space.core.apps.bpm.utils.BpmProcessPageBeanUtil;
  23. import space.core.apps.bpm.utils.BpmProcessUtil;
  24. import space.core.apps.common.BaseTransaction;
  25. import space.core.common.utils.DateTimeUtil;
  26. import space.core.common.utils.GsonUtil;
  27. import space.core.common.utils.StringUtil;
  28. import space.core.db.bean.base.PageBean;
  29. import space.core.db.jdbc.GeneralDBAccess;
  30. import space.core.db.jdbc.SqlCommandImpl;
  31. /**
  32. * 文章流程服务类
  33. *
  34. * @author 陈锋
  35. * @log 2020年10月11日 上午1:14:57
  36. *
  37. */
  38. public class ArticleFlowService extends BaseTransaction {
  39. static Logger log = LogManager.getLogger(ArticleFlowService.class);
  40. private static final long serialVersionUID = -2593351714351810842L;
  41. /**
  42. * 获取 BPM 里的文章对象
  43. *
  44. * @param gdba
  45. * @return
  46. * @throws Exception
  47. * @author 陈锋
  48. * @log 2020年10月11日
  49. */
  50. private Article getBPMArticle(GeneralDBAccess gdba) throws Exception {
  51. Map<String, String> paramMap = getBpmParamMap();
  52. Long articleid = Long.valueOf(paramMap.get("articleid").toString());
  53. Article article = new Article();
  54. article.setArticleid(articleid);
  55. gdba.selectById(article);
  56. return article;
  57. }
  58. /**
  59. * 获取文章对象
  60. * @param gdba
  61. * @param articleid
  62. * @return
  63. * @throws Exception
  64. * @author 陈锋
  65. * @log 2020年10月11日
  66. */
  67. private Article getArticleById(GeneralDBAccess gdba, Long articleid) throws Exception {
  68. Article article = new Article();
  69. article.setArticleid(articleid);
  70. gdba.selectById(article);
  71. if (article.getDcode() == null) {
  72. throw new Exception("文章不存在");
  73. }
  74. return article;
  75. }
  76. /**
  77. *
  78. * 获取部门负责人
  79. *
  80. * @param gdba
  81. * @param mtCode 类别码
  82. * @param departmentid 部门 id
  83. * @return
  84. * @throws Exception
  85. * @author 陈锋
  86. * @log 2020年10月29日
  87. */
  88. private List<Map<String, Object>> getDepartmentManageByMtcode(GeneralDBAccess gdba, Long mtCode, Long departmentid) throws Exception {
  89. StringBuilder sqlBuilder = new StringBuilder();
  90. if (mtCode.equals(10030L)) { // 人员
  91. sqlBuilder.append(" select p.personid from person p ");
  92. // 在用、并且不是离职的
  93. sqlBuilder.append(" where p.dcode = 61 and p.pcode != 10001 and p.personid in ");
  94. }
  95. sqlBuilder.append(" (Select objectid from department_manage where departmentid = :departmentid and mtcode = :mtcode )");
  96. SqlCommandImpl sqlCmd = new SqlCommandImpl(sqlBuilder.toString());
  97. sqlCmd.setString("mtcode", mtCode).setString("departmentid", departmentid);
  98. return gdba.selectAsMapList(sqlCmd);
  99. }
  100. /**
  101. * 验证是否有部门负责人
  102. *
  103. * @param gdba
  104. * @param article 文章
  105. * @param departmentName 部门名
  106. * @param departmentid 部门 id
  107. * @throws Exception
  108. * @author 陈锋
  109. * @log 2020年10月31日
  110. */
  111. private void verifyDepartmentChargePerson(GeneralDBAccess gdba, Article article, String departmentName, Long departmentid) throws Exception {
  112. try {
  113. List<Map<String, Object>> personList = getDepartmentManageByMtcode(gdba, 10030L, departmentid);
  114. if (personList.size() == 0) {
  115. throw new Exception("未找到「" + departmentName + "」部门负责人");
  116. }
  117. } catch (Exception e) {
  118. updateArticleById(gdba, article);
  119. throw new Exception("未找到「" + departmentName + "」部门负责人");
  120. }
  121. }
  122. /**
  123. * 更新文章为“录入”状态
  124. *
  125. * @param gdba
  126. * @param article 文章
  127. * @throws Exception
  128. * @author 陈锋
  129. * @log 2020年10月31日
  130. */
  131. private void updateArticleById(GeneralDBAccess gdba, Article article) throws Exception {
  132. article.setDcode(dataStatusCode.INSERT.getCode());
  133. Set<String> updateSet = new HashSet<String>();
  134. updateSet.add("dcode");
  135. gdba.updateById(article, updateSet);
  136. gdba.commit();
  137. }
  138. /**
  139. * 验证文章是否有栏目负责人
  140. *
  141. * @param gdba
  142. * @param article 文章
  143. * @throws Exception
  144. * @author 陈锋
  145. * @log 2020年10月10日
  146. */
  147. private void verifyNavigationPerson(GeneralDBAccess gdba, Article article) throws Exception {
  148. try {
  149. List<Object> list = ArticleUtil.getManageByWnmcode(gdba, 10020L, article.getNavigationid());// 文章负责对象,栏目
  150. if (list.size() == 0) {
  151. throw new Exception("未找到栏目负责对象");
  152. }
  153. } catch (Exception e) {
  154. updateArticleById(gdba, article);
  155. throw new Exception("未找到栏目负责对象");
  156. }
  157. }
  158. /**
  159. * 启动文章变动流程的前置服务
  160. *
  161. * @return
  162. * @throws Exception
  163. * @author 陈锋
  164. * @log 2020年10月7日
  165. */
  166. public String startArticleChangeProcessBefore() throws Exception {
  167. Article article = getArticleById(getGdbaInstance(), getParameterToLong("articleid"));
  168. setBPMStartChangeProcess("article_start_change_submit",article.getArticleid(), null, article.getTitle(), article.getDesc());
  169. return DEFAULT_FORWARD;
  170. }
  171. /**
  172. * 启动文章变动流程
  173. * @return
  174. * @throws Exception
  175. * @author 陈锋
  176. * @log 2020年10月7日
  177. */
  178. public String startArticleChangeProcess() throws Exception {
  179. GeneralDBAccess gdba = getGdbaInstance();
  180. Article article = null;
  181. try {
  182. if (getAppUser() == null) {
  183. throw new Exception("登录会话已失效,请重新登录");
  184. }
  185. StartChangeProcess startChangeProcess = getStartChangeProcess();
  186. article = getArticleById(gdba, startChangeProcess.getChangeId());
  187. startChangeProcess.setChangeTitle(article.getTitle());
  188. Department department = getAppUser().getDepartment();
  189. if (department == null && getAppUser().getPerson() != null
  190. && getAppUser().getPerson().getDepartmentid() != null) {
  191. department = new Department();
  192. department.setDepartmentid(getAppUser().getPerson().getDepartmentid());
  193. gdba.selectById(department);
  194. }
  195. if (department == null) {
  196. throw new Exception("当前登录用户未关联部门,无法发起流程");
  197. }
  198. // 撤回当前数据未结束的流程
  199. Map<String, String> paramMap = new HashMap<String, String>();
  200. BpmProcessUtil.withdrawTaskByPageBean(gdba, article, getWebApp(), getAppUser(), paramMap);
  201. withdrawArticleCopy(gdba, article);// 收回
  202. verifyDepartmentChargePerson(gdba, article, department.getName(), department.getDepartmentid());
  203. verifyNavigationPerson(gdba, article);
  204. Map<String, String> dcodeMap = new HashMap<String, String>();
  205. dcodeMap.put(ArticleCopy.class.getName(), "dcode");
  206. BpmProcessUtil.startChangeProcess(getWebApp(), startChangeProcess.getChangeTitle(), "articleChange", getAppUser(), article,
  207. gdba, startChangeProcess.getChangeDescribe(), dcodeMap);
  208. gdba.commit();
  209. setResponsePackage(getResponseSuccessMsgPackage("发起成功"));
  210. } catch (Exception e) {
  211. e.printStackTrace();
  212. String errMsg = e.getMessage();
  213. if (errMsg == null || errMsg.trim().isEmpty()) {
  214. errMsg = e.getClass().getSimpleName();
  215. }
  216. setResponsePackage(getResponseErrorMsgPackage("发起失败:" + errMsg));
  217. }
  218. return DEFAULT_FORWARD;
  219. }
  220. /**
  221. * 撤回未审核的文章抄送
  222. *
  223. * @param gdba
  224. * @param article
  225. * @throws Exception
  226. * @author 陈锋
  227. * @log 2020年10月31日
  228. */
  229. private void withdrawArticleCopy(GeneralDBAccess gdba, Article article) throws Exception {
  230. String sql = "select * from article_copy where articleid = :articleid and dcode in(21, 31, 41, 51) ";
  231. SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
  232. sqlCmd.setString("articleid", article.getArticleid());
  233. List<ArticleCopy> ArticleCopyList = gdba.selectAsList(sqlCmd, ArticleCopy.class);
  234. Set<String> updateSet = new HashSet<String>();
  235. updateSet.add("dcode");
  236. for (ArticleCopy articleCopy : ArticleCopyList) {
  237. articleCopy.setDcode(dataStatusCode.INSERT_AUDIT.getCode());
  238. gdba.updateById(articleCopy, updateSet);
  239. }
  240. }
  241. /**
  242. * 启动文章流程的前置服务
  243. *
  244. * @return
  245. * @throws Exception
  246. * @author 陈锋
  247. * @log 2020年2月25日
  248. */
  249. public String startArticleProcessBefore() throws Exception {
  250. Article article = getArticleById(getGdbaInstance(), getParameterToLong("articleid"));
  251. setBPMStartParam("article_start_submit", article.getArticleid(), article.getTitle(), article.getDesc());
  252. return DEFAULT_FORWARD;
  253. }
  254. /**
  255. * 启动文章流程
  256. *
  257. * @return
  258. * @throws Exception
  259. * @author 陈锋
  260. * @log 2020年2月25日
  261. */
  262. public String startArticleProcess() throws Exception {
  263. try {
  264. if (getAppUser() == null) {
  265. throw new Exception("登录会话已失效,请重新登录");
  266. }
  267. GeneralDBAccess gdba = getGdbaInstance();
  268. StartProcess startProcess = getStartProcess();
  269. Article article = getArticleById(gdba, startProcess.getId());
  270. startProcess.setTitle(article.getTitle());
  271. Department department = getAppUser().getDepartment();
  272. if (department == null && getAppUser().getPerson() != null
  273. && getAppUser().getPerson().getDepartmentid() != null) {
  274. department = new Department();
  275. department.setDepartmentid(getAppUser().getPerson().getDepartmentid());
  276. gdba.selectById(department);
  277. }
  278. if (department == null) {
  279. throw new Exception("当前登录用户未关联部门,无法发起流程");
  280. }
  281. try {
  282. verifyDepartmentChargePerson(gdba, article, department.getName(), department.getDepartmentid());
  283. verifyNavigationPerson(gdba, article);
  284. } catch (Exception e) {
  285. throw new Exception("流程前置校验失败:" + (e.getMessage() != null ? e.getMessage() : e.getClass().getSimpleName()));
  286. }
  287. Map<String, String> dcodeMap = new HashMap<String, String>();
  288. dcodeMap.put(Article.class.getName(), "dcode");
  289. dcodeMap.put(ArticleCopy.class.getName(), "dcode");
  290. try {
  291. // 草稿 dcode=21 时 BpmProcessPageBeanUtil 无法自动推断 startType,需显式指定 add
  292. BpmProcessUtil.startProcess(getWebApp(), startProcess.getTitle(), "articleRelease", getAppUser(), article,
  293. gdba, startProcess.getDescribe(), dcodeMap, "add", null);
  294. } catch (Exception e) {
  295. throw new Exception("BPM启动失败:" + (e.getMessage() != null ? e.getMessage() : e.getClass().getSimpleName()));
  296. }
  297. // 录入(11)/待提交(12) 发起时 BpmProcessPageBeanUtil 只会写成 21,父列表仍显示可再次申请;统一落为审核中(31)
  298. article = getArticleById(gdba, startProcess.getId());
  299. if (Long.valueOf(dataStatusCode.INSERT_AUDIT.getCode()).equals(article.getDcode())) {
  300. article.setDcode(dataStatusCode.USE_AUDIT.getCode());
  301. Set<String> dcodeFields = new HashSet<String>();
  302. dcodeFields.add("dcode");
  303. gdba.updateById(article, dcodeFields);
  304. }
  305. gdba.commit();
  306. setResponsePackage(getResponseSuccessMsgPackage("发起成功"));
  307. } catch (Exception e) {
  308. e.printStackTrace();
  309. String errMsg = e.getMessage();
  310. if (errMsg == null || errMsg.trim().isEmpty()) {
  311. errMsg = e.getClass().getSimpleName();
  312. }
  313. setResponsePackage(getResponseErrorMsgPackage("发起失败:" + errMsg));
  314. }
  315. return DEFAULT_FORWARD;
  316. }
  317. /**
  318. * 同意发布文章
  319. *
  320. * @author 陈锋
  321. * @throws Exception
  322. * @log 2020年2月25日
  323. */
  324. public void agree() throws Exception {
  325. try {
  326. BpmApp bpmApp = BpmAppUtil.getBpmApp();
  327. GeneralDBAccess gdba = bpmApp.getGdba();
  328. Map<String, String> paramMap = getBpmParamMap();
  329. Long articleid = Long.valueOf(paramMap.get("articleid").toString());
  330. Article article = new Article();
  331. article.setArticleid(articleid);
  332. gdba.selectById(article);
  333. article.setLastChangeTime(DateTimeUtil.getNowTimestamp());
  334. // 定时发布
  335. if (article.getRelease() == 1) {
  336. // 发布时间
  337. if (StringUtil.notNull(article.getReleaseTime())
  338. && article.getReleaseTime().getTime() <= DateTimeUtil.getCurrentTimeMillis()) {
  339. article.setAscode(articleStatusCode.HAS_RELEASE.getCode());
  340. article.setReleaseTaskSchedulesid(null);
  341. }
  342. } else {
  343. // 没有设置定时发布,则审核完流程时,自动发布
  344. article.setAscode(articleStatusCode.HAS_RELEASE.getCode());
  345. if (StringUtil.isNull(article.getReleaseTime())) {
  346. article.setReleaseTime(DateTimeUtil.getNowTimestamp());
  347. }
  348. }
  349. gdba.updateById(article);
  350. BpmProcessPageBeanUtil.updatePageBeanForAgree(gdba, article);
  351. agreeAuthorizedArticleCopy(gdba, articleid);
  352. } catch (Exception e) {
  353. // 文章里的同意失败
  354. throw new Exception("同意发布文章失败");
  355. }
  356. }
  357. /**
  358. * 主栏目审核通过后,自动通过“申请人本身就是抄送栏目负责人”的抄送记录。
  359. * 其他抄送记录仍进入抄送审。
  360. *
  361. * @param gdba 数据库
  362. * @param articleid 文章 ID
  363. * @throws Exception
  364. */
  365. private void agreeAuthorizedArticleCopy(GeneralDBAccess gdba, Long articleid) throws Exception {
  366. String sql = "select * from article_copy where articleid = :articleid and dcode in (21, 31, 41, 51) ";
  367. SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
  368. sqlCmd.setString("articleid", articleid);
  369. List<ArticleCopy> articleCopyList = gdba.selectAsList(sqlCmd, ArticleCopy.class);
  370. Set<String> updateSet = new HashSet<String>();
  371. updateSet.add("dcode");
  372. for (ArticleCopy articleCopy : articleCopyList) {
  373. if (!ArticleUtil.isNavigationManager(gdba, 10020L, articleCopy.getNavigationid(), articleCopy.getCreatePid())) {
  374. continue;
  375. }
  376. articleCopy.setDcode(dataStatusCode.USE.getCode());
  377. gdba.updateById(articleCopy, updateSet);
  378. }
  379. }
  380. /**
  381. * 拒绝发布文章
  382. *
  383. * @author 陈锋
  384. * @throws Exception
  385. * @log 2020年2月25日
  386. */
  387. public void reject() throws Exception {
  388. try {
  389. BpmApp bpmApp = BpmAppUtil.getBpmApp();
  390. GeneralDBAccess gdba = bpmApp.getGdba();
  391. Map<String, String> paramMap = getBpmParamMap();
  392. Long articleid = Long.valueOf(paramMap.get("articleid").toString());
  393. Article article = new Article();
  394. article.setArticleid(articleid);
  395. gdba.selectById(article);
  396. article.setLastChangeTime(DateTimeUtil.getNowTimestamp());
  397. gdba.updateById(article);
  398. BpmProcessPageBeanUtil.updatePageBeanForReject(gdba, article);
  399. } catch (Exception e) {
  400. throw new Exception("退回发布文章失败");
  401. }
  402. }
  403. /**
  404. * 同意抄送文章
  405. *
  406. * @throws Exception
  407. * @author 陈锋
  408. * @log 2020年2月25日
  409. */
  410. public void agreeArticleCopy() throws Exception {
  411. try {
  412. Map<String, String> paramMap = getBpmParamMap();
  413. BpmApp bpmApp = BpmAppUtil.getBpmApp();
  414. Audit audit = bpmApp.getAudit();
  415. Map<String, Object> paramAuditMap = GsonUtil.jsonToMap2(audit.getForeachVar());
  416. String sql = "select * from article_copy WHERE navigationid = :navigationid AND articleid = :articleid ";// AND dcode = :dcode
  417. SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
  418. sqlCmd.setInt("articleid", paramMap.get("articleid"));
  419. sqlCmd.setInt("navigationid", paramAuditMap.get("navigationid"));
  420. // sqlCmd.setInt("dcode", dataStatusCode.INSERT_AUDIT.getCode());
  421. GeneralDBAccess gdba = bpmApp.getGdba();
  422. List<PageBean> pageBeanList = gdba.selectAsList(sqlCmd, ArticleCopy.class);
  423. BpmProcessPageBeanUtil.updatePageBeanForAgree(gdba, pageBeanList);
  424. } catch (Exception e) {
  425. throw new Exception("同意抄送文章失败");
  426. }
  427. }
  428. /**
  429. * 同意直通发布文章。
  430. * 用于“开始 -> 结束”的发布流程:没有抄送审核节点,需要在结束时同步发布主文章和抄送栏目。
  431. *
  432. * @throws Exception
  433. */
  434. public void agreeDirectRelease() throws Exception {
  435. try {
  436. agree();
  437. Map<String, String> paramMap = getBpmParamMap();
  438. String sql = "select * from article_copy WHERE articleid = :articleid ";
  439. SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
  440. sqlCmd.setInt("articleid", paramMap.get("articleid"));
  441. BpmApp bpmApp = BpmAppUtil.getBpmApp();
  442. GeneralDBAccess gdba = bpmApp.getGdba();
  443. List<PageBean> pageBeanList = gdba.selectAsList(sqlCmd, ArticleCopy.class);
  444. BpmProcessPageBeanUtil.updatePageBeanForAgree(gdba, pageBeanList);
  445. } catch (Exception e) {
  446. throw new Exception("同意直通发布文章失败");
  447. }
  448. }
  449. /**
  450. * 拒绝抄送文章
  451. *
  452. * @throws Exception
  453. * @author 陈锋
  454. * @log 2020年2月25日
  455. */
  456. public void rejectArticleCopy() throws Exception {
  457. try {
  458. Map<String, String> paramMap = getBpmParamMap();
  459. BpmApp bpmApp = BpmAppUtil.getBpmApp();
  460. Audit audit = bpmApp.getAudit();
  461. Map<String, Object> paramAuditMap = GsonUtil.jsonToMap2(audit.getForeachVar());
  462. String sql = "select * from article_copy WHERE navigationid = :navigationid AND articleid = :articleid ";// AND dcode = :dcode
  463. SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
  464. sqlCmd.setInt("articleid", paramMap.get("articleid"));
  465. sqlCmd.setInt("navigationid", paramAuditMap.get("navigationid"));
  466. // sqlCmd.setInt("dcode", dataStatusCode.INSERT_AUDIT.getCode());
  467. GeneralDBAccess gdba = bpmApp.getGdba();
  468. List<PageBean> pageBeanList = gdba.selectAsList(sqlCmd, ArticleCopy.class);
  469. BpmProcessPageBeanUtil.updatePageBeanForReject(gdba, pageBeanList);
  470. } catch (Exception e) {
  471. throw new Exception("退回抄送文章失败");
  472. }
  473. }
  474. /**
  475. * 启动停用文章流程的前置服务
  476. *
  477. * @return
  478. * @throws Exception
  479. * @author 陈锋
  480. * @log 2020年10月11日
  481. */
  482. public String startDisableArticleProcessBefore() throws Exception {
  483. Article article = getArticleById(getGdbaInstance(), getParameterToLong("articleid"));
  484. setBPMStartDisableProcess("article_start_disable_submit", article.getArticleid(), article.getTitle(), article.getDesc());
  485. return DISABLE_APPLY_FORWARD;
  486. }
  487. /**
  488. * 启动停用文章流程
  489. *
  490. * @return
  491. * @throws Exception
  492. * @author 陈锋
  493. * @log 2020年10月11日
  494. */
  495. public String startDisableArticleProcess() throws Exception {
  496. try {
  497. GeneralDBAccess gdba = getGdbaInstance();
  498. StartDisableProces startDisableProcess = getStartDisableProcess();
  499. Article article = new Article();
  500. article.setArticleid(startDisableProcess.getId());
  501. gdba.selectById(article);
  502. // 停用抄送的栏目
  503. // String sql = "select * from article_copy where articleid = :articleid ";
  504. // SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
  505. // sqlCmd.setInt("articleid", article.getArticleid());
  506. // List<PageBean> articleCopyList = gdba.selectAsList(sqlCmd, ArticleCopy.class);
  507. //
  508. // Map<String, String> dcodeMap = new HashMap<String, String>();
  509. // dcodeMap.put(ArticleCopy.class.getName(), "dcode");// 防止没有抄送记录
  510. //
  511. // BpmProcessUtil.startDisableProcess(getWebApp(), startDisableProcess.getTitle(), "articleDisable", getAppUser(), article,
  512. // gdba, startDisableProcess.getDescribe(), articleCopyList, dcodeMap);
  513. // BpmProcessUtil.startDisableProcess(getWebApp(), startDisableProcess.getTitle(), "articleDisable", getAppUser(), article,
  514. // gdba, startDisableProcess.getDescribe(), null);
  515. gdba.commit();
  516. setResponsePackage(getResponseSuccessMsgPackage("发起成功"));
  517. } catch (Exception e) {
  518. e.printStackTrace();
  519. setResponsePackage(getResponseErrorMsgPackage("发起失败:" + e.getMessage()));
  520. }
  521. return DEFAULT_FORWARD;
  522. }
  523. /**
  524. * 同意停用文章审核
  525. *
  526. * @return
  527. * @throws Exception
  528. * @author 陈锋
  529. * @log 2020年10月11日
  530. */
  531. public String agreeDisable() throws Exception {
  532. try {
  533. BpmApp bpmApp = BpmAppUtil.getBpmApp();
  534. GeneralDBAccess gdba = bpmApp.getGdba();
  535. Article article = getBPMArticle(gdba);
  536. article.setLastChangeTime(DateTimeUtil.getNowTimestamp());
  537. gdba.updateById(article);
  538. // 把抄送到的栏目全部停用
  539. // String sql = "UPDATE article_copy SET dcode = '71' WHERE articleid = :articleid ";
  540. // SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
  541. // sqlCmd.setInt("articleid", article.getArticleid());
  542. // gdba.modify(sqlCmd);
  543. BpmProcessPageBeanUtil.updatePageBeanForAgree(gdba, article);
  544. } catch (Exception e) {
  545. throw new Exception("同意停用文章失败");
  546. }
  547. return DEFAULT_FORWARD;
  548. }
  549. /**
  550. * 拒绝停用文章审核
  551. *
  552. * @return
  553. * @throws Exception
  554. * @author 陈锋
  555. * @log 2020年10月11日
  556. */
  557. public String rejectDisable() throws Exception {
  558. try {
  559. BpmApp bpmApp = BpmAppUtil.getBpmApp();
  560. GeneralDBAccess gdba = bpmApp.getGdba();
  561. Article article = getBPMArticle(gdba);
  562. article.setLastChangeTime(DateTimeUtil.getNowTimestamp());
  563. gdba.updateById(article);
  564. // String sql = "SELECT * FROM article_copy WHERE articleid = :articleid ";
  565. // SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
  566. // sqlCmd.setInt("articleid", article.getArticleid());
  567. // List<PageBean> articleCopyList = gdba.selectAsList(sqlCmd, ArticleCopy.class);
  568. // BpmProcessPageBeanUtil.updatePageBeanForReject(gdba, articleCopyList);
  569. BpmProcessPageBeanUtil.updatePageBeanForReject(gdba, article);
  570. } catch (Exception e) {
  571. throw new Exception("退回停用文章失败");
  572. }
  573. return DEFAULT_FORWARD;
  574. }
  575. /**
  576. * 启动启用文章流程的前置服务
  577. *
  578. * @return
  579. * @throws Exception
  580. * @author 陈锋
  581. * @log 2020年10月11日
  582. */
  583. public String startEnableArticleProcessBefore() throws Exception {
  584. Article article = getArticleById(getGdbaInstance(), getParameterToLong("articleid"));
  585. setBPMStartEnableProcess("article_start_enable_submit", article.getArticleid(), article.getTitle(), article.getDesc());
  586. return ENABLE_APPLY_FORWARD;
  587. }
  588. /**
  589. * 启动启用文章流程
  590. *
  591. * @return
  592. * @throws Exception
  593. * @author 陈锋
  594. * @log 2020年10月11日
  595. */
  596. public String startEnableArticleProcess() throws Exception {
  597. try {
  598. GeneralDBAccess gdba = getGdbaInstance();
  599. StartEnableProces startEnableProces = getStartEnableProcess();
  600. Article article = getArticleById(gdba, startEnableProces.getId());
  601. Department department = getAppUser().getDepartment();
  602. verifyDepartmentChargePerson(gdba, article, department.getName(), department.getDepartmentid());
  603. verifyNavigationPerson(gdba, article);
  604. // String sql = "select * from article_copy where articleid = :articleid ";
  605. // SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
  606. // sqlCmd.setInt("articleid", article.getArticleid());
  607. // List<PageBean> articleCopyList = gdba.selectAsList(sqlCmd, ArticleCopy.class);
  608. //
  609. // Map<String, String> dcodeMap = new HashMap<String, String>();
  610. // dcodeMap.put(ArticleCopy.class.getName(), "dcode");// 防止没有抄送记录
  611. //
  612. // BpmProcessUtil.startEnableProcess(getWebApp(), startEnableProces.getTitle(), "articleEnable", getAppUser(), article,
  613. // gdba, startEnableProces.getDescribe(), articleCopyList, dcodeMap);
  614. // BpmProcessUtil.startEnableProcess(getWebApp(), startEnableProces.getTitle(), "articleEnable", getAppUser(), article,
  615. // gdba, startEnableProces.getDescribe(), null);
  616. gdba.commit();
  617. setResponsePackage(getResponseSuccessMsgPackage("发起成功"));
  618. } catch (Exception e) {
  619. e.printStackTrace();
  620. setResponsePackage(getResponseErrorMsgPackage("发起失败:" + e.getMessage()));
  621. }
  622. return DEFAULT_FORWARD;
  623. }
  624. /**
  625. * 同意启用文章审核
  626. *
  627. * @return
  628. * @throws Exception
  629. * @author 陈锋
  630. * @log 2020年10月11日
  631. */
  632. public String agreeEnable() throws Exception {
  633. try {
  634. BpmApp bpmApp = BpmAppUtil.getBpmApp();
  635. GeneralDBAccess gdba = bpmApp.getGdba();
  636. Article article = getBPMArticle(gdba);
  637. article.setLastChangeTime(DateTimeUtil.getNowTimestamp());
  638. gdba.updateById(article);
  639. BpmProcessPageBeanUtil.updatePageBeanForAgree(gdba, article);
  640. // gdba.commit();
  641. } catch (Exception e) {
  642. throw new Exception("同意启用文章失败");
  643. }
  644. return DEFAULT_FORWARD;
  645. }
  646. /**
  647. * 拒绝启用文章审核
  648. *
  649. * @return
  650. * @throws Exception
  651. * @author 陈锋
  652. * @log 2020年10月11日
  653. */
  654. public String rejectEnable() throws Exception {
  655. try {
  656. BpmApp bpmApp = BpmAppUtil.getBpmApp();
  657. GeneralDBAccess gdba = bpmApp.getGdba();
  658. Article article = getBPMArticle(gdba);
  659. article.setLastChangeTime(DateTimeUtil.getNowTimestamp());
  660. gdba.updateById(article);
  661. BpmProcessPageBeanUtil.updatePageBeanForReject(gdba, article);
  662. // gdba.commit();
  663. } catch (Exception e) {
  664. throw new Exception("退回启用文章失败");
  665. }
  666. return DEFAULT_FORWARD;
  667. }
  668. /**
  669. * 撤回(收回)文章流程时,改变文章抄送栏目状态,文章状态已在流程自动改了
  670. *
  671. * @return
  672. * @author 陈锋
  673. * @throws Exception
  674. * @log 2020年11月3日
  675. */
  676. public String withdrawArticleFlow() throws Exception {
  677. BpmApp bpmApp = BpmAppUtil.getBpmApp();
  678. GeneralDBAccess gdba = bpmApp.getGdba();
  679. Article article = getBPMArticle(gdba);
  680. article.setDcode(dataStatusCode.INSERT.getCode());
  681. gdba.updateById(article);
  682. // 更新文章的抄送栏目为“录入”状态
  683. String sql = "update article_copy set dcode = 21 where articleid = :articleid ";
  684. SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
  685. sqlCmd.setInt("articleid", article.getArticleid());
  686. gdba.modify(sqlCmd);
  687. return DEFAULT_FORWARD;
  688. }
  689. }