| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841 |
- package space.apps.moudules.website.services.flow;
- import java.util.HashMap;
- import java.util.HashSet;
- import java.util.List;
- import java.util.Map;
- import java.util.Set;
- import org.apache.logging.log4j.LogManager;
- import org.apache.logging.log4j.Logger;
- import apps.pojo.Article;
- import apps.pojo.ArticleCopy;
- import apps.pojo.Audit;
- import apps.pojo.Department;
- import space.apps.common.ConstVars.dataStatusCode;
- import space.apps.moudules.website.common.ConstVars.articleStatusCode;
- import space.apps.moudules.website.util.ArticleUtil;
- import space.core.apps.bpm.bean.BpmApp;
- import space.core.apps.bpm.bean.StartChangeProcess;
- import space.core.apps.bpm.bean.StartDisableProces;
- import space.core.apps.bpm.bean.StartEnableProces;
- import space.core.apps.bpm.bean.StartProcess;
- import space.core.apps.bpm.utils.BpmAppUtil;
- import space.core.apps.bpm.utils.BpmProcessPageBeanUtil;
- import space.core.apps.bpm.utils.BpmProcessUtil;
- import space.core.apps.common.BaseTransaction;
- import space.core.common.utils.DateTimeUtil;
- import space.core.common.utils.GsonUtil;
- import space.core.common.utils.StringUtil;
- import space.core.db.bean.base.PageBean;
- import space.core.db.jdbc.GeneralDBAccess;
- import space.core.db.jdbc.SqlCommandImpl;
- /**
- * 文章流程服务类
- *
- * @author 陈锋
- * @log 2020年10月11日 上午1:14:57
- *
- */
- public class ArticleFlowService extends BaseTransaction {
- static Logger log = LogManager.getLogger(ArticleFlowService.class);
-
- private static final long serialVersionUID = -2593351714351810842L;
-
- /**
- * 获取 BPM 里的文章对象
- *
- * @param gdba
- * @return
- * @throws Exception
- * @author 陈锋
- * @log 2020年10月11日
- */
- private Article getBPMArticle(GeneralDBAccess gdba) throws Exception {
- Map<String, String> paramMap = getBpmParamMap();
- Long articleid = Long.valueOf(paramMap.get("articleid").toString());
- Article article = new Article();
- article.setArticleid(articleid);
- gdba.selectById(article);
-
- return article;
- }
-
- /**
- * 获取文章对象
- * @param gdba
- * @param articleid
- * @return
- * @throws Exception
- * @author 陈锋
- * @log 2020年10月11日
- */
- private Article getArticleById(GeneralDBAccess gdba, Long articleid) throws Exception {
- // 显式列查询:生产 article 表含 guest_access_flag,但 apps.pojo.Article 未同步该字段
- String sql = "SELECT articleid, dcode, title, `desc`, navigationid, unitid, websiteid, ascode,"
- + " create_pid, last_change_pid, create_time, last_change_time, content, edit_content,"
- + " source, thumbnail, sticktop, `release`, url, read_count, ajtcode"
- + " FROM article WHERE articleid = :articleid";
- SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
- sqlCmd.setString("articleid", articleid);
- List<Article> list = gdba.selectAsList(sqlCmd, Article.class);
- if (list == null || list.isEmpty()) {
- throw new Exception("文章不存在");
- }
- return list.get(0);
- }
-
- /**
- *
- * 获取部门负责人
- *
- * @param gdba
- * @param mtCode 类别码
- * @param departmentid 部门 id
- * @return
- * @throws Exception
- * @author 陈锋
- * @log 2020年10月29日
- */
- private List<Map<String, Object>> getDepartmentManageByMtcode(GeneralDBAccess gdba, Long mtCode, Long departmentid) throws Exception {
- StringBuilder sqlBuilder = new StringBuilder();
- if (mtCode.equals(10030L)) { // 人员
- sqlBuilder.append(" select p.personid from person p ");
- // 在用、并且不是离职的
- sqlBuilder.append(" where p.dcode = 61 and p.pcode != 10001 and p.personid in ");
- }
- sqlBuilder.append(" (Select objectid from department_manage where departmentid = :departmentid and mtcode = :mtcode )");
- SqlCommandImpl sqlCmd = new SqlCommandImpl(sqlBuilder.toString());
- sqlCmd.setString("mtcode", mtCode).setString("departmentid", departmentid);
- return gdba.selectAsMapList(sqlCmd);
- }
-
- /**
- * 验证是否有部门负责人
- *
- * @param gdba
- * @param article 文章
- * @param departmentName 部门名
- * @param departmentid 部门 id
- * @throws Exception
- * @author 陈锋
- * @log 2020年10月31日
- */
- private void verifyDepartmentChargePerson(GeneralDBAccess gdba, Article article, String departmentName, Long departmentid) throws Exception {
- try {
- List<Map<String, Object>> personList = getDepartmentManageByMtcode(gdba, 10030L, departmentid);
-
- if (personList.size() == 0) {
- throw new Exception("未找到「" + departmentName + "」部门负责人");
- }
-
- } catch (Exception e) {
- updateArticleById(gdba, article);
-
- throw new Exception("未找到「" + departmentName + "」部门负责人");
- }
- }
-
- /**
- * 更新文章为“录入”状态
- *
- * @param gdba
- * @param article 文章
- * @throws Exception
- * @author 陈锋
- * @log 2020年10月31日
- */
- private void updateArticleById(GeneralDBAccess gdba, Article article) throws Exception {
-
- article.setDcode(dataStatusCode.INSERT.getCode());
-
- Set<String> updateSet = new HashSet<String>();
- updateSet.add("dcode");
-
- gdba.updateById(article, updateSet);
-
- gdba.commit();
- }
-
- /**
- * 验证文章是否有栏目负责人
- *
- * @param gdba
- * @param article 文章
- * @throws Exception
- * @author 陈锋
- * @log 2020年10月10日
- */
- private void verifyNavigationPerson(GeneralDBAccess gdba, Article article) throws Exception {
-
- try {
-
- List<Object> list = ArticleUtil.getManageByWnmcode(gdba, 10020L, article.getNavigationid());// 文章负责对象,栏目
-
- if (list.size() == 0) {
- throw new Exception("未找到栏目负责对象");
- }
-
- } catch (Exception e) {
- updateArticleById(gdba, article);
-
- throw new Exception("未找到栏目负责对象");
- }
- }
-
- /**
- * 启动文章变动流程的前置服务
- *
- * @return
- * @throws Exception
- * @author 陈锋
- * @log 2020年10月7日
- */
- public String startArticleChangeProcessBefore() throws Exception {
- Article article = getArticleById(getGdbaInstance(), getParameterToLong("articleid"));
- setBPMStartChangeProcess("article_start_change_submit",article.getArticleid(), null, article.getTitle(), article.getDesc());
- return DEFAULT_FORWARD;
- }
-
- /**
- * 启动文章变动流程
- * @return
- * @throws Exception
- * @author 陈锋
- * @log 2020年10月7日
- */
- public String startArticleChangeProcess() throws Exception {
- GeneralDBAccess gdba = getGdbaInstance();
- Article article = new Article();
-
- try {
-
- StartChangeProcess startChangeProcess = getStartChangeProcess();
-
- article.setArticleid(startChangeProcess.getChangeId());
- gdba.selectById(article);
- startChangeProcess.setChangeTitle(article.getTitle());
-
- Department department = getAppUser().getDepartment();
-
- // 撤回当前数据未结束的流程
- Map<String, String> paramMap = new HashMap<String, String>();
- BpmProcessUtil.withdrawTaskByPageBean(gdba, article, getWebApp(), getAppUser(), paramMap);
-
- withdrawArticleCopy(gdba, article);// 收回
-
- verifyDepartmentChargePerson(gdba, article, department.getName(), department.getDepartmentid());
- verifyNavigationPerson(gdba, article);
-
- Map<String, String> dcodeMap = new HashMap<String, String>();
- dcodeMap.put(ArticleCopy.class.getName(), "dcode");
-
- BpmProcessUtil.startChangeProcess(getWebApp(), startChangeProcess.getChangeTitle(), "articleChange", getAppUser(), article,
- gdba, startChangeProcess.getChangeDescribe(), dcodeMap);
-
- gdba.commit();
-
- setResponsePackage(getResponseSuccessMsgPackage("发起成功"));
- } catch (Exception e) {
- e.printStackTrace();
- setResponsePackage(getResponseErrorMsgPackage("发起失败:" + e.getMessage()));
- }
-
- return DEFAULT_FORWARD;
- }
-
- /**
- * 撤回未审核的文章抄送
- *
- * @param gdba
- * @param article
- * @throws Exception
- * @author 陈锋
- * @log 2020年10月31日
- */
- private void withdrawArticleCopy(GeneralDBAccess gdba, Article article) throws Exception {
- String sql = "select * from article_copy where articleid = :articleid and dcode in(21, 31, 41, 51) ";
- SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
- sqlCmd.setString("articleid", article.getArticleid());
-
- List<ArticleCopy> ArticleCopyList = gdba.selectAsList(sqlCmd, ArticleCopy.class);
-
- Set<String> updateSet = new HashSet<String>();
- updateSet.add("dcode");
-
- for (ArticleCopy articleCopy : ArticleCopyList) {
- articleCopy.setDcode(dataStatusCode.INSERT_AUDIT.getCode());
- gdba.updateById(articleCopy, updateSet);
- }
-
- }
-
- /**
- * 启动文章流程的前置服务
- *
- * @return
- * @throws Exception
- * @author 陈锋
- * @log 2020年2月25日
- */
- public String startArticleProcessBefore() throws Exception {
- Article article = getArticleById(getGdbaInstance(), getParameterToLong("articleid"));
- setBPMStartParam("article_start_submit", article.getArticleid(), article.getTitle(), article.getDesc());
- return DEFAULT_FORWARD;
- }
- /**
- * 启动文章流程
- *
- * @return
- * @throws Exception
- * @author 陈锋
- * @log 2020年2月25日
- */
- public String startArticleProcess() throws Exception {
-
- try {
- if (getAppUser() == null) {
- throw new Exception("登录会话已失效,请重新登录");
- }
- GeneralDBAccess gdba = getGdbaInstance();
- StartProcess startProcess = getStartProcess();
-
- Article article = getArticleById(gdba, startProcess.getId());
- startProcess.setTitle(article.getTitle());
-
- Department department = getAppUser().getDepartment();
- if (department == null && getAppUser().getPerson() != null
- && getAppUser().getPerson().getDepartmentid() != null) {
- department = new Department();
- department.setDepartmentid(getAppUser().getPerson().getDepartmentid());
- gdba.selectById(department);
- }
- if (department == null) {
- throw new Exception("当前登录用户未关联部门,无法发起流程");
- }
- try {
- verifyDepartmentChargePerson(gdba, article, department.getName(), department.getDepartmentid());
- verifyNavigationPerson(gdba, article);
- } catch (Exception e) {
- throw new Exception("流程前置校验失败:" + (e.getMessage() != null ? e.getMessage() : e.getClass().getSimpleName()));
- }
-
- Map<String, String> dcodeMap = new HashMap<String, String>();
- dcodeMap.put(Article.class.getName(), "dcode");
- dcodeMap.put(ArticleCopy.class.getName(), "dcode");
-
- try {
- // 草稿 dcode=21 时 BpmProcessPageBeanUtil 无法自动推断 startType,需显式指定 add
- BpmProcessUtil.startProcess(getWebApp(), startProcess.getTitle(), "articleRelease", getAppUser(), article,
- gdba, startProcess.getDescribe(), dcodeMap, "add", null);
- } catch (Exception e) {
- throw new Exception("BPM启动失败:" + (e.getMessage() != null ? e.getMessage() : e.getClass().getSimpleName()));
- }
- // 录入(11)/待提交(12) 发起时 BpmProcessPageBeanUtil 只会写成 21,父列表仍显示可再次申请;统一落为审核中(31)
- article = getArticleById(gdba, startProcess.getId());
- if (!Long.valueOf(dataStatusCode.USE_AUDIT.getCode()).equals(article.getDcode())) {
- article.setDcode(dataStatusCode.USE_AUDIT.getCode());
- Set<String> dcodeFields = new HashSet<String>();
- dcodeFields.add("dcode");
- gdba.updateById(article, dcodeFields);
- }
-
- gdba.commit();
-
- setResponsePackage(getResponseSuccessMsgPackage("发起成功"));
- } catch (Exception e) {
- e.printStackTrace();
- String errMsg = e.getMessage();
- if (errMsg == null || errMsg.trim().isEmpty()) {
- errMsg = e.getClass().getSimpleName();
- }
- setResponsePackage(getResponseErrorMsgPackage("发起失败:" + errMsg));
- }
-
- return DEFAULT_FORWARD;
- }
-
- /**
- * 同意发布文章
- *
- * @author 陈锋
- * @throws Exception
- * @log 2020年2月25日
- */
- public void agree() throws Exception {
- try {
- BpmApp bpmApp = BpmAppUtil.getBpmApp();
- GeneralDBAccess gdba = bpmApp.getGdba();
- Map<String, String> paramMap = getBpmParamMap();
- Long articleid = Long.valueOf(paramMap.get("articleid").toString());
- Article article = new Article();
- article.setArticleid(articleid);
- gdba.selectById(article);
- article.setLastChangeTime(DateTimeUtil.getNowTimestamp());
- // 定时发布
- if (article.getRelease() == 1) {
- // 发布时间
- if (StringUtil.notNull(article.getReleaseTime())
- && article.getReleaseTime().getTime() <= DateTimeUtil.getCurrentTimeMillis()) {
- article.setAscode(articleStatusCode.HAS_RELEASE.getCode());
- article.setReleaseTaskSchedulesid(null);
- }
- } else {
- // 没有设置定时发布,则审核完流程时,自动发布
- article.setAscode(articleStatusCode.HAS_RELEASE.getCode());
-
- if (StringUtil.isNull(article.getReleaseTime())) {
- article.setReleaseTime(DateTimeUtil.getNowTimestamp());
- }
- }
- gdba.updateById(article);
- BpmProcessPageBeanUtil.updatePageBeanForAgree(gdba, article);
- agreeAuthorizedArticleCopy(gdba, articleid);
- } catch (Exception e) {
- // 文章里的同意失败
- throw new Exception("同意发布文章失败");
- }
- }
- /**
- * 主栏目审核通过后,自动通过“申请人本身就是抄送栏目负责人”的抄送记录。
- * 其他抄送记录仍进入抄送审。
- *
- * @param gdba 数据库
- * @param articleid 文章 ID
- * @throws Exception
- */
- private void agreeAuthorizedArticleCopy(GeneralDBAccess gdba, Long articleid) throws Exception {
- String sql = "select * from article_copy where articleid = :articleid and dcode in (21, 31, 41, 51) ";
- SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
- sqlCmd.setString("articleid", articleid);
- List<ArticleCopy> articleCopyList = gdba.selectAsList(sqlCmd, ArticleCopy.class);
- Set<String> updateSet = new HashSet<String>();
- updateSet.add("dcode");
- for (ArticleCopy articleCopy : articleCopyList) {
- if (!ArticleUtil.isNavigationManager(gdba, 10020L, articleCopy.getNavigationid(), articleCopy.getCreatePid())) {
- continue;
- }
- articleCopy.setDcode(dataStatusCode.USE.getCode());
- gdba.updateById(articleCopy, updateSet);
- }
- }
- /**
- * 拒绝发布文章
- *
- * @author 陈锋
- * @throws Exception
- * @log 2020年2月25日
- */
- public void reject() throws Exception {
- try {
- BpmApp bpmApp = BpmAppUtil.getBpmApp();
- GeneralDBAccess gdba = bpmApp.getGdba();
- Map<String, String> paramMap = getBpmParamMap();
- Long articleid = Long.valueOf(paramMap.get("articleid").toString());
- Article article = new Article();
- article.setArticleid(articleid);
- gdba.selectById(article);
- article.setLastChangeTime(DateTimeUtil.getNowTimestamp());
- gdba.updateById(article);
- BpmProcessPageBeanUtil.updatePageBeanForReject(gdba, article);
- } catch (Exception e) {
- throw new Exception("退回发布文章失败");
- }
- }
- /**
- * 同意抄送文章
- *
- * @throws Exception
- * @author 陈锋
- * @log 2020年2月25日
- */
- public void agreeArticleCopy() throws Exception {
- try {
- Map<String, String> paramMap = getBpmParamMap();
- BpmApp bpmApp = BpmAppUtil.getBpmApp();
- Audit audit = bpmApp.getAudit();
- Map<String, Object> paramAuditMap = GsonUtil.jsonToMap2(audit.getForeachVar());
- String sql = "select * from article_copy WHERE navigationid = :navigationid AND articleid = :articleid ";// AND dcode = :dcode
- SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
- sqlCmd.setInt("articleid", paramMap.get("articleid"));
- sqlCmd.setInt("navigationid", paramAuditMap.get("navigationid"));
- // sqlCmd.setInt("dcode", dataStatusCode.INSERT_AUDIT.getCode());
- GeneralDBAccess gdba = bpmApp.getGdba();
- List<PageBean> pageBeanList = gdba.selectAsList(sqlCmd, ArticleCopy.class);
- BpmProcessPageBeanUtil.updatePageBeanForAgree(gdba, pageBeanList);
- } catch (Exception e) {
- throw new Exception("同意抄送文章失败");
- }
- }
- /**
- * 同意直通发布文章。
- * 用于“开始 -> 结束”的发布流程:没有抄送审核节点,需要在结束时同步发布主文章和抄送栏目。
- *
- * @throws Exception
- */
- public void agreeDirectRelease() throws Exception {
- try {
- agree();
- Map<String, String> paramMap = getBpmParamMap();
- String sql = "select * from article_copy WHERE articleid = :articleid ";
- SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
- sqlCmd.setInt("articleid", paramMap.get("articleid"));
- BpmApp bpmApp = BpmAppUtil.getBpmApp();
- GeneralDBAccess gdba = bpmApp.getGdba();
- List<PageBean> pageBeanList = gdba.selectAsList(sqlCmd, ArticleCopy.class);
- BpmProcessPageBeanUtil.updatePageBeanForAgree(gdba, pageBeanList);
- } catch (Exception e) {
- throw new Exception("同意直通发布文章失败");
- }
- }
-
- /**
- * 拒绝抄送文章
- *
- * @throws Exception
- * @author 陈锋
- * @log 2020年2月25日
- */
- public void rejectArticleCopy() throws Exception {
- try {
- Map<String, String> paramMap = getBpmParamMap();
- BpmApp bpmApp = BpmAppUtil.getBpmApp();
- Audit audit = bpmApp.getAudit();
- Map<String, Object> paramAuditMap = GsonUtil.jsonToMap2(audit.getForeachVar());
- String sql = "select * from article_copy WHERE navigationid = :navigationid AND articleid = :articleid ";// AND dcode = :dcode
- SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
- sqlCmd.setInt("articleid", paramMap.get("articleid"));
- sqlCmd.setInt("navigationid", paramAuditMap.get("navigationid"));
- // sqlCmd.setInt("dcode", dataStatusCode.INSERT_AUDIT.getCode());
- GeneralDBAccess gdba = bpmApp.getGdba();
- List<PageBean> pageBeanList = gdba.selectAsList(sqlCmd, ArticleCopy.class);
- BpmProcessPageBeanUtil.updatePageBeanForReject(gdba, pageBeanList);
- } catch (Exception e) {
- throw new Exception("退回抄送文章失败");
- }
- }
-
- /**
- * 启动停用文章流程的前置服务
- *
- * @return
- * @throws Exception
- * @author 陈锋
- * @log 2020年10月11日
- */
- public String startDisableArticleProcessBefore() throws Exception {
- Article article = getArticleById(getGdbaInstance(), getParameterToLong("articleid"));
- setBPMStartDisableProcess("article_start_disable_submit", article.getArticleid(), article.getTitle(), article.getDesc());
- return DISABLE_APPLY_FORWARD;
- }
-
- /**
- * 启动停用文章流程
- *
- * @return
- * @throws Exception
- * @author 陈锋
- * @log 2020年10月11日
- */
- public String startDisableArticleProcess() throws Exception {
-
- try {
- GeneralDBAccess gdba = getGdbaInstance();
- StartDisableProces startDisableProcess = getStartDisableProcess();
-
- Article article = new Article();
- article.setArticleid(startDisableProcess.getId());
- gdba.selectById(article);
-
- // 停用抄送的栏目
- // String sql = "select * from article_copy where articleid = :articleid ";
- // SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
- // sqlCmd.setInt("articleid", article.getArticleid());
- // List<PageBean> articleCopyList = gdba.selectAsList(sqlCmd, ArticleCopy.class);
- //
- // Map<String, String> dcodeMap = new HashMap<String, String>();
- // dcodeMap.put(ArticleCopy.class.getName(), "dcode");// 防止没有抄送记录
- //
- // BpmProcessUtil.startDisableProcess(getWebApp(), startDisableProcess.getTitle(), "articleDisable", getAppUser(), article,
- // gdba, startDisableProcess.getDescribe(), articleCopyList, dcodeMap);
-
- // BpmProcessUtil.startDisableProcess(getWebApp(), startDisableProcess.getTitle(), "articleDisable", getAppUser(), article,
- // gdba, startDisableProcess.getDescribe(), null);
-
- gdba.commit();
-
- setResponsePackage(getResponseSuccessMsgPackage("发起成功"));
- } catch (Exception e) {
- e.printStackTrace();
- setResponsePackage(getResponseErrorMsgPackage("发起失败:" + e.getMessage()));
- }
-
- return DEFAULT_FORWARD;
- }
-
- /**
- * 同意停用文章审核
- *
- * @return
- * @throws Exception
- * @author 陈锋
- * @log 2020年10月11日
- */
- public String agreeDisable() throws Exception {
-
- try {
-
- BpmApp bpmApp = BpmAppUtil.getBpmApp();
- GeneralDBAccess gdba = bpmApp.getGdba();
- Article article = getBPMArticle(gdba);
-
- article.setLastChangeTime(DateTimeUtil.getNowTimestamp());
- gdba.updateById(article);
-
- // 把抄送到的栏目全部停用
- // String sql = "UPDATE article_copy SET dcode = '71' WHERE articleid = :articleid ";
- // SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
- // sqlCmd.setInt("articleid", article.getArticleid());
- // gdba.modify(sqlCmd);
- BpmProcessPageBeanUtil.updatePageBeanForAgree(gdba, article);
-
- } catch (Exception e) {
- throw new Exception("同意停用文章失败");
- }
-
- return DEFAULT_FORWARD;
- }
-
- /**
- * 拒绝停用文章审核
- *
- * @return
- * @throws Exception
- * @author 陈锋
- * @log 2020年10月11日
- */
- public String rejectDisable() throws Exception {
-
- try {
-
- BpmApp bpmApp = BpmAppUtil.getBpmApp();
- GeneralDBAccess gdba = bpmApp.getGdba();
- Article article = getBPMArticle(gdba);
-
- article.setLastChangeTime(DateTimeUtil.getNowTimestamp());
- gdba.updateById(article);
-
- // String sql = "SELECT * FROM article_copy WHERE articleid = :articleid ";
- // SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
- // sqlCmd.setInt("articleid", article.getArticleid());
- // List<PageBean> articleCopyList = gdba.selectAsList(sqlCmd, ArticleCopy.class);
- // BpmProcessPageBeanUtil.updatePageBeanForReject(gdba, articleCopyList);
-
- BpmProcessPageBeanUtil.updatePageBeanForReject(gdba, article);
-
- } catch (Exception e) {
- throw new Exception("退回停用文章失败");
- }
-
- return DEFAULT_FORWARD;
- }
-
- /**
- * 启动启用文章流程的前置服务
- *
- * @return
- * @throws Exception
- * @author 陈锋
- * @log 2020年10月11日
- */
- public String startEnableArticleProcessBefore() throws Exception {
- Article article = getArticleById(getGdbaInstance(), getParameterToLong("articleid"));
- setBPMStartEnableProcess("article_start_enable_submit", article.getArticleid(), article.getTitle(), article.getDesc());
- return ENABLE_APPLY_FORWARD;
- }
-
- /**
- * 启动启用文章流程
- *
- * @return
- * @throws Exception
- * @author 陈锋
- * @log 2020年10月11日
- */
- public String startEnableArticleProcess() throws Exception {
-
- try {
- GeneralDBAccess gdba = getGdbaInstance();
- StartEnableProces startEnableProces = getStartEnableProcess();
- Article article = getArticleById(gdba, startEnableProces.getId());
-
- Department department = getAppUser().getDepartment();
- verifyDepartmentChargePerson(gdba, article, department.getName(), department.getDepartmentid());
- verifyNavigationPerson(gdba, article);
-
- // String sql = "select * from article_copy where articleid = :articleid ";
- // SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
- // sqlCmd.setInt("articleid", article.getArticleid());
- // List<PageBean> articleCopyList = gdba.selectAsList(sqlCmd, ArticleCopy.class);
- //
- // Map<String, String> dcodeMap = new HashMap<String, String>();
- // dcodeMap.put(ArticleCopy.class.getName(), "dcode");// 防止没有抄送记录
- //
- // BpmProcessUtil.startEnableProcess(getWebApp(), startEnableProces.getTitle(), "articleEnable", getAppUser(), article,
- // gdba, startEnableProces.getDescribe(), articleCopyList, dcodeMap);
-
- // BpmProcessUtil.startEnableProcess(getWebApp(), startEnableProces.getTitle(), "articleEnable", getAppUser(), article,
- // gdba, startEnableProces.getDescribe(), null);
-
- gdba.commit();
-
- setResponsePackage(getResponseSuccessMsgPackage("发起成功"));
- } catch (Exception e) {
- e.printStackTrace();
- setResponsePackage(getResponseErrorMsgPackage("发起失败:" + e.getMessage()));
- }
-
- return DEFAULT_FORWARD;
- }
-
- /**
- * 同意启用文章审核
- *
- * @return
- * @throws Exception
- * @author 陈锋
- * @log 2020年10月11日
- */
- public String agreeEnable() throws Exception {
-
- try {
-
- BpmApp bpmApp = BpmAppUtil.getBpmApp();
- GeneralDBAccess gdba = bpmApp.getGdba();
- Article article = getBPMArticle(gdba);
-
- article.setLastChangeTime(DateTimeUtil.getNowTimestamp());
- gdba.updateById(article);
- BpmProcessPageBeanUtil.updatePageBeanForAgree(gdba, article);
-
- // gdba.commit();
-
- } catch (Exception e) {
- throw new Exception("同意启用文章失败");
- }
-
- return DEFAULT_FORWARD;
- }
-
- /**
- * 拒绝启用文章审核
- *
- * @return
- * @throws Exception
- * @author 陈锋
- * @log 2020年10月11日
- */
- public String rejectEnable() throws Exception {
-
- try {
-
- BpmApp bpmApp = BpmAppUtil.getBpmApp();
- GeneralDBAccess gdba = bpmApp.getGdba();
- Article article = getBPMArticle(gdba);
-
- article.setLastChangeTime(DateTimeUtil.getNowTimestamp());
- gdba.updateById(article);
- BpmProcessPageBeanUtil.updatePageBeanForReject(gdba, article);
-
- // gdba.commit();
-
- } catch (Exception e) {
- throw new Exception("退回启用文章失败");
- }
-
- return DEFAULT_FORWARD;
- }
-
- /**
- * 撤回(收回)文章流程时,改变文章抄送栏目状态,文章状态已在流程自动改了
- *
- * @return
- * @author 陈锋
- * @throws Exception
- * @log 2020年11月3日
- */
- public String withdrawArticleFlow() throws Exception {
-
- BpmApp bpmApp = BpmAppUtil.getBpmApp();
- GeneralDBAccess gdba = bpmApp.getGdba();
- Article article = getBPMArticle(gdba);
-
- article.setDcode(dataStatusCode.INSERT.getCode());
- gdba.updateById(article);
-
- // 更新文章的抄送栏目为“录入”状态
- String sql = "update article_copy set dcode = 21 where articleid = :articleid ";
- SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
- sqlCmd.setInt("articleid", article.getArticleid());
-
- gdba.modify(sqlCmd);
-
- return DEFAULT_FORWARD;
- }
- }
|