Merge branch 'dev' of http://git.znkjfw.com/ak/zn-cloud into frx
# Conflicts: # yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/oa/BpmOAContractMapper.java
This commit is contained in:
commit
d726cc5abb
@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
||||
@Tag(name = "RPC 服务 - 流程实例")
|
||||
|
@ -24,7 +24,7 @@ import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUti
|
||||
*/
|
||||
@RestController
|
||||
@Validated
|
||||
public class BpmOAContractApiImpl implements BpmOAContractApi{
|
||||
public class BpmOAContractApiImpl implements BpmOAContractApi {
|
||||
|
||||
@Resource
|
||||
private BpmOAContractService contractService;
|
||||
|
@ -18,7 +18,6 @@ import java.util.Objects;
|
||||
* 合同审批 Mapper
|
||||
*
|
||||
* @author 符溶馨
|
||||
|
||||
*/
|
||||
@Mapper
|
||||
public interface BpmOAContractMapper extends BaseMapperX<BpmOAContractDO> {
|
||||
|
@ -18,7 +18,7 @@ public interface BpmOAContractService {
|
||||
/**
|
||||
* 创建合同申请
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param userId 用户编号
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
@ -26,21 +26,23 @@ public interface BpmOAContractService {
|
||||
|
||||
/**
|
||||
* 更新合同
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateContract(BpmOAContractDO updateReqVO);
|
||||
|
||||
/**
|
||||
* 修改开票金额
|
||||
*
|
||||
* @param contractId 合同编号
|
||||
* @param amount 开票金额
|
||||
* @param amount 开票金额
|
||||
*/
|
||||
void updateInvoiceMoney(Long contractId, BigDecimal amount);
|
||||
|
||||
/**
|
||||
* 更新合同申请的状态
|
||||
*
|
||||
* @param id 编号
|
||||
* @param id 编号
|
||||
* @param result 结果
|
||||
*/
|
||||
void updateContractResult(String processInstanceId, Long id, Integer result);
|
||||
@ -55,6 +57,7 @@ public interface BpmOAContractService {
|
||||
|
||||
/**
|
||||
* 获得指定合同申请
|
||||
*
|
||||
* @param processInstanceId 流程实例编号
|
||||
* @return 出差申请
|
||||
*/
|
||||
@ -62,6 +65,7 @@ public interface BpmOAContractService {
|
||||
|
||||
/**
|
||||
* 获取当前用户所在部门的合同列表
|
||||
*
|
||||
* @param userIds 用户编号集合
|
||||
* @return 合同列表
|
||||
*/
|
||||
@ -69,6 +73,7 @@ public interface BpmOAContractService {
|
||||
|
||||
/**
|
||||
* 获得合同分页
|
||||
*
|
||||
* @param pageReqVO 分页参数
|
||||
* @return 分页列表
|
||||
*/
|
||||
@ -76,6 +81,7 @@ public interface BpmOAContractService {
|
||||
|
||||
/**
|
||||
* 获得指定流程实例的合同申请列表
|
||||
*
|
||||
* @param processInstanceIds 流程实例编号集合
|
||||
* @return 合同列表
|
||||
*/
|
||||
@ -83,7 +89,8 @@ public interface BpmOAContractService {
|
||||
|
||||
/**
|
||||
* 获得合同统计信息
|
||||
* @param userId 用户编号
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param relation 查询类型
|
||||
* @return 统计信息
|
||||
*/
|
||||
@ -100,6 +107,7 @@ public interface BpmOAContractService {
|
||||
|
||||
/**
|
||||
* 获得合同列表
|
||||
*
|
||||
* @param respVO 参数列表
|
||||
* @return 合同列表
|
||||
*/
|
||||
@ -107,6 +115,7 @@ public interface BpmOAContractService {
|
||||
|
||||
/**
|
||||
* 获得指定客户合同列表
|
||||
*
|
||||
* @param customerId 客户编号
|
||||
* @return 合同列表
|
||||
*/
|
||||
|
@ -63,12 +63,11 @@ import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PRODUCT_S
|
||||
* OA 合同审批 Service 实现类
|
||||
*
|
||||
* @author 符溶馨
|
||||
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class BpmOAContractServiceImpl extends BpmOABaseService implements BpmOAContractService{
|
||||
public class BpmOAContractServiceImpl extends BpmOABaseService implements BpmOAContractService {
|
||||
|
||||
/**
|
||||
* OA 合同审批对应的流程定义 KEY
|
||||
@ -134,7 +133,7 @@ public class BpmOAContractServiceImpl extends BpmOABaseService implements BpmOAC
|
||||
no = "HT" + now + String.format("%03d", Integer.parseInt(no) + 1);
|
||||
// redis 缓存订单号
|
||||
stringRedisTemplate.opsForValue().increment(key, 1);
|
||||
}else {
|
||||
} else {
|
||||
no = "HT" + now + String.format("%03d", 1);
|
||||
// redis 缓存订单号
|
||||
stringRedisTemplate.opsForValue().set(key, "1", 1, TimeUnit.DAYS);
|
||||
@ -148,7 +147,7 @@ public class BpmOAContractServiceImpl extends BpmOABaseService implements BpmOAC
|
||||
}
|
||||
|
||||
//插入OA 合同审批
|
||||
contractMapper.insert(contract) ;
|
||||
contractMapper.insert(contract);
|
||||
|
||||
// 发起 BPM 流程
|
||||
Map<String, Object> processInstanceVariables = new HashMap<>();
|
||||
@ -165,10 +164,10 @@ public class BpmOAContractServiceImpl extends BpmOABaseService implements BpmOAC
|
||||
historyProcessInstanceService.createHistoryProcessInstance(processInstanceId, createReqVO.getProcessInstanceId());
|
||||
}
|
||||
|
||||
List<UploadUserFile> fileItems = createReqVO.getFileItems() ;
|
||||
List<UploadUserFile> fileItems = createReqVO.getFileItems();
|
||||
//这里的逻辑,如果fileItems不为空,且有数据,那么说明是上传了附件的,则需要更工作流文件表对应的实例Id
|
||||
if (fileItems != null && !fileItems.isEmpty()) {
|
||||
uploadBpmFileProcessInstanceId(processInstanceId,fileItems) ;
|
||||
uploadBpmFileProcessInstanceId(processInstanceId, fileItems);
|
||||
}
|
||||
|
||||
// 同步插入关联产品记录
|
||||
@ -328,7 +327,7 @@ public class BpmOAContractServiceImpl extends BpmOABaseService implements BpmOAC
|
||||
@Override
|
||||
public List<BpmOAContractDO> getContractList(BpmOAContractVO respVO) {
|
||||
|
||||
Date[] dateArray = new Date[] { respVO.getStarTime(), respVO.getEndTime() };
|
||||
Date[] dateArray = new Date[]{respVO.getStarTime(), respVO.getEndTime()};
|
||||
|
||||
return contractMapper.selectList(new LambdaQueryWrapperX<BpmOAContractDO>()
|
||||
.inIfPresent(BpmOAContractDO::getUserId, respVO.getUserId())
|
||||
|
@ -11,7 +11,8 @@ import lombok.Getter;
|
||||
@AllArgsConstructor
|
||||
public enum FlowStepEnum {
|
||||
TYPE_2(2,"指定人员"),
|
||||
TYPE_3(3,"指定部门");
|
||||
TYPE_3(3,"指定部门"),
|
||||
TYPE_4(4,"下属");
|
||||
|
||||
private Integer value;
|
||||
private String desc;
|
||||
|
@ -83,7 +83,8 @@ public class CrmAchievementController {
|
||||
@Operation(summary = "业绩目标统计")
|
||||
public CommonResult<AchieveCountRespVO> getAchievementCount(@RequestParam(name = "type", required = false) Integer type,
|
||||
@RequestParam(name = "month", required = false) Integer month,
|
||||
@RequestParam(name = "year", required = false) Integer year) {
|
||||
return success(achievementService.getCount(type, year, month));
|
||||
@RequestParam(name = "year", required = false) Integer year,
|
||||
@RequestParam(name = "userId", required = false) Long userId) {
|
||||
return success(achievementService.getCount(type, year, month, userId));
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.crmanalysis.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.product.api.storeproductattrvalue.vo.UserProductCountVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 用户业绩分析信息 Response VO")
|
||||
@Data
|
||||
@ -15,6 +17,9 @@ public class UserAchieveVO {
|
||||
@Schema(description = "用户名称")
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "产品数量")
|
||||
private Integer productCount;
|
||||
|
||||
@Schema(description = "合同数量")
|
||||
private Long contractCount;
|
||||
|
||||
@ -33,4 +38,7 @@ public class UserAchieveVO {
|
||||
@Schema(description = "转客比率")
|
||||
private String cluesToCustomerPer;
|
||||
|
||||
@Schema(description = "产品列表")
|
||||
private List<UserProductCountVO> productCountList;
|
||||
|
||||
}
|
||||
|
@ -25,10 +25,10 @@ public class CrmIndexController {
|
||||
|
||||
@GetMapping("/getCount")
|
||||
@Operation(summary = "首页统计")
|
||||
public CommonResult<CrmIndexRespVO> getCount(@RequestParam(name = "relation",defaultValue = "my",required=false) String relation) {
|
||||
return success(crmIndexService.getIndexCount(relation));
|
||||
public CommonResult<CrmIndexRespVO> getCount(@RequestParam(name = "relation", defaultValue = "my", required = false) String relation,
|
||||
@RequestParam(name = "userId", required = false) Long userId) {
|
||||
return success(crmIndexService.getIndexCount(relation, userId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -8,10 +8,12 @@ import cn.iocoder.yudao.module.crm.controller.admin.crmanalysis.vo.ContractVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.crmcontract.vo.CrmContractPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.crmcontract.vo.CrmContractRespVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.crmcontract.CrmContractDO;
|
||||
import cn.iocoder.yudao.module.product.api.storeproductattrvalue.vo.UserProductCountVO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -54,4 +56,11 @@ public interface CrmContractMapper extends BaseMapperX<CrmContractDO> {
|
||||
|
||||
List<ContractVO> selectContractTop();
|
||||
|
||||
/**
|
||||
* 获取用户合同产品数量
|
||||
* @param userIds
|
||||
* @param createTime
|
||||
* @return
|
||||
*/
|
||||
List<UserProductCountVO> getProductCount(@Param("userIds") List<Long> userIds, @Param("createTime") LocalDateTime[] createTime);
|
||||
}
|
||||
|
@ -70,6 +70,6 @@ public interface CrmAchievementService {
|
||||
* @param month 月份
|
||||
* @return
|
||||
*/
|
||||
AchieveCountRespVO getCount(Integer type, Integer year, Integer month);
|
||||
AchieveCountRespVO getCount(Integer type, Integer year, Integer month, Long userId);
|
||||
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import cn.iocoder.yudao.module.bpm.api.oa.vo.receipt.BpmOAReceiptVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.crmachievement.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.crmachievement.CrmAchievementDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.crmachievement.CrmAchievementMapper;
|
||||
import cn.iocoder.yudao.module.crm.service.userlivetree.UserLiveTreeService;
|
||||
import cn.iocoder.yudao.module.hrm.enums.FlowStepEnum;
|
||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
@ -64,6 +65,8 @@ public class CrmAchievementServiceImpl implements CrmAchievementService {
|
||||
|
||||
@Resource
|
||||
private BpmOAReceiptApi receiptApi;
|
||||
@Resource
|
||||
private UserLiveTreeService userLiveTreeService;
|
||||
|
||||
|
||||
@Override
|
||||
@ -147,7 +150,8 @@ public class CrmAchievementServiceImpl implements CrmAchievementService {
|
||||
|
||||
/**
|
||||
* 批量插入操作
|
||||
* @param createReqVO 更新信息
|
||||
*
|
||||
* @param createReqVO 更新信息
|
||||
* @param achievements 更新信息
|
||||
*/
|
||||
private void saveAchievementBatch(DeptAchieveSaveVO createReqVO, List<CrmAchievementDO> achievements) {
|
||||
@ -160,7 +164,7 @@ public class CrmAchievementServiceImpl implements CrmAchievementService {
|
||||
if (CollectionUtil.isEmpty(achievementOld)) {
|
||||
|
||||
achievementMapper.insertBatch(achievements);
|
||||
}else {
|
||||
} else {
|
||||
|
||||
// 获取之前业绩数据Map
|
||||
Map<Long, CrmAchievementDO> oldMap = convertMap(achievementOld, CrmAchievementDO::getTypeId);
|
||||
@ -282,7 +286,7 @@ public class CrmAchievementServiceImpl implements CrmAchievementService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AchieveCountRespVO getCount(Integer type, Integer year, Integer month) {
|
||||
public AchieveCountRespVO getCount(Integer type, Integer year, Integer month, Long userId) {
|
||||
|
||||
// 获取当前登录用户编号
|
||||
List<Long> userIds = new ArrayList<>();
|
||||
@ -290,7 +294,7 @@ public class CrmAchievementServiceImpl implements CrmAchievementService {
|
||||
|
||||
if (FlowStepEnum.TYPE_2.getValue().equals(type)) {
|
||||
userIds.add(typeId);
|
||||
} else {
|
||||
} else if (FlowStepEnum.TYPE_3.getValue().equals(type)) {
|
||||
//部门
|
||||
String deptId = Objects.requireNonNull(SecurityFrameworkUtils.getLoginUser()).getInfo().get(SecurityFrameworkUtils.INFO_KEY_DEPT_ID);
|
||||
typeId = deptId == null ? null : Long.valueOf(deptId);
|
||||
@ -299,6 +303,13 @@ public class CrmAchievementServiceImpl implements CrmAchievementService {
|
||||
adminUserDOS = adminUserApi.getUserList(new AdminUserApiDTO().setDeptId(typeId).setNextDept(1)).getCheckedData();
|
||||
}
|
||||
userIds = adminUserDOS.stream().map(AdminUserApiVO::getId).collect(Collectors.toList());
|
||||
} else {
|
||||
if (userId != null) {
|
||||
userIds.add(userId);
|
||||
} else {
|
||||
//下属
|
||||
userIds = userLiveTreeService.getItemIdsByUserId(typeId);
|
||||
}
|
||||
}
|
||||
Date starTime = new Date();
|
||||
Date endTime = new Date();
|
||||
|
@ -30,10 +30,12 @@ import cn.iocoder.yudao.module.crm.dal.mysql.crmcontract.CrmContractMapper;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.crmcontractreceivables.CrmContractReceivablesMapper;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.crmcustomer.CrmCustomerMapper;
|
||||
import cn.iocoder.yudao.module.crm.service.crmclues.CrmCluesService;
|
||||
import cn.iocoder.yudao.module.crm.service.crmcontract.CrmContractService;
|
||||
import cn.iocoder.yudao.module.crm.service.userlivetree.UserLiveTreeService;
|
||||
import cn.iocoder.yudao.module.hrm.enums.ContractStatusEnum;
|
||||
import cn.iocoder.yudao.module.hrm.enums.FlowStepEnum;
|
||||
import cn.iocoder.yudao.module.hrm.enums.RelationEnum;
|
||||
import cn.iocoder.yudao.module.product.api.storeproductattrvalue.vo.UserProductCountVO;
|
||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptApiDTO;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptApiVO;
|
||||
@ -87,7 +89,8 @@ public class AchievementServiceImpl implements AchievementService {
|
||||
private BpmOAReceiptApi receiptApi;
|
||||
@Resource
|
||||
private UserLiveTreeService userLiveTreeService;
|
||||
|
||||
@Resource
|
||||
private CrmContractService contractService;
|
||||
|
||||
@Override
|
||||
public PageResult<UserAchieveVO> getAchievementPage(AchievementPageReqVO pageReqVO) {
|
||||
@ -118,8 +121,13 @@ public class AchievementServiceImpl implements AchievementService {
|
||||
List<CrmCluesStatisticsRespVO> cluesStatisticsRespVOS = cluesService.getCluesStatisticsByUserIds(userIds, pageReqVO.getCreateTime());
|
||||
Map<Long, CrmCluesStatisticsRespVO> clusesMap = convertMap(cluesStatisticsRespVOS, CrmCluesStatisticsRespVO::getOwnerUserId);
|
||||
|
||||
pageResult1.getList().forEach(v -> {
|
||||
// 统计用户产品数量
|
||||
List<UserProductCountVO> userProductCountVOS = contractService.getProductCount(userIds, pageReqVO.getCreateTime());
|
||||
// -- 根据用户分组 -
|
||||
Map<Long, List<UserProductCountVO>> userProductCount = userProductCountVOS.stream()
|
||||
.collect(Collectors.groupingBy(UserProductCountVO::getUserId));
|
||||
|
||||
pageResult1.getList().forEach(v -> {
|
||||
String per = "0";
|
||||
// 设置合同数量
|
||||
v.setContractCount(contractMap.get(v.getId()) != null ? Long.valueOf(contractMap.get(v.getId()).getCount()) : 0L);
|
||||
@ -131,6 +139,11 @@ public class AchievementServiceImpl implements AchievementService {
|
||||
v.setCluesCount(clusesMap.get(v.getId()) != null ? Long.valueOf(clusesMap.get(v.getId()).getCount()) : 0L);
|
||||
// 设置转客数量
|
||||
v.setCluesToCustomerCount(clusesMap.get(v.getId()) != null ? Long.valueOf(clusesMap.get(v.getId()).getSuccessCount()) : 0L);
|
||||
// 产品列表
|
||||
v.setProductCountList(userProductCount.getOrDefault(v.getId(), Collections.emptyList()));
|
||||
// 产品数量
|
||||
int sum = v.getProductCountList().stream().mapToInt(UserProductCountVO::getNums).sum();
|
||||
v.setProductCount(sum);
|
||||
// 设置转客比率
|
||||
if (v.getCluesCount() > 0) {
|
||||
per = NumberUtil.round(NumberUtil.div(v.getCluesToCustomerCount(), v.getCluesCount()), 2)
|
||||
|
@ -6,9 +6,12 @@ import cn.iocoder.yudao.module.crm.controller.admin.crmcontract.vo.CrmContractPa
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.crmcontract.vo.CrmContractRespVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.crmcontract.vo.CrmContractSaveReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.crmcontract.CrmContractProductDO;
|
||||
import cn.iocoder.yudao.module.product.api.storeproductattrvalue.vo.UserProductCountVO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 合同 Service 接口
|
||||
@ -67,20 +70,32 @@ public interface CrmContractService {
|
||||
|
||||
/**
|
||||
* 生成合同编号
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getCode();
|
||||
|
||||
/**
|
||||
* 审核合同
|
||||
*
|
||||
* @param checkInfoVO
|
||||
*/
|
||||
void check(CheckInfoVO checkInfoVO);
|
||||
|
||||
/**
|
||||
* 创建合同产品
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
void createProduct(List<CrmContractProductDO> createReqVO);
|
||||
|
||||
/**
|
||||
* 获取用户合同产品数量
|
||||
*
|
||||
* @param userIds
|
||||
* @param createTime
|
||||
* @return
|
||||
*/
|
||||
List<UserProductCountVO> getProductCount(List<Long> userIds, LocalDateTime[] createTime);
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ import cn.iocoder.yudao.module.crm.dal.mysql.crmcustomercontacts.CrmCustomerCont
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.crmflow.CrmFlowMapper;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.crmflow.CrmFlowStepMapper;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.crmflowlog.CrmFlowLogMapper;
|
||||
import cn.iocoder.yudao.module.crm.service.crmoperatelog.CrmOperatelogService;
|
||||
import cn.iocoder.yudao.module.crm.service.userlivetree.UserLiveTreeService;
|
||||
import cn.iocoder.yudao.module.hrm.enums.ContractStatusEnum;
|
||||
import cn.iocoder.yudao.module.hrm.enums.FlowStepEnum;
|
||||
@ -42,10 +41,12 @@ import cn.iocoder.yudao.module.product.api.storeproduct.StoreProductApi;
|
||||
import cn.iocoder.yudao.module.product.api.storeproductattrvalue.StoreProductAttrValueApi;
|
||||
import cn.iocoder.yudao.module.product.api.storeproductattrvalue.dto.StoreProductAttrValueApiDTO;
|
||||
import cn.iocoder.yudao.module.product.api.storeproductattrvalue.vo.StoreProductAttrValueApiVO;
|
||||
import cn.iocoder.yudao.module.product.api.storeproductattrvalue.vo.UserProductCountVO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserApiDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserApiVO;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.workovertime.vo.WorkOvertimeRuleItemApiVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -58,11 +59,9 @@ import org.springframework.validation.annotation.Validated;
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@ -397,6 +396,11 @@ public class CrmContractServiceImpl implements CrmContractService {
|
||||
contractProductMapper.insertBatch(createReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserProductCountVO> getProductCount(List<Long> userIds, LocalDateTime[] createTime) {
|
||||
return contractMapper.getProductCount(userIds, createTime);
|
||||
}
|
||||
|
||||
private void createContractProductList(Long contractId, List<CrmContractProductDO> list) {
|
||||
List<StoreProductAttrValueApiVO> storeProductAttrValueList = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
|
@ -9,6 +9,6 @@ import cn.iocoder.yudao.module.crm.controller.admin.crmindex.vo.CrmIndexRespVO;
|
||||
*/
|
||||
public interface CrmIndexService {
|
||||
|
||||
CrmIndexRespVO getIndexCount(String relation);
|
||||
CrmIndexRespVO getIndexCount(String relation,Long userId);
|
||||
|
||||
}
|
||||
|
@ -71,47 +71,9 @@ public class CrmIndexServiceImpl implements CrmIndexService {
|
||||
|
||||
|
||||
@Override
|
||||
public CrmIndexRespVO getIndexCount(String relation) {
|
||||
// Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
||||
// Date todayStart = DateUtil.beginOfDay(new Date());
|
||||
// Date todayEnd = DateUtil.endOfDay(new Date());
|
||||
// Date day30 = DateUtil.offsetDay(new Date(),30);
|
||||
//
|
||||
// Long followCustomerCount = customerMapper.selectCount(new LambdaQueryWrapper<CrmCustomerDO>()
|
||||
// .between(CrmCustomerDO::getNextTime,todayStart,todayEnd).eq(CrmCustomerDO::getOwnerUserId,loginUserId));
|
||||
// Long followBusinessCount = businessMapper.selectCount(new LambdaQueryWrapper<CrmBusinessDO>()
|
||||
// .between(CrmBusinessDO::getNextTime,todayStart,todayEnd).eq(CrmBusinessDO::getOwnerUserId,loginUserId));
|
||||
// Long followCluesCount = crmCluesMapper.selectCount(new LambdaQueryWrapper<CrmCluesDO>()
|
||||
// .between(CrmCluesDO::getNextTime,todayStart,todayEnd).eq(CrmCluesDO::getOwnerUserId,loginUserId));
|
||||
// Long contractDueCount = contractMapper.selectCount(new LambdaQueryWrapper<CrmContractDO>()
|
||||
// .between(CrmContractDO::getEndTime,todayStart,day30).eq(CrmContractDO::getOwnerUserId,loginUserId));
|
||||
// Long customerDueCount = 0L;
|
||||
// Long contractReturnCount = contractMapper.selectCount(new LambdaQueryWrapper<CrmContractDO>()
|
||||
// .eq(CrmContractDO::getOwnerUserId,loginUserId).apply("money > return_money"));
|
||||
// Long myInvoiceCount = crmInvoiceMapper.selectCount(new LambdaQueryWrapper<CrmInvoiceDO>()
|
||||
// .eq(CrmInvoiceDO::getCreator,loginUserId));
|
||||
// Long productCount = storeProductMapper.selectCount();
|
||||
//
|
||||
// Long contractCheckCount = contractMapper.selectCount(new LambdaQueryWrapper<CrmContractDO>()
|
||||
// .apply( "FIND_IN_SET ('" + loginUserId + "',flow_admin_id)"));
|
||||
// Long receivablesCheckCount = contractReceivablesMapper.selectCount(new LambdaQueryWrapper<CrmContractReceivablesDO>()
|
||||
// .apply( "FIND_IN_SET ('" + loginUserId + "',flow_admin_id)"));
|
||||
// Long invoiceCheckCount = crmInvoiceMapper.selectCount(new LambdaQueryWrapper<CrmInvoiceDO>()
|
||||
// .apply( "FIND_IN_SET ('" + loginUserId + "',flow_admin_id)"));
|
||||
|
||||
public CrmIndexRespVO getIndexCount(String relation, Long userId) {
|
||||
return CrmIndexRespVO.builder()
|
||||
// .followCustomerCount(followCustomerCount)
|
||||
// .followBusinessCount(followBusinessCount)
|
||||
// .followCluesCount(followCluesCount)
|
||||
// .contractDueCount(contractDueCount)
|
||||
// .customerDueCount(customerDueCount)
|
||||
// .contractReturnCount(contractReturnCount)
|
||||
// .myInvoiceCount(myInvoiceCount)
|
||||
// .productCount(productCount)
|
||||
// .contractCheckCount(contractCheckCount)
|
||||
// .receivablesCheckCount(receivablesCheckCount)
|
||||
// .invoiceCheckCount(invoiceCheckCount)
|
||||
.brieCountVO(getBrieCount(relation))
|
||||
.brieCountVO(getBrieCount(relation, userId))
|
||||
.build();
|
||||
}
|
||||
|
||||
@ -120,7 +82,7 @@ public class CrmIndexServiceImpl implements CrmIndexService {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private BrieCountVO getBrieCount(String relation) {
|
||||
private BrieCountVO getBrieCount(String relation, Long userId) {
|
||||
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
||||
Date todayStart = DateUtil.beginOfDay(new Date());
|
||||
Date todayEnd = DateUtil.endOfDay(new Date());
|
||||
@ -133,7 +95,11 @@ public class CrmIndexServiceImpl implements CrmIndexService {
|
||||
if (RelationEnum.MY.getValue().equals(relation)) {
|
||||
ids.add(adminId);
|
||||
} else if (RelationEnum.SUB.getValue().equals(relation)) {
|
||||
ids = userLiveTreeService.getItemIdsByUserId(adminId);
|
||||
if (userId != null) {
|
||||
ids.add(userId);
|
||||
} else {
|
||||
ids = userLiveTreeService.getItemIdsByUserId(adminId);
|
||||
}
|
||||
}
|
||||
|
||||
Long count01 = businessMapper.selectCount(new LambdaQueryWrapper<CrmBusinessDO>()
|
||||
|
@ -81,4 +81,37 @@
|
||||
money DESC
|
||||
LIMIT 10
|
||||
</select>
|
||||
<select id="getProductCount"
|
||||
resultType="cn.iocoder.yudao.module.product.api.storeproductattrvalue.vo.UserProductCountVO">
|
||||
select
|
||||
a.owner_user_id as userId,
|
||||
b.nums AS nums,
|
||||
b.product_id as productId,
|
||||
b.name as name,
|
||||
b.product_attr_unique as productAttrUnique,
|
||||
b.price as price,
|
||||
b.discount as discount,
|
||||
b.subtotal as subtotal,
|
||||
b.remarks as remarks
|
||||
from crm_contract as a
|
||||
left join crm_contract_product as b on a.id = b.contract_id
|
||||
<where>
|
||||
a.deleted = 0
|
||||
and b.deleted = 0
|
||||
<if test="userIds != null and userIds.size() > 0">
|
||||
AND a.owner_user_id in
|
||||
<foreach collection="userIds" item="id" index="index" open="(" close=")" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="createTime != null and createTime.length > 0">
|
||||
<if test="createTime[0] != null">
|
||||
and a.create_time >= #{createTime[0]}
|
||||
</if>
|
||||
<if test="createTime[1] != null">
|
||||
and a.create_time <= #{createTime[1]}
|
||||
</if>
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.module.product.api.storeproductattrvalue.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class UserProductCountVO {
|
||||
@Schema(description = "用户编号")
|
||||
private Long userId;
|
||||
@Schema(description = "产品数量")
|
||||
private Integer nums;
|
||||
@Schema(description = "产品id")
|
||||
private Long productId;
|
||||
@Schema(description = "产品名称")
|
||||
private String name;
|
||||
@Schema(description = "商品属性")
|
||||
private String productAttrUnique;
|
||||
@Schema(description = "产品单价")
|
||||
private BigDecimal price;
|
||||
@Schema(description = "折扣")
|
||||
private BigDecimal discount;
|
||||
@Schema(description = "小计(折扣后价格)")
|
||||
private BigDecimal subtotal;
|
||||
@Schema(description = "备注")
|
||||
private String remarks;
|
||||
}
|
@ -281,9 +281,11 @@ public class HolidayUserRecordServiceImpl implements HolidayUserRecordService {
|
||||
String year = String.valueOf(now.getYear());
|
||||
newHolidayUserDOList.forEach(
|
||||
a -> {
|
||||
newHolidayUserEmploymentRecordDOList.add(new HolidayUserEmploymentRecordDO().setUserId(a.getUserId())
|
||||
.setHolidaySettingId(holidaySetting.getId())
|
||||
.setYearNum(year));
|
||||
if (BigDecimal.ZERO.compareTo(a.getHolidayBalance()) > 0) {
|
||||
newHolidayUserEmploymentRecordDOList.add(new HolidayUserEmploymentRecordDO().setUserId(a.getUserId())
|
||||
.setHolidaySettingId(holidaySetting.getId())
|
||||
.setYearNum(year));
|
||||
}
|
||||
}
|
||||
);
|
||||
if (CollUtil.isNotEmpty(newHolidayUserEmploymentRecordDOList)) {
|
||||
@ -300,6 +302,7 @@ public class HolidayUserRecordServiceImpl implements HolidayUserRecordService {
|
||||
List<AdminUserDO> users = this.getUsersByRange(holidaySetting, holidaySettingRangeDOS);
|
||||
// -- 计算获取每个人的假期额度
|
||||
Map<Long, BigDecimal> userQuotaMap = this.getQuotaMap(users, holidayBalanceSettingDO, holidayWorkingAgeDOS);
|
||||
log.info("计算获取每个人的假期额度 userQuotaMap:{}", userQuotaMap);
|
||||
// -- 获取用户的假期表
|
||||
List<Long> userIds = users.stream().map(AdminUserDO::getId).collect(Collectors.toList());
|
||||
Map<Long, AdminUserDO> userMap = users.stream().collect(Collectors.toMap(AdminUserDO::getId, a -> a));
|
||||
@ -434,6 +437,7 @@ public class HolidayUserRecordServiceImpl implements HolidayUserRecordService {
|
||||
LocalDateTime now, String remark, Integer direction, String reason, Boolean recordZero) {
|
||||
BigDecimal quota = userQuotaMap.get(userId);
|
||||
// -- 如果是0的话就不记录了 -- 如果不记录0 并且是0 直接return
|
||||
log.info("假期额度分配数量quota为:{},recordZero为:{}", quota, recordZero);
|
||||
if (quota == null || (BigDecimal.ZERO.compareTo(quota) == 0 && !recordZero)) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user