Commit ae9ee6ae by kangxiaoshan

Merge branch 'contract_rela' into 31762_2_bugfix

parents 318643f9 298adca5
...@@ -40,17 +40,31 @@ public class ContractController { ...@@ -40,17 +40,31 @@ public class ContractController {
private static final Logger logger = LoggerFactory.getLogger(ContractController.class); private static final Logger logger = LoggerFactory.getLogger(ContractController.class);
private static final Map<String, String> CONTRACT_STATUS = new HashMap<String, String>() {{ private static final Map<String, String> CONTRACT_STATUS = new HashMap<String, String>() {{
put(ContractStatusEnum.WAIT.getKey(), ContractStatusEnum.WAIT.getValue()); // put(ContractStatusEnum.WAIT.getKey(), ContractStatusEnum.WAIT.getValue());
put(ContractStatusEnum.EXECUTING.getKey(), ContractStatusEnum.EXECUTING.getValue()); // put(ContractStatusEnum.EXECUTING.getKey(), ContractStatusEnum.EXECUTING.getValue());
put(ContractStatusEnum.END.getKey(), ContractStatusEnum.END.getValue()); // put(ContractStatusEnum.END.getKey(), ContractStatusEnum.END.getValue());
put(ContractStatusEnum.CANCEL.getKey(), ContractStatusEnum.CANCEL.getValue()); // put(ContractStatusEnum.CANCEL.getKey(), ContractStatusEnum.CANCEL.getValue());
put(ContractStatusEnum.MONEY_BACK_ALL.getKey(), ContractStatusEnum.MONEY_BACK_ALL.getValue()); // put(ContractStatusEnum.MONEY_BACK_ALL.getKey(), ContractStatusEnum.MONEY_BACK_ALL.getValue());
put(ContractStatusEnum.MONEY_BACK_PART.getKey(), ContractStatusEnum.MONEY_BACK_PART.getValue()); // put(ContractStatusEnum.MONEY_BACK_PART.getKey(), ContractStatusEnum.MONEY_BACK_PART.getValue());
put(ContractStatusEnum.MONEY_BACK_NONE.getKey(), ContractStatusEnum.MONEY_BACK_NONE.getValue()); // put(ContractStatusEnum.MONEY_BACK_NONE.getKey(), ContractStatusEnum.MONEY_BACK_NONE.getValue());
put(ContractStatusEnum.DELETE.getKey(), ContractStatusEnum.DELETE.getValue()); // put(ContractStatusEnum.DELETE.getKey(), ContractStatusEnum.DELETE.getValue());
putdata(this,ContractStatusEnum.WAIT);
putdata(this,ContractStatusEnum.EXECUTING);
putdata(this,ContractStatusEnum.END);
putdata(this,ContractStatusEnum.CANCEL);
putdata(this,ContractStatusEnum.MONEY_BACK_ALL);
putdata(this,ContractStatusEnum.MONEY_BACK_PART);
putdata(this,ContractStatusEnum.MONEY_BACK_NONE);
putdata(this,ContractStatusEnum.DELETE);
}}; }};
private static void putdata(Map map,ContractStatusEnum a){
map.put(a.getKey(),a.getValue());
}
@Autowired @Autowired
private ContractService service; private ContractService service;
......
...@@ -4,6 +4,7 @@ import common.model.ContractRelation; ...@@ -4,6 +4,7 @@ import common.model.ContractRelation;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import java.math.BigInteger;
import java.util.List; import java.util.List;
...@@ -12,8 +13,8 @@ import java.util.List; ...@@ -12,8 +13,8 @@ import java.util.List;
*/ */
public interface ContractRelationRepository extends JpaRepository<ContractRelation, Long> { public interface ContractRelationRepository extends JpaRepository<ContractRelation, Long> {
@Query(value = "select relation_id id from contract_relation where main_contract = ?1 union all select main_contract id from contract_relation where relation_id = ?1",nativeQuery = true) @Query(value = "select relation_id id from contract_relation where main_contract in ?1 union all select main_contract id from contract_relation where relation_id in ?1",nativeQuery = true)
List<Long> findRelationIds(String contractId); List<BigInteger> findRelationIds(List contractId);
@Query(value = "select * from contract_relation where main_contract = ?1 and relation_id = ?2 and platform = ?3",nativeQuery = true) @Query(value = "select * from contract_relation where main_contract = ?1 and relation_id = ?2 and platform = ?3",nativeQuery = true)
ContractRelation findByRelationData(Long mainContract, Long relationId, String platform); ContractRelation findByRelationData(Long mainContract, Long relationId, String platform);
......
...@@ -60,10 +60,10 @@ public interface ContractRepository extends JpaRepository<Contract, Long> { ...@@ -60,10 +60,10 @@ public interface ContractRepository extends JpaRepository<Contract, Long> {
Contract findByCodePlatform(String contractCode, String platform); Contract findByCodePlatform(String contractCode, String platform);
@Query(value="select * from contract where start_date >= ?1 and start_date <= ?2 and platform in ?3 and id in ?4 and status!='del' order by ds desc",nativeQuery=true) @Query(value="select * from contract where start_date >= ?1 and start_date <= ?2 and platform in ?3 and id in ?4 and status!='del' order by ds desc",nativeQuery=true)
List<Contract> findByDsRelation(String startDate, String endDate, List<String> platform, List<Long> contractIds); List<Contract> findByDsRelation(String startDate, String endDate, List<String> platform, List<String> contractIds);
@Query(value="select * from contract where start_date >= ?1 and start_date <= ?2 and platform in ?3 and create_account in ?4 and id in ?5 and status!='del' order by ds desc",nativeQuery=true) @Query(value="select * from contract where start_date >= ?1 and start_date <= ?2 and platform in ?3 and create_account in ?4 and id in ?5 and status!='del' order by ds desc",nativeQuery=true)
List<Contract> findByDsAndRoileRelation(String startDate, String endDate, List<String> platform, List<Long> create_account, List<Long> contractIds); List<Contract> findByDsAndRoileRelation(String startDate, String endDate, List<String> platform, List<Long> create_account, List<String> contractIds);
@Query(value = "select new map( c.id as id, c.contractCode as contractCode ) from Contract c where c.platform in ?1 and c.contractCode is not null and c.contractCode <> 'null' ") @Query(value = "select new map( c.id as id, c.contractCode as contractCode ) from Contract c where c.platform in ?1 and c.contractCode is not null and c.contractCode <> 'null' ")
......
package common.service; package common.service;
import java.util.List;
/** /**
* description: * description:
......
...@@ -886,14 +886,16 @@ public class ContractServiceImpl implements ContractService { ...@@ -886,14 +886,16 @@ public class ContractServiceImpl implements ContractService {
} }
} }
List<Long> contractIds = null;
List<String> platforms = new ArrayList<>(); List<String> platforms = new ArrayList<>();
Map<String,String> idsDic = new HashMap<>();
platforms.add(platform); platforms.add(platform);
if (!StringUtils.isEmpty(contractId)) { if (!StringUtils.isEmpty(contractId)) {
//获取 关联合同列表 //获取 关联合同列表
contractIds = contractRelationRepository.findRelationIds(contractId); List<String> conIds = new ArrayList<>();
conIds.add(contractId);
this.getContractRelationIds(conIds,idsDic);
idsDic.remove(contractId);
if("fake".equals(platform)){ if("fake".equals(platform)){
platforms.add("tkio"); platforms.add("tkio");
} }
...@@ -901,7 +903,7 @@ public class ContractServiceImpl implements ContractService { ...@@ -901,7 +903,7 @@ public class ContractServiceImpl implements ContractService {
List<Contract> contractList = new ArrayList<>(); List<Contract> contractList = new ArrayList<>();
List<String> ids = new ArrayList<>(idsDic.keySet());
if (loginAccount.getRole().equals(RoleEnum.SOUTH_BUSSINUSS.getKey()) || loginAccount.getRole().equals(RoleEnum.NORTH_BUSSINUSS.getKey())) { if (loginAccount.getRole().equals(RoleEnum.SOUTH_BUSSINUSS.getKey()) || loginAccount.getRole().equals(RoleEnum.NORTH_BUSSINUSS.getKey())) {
...@@ -917,8 +919,8 @@ public class ContractServiceImpl implements ContractService { ...@@ -917,8 +919,8 @@ public class ContractServiceImpl implements ContractService {
if(!StringUtils.isEmpty(contractId)){ if(!StringUtils.isEmpty(contractId)){
//查看关联合同 //查看关联合同
if (contractIds != null && contractIds.size() > 0) { if (ids != null && ids.size() > 0) {
contractList = contractRepository.findByDsAndRoileRelation(startDate, endDate, platforms, idList, contractIds); contractList = contractRepository.findByDsAndRoileRelation(startDate, endDate, platforms, idList, ids);
} }
}else{ }else{
...@@ -930,8 +932,8 @@ public class ContractServiceImpl implements ContractService { ...@@ -930,8 +932,8 @@ public class ContractServiceImpl implements ContractService {
// contractList = contractRepository.findByDs(startDate, endDate, platform); // contractList = contractRepository.findByDs(startDate, endDate, platform);
if(!StringUtils.isEmpty(contractId)){ if(!StringUtils.isEmpty(contractId)){
if (contractIds != null && contractIds.size() > 0) { if (ids != null && ids.size() > 0) {
contractList = contractRepository.findByDsRelation(startDate, endDate, platforms, contractIds); contractList = contractRepository.findByDsRelation(startDate, endDate, platforms, ids);
} }
}else{ }else{
contractList = contractRepository.findByDs(startDate, endDate, platform); contractList = contractRepository.findByDs(startDate, endDate, platform);
...@@ -968,44 +970,31 @@ public class ContractServiceImpl implements ContractService { ...@@ -968,44 +970,31 @@ public class ContractServiceImpl implements ContractService {
return result; return result;
} }
// @Override
// public List<Contract> findAllContract(User loginAccount, String startDate, String endDate, String platform, String contractId) { private void getContractRelationIds (List<String> contractId,Map<String,String> idsDic){
//
// List<Long> contractIds = null; //获取 关联合同 id
// List<String> contractIds = new ArrayList<>();
// if (!StringUtils.isEmpty(contractId)) {
// //获取 关联合同列表 List<BigInteger> ids = contractRelationRepository.findRelationIds(contractId);
// contractIds = contractRelationRepository.findRelationIds(contractId);
// } if (ids != null && ids.size() > 0) {
// for(BigInteger id : ids){
// List<Contract> contractList;
// if (!loginAccount.getRole().equals(RoleEnum.MANAGER.getKey())) { String idss = id.toString();
// //非 管理员 if (idsDic.get(idss) == null) {
// List<User> userList = userService.findAllSons(loginAccount.getId()); contractIds.add(idss);
// List<Long> idList = new ArrayList<>(); idsDic.put(idss,"0");
// idList.add(loginAccount.getId()); }
// for (User u : userList) { }
// idList.add(u.getId());
// } if(contractIds.size()>0){
// //递归 查询 id 查询所有相关联的合同
// if (contractIds != null && contractIds.size() > 0) { this.getContractRelationIds(contractIds,idsDic);
// contractList = contractRepository.findByDsAndRoileRelation(startDate, endDate, platform, idList, contractIds); }
// } else { }
// contractList = contractRepository.findByDsAndRoile(startDate, endDate, platform, idList); }
// }
//
// } else {
//
// if (contractIds != null && contractIds.size() > 0) {
// contractList = contractRepository.findByDsRelation(startDate, endDate, platform, contractIds);
// } else {
// contractList = contractRepository.findByDs(startDate, endDate, platform);
// }
//
// }
//
// return contractList;
// }
@Override @Override
public Contract contractStatusUpdate(String platform, String contractId, String status) { public Contract contractStatusUpdate(String platform, String contractId, String status) {
......
package common.task; package common.task;
import com.google.common.base.Splitter;
import common.model.AppCategory;
import common.model.AppInfo;
import common.model.Contract; import common.model.Contract;
import common.repository.AppCategoryRepository;
import common.repository.AppInfoRepository;
import common.repository.CityRepository;
import common.repository.ContractRepository; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import util.*; import util.DateUtil;
import util.ValidateUtil;
import java.io.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* Created by zxy on 2017/12/26. * Created by zxy on 2017/12/26.
......
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