ArticleFlowService.java 25 KB

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