Commit 586a98c6 by lzxry

adi查用户bug

parent ccce33dd
......@@ -652,7 +652,8 @@ public class ContractServiceImpl implements ContractService {
}
}else if("cas".equals(resource.getPlatform())){
ADIUser adiUser = adiAccountService.findOne(resource.getEmail(), resource.getContractType());
PackageBase one = packageBaseRepository.findOne(resource.getPriceLevel());
ADIUser adiUser = adiAccountService.findOne(resource.getEmail(),one.getPackageName());
if(adiUser==null || StringUtils.isEmpty(adiUser.getSendTime())){
resource.setShareSign(0);
}else{
......@@ -927,6 +928,26 @@ public class ContractServiceImpl implements ContractService {
contractExist.setErroMessage("补充协议开始日期不能晚于原始合同的结束日期");
return contractExist;
}
}else if("cas".equals(resource.getPlatform())){
PackageBase one = packageBaseRepository.findOne(resource.getPriceLevel());
ADIUser adiUser = adiAccountService.findOne(resource.getEmail(), one.getPackageName());
if(adiUser==null || StringUtils.isEmpty(adiUser.getSendTime())){
resource.setShareSign(0);
}else{
resource.setShareSign(1);
DateTime sendTime = new DateTime(DateUtil.parseDate(DateUtil.C_TIME_PATTON_DEFAULT,adiUser.getSendTime()));
DateTime startDate = new DateTime(resource.getStartDate());
if(sendTime.isBefore(startDate)){
sendTime = startDate;
}
DateTime endDate = new DateTime(resource.getEndDate());
String validStartDateStr = sendTime.toString(DateUtil.C_DATE_PATTON_DEFAULT);
int contractAllDay = Days.daysBetween(startDate, endDate).getDays();//合同总天数-1 ,用于计算结束日期
String validEndDateStr = sendTime.plusDays(contractAllDay).toString("yyyy-MM-dd");
resource.setValidStartDate(validStartDateStr);
resource.setValidEndDate(validEndDateStr);
}
}
if (resource.getContractCode() != null && !resource.getContractCode().equals(contract.getContractCode())) {
......
......@@ -3,7 +3,9 @@ package track.task;
import adi.model.ADIUser;
import adi.service.ADIAccountService;
import common.model.Contract;
import common.model.PackageBase;
import common.repository.ContractRepository;
import common.repository.PackageBaseRepository;
import org.joda.time.DateTime;
import org.joda.time.Days;
import org.slf4j.Logger;
......@@ -12,7 +14,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import util.DateUtil;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author liyin
......@@ -26,13 +30,21 @@ public class CASIPSendTimeTask {
ADIAccountService adiAccountService;
@Autowired
ContractRepository contractRepository;
@Autowired
PackageBaseRepository packageBaseRepository;
public void task(){
logger.info("CAS的IP定制发送日定时任务");
List<PackageBase> packageBases = packageBaseRepository.findByPlatAndStatus("cas", 1);
Map<Long, PackageBase> packageBaseMap = new HashMap<>();
for (PackageBase base : packageBases) {
packageBaseMap.put(base.getId(), base);
}
List<Contract> contracts = contractRepository.findByPlatformAndShareSign("cas",0);
for (Contract contract : contracts) {
ADIUser adiUser = adiAccountService.findOne(contract.getEmail(), contract.getContractType());
PackageBase packageBase = packageBaseMap.get(contract.getPriceLevel());
ADIUser adiUser = adiAccountService.findOne(contract.getEmail(), packageBase==null?"":packageBase.getPackageName());
if(adiUser!=null&&!StringUtils.isEmpty(adiUser.getSendTime())){
contract.setShareSign(1);
DateTime sendTime = new DateTime(DateUtil.parseDate(DateUtil.C_TIME_PATTON_DEFAULT,adiUser.getSendTime()));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment