فهرست منبع

修改代码,定时处理任务状态

ysm 11 ماه پیش
والد
کامیت
5b5c772c6b

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

@@ -9,6 +9,7 @@ import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
 import org.springframework.data.redis.serializer.StringRedisSerializer;
 import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.transaction.annotation.EnableTransactionManagement;
 /**
  * Author: 吴涛涛
@@ -20,6 +21,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
 @MapperScan("com.management.platform.mapper")
 @EnableTransactionManagement //开启事务支持
 @EnableAsync
+@EnableScheduling
 public class PlatformStartApplication {
     public static void main(String[] args) {
         SpringApplication.run(PlatformStartApplication.class, args);

+ 8 - 6
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/ContactsController.java

@@ -57,23 +57,25 @@ public class ContactsController {
         return contactsService.addContacts(contacts, request);
     }
     @RequestMapping("/getAllContacts")
-    public HttpRespMsg getAllContacts(Integer customerId,HttpServletRequest request){
-        return contactsService.getAllContacts(customerId,request);
+    public HttpRespMsg getAllContacts(Integer businessId,Integer salesId ,Integer customerId,HttpServletRequest request){
+        return contactsService.getAllContacts(businessId,salesId,customerId,request);
     }
 
     /**
      * 分页查询联系人
      * @param pageIndex
      * @param pageSize
-     * @param customName
+     * @param customId
      * @param name
+     * @param email
+     * @param creatorId
      * @param phone
-     * @param ownerName
+     * @param ownerId
      * @return
      */
     @RequestMapping("/pageContacts")
-    public HttpRespMsg pageContacts(@RequestParam Integer pageIndex, @RequestParam Integer pageSize,String customName, String name, String email,String creatorName, String phone, String ownerName){
-        return contactsService.pageContacts(pageIndex,pageSize,customName,name,email,creatorName,phone,ownerName,request);
+    public HttpRespMsg pageContacts(@RequestParam Integer pageIndex, @RequestParam Integer pageSize,Integer customId, String name, String email,String creatorId, String phone, String ownerId){
+        return contactsService.pageContacts(pageIndex,pageSize,customId,name,email,creatorId,phone,ownerId,request);
     }
 
     /**

+ 34 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/TaskController.java

@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.annotation.TableField;
 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.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.pagehelper.IPage;
 import com.management.platform.entity.*;
@@ -16,7 +17,10 @@ import com.management.platform.service.*;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.MessageUtils;
 import com.taobao.api.internal.mapping.ApiField;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.ss.formula.functions.T;
 import org.assertj.core.util.Lists;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -27,6 +31,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
+import java.sql.Wrapper;
 import java.time.Duration;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
@@ -44,6 +49,7 @@ import java.util.stream.Collectors;
  */
 @RestController
 @RequestMapping("/tasks")
+@Slf4j
 public class TaskController {
     @Resource
     private HttpServletRequest request;
@@ -100,5 +106,33 @@ public class TaskController {
         return taskService.updateTaskStatus(taskDto,request);
     }
 
+    /**
+     * 定时修改过期的任务状态
+     */
+    @Scheduled(cron = "0 0/30 * * * ?")
+    public void updateTaskStatusByTiming(){
+        log.info("定时执行了===========>");
+        QueryWrapper<Task> taskQueryWrapper = new QueryWrapper<>();
+        taskQueryWrapper.eq("is_delete",0);
+        List<Task> list = taskService.list(taskQueryWrapper);
+        ArrayList<Integer> overtimeTaskIds = new ArrayList<>();
+        if (!list.isEmpty()){
+            for (Task task : list) {
+                if (task.getEndDate()!=null && task.getStatus()!=null && task.getStatus()<2 &&task.getEndDate().isBefore(LocalDateTime.now())){
+                    overtimeTaskIds.add(task.getId());
+                }
+            }
+        }
+        if (!overtimeTaskIds.isEmpty()){
+            UpdateWrapper<Task> updateWrapper = new UpdateWrapper<>();
+            updateWrapper.set("status",3).in("id",overtimeTaskIds);//设置推迟
+            taskService.update(updateWrapper);
+            log.info("修改了");
+        }else {
+            log.info("没修改");
+        }
+
+    }
+
 }
 

+ 1 - 1
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/Contacts.java

@@ -19,7 +19,7 @@ import org.springframework.format.annotation.DateTimeFormat;
  * </p>
  *
  * @author Seyason
- * @since 2024-03-12
+ * @since 2024-06-12
  */
 @Data
 @EqualsAndHashCode(callSuper = false)

+ 2 - 2
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/ContactsService.java

@@ -22,7 +22,7 @@ public interface ContactsService extends IService<Contacts> {
 
     HttpRespMsg addContacts(Contacts contacts, HttpServletRequest request);
 
-    HttpRespMsg pageContacts(Integer pageIndex, Integer pageSize, String customName, String name,String email,String creatorName,  String phone, String ownerName, HttpServletRequest request);
+    HttpRespMsg pageContacts(Integer pageIndex, Integer pageSize, Integer customId, String name, String email, String creatorId, String phone, String ownerId, HttpServletRequest request);
 
     HttpRespMsg selectContactsByCustomId(Custom custom,HttpServletRequest request);
 
@@ -42,7 +42,7 @@ public interface ContactsService extends IService<Contacts> {
 
     HttpRespMsg exportData(String customName, String name, String email, String creatorName, String phone, String ownerName, HttpServletRequest request) throws Exception;
 
-    HttpRespMsg getAllContacts(Integer customerId, HttpServletRequest request);
+    HttpRespMsg getAllContacts(Integer businessId, Integer salesId, Integer customerId, HttpServletRequest request);
 
     int transferContacts(Contacts contactsGet, User user);
 

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

@@ -113,7 +113,7 @@ public class ContactsDocumentServiceImpl extends ServiceImpl<ContactsDocumentMap
     public HttpRespMsg fileDown(HttpServletRequest request, HttpServletResponse response, Integer folderId, Integer contactsId, Integer fileId) {
         HttpRespMsg msg = new HttpRespMsg();
         User user = userMapper.selectById(request.getHeader("token"));
-        List<ContactsDocument> files = contactsDocumentMapper.selectList(new QueryWrapper<ContactsDocument>().eq("contacts_id", contactsId));
+        List<ContactsDocument> files = contactsDocumentMapper.selectList(new QueryWrapper<ContactsDocument>().eq("id", fileId));
         try {
             ServletOutputStream os = response.getOutputStream();
             for (ContactsDocument file : files) {
@@ -142,7 +142,7 @@ public class ContactsDocumentServiceImpl extends ServiceImpl<ContactsDocumentMap
         List<Integer> fileIds = contactsFileDto.getFileIds();
         List<ContactsDocument> contactsDocuments = contactsDocumentMapper.selectBatchIds(fileIds);
         for (ContactsDocument contactsDocument : contactsDocuments) {
-            contactsDocumentMapper.update(null,new UpdateWrapper<ContactsDocument>().eq("contacts_id", contactsDocument.getContactsId()).set("is_deleted", 1));
+            contactsDocumentMapper.update(null,new UpdateWrapper<ContactsDocument>().eq("id", contactsDocument.getId()).set("is_deleted", 1));
         }
         msg.setMsg("删除成功");
         return msg;

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

@@ -3,7 +3,6 @@ package com.management.platform.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -17,10 +16,6 @@ import com.management.platform.service.WxCorpInfoService;
 import com.management.platform.util.ExcelUtil;
 import com.management.platform.util.HttpRespMsg;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.poi.hssf.usermodel.HSSFCell;
-import org.apache.poi.hssf.usermodel.HSSFRow;
-import org.apache.poi.hssf.usermodel.HSSFSheet;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.xssf.usermodel.XSSFCell;
 import org.apache.poi.xssf.usermodel.XSSFRow;
@@ -64,6 +59,9 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
     @Resource
     private BusinessOpportunityMapper businessOpportunityMapper;
 
+    @Resource
+    private SalesOrderMapper salesOrderMapper;
+
     @Resource
     private CustomMapper customMapper;
 
@@ -112,13 +110,10 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
         }
 
         LambdaQueryWrapper<Contacts> lqw_contacts = new LambdaQueryWrapper<>();
-        lqw_contacts.eq(Contacts::getCustomId, contacts.getCustomId())
-                .eq(Contacts::getName, contacts.getName())
-                .eq(Contacts::getPhone,contacts.getPhone())
-                .eq(Contacts::getOwnerId,contacts.getOwnerId());
+        lqw_contacts.eq(Contacts::getPhone,contacts.getPhone());
         Contacts selectedOne = contactsMapper.selectOne(lqw_contacts);
         if (selectedOne != null) {
-            httpRespMsg.setError("已存在该联系人!");
+            httpRespMsg.setError("已存在该联系人,手机号重复!");
             return httpRespMsg;
         }
         contacts.setCompanyId(companyId)
@@ -141,19 +136,19 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
     }
 
     @Override
-    public HttpRespMsg pageContacts(Integer pageIndex, Integer pageSize, String customName, String name, String email, String creatorName, String phone, String ownerName, HttpServletRequest request) {
+    public HttpRespMsg pageContacts(Integer pageIndex, Integer pageSize, Integer customId, String name, String email, String creatorId, String phone, String ownerId, HttpServletRequest request) {
         Map<String, Object> map = new HashMap<>();
-        map.put("customName", customName);
+        map.put("customId", customId);
         map.put("name", name);
         map.put("phone", phone);
-        map.put("ownerName", ownerName);
+        map.put("ownerId", ownerId);
         map.put("email", email);
-        map.put("creatorName", creatorName);
+        map.put("creatorId", creatorId);
         String token = String.valueOf(request.getHeader("Token"));
         User user = userMapper.selectById(token);
         map.put("companyId", user.getCompanyId());
         map.put("isDelete", 0);
-        Page<ContactsVo> pageContacts = contactsMapper.pageContacts(new Page(pageIndex, pageSize), map);
+        Page<ContactsVo> pageContacts = contactsMapper.pageContacts(new Page((long) (pageIndex - 1) *pageSize, pageSize), map);
 
         List<ContactsVo> records = pageContacts.getRecords();
         long total = pageContacts.getTotal();
@@ -241,7 +236,7 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
         User user = userMapper.selectById(token);
         map.put("companyId", user.getCompanyId());
         map.put("isDelete", 1);
-        Page<ContactsVo> pageContacts = contactsMapper.pageContacts(new Page(pageIndex, pageSize), map);
+        Page<ContactsVo> pageContacts = contactsMapper.pageContacts(new Page((long) (pageIndex - 1) *pageSize, pageSize), map);
 
         List<ContactsVo> records = pageContacts.getRecords();
         long total = pageContacts.getTotal();
@@ -475,11 +470,6 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
                             userNameList.add(cell.getStringCellValue());
                         }
                     }
-                    if(modelName.equals("companySigner")){
-                        if(!org.springframework.util.StringUtils.isEmpty(cell.getStringCellValue())){
-                            userNameList.add(cell.getStringCellValue());
-                        }
-                    }
 
                 }
             }
@@ -508,6 +498,7 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
                 Contacts contacts=new Contacts();
                 contacts.setCompanyId(companyId);
                 contacts.setCreatorId(user.getId());
+                contacts.setIsDelete(0);
                 for (int i = 0; i < cellNum; i++) {
                     String modelName = modelNameList.get(i);
                     String className = modelName.substring(0, 1).toUpperCase() + modelName.substring(1);
@@ -684,10 +675,32 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
     }
 
     @Override
-    public HttpRespMsg getAllContacts(Integer customerId, HttpServletRequest request) {
+    public HttpRespMsg getAllContacts(Integer businessId, Integer salesId, Integer customerId, HttpServletRequest request) {
         User user = userMapper.selectById(request.getHeader("token"));
         HttpRespMsg mgs = new HttpRespMsg();
-        if (customerId!=null){
+        if (businessId!=null){
+            BusinessOpportunity businessOpportunity = businessOpportunityMapper.selectById(businessId);
+            if (businessOpportunity==null||businessOpportunity.getContactsId()==null){
+                mgs.setData(new ArrayList<Contacts>());
+            }else {
+                Integer contactsId = businessOpportunity.getContactsId();
+                mgs.setData(contactsMapper.selectList(new QueryWrapper<Contacts>()
+                        .eq("company_id",user.getCompanyId())
+                        .eq("id",contactsId)));
+            }
+        }else if(salesId!=null){
+            SalesOrder salesOrder = salesOrderMapper.selectById(salesId);
+            if (salesOrder==null||salesOrder.getContactsId()==null){
+                mgs.setData(new ArrayList<Contacts>());
+            }else {
+                Integer contactsId = salesOrder.getContactsId();
+                mgs.setData(contactsMapper.selectList(new QueryWrapper<Contacts>()
+                        .eq("company_id",user.getCompanyId())
+                        .eq("id",contactsId)));
+            }
+
+        }
+        else if (customerId!=null){
             mgs.setData(contactsMapper.selectList(new QueryWrapper<Contacts>()
                     .eq("company_id",user.getCompanyId())
                     .eq("custom_id",customerId)));

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

@@ -242,7 +242,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                 User selectedUser = userMapper.selectById(executorId);
                 taskExecutor.setExecutorId(executorId)
                         .setTaskId(task.getId())
-                        .setExecutorName(selectedUser.getName());
+                        .setExecutorName(selectedUser.getName())
+                        .setCompanyId(user.getCompanyId());
                 taskExecutorMapper.insert(taskExecutor);
             }
         }
@@ -402,6 +403,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                 task.setCreaterId(user.getId());
                 task.setCreateDate(LocalDateTime.now());
                 task.setStatus(0);
+                task.setIsDelete(0);
                 for (int i = 0; i < cellNum; i++) {
                     JSONObject item = configObJSONArray.getJSONObject(i);
                     String modelName = item.getString("model");

+ 1 - 1
fhKeeper/formulahousekeeper/management-crm/src/main/resources/application-dev.yml

@@ -80,7 +80,7 @@ mybatis:
   mapper-locations: mappers/*Mapper.xml
 #####配置图片上传路径####
 upload:
-  path: /www/staticproject/timesheet/upload/
+  path: /www/staticproject/timesheet-crm/upload/
 
 
 

+ 12 - 1
fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/ContactsMapper.xml

@@ -29,11 +29,13 @@
     <sql id="Base_Column_List">
         id, company_id, sex, name, custom_id, email, phone, owner_id, creator_id, address, remark, is_delete, create_time, position, plate1, plate2, plate3, plate4, plate5
     </sql>
+
     <select id="pageContacts" parameterType="java.util.Map"  resultType="com.management.platform.entity.vo.ContactsVo">
-        SELECT c.*, cust.custom_name as customName, own.name as ownerName
+        SELECT c.*, cust.custom_name as customName, own.name as ownerName,u.name as creatorName
         FROM contacts c
         LEFT JOIN custom cust ON c.custom_id = cust.id
         LEFT JOIN user own ON c.owner_id = own.id
+        LEFT JOIN user u ON c.creator_id = u.id
         <where>
             <if test="map.isDelete != null ">
                 AND c.is_delete =#{map.isDelete}
@@ -47,6 +49,15 @@
             <if test="map.creatorName != null and map.creatorName != ''">
                 AND own.name LIKE CONCAT('%', #{map.creatorName}, '%')
             </if>
+            <if test="map.customId != null and map.customId != ''">
+                AND cust.id =#{map.customId}
+            </if>
+            <if test="map.ownerId != null and map.ownerId != ''">
+                AND own.id =#{map.ownerId}
+            </if>
+            <if test="map.creatorId != null and map.creatorId != ''">
+                AND own.id =#{map.creatorId}
+            </if>
             <if test="map.phone != null and map.phone != ''">
                 AND c.phone LIKE CONCAT('%', #{map.phone}, '%')
             </if>