Переглянути джерело

采购保存流程id,客户功能修改,多公司营业日期改成字符串

yzc 2 роки тому
батько
коміт
e26410b430

+ 4 - 4
hx-common/src/main/java/com/fjhx/common/entity/corporation/po/Corporation.java

@@ -53,14 +53,14 @@ public class Corporation extends BasePo {
     /**
      * 营业开始日期
      */
-    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
-    private Date startDate;
+//    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    private String startDate;
 
     /**
      * 营业结束日期
      */
-    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
-    private Date stopDate;
+//    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    private String stopDate;
 
     /**
      * 纳税人资质

+ 16 - 11
hx-customer/src/main/java/com/fjhx/customer/controller/customer/CustomerController.java

@@ -1,18 +1,18 @@
 package com.fjhx.customer.controller.customer;
 
 import com.baomidou.dynamic.datasource.annotation.DS;
-import com.fjhx.common.constant.SourceConstant;
-import org.springframework.web.bind.annotation.*;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.fjhx.customer.entity.customer.vo.CustomerVo;
-import com.fjhx.customer.entity.customer.dto.CustomerSelectDto;
+import com.fjhx.common.constant.SourceConstant;
 import com.fjhx.customer.entity.customer.dto.CustomerDto;
-import com.ruoyi.common.core.domain.BaseSelectDto;
+import com.fjhx.customer.entity.customer.dto.CustomerSelectDto;
+import com.fjhx.customer.entity.customer.vo.CustomerVo;
 import com.fjhx.customer.service.customer.CustomerService;
+import com.ruoyi.common.core.domain.BaseSelectDto;
 import org.springframework.beans.factory.annotation.Autowired;
-
-import java.util.List;
-import java.util.Map;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 /**
  * <p>
@@ -85,9 +85,14 @@ public class CustomerController {
      */
     @PostMapping("/CustomerAllocation")
     public void CustomerAllocation(@RequestBody CustomerDto dto) {
-            customerService.updateById(dto);
+        customerService.updateById(dto);
     }
 
-
-
+    /**
+     * 修改客户标签
+     */
+    @PostMapping("/editTag")
+    public void editTag(@RequestBody CustomerDto customerDto) {
+        customerService.editTag(customerDto);
+    }
 }

+ 18 - 5
hx-customer/src/main/java/com/fjhx/customer/controller/customer/CustomerFollowRecordsController.java

@@ -1,13 +1,18 @@
 package com.fjhx.customer.controller.customer;
 
-import org.springframework.web.bind.annotation.*;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.fjhx.customer.entity.customer.vo.CustomerFollowRecordsVo;
-import com.fjhx.customer.entity.customer.dto.CustomerFollowRecordsSelectDto;
 import com.fjhx.customer.entity.customer.dto.CustomerFollowRecordsDto;
-import com.ruoyi.common.core.domain.BaseSelectDto;
+import com.fjhx.customer.entity.customer.dto.CustomerFollowRecordsSelectDto;
+import com.fjhx.customer.entity.customer.vo.CustomerFollowRecordsVo;
 import com.fjhx.customer.service.customer.CustomerFollowRecordsService;
+import com.ruoyi.common.core.domain.BaseSelectDto;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
 
 
 /**
@@ -15,7 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
  * 客户跟进记录 前端控制器
  * </p>
  *
- * @author 
+ * @author
  * @since 2023-05-05
  */
 @RestController
@@ -65,4 +70,12 @@ public class CustomerFollowRecordsController {
         customerFollowRecordsService.delete(dto.getId());
     }
 
+    /**
+     * 跟进记录列表
+     */
+    @PostMapping("/followList")
+    public List<CustomerFollowRecordsVo> followList(@RequestBody CustomerFollowRecordsSelectDto dto) {
+        return customerFollowRecordsService.followList(dto.getCustomerId());
+    }
+
 }

+ 6 - 1
hx-customer/src/main/java/com/fjhx/customer/entity/customer/dto/CustomerFollowRecordsSelectDto.java

@@ -7,11 +7,16 @@ import lombok.Setter;
 /**
  * 客户跟进记录列表查询入参实体
  *
- * @author 
+ * @author
  * @since 2023-05-05
  */
 @Getter
 @Setter
 public class CustomerFollowRecordsSelectDto extends BaseSelectDto {
 
+    /**
+     * 客户id
+     */
+    private Long customerId;
+
 }

+ 11 - 2
hx-customer/src/main/java/com/fjhx/customer/entity/customer/po/CustomerUser.java

@@ -1,8 +1,7 @@
 package com.fjhx.customer.entity.customer.po;
 
-import com.ruoyi.common.core.domain.BasePo;
 import com.baomidou.mybatisplus.annotation.TableName;
-import java.util.Date;
+import com.ruoyi.common.core.domain.BasePo;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -34,4 +33,14 @@ public class CustomerUser extends BasePo {
      */
     private String phone;
 
+    /**
+     * 电子邮箱
+     */
+    private String email;
+
+    /**
+     * 更多联系方式
+     */
+    private String contactJson;
+
 }

+ 7 - 1
hx-customer/src/main/java/com/fjhx/customer/entity/customer/vo/CustomerFollowRecordsVo.java

@@ -1,9 +1,12 @@
 package com.fjhx.customer.entity.customer.vo;
 
 import com.fjhx.customer.entity.customer.po.CustomerFollowRecords;
+import com.fjhx.file.entity.ObsFile;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.util.List;
+
 /**
  * 客户跟进记录列表查询返回值实体
  *
@@ -13,5 +16,8 @@ import lombok.Setter;
 @Getter
 @Setter
 public class CustomerFollowRecordsVo extends CustomerFollowRecords {
-
+    /**
+     * 文件列表
+     */
+    List<ObsFile> fileList;
 }

+ 4 - 0
hx-customer/src/main/java/com/fjhx/customer/service/customer/CustomerFollowRecordsService.java

@@ -7,6 +7,8 @@ import com.fjhx.customer.entity.customer.vo.CustomerFollowRecordsVo;
 import com.fjhx.customer.entity.customer.dto.CustomerFollowRecordsSelectDto;
 import com.fjhx.customer.entity.customer.dto.CustomerFollowRecordsDto;
 
+import java.util.List;
+
 
 /**
  * <p>
@@ -23,6 +25,8 @@ public interface CustomerFollowRecordsService extends BaseService<CustomerFollow
      */
     Page<CustomerFollowRecordsVo> getPage(CustomerFollowRecordsSelectDto dto);
 
+    List<CustomerFollowRecordsVo> followList(Long id);
+
     /**
      * 客户跟进记录明细
      */

+ 2 - 0
hx-customer/src/main/java/com/fjhx/customer/service/customer/CustomerService.java

@@ -66,4 +66,6 @@ public interface CustomerService extends BaseService<Customer> {
      * @return
      */
     List<CustomerVo> sourceIncrement(QueryWrapper<Object> query);
+
+    void editTag(CustomerDto customerDto);
 }

+ 59 - 12
hx-customer/src/main/java/com/fjhx/customer/service/customer/impl/CustomerFollowRecordsServiceImpl.java

@@ -1,20 +1,30 @@
 package com.fjhx.customer.service.customer.impl;
 
-import com.baomidou.dynamic.datasource.annotation.DS;
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.dynamic.datasource.annotation.DSTransactional;
+import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.common.constant.SourceConstant;
+import com.fjhx.customer.entity.customer.dto.CustomerFollowRecordsDto;
+import com.fjhx.customer.entity.customer.dto.CustomerFollowRecordsSelectDto;
 import com.fjhx.customer.entity.customer.po.CustomerFollowRecords;
+import com.fjhx.customer.entity.customer.vo.CustomerFollowRecordsVo;
 import com.fjhx.customer.mapper.customer.CustomerFollowRecordsMapper;
 import com.fjhx.customer.service.customer.CustomerFollowRecordsService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.file.entity.FileInfo;
+import com.fjhx.file.entity.ObsFile;
+import com.fjhx.file.service.FileInfoService;
 import com.fjhx.file.utils.ObsFileUtil;
-import org.springframework.stereotype.Service;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.fjhx.customer.entity.customer.vo.CustomerFollowRecordsVo;
-import com.fjhx.customer.entity.customer.dto.CustomerFollowRecordsSelectDto;
+import com.obs.services.internal.ServiceException;
 import com.ruoyi.common.utils.wrapper.IWrapper;
-import com.fjhx.customer.entity.customer.dto.CustomerFollowRecordsDto;
-import cn.hutool.core.bean.BeanUtil;
-import oshi.util.FileUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 
 /**
@@ -22,21 +32,58 @@ import oshi.util.FileUtil;
  * 客户跟进记录 服务实现类
  * </p>
  *
- * @author 
+ * @author
  * @since 2023-05-05
  */
 @Service
 public class CustomerFollowRecordsServiceImpl extends ServiceImpl<CustomerFollowRecordsMapper, CustomerFollowRecords> implements CustomerFollowRecordsService {
 
+    @Autowired
+    FileInfoService fileInfoService;
+
     @Override
     public Page<CustomerFollowRecordsVo> getPage(CustomerFollowRecordsSelectDto dto) {
         IWrapper<CustomerFollowRecords> wrapper = getWrapper();
+        wrapper.eq("cfr",CustomerFollowRecords::getCustomerId,dto.getCustomerId());//根据客户id过滤
         wrapper.orderByDesc("cfr", CustomerFollowRecords::getId);
         Page<CustomerFollowRecordsVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
+        List<CustomerFollowRecordsVo> records = page.getRecords();
+        //赋值文件列表信息
+        List<Long> ids = records.stream().map(CustomerFollowRecordsVo::getId).filter(ObjectUtil::isNotNull).distinct().collect(Collectors.toList());
+        if (ObjectUtil.isNotEmpty(ids)) {
+            DynamicDataSourceContextHolder.push(SourceConstant.BASE);
+            Map<Long, List<FileInfo>> longListMap = fileInfoService.mapKGroup(FileInfo::getBusinessId, q -> q.in(FileInfo::getBusinessId, ids));
+            for (CustomerFollowRecordsVo record : records) {
+                List<ObsFile> obsFiles = BeanUtil.copyToList(longListMap.get(record.getId()), ObsFile.class);
+                record.setFileList(obsFiles);
+            }
+        }
+
         return page;
     }
 
     @Override
+    public List<CustomerFollowRecordsVo> followList(Long customerId){
+        if(ObjectUtil.isEmpty(customerId)){
+            throw new ServiceException("客户id不能为空");
+        }
+        List<CustomerFollowRecords> customerFollowRecords = list(q->q.eq(CustomerFollowRecords::getCustomerId,customerId)
+                .orderByDesc(CustomerFollowRecords::getDate));
+        List<CustomerFollowRecordsVo> customerFollowRecordsVos = BeanUtil.copyToList(customerFollowRecords, CustomerFollowRecordsVo.class);
+        //赋值文件列表信息
+        List<Long> ids = customerFollowRecordsVos.stream().map(CustomerFollowRecordsVo::getId).filter(ObjectUtil::isNotNull).distinct().collect(Collectors.toList());
+        if (ObjectUtil.isNotEmpty(ids)) {
+            DynamicDataSourceContextHolder.push(SourceConstant.BASE);
+            Map<Long, List<FileInfo>> longListMap = fileInfoService.mapKGroup(FileInfo::getBusinessId, q -> q.in(FileInfo::getBusinessId, ids));
+            for (CustomerFollowRecordsVo record : customerFollowRecordsVos) {
+                List<ObsFile> obsFiles = BeanUtil.copyToList(longListMap.get(record.getId()), ObsFile.class);
+                record.setFileList(obsFiles);
+            }
+        }
+        return customerFollowRecordsVos;
+    }
+
+    @Override
     public CustomerFollowRecordsVo detail(Long id) {
         CustomerFollowRecords CustomerFollowRecords = this.getById(id);
         CustomerFollowRecordsVo result = BeanUtil.toBean(CustomerFollowRecords, CustomerFollowRecordsVo.class);
@@ -47,14 +94,14 @@ public class CustomerFollowRecordsServiceImpl extends ServiceImpl<CustomerFollow
     @Override
     public void add(CustomerFollowRecordsDto customerFollowRecordsDto) {
         this.save(customerFollowRecordsDto);
-        ObsFileUtil.saveFile(customerFollowRecordsDto.getFileList(),customerFollowRecordsDto.getId());
+        ObsFileUtil.saveFile(customerFollowRecordsDto.getFileList(), customerFollowRecordsDto.getId());
     }
 
     @DSTransactional
     @Override
     public void edit(CustomerFollowRecordsDto customerFollowRecordsDto) {
         this.updateById(customerFollowRecordsDto);
-        ObsFileUtil.editFile(customerFollowRecordsDto.getFileList(),customerFollowRecordsDto.getId());
+        ObsFileUtil.editFile(customerFollowRecordsDto.getFileList(), customerFollowRecordsDto.getId());
     }
 
     @DSTransactional

+ 17 - 3
hx-customer/src/main/java/com/fjhx/customer/service/customer/impl/CustomerServiceImpl.java

@@ -79,9 +79,12 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
         List<Long> customerIds = records.stream().map(Customer::getId).collect(Collectors.toList());
         if (ObjectUtil.isNotEmpty(customerIds)) {
             Map<Long, List<CustomerFollowRecords>> longListMap = customerFollowRecordsService.mapKGroup(CustomerFollowRecords::getCustomerId,
-                    q -> q.in(CustomerFollowRecords::getCustomerId, customerIds));
+                    q -> q.in(CustomerFollowRecords::getCustomerId, customerIds).orderByDesc(CustomerFollowRecords::getDate));
             for (CustomerVo record : records) {
-                record.setCustomerFollowRecordsList(longListMap.get(record.getId()));
+                List<CustomerFollowRecords> customerFollowRecords = longListMap.get(record.getId());
+                if (ObjectUtil.isNotEmpty(customerFollowRecords)) {
+                    record.setCustomerFollowRecordsList(customerFollowRecords.subList(0, 2));
+                }
             }
         }
         return page;
@@ -178,7 +181,10 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
             Map<Long, List<CustomerFollowRecords>> longListMap = customerFollowRecordsService.mapKGroup(CustomerFollowRecords::getCustomerId,
                     q -> q.in(CustomerFollowRecords::getCustomerId, customerIds));
             for (CustomerVo record : records) {
-                record.setCustomerFollowRecordsList(longListMap.get(record.getId()));
+                List<CustomerFollowRecords> customerFollowRecords = longListMap.get(record.getId());
+                if (ObjectUtil.isNotEmpty(customerFollowRecords)) {
+                    record.setCustomerFollowRecordsList(customerFollowRecords.subList(0, 2));
+                }
             }
         }
         return page;
@@ -214,5 +220,13 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
         customerUserService.saveBatch(customerUserDtoList);
     }
 
+    /**
+     * 修改客户标签
+     */
+    @Override
+    public void editTag(CustomerDto customerDto) {
+        this.updateById(customerDto);
+    }
+
 
 }

+ 5 - 0
hx-purchase/src/main/java/com/fjhx/purchase/entity/purchase/po/Purchase.java

@@ -110,4 +110,9 @@ public class Purchase extends BasePo {
      * 维多利亚扩展json
      */
     private String victoriatouristJson;
+
+    /**
+     * 流程实例
+     */
+    private Long flowId;
 }

+ 1 - 0
hx-sale/src/main/java/com/fjhx/sale/flow/PurchaseFlow.java

@@ -61,6 +61,7 @@ public class PurchaseFlow extends FlowDelegate {
         Purchase purchase = submitData.toJavaObject(Purchase.class);
         purchase.setCode(CodeEnum.PURCHASE.getCode());
         purchase.setPurchaseStatus(PurchaseStatusEnum.UNDER_REVIEW.getKey());
+        purchase.setFlowId(flowId);
         purchaseService.save(purchase);
         List<PurchaseDetail> purchaseDetailList = purchase.getPurchaseDetailList();
         if(CollectionUtils.isNotEmpty(purchaseDetailList)){

+ 15 - 0
hx-sale/src/main/java/com/fjhx/sale/flow/PurchaseFlowByWdly.java

@@ -74,11 +74,26 @@ public class PurchaseFlowByWdly extends FlowDelegate {
             Purchase purchase = submitData.toJavaObject(Purchase.class);
             purchase.setCode(CodeEnum.PURCHASE.getCode());
             purchase.setPurchaseStatus(PurchaseStatusEnum.UNDER_REVIEW.getKey());
+            purchase.setFlowId(flowId);
             purchaseService.save(purchase);
             List<PurchaseDetail> purchaseDetailList = purchase.getPurchaseDetailList();
             if (CollectionUtils.isNotEmpty(purchaseDetailList)) {
                 for (PurchaseDetail s : purchaseDetailList) {
                     s.setPurchaseId(purchase.getId());
+                    //计算采购数量是否大于申购数量
+                    List<PurchaseDetail> purchaseDetailList1 = purchaseDetailService.list(q -> q.eq(PurchaseDetail::getSubscribeDetailId,
+                            s.getSubscribeDetailId()));
+                    //求和
+                    BigDecimal purchaseCount = purchaseDetailList1.stream()
+                            .map(PurchaseDetail::getCount)
+                            .reduce(BigDecimal.ZERO, BigDecimal::add);
+                    //计算历史采购数量+本次采购数量之和
+                    BigDecimal count = purchaseCount.add(s.getCount());
+                    //判断采购数量是否大于申购数量
+                    SubscribeDetail subscribeDetail = subscribeDetailService.getById(s.getSubscribeDetailId());
+                    if (count.compareTo(subscribeDetail.getCount()) > 0) {
+                        throw new ServiceException("采购数量不能大于申购数量");
+                    }
                 }
                 purchaseDetailService.saveBatch(purchaseDetailList);
             }