From 2b9cdcbaccb6ea4c4ffe9461d0589ab3e28ef7f3 Mon Sep 17 00:00:00 2001
From: fengjin <1435304038@qq.com>
Date: 星期一, 10 十月 2022 16:06:12 +0800
Subject: [PATCH] Merge branch 'zigonggao_dev' into huacheng_test

---
 flower_city/src/main/java/com/dg/core/db/gen/mapper/SysUserMapper.java              |    8 +
 flower_city/src/main/java/com/dg/core/api/ReplyTemplateAppletsController.java       |  159 ++++++++++++++++++++++++++
 flower_city/src/main/java/com/dg/core/service/ISysUserService.java                  |    8 +
 flower_city/src/main/resources/mapper/SysUserMapper.xml                             |    9 +
 flower_city/src/main/java/com/dg/core/api/GuideDoAppletsController.java             |   56 +++++++++
 flower_city/src/main/java/com/dg/core/db/gen/entity/SysUser.java                    |    6 +
 flower_city/src/main/resources/mapper/OrganizationChartMapper.xml                   |    7 +
 flower_city/src/main/java/com/dg/core/controller/GuideDoController.java             |   14 ++
 flower_city/src/main/java/com/dg/core/db/gen/mapper/OrganizationChartMapper.java    |    6 +
 flower_city/src/main/java/com/dg/core/service/impl/SysUserServiceImpl.java          |   10 +
 flower_city/src/main/java/com/dg/core/service/impl/GuideRepairOrderServiceImpl.java |   73 +++++++++++-
 11 files changed, 348 insertions(+), 8 deletions(-)

diff --git a/flower_city/src/main/java/com/dg/core/api/GuideDoAppletsController.java b/flower_city/src/main/java/com/dg/core/api/GuideDoAppletsController.java
new file mode 100644
index 0000000..e2352af
--- /dev/null
+++ b/flower_city/src/main/java/com/dg/core/api/GuideDoAppletsController.java
@@ -0,0 +1,56 @@
+package com.dg.core.api;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.dg.core.ResultData;
+import com.dg.core.annotation.Authorization;
+import com.dg.core.controller.BaseController;
+import com.dg.core.db.gen.entity.SysUser;
+import com.dg.core.service.ISysUserService;
+import com.dg.core.util.Snowflake;
+import com.dg.core.util.TableDataInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.Assert;
+import org.springframework.web.bind.annotation.*;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+
+@Api(tags = {"导办用户小程序接口"})
+@RestController
+@RequestMapping("/applets/guidedo")
+public class GuideDoAppletsController extends BaseController
+{
+
+    @Autowired
+    ISysUserService IUserService;
+
+
+
+    /**
+     * 根据部门id及分类id获取导办用户
+     *
+     * @return 结果
+     */
+    @ApiOperation(value = "根据部门id及分类id获取导办用户",response = SysUser.class)
+    @GetMapping("/selectListByDepartmentId")
+    @Authorization
+    public ResultData selectListByDepartmentId(@RequestParam("departmentId") String departmentId,
+                                               @RequestParam(value = "classifyId",required = false) String classifyId){
+        return  ResultData.success(IUserService.selectListByDepartmentId(departmentId,classifyId));
+    }
+
+    /**
+     * 查询导办用户列表(不分页)
+     * @return 结果
+     */
+    @ApiOperation(value = " 查询导办用户列表(不分页)",response = SysUser.class)
+    @GetMapping("/queryList")
+    public  ResultData  queryList(){
+        return  ResultData.success(IUserService.queryList(2));
+    }
+
+}
diff --git a/flower_city/src/main/java/com/dg/core/api/ReplyTemplateAppletsController.java b/flower_city/src/main/java/com/dg/core/api/ReplyTemplateAppletsController.java
new file mode 100644
index 0000000..79cea4f
--- /dev/null
+++ b/flower_city/src/main/java/com/dg/core/api/ReplyTemplateAppletsController.java
@@ -0,0 +1,159 @@
+package com.dg.core.api;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.dg.core.ResultData;
+import com.dg.core.annotation.Authorization;
+import com.dg.core.annotation.CurrentUser;
+import com.dg.core.controller.BaseController;
+import com.dg.core.db.gen.entity.ReplyTemplateEntity;
+import com.dg.core.db.gen.entity.SysUser;
+import com.dg.core.service.IOrganizationChartService;
+import com.dg.core.service.IReplyTemplateService;
+import com.dg.core.util.TableDataInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@Api(tags = {"回复模板小程序接口"})
+@RestController
+@RequestMapping("/applets/reply")
+public class ReplyTemplateAppletsController extends BaseController
+{
+
+    @Autowired
+    IReplyTemplateService iReplyTemplateService;
+
+    @Autowired
+    IOrganizationChartService iOrganizationChartService;
+
+
+    /**
+     * 获取模板列表
+     * @return
+     */
+    @ApiOperation(value = "获取模板列表",response = ReplyTemplateEntity.class)
+    @GetMapping("/getlist")
+    @Authorization
+    public TableDataInfo selectConfigList(@RequestParam(value = "pageNum",required = false) Integer pageNum,
+                                          @RequestParam(value = "pageSize",required = false) Integer pageSize,
+                                          @RequestParam(value = "Name",required = false) String Name,
+                                          @CurrentUser SysUser sysUser)
+    {
+        Page<ReplyTemplateEntity> pageParam = new Page<>(pageNum,pageSize);
+        List<String> ids=iOrganizationChartService.getIds(sysUser.getDepartmentId());
+        List<ReplyTemplateEntity> list = iReplyTemplateService.selectConfigList(pageParam,pageSize,Name,ids);
+        int num=iReplyTemplateService.countNum(Name,ids);
+        return getDataTable(list,num);
+    }
+
+    /**
+     * 获取详情
+     * @param Id
+     * @return
+     */
+    @ApiOperation(value = "获取详情",response = ReplyTemplateEntity.class)
+    @GetMapping("/getdata")
+    @Authorization
+    public ResultData selectConfigData(@RequestParam(value = "Id",required = false) String Id)
+    {
+        if(StringUtils.isEmpty(Id))
+        {
+            return ResultData.error("Id不能为空");
+        }
+        return ResultData.success(iReplyTemplateService.selectConfigData(Id));
+    }
+
+    /**
+     * 新增模板
+     * @param entity
+     * @return
+     */
+    @ApiOperation(value = "新增模板",response = ReplyTemplateEntity.class)
+    @PostMapping("/add")
+    @Authorization
+    public ResultData insertConfig(@RequestBody ReplyTemplateEntity entity,@CurrentUser SysUser sysUser)
+    {
+        if(entity==null)
+        {
+            return ResultData.error("参数不能为空");
+        }
+
+        if(StringUtils.isEmpty(entity.getName()))
+        {
+            return ResultData.error("模板名称不能为空");
+        }
+
+        entity.setId(null);
+        entity.setDepartmentId(sysUser.getDepartmentId());
+        entity.setCreateUserId(sysUser.getUserId()+"");
+
+        return toAjax(iReplyTemplateService.insertConfig(entity));
+    }
+
+    /**
+     * 更新模板
+     * @param entity
+     * @return
+     */
+    @ApiOperation(value = "更新模板",response = ReplyTemplateEntity.class)
+    @PostMapping("/update")
+    @Authorization
+    public ResultData updateConfig(@RequestBody ReplyTemplateEntity entity)
+    {
+        if(entity==null)
+        {
+            return ResultData.error("参数不能为空");
+        }
+
+        if(StringUtils.isEmpty(entity.getName()))
+        {
+            return ResultData.error("模板名称不能为空");
+        }
+        return toAjax(iReplyTemplateService.updateConfig(entity));
+    }
+
+    /**
+     * 删除模板
+     * @param Id
+     * @return
+     */
+    @ApiOperation(value = "删除模板",response = ReplyTemplateEntity.class)
+    @DeleteMapping("/delete")
+    @Authorization
+    public ResultData deleteConfigById(@RequestParam(value = "Id",required = false) String Id)
+    {
+        return toAjax(iReplyTemplateService.deleteConfigById(Id));
+    }
+
+
+    /**
+     * 复制模板
+     * @param Id
+     * @return
+     */
+    @ApiOperation(value = "复制模板",response = ReplyTemplateEntity.class)
+    @PostMapping("/copy")
+    @Authorization
+    public ResultData copy(@RequestParam(value = "Id",required = false) String Id)
+    {
+        if(StringUtils.isEmpty(Id))
+        {
+            return ResultData.error("Id不能为空");
+        }
+
+        ReplyTemplateEntity entity=iReplyTemplateService.selectConfigData(Id);
+
+        if(entity==null)
+        {
+            return ResultData.error("模板不存在!");
+        }
+        entity.setId(null);
+        return toAjax(iReplyTemplateService.insertConfig(entity));
+    }
+
+
+}
diff --git a/flower_city/src/main/java/com/dg/core/controller/GuideDoController.java b/flower_city/src/main/java/com/dg/core/controller/GuideDoController.java
index 63137fe..c533fca 100644
--- a/flower_city/src/main/java/com/dg/core/controller/GuideDoController.java
+++ b/flower_city/src/main/java/com/dg/core/controller/GuideDoController.java
@@ -11,6 +11,7 @@
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.repository.query.Param;
 import org.springframework.util.Assert;
 import org.springframework.web.bind.annotation.*;
 
@@ -178,8 +179,19 @@
     @GetMapping("/selectListByDepartmentId")
     @Authorization
     public ResultData selectListByDepartmentId(@RequestParam("departmentId") String departmentId,
-                                               @RequestParam("classifyId") String classifyId){
+                                               @RequestParam(value = "classifyId",required = false) String classifyId){
         return  ResultData.success(IUserService.selectListByDepartmentId(departmentId,classifyId));
     }
 
+    /**
+     * 查询导办用户列表(不分页)
+     * @return 结果
+     */
+    @ApiOperation(" 查询导办用户列表(不分页)")
+    @GetMapping("/queryList")
+    @Authorization
+    public  ResultData  queryList(){
+        return  ResultData.success(IUserService.queryList(2));
+    }
+
 }
diff --git a/flower_city/src/main/java/com/dg/core/db/gen/entity/SysUser.java b/flower_city/src/main/java/com/dg/core/db/gen/entity/SysUser.java
index f0b30e7..704b993 100644
--- a/flower_city/src/main/java/com/dg/core/db/gen/entity/SysUser.java
+++ b/flower_city/src/main/java/com/dg/core/db/gen/entity/SysUser.java
@@ -237,6 +237,12 @@
     @ApiModelProperty("微信小程序id")
     private String openid;
 
+    /**
+     * 待处理办事指南数量
+     */
+    @ApiModelProperty("待处理办事指南数量")
+    private Integer transactionNum;
+
 
 
 
diff --git a/flower_city/src/main/java/com/dg/core/db/gen/mapper/OrganizationChartMapper.java b/flower_city/src/main/java/com/dg/core/db/gen/mapper/OrganizationChartMapper.java
index 2cce0ad..dcceb35 100644
--- a/flower_city/src/main/java/com/dg/core/db/gen/mapper/OrganizationChartMapper.java
+++ b/flower_city/src/main/java/com/dg/core/db/gen/mapper/OrganizationChartMapper.java
@@ -59,5 +59,11 @@
     int countList(String organizationName);
 
 
+    /**
+     * 根据所属地区查找部门
+     */
+    List<OrganizationChartEntity> selectByCode(@Param("areaCode") String areaCode);
+
+
 
 }
diff --git a/flower_city/src/main/java/com/dg/core/db/gen/mapper/SysUserMapper.java b/flower_city/src/main/java/com/dg/core/db/gen/mapper/SysUserMapper.java
index 05f9292..112b146 100644
--- a/flower_city/src/main/java/com/dg/core/db/gen/mapper/SysUserMapper.java
+++ b/flower_city/src/main/java/com/dg/core/db/gen/mapper/SysUserMapper.java
@@ -70,4 +70,12 @@
      * @return 结果
      */
     List<SysUser> selectListByDepartmentId(@Param("list") List<String> list,@Param("classifyIdFront") String classifyIdFront,@Param("classifyIdAfter") String classifyIdAfter);
+
+
+    /**
+     * 查询用户列表(不分页)
+     * @param userType 用户类型
+     * @return 结果
+     */
+    List<SysUser>  queryList(@Param("userType") Integer userType);
 }
diff --git a/flower_city/src/main/java/com/dg/core/service/ISysUserService.java b/flower_city/src/main/java/com/dg/core/service/ISysUserService.java
index 3b24b17..92d98eb 100644
--- a/flower_city/src/main/java/com/dg/core/service/ISysUserService.java
+++ b/flower_city/src/main/java/com/dg/core/service/ISysUserService.java
@@ -80,4 +80,12 @@
     ResultData loginByPhonenumber(String phonenumber);
 
 
+    /**
+     * 查询用户列表(不分页)
+     * @param userType 用户类型
+     * @return 结果
+     */
+    List<SysUser>  queryList(Integer userType);
+
+
 }
diff --git a/flower_city/src/main/java/com/dg/core/service/impl/GuideRepairOrderServiceImpl.java b/flower_city/src/main/java/com/dg/core/service/impl/GuideRepairOrderServiceImpl.java
index a95049c..8a45c67 100644
--- a/flower_city/src/main/java/com/dg/core/service/impl/GuideRepairOrderServiceImpl.java
+++ b/flower_city/src/main/java/com/dg/core/service/impl/GuideRepairOrderServiceImpl.java
@@ -4,16 +4,14 @@
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.dg.core.db.gen.entity.*;
-import com.dg.core.db.gen.mapper.GuideRepairOrderImageMapper;
-import com.dg.core.db.gen.mapper.GuideRepairOrderMapper;
-import com.dg.core.db.gen.mapper.SysUserMapper;
-import com.dg.core.db.gen.mapper.TransactionEventMapper;
+import com.dg.core.db.gen.mapper.*;
 import com.dg.core.service.IGuideRepairOrderService;
 import com.dg.core.util.Snowflake;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.time.LocalDateTime;
+import java.util.ArrayList;
 import java.util.List;
 
 @Service
@@ -27,6 +25,12 @@
 
     @Resource
     private SysUserMapper sysUserMapper;
+    
+    @Resource
+    private OrganizationChartMapper  organizationChartMapper;
+
+    @Resource
+    private  GuideEvolveMapper guideEvolveMapper;
 
     @Override
     public  int addOrder(GuideRepairOrder guideRepairOrder){
@@ -37,11 +41,55 @@
         guideRepairOrder.setMatterName(transactionEvent.getMatterName());
         guideRepairOrder.setDepartmentId(transactionEvent.getDepartmentId());
         guideRepairOrder.setClassifyId(transactionEvent.getClassifyId());
-        sysUserMapper.selectListByDepartmentId(null, "," + guideRepairOrder.getMatterId(), guideRepairOrder.getMatterId() + ",");
-        guideRepairOrder.setState("1");
+        List<String> departmentIds=new ArrayList<>();
+        //自动分配业务代码开始
+        List<OrganizationChartEntity> organizationChartEntities = organizationChartMapper.selectByCode(guideRepairOrder.getAreaCode());
+        if (organizationChartEntities!=null){
+            for (OrganizationChartEntity organizationChart:organizationChartEntities) {
+                departmentIds.add(organizationChart.getId().toString());
+            }
+            List<SysUser> sysUsers = sysUserMapper.selectListByDepartmentId(departmentIds, "," + transactionEvent.getClassifyId(), transactionEvent.getClassifyId() + ",");//获取导半人员
+            if (sysUsers==null) {//如果此所属地区部门没有导半人员则看其下级地区有没有相关分类导办人员
+                for (OrganizationChartEntity organizationChart:organizationChartEntities) {
+                    //获取下级部门
+                    List<OrganizationChartEntity> organizationChartEntitiesUser = organizationChartMapper.selectList(new QueryWrapper<OrganizationChartEntity>().lambda()
+                            .eq(OrganizationChartEntity::getParentId, organizationChart.getId().toString()));
+                    if (organizationChartEntitiesUser!=null)
+                        departmentIds=this.getDepartmentIds(organizationChartEntitiesUser,departmentIds);
+                }
+                sysUsers = sysUserMapper.selectListByDepartmentId(departmentIds, "," + transactionEvent.getClassifyId(), transactionEvent.getClassifyId() + ",");//获取导半人员
+                if (sysUsers==null){//如果其下级部门仍没有该分类的导半人员则查询所以该所属地区的导办人员
+                    sysUsers = sysUserMapper.selectListByDepartmentId(departmentIds,null,null);//获取导半人员
+                    if(sysUsers==null)//如果该所属地区没有导办人员则为特殊单据需要手动分配
+                        guideRepairOrder.setState("1");
+                }
+            }
+            if (sysUsers!=null){//系统分配导办人员
+                SysUser sysUser = sysUsers.get(0);//因为sql用了升序排序所以第一条就是待办结最少的人员之一
+                guideRepairOrder.setState("2");
+                guideRepairOrder.setGuideUserId(sysUser.getUserId().toString());
+                guideRepairOrder.setGuideDepartmentId(sysUser.getDepartmentId());
+                //新增分配记录
+                GuideEvolveEntity entity=new GuideEvolveEntity();
+                entity.setCreateTime(LocalDateTime.now());
+                entity.setUpdateTime(LocalDateTime.now());
+                entity.setState("10");
+                entity.setDepartmentalId(sysUser.getDepartmentId());
+                entity.setToUserId(guideRepairOrder.getGuideUserId()+"");
+                entity.setFromUserId(guideRepairOrder.getSubmitUserId());
+                entity.setFromDepartmentalId(guideRepairOrder.getGuideDepartmentId());
+                entity.setGuideId(guideRepairOrder.getId().toString());
+                guideEvolveMapper.insertConfig(entity);
+            }
+        }
+        else{//如果该办事指南用户所选所属地区无导半部门则为特殊单据需要手动分配
+           guideRepairOrder.setState("1");
+        }
+        //自动分配业务代码结束
         guideRepairOrder.setCreateTime(LocalDateTime.now());
         guideRepairOrder.setUpdateTime(LocalDateTime.now());
         transactionEvent.setTransactionNum(transactionEvent.getTransactionNum()+1);
+        //保存图片地址
         if (guideRepairOrder.getImages()!=null){
            String[] images = guideRepairOrder.getImages().split(",");
            for (String image: images) {
@@ -54,6 +102,7 @@
             guideRepairOrderImageMapper.insert(guideRepairOrderImage);
           }
         }
+        //保存视频地址
         if (guideRepairOrder.getVideo()!=null){
           if (guideRepairOrder.getOrderNum()!=null){
             GuideRepairOrderImage guideRepairOrderImage = new GuideRepairOrderImage();
@@ -74,6 +123,18 @@
 
     }
 
+    public  List<String> getDepartmentIds(  List<OrganizationChartEntity> organizationChartEntities,List<String> departmentIds){
+        for (OrganizationChartEntity organizationChart:organizationChartEntities) {
+            departmentIds.add(organizationChart.getId().toString());
+            List<OrganizationChartEntity> organizationChartEntitiesUser = organizationChartMapper.selectList(new QueryWrapper<OrganizationChartEntity>().lambda()
+                    .eq(OrganizationChartEntity::getParentId, organizationChart.getId().toString()));
+            if (organizationChartEntitiesUser!=null)
+                departmentIds=this.getDepartmentIds(organizationChartEntitiesUser,departmentIds);
+
+        }
+        return  departmentIds;
+    }
+
     @Override
     public GuideRepairOrder selectConfigData(String Id, String orderNum) {
         return baseMapper.selectConfigData(Id,orderNum);
diff --git a/flower_city/src/main/java/com/dg/core/service/impl/SysUserServiceImpl.java b/flower_city/src/main/java/com/dg/core/service/impl/SysUserServiceImpl.java
index 505ff13..8a699d6 100644
--- a/flower_city/src/main/java/com/dg/core/service/impl/SysUserServiceImpl.java
+++ b/flower_city/src/main/java/com/dg/core/service/impl/SysUserServiceImpl.java
@@ -147,7 +147,10 @@
                     departmentIds=this.getDepartmentIds(organizationChartEntitiesUser,departmentIds);
             }
         }
-        return baseMapper.selectListByDepartmentId(departmentIds,","+classifyId,classifyId+",");
+        if (classifyId==null)
+            return baseMapper.selectListByDepartmentId(departmentIds,null,null);
+        else
+             return baseMapper.selectListByDepartmentId(departmentIds,","+classifyId,classifyId+",");
     }
 
     @Override
@@ -224,6 +227,11 @@
         }
     }
 
+    @Override
+    public List<SysUser> queryList(Integer userType) {
+        return baseMapper.queryList(userType);
+    }
+
     public  List<String> getDepartmentIds(  List<OrganizationChartEntity> organizationChartEntities,List<String> departmentIds){
         for (OrganizationChartEntity organizationChart:organizationChartEntities) {
             departmentIds.add(organizationChart.getId().toString());
diff --git a/flower_city/src/main/resources/mapper/OrganizationChartMapper.xml b/flower_city/src/main/resources/mapper/OrganizationChartMapper.xml
index 84b6f2a..33eb168 100644
--- a/flower_city/src/main/resources/mapper/OrganizationChartMapper.xml
+++ b/flower_city/src/main/resources/mapper/OrganizationChartMapper.xml
@@ -91,6 +91,13 @@
         or resume like concat('%', #{keyWord}, '%') or #{keyWord} like concat('%', resume, '%')
     </select>
 
+    <select id="selectByCode" resultMap="OrganizationChartResult">
+        <include refid="selectOrganizationChartVo"/>
+        <where>
+            city=#{areaCode} or district= #{areaCode} or village=#{areaCode}
+        </where>
+    </select>
+
     <insert id="insertConfig" parameterType="com.dg.core.db.gen.entity.OrganizationChartEntity">
         insert into automessage_organization_chart (
         <if test="id != null">id,</if>
diff --git a/flower_city/src/main/resources/mapper/SysUserMapper.xml b/flower_city/src/main/resources/mapper/SysUserMapper.xml
index e34d69d..a4ed940 100644
--- a/flower_city/src/main/resources/mapper/SysUserMapper.xml
+++ b/flower_city/src/main/resources/mapper/SysUserMapper.xml
@@ -35,6 +35,7 @@
         <result property="transactionIds"      column="transaction_ids"      />
         <result property="transactionNames"      column="transaction_names"      />
         <result property="openid"      column="openid"      />
+        <result property="transactionNum"      column="transaction_num"      />
     </resultMap>
 
     <sql id="selectSysUserVo">
@@ -85,6 +86,14 @@
         </where>
     </select>
 
+    <select id="queryList"  resultMap="SysUserResult">
+        <include refid="selectSysUserVo"/>
+        <where>
+            user_type=#{userType}
+        </where>
+        ORDER BY department_id
+    </select>
+
     <select id="selectConfigList" parameterType="string" resultMap="SysUserResult">
         <include refid="selectSysUserVo"/>
         <where>

--
Gitblit v1.7.1