Browse Source

派单管理

shudonghui 1 năm trước cách đây
mục cha
commit
48736dbb12

+ 87 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/result/TBCrmResult.java

@@ -0,0 +1,87 @@
+package com.qmth.sop.business.bean.result;
+
+import com.qmth.sop.business.entity.TBCrm;
+import com.qmth.sop.common.enums.ProductTypeEnum;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+public class TBCrmResult extends TBCrm implements Serializable {
+
+    @ApiModelProperty(value = "服务单元")
+    private String service;
+
+    @ApiModelProperty(value = "派单人")
+    private String crmUserName;
+
+    @ApiModelProperty(value = "客户名称")
+    private String custom;
+
+    @ApiModelProperty(value = "客户类型")
+    private ProductTypeEnum customType;
+
+    @ApiModelProperty(value = "实施产品")
+    private String product;
+
+    @ApiModelProperty(value = "大区经理")
+    private String leadName;
+
+    @ApiModelProperty(value = "提交人")
+    private String createName;
+
+    public String getService() {
+        return service;
+    }
+
+    public void setService(String service) {
+        this.service = service;
+    }
+
+    public String getCrmUserName() {
+        return crmUserName;
+    }
+
+    public void setCrmUserName(String crmUserName) {
+        this.crmUserName = crmUserName;
+    }
+
+    public String getCustom() {
+        return custom;
+    }
+
+    public void setCustom(String custom) {
+        this.custom = custom;
+    }
+
+    public ProductTypeEnum getCustomType() {
+        return customType;
+    }
+
+    public void setCustomType(ProductTypeEnum customType) {
+        this.customType = customType;
+    }
+
+    public String getProduct() {
+        return product;
+    }
+
+    public void setProduct(String product) {
+        this.product = product;
+    }
+
+    public String getLeadName() {
+        return leadName;
+    }
+
+    public void setLeadName(String leadName) {
+        this.leadName = leadName;
+    }
+
+    public String getCreateName() {
+        return createName;
+    }
+
+    public void setCreateName(String createName) {
+        this.createName = createName;
+    }
+}

+ 10 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/TBCrmMapper.java

@@ -5,11 +5,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.sop.business.bean.result.CrmServiceResult;
 import com.qmth.sop.business.bean.result.SysLogResult;
+import com.qmth.sop.business.bean.result.TBCrmResult;
 import com.qmth.sop.business.entity.TBCrm;
 import com.qmth.sop.common.enums.ProductTypeEnum;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -66,4 +68,12 @@ public interface TBCrmMapper extends BaseMapper<TBCrm> {
      * @return 派单信息
      */
     List<CrmServiceResult> findOrderListByServiceIds(@Param("serviceIdList") List<Long> serviceIdList);
+
+	/**
+	 * 查询列表
+	 * @param iPage
+	 * @return
+	 */
+
+    IPage<TBCrmResult> query(IPage<Map> iPage, @Param("serviceId") Long serviceId, @Param("leadId") Long leadId, @Param("crmUserId") Long crmUserId, @Param("type") String type, @Param("custom") String custom, @Param("crmNo") String crmNo, @Param("startTime") Long startTime, @Param("endTime") Long endTime);
 }

+ 32 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TBCrmService.java

@@ -1,14 +1,17 @@
 package com.qmth.sop.business.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.sop.business.bean.params.ServiceScopeParam;
 import com.qmth.sop.business.bean.result.CrmServiceResult;
 import com.qmth.sop.business.bean.result.CrmSubTotalResult;
+import com.qmth.sop.business.bean.result.TBCrmResult;
 import com.qmth.sop.business.entity.TBCrm;
 import com.qmth.sop.common.enums.ProductTypeEnum;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -83,4 +86,33 @@ public interface TBCrmService extends IService<TBCrm> {
      * @return 派单小计
      */
     CrmSubTotalResult findCrmSubTotalData();
+
+
+
+    /**
+     * 查询列表
+     *
+     * @param iPage
+     * @return
+     */
+    IPage<TBCrmResult> query(IPage<Map> iPage, Long serviceId, Long leadId, Long crmUserId, ProductTypeEnum type, String custom, String crmNo, Long startTime, Long endTime);
+    /**
+     * 新增修改派单信息表
+     *
+     * @param tBCrm
+     */
+    Boolean saveTBCrm(TBCrm tBCrm);
+
+
+    /**
+     * 删除派单信息表
+     *
+     * @param id
+     */
+    Boolean delete(Long id);
+
+    boolean batchZone(long serviceId, long[] crmIds);
+
+    boolean batchDisable(long[] crmIds);
+
 }

+ 76 - 2
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBCrmServiceImpl.java

@@ -5,9 +5,12 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.boot.api.exception.ApiException;
 import com.qmth.sop.business.bean.params.ServiceScopeParam;
 import com.qmth.sop.business.bean.result.CrmServiceResult;
 import com.qmth.sop.business.bean.result.CrmSubTotalResult;
+import com.qmth.sop.business.bean.result.TBCrmResult;
+import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.TBCrm;
 import com.qmth.sop.business.entity.TBService;
 import com.qmth.sop.business.mapper.TBCrmMapper;
@@ -15,15 +18,18 @@ import com.qmth.sop.business.service.TBCrmService;
 import com.qmth.sop.business.service.TBServiceService;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.ExceptionResultEnum;
+import com.qmth.sop.common.enums.FieldUniqueEnum;
 import com.qmth.sop.common.enums.ProductTypeEnum;
 import com.qmth.sop.common.enums.ServiceStatusEnum;
+import com.qmth.sop.common.util.ResultUtil;
+import com.qmth.sop.common.util.ServletUtil;
 import org.apache.commons.collections4.CollectionUtils;
+import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -125,4 +131,72 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
         crmSubTotalResult.setUnbindCrmCount(unbindCrmCount);
         return crmSubTotalResult;
     }
+
+    @Override
+    public IPage<TBCrmResult> query(IPage<Map> iPage, Long serviceId, Long leadId, Long crmUserId, ProductTypeEnum type, String custom, String crmNo, Long startTime, Long endTime) {
+        return this.baseMapper.query(iPage ,serviceId,leadId,crmUserId,Objects.nonNull(type)?type.name():null,custom,crmNo,startTime,endTime);
+    }
+
+
+	/**
+	 * 新增修改派单信息表
+	 *
+	 * @param tBCrm
+	 */
+	@Override
+	@Transactional
+	public Boolean saveTBCrm(TBCrm tBCrm) {
+		try {
+			SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+			if (Objects.isNull(tBCrm.getId())) {// 新增
+				tBCrm.insertInfo(sysUser.getId());
+			} else { // 修改
+				tBCrm.updateInfo(sysUser.getId());
+			}
+			return saveOrUpdate(tBCrm);
+		} catch (Exception e) {
+			if (e instanceof DuplicateKeyException) {
+				String errorColumn = e.getCause().toString();
+				String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
+				throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
+			} else if (e instanceof ApiException) {
+				ResultUtil.error((ApiException) e, e.getMessage());
+			} else {
+				ResultUtil.error(e.getMessage());
+			}
+		}
+		return null;
+
+	}
+
+	/**
+	 * 删除派单信息表
+	 *
+	 * @param id
+	 */
+	@Override
+	@Transactional
+	public Boolean delete(Long id) {
+		return this.removeById(id);
+	}
+
+    @Override
+    @Transactional
+    public boolean batchZone(long serviceId, long[] crmIds) {
+        List<Long> crmIdList = Arrays.stream(crmIds).boxed().collect(Collectors.toList());
+        List<TBCrm> tbCrmList = this.listByIds(crmIdList);
+        tbCrmList.forEach(e -> e.setServiceId(serviceId));
+        return this.updateBatchById(tbCrmList);
+    }
+
+    @Override
+    @Transactional
+    public boolean batchDisable(long[] crmIds) {
+        //批量修改
+        List<Long> crmIdList = Arrays.stream(crmIds).boxed().collect(Collectors.toList());
+        List<TBCrm> tbCrmList = this.listByIds(crmIdList);
+        tbCrmList.forEach(e -> e.setEnable(false));
+        return this.updateBatchById(tbCrmList);
+    }
+
 }

+ 12 - 0
sop-business/src/main/resources/db/log/shudonghui_update_log.sql

@@ -188,4 +188,16 @@ INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (1031, '质量问题反馈', '/api/admin/tb/quality/problem/apply/save', 'URL', 21, 1, 'AUTH', NULL, 1, 1, 0);
 UPDATE `sys_privilege` SET `name` = '作废', `url` = 'Cancel', `type` = 'BUTTON', `parent_id` = 21, `sequence` = 1, `property` = 'AUTH', `related` = '1029', `enable` = 1, `default_auth` = 0, `front_display` = 1 WHERE `id` = 128;
 UPDATE `sys_privilege` SET `name` = '查询', `url` = 'Select', `type` = 'BUTTON', `parent_id` = 21, `sequence` = 2, `property` = 'AUTH', `related` = '1030', `enable` = 1, `default_auth` = 0, `front_display` = 1 WHERE `id` = 130;
+-------------------------------
+-------------------------------
+---2023.8.15 派单管理
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (1032, '派单管理', '/api/admin/tb/crm/batchDisable', 'URL', 50, 1, 'AUTH', NULL, 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (1033, '派单管理', '/api/admin/tb/crm/batchZone', 'URL', 50, 2, 'AUTH', NULL, 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (1034, '派单管理', '/api/admin/tb/crm/countWaitZone', 'URL', 50, 3, 'AUTH', NULL, 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (1035, '派单管理', '/api/admin/tb/crm/delete', 'URL', 50, 4, 'AUTH', NULL, 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (1036, '派单管理', '/api/admin/tb/crm/get', 'URL', 50, 5, 'AUTH', NULL, 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (1037, '派单管理', '/api/admin/tb/crm/query', 'URL', 50, 6, 'AUTH', NULL, 1, 1, 0);
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (1038, '派单管理', '/api/admin/tb/crm/save', 'URL', 50, 7, 'AUTH', NULL, 1, 1, 0);
+UPDATE `sys_privilege` SET `name` = '派单管理', `url` = 'crm', `type` = 'MENU', `parent_id` = 50, `sequence` = 1, `property` = '1032, 1033,1035,1036,1037,1038', `related` = NULL, `enable` = 1, `default_auth` = 0, `front_display` = 1 WHERE `id` = 51;
+UPDATE `sys_privilege` SET `name` = '统计查询', `url` = 'crmCount', `type` = 'MENU', `parent_id` = 50, `sequence` = 2, `property` = '1034', `related` = NULL, `enable` = 1, `default_auth` = 0, `front_display` = 1 WHERE `id` = 52;
 -------------------------------

+ 56 - 0
sop-business/src/main/resources/mapper/TBCrmMapper.xml

@@ -129,4 +129,60 @@
             </if>
         </where>
     </select>
+
+
+    <select id="query" resultType="com.qmth.sop.business.bean.result.TBCrmResult">
+        SELECT
+        a.*,
+        tbs.name service,
+        cru.real_name crm_user_name,
+        sc.NAME custom,
+        sc.type custom_type,
+        p.name product,
+        lu.real_name leadName,
+        cu.real_name createName
+        FROM
+        t_b_crm a
+        LEFT JOIN sys_user cru ON cru.id = a.crm_user_id
+        LEFT JOIN sys_user lu ON lu.id = a.lead_id
+        LEFT JOIN sys_user cu ON cu.id = a.create_id
+        LEFT JOIN t_b_product p ON p.id = a.product_id
+        LEFT JOIN t_b_service tbs ON a.service_id = tbs.id
+        LEFT JOIN sys_custom sc ON sc.id = a.custom_id
+        <where>
+            and a.enable=1
+            <if test="serviceId != null and serviceId != ''">
+                and a.service_id = #{serviceId}
+            </if>
+            <if test="leadId != null and leadId != ''">
+                and a.lead_id = #{leadId}
+            </if>
+            <if test="crmUserId != null and crmUserId != ''">
+                and a.crm_user_id = #{crmUserId}
+            </if>
+            <if test="type != null and type != ''">
+                and sc.type = #{type}
+            </if>
+            <if test="custom != null and custom != ''">
+                and sc.name like concat('%', #{custom} , '%')
+            </if>
+            <if test="crmNo != null and crmNo != ''">
+                and a.crm_no like concat('%', #{crmNo} , '%')
+            </if>
+            <if test="startTime != null and startTime != '' ">
+                <![CDATA[
+               and a.create_time >= #{startTime}
+               ]]>
+            </if>
+            <if test="endTime != null and endTime != ''">
+                <![CDATA[
+                and a.create_time <= #{endTime}
+                ]]>
+            </if>
+        </where>
+
+
+        ORDER BY
+        a.create_time DESC
+    </select>
 </mapper>

+ 1 - 0
sop-common/src/main/java/com/qmth/sop/common/contant/SystemConstant.java

@@ -147,6 +147,7 @@ public class SystemConstant {
     public static final String PREFIX_URL_VIOLATION_DETAIL = "/admin/tb/violation/detail";
     public static final String PREFIX_URL_DING = "/admin/tb/ding";
     public static final String PREFIX_URL_QUALITY_PROBLEM_APPLY= "/admin/tb/quality/problem/apply";
+    public static final String PREFIX_URL_CRM= "/admin/tb/crm";
 
     /**
      * 缓存配置

+ 106 - 13
sop-server/src/main/java/com/qmth/sop/server/api/TBCrmController.java

@@ -1,25 +1,118 @@
 package com.qmth.sop.server.api;
 
-
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmth.boot.api.annotation.Aac;
+import com.qmth.boot.api.annotation.BOOL;
 import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.sop.business.bean.result.TBCrmResult;
+import com.qmth.sop.business.entity.TBCrm;
+import com.qmth.sop.business.service.TBCrmService;
 import com.qmth.sop.common.contant.SystemConstant;
-import io.swagger.annotations.Api;
-import org.springframework.web.bind.annotation.RequestMapping;
+import com.qmth.sop.common.enums.ProductTypeEnum;
+import com.qmth.sop.common.util.Result;
+import com.qmth.sop.common.util.ResultUtil;
+import io.swagger.annotations.*;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
 
-import org.springframework.web.bind.annotation.RestController;
+import javax.annotation.Resource;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
 
 /**
- * <p>
- * 派单信息表 前端控制器
- * </p>
+ * 派单信息表 控制器
  *
- * @author wangliang
- * @since 2023-08-01
+ * @author: shudonghui
+ * @date: 2023-08-14 15:55:18
+ * @version: 1.0
+ * @email: shudonghui@qmth.com.cn
+ * @Company: www.qmth.com.cn
  */
-
-@Api(tags = "派单管理前端控制器")
+@Api(tags = "派单信息表 Controller")
 @RestController
-@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_SERVICE_CRM)
+@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_CRM)
+@Validated
 public class TBCrmController {
 
-}
+
+    @Resource
+    TBCrmService tBCrmService;
+
+    
+    @ApiOperation(value = "派单信息表查询接口")
+    @RequestMapping(value = "/query", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "派单信息表查询结果", response = TBCrmResult.class)})
+    public Result query(
+            @ApiParam(value = "服务单元", required = false) @RequestParam(required = false) Long serviceId,
+            @ApiParam(value = "大区经理", required = false) @RequestParam(required = false) Long leadId,
+            @ApiParam(value = "派单人", required = false) @RequestParam(required = false) Long crmUserId,
+            @ApiParam(value = "客户类型", required = false) @RequestParam(required = false) ProductTypeEnum type,
+            @ApiParam(value = "客户名称(模糊查询)", required = false) @RequestParam(required = false) String custom,
+            @ApiParam(value = "项目单号(模糊查询) ", required = false) @RequestParam(required = false) String crmNo,
+            @ApiParam(value = "派单时间开始", required = false) @RequestParam(required = false) Long startTime,
+            @ApiParam(value = "派单时间结束", required = false) @RequestParam(required = false) Long endTime,
+            @ApiParam(value = "分页页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
+            @ApiParam(value = "分页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
+        IPage<TBCrmResult> resultIPage = tBCrmService.query(new Page<>(pageNumber, pageSize), serviceId,leadId,crmUserId,type,custom,crmNo,startTime,endTime);
+
+        return ResultUtil.ok(resultIPage);
+    }
+
+    
+    @ApiOperation(value = "派单信息表新增修改接口")
+    @RequestMapping(value = "/save", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result save(@ApiParam(value = "派单信息表信息", required = true) @RequestBody(required = true) TBCrm tBCrm) {
+        return ResultUtil.ok(tBCrmService.saveTBCrm(tBCrm));
+    }
+
+
+    
+    @ApiOperation(value = "派单信息表删除接口")
+    @RequestMapping(value = "/delete", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result delete(@ApiParam(value = "派单信息表id", required = true) @RequestParam(required = true) long id) {
+        return ResultUtil.ok(tBCrmService.delete(id));
+    }
+
+
+    
+    @ApiOperation(value = "派单信息表获取单个接口")
+    @RequestMapping(value = "/get", method = RequestMethod.GET)
+    @ApiResponses({@ApiResponse(code = 200, message = "派单信息表信息", response = TBCrm.class)})
+    public Result get(@ApiParam(value = "派单信息表id", required = true) @RequestParam long id) {
+        return ResultUtil.ok(tBCrmService.getById(id));
+    }
+
+    //批量划定服务单元
+    
+    @ApiOperation(value = "批量划定服务单元接口")
+    @RequestMapping(value = "/batchZone", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result batchZone(@ApiParam(value = "服务单元id", required = true) @RequestParam(required = true) long serviceId,
+                            @ApiParam(value = "派单信息表id", required = true) @RequestParam(required = true) long[] crmIds) {
+        return ResultUtil.ok(tBCrmService.batchZone(serviceId, crmIds));
+    }
+
+    //批量禁用
+    
+    @ApiOperation(value = "批量禁用接口")
+    @RequestMapping(value = "/batchDisable", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result batchDisable(@ApiParam(value = "派单信息表id", required = true) @RequestParam(required = true) long[] crmIds) {
+        return ResultUtil.ok(tBCrmService.batchDisable(crmIds));
+    }
+
+    //统计待划定数量
+    
+    @ApiOperation(value = "统计待划定数量接口")
+    @RequestMapping(value = "/countWaitZone", method = RequestMethod.GET)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result countWaitZone() {
+        return ResultUtil.ok(tBCrmService.count(new QueryWrapper<TBCrm>().lambda().isNull(TBCrm::getServiceId)));
+    }
+
+
+}