统计修改
This commit is contained in:
parent
79a441234f
commit
66bd0f7991
@ -297,4 +297,7 @@ public class PsContractInfoVo implements Serializable {
|
||||
|
||||
private PsContractCountVo psContractCountVo;
|
||||
|
||||
private long countNum;
|
||||
private BigDecimal sumAmount;
|
||||
|
||||
}
|
||||
|
@ -27,12 +27,26 @@ public class OldOrNewCusContractCountVo {
|
||||
private Long oldContractNum;
|
||||
|
||||
/**
|
||||
* 新客户 新签 占比
|
||||
* 新客户 新签 金额
|
||||
*/
|
||||
private BigDecimal newContractPer;
|
||||
private BigDecimal newPrice;
|
||||
/**
|
||||
* 老客户 新签 占比
|
||||
* 老客户 新签 金额
|
||||
*/
|
||||
private BigDecimal oldContractPer;
|
||||
private BigDecimal oldPrice;
|
||||
|
||||
/**
|
||||
* 新客户 新签 金额 占比
|
||||
*/
|
||||
private BigDecimal newPricePer;
|
||||
/**
|
||||
* 老客户 新签 金额 占比
|
||||
*/
|
||||
private BigDecimal oldPricePer;
|
||||
|
||||
|
||||
private BigDecimal all;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.chrono.ChronoLocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.Temporal;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
@ -318,36 +317,46 @@ public class HomeServiceImpl implements HomeService {
|
||||
|
||||
OldOrNewCusContractCountVo ret = new OldOrNewCusContractCountVo();
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.select("count(1) countNum, IFNULL(sum(contract_amount), 0) sumAmount");
|
||||
queryWrapper.eq("is_old_cus", 1);
|
||||
queryWrapper.eq("is_due", "0");
|
||||
queryWrapper.ge(startDate != null,"apply_date", startDate)
|
||||
.lt(endDate != null,"apply_date", endDate);
|
||||
Long oldCusNum = psContractInfoMapper.selectCount(queryWrapper);
|
||||
|
||||
List<Map<String, Object>> maps = psContractInfoMapper.selectMaps(queryWrapper);
|
||||
Map<String, Object> oldVal = maps.get(0);
|
||||
Long oldCusNum = (Long)oldVal.get("countNum");
|
||||
BigDecimal oldSumPrice = (BigDecimal)oldVal.get("sumAmount");
|
||||
|
||||
queryWrapper.clear();
|
||||
queryWrapper.select("count(1) countNum, IFNULL(sum(contract_amount), 0) sumAmount");
|
||||
queryWrapper.eq("is_old_cus", 0);
|
||||
queryWrapper.eq("is_due", "0");
|
||||
queryWrapper.ge(startDate != null,"apply_date", startDate)
|
||||
.lt(endDate != null,"apply_date", endDate);
|
||||
Long newCusNum = psContractInfoMapper.selectCount(queryWrapper);
|
||||
maps = psContractInfoMapper.selectMaps(queryWrapper);
|
||||
Map<String, Object> stringObjectMap = maps.get(0);
|
||||
long newCountNum = (Long)stringObjectMap.get("countNum");
|
||||
BigDecimal newSumPrice = (BigDecimal)stringObjectMap.get("sumAmount");
|
||||
|
||||
long sum = oldCusNum + newCusNum;
|
||||
BigDecimal sum = newSumPrice.add(oldSumPrice);
|
||||
|
||||
ret.setOldContractNum(oldCusNum);
|
||||
ret.setNewContractNum(newCusNum);
|
||||
if (oldCusNum != 0){
|
||||
ret.setOldContractPer(new BigDecimal(oldCusNum).divide(new BigDecimal(sum), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
|
||||
ret.setNewContractNum(newCountNum);
|
||||
ret.setOldPrice(oldSumPrice);
|
||||
ret.setNewPrice(newSumPrice);
|
||||
if (oldSumPrice.doubleValue() != 0){
|
||||
ret.setOldPricePer(oldSumPrice.divide(sum, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
|
||||
} else{
|
||||
ret.setOldContractPer(new BigDecimal(0));
|
||||
ret.setOldPricePer(new BigDecimal(0));
|
||||
}
|
||||
if (newCusNum != 0){
|
||||
ret.setNewContractPer((new BigDecimal(100).subtract(ret.getOldContractPer())));
|
||||
if (newSumPrice.doubleValue() != 0){
|
||||
ret.setNewPricePer((new BigDecimal(100).subtract(ret.getOldPricePer())));
|
||||
} else{
|
||||
ret.setNewContractPer(new BigDecimal(0));
|
||||
ret.setNewPricePer(new BigDecimal(0));
|
||||
}
|
||||
|
||||
ret.setDateStr(date);
|
||||
ret.setAll(ret.getOldPrice().add(ret.getNewPrice()));
|
||||
return ret;
|
||||
}
|
||||
private String contractSource = "转介绍";
|
||||
|
@ -554,17 +554,17 @@ public class PsContractInfoServiceImpl implements IPsContractInfoService {
|
||||
psContractCompanyMapper.delete(qw1);
|
||||
|
||||
//服务公司删,则删任务,重新校验合同状态,可能已完成
|
||||
QueryWrapper<PsTaskMain> qw = Wrappers.query();
|
||||
qw.eq( "service_company_id", psCompanyInfoBo.getId());
|
||||
qw.eq( "contract_code", updateBo.getContractCode());
|
||||
List<PsTaskMain> psTaskMainList = taskMainMapper.selectList(qw);
|
||||
taskMainMapper.delete(qw);
|
||||
|
||||
//服务公司删,则删任务,重新校验合同状态,可能已完成
|
||||
List<Long> taskIds = psTaskMainList.stream().map(stTask1 -> stTask1.getId()).collect(Collectors.toList());
|
||||
if (!taskIds.isEmpty()){
|
||||
taskAppointMapper.deleteByIds(taskIds);
|
||||
}
|
||||
// QueryWrapper<PsTaskMain> qw = Wrappers.query();
|
||||
// qw.eq( "service_company_id", psCompanyInfoBo.getId());
|
||||
// qw.eq( "contract_code", updateBo.getContractCode());
|
||||
// List<PsTaskMain> psTaskMainList = taskMainMapper.selectList(qw);
|
||||
// taskMainMapper.delete(qw);
|
||||
//
|
||||
// //服务公司删,则删任务,重新校验合同状态,可能已完成
|
||||
// List<Long> taskIds = psTaskMainList.stream().map(stTask1 -> stTask1.getId()).collect(Collectors.toList());
|
||||
// if (!taskIds.isEmpty()){
|
||||
// taskAppointMapper.deleteByIds(taskIds);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@ -592,6 +592,10 @@ public class PsContractInfoServiceImpl implements IPsContractInfoService {
|
||||
wrapper.set("task_status", TaskStatusEnum.DISABLED.getCode());
|
||||
taskMainMapper.update(wrapper);
|
||||
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.eq( "contract_code", updateBo.getContractCode());
|
||||
taskAppointMapper.delete(queryWrapper);
|
||||
|
||||
if(!"1".equals(updateBo.getIsDue())){
|
||||
List<PsTaskMain> psTaskMainList = new ArrayList<>();
|
||||
for (PsCompanyInfoBo companyInfoBo : updateBo.getServiceCompanyInfoList()){
|
||||
|
Loading…
Reference in New Issue
Block a user