Selaa lähdekoodia

报表模块修改

ysm 11 kuukautta sitten
vanhempi
commit
65c4d9d0e7

+ 7 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/vo/DepartmentVO.java

@@ -23,4 +23,11 @@ public class DepartmentVO {
     private List<String> otherManagerIds;
     private Integer ddDeptid;
     private Integer pushToSap;
+
+    private Integer customertotal;//客户总量
+    private Integer customerDeal;//客户成交量
+    private Double dealRate;//客户成交量率
+    private Integer num;//客户数量
+    private Integer saleNum;//交易客户数量
+    private String departmentName;
 }

+ 5 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/mapper/DepartmentMapper.java

@@ -2,6 +2,7 @@ package com.management.platform.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.management.platform.entity.Department;
+import com.management.platform.entity.vo.DepartmentVO;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Update;
 
@@ -31,4 +32,8 @@ public interface DepartmentMapper extends BaseMapper<Department> {
 
     @Update("update department set superior_id = null where department_id = #{departmentId}")
     void updateNullSuperior(Integer departmentId);
+
+    List<DepartmentVO> getCustomerTotalCount(String startDate, String endDate, Integer departmentId, Integer companyId);
+
+    List<DepartmentVO> getCustomerTransferRate(String startDate, String endDate, Integer departmentId, Integer companyId);
 }

+ 22 - 4
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/ContactsServiceImpl.java

@@ -115,8 +115,8 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
 
         LambdaQueryWrapper<Contacts> lqw_contacts = new LambdaQueryWrapper<>();
         lqw_contacts.eq(Contacts::getPhone,contacts.getPhone());
-        Contacts selectedOne = contactsMapper.selectOne(lqw_contacts);
-        if (selectedOne != null) {
+        List<Contacts> list = contactsMapper.selectList(lqw_contacts);
+        if (!list.isEmpty()) {
             httpRespMsg.setError("已存在该联系人,手机号重复!");
             return httpRespMsg;
         }
@@ -550,7 +550,7 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
                                 contacts.setCustomId(custom.getId());
                             }
                              else {
-                                msg.setError("负责人["+customerName+"]在系统中不存在");
+                                msg.setError("客户["+customerName+"]在系统中不存在");
                                 return msg;
                             }
                         }
@@ -577,7 +577,8 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
                             if (first.isPresent()) {
                                 contacts.setOwnerId(first.get().getId());
                             } else {
-                                throw new Exception("["+userName+"]在系统中不存在");
+                                msg.setError("负责人["+userName+"]在系统中不存在");
+                                return msg;
                             }
                         }
                     }else{
@@ -591,6 +592,23 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
             }
 
             if(importContactsList.size()>0){
+                LambdaQueryWrapper<Contacts> lqw_contacts = new LambdaQueryWrapper<>();
+                for (Contacts contacts : importContactsList) {
+                    lqw_contacts.eq(Contacts::getPhone,contacts.getPhone());
+                    List<Contacts> list = contactsMapper.selectList(lqw_contacts);
+                    if (!list.isEmpty()) {
+                        msg.setError("手机号:"+contacts.getPhone()+"重复");
+                        return msg;
+                    }
+                    if (contacts.getName()==null||StringUtils.isEmpty(contacts.getName())){
+                        msg.setError("请确保联系人名称不为空");
+                        return msg;
+                    }
+                    if (contacts.getCustomId()==null){
+                        msg.setError("请确保客户名称不为空");
+                        return msg;
+                    }
+                }
                 if(!saveOrUpdateBatch(importContactsList)){
                     msg.setError("验证失败");
                     return msg;

+ 64 - 19
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/CustomServiceImpl.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.management.platform.entity.*;
+import com.management.platform.entity.vo.DepartmentVO;
 import com.management.platform.entity.vo.UserVO;
 import com.management.platform.mapper.*;
 import com.management.platform.service.CustomService;
@@ -69,6 +70,9 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
     @Autowired
     private UploadFileMapper uploadFileMapper;
 
+    @Autowired
+    private DepartmentMapper departmentMapper;
+
 
     @Resource
     private HttpServletRequest request;
@@ -441,40 +445,81 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
 
     @Override
     public HttpRespMsg getCustomerTotalCount(String startDate, String endDate, String userId, Integer departmentId, Integer exportType, HttpServletRequest request) {
+        HttpRespMsg msg = new HttpRespMsg();
         User user = userMapper.selectById(request.getHeader("token"));
         Integer companyId = user.getCompanyId();
-        List<UserVO> userVoList=userMapper.getCustomerTotalCount(startDate,endDate,userId,companyId);
-        if (userVoList!=null&&!userVoList.isEmpty()){
-            for (UserVO userVO : userVoList) {
-                if (userVO.getCustomertotal()==0){
-                    userVO.setDealRate((double) 0);
-                }else {
-                    userVO.setDealRate((double) (userVO.getCustomerDeal()/userVO.getCustomertotal()));
+        if (exportType==1){//员工
+            List<UserVO> userVoList=userMapper.getCustomerTotalCount(startDate,endDate,userId,companyId);
+            if (userVoList!=null&&!userVoList.isEmpty()){
+                for (UserVO userVO : userVoList) {
+                    if (userVO.getCustomertotal()==0){
+                        userVO.setDealRate((double) 0);
+                    }else {
+                        double v = ((double) userVO.getCustomerDeal() / userVO.getCustomertotal());
+                        String formattedValue = String.format("%.2f", v);
+                        userVO.setDealRate(Double.parseDouble(formattedValue));
+                    }
+                }
+            }
+            msg.setData(userVoList);
+        }else {
+            List<DepartmentVO> departmentVoList=departmentMapper.getCustomerTotalCount(startDate,endDate,departmentId,companyId);
+            if (departmentVoList!=null&&!departmentVoList.isEmpty()){
+                for (DepartmentVO departmentVO : departmentVoList) {
+                    if (departmentVO.getCustomertotal()==0){
+                        departmentVO.setDealRate((double)0);
+                    }else {
+                        double v=((double) departmentVO.getCustomerDeal() /departmentVO.getCustomertotal());
+                        String formattedValue = String.format("%.2f", v);
+                        departmentVO.setDealRate(Double.parseDouble(formattedValue));
+                    }
                 }
             }
+            msg.setData(departmentVoList);
         }
-        HttpRespMsg msg = new HttpRespMsg();
-        msg.setData(userVoList);
         return msg;
     }
 
     @Override
     public HttpRespMsg getCustomerTransferRate(String startDate, String endDate, String userId, Integer departmentId, Integer exportType, HttpServletRequest request) {
+        HttpRespMsg msg = new HttpRespMsg();
+
         User user = userMapper.selectById(request.getHeader("token"));
         Integer companyId = user.getCompanyId();
-        List<UserVO> userVoList=userMapper.getCustomerTransferRate(startDate,endDate,userId,companyId);
-        if (userVoList!=null&&!userVoList.isEmpty()){
-            for (UserVO userVO : userVoList) {
-                if (userVO.getNum()==0){
-                    userVO.setDealRate((double) 0);
-                }else {
-                    double v = (double) userVO.getSaleNum() / userVO.getNum();
-                    userVO.setDealRate(v);
+
+        if (exportType==1) {//员工
+            List<UserVO> userVoList=userMapper.getCustomerTransferRate(startDate,endDate,userId,companyId);
+            if (userVoList!=null&&!userVoList.isEmpty()){
+                for (UserVO userVO : userVoList) {
+                    if (userVO.getNum()==0){
+                        userVO.setDealRate((double) 0);
+                    }else {
+                        double v = (double) userVO.getSaleNum() / userVO.getNum();
+                        String formattedValue = String.format("%.2f", v);
+                        userVO.setDealRate(Double.parseDouble(formattedValue));
+                        userVO.setDealRate(v);
+                    }
                 }
             }
+            msg.setData(userVoList);
         }
-        HttpRespMsg msg = new HttpRespMsg();
-        msg.setData(userVoList);
+        else {//部门
+            List<DepartmentVO> departmentVoList=departmentMapper.getCustomerTransferRate(startDate,endDate,departmentId,companyId);
+            if (departmentVoList!=null&&!departmentVoList.isEmpty()){
+                for (DepartmentVO departmentVO : departmentVoList) {
+                    if (departmentVO.getNum()==0){
+                        departmentVO.setDealRate((double)0);
+                    }else {
+                        double v = (double) departmentVO.getSaleNum() / departmentVO.getNum();
+                        String formattedValue = String.format("%.2f", v);
+                        departmentVO.setDealRate(Double.parseDouble(formattedValue));
+                    }
+                }
+            }
+            msg.setData(departmentVoList);
+        }
+
+
         return msg;
 
     }

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1445 - 1383
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java


+ 37 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/DepartmentMapper.xml

@@ -118,4 +118,41 @@
         GROUP BY b.project_id, a.department_id
         having IFNULL(SUM(b.custom_data),0) > 0
     </select>
+    <select id="getCustomerTotalCount" resultType="com.management.platform.entity.vo.DepartmentVO">
+        select count(*) as customertotal ,
+        sum(case when c.close_deal=1 then 1 else 0 end) as customerDeal ,
+        u.department_id as id,d.department_name as departmentName
+        from custom c
+        left join user u on c.incharger_id=u.id
+        left join department d on d.department_id=u.department_id
+        <where>
+            1=1 AND u.department_id IS NOT NULL and c.company_id=#{companyId}
+
+            <if test="startDate !=null and startDate !='' and endDate !=null and endDate !=''">
+                AND  c.create_time BETWEEN #{startDate} AND #{endDate}
+            </if>
+            <if test="departmentId !=null ">
+                AND  u.department_id=#{departmentId}
+            </if>
+        </where>
+        group by u.department_id
+    </select>
+    <select id="getCustomerTransferRate" resultType="com.management.platform.entity.vo.DepartmentVO">
+        select count(distinct c.id) as num, count(distinct s.custom_id) as saleNum,
+            u.department_id as id,d.department_name as departmentName
+        from  custom c
+        left join sales_order s on c.id=s.custom_id
+        INNER JOIN user u on u.id=c.incharger_id
+        left join department d on d.department_id=u.department_id
+        <where>
+            1=1 AND u.department_id IS NOT NULL and c.company_id=#{companyId}
+            <if test="startDate !=null and startDate !='' and endDate !=null and endDate !=''">
+                AND  c.create_time BETWEEN #{startDate} AND #{endDate}
+            </if>
+            <if test="departmentId !=null ">
+                AND  u.department_id=#{departmentId}
+            </if>
+        </where>
+        group by  u.department_id
+    </select>
 </mapper>

+ 3 - 2
fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/UserMapper.xml

@@ -285,7 +285,7 @@
             from custom c
             left join user u on c.incharger_id=u.id
         <where>
-            1=1 and c.company_id=#{companyId}
+            1=1 and c.incharger_id is not null and c.company_id=#{companyId}
 
             <if test="startDate !=null and startDate !='' and endDate !=null and endDate !=''">
                 AND  c.create_time BETWEEN #{startDate} AND #{endDate}
@@ -293,6 +293,7 @@
             <if test="userId !=null and userId!=''">
                 AND  c.incharger_id=#{userId}
             </if>
+
         </where>
             group by c.incharger_id
 
@@ -303,7 +304,7 @@
                   left join sales_order s on c.id=s.custom_id
                   INNER JOIN user u on u.id=c.incharger_id
         <where>
-            1=1 and c.company_id=#{companyId}
+            1=1 and c.incharger_id is not null  and c.company_id=#{companyId}
             <if test="startDate !=null and startDate !='' and endDate !=null and endDate !=''">
                 AND  c.create_time BETWEEN #{startDate} AND #{endDate}
             </if>