Commit cbf4c45d by manxiaoqiang

app排序

parent 820915cc
...@@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableList; ...@@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableList;
import common.model.*; import common.model.*;
import common.service.ContractService; import common.service.ContractService;
import common.service.MenuService; import common.service.MenuService;
import common.task.ContractSendEmailThread;
import dic.OperateObjectTypeEnum; import dic.OperateObjectTypeEnum;
import exception.TipException; import exception.TipException;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
...@@ -177,6 +178,9 @@ public class ContractController { ...@@ -177,6 +178,9 @@ public class ContractController {
Contract contract1 = service.create(loginAccount, contract); Contract contract1 = service.create(loginAccount, contract);
NewUserLogThread userlog = new NewUserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), contract.getContractCode(), "新建合同","",contract1.toString(), request); NewUserLogThread userlog = new NewUserLogThread(loginAccount.getEmail(), loginAccount.getName(), OperateObjectTypeEnum.CUSTOMER.getKey(), contract.getContractCode(), "新建合同","",contract1.toString(), request);
userlog.start(); userlog.start();
ContractSendEmailThread email = new ContractSendEmailThread(contract);
email.start();
return ResultModel.OK(contract1); return ResultModel.OK(contract1);
} }
......
...@@ -29,4 +29,10 @@ public interface ContractRepository extends JpaRepository<Contract, Long> { ...@@ -29,4 +29,10 @@ public interface ContractRepository extends JpaRepository<Contract, Long> {
@Query(value="SELECT * from contract where platform = ?1 and email = ?2",nativeQuery=true) @Query(value="SELECT * from contract where platform = ?1 and email = ?2",nativeQuery=true)
List<Contract> findByPlatformAndEmail(String platform, String email); List<Contract> findByPlatformAndEmail(String platform, String email);
@Query(value="SELECT * from contract where start_date = ?1",nativeQuery=true)
List<Contract> findByStartDate(String startDate);
@Query(value="SELECT * from contract where end_date = ?1",nativeQuery=true)
List<Contract> findByEndDate(String endDate);
} }
...@@ -94,7 +94,7 @@ public class ContractServiceImpl implements ContractService{ ...@@ -94,7 +94,7 @@ public class ContractServiceImpl implements ContractService{
public Contract create(User loginUser, Contract resource) { public Contract create(User loginUser, Contract resource) {
resource.setPayMoney(0L); resource.setPayMoney(0L);
resource.setInvoice(0L); resource.setInvoice(0L);
if(DateUtil.getBeforeDays(0).compareTo(resource.getStartDate()) > 0){ if(DateUtil.getBeforeDays(0).compareTo(resource.getStartDate()) < 0){
resource.setDs(DateUtil.getBeforeDays(0)); resource.setDs(DateUtil.getBeforeDays(0));
resource.setStatus("wait"); resource.setStatus("wait");
}else{ }else{
...@@ -135,7 +135,7 @@ public class ContractServiceImpl implements ContractService{ ...@@ -135,7 +135,7 @@ public class ContractServiceImpl implements ContractService{
if(!resource.getStartDate().equals(contract.getStartDate())){ if(!resource.getStartDate().equals(contract.getStartDate())){
cc.setContent(cc.getContent() + "开始时间变更 : " + contract.getStartDate() + "-->" + resource.getStartDate()); cc.setContent(cc.getContent() + "开始时间变更 : " + contract.getStartDate() + "-->" + resource.getStartDate());
contract.setStartDate(resource.getStartDate()); contract.setStartDate(resource.getStartDate());
if(DateUtil.getBeforeDays(0).compareTo(resource.getStartDate()) > 0){ if(DateUtil.getBeforeDays(0).compareTo(resource.getStartDate()) < 0){
contract.setStatus("wait"); contract.setStatus("wait");
}else{ }else{
contract.setStatus("executing"); contract.setStatus("executing");
......
package common.task;
import common.context.AppUtils;
import common.model.Contract;
import common.model.User;
import common.model.UserLog;
import common.repository.UserLogRepository;
import common.repository.UserRepository;
import dic.RoleTypeEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import tkio.model.PackageType;
import tkio.repository.PackageTypeRepository;
import util.DateUtil;
import util.IPAddrUtil;
import util.MailUtils;
import util.ValidateUtil;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
/**
* Created by zxy on 2017/12/15.
*/
public class ContractSendEmailThread
extends Thread
{
protected Logger logger = LoggerFactory.getLogger(ContractSendEmailThread.class);
private PackageTypeRepository packageTypeRepository = AppUtils.getApplicationContext().getBean(PackageTypeRepository.class);
private UserRepository userRepository = AppUtils.getApplicationContext().getBean(UserRepository.class);
private Contract contract;
public ContractSendEmailThread(Contract contract) {
this.contract = contract;
}
@Override
public void run()
{
Map<Long, String> packageMap = getPackageMap();
StringBuffer sb = new StringBuffer();
sb.append("账号 :" + this.contract.getEmail() + " 签约了," + " 套餐 :" +
packageMap.get(this.contract.getPriceLevel()) + ",开始时间 " + this.contract.getStartDate()
+ ",结束时间 " + this.contract.getEndDate());
User user = userRepository.findOne(this.contract.getSale());
List<String> list = new ArrayList<>();
list.add(user.getEmail());
if(!user.getRoleType().equals(RoleTypeEnum.MANAGER)){
List<User> userList = userRepository.findOneDepartment(user.getRole());
for(User u : userList){
if (u.getRoleType().equals(RoleTypeEnum.MANAGER)){
list.add(u.getEmail());
}
}
}
try {
MailUtils.sendSimpleEmail("新建合同", sb.toString(),list);
} catch (Exception e) {
e.printStackTrace();
}
}
public Map<Long, String> getPackageMap(){
List<PackageType> typeList = packageTypeRepository.findAll();
Map<Long, String> typeMap = new HashMap<>();
if(ValidateUtil.isValid(typeList)){
for(PackageType s: typeList){
typeMap.put(s.getId(), s.getPackageName());
}
}
return typeMap;
}
}
package common.task;
import com.google.common.base.Splitter;
import common.model.AppCategory;
import common.model.AppInfo;
import common.model.Contract;
import common.repository.AppCategoryRepository;
import common.repository.AppInfoRepository;
import common.repository.CityRepository;
import common.repository.ContractRepository;
import dmp.model.OtPkgDevStats;
import dmp.repository.OtPkgDevStatsRepository;
import dmp.repository.TagCrawlerAppsWandoujiaRepository;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.anarres.lzo.LzoAlgorithm;
import org.anarres.lzo.LzoDecompressor;
import org.anarres.lzo.LzoInputStream;
import org.anarres.lzo.LzoLibrary;
import org.apache.commons.collections.map.HashedMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import util.*;
import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by zxy on 2017/12/26.
*/
public class ContractTask
{
private static Logger logger = LoggerFactory.getLogger(ContractTask.class);
@Autowired
ContractRepository contractRepository;
public void task(){
List<Contract> contractList = contractRepository.findByStartDate(DateUtil.getBeforeDays(0));
if(ValidateUtil.isValid(contractList)){
List<Contract> list = new ArrayList<>();
for(Contract c : contractList){
c.setStatus("executing");
list.add(c);
}
contractRepository.save(list);
}
List<Contract> contractList2 = contractRepository.findByEndDate(DateUtil.getBeforeDays(0));
if(ValidateUtil.isValid(contractList2)){
List<Contract> list = new ArrayList<>();
for(Contract c : contractList2){
c.setStatus("end");
list.add(c);
}
contractRepository.save(list);
}
}
}
...@@ -25,9 +25,12 @@ ...@@ -25,9 +25,12 @@
<task:scheduled ref="emailTask" method="task" cron="0 20 0 * * ?"/> <task:scheduled ref="emailTask" method="task" cron="0 20 0 * * ?"/>
</task:scheduled-tasks> </task:scheduled-tasks>
<bean id="trackAccountTask" class="track.task.AccountTask"></bean> <bean id="contractTask" class="common.task.ContractTask"></bean>
<task:scheduled-tasks>
<task:scheduled ref="contractTask" method="task" cron="0 20 17 * * ?"/>
</task:scheduled-tasks>
<bean id="trackAccountTask" class="track.task.AccountTask"></bean>
<task:scheduled-tasks> <task:scheduled-tasks>
<!--//定时同步短链数据(每5分钟执行一次)--> <!--//定时同步短链数据(每5分钟执行一次)-->
<task:scheduled ref="trackAccountTask" method="task" cron="0 32 0 * * ?"/> <task:scheduled ref="trackAccountTask" method="task" cron="0 32 0 * * ?"/>
......
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