zm
2024-08-16 3406a479c190b6863808723132b83c265bc843ef
src/main/java/com/product/administration/service/CooperatesService.java
@@ -1,7 +1,6 @@
package com.product.administration.service;
import com.alibaba.fastjson.JSONArray;
import com.product.admin.service.UserService;
import com.product.administration.config.CmnConst;
import com.product.administration.service.ide.ICooperatesService;
import com.product.common.lang.StringUtils;
@@ -16,9 +15,9 @@
import com.product.core.spring.context.SpringMVCContextHolder;
import com.product.core.transfer.Transactional;
import com.product.core.websocket.service.WebsocketMesssageServiceThread;
import com.product.module.sys.service.UserService;
import com.product.util.BaseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import com.product.tool.flow.service.FlowCoordinationService;
@@ -35,7 +34,6 @@
 * @author: ZhouJie
 * @Description: 协同办公
 */
@Component
@Service
public class CooperatesService extends AbstractBaseService implements ICooperatesService {
   @Autowired
@@ -47,7 +45,6 @@
   @Autowired
   QueryFilterService queryFilterService;
   @Autowired
   @Qualifier("userOperService")
   UserService userService;
   /**
@@ -82,11 +79,17 @@
      FieldSetEntity fse = baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_COOPERATES, fs.getString(CmnConst.UUID), true);
      DataTableEntity copsub = fse.getSubDataTable(CmnConst.PRODUCT_OA_COOPERATE_SUB);
      baseDao.loadPromptData(copsub);
      for (int i = 0; i <copsub.getRows() ; i++) {
         String userId = copsub.getString(i, "created_by_save_value");
         String userAvatar = userService.getUserAvatar(userId);
         if (!StringUtils.isEmpty(userAvatar)) {
               copsub.setFieldValue(i, "avatar", userAvatar);
         }
      }
      StringBuilder stringBuilder = new StringBuilder();
      stringBuilder.append(" select ifnull(concat(tricode,'-',receiver) ,receiver) code,uuid,title,cooperate_uuid,grade,receiver as id,receiver,sender, ");
      stringBuilder.append(" receiver_name,(select user_name FROM product_sys_users where user_id=receiver) label,sender_name,status, ");
      stringBuilder.append(" tricode,opinion,handle_time,type,attachments from product_oa_cooperate_flow_node where cooperate_uuid=? ORDER BY tricode ");
      stringBuilder.append(" tricode,opinion,handle_time,type,attachments,is_hide_commentss from product_oa_cooperate_flow_node where cooperate_uuid=? ORDER BY tricode ");
      DataTableEntity dt = baseDao.listTable(stringBuilder.toString(), new Object[]{fs.getString("uuid")});
      JSONArray json = null;
      if (dt != null && dt.getRows() > 0) {
@@ -117,9 +120,9 @@
         fse.addSubDataTable(dd);
         json = BaseUtil.dataTableToTreeData(dt, "code", "tricode", null, false);
      }
      String sql = " select count(*) sum from product_oa_cooperate_flow_node where cooperate_uuid =?  and status =? ";
      String sql1 = " select count(*) sum from product_oa_cooperate_flow_node where cooperate_uuid =? ";
      String sql0 = " select count(*) sum from product_oa_cooperate_flow_node where cooperate_uuid =?  and (status =? or status is null) ";
      String sql = " select count(*) sum from product_oa_cooperate_flow_node where cooperate_uuid =?  and status =? and tricode is not null";
      String sql1 = " select count(*) sum from product_oa_cooperate_flow_node where cooperate_uuid =? and tricode is not null";
      String sql0 = " select count(*) sum from product_oa_cooperate_flow_node where cooperate_uuid =?  and (status =? or status is null) and tricode is not null";
      FieldSetEntity fss = baseDao.getFieldSetEntityBySQL(sql1, new Object[]{fs.getString(CmnConst.UUID)}, true);
      FieldSetEntity fs0 = baseDao.getFieldSetEntityBySQL(sql0, new Object[]{fs.getString(CmnConst.UUID), 0}, true);
      FieldSetEntity fs1 = baseDao.getFieldSetEntityBySQL(sql, new Object[]{fs.getString(CmnConst.UUID), 1}, true);
@@ -127,7 +130,7 @@
      if (fss.getInteger("sum") == null) {
         fse.setValue("totals", 0);//流程共有人数
      } else {
         fse.setValue("totals", fss.getInteger("sum") - 1);
         fse.setValue("totals", fss.getInteger("sum"));
      }
      if (fs0.getInteger("sum") == null) {
         fse.setValue("uncollectd", 0);//未收未办人数
@@ -142,7 +145,7 @@
      if (fs2.getInteger("sum") == null) {
         fse.setValue("done", 0);//已收已办人数
      } else {
         fse.setValue("done", fs2.getInteger("sum") - 1);
         fse.setValue("done", fs2.getInteger("sum"));
      }
      int a = fse.getInteger("totals") - fse.getInteger("uncollectd") - fse.getInteger("received") - fse.getInteger("done");
      fse.setValue("not_yet", a);//未到环节人数
@@ -250,6 +253,7 @@
    */
   public void saveTodo(FieldSetEntity fs) throws BaseException {
      fs.setValue("status", 1);
      fs.setValue("handle_time", new Date());
      baseDao.update(fs);
   }
@@ -264,6 +268,11 @@
      fs.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
      fs.setValue("created_utc_datetime", new Date());
      return baseDao.add(fs);
   }
   @Override
   public boolean delSupplyText(FieldSetEntity fs) {
      return baseDao.delete(fs.getTableName(),new String[]{fs.getUUID()});
   }
   /**
@@ -307,12 +316,16 @@
      int user_id = SpringMVCContextHolder.getCurrentUser().getUser_id();
      String queryFilter = queryFilterService.getQueryFilter(fs);
      StringBuffer str = new StringBuffer();
      str.append(" select lc.*,lcn.uuid flow_node_uuid from product_oa_cooperate_flow_node lcn LEFT JOIN product_oa_COOPERATEs lc ");
      str.append("SELECT * FROM ( ");
      str.append(" select lc.*,lcn.uuid flow_node_uuid from product_oa_cooperate_flow_node as lcn LEFT JOIN product_oa_cooperates as lc ");
      str.append(" on lc.uuid=lcn.cooperate_uuid where lcn.receiver=? and lcn.status=? and sender_name is not null ");
      if (!StringUtils.isEmpty(queryFilter)) {
         str.append(" and ").append(queryFilter);
         str.append(" and  ").append(queryFilter);
      }
      DataTableEntity dt = baseDao.listTable(str.toString(), new Object[]{user_id, 2});
      str.append(" order by start_time desc) a");
      DataTableEntity dt = baseDao.listTable(str.toString(), new Object[]{user_id, 2}, fs.getInteger(CmnConst.PAGESIZE), fs.getInteger(CmnConst.CPAGE));
      dt.getMeta().addAliasTable("product_oa_cooperates", "lc");
      dt.getMeta().addAliasTable("product_oa_cooperate_flow_node", "lcn");
      baseDao.loadPromptData(dt);
      return dt;
   }