Ver código fonte

Merge branch 'master' of http://47.100.37.243:10191/wutt/manHourHousekeeper

Min 10 meses atrás
pai
commit
efa98261a1
14 arquivos alterados com 617 adições e 390 exclusões
  1. 274 211
      fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/customer/component/information.vue
  2. 15 4
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/BusinessOpportunityController.java
  3. 5 5
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/CustomController.java
  4. 4 0
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/Custom.java
  5. 1 0
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/dto/TaskDto.java
  6. 2 0
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/mapper/ActionLogMapper.java
  7. 6 0
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/mapper/BusinessOpportunityMapper.java
  8. 1 0
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/BusinessOpportunityService.java
  9. 2 1
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/BusinessOpportunityServiceImpl.java
  10. 23 1
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/ContactsServiceImpl.java
  11. 157 114
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/CustomServiceImpl.java
  12. 10 1
      fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/TaskServiceImpl.java
  13. 27 0
      fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/BusinessOpportunityMapper.xml
  14. 90 53
      fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/CustomMapper.xml

+ 274 - 211
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/customer/component/information.vue

@@ -1,270 +1,333 @@
 <template>
-    <div class="information pl-4 pr-4 pt-3 pb-3">
-        <div class="flex justify-between">
-            <div class="title">基本信息</div>
-            <div>
-                <el-button type="primary" @click="claimCustomer()" v-if="!information.inchargerName">认领</el-button>
-                <el-button type="primary" @click="transferCli()">转移</el-button>
-                <el-button type="primary" v-permission="['customerEdit']" @click="editCustomer()">编辑</el-button>
-            </div>
+  <div class="information pl-4 pr-4 pt-3 pb-3">
+    <div class="flex justify-between">
+      <div class="title">基本信息</div>
+      <div>
+        <el-button type="primary" @click="claimCustomer()" v-if="!information.inchargerName"
+          >认领</el-button
+        >
+        <el-button type="primary" @click="transferCli()">转移</el-button>
+        <el-button type="primary" v-permission="['customerEdit']" @click="editCustomer()"
+          >编辑</el-button
+        >
+      </div>
+    </div>
+    <div class="form flex flex-wrap justify-between">
+      <div class="formItem flex pt-2 pb-1">
+        <div class="w-20 text-right text-gray-500">客户名称:</div>
+        <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1" v-ellipsis-tooltip>
+          {{ information.customName }}
+        </div>
+      </div>
+      <div class="formItem flex pt-2 pb-1">
+        <div class="w-22 text-right text-gray-500">客户来源:</div>
+        <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1">
+          {{ information.customSourceValue }}
+        </div>
+      </div>
+      <div class="formItem flex pt-2 pb-1">
+        <div class="w-22 text-right text-gray-500">电话号码:</div>
+        <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1" v-ellipsis-tooltip>
+          {{ information.telPhone }}
+        </div>
+      </div>
+      <div class="formItem flex pt-2 pb-1">
+        <div class="w-22 text-right text-gray-500">邮箱:</div>
+        <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1" v-ellipsis-tooltip>
+          {{ information.email }}
+        </div>
+      </div>
+      <div class="formItem flex pt-2 pb-1">
+        <div class="w-22 text-right text-gray-500">客户行业:</div>
+        <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1">
+          {{ information.customerIndustryValue }}
+        </div>
+      </div>
+      <div class="formItem flex pt-2 pb-1">
+        <div class="w-22 text-right text-gray-500">客户级别:</div>
+        <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1">
+          {{ information.customerLevelValue }}
         </div>
-        <div class="form flex flex-wrap justify-between">
-            <div class="formItem flex pt-2 pb-1">
-                <div class="w-20 text-right text-gray-500">客户名称:</div>
-                <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1" v-ellipsis-tooltip>{{
-                    information.customName }}</div>
-            </div>
-            <div class="formItem flex pt-2 pb-1">
-                <div class="w-22 text-right text-gray-500">客户来源:</div>
-                <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1">{{
-                    information.customSourceValue }}
-                </div>
-            </div>
-            <div class="formItem flex pt-2 pb-1">
-                <div class="w-22 text-right text-gray-500">电话号码:</div>
-                <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1" v-ellipsis-tooltip>{{
-                    information.companyPhone }}
-                </div>
-            </div>
-            <div class="formItem flex pt-2 pb-1">
-                <div class="w-22 text-right text-gray-500">邮箱:</div>
-                <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1" v-ellipsis-tooltip>{{
-                    information.email }}</div>
-            </div>
-            <div class="formItem flex pt-2 pb-1">
-                <div class="w-22 text-right text-gray-500">客户行业:</div>
-                <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1">{{
-                    information.customerIndustryValue }}</div>
-            </div>
-            <div class="formItem flex pt-2 pb-1">
-                <div class="w-22 text-right text-gray-500">客户级别:</div>
-                <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1">{{
-                    information.customerLevelValue
-                }}</div>
-            </div>
-            <div class="formItem flex pt-2 pb-1">
-                <div class="w-22 text-right text-gray-500">客户地址:</div>
-                <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1">{{ information.address }}</div>
-            </div>
-            <div class="formItem flex pt-2 pb-1">
-                <div class="w-22 text-right text-gray-500">负责人:</div>
-                <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1">{{ information.inchargerName }}
-                </div>
-            </div>
-            <div class="formItem flex pt-2 pb-1">
-                <div class="w-22 text-right text-gray-500">创建人:</div>
-                <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1">{{ information.creatorName }}
-                </div>
-            </div>
-            <div class="formItem flex pt-2 pb-1">
-                <div class="w-22 text-right text-gray-500">创建时间:</div>
-                <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1">{{ information.newCreateTime }}
-                </div>
-            </div>
-            <div class="formItem flex pt-2 pb-1" style="width: 100%;">
-                <div class="w-22 text-right text-gray-500">备注:</div>
-                <div class="flex-1 ml-1 text " v-ellipsis-tooltip>
-                    {{ information.customDesc }}
-                </div>
-            </div>
+      </div>
+      <div class="formItem flex pt-2 pb-1">
+        <div class="w-22 text-right text-gray-500">客户地址:</div>
+        <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1">
+          {{ information.address }}
         </div>
+      </div>
+      <div class="formItem flex pt-2 pb-1">
+        <div class="w-22 text-right text-gray-500">负责人:</div>
+        <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1">
+          {{ information.inchargerName }}
+        </div>
+      </div>
+      <div class="formItem flex pt-2 pb-1">
+        <div class="w-22 text-right text-gray-500">创建人:</div>
+        <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1">
+          {{ information.creatorName }}
+        </div>
+      </div>
+      <div class="formItem flex pt-2 pb-1">
+        <div class="w-22 text-right text-gray-500">创建时间:</div>
+        <div class="flex-1 overflow-hidden text-ellipsis whitespace-nowrap ml-1">
+          {{ information.newCreateTime }}
+        </div>
+      </div>
+      <div class="formItem flex pt-2 pb-1" style="width: 100%">
+        <div class="w-22 text-right text-gray-500">备注:</div>
+        <div class="flex-1 ml-1 text" v-ellipsis-tooltip>
+          {{ information.customDesc }}
+        </div>
+      </div>
+    </div>
 
-        <!-- 弹窗 -->
-        <el-dialog v-model="allVisible.transferCustomerVisible" width="600" :show-close="false" top="10vh">
-            <template #header="{ close, titleId, titleClass }">
-                <div class="flex justify-between items-center border-b pb-3 dialog-header">
-                    <h4 :id="titleId">{{ '转移客户' }}</h4>
-                    <div>
-                        <el-button type="primary" :loading="allLoading.transferCustomerLoading"
-                            @click="transferCustomer()">转移</el-button>
-                        <el-button @click="allVisible.transferCustomerVisible = false">取消</el-button>
-                    </div>
-                </div>
-            </template>
-            <div class="scroll-bar m-6">
-                <div class="flex mb-4">
-                    <div class="w-20 flex items-center justify-end pr-4">转移至:</div>
-                    <el-select v-model="transferValue" placeholder="请选择" class="flex1">
-                        <el-option v-for="item in transferOptions" :key="item.id" :label="item.name" :value="item.id" />
-                    </el-select>
-                </div>
-                <div class="pl-3 text-[#e94a4a]">转移后,将看不到此客户</div>
-            </div>
-        </el-dialog>
+    <!-- 弹窗 -->
+    <el-dialog
+      v-model="allVisible.transferCustomerVisible"
+      width="600"
+      :show-close="false"
+      top="10vh"
+    >
+      <template #header="{ close, titleId, titleClass }">
+        <div class="flex justify-between items-center border-b pb-3 dialog-header">
+          <h4 :id="titleId">{{ '转移客户' }}</h4>
+          <div>
+            <el-button
+              type="primary"
+              :loading="allLoading.transferCustomerLoading"
+              @click="transferCustomer()"
+              >转移</el-button
+            >
+            <el-button @click="allVisible.transferCustomerVisible = false">取消</el-button>
+          </div>
+        </div>
+      </template>
+      <div class="scroll-bar m-6">
+        <div class="flex mb-4">
+          <div class="w-20 flex items-center justify-end pr-4">转移至:</div>
+          <el-select v-model="transferValue" placeholder="请选择" class="flex1">
+            <el-option
+              v-for="item in transferOptions"
+              :key="item.id"
+              :label="item.name"
+              :value="item.id"
+            />
+          </el-select>
+        </div>
+        <div class="pl-3 text-[#e94a4a]">转移后,将看不到此客户</div>
+      </div>
+    </el-dialog>
 
-        <el-dialog v-model="allVisible.editCustomerVisible" width="1000" :show-close="false" top="10vh">
-            <template #header="{ close, titleId, titleClass }">
-                <div class="flex justify-between items-center border-b pb-3 dialog-header">
-                    <h4 :id="titleId">{{ '编辑客户' }}</h4>
-                    <div>
-                        <el-button type="primary" @click="saveCustomer()"
-                            :loading="allLoading.saveLading">保存</el-button>
-                        <el-button @click="closeVisible('editCustomerVisible')">取消</el-button>
-                    </div>
-                </div>
-            </template>
-            <div class="h-[60vh] overflow-y-auto scroll-bar pt-3" v-loading="allLoading.generateFormDataLoading">
-                <GenerateForm ref="generateForm" :data="generateFormData" :value="generateFormValue"
-                    :key="generateFormKey" />
-            </div>
-        </el-dialog>
-    </div>
+    <el-dialog v-model="allVisible.editCustomerVisible" width="1000" :show-close="false" top="10vh">
+      <template #header="{ close, titleId, titleClass }">
+        <div class="flex justify-between items-center border-b pb-3 dialog-header">
+          <h4 :id="titleId">{{ '编辑客户' }}</h4>
+          <div>
+            <el-button type="primary" @click="saveCustomer()" :loading="allLoading.saveLading"
+              >保存</el-button
+            >
+            <el-button @click="closeVisible('editCustomerVisible')">取消</el-button>
+          </div>
+        </div>
+      </template>
+      <div
+        class="h-[60vh] overflow-y-auto scroll-bar pt-3"
+        v-loading="allLoading.generateFormDataLoading"
+      >
+        <GenerateForm
+          ref="generateForm"
+          :data="generateFormData"
+          :value="generateFormValue"
+          :key="generateFormKey"
+        />
+      </div>
+    </el-dialog>
+  </div>
 </template>
 <script lang="ts" setup>
 import { confirmAction } from '@/utils/tools';
-import { ref, reactive, onMounted, onUnmounted, defineExpose, inject, watchEffect } from 'vue'
+import { ref, reactive, onMounted, onUnmounted, defineExpose, inject, watchEffect } from 'vue';
 import { GenerateForm } from '@zmjs/form-design';
-import { useStore } from '@/store/index'
+import { useStore } from '@/store/index';
 import { get, post } from '@/utils/request';
 import { GETPERSONNEL, URL_CLAIM, URL_EDITSAVE, URL_TEMPLALE } from '../api';
 import { formatDate } from '@/utils/times';
 
 const emits = defineEmits(['refreshData']);
-const { userInfo } = useStore()
+const { userInfo } = useStore();
 const props = defineProps<{
-    data: any
-}>()
+  data: any;
+}>();
 const generateFormData = ref({
-    config: {},
-    list: []
-}) // 自定义表单数据
-const generateFormValue = ref({})
-const generateForm = ref<typeof GenerateForm>()
-const generateFormKey = ref(1)
-const globalPopup = inject<GlobalPopup>('globalPopup')
-const information = ref<any>({})
-const transferValue = ref('')
-const transferOptions = ref<personnelInterface[]>([])
+  config: {},
+  list: []
+}); // 自定义表单数据
+const generateFormValue = ref({});
+const generateForm = ref<typeof GenerateForm>();
+const generateFormKey = ref(1);
+const globalPopup = inject<GlobalPopup>('globalPopup');
+const information = ref<any>({});
+const transferValue = ref('');
+const transferOptions = ref<personnelInterface[]>([]);
 
 const allLoading = reactive({
-    editBusinessLoading: false,
-    saveLading: false,
-    transferCustomerLoading: false,
-    saveContactLoading: false,
-    generateFormDataLoading: false
-})
+  editBusinessLoading: false,
+  saveLading: false,
+  transferCustomerLoading: false,
+  saveContactLoading: false,
+  generateFormDataLoading: false
+});
 const allVisible = reactive({
-    transferCustomerVisible: false,
-    editCustomerVisible: false
-})
+  transferCustomerVisible: false,
+  editCustomerVisible: false
+});
 
 function saveCustomer() {
-    generateForm.value?.getData().then((res: any) => {
-        allLoading.saveLading = true
-        let formVal = { ...generateFormValue.value, ...res }
-        delete formVal.createTime
-        post(URL_EDITSAVE, { ...formVal }).then((_res) => {
-            globalPopup?.showSuccess('操作成功')
-            closeVisible('editCustomerVisible')
-            emits('refreshData')
-        }).finally(() => {
-            allLoading.saveLading = false
+  generateForm.value
+    ?.getData()
+    .then((res: any) => {
+      allLoading.saveLading = true;
+      let formVal = { ...generateFormValue.value, ...res };
+      delete formVal.createTime;
+      post(URL_EDITSAVE, { ...formVal })
+        .then((_res) => {
+          globalPopup?.showSuccess('操作成功');
+          closeVisible('editCustomerVisible');
+          emits('refreshData');
         })
-    }).catch((_err: any) => {
-        console.log(_err)
-        globalPopup?.showError('请填写完整')
+        .finally(() => {
+          allLoading.saveLading = false;
+        });
     })
+    .catch((_err: any) => {
+      console.log(_err);
+      globalPopup?.showError('请填写完整');
+    });
 }
 
 function transferCli() {
-    transferValue.value
-    showVisible('transferCustomerVisible')
+  transferValue.value;
+  showVisible('transferCustomerVisible');
 }
 
 function transferCustomer() {
-    const ids = information.value?.id
-    const inchargerId = information.value?.inchargerName ? transferValue.value : userInfo.id
-    if (!inchargerId) {
-        globalPopup?.showWarning('请选择转移的人员')
-        return
-    }
-    allLoading.transferCustomerLoading = true
-    post(URL_CLAIM, { ids, inchargerId }).then((res) => {
-        if (res.code == 'ok') {
-            globalPopup?.showSuccess('操作成功')
-            allVisible.transferCustomerVisible = false
-            emits('refreshData')
-        }
-    }).finally(() => {
-        allLoading.transferCustomerLoading = false
+  const ids = information.value?.id;
+  const inchargerId = information.value?.inchargerName ? transferValue.value : userInfo.id;
+  if (!inchargerId) {
+    globalPopup?.showWarning('请选择转移的人员');
+    return;
+  }
+  allLoading.transferCustomerLoading = true;
+  post(URL_CLAIM, { ids, inchargerId })
+    .then((res) => {
+      if (res.code == 'ok') {
+        globalPopup?.showSuccess('操作成功');
+        allVisible.transferCustomerVisible = false;
+        emits('refreshData');
+      }
     })
+    .finally(() => {
+      allLoading.transferCustomerLoading = false;
+    });
 }
 
 function claimCustomer() {
-    confirmAction(`确定认领【${information.value.customName}】商机吗?`).then(() => {
-        transferCustomer()
-    })
+  confirmAction(`确定认领【${information.value.customName}】商机吗?`).then(() => {
+    transferCustomer();
+  });
 }
 
 function editCustomer() {
-    const { id, companyPhone, customName, inchargerId, createTime, customSourceId, customerIndustryId, customerLevelId, email, telPhone, customDesc } = information.value
-    const formVal = {
-        id, customName, inchargerId, customerIndustryId, customerLevelId, email, customSourceId,
-        createTime: formatDate(new Date(createTime)),
-        telPhone, companyPhone,
-        customDesc
-    }
-    generateFormValue.value = formVal
-    allLoading.generateFormDataLoading = true
-    showVisible('editCustomerVisible')
-    setTimeout(() => {
-        generateForm.value && generateForm.value?.reset()
-        generateFormKey.value++
-        allLoading.generateFormDataLoading = false
-    }, 500)
+  const {
+    id,
+    companyPhone,
+    customName,
+    inchargerId,
+    createTime,
+    customSourceId,
+    customerIndustryId,
+    customerLevelId,
+    email,
+    telPhone,
+    customDesc
+  } = information.value;
+  const formVal = {
+    id,
+    customName,
+    inchargerId,
+    customerIndustryId,
+    customerLevelId,
+    email,
+    customSourceId,
+    createTime: formatDate(new Date(createTime)),
+    telPhone,
+    companyPhone,
+    customDesc
+  };
+  generateFormValue.value = formVal;
+  allLoading.generateFormDataLoading = true;
+  showVisible('editCustomerVisible');
+  setTimeout(() => {
+    generateForm.value && generateForm.value?.reset();
+    generateFormKey.value++;
+    allLoading.generateFormDataLoading = false;
+  }, 500);
 }
 
 function showVisible(type: keyof typeof allVisible) {
-    allVisible[type] = true
+  allVisible[type] = true;
 }
 
 function closeVisible(type: keyof typeof allVisible) {
-    allVisible[type] = false
+  allVisible[type] = false;
 }
 
 async function getSystemField() {
-    const { data } = await post(GETPERSONNEL, {})
-    transferOptions.value = data.map((item: any) => {
-        const { id, name, phone, jobNumber } = item
-        return {
-            id, name, phone, jobNumber
-        }
-    })
-    const res = await get(URL_TEMPLALE)
-    generateFormData.value = JSON.parse(res.data[0].config)
+  const { data } = await post(GETPERSONNEL, {});
+  transferOptions.value = data.map((item: any) => {
+    const { id, name, phone, jobNumber } = item;
+    return {
+      id,
+      name,
+      phone,
+      jobNumber
+    };
+  });
+  const res = await get(URL_TEMPLALE);
+  generateFormData.value = JSON.parse(res.data[0].config);
 }
 
 watchEffect(() => {
-    const { data } = props
-    information.value = data
-})
+  const { data } = props;
+  information.value = data;
+});
 
 // 生命周期钩子
 onMounted(() => {
-    getSystemField()
+  getSystemField();
 });
 </script>
 <style scoped lang="scss">
 .information {
-    .title {
-        font-size: 18px;
-        color: #000
-    }
+  .title {
+    font-size: 18px;
+    color: #000;
+  }
 
-    .form {
-        .formItem {
-            width: 48%;
-        }
+  .form {
+    .formItem {
+      width: 48%;
+    }
 
-        .text {
-            display: -webkit-box;
-            /* Safari */
-            -webkit-line-clamp: 2;
-            /* number of lines to show */
-            -webkit-box-orient: vertical;
-            overflow: hidden;
-            line-height: 1.5;
-        }
+    .text {
+      display: -webkit-box;
+      /* Safari */
+      -webkit-line-clamp: 2;
+      /* number of lines to show */
+      -webkit-box-orient: vertical;
+      overflow: hidden;
+      line-height: 1.5;
     }
+  }
 }
-</style>
+</style>

+ 15 - 4
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/BusinessOpportunityController.java

@@ -54,17 +54,27 @@ public class BusinessOpportunityController {
     @Resource
     private BusinessOpportunityService bOservice;
     @Resource
+    private BusinessOpportunityMapper boMapper;
+    @Resource
     private BusinessOpportunityMapper businessOpportunityMapper;
 
     @RequestMapping("getAll")
     public Object getAll(HttpServletRequest request) {
         User user = userMapper.selectById(request.getHeader("Token"));
+        List<BusinessOpportunity> list = new ArrayList<>();
+        boolean isAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看全部商机");
+        boolean isNotAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看负责部门商机");
+        if (isAll) {
+            list = boMapper.getAllList(user.getCompanyId());
+        } else if (isNotAll) {
+            list = boMapper.getAllList1(user);
+        } else {
+            list = boMapper.getAllList2(user);
+        }
         HttpRespMsg msg = new HttpRespMsg();
-        msg.setMsg("操作成功");
-        msg.setData(
-                businessOpportunityMapper.selectList(new QueryWrapper<BusinessOpportunity>().eq("company_id", user.getCompanyId()))
-        );
+        msg.setData(list);
         return msg;
+
     }
 
 
@@ -214,6 +224,7 @@ public class BusinessOpportunityController {
             bOservice.insert(bo);
         }else {
             //修改
+            bo.setEditTime(new Date());
             bOservice.update(bo,user.getId());
 
         }

+ 5 - 5
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/CustomController.java

@@ -94,10 +94,10 @@ public class CustomController {
         return customService.getInfo(custom, request);
     }
 
-    @RequestMapping("getLog")
-    public HttpRespMsg getLog(Custom custom, HttpServletRequest request) {
-        return customService.getInfo(custom, request);
-    }
+//    @RequestMapping("getLog")
+//    public HttpRespMsg getLog(Custom custom, HttpServletRequest request) {
+//        return customService.getInfo(custom, request);
+//    }
 
     @RequestMapping("/importData")
     public HttpRespMsg importData(MultipartFile multipartFile){
@@ -173,7 +173,7 @@ public class CustomController {
             }
             dataList.add(item);
         }
-        String fileName="商机表导出_"+ System.currentTimeMillis();
+        String fileName="客户表导出_"+ System.currentTimeMillis();
         return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,fileName,dataList,path);
     }
 

+ 4 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/Custom.java

@@ -254,7 +254,11 @@ public class Custom extends Model<Custom> {
     private List<ActionLog> actionLogs;
     @TableField(exist = false)
     private List<Contacts> contactsList;
+    @TableField(exist = false)
+    private Integer isDesc;
 
+    @TableField(exist = false)
+    private List<Task> tasks;
 
     @Override
     protected Serializable pkVal() {

+ 1 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/dto/TaskDto.java

@@ -14,6 +14,7 @@ import java.time.LocalDate;
 @Accessors(chain = true)
 public class TaskDto extends Task {
     private Integer businessOpportunityId;
+    private Integer customerId;
     private Integer pageIndex;
     private Integer pageSize;
 

+ 2 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/mapper/ActionLogMapper.java

@@ -21,4 +21,6 @@ public interface ActionLogMapper extends BaseMapper<ActionLog> {
     List<ActionLog> selectByInfoList(Integer id);
     @Select("select a.*,u.`name` userName from action_log a left join `user` u on a.user_id = u.id where code = 'business' and item_id = #{id}")
     List<ActionLog> selectByInfoListBusiness(Integer id);
+    @Select("select a.*,u.`name` userName from action_log a left join `user` u on a.user_id = u.id where code = 'custom' and item_id = #{id}")
+    List<ActionLog> selectByInfoListCustom(Integer id);
 }

+ 6 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/mapper/BusinessOpportunityMapper.java

@@ -2,6 +2,7 @@ package com.management.platform.mapper;
 
 import com.management.platform.entity.BusinessOpportunity;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.management.platform.entity.User;
 import com.management.platform.util.HttpRespMsg;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.web.multipart.MultipartFile;
@@ -37,4 +38,9 @@ public interface BusinessOpportunityMapper extends BaseMapper<BusinessOpportunit
 
     List<Map<String, Object>> getDataStage(Integer companyId, String startDate, String endDate, String userId,@Param("list") List<String> targetUserIds);
 
+    List<BusinessOpportunity> getAllList(Integer companyId);
+
+    List<BusinessOpportunity> getAllList1(User user);
+
+    List<BusinessOpportunity> getAllList2(User user);
 }

+ 1 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/BusinessOpportunityService.java

@@ -67,4 +67,5 @@ public interface BusinessOpportunityService extends IService<BusinessOpportunity
     void saveReason(BusinessOpportunity bo, User user);
 
     void saveStage(BusinessOpportunity bo, User user);
+
 }

+ 2 - 1
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/BusinessOpportunityServiceImpl.java

@@ -640,10 +640,11 @@ public class BusinessOpportunityServiceImpl extends ServiceImpl<BusinessOpportun
 
     @Override
     public void saveStage(BusinessOpportunity bo, User user) {
-        bOMapper.update(bo, new UpdateWrapper<BusinessOpportunity>().eq("id", bo.getId()).set("Stage_Id", bo.getStageId()));
+        bOMapper.update(bo, new UpdateWrapper<BusinessOpportunity>().eq("id", bo.getId()).set("Stage_Id", bo.getStageId()).set("edit_time",new Date()));
         ActionLog al = new ActionLog();
         al.setCode("business");
         al.setName("推进了阶段至" + bo.getStageValue());
+        al.setCreatTime(new Date());
         al.setUserId(user.getId());
         al.setItemId(bo.getId());
         actionLogMapper.insert(al);

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

@@ -84,6 +84,8 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
 
     @Resource
     private StageMapper stageMapper;
+    @Resource
+    private ActionLogMapper logMapper;
 
     @Value(value = "${upload.path}")
     private String path;
@@ -127,7 +129,15 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
                 .setCreateTime(LocalDateTime.now())
                 .setCreatorId(user.getId());
         contactsMapper.insert(contacts);
-
+        if (contacts.getCustomId() != null){
+            ActionLog actionLog = new ActionLog();
+            actionLog.setCreatTime(new Date())
+            .setUserId(user.getId())
+            .setCode("custom")
+            .setName("新建了相关联系人")
+            .setItemId(contacts.getCustomId());
+            logMapper.insert(actionLog);
+        }
         ContactsLog contactsLog = new ContactsLog();
         contactsLog.setContactsId(contacts.getId())
                 .setOperateId(user.getId())
@@ -203,6 +213,18 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
         Integer companyId = user.getCompanyId();
         if (contacts == null || contacts.getId() == null) {
             msg.setError("关键信息为空");
+            return msg;
+        }
+        LambdaQueryWrapper<Contacts> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.ne(Contacts::getId,contacts.getId()).eq(Contacts::getCompanyId,companyId);
+        List<Contacts> list = contactsMapper.selectList(queryWrapper);
+        if (!list.isEmpty()){
+            for (Contacts c : list) {
+                if (StringUtils.isNotEmpty(c.getPhone())&&StringUtils.isNotEmpty(contacts.getPhone())&&c.getPhone().equals(contacts.getPhone())){
+                    msg.setError("联系人电话存在重复,请修改");
+                    return msg;
+                }
+            }
         }
         contactsMapper.updateById(contacts);
 

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

@@ -39,6 +39,7 @@ import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.net.URLEncoder;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -88,6 +89,9 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
     @Autowired
     private ContactsMapper contactsMapper;
 
+    @Autowired
+    private TaskMapper taskMapper;
+
     @Override
     public HttpRespMsg insertAndUpdate(Custom custom, HttpServletRequest request) {
         HttpRespMsg msg = new HttpRespMsg();
@@ -116,7 +120,7 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
             ActionLog actionLog = new ActionLog();
             actionLog.setCode("custom");
             actionLog.setCreatTime(new Date());
-            actionLog.setName("创建了客户");
+            actionLog.setName("编辑了客户");
             actionLog.setItemId(custom.getId());
             actionLog.setUserId(user.getId());
             actionLogMapper.insert(actionLog);
@@ -127,7 +131,7 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
                 return msg;
             }
             if (customMapper.selectCount(new QueryWrapper<Custom>().eq("tel_phone", custom.getTelPhone())) > 0) {
-//                msg.setError("电话号码重复了");
+                msg.setError("电话号码重复了");
                 return msg;
             }
 
@@ -140,19 +144,19 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
             custom.setCreateTime(new Date());
             custom.setCreatorId(user.getId());
             custom.setIsDelete(0);
+            customMapper.insert(custom);
             ActionLog actionLog = new ActionLog();
             actionLog.setCode("custom");
             actionLog.setCreatTime(new Date());
-            actionLog.setName("编辑了客户");
+            actionLog.setName("新建了客户");
             actionLog.setUserId(user.getId());
             actionLog.setItemId(custom.getId());
             actionLogMapper.insert(actionLog);
-            customMapper.insert(custom);
-            if (custom.getCustomName() != null && custom.getCustomName()!="" &&custom.getTelPhone() !="" &&custom.getTelPhone()!=null){
+            if (custom.getCustomName() != null && custom.getCustomName() != "" && custom.getTelPhone() != "" && custom.getTelPhone() != null) {
                 Contacts contacts = contactsMapper.selectOne(new QueryWrapper<Contacts>().eq("name", custom.getCustomName()).eq("phone", custom.getTelPhone()));
-                if (contacts != null){
+                if (contacts != null) {
                     contacts.setCustomId(custom.getId());
-                    contactsMapper.update(contacts,new UpdateWrapper<Contacts>().eq("id",contacts.getId()));
+                    contactsMapper.update(contacts, new UpdateWrapper<Contacts>().eq("id", contacts.getId()));
                 }
             }
         }
@@ -189,64 +193,97 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void getAndTransfer(Custom custom, User user) {
-        UpdateWrapper<Custom> updateWrapper = new UpdateWrapper<>();
-        updateWrapper.eq("id", custom.getId());
-        Custom custom1 = customMapper.selectById(custom.getId());
-        String inchargerId = custom1.getInchargerId();
-        if (inchargerId == null) {
-            //认领
-            ActionLog actionLog = new ActionLog();
-            actionLog.setCode("custom");
-            actionLog.setCreatTime(new Date());
-            actionLog.setName("认领了客户");
-            actionLog.setUserId(user.getId());
-            actionLog.setItemId(custom.getId());
-            actionLogMapper.insert(actionLog);
-        } else {
-            //转移
-            ActionLog actionLog = new ActionLog();
-            actionLog.setCode("custom");
-            actionLog.setCreatTime(new Date());
-            actionLog.setName("转移了客户");
-            actionLog.setUserId(user.getId());
-            actionLog.setItemId(custom.getId());
-            actionLogMapper.insert(actionLog);
+        String ids1 = custom.getIds();
+        List<Integer> ids = Arrays.stream(ids1.split(","))
+                .map(Integer::parseInt)
+                .collect(Collectors.toList());
+        for (Integer id : ids) {
+            System.out.println(id);
+            UpdateWrapper<Custom> updateWrapper = new UpdateWrapper<>();
+            updateWrapper.eq("id", id);
+//        updateWrapper.eq("id", custom.getId()).set("incharger_id",custom.getInchargerId());
+            String inchargerId = custom.getInchargerId();
+            if (inchargerId == null) {
+                //认领
+                ActionLog actionLog = new ActionLog();
+                actionLog.setCode("custom");
+                actionLog.setCreatTime(new Date());
+                actionLog.setName("认领了客户");
+                actionLog.setUserId(user.getId());
+                actionLog.setItemId(id);
+                actionLogMapper.insert(actionLog);
+            } else {
+                //转移
+                ActionLog actionLog = new ActionLog();
+                actionLog.setCode("custom");
+                actionLog.setCreatTime(new Date());
+                actionLog.setName("转移了客户");
+                actionLog.setUserId(user.getId());
+                actionLog.setItemId(id);
+                actionLogMapper.insert(actionLog);
+            }
+            customMapper.update(custom, updateWrapper);
         }
-        customMapper.update(custom, updateWrapper);
     }
 
     @Autowired
     private SalesOrderMapper salesOrderMapper;
+    @Autowired
+    private StageMapper stageMapper;
+
     @Override
     public HttpRespMsg getInfo(Custom custom, HttpServletRequest request) {
         Custom custom1 = customMapper.getInfo(custom.getId());
 
         // 附件列表
-        custom1.setFiles(uploadFileMapper.selectList(new QueryWrapper<UploadFile>().eq("code", "custom").eq("item_id",custom1.getId())));
+        custom1.setFiles(uploadFileMapper.selectByInfoList("custom", custom1.getId()));
         //商机列表
-        custom1.setBusinessOpportunitys(businessOpportunityMapper.selectList(new QueryWrapper<BusinessOpportunity>().eq("customer_id",custom1.getId())));
+        List<BusinessOpportunity> bos = businessOpportunityMapper.selectList(new QueryWrapper<BusinessOpportunity>().eq("customer_id", custom1.getId()));
+        if (bos.size() >0){
+            List<Integer> sIds = bos.stream().map(BusinessOpportunity::getStageId).distinct().collect(Collectors.toList());
+            List<Stage> stages = stageMapper.selectList(new QueryWrapper<Stage>().in("id", sIds));
+            Map<Integer, String> stageValue =  stages.stream()
+                    .collect(Collectors.toMap(Stage::getId, Stage::getName));
+            custom1.setBusinessOpportunitys(bos);
+            for (BusinessOpportunity bo : bos) {
+                bo.setCustomerName(custom1.getCustomName());
+                bo.setStageValue(stageValue.get(bo.getStageId()));
+            }
+            List<String> userIds = bos.stream()
+                    .flatMap(bo -> {
+                        List<String> ids = new ArrayList<>();
+                        ids.add(bo.getInchargerId());
+                        ids.add(bo.getCreatorId());
+                        return ids.stream();
+                    })
+                    .distinct() // 去重
+                    .collect(Collectors.toList());
+            if (userIds.size()>0){
+                List<User> users = userMapper.selectList(new QueryWrapper<User>().in("id", userIds));
+                Map<String, String> userIdToNameMap = users.stream()
+                        .collect(Collectors.toMap(User::getId, User::getName));
+                for (BusinessOpportunity bo : bos) {
+                    bo.setInchargerName(userIdToNameMap.get(bo.getInchargerId()));
+                    bo.setCreatorName(userIdToNameMap.get(bo.getCreatorId()));
+                }
+            }
+        }
+        custom1.setBusinessOpportunitys(bos);
         //操作记录
-        custom1.setActionLogs(actionLogMapper.selectList(new QueryWrapper<ActionLog>().eq("code","custom").eq("item_id",custom1.getId())));
-//        List<CustomItemContacts> contacts = customItemContactsMapper.selectList(new QueryWrapper<CustomItemContacts>().eq("contacts_id", custom1.getId()));
-//        List<Integer> ids = new ArrayList<>();
-//        for (CustomItemContacts contact : contacts) {
-//            ids.add(contact.getCustomId());
-//        }
-//        if (ids.size() > 0){
-//            List<Contacts> cs = contactsMapper.selectListByIds(ids);
-//            custom1.setContactsList(cs);
-//        }
+        List<ActionLog> actionLogs = actionLogMapper.selectByInfoListCustom(custom.getId());
+        List<Task> tasks = taskMapper.selectList(new QueryWrapper<Task>().in("custom_id", custom1.getId()));
+        custom1.setTasks(tasks);
+        custom1.setActionLogs(actionLogs);
         //联系人
-        custom1.setContacts(contactsMapper.selectList((new QueryWrapper<Contacts>().eq("custom_id",custom1.getId()))));
+        custom1.setContacts(contactsMapper.selectList((new QueryWrapper<Contacts>().eq("custom_id", custom1.getId()))));
         //订单
-        custom1.setSalesOrders(salesOrderMapper.selectList((new QueryWrapper<SalesOrder>().eq("custom_id",custom1.getId()))));
+        custom1.setSalesOrders(salesOrderMapper.selectList((new QueryWrapper<SalesOrder>().eq("custom_id", custom1.getId()))));
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         httpRespMsg.setData(custom1);
         return httpRespMsg;
     }
 
 
-
     @Override
     public HttpRespMsg getList(Custom custom, HttpServletRequest request) {
         User user = userMapper.selectById(request.getHeader("Token"));
@@ -254,7 +291,7 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
         custom.setIsDelete(0);
         custom.setUserId(user.getId());
         custom.setEndTime(custom.getEndTime() + " 23:59:59");
-        custom.setPageIndex((custom.getPageIndex()-1) * custom.getPageFrom() );
+        custom.setPageIndex((custom.getPageIndex() - 1) * custom.getPageFrom());
         boolean isAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看全部客户");
         boolean isNotAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看负责部门客户");
         List<Custom> list = new ArrayList<>();
@@ -287,7 +324,7 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
         custom.setIsDelete(1);
         custom.setUserId(user.getId());
         custom.setEndTime(custom.getEndTime() + " 23:59:59");
-        custom.setPageIndex((custom.getPageIndex()-1) * custom.getPageFrom() );
+        custom.setPageIndex((custom.getPageIndex() - 1) * custom.getPageFrom());
         boolean isAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看全部客户");
         boolean isNotAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看负责部门客户");
         List<Custom> list = new ArrayList<>();
@@ -316,6 +353,7 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
 
     @Value(value = "${upload.file}")
     private String filePath;
+
     @Override
     public Object uploadFile(Custom custom, HttpServletRequest request, MultipartFile file) {
         User user = userMapper.selectById(request.getHeader("token"));
@@ -368,7 +406,7 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
                 e.printStackTrace();
                 // 文件上传失败的响应消息
                 HttpRespMsg msg = new HttpRespMsg();
-                msg.setError("上传成功失败");
+                msg.setError("上传失败");
                 return msg;
             }
         } else {
@@ -385,7 +423,7 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
         try {
             ServletOutputStream os = response.getOutputStream();
             UploadFile uploadFile = uploadFileMapper.selectById(file.getId());
-            if (uploadFile == null ){
+            if (uploadFile == null) {
                 msg.setError("文件未找到");
                 return msg;
             }
@@ -401,7 +439,8 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
             msg.setError(MessageUtils.message("file.error"));
             e.printStackTrace();
         }
-        return msg;    }
+        return msg;
+    }
 
     @Override
     public Object deleteFile(UploadFile file, HttpServletRequest request) {
@@ -409,7 +448,6 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
         try {
             UploadFile uploadFile = uploadFileMapper.selectById(file.getId());
             uploadFileMapper.deleteById(uploadFile.getId());
-            String realName = uploadFile.getRealName();
             File file1 = new File(uploadFile.getPath());
             file1.delete();
             msg.setMsg("删除成功");
@@ -417,11 +455,15 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
             e.printStackTrace();
             msg.setError("删除失败");
         }
-        return msg;    }
+        return msg;
+    }
 
     @Override
     public Object reFileName(UploadFile uploadFile, HttpServletRequest request) {
-        return uploadFileMapper.update(null, new UpdateWrapper<UploadFile>().eq("id", uploadFile.getId()).set("name", uploadFile.getName()));
+        uploadFileMapper.update(null, new UpdateWrapper<UploadFile>().eq("item_id", uploadFile.getId()).eq("code", "custom").set("name", uploadFile.getName()));
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        httpRespMsg.setMsg("操作成功");
+        return httpRespMsg;
     }
 
     @Override
@@ -429,13 +471,13 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
         User user = userMapper.selectById(request.getHeader("token"));
         Integer companyId = user.getCompanyId();
         HttpRespMsg msg = new HttpRespMsg();
-        msg.setData(customMapper.selectList(new QueryWrapper<Custom>().eq("company_id",companyId)));
+        msg.setData(customMapper.selectList(new QueryWrapper<Custom>().eq("company_id", companyId)));
         return msg;
     }
 
     @Override
     public Map<String, Object> getDataSummary(Integer companyId, String startDate, String endDate, String userId, List<String> targetUserIds) {
-        return customMapper.getDataSummary(companyId,startDate,endDate,userId,targetUserIds);
+        return customMapper.getDataSummary(companyId, startDate, endDate, userId, targetUserIds);
     }
 
     @Override
@@ -448,13 +490,13 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
         HttpRespMsg msg = new HttpRespMsg();
         User user = userMapper.selectById(request.getHeader("token"));
         Integer companyId = user.getCompanyId();
-        if (exportType==1){//员工
-            List<UserVO> userVoList=userMapper.getCustomerTotalCount(startDate,endDate,userId,companyId);
-            if (userVoList!=null&&!userVoList.isEmpty()){
+        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){
+                    if (userVO.getCustomertotal() == 0) {
                         userVO.setDealRate((double) 0);
-                    }else {
+                    } else {
                         double v = ((double) userVO.getCustomerDeal() / userVO.getCustomertotal());
                         String formattedValue = String.format("%.2f", v);
                         userVO.setDealRate(Double.parseDouble(formattedValue));
@@ -462,14 +504,14 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
                 }
             }
             msg.setData(userVoList);
-        }else {
-            List<DepartmentVO> departmentVoList=departmentMapper.getCustomerTotalCount(startDate,endDate,departmentId,companyId);
-            if (departmentVoList!=null&&!departmentVoList.isEmpty()){
+        } 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());
+                    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));
                     }
@@ -487,13 +529,13 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
         User user = userMapper.selectById(request.getHeader("token"));
         Integer companyId = user.getCompanyId();
 
-        if (exportType==1) {//员工
-            List<UserVO> userVoList=userMapper.getCustomerTransferRate(startDate,endDate,userId,companyId);
-            if (userVoList!=null&&!userVoList.isEmpty()){
+        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){
+                    if (userVO.getNum() == 0) {
                         userVO.setDealRate((double) 0);
-                    }else {
+                    } else {
                         double v = (double) userVO.getSaleNum() / userVO.getNum();
                         String formattedValue = String.format("%.2f", v);
                         userVO.setDealRate(Double.parseDouble(formattedValue));
@@ -502,14 +544,13 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
                 }
             }
             msg.setData(userVoList);
-        }
-        else {//部门
-            List<DepartmentVO> departmentVoList=departmentMapper.getCustomerTransferRate(startDate,endDate,departmentId,companyId);
-            if (departmentVoList!=null&&!departmentVoList.isEmpty()){
+        } 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 {
+                    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));
@@ -526,7 +567,7 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
 
     @Override
     public HttpRespMsg importData(MultipartFile multipartFile) {
-        HttpRespMsg msg=new HttpRespMsg();
+        HttpRespMsg msg = new HttpRespMsg();
         String fileName = multipartFile.getOriginalFilename();
         File file = new File(fileName == null ? "file" : fileName);
         User user = userMapper.selectById(request.getHeader("token"));
@@ -554,15 +595,15 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
             int rowNum = sheet.getLastRowNum();
             //获取当前表单模板 校验规则
             SysForm sysForm = sysFormMapper.selectOne(new LambdaQueryWrapper<SysForm>().eq(SysForm::getCode, "Customer").eq(SysForm::getCompanyId, companyId).eq(SysForm::getIsCurrent, 1));
-            if(sysForm==null){
+            if (sysForm == null) {
                 msg.setError("当前模块未配置自定义模板,需先完成配置");
                 return msg;
             }
             String config = sysForm.getConfig();
             JSONObject configOb = JSON.parseObject(config);
             JSONArray configObJSONArray = configOb.getJSONArray("list");
-            List<String> userNameList=new ArrayList<>();
-            HttpRespMsg respMsg=new HttpRespMsg();
+            List<String> userNameList = new ArrayList<>();
+            HttpRespMsg respMsg = new HttpRespMsg();
             for (int rowIndex = 0; rowIndex <= rowNum; rowIndex++) {
                 XSSFRow row = sheet.getRow(rowIndex);
                 if (row == null) {
@@ -578,33 +619,34 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
                     JSONObject item = configObJSONArray.getJSONObject(i);
                     String modelName = item.getString("model");
                     XSSFCell cell = row.getCell(i);
-                    if(cell!=null){
-                        switch (item.getString("type")){
+                    if (cell != null) {
+                        switch (item.getString("type")) {
 //                            case "time":cell.setCellType(CellType.NUMERIC);
 //                                break;
-                            default:cell.setCellType(CellType.STRING);
+                            default:
+                                cell.setCellType(CellType.STRING);
                         }
                     }
-                    if(modelName.equals("inchargerId")){
+                    if (modelName.equals("inchargerId")) {
                         System.out.println("=====");
                         System.out.println(modelName);
                         System.out.println(cell.toString());
-                        if(!StringUtils.isEmpty(cell.getStringCellValue())){
+                        if (!StringUtils.isEmpty(cell.getStringCellValue())) {
                             userNameList.add(cell.getStringCellValue());
                         }
                     }
 
                 }
             }
-            System.out.println("参与搜索的人员列表"+userNameList + userNameList.size());
-            if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1&&userNameList.size()>0){
-                respMsg = wxCorpInfoService.getBatchSearchUserInfo(wxCorpInfo, userNameList,null);
-                if(respMsg.code.equals("0")){
-                    msg.setError("姓名为["+String.valueOf(respMsg.data)+"]的人员存在重复,请使用工号!");
+            System.out.println("参与搜索的人员列表" + userNameList + userNameList.size());
+            if (wxCorpInfo != null && wxCorpInfo.getSaasSyncContact() == 1 && userNameList.size() > 0) {
+                respMsg = wxCorpInfoService.getBatchSearchUserInfo(wxCorpInfo, userNameList, null);
+                if (respMsg.code.equals("0")) {
+                    msg.setError("姓名为[" + String.valueOf(respMsg.data) + "]的人员存在重复,请使用工号!");
                     return msg;
                 }
             }
-            List<User> targetUserList= (List<User>) respMsg.data;
+            List<User> targetUserList = (List<User>) respMsg.data;
             //直接忽略空行 从row1开始
             for (int rowIndex = 1; rowIndex <= rowNum; rowIndex++) {
                 XSSFRow row = sheet.getRow(rowIndex);
@@ -617,7 +659,7 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
                 }
                 //获取到当前行的列数据
                 int cellNum = row.getLastCellNum();
-                Custom custom =new Custom();
+                Custom custom = new Custom();
                 custom.setCompanyId(companyId);
                 custom.setCreateTime(new Date());
                 custom.setCreatorId(user.getId());
@@ -625,47 +667,48 @@ public class CustomServiceImpl extends ServiceImpl<CustomMapper, Custom> impleme
                     JSONObject item = configObJSONArray.getJSONObject(i);
                     String modelName = item.getString("model");
                     String className = modelName.substring(0, 1).toUpperCase() + modelName.substring(1);
-                    String getter="get"+className;
-                    String setter="set"+className;
+                    String getter = "get" + className;
+                    String setter = "set" + className;
                     XSSFCell cell = row.getCell(i);
-                    if(cell!=null){
-                        switch (item.getString("type")){
+                    if (cell != null) {
+                        switch (item.getString("type")) {
 
-                            default:cell.setCellType(CellType.STRING);
+                            default:
+                                cell.setCellType(CellType.STRING);
                         }
                     }
                     //校验当前列是否为必填
                     JSONObject options = item.getJSONObject("options");
                     JSONObject rules = options.getJSONObject("rules");
                     Boolean required = rules.getBoolean("required");
-                    if(required){
-                        if(StringUtils.isEmpty(cell.getStringCellValue())){
-                            msg.setError(item.getString("label")+"值不能为空值");
+                    if (required) {
+                        if (StringUtils.isEmpty(cell.getStringCellValue())) {
+                            msg.setError(item.getString("label") + "值不能为空值");
                             return msg;
                         }
                     }
-                    if(modelName.equals("inchargerId")){
-                        if(!StringUtils.isEmpty(cell.getStringCellValue())){
+                    if (modelName.equals("inchargerId")) {
+                        if (!StringUtils.isEmpty(cell.getStringCellValue())) {
                             String userName = cell.getStringCellValue();
                             Optional<User> first;
-                            if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                            if (wxCorpInfo != null && wxCorpInfo.getSaasSyncContact() == 1) {
                                 Optional<User> optional = targetUserList.stream().filter(tl -> tl.getName().equals(userName)).findFirst();
-                                first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(userName))||(optional.isPresent()&&u.getCorpwxUserid()!=null&&u.getCorpwxUserid().equals(optional.get().getCorpwxUserid()))).findFirst();
-                            }else {
-                                first= userList.stream().filter(u -> u.getName().equals(userName)||(u.getJobNumber()!=null&&u.getJobNumber().equals(userName))).findFirst();
+                                first = userList.stream().filter(u -> (u.getJobNumber() != null && u.getJobNumber().equals(userName)) || (optional.isPresent() && u.getCorpwxUserid() != null && u.getCorpwxUserid().equals(optional.get().getCorpwxUserid()))).findFirst();
+                            } else {
+                                first = userList.stream().filter(u -> u.getName().equals(userName) || (u.getJobNumber() != null && u.getJobNumber().equals(userName))).findFirst();
                             }
                             if (first.isPresent()) {
                                 custom.setInchargerId(first.get().getId());
                             } else {
-                                msg.setError("负责人["+userName+"]在系统中不存在");
+                                msg.setError("负责人[" + userName + "]在系统中不存在");
                                 return msg;
                             }
                         }
-                    }else {
-                        if(!StringUtils.isEmpty(cell.getStringCellValue())){
+                    } else {
+                        if (!StringUtils.isEmpty(cell.getStringCellValue())) {
                             Class<Clue> clueClass = Clue.class;
-                            Method method = clueClass.getMethod(setter,String.class);
-                            method.invoke(custom,cell.getStringCellValue());
+                            Method method = clueClass.getMethod(setter, String.class);
+                            method.invoke(custom, cell.getStringCellValue());
                         }
                     }
 

+ 10 - 1
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/TaskServiceImpl.java

@@ -184,6 +184,15 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
             actionLog.setItemId(taskDto.getBusinessOpportunityId());
             logMapper.insert(actionLog);
         }
+        if (taskDto.getCustomId() != null){
+            ActionLog actionLog = new ActionLog();
+            actionLog.setCreatTime(new Date());
+            actionLog.setUserId(userId);
+            actionLog.setCode("custom");
+            actionLog.setName("新建了相关任务");
+            actionLog.setItemId(taskDto.getCustomId());
+            logMapper.insert(actionLog);
+        }
         return httpRespMsg;
     }
 
@@ -416,7 +425,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                     String modelName = modelNameList.get(i);
                     XSSFCell cell = row.getCell(i);
                     if(modelName.equals("executorId")){
-                        if(!StringUtils.isEmpty(cell.getStringCellValue())){
+                        if((cell != null) && !StringUtils.isEmpty(cell.getStringCellValue())){
                             List<String> executorNames = new ArrayList<>();
                             String stringCellValue = cell.getStringCellValue();
                             // 定义正则表达式,匹配中文字符、英文字符、数字

+ 27 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/BusinessOpportunityMapper.xml

@@ -278,6 +278,33 @@
         </if>
         GROUP BY s.id
     </select>
+    <select id="getAllList" resultType="com.management.platform.entity.BusinessOpportunity">
+        select
+        id,
+        name
+        from business_opportunity
+        where company_id = #{companyId}
+        and is_delete = 0
+    </select>
 
+    <select id="getAllList1" resultType="com.management.platform.entity.BusinessOpportunity">
+        select
+        id,
+        name
+        from business_opportunity
+        where company_id = #{companyId}
+        and is_delete = 0
+        and (incharger_id in
+        (SELECT id from `user` WHERE department_id = (SELECT department_id from `user` WHERe id = #{id}))
+        or incharger_id is null)
+    </select>
 
+    <select id="getAllList2" resultType="com.management.platform.entity.BusinessOpportunity">
+        select id,
+               name
+        from business_opportunity
+        where company_id = #{companyId}
+          and is_delete = 0
+          and (incharger_id = #{id} or incharger_id is null)
+    </select>
 </mapper>

+ 90 - 53
fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/CustomMapper.xml

@@ -43,48 +43,66 @@
         id, company_id, custom_name, custom_source_id, customer_industry_id, customer_level_id, email, owner_id, custom_code, tel_phone, fax, country_billing, province_billing, city_billing, street_billing, country_delivery, province_delivery, city_delivery, street_delivery, create_time, plate1, plate2, plate3, plate4, plate5, creator_id, custom_desc, is_delete, company_phone, incharger_id, address, close_deal
     </sql>
     <select id="getList" resultType="com.management.platform.entity.Custom">
-        select id,
-        custom_name,
-        email,
-        company_phone,
-        create_time,
-        customer_level_id,
+        select
+        c.id,
+        c.contacts_name,
+        c.custom_name,
+        c.email,
+        c.company_phone,
+        c.create_time,
+        c.customer_level_id,
         (select name from sys_dict where customer_level_id = id and code = 'CustomLevel') customerLevelValue,
-        customer_industry_id,
+        c.customer_industry_id,
         (select name from sys_dict where customer_industry_id = id and code = 'CustomIndustry') customerIndustryValue,
-        custom_source_id,
-        (select name from sys_dict where custom_source_id = id and code = 'CustomSources') customSourceValue,
-        incharger_id,
+        c.custom_source_id,
+        (select name from sys_dict where custom_source_id = id) customSourceValue,
+        c.incharger_id,
         (select `name` from `user` where id = incharger_id) inchargerName,
-        creator_id,
+        c.creator_id,
         (select `name` from `user` where id = creator_id) creatorName
-        from custom
-        where company_id = #{companyId}
-          and is_delete =#{isDelete}
+        from custom c
+        left join sys_dict sd on c.customer_level_id = sd.id
+        where c.company_id = #{companyId}
+          and c.is_delete =#{isDelete}
         <if test="inchargerId != null and inchargerId != ''  ">
-            and incharger_id =#{inchargerId}
+            and c.incharger_id =#{inchargerId}
         </if>
         <if test="startTime != null and endTime != null ">
-            and create_time BETWEEN #{startTime} and #{endTime}
+            and c.create_time BETWEEN #{startTime} and #{endTime}
         </if>
         <if test="customName != null and customName != '' ">
-            and custom_name = #{customName}
+            and c.custom_name LIKE CONCAT('%', #{customName}, '%')
         </if>
         <if test="email != null and email != '' ">
-            and email = #{email}
+            and c.email LIKE CONCAT('%', #{email}, '%')
         </if>
         <if test="companyPhone != null ">
-            and company_phone = #{companyPhone}
+            and c.company_phone = #{companyPhone}
         </if>
         <if test="customerLevelId != null ">
-            and customer_level_id = #{customerLevelId}
+            and c.customer_level_id = #{customerLevelId}
         </if>
         <if test="customSourceId != null ">
-            and custom_source_id = #{customSourceId}
+            and c.custom_source_id = #{customSourceId}
         </if>
           <if test="customerIndustryId != null ">
-            and customer_industry_id = #{customerIndustryId}
-        </if>
+            and c.customer_industry_id = #{customerIndustryId}
+        </if>
+        ORDER BY
+        <choose>
+            <when test="isDesc == null ">
+                c.id DESC
+            </when>
+            <when test="isDesc == 0">
+                sd.seq ASC, c.id DESC
+            </when>
+            <when test="isDesc == 1">
+                sd.seq DESC, c.id DESC
+            </when>
+            <otherwise>
+                c.id DESC
+            </otherwise>
+        </choose>
         Limit #{pageIndex},#{pageFrom}
     </select>
     <select id="getTotal" resultType="java.lang.Integer">
@@ -118,51 +136,67 @@
         </if>
     </select>
     <select id="getList1" resultType="com.management.platform.entity.Custom">
-        select id,
-        custom_name,
-        email,
-        company_phone,
-        create_time,
-        customer_level_id,
+        select c.id,
+        c.custom_name,
+        c.email,
+        c.company_phone,
+        c.create_time,
+        c.customer_level_id,
         (select name from sys_dict where customer_level_id = id and code = 'CustomLevel') customerLevelValue,
-        customer_industry_id,
+        c.customer_industry_id,
         (select name from sys_dict where customer_industry_id = id and code = 'CustomIndustry') customerIndustryValue,
-        custom_source_id,
-        (select name from sys_dict where custom_source_id = id and code = 'CustomSources') customSourceValue,
-        incharger_id,
+        c.custom_source_id,
+        (select name from sys_dict where custom_source_id = id ) customSourceValue,
+        c.incharger_id,
         (select `name` from `user` where id = incharger_id) inchargerName,
-        creator_id,
+        c.creator_id,
         (select `name` from `user` where id = creator_id) creatorName
-        from custom
-        where company_id = #{companyId}
-        and is_delete =#{isDelete}
-        and incharger_id in
-        (SELECT id from `user` WHERE department_id = (SELECT department_id from `user` WHERe id = #{userId}))
-        or incharger_id is null
+        from custom c
+        left join sys_dict sd on c.customer_level_id = sd.id
+        where c.company_id = #{companyId}
+        and c.is_delete =#{isDelete}
+        and c.incharger_id in
+        (SELECT id from `user` WHERE department_id = (SELECT department_id from `user` WHERE id = #{userId}))
+        or c.incharger_id is null
         <if test="inchargerId != null and inchargerId != ''  ">
-            and incharger_id =#{inchargerId}
+            and c.incharger_id =#{inchargerId}
         </if>
         <if test="startTime != null and endTime != null ">
-            and create_time BETWEEN #{startTime} and #{endTime}
+            and c.create_time BETWEEN #{startTime} and #{endTime}
         </if>
         <if test="customName != null and customName != '' ">
-            and custom_name = #{customName}
+            and c.custom_name LIKE CONCAT('%', #{customName}, '%')
         </if>
         <if test="email != null and email != '' ">
-            and email = #{email}
+            and c.email LIKE CONCAT('%', #{email}, '%')
         </if>
         <if test="companyPhone != null ">
-            and company_phone = #{companyPhone}
+            and c.company_phone = #{companyPhone}
         </if>
         <if test="customerLevelId != null ">
-            and customer_level_id = #{customerLevelId}
+            and c.customer_level_id = #{customerLevelId}
         </if>
         <if test="customSourceId != null ">
-            and custom_source_id = #{customSourceId}
+            and c.custom_source_id = #{customSourceId}
         </if>
         <if test="customerIndustryId != null ">
-            and customer_industry_id = #{customerIndustryId}
-        </if>
+            and c.customer_industry_id = #{customerIndustryId}
+        </if>
+        ORDER BY
+        <choose>
+            <when test="isDesc == null ">
+                c.id DESC
+            </when>
+            <when test="isDesc == 0">
+                sd.seq ASC, c.id DESC
+            </when>
+            <when test="isDesc == 1">
+                sd.seq DESC, c.id DESC
+            </when>
+            <otherwise>
+                c.id DESC
+            </otherwise>
+        </choose>
         Limit #{pageIndex},#{pageFrom}
     </select>
     <select id="getTotal1" resultType="java.lang.Integer">
@@ -209,7 +243,7 @@
         customer_industry_id,
         (select name from sys_dict where customer_industry_id = id and code = 'CustomIndustry') customerIndustryValue,
         custom_source_id,
-        (select name from sys_dict where custom_source_id = id and code = 'CustomSources') customSourceValue,
+        (select name from sys_dict where custom_source_id = id ) customSourceValue,
         incharger_id,
         (select `name` from `user` where id = incharger_id) inchargerName,
         creator_id,
@@ -226,10 +260,10 @@
             and create_time BETWEEN #{startTime} and #{endTime}
         </if>
         <if test="customName != null and customName != '' ">
-            and custom_name = #{customName}
+            and custom_name LIKE CONCAT('%', #{customName}, '%')
         </if>
         <if test="email != null and email != '' ">
-            and email = #{email}
+            and email LIKE CONCAT('%', #{email}, '%')
         </if>
         <if test="companyPhone != null ">
             and company_phone = #{companyPhone}
@@ -243,6 +277,7 @@
         <if test="customerIndustryId != null ">
             and customer_industry_id = #{customerIndustryId}
         </if>
+        ORDER BY id desc
         Limit #{pageIndex},#{pageFrom}
     </select>
     <select id="getTotal2" resultType="java.lang.Integer">
@@ -280,10 +315,12 @@
     <select id="getInfo" resultType="com.management.platform.entity.Custom">
         select id,
                custom_name,
+               contacts_name,
                custom_source_id,
                customer_industry_id,
                customer_level_id,
                email,
+               tel_phone,
                address,
                custom_code,
                tel_phone,
@@ -299,7 +336,7 @@
                is_delete,
                (select `name` from sys_dict where customer_level_id = id and code = 'CustomLevel') customerLevelValue,
                (select `name` from sys_dict where customer_industry_id = id and code = 'CustomIndustry') customerIndustryValue,
-               (select `name` from sys_dict where custom_source_id = id and code = 'CustomSources') customSourceValue,
+               (select `name` from sys_dict where custom_source_id = id ) customSourceValue,
                (select `name` from `user` where id = incharger_id) inchargerName,
                (select `name` from `user` where id = creator_id) creatorName
         from custom