Browse Source

项目管理系统对接

chenc 3 years ago
parent
commit
63052051f7
20 changed files with 530 additions and 45 deletions
  1. 2 2
      jeecg-boot/jeecg-boot-base-common/src/main/java/org/jeecg/common/system/api/ISysBaseAPI.java
  2. 3 0
      jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/entity/ActBusiness.java
  3. 4 0
      jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/entity/TbTableInfo.java
  4. 4 1
      jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/entity/TbTableInfoPractice.java
  5. 5 5
      jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/service/Impl/ActBusinessServiceImpl.java
  6. 21 7
      jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/service/Impl/ActZprocessServiceImpl.java
  7. 51 16
      jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/web/ActBusinessController.java
  8. 40 6
      jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/web/TbTableInfoController.java
  9. 1 0
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  10. 5 1
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/controller/CdEnterpriseEnnouncementController.java
  11. 198 0
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/controller/CdLinksController.java
  12. 2 0
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/controller/CdScheduleController.java
  13. 79 0
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/entity/CdLinks.java
  14. 17 0
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/mapper/CdLinksMapper.java
  15. 5 0
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/mapper/xml/CdLinksMapper.xml
  16. 14 0
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/service/ICdLinksService.java
  17. 19 0
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/service/impl/CdLinksServiceImpl.java
  18. 33 0
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/LoginController.java
  19. 4 4
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysBaseApiImpl.java
  20. 23 3
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/util/HttpHelper.java

+ 2 - 2
jeecg-boot/jeecg-boot-base-common/src/main/java/org/jeecg/common/system/api/ISysBaseAPI.java

@@ -111,7 +111,7 @@ public interface ISysBaseAPI {
 	 * @param title  消息主题
 	 * @param msgContent  消息内容
 	 */
-	public void sendSysAnnouncement(String fromUser,String toUser,String title, String msgContent,Map<String,Object> map);
+	public void sendSysAnnouncement(LoginUser loginUser,String fromUser,String toUser,String title, String msgContent,Map<String,Object> map);
 
 	/**
 	 * 发送系统消息
@@ -153,7 +153,7 @@ public interface ISysBaseAPI {
 	 * @param msgContent  消息内容
 	 * @param setMsgCategory  消息类型 1:消息2:系统消息
 	 */
-	public void sendSysAnnouncement(String fromUser, String toUser, String title, String msgContent, String setMsgCategory,Map<String,Object> map);
+	public void sendSysAnnouncement(LoginUser loginUser,String fromUser, String toUser, String title, String msgContent, String setMsgCategory,Map<String,Object> map);
 
 	/**queryTableDictByKeys
 	 * 发送系统消息

+ 3 - 0
jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/entity/ActBusiness.java

@@ -138,6 +138,9 @@ public class ActBusiness {
 	@TableField(exist = false)
 	private String isAgree;
 
+	@TableField(exist = false)
+	private String externalUsername;
+
 	/**公司id*/
 	private String pkOrg;
 }

+ 4 - 0
jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/entity/TbTableInfo.java

@@ -50,6 +50,10 @@ public class TbTableInfo {
     private String delFlag;
     //是否初始表单0否1是
     private String isInitial;
+
+    //表单显示类型(1PC端2手机端)
+    private String type;
+
     //是否可以保存
     @TableField(exist = false)
     private Boolean isSave;

+ 4 - 1
jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/entity/TbTableInfoPractice.java

@@ -51,6 +51,8 @@ public class TbTableInfoPractice {
     private String isInitial;
     //业务表id(外键)
     private String businessTableId;
+    //表单显示类型(1PC端2手机端)
+    private String type;
     //是否可以保存
     @TableField(exist = false)
     private Boolean isSave;
@@ -64,7 +66,7 @@ public class TbTableInfoPractice {
 
     public TbTableInfoPractice(String id, String businessTable, String text, String content,
        String pkOrg, String routeName, String stepMemo, String processId, String taskNodeId,
-       String isInitial, String businessTableId) {
+       String isInitial, String businessTableId,String type) {
         this.id = id;
         this.businessTable = businessTable;
         this.text = text;
@@ -76,6 +78,7 @@ public class TbTableInfoPractice {
         this.taskNodeId = taskNodeId;
         this.isInitial = isInitial;
         this.businessTableId = businessTableId;
+        this.type=type;
     }
 
 

+ 5 - 5
jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/service/Impl/ActBusinessServiceImpl.java

@@ -236,11 +236,11 @@ public class ActBusinessServiceImpl extends ServiceImpl<ActBusinessMapper, ActBu
                             filedIdVB.append(",'" + i + "'");
 
                             //创建时间
-                            filedIdB.append(",create_time");
-                            filedIdVB.append(",'" + new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(date)  + "'");
-                            //创建人
-                            filedIdB.append(",create_by");
-                            filedIdVB.append(",'"+ user.getUsername() +"'");
+//                            filedIdB.append(",create_time");
+//                            filedIdVB.append(",'" + new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(date)  + "'");
+//                            //创建人
+//                            filedIdB.append(",create_by");
+//                            filedIdVB.append(",'"+ user.getUsername() +"'");
                             this.baseMapper.insertBusiData(String.format("INSERT INTO %s (%s) VALUES (%s)", childTableName, filedIdB.toString(), filedIdVB.toString()));
                         }
                     }

+ 21 - 7
jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/service/Impl/ActZprocessServiceImpl.java

@@ -22,6 +22,7 @@ import org.activiti.engine.impl.pvm.process.ActivityImpl;
 import org.activiti.engine.runtime.ProcessInstance;
 import org.activiti.engine.task.IdentityLink;
 import org.activiti.engine.task.Task;
+import org.apache.commons.lang.StringUtils;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.common.system.api.ISysBaseAPI;
@@ -112,8 +113,19 @@ public class ActZprocessServiceImpl extends ServiceImpl<ActZprocessMapper, ActZp
 
     public String startProcess(ActBusiness actBusiness) {
         LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        // 启动流程用户
-        identityService.setAuthenticatedUserId(loginUser.getUsername());
+        //判断是否外部项目调用接口传入启动流程用户
+        if(StringUtils.isNotBlank(actBusiness.getExternalUsername())){
+            //有则获取
+            // 启动流程用户
+            identityService.setAuthenticatedUserId(actBusiness.getExternalUsername());
+            loginUser=new LoginUser();
+            loginUser.setOrgCode(actBusiness.getPkOrg());
+            loginUser.setUsername(actBusiness.getExternalUsername());
+        }else{
+            //没有则获取当前登陆人
+            // 启动流程用户
+            identityService.setAuthenticatedUserId(loginUser.getUsername());
+        }
         // 启动流程 需传入业务表id变量
         Map<String, Object> params = actBusiness.getParams();
         params.put("tableId", actBusiness.getTableId());
@@ -123,10 +135,12 @@ public class ActZprocessServiceImpl extends ServiceImpl<ActZprocessMapper, ActZp
         if (StrUtil.isBlank(tableId)||StrUtil.isBlank(tableName)){
             throw new JeecgBootException("没有业务表单数据");
         }
-        /*表单数据写入*/
-        Map<String, Object> busiData = actBusinessService.getBaseMapper().getBusiData(tableId, tableName);
-        for (String key : busiData.keySet()) {
-            params.put(key,busiData.get(key));
+        if(StringUtils.isEmpty(actBusiness.getExternalUsername())){
+            /*表单数据写入*/
+            Map<String, Object> busiData = actBusinessService.getBaseMapper().getBusiData(tableId, tableName);
+            for (String key : busiData.keySet()) {
+                params.put(key,busiData.get(key));
+            }
         }
         ProcessInstance pi = runtimeService.startProcessInstanceById(actBusiness.getProcDefId(), actBusiness.getId(), params);
         // 设置流程实例名称
@@ -228,7 +242,7 @@ public class ActZprocessServiceImpl extends ServiceImpl<ActZprocessMapper, ActZp
      */
     public void sendMessage(LoginUser fromUser, LoginUser toUser,String title,String msgText,  Boolean sendMessage, Boolean sendSms, Boolean sendEmail,Map<String,Object> map) {
         if (sendMessage!=null&&sendMessage){
-            sysBaseAPI.sendSysAnnouncement(fromUser.getUsername(),toUser.getUsername(),title,msgText,map);
+            sysBaseAPI.sendSysAnnouncement(fromUser,fromUser.getUsername(),toUser.getUsername(),title,msgText,map);
         }
         //todo 以下需要购买阿里短信服务;设定邮件服务账号
         if (sendSms!=null&&sendSms&& StrUtil.isNotBlank(toUser.getPhone())){

+ 51 - 16
jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/web/ActBusinessController.java

@@ -16,8 +16,11 @@ import org.apache.commons.lang.StringUtils;
 import org.apache.shiro.SecurityUtils;
 import org.checkerframework.checker.units.qual.Area;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.system.api.ISysBaseAPI;
+import org.jeecg.common.system.util.JwtUtil;
 import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.common.util.RedisUtil;
 import org.jeecg.modules.activiti.entity.*;
 import org.jeecg.modules.activiti.service.ITbTableInfoPracticeService;
 import org.jeecg.modules.activiti.service.ITbTableInfoService;
@@ -80,7 +83,7 @@ public class ActBusinessController {
                 tbTableInfoPracticeService.save(new TbTableInfoPractice(IdUtil.simpleUUID(), tbTableInfo.getBusinessTable(), tbTableInfo.getText(),
                         StringUtils.isNotBlank(josonContent) ? josonContent : tbTableInfo.getContent(),
                         tbTableInfo.getPkOrg(), tbTableInfo.getRouteName(), tbTableInfo.getStepMemo(), tbTableInfo.getProcessId(), tbTableInfo.getTaskNodeId(),
-                        tbTableInfo.getIsInitial(), tableId));
+                        tbTableInfo.getIsInitial(), tableId,tbTableInfo.getType()));
             }
             //获取审核人
             ProcessNodeVo node = actZprocessService.getFirstNode(procDefId);
@@ -148,12 +151,12 @@ public class ActBusinessController {
         String tableId = actBusiness.getTableId();
         String tableName = actBusiness.getTableName();
         act.setTableId(tableId);
-        Map<String, Object> busiData = actBusinessService.getBaseMapper().getBusiData(tableId, tableName);
-
-        if (MapUtil.isNotEmpty(busiData)&&busiData.get(ActivitiConstant.titleKey)!=null){
-            //如果表单里有 标题  更新一下
-            actBusiness.setTitle(busiData.get(ActivitiConstant.titleKey)+"");
-        }
+//        Map<String, Object> busiData = actBusinessService.getBaseMapper().getBusiData(tableId, tableName);
+//
+//        if (MapUtil.isNotEmpty(busiData)&&busiData.get(ActivitiConstant.titleKey)!=null){
+//            //如果表单里有 标题  更新一下
+//            actBusiness.setTitle(busiData.get(ActivitiConstant.titleKey)+"");
+//        }
         String processInstanceId = actZprocessService.startProcess(act);
         actBusiness.setProcInstId(processInstanceId);
         actBusiness.setStatus(1);
@@ -224,12 +227,12 @@ public class ActBusinessController {
         String tableId = request.getParameter("id");
         String jsonContent1 = JSON.toJSONString(jsonContent.getJsonContent());
         if(StringUtils.isNotBlank(jsonContent1)){
-            List<TbTableInfoPractice> list = tbTableInfoPracticeService.list(new LambdaQueryWrapper<TbTableInfoPractice>()
-                    .eq(TbTableInfoPractice::getBusinessTableId, tableId));
-            for(TbTableInfoPractice tbTableInfoPractice : list) {
-                //修改申请保存后的表单json
-                tbTableInfoPracticeService.updateById(new TbTableInfoPractice(tbTableInfoPractice.getId(), jsonContent1));
-            }
+//            List<TbTableInfoPractice> list = tbTableInfoPracticeService.list(new LambdaQueryWrapper<TbTableInfoPractice>()
+//                    .eq(TbTableInfoPractice::getBusinessTableId, tableId));
+//            for(TbTableInfoPractice tbTableInfoPractice : list) {
+//                //修改申请保存后的表单json
+//                tbTableInfoPracticeService.updateById(new TbTableInfoPractice(tbTableInfoPractice.getId(), jsonContent1));
+//            }
         }
         actBusinessService.saveApplyForm(tableId,request);
         return Result.ok();
@@ -274,6 +277,38 @@ public class ActBusinessController {
         actBusinessService.updateById(actBusiness);
         return Result.ok("操作成功");
     }
+
+    /**
+    * @Author chenchuang
+    * @Description //TODO 外部项目用来调用的流程提交接口
+    * @Date 2021/11/26 10:52
+    * @Param [act]
+    * @return org.jeecg.common.api.vo.Result
+    */
+    @RequestMapping(value = "/external/apply", method = RequestMethod.POST)
+    public Result externalApply(ActBusiness act){
+        Result result=new Result();
+        try {
+            //获取审核人
+            ProcessNodeVo node = actZprocessService.getFirstNode(act.getProcDefId());
+            ActBusiness actBusiness = new ActBusiness();
+            actBusiness.setUserId(act.getExternalUsername());
+            actBusiness.setTableId(act.getTableId());
+            actBusiness.setProcDefId(act.getProcDefId());
+            actBusiness.setTitle(act.getTitle());
+            actBusiness.setTableName(act.getTableName());
+            actBusiness.setPkOrg("4adf2baae8d644e7be6ead18bdf2ff2f");//公司id
+            actBusiness.setExternalUsername(act.getExternalUsername());
+            actBusinessService.save(actBusiness);
+            submit(actBusiness,node);
+            result.success("操作成功");
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
     /*撤回申请*/
     @RequestMapping(value = "/cancel", method = RequestMethod.POST)
     public Result<Object> cancel(@RequestParam String id,
@@ -340,9 +375,9 @@ public class ActBusinessController {
     public Result<Object> listData(){
         List<Map> list = new ArrayList();
         Map map = Maps.newHashMap();
-        map.put("text", "实例表单1");
-        map.put("routeName", "外部表单test_demo1");
-        map.put("businessTable", "test_demo1");
+        map.put("text", "合同表单");
+        map.put("routeName", "外部表单contract-file");
+        map.put("businessTable", "contract-file");
         list.add(map);
         return Result.ok(list);
     }

+ 40 - 6
jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/web/TbTableInfoController.java

@@ -50,7 +50,7 @@ public class TbTableInfoController {
      */
     @PostMapping("/add")
     public Result<Object> add(@RequestBody TbTableInfo tbTableInfo){
-        TbTableInfo tableInfo = tbTableInfoService.getOne(new QueryWrapper<TbTableInfo>().eq("business_table", tbTableInfo.getBusinessTable()).eq("step_memo",tbTableInfo.getStepMemo()));
+        TbTableInfo tableInfo = tbTableInfoService.getOne(new QueryWrapper<TbTableInfo>().eq("business_table", tbTableInfo.getBusinessTable()).eq("step_memo",tbTableInfo.getStepMemo()).eq("type",tbTableInfo.getType()));
         String  jsonContent = JSON.toJSONString(tbTableInfo.getJsonContent());
         tbTableInfo.setContent(jsonContent);
         if(tableInfo != null){
@@ -95,22 +95,41 @@ public class TbTableInfoController {
 
     /**
      * @desc 条件查询
+     * businessTable 表名称
+     * taskNodeId 任务节点id
+     * tableId 表id
      */
     @RequestMapping("/query")
-    public Result<Object> query(String businessTable,String taskNodeId,String tableId){
+    public Result<Object> query(String businessTable,String taskNodeId,String tableId,String type){
             if(StringUtils.isNotBlank(tableId)){
                 //表单发起申请完查询随着业务流动json
-                return queryBusiness(businessTable,taskNodeId,tableId);
+                return queryBusiness(businessTable,taskNodeId,tableId,type);
             }else{
                 //表单发起申请时查询json(新增)
-                return queryInitial(businessTable,taskNodeId);
+                return queryInitial(businessTable,taskNodeId,type);
             }
     }
 
     //获取初始表单Json
-    public Result queryInitial(String businessTable,String taskNodeId){
+    public Result queryInitial(String businessTable,String taskNodeId,String type){
         boolean isSave=false;
         QueryWrapper<TbTableInfo> queryWrapper = new QueryWrapper<TbTableInfo>().eq("business_table", businessTable);
+        String whereType="1";//默认类型为PC端表单
+        //如果类型不为PC端的表单则验证
+        if(!type.equals("1")){
+            //查询数据库是否存在当前type类型的表单
+            QueryWrapper<TbTableInfo> queryWrapper2 = new QueryWrapper<TbTableInfo>().eq("business_table", businessTable);
+            queryWrapper2.lambda().eq(TbTableInfo::getType,type);
+            queryWrapper2.lambda().eq(TbTableInfo::getDelFlag,'0');
+            List<TbTableInfo> tbTableInfoList=tbTableInfoService.list(queryWrapper2);
+            //存在则可以继续查询 不存在则默认查询PC端的
+            if(tbTableInfoList!=null&&tbTableInfoList.size()>0){
+                whereType=type;
+            }
+        }
+        //过滤表单类型
+        queryWrapper.lambda().eq(TbTableInfo::getType,whereType);
+
         //查询任务节点是否关联表
         List<ActNode> actNodeList=  actNodeService.list(new QueryWrapper<ActNode>().eq("node_id",taskNodeId));
         if(actNodeList!=null&&actNodeList.size()>0&&StringUtils.isNotBlank(actNodeList.get(0).getTbTableInfoId())){
@@ -143,9 +162,24 @@ public class TbTableInfoController {
     }
 
     //随着业务不断变化的json
-    public Result queryBusiness(String businessTable,String taskNodeId,String tableId){
+    public Result queryBusiness(String businessTable,String taskNodeId,String tableId,String type){
         boolean isSave=false;
         QueryWrapper<TbTableInfoPractice> queryWrapper = new QueryWrapper<TbTableInfoPractice>().eq("business_table_id", tableId);
+        String whereType="1";//默认类型为PC端表单
+        //如果类型不为PC端的表单则验证
+        if(!type.equals("1")){
+            //查询数据库是否存在当前type类型的表单
+            QueryWrapper<TbTableInfoPractice> queryWrapper2 = new QueryWrapper<TbTableInfoPractice>().eq("business_table_id", tableId);
+            queryWrapper2.lambda().eq(TbTableInfoPractice::getType,type);
+            queryWrapper2.lambda().eq(TbTableInfoPractice::getDelFlag,'0');
+            List<TbTableInfoPractice> tbTableInfoList=iTbTableInfoPracticeService.list(queryWrapper2);
+            //存在则可以继续查询 不存在则默认查询PC端的
+            if(tbTableInfoList!=null&&tbTableInfoList.size()>0){
+                whereType=type;
+            }
+        }
+        //过滤表单类型
+        queryWrapper.lambda().eq(TbTableInfoPractice::getType,whereType);
         //查询任务节点是否关联表
         List<ActNode> actNodeList=  actNodeService.list(new QueryWrapper<ActNode>().eq("node_id",taskNodeId));
         if(actNodeList!=null&&actNodeList.size()>0&&StringUtils.isNotBlank(actNodeList.get(0).getTbTableInfoId())){

+ 1 - 0
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -121,6 +121,7 @@ public class ShiroConfig {
 		filterChainDefinitionMap.put("/diagram-viewer/**", "anon");
 		filterChainDefinitionMap.put("/editor-app/**", "anon");
 		filterChainDefinitionMap.put("/tbTableInfo/**","anon");
+		filterChainDefinitionMap.put("/actBusiness/external/**","anon");
 
 		//性能监控
 		filterChainDefinitionMap.put("/actuator/metrics/**", "anon");

+ 5 - 1
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/controller/CdEnterpriseEnnouncementController.java

@@ -9,6 +9,7 @@ import java.net.URLDecoder;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import com.baomidou.mybatisplus.extension.api.R;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
@@ -72,10 +73,13 @@ public class CdEnterpriseEnnouncementController extends JeecgController<CdEnterp
 		//公司id过滤
 		LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 		queryWrapper.lambda().eq(CdEnterpriseEnnouncement::getPkOrg,sysUser.getOrgCode());
+		queryWrapper.lambda().eq(CdEnterpriseEnnouncement::getDelFlag,'0');
+		queryWrapper.lambda().orderByDesc(CdEnterpriseEnnouncement::getCreateTime);
 		Page<CdEnterpriseEnnouncement> page = new Page<CdEnterpriseEnnouncement>(pageNo, pageSize);
 		IPage<CdEnterpriseEnnouncement> pageList = cdEnterpriseEnnouncementService.page(page, queryWrapper);
 		return Result.ok(pageList);
 	}
+
 	
 	/**
 	 * 添加
@@ -175,7 +179,7 @@ public class CdEnterpriseEnnouncementController extends JeecgController<CdEnterp
 
   /**
   * @Author chenchuang
-  * @Description //TODO 发布与取消发布接口
+	  * @Description //TODO 发布与取消发布接口
   * @Date 2021/11/3 10:41
   * @Param [cdEnterpriseEnnouncement]
   * @return org.jeecg.common.api.vo.Result

+ 198 - 0
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/controller/CdLinksController.java

@@ -0,0 +1,198 @@
+package org.jeecg.modules.oa.controller;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.oa.entity.CdLinks;
+import org.jeecg.modules.oa.service.ICdLinksService;
+import java.util.Date;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+import com.alibaba.fastjson.JSON;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+ /**
+ * @Description: 友情链接
+ * @Author: jeecg-boot
+ * @Date:   2021-11-09
+ * @Version: V1.0
+ */
+@Slf4j
+@Api(tags="友情链接")
+@RestController
+@RequestMapping("/oa/cdLinks")
+public class CdLinksController extends JeecgController<CdLinks, ICdLinksService> {
+	@Autowired
+	private ICdLinksService cdLinksService;
+	
+	/**
+	 * 分页列表查询
+	 *
+	 * @param cdLinks
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	@AutoLog(value = "友情链接-分页列表查询")
+	@ApiOperation(value="友情链接-分页列表查询", notes="友情链接-分页列表查询")
+	@GetMapping(value = "/list")
+	public Result<?> queryPageList(CdLinks cdLinks,
+								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+								   HttpServletRequest req) {
+		QueryWrapper<CdLinks> queryWrapper = QueryGenerator.initQueryWrapper(cdLinks, req.getParameterMap());
+		LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+		queryWrapper.lambda().eq(CdLinks::getPkOrg,sysUser.getOrgCode());
+		queryWrapper.lambda().eq(CdLinks::getDelFlag,'0');
+		queryWrapper.lambda().orderByDesc(CdLinks::getCreateTime);
+		Page<CdLinks> page = new Page<CdLinks>(pageNo, pageSize);
+		IPage<CdLinks> pageList = cdLinksService.page(page, queryWrapper);
+		return Result.ok(pageList);
+	}
+	
+	/**
+	 * 添加
+	 *
+	 * @param cdLinks
+	 * @return
+	 */
+	@AutoLog(value = "友情链接-添加")
+	@ApiOperation(value="友情链接-添加", notes="友情链接-添加")
+	@PostMapping(value = "/add")
+	public Result<?> add(@RequestBody CdLinks cdLinks) {
+		//公司id
+		LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+		cdLinks.setPkOrg(sysUser.getOrgCode());
+		cdLinksService.save(cdLinks);
+		return Result.ok("添加成功!");
+	}
+	
+	/**
+	 * 编辑
+	 *
+	 * @param cdLinks
+	 * @return
+	 */
+	@AutoLog(value = "友情链接-编辑")
+	@ApiOperation(value="友情链接-编辑", notes="友情链接-编辑")
+	@PutMapping(value = "/edit")
+	public Result<?> edit(@RequestBody CdLinks cdLinks) {
+		cdLinksService.updateById(cdLinks);
+		return Result.ok("编辑成功!");
+	}
+	
+	/**
+	 * 通过id删除
+	 *
+	 * @param id
+	 * @return
+	 */
+	@AutoLog(value = "友情链接-通过id删除")
+	@ApiOperation(value="友情链接-通过id删除", notes="友情链接-通过id删除")
+	@DeleteMapping(value = "/delete")
+	public Result<?> delete(@RequestParam(name="id",required=true) String id) {
+		cdLinksService.removeById(id);
+		return Result.ok("删除成功!");
+	}
+	
+	/**
+	 * 批量删除
+	 *
+	 * @param ids
+	 * @return
+	 */
+	@AutoLog(value = "友情链接-批量删除")
+	@ApiOperation(value="友情链接-批量删除", notes="友情链接-批量删除")
+	@DeleteMapping(value = "/deleteBatch")
+	public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		this.cdLinksService.removeByIds(Arrays.asList(ids.split(",")));
+		return Result.ok("批量删除成功!");
+	}
+	
+	/**
+	 * 通过id查询
+	 *
+	 * @param id
+	 * @return
+	 */
+	@AutoLog(value = "友情链接-通过id查询")
+	@ApiOperation(value="友情链接-通过id查询", notes="友情链接-通过id查询")
+	@GetMapping(value = "/queryById")
+	public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
+		CdLinks cdLinks = cdLinksService.getById(id);
+		return Result.ok(cdLinks);
+	}
+
+  /**
+   * 导出excel
+   *
+   * @param request
+   * @param cdLinks
+   */
+  @RequestMapping(value = "/exportXls")
+  public ModelAndView exportXls(HttpServletRequest request, CdLinks cdLinks) {
+      return super.exportXls(request, cdLinks, CdLinks.class, "友情链接");
+  }
+
+  /**
+   * 通过excel导入数据
+   *
+   * @param request
+   * @param response
+   * @return
+   */
+  @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+  public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+      return super.importExcel(request, response, CdLinks.class);
+  }
+
+  /**
+  * @Author chenchuang
+  * @Description //TODO 发布与取消发布接口
+  * @Date 2021/11/9 10:53
+  * @Param [cdLinks]
+  * @return org.jeecg.common.api.vo.Result
+  */
+ @RequestMapping(value = "/releaseUpdate")
+ public Result releaseUpdate(CdLinks cdLinks){
+	 Result result =new Result();
+	 CdLinks entity= cdLinksService.getById(cdLinks.getId());
+	 if(entity==null){
+		 result.error500("未找到实体");
+		 return result;
+	 }
+	 entity.setIsRelease(cdLinks.getIsRelease());
+	 cdLinksService.updateById(entity);
+	 result.success("操作成功");
+	 return result;
+ }
+
+}

+ 2 - 0
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/controller/CdScheduleController.java

@@ -71,6 +71,8 @@ public class CdScheduleController extends JeecgController<CdSchedule, ICdSchedul
 		QueryWrapper<CdSchedule> queryWrapper = QueryGenerator.initQueryWrapper(cdSchedule, req.getParameterMap());
 		LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
 		queryWrapper.lambda().eq(CdSchedule::getPkOrg,sysUser.getOrgCode());
+		queryWrapper.lambda().eq(CdSchedule::getDelFlag,'0');
+		queryWrapper.lambda().orderByDesc(CdSchedule::getCreateTime);
 		Page<CdSchedule> page = new Page<CdSchedule>(pageNo, pageSize);
 		IPage<CdSchedule> pageList = cdScheduleService.page(page, queryWrapper);
 		return Result.ok(pageList);

+ 79 - 0
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/entity/CdLinks.java

@@ -0,0 +1,79 @@
+package org.jeecg.modules.oa.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * @Description: 友情链接
+ * @Author: jeecg-boot
+ * @Date:   2021-11-09
+ * @Version: V1.0
+ */
+@Data
+@TableName("cd_links")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="cd_links对象", description="友情链接")
+public class CdLinks {
+    
+	/**主键id*/
+	@TableId(type = IdType.ID_WORKER_STR)
+    @ApiModelProperty(value = "主键id")
+	private String id;
+	/**名称*/
+	@Excel(name = "名称", width = 15)
+    @ApiModelProperty(value = "名称")
+	private String name;
+	/**链接*/
+	@Excel(name = "链接", width = 15)
+    @ApiModelProperty(value = "链接")
+	private String link;
+	/**是否发布0否1是*/
+	@Excel(name = "是否发布0否1是", width = 15)
+    @ApiModelProperty(value = "是否发布0否1是")
+	private String isRelease;
+	/**简介*/
+	@Excel(name = "简介", width = 15)
+    @ApiModelProperty(value = "简介")
+	private Object briefIntroduction;
+	/**创建人*/
+	@Excel(name = "创建人", width = 15)
+    @ApiModelProperty(value = "创建人")
+	private String createBy;
+	/**创建日期*/
+	@Excel(name = "创建日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建日期")
+	private Date createTime;
+	/**更新人*/
+	@Excel(name = "更新人", width = 15)
+    @ApiModelProperty(value = "更新人")
+	private String updateBy;
+	/**更新日期*/
+	@Excel(name = "更新日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "更新日期")
+	private Date updateTime;
+	/**所属公司*/
+	@Excel(name = "所属公司", width = 15)
+    @ApiModelProperty(value = "所属公司")
+	private String pkOrg;
+	/**删除标记(0正常1删除)*/
+	@Excel(name = "删除标记(0正常1删除)", width = 15)
+    @ApiModelProperty(value = "删除标记(0正常1删除)")
+	private String delFlag;
+}

+ 17 - 0
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/mapper/CdLinksMapper.java

@@ -0,0 +1,17 @@
+package org.jeecg.modules.oa.mapper;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.oa.entity.CdLinks;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * @Description: 友情链接
+ * @Author: jeecg-boot
+ * @Date:   2021-11-09
+ * @Version: V1.0
+ */
+public interface CdLinksMapper extends BaseMapper<CdLinks> {
+
+}

+ 5 - 0
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/mapper/xml/CdLinksMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.oa.mapper.CdLinksMapper">
+
+</mapper>

+ 14 - 0
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/service/ICdLinksService.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.oa.service;
+
+import org.jeecg.modules.oa.entity.CdLinks;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 友情链接
+ * @Author: jeecg-boot
+ * @Date:   2021-11-09
+ * @Version: V1.0
+ */
+public interface ICdLinksService extends IService<CdLinks> {
+
+}

+ 19 - 0
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oa/service/impl/CdLinksServiceImpl.java

@@ -0,0 +1,19 @@
+package org.jeecg.modules.oa.service.impl;
+
+import org.jeecg.modules.oa.entity.CdLinks;
+import org.jeecg.modules.oa.mapper.CdLinksMapper;
+import org.jeecg.modules.oa.service.ICdLinksService;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+/**
+ * @Description: 友情链接
+ * @Author: jeecg-boot
+ * @Date:   2021-11-09
+ * @Version: V1.0
+ */
+@Service
+public class CdLinksServiceImpl extends ServiceImpl<CdLinksMapper, CdLinks> implements ICdLinksService {
+
+}

+ 33 - 0
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/LoginController.java

@@ -4,6 +4,7 @@ import cn.hutool.core.util.RandomUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.aliyuncs.exceptions.ClientException;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.dingtalk.api.response.OapiDepartmentListResponse;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -338,6 +339,18 @@ public class LoginController {
 		return result;
 	}
 
+	@PostMapping("/getToKen")
+	public Result getToKen(String username,String syspassword){
+		Result result=new Result();
+		// 生成token
+		String token = JwtUtil.sign(username, syspassword);
+		// 设置token缓存有效时间
+		redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
+		redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME*2 / 1000);
+		result.setResult(token);
+		return result;
+	}
+
 
 	/**
 	 * 用户信息
@@ -541,6 +554,22 @@ public class LoginController {
 		//System.out.println("---------------------------- user info :"+JSONObject.toJSONString(userInfo));
 		// 获取用户完整信息
 		JSONObject user = HttpHelper.getUserCompleteInfo(accessToken,userInfo.getString("userid"));
+		String pkOrg="";//组织id
+		try {
+			//获取公司信息
+			Map<String,Object> departmentMap=HttpHelper.getDepartmentGet("1",accessToken);
+			//根据公司名称获取公司id
+			QueryWrapper<SysDepart> queryWrapper=new QueryWrapper<>();
+			queryWrapper.lambda().eq(SysDepart::getDelFlag,'0');
+			queryWrapper.lambda().eq(SysDepart::getDepartName,departmentMap.get("name"));
+			List<SysDepart> sysDepartList=sysDepartService.list(queryWrapper);
+			if(sysDepartList!=null&&sysDepartList.size()>0){
+				pkOrg=sysDepartList.get(0).getId();
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+//		JSONObject list = DepartmentHelper.listDepartments(accessToken, "1");
 		System.out.println(user);
 		//获取项目用户信息
 		QueryWrapper<SysUser> sysUserQueryWrapper = new QueryWrapper<>();
@@ -555,6 +584,10 @@ public class LoginController {
 			result.error500("用户不存在");
 			return result;
 		}else{
+			//如果根据钉钉公司名称查询不为空则赋值公司id
+			if(StringUtils.isNotBlank(pkOrg)){
+				one.setPkOrg(pkOrg);
+			}
 			//用户登录信息
 			userInfo(one, result);
 			sysBaseAPI.addLog("用户名: " + one.getUsername() + ",登录成功!", CommonConstant.LOG_TYPE_1, null);

+ 4 - 4
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysBaseApiImpl.java

@@ -210,12 +210,12 @@ public class SysBaseApiImpl implements ISysBaseAPI {
 	}
 
 	@Override
-	public void sendSysAnnouncement(String fromUser, String toUser, String title, String msgContent,Map<String,Object> map) {
-		this.sendSysAnnouncement(fromUser, toUser, title, msgContent, CommonConstant.MSG_CATEGORY_2,map);
+	public void sendSysAnnouncement(LoginUser loginUser,String fromUser, String toUser, String title, String msgContent,Map<String,Object> map) {
+		this.sendSysAnnouncement(loginUser,fromUser, toUser, title, msgContent, CommonConstant.MSG_CATEGORY_2,map);
 	}
 
 	@Override
-	public void sendSysAnnouncement(String fromUser, String toUser, String title, String msgContent, String setMsgCategory,Map<String,Object> map) {
+	public void sendSysAnnouncement(LoginUser loginUser,String fromUser, String toUser, String title, String msgContent, String setMsgCategory,Map<String,Object> map) {
 		SysAnnouncement announcement = new SysAnnouncement();
 		announcement.setTitile(title);
 		announcement.setMsgContent(msgContent);
@@ -227,7 +227,7 @@ public class SysBaseApiImpl implements ISysBaseAPI {
 		announcement.setMsgCategory(setMsgCategory);
 		announcement.setDelFlag(String.valueOf(CommonConstant.DEL_FLAG_0));
 		//公司id
-		LoginUser loginUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
+//		LoginUser loginUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
 		announcement.setPkOrg(loginUser.getOrgCode());
 		if(map!=null){
 			if(map.get("isUrl")!=null&&map.get("isUrl").toString().equals("1")){

+ 23 - 3
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/util/HttpHelper.java

@@ -31,9 +31,7 @@ import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
-import java.util.Formatter;
-import java.util.LinkedList;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Slf4j
@@ -406,6 +404,28 @@ public class HttpHelper {
         return ret;
     }
 
+    /**
+     * 根据部门id获取部门信息
+     * @param accessToken
+     * @throws Exception
+     */
+    public static Map<String,Object> getDepartmentGet(String depId,String accessToken) throws Exception{
+        DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/department/get");
+        OapiDepartmentGetRequest req = new OapiDepartmentGetRequest();
+        req.setHttpMethod("GET");
+        req.setLang("zh_CN");
+        req.setId(depId);
+        OapiDepartmentGetResponse response = client.execute(req, accessToken);
+        Map<String,Object> map=new HashMap<>();
+        if (response.isSuccess()){
+//            ret = response.getBody();
+            map.put("name",response.getName());
+        }else {
+            log.error("---------------------------- get department list error:" + response.getErrmsg());
+        }
+        return map;
+    }
+
     /**
      * 发送钉钉消息
      * @param username 人员的name,根据name去钉钉中匹配,找到对应的钉钉userid