Jiaqi.xu

BASF请求绑定账号

......@@ -194,7 +194,7 @@ public class BasfDataInterface {
//记录请求的运单
IClearApiLog saveIClearApiLogResult = iClearApiLogService.saveIClearApiLog(iClearApiLogService.convertToIClearApiLogCselect(consignmentCode.getConsignmentCode(),appId,appKey,new Date(Long.valueOf(timeStamp))));
//查询请求需要得运单申报信息
List<DeclaredInfo> declaredInfos = declaredInfoService.selectDeclaredInfo(splitConsignment);
List<DeclaredInfo> declaredInfos = declaredInfoService.selectDeclaredInfo(splitConsignment,appId);
//构造返回数据
List<BasfConsignment> basfConsignments = basfConsignmentService.basfConsignmentList(declaredInfos);
//返回申报数据
......@@ -254,7 +254,7 @@ public class BasfDataInterface {
IClearApiLog saveIClearApiLogResult = iClearApiLogService.saveIClearApiLog(iClearApiLogService.convertToIClearApiLogCselect(consignmentCode.getConsignmentCode(),appId,appKey,new Date(Long.valueOf(timeStamp))));
//查询请求需要得运单申报信息
//List<DeclaredInfo> declaredInfos = declaredInfoService.selectDeclaredInfo(splitConsignment);
List<BasfcReceipt> chmConsignments = chmConsignmentService.getConsignmentCode(splitConsignment);
List<BasfcReceipt> chmConsignments = chmConsignmentService.getConsignmentCode(splitConsignment,appId);
//构造返回数据
//List<BasfConsignment> basfConsignments = basfConsignmentService.basfConsignmentList(declaredInfos);
//返回申报数据
......
......@@ -330,6 +330,13 @@ public class ChmConsignment implements Serializable {
@Column(name = "CREATE_TIME")
private Date createTime;
/**
* 运单创建人ID
*/
@JsonIgnore
@ManyToOne(targetEntity = SysUser.class)
@JoinColumn(name = "CREATOR_ID")
private SysUser creatorId;
/**
* 运单创建人
......
......@@ -45,6 +45,6 @@ public interface ChmConsignmentRepository extends JpaSpecificationExecutor<ChmCo
*/
@Query( nativeQuery = true,value = "select ID,CONSIGNMENT_CODE,CUSTOMS_RECEIPT,CONS_TYPE,CUSTOMS_RECEIPT_TIME from T_CHM_CONSIGNMENT where ID IN(\n" +
"select MAX(ID)as ID from T_CHM_CONSIGNMENT \n" +
"where CONS_TYPE_ID = ?2 and CUSTOMS_RECEIPT is not null AND CONSIGNMENT_CODE IN ?1 GROUP BY CONSIGNMENT_CODE)")
public List<Object[]> findChmByConsignmentCode(List<String> consignmentCode, Long consTypeId);
"where CREATOR_ID = ?3 AND CONS_TYPE_ID = ?2 and CUSTOMS_RECEIPT is not null AND CONSIGNMENT_CODE IN ?1 GROUP BY CONSIGNMENT_CODE)")
public List<Object[]> findChmByConsignmentCode(List<String> consignmentCode, Long consTypeId,Long creatorId);
}
......
......@@ -20,6 +20,6 @@ public interface DeclaredInfoRepository extends JpaRepository<DeclaredInfo, Inte
* 根据运单号在申报数据表中查询数据
* @return
*/
@Query(nativeQuery = true, value = "select * from T_DECLARED_INFO where CONSIGNMENT_ID IN (SELECT MAX(ID)AS ID FROM T_CHM_CONSIGNMENT WHERE T_CHM_CONSIGNMENT.CONS_TYPE_ID = ?2 and CONSIGNMENT_CODE IN ?1 group by CONSIGNMENT_CODE)")
public List<DeclaredInfo> getDeclaredInfoByAll(List<String> consignmentCodeList,Long consTypeId);
@Query(nativeQuery = true, value = "select * from T_DECLARED_INFO where CONSIGNMENT_ID IN (SELECT MAX(ID)AS ID FROM T_CHM_CONSIGNMENT t WHERE t.CREATOR_ID = ?3 and t.CONS_TYPE_ID = ?2 and CONSIGNMENT_CODE IN ?1 group by CONSIGNMENT_CODE)")
public List<DeclaredInfo> getDeclaredInfoByAll(List<String> consignmentCodeList,Long consTypeId,Long creator);
}
......
package com.erry.iclear.dateInterface.repository;
import com.erry.iclear.dateInterface.entity.SysUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.math.BigDecimal;
import java.util.List;
/**
* Created by liyang on 2017/2/21.
*/
@Repository
public interface SysUserRepository extends JpaSpecificationExecutor<SysUser>, JpaRepository<SysUser, Long> {
@Query(nativeQuery = true, value = "select * from t_au_user where login_name = ?1")
public List<SysUser> findByLoginName(String loginName);
/**
* 根据用户登录名list查询用户列表信息
*
* @param loginNames
* @return
*/
@Query(nativeQuery = true, value = "select * from t_au_user where login_name IN (?1) ")
public List<SysUser> findUserListByLoginNames(List loginNames);
/**
* 根据登录名查询单个用户信息
*
* @param loginName
* @return
*/
@Query(nativeQuery = true, value = "select * from t_au_user where login_name = ?1")
public SysUser findUserByLoginName(String loginName);
@Query(nativeQuery = true, value = "select * from t_au_user where username = ?1")
public List<SysUser> findByUserName(String userName);
@Query(nativeQuery = true, value = "select * from t_au_user where report_to = ?1")
public List<SysUser> findUserListByReportTo(Long userId);
@Query(nativeQuery = true, value = "select login_name from t_au_user where report_to = ?1 and IS_VALID=1")
public List<String> findLoginNameListByReportTo(Long userId);
@Query(nativeQuery = true, value = "select * from t_au_user where is_valid=1 and VISIBLE=1")
public List<SysUser> findAllUserListByValid();
@Query(nativeQuery = true ,value = " select * from T_AU_USER where id in (\n" +
"select USER_ID from [dbo].[T_AU_USER_ROLES]\n" +
" where ROLE_ID =?1\n" +
" ) and is_valid=1 ;")
public List<SysUser> findAllUserListByRole(Long roleId);
/**
* 根据用户ID查找用户信息
* @param userId
* @return
*/
@Query(nativeQuery = true, value = "select * from t_au_user where id = ?1")
public SysUser findUserById(Long userId);
@Query(nativeQuery = true, value = "select * from t_au_user where TYPE_NAME ='客户' and login_name = ?1")
public SysUser findUserByLoginNameFed(String loginName);
/**
* 查询员工账号
* @return
*/
@Query(nativeQuery = true,value = "select ID from T_AU_USER where IS_VALID = 1 AND ORG_NAME = 'RDE' AND CONS_DISTRIBUTION = '2'")
public List<BigDecimal> findByDistribution();
}
......@@ -6,12 +6,10 @@ import com.erry.iclear.dateInterface.api.request.BasfcReceipt;
import com.erry.iclear.dateInterface.api.request.Mawb;
import com.erry.iclear.dateInterface.api.response.ResultRS;
import com.erry.iclear.dateInterface.common.Constant;
import com.erry.iclear.dateInterface.entity.ChmCarryPort;
import com.erry.iclear.dateInterface.entity.ChmConsignment;
import com.erry.iclear.dateInterface.entity.ChmConsignmentDetail;
import com.erry.iclear.dateInterface.entity.DictionaryEntries;
import com.erry.iclear.dateInterface.entity.*;
import com.erry.iclear.dateInterface.repository.ChmConsignmentRepository;
import com.erry.iclear.dateInterface.repository.DictionaryEntriesRepository;
import com.erry.iclear.dateInterface.repository.SysUserRepository;
import com.erry.iclear.dateInterface.util.DateUtils;
import com.erry.iclear.dateInterface.util.NumberUtils;
import com.erry.iclear.dateInterface.util.StringUtil;
......@@ -48,6 +46,9 @@ public class ChmConsignmentService {
@Autowired
private DeclaredInfoService declaredInfoService;
@Autowired
private SysUserRepository sysUserRepository;
/**
* 转换主单
* @return
......@@ -285,8 +286,11 @@ public class ChmConsignmentService {
//推送时间作为创建时间,可以用来校验数据的有序性,如果新的推送时间小于已有的创建时间,就不更新数据
result.setCreateTime(new Date());
result.setUpdateTime(pushTime);
result.setCreator(creator);
if (!creator.equals("IDE-ICLEAR-API")){
SysUser sysUser = sysUserRepository.findUserByLoginName(creator);
result.setCreatorId(sysUser);
result.setCreator(sysUser.getLoginName());
}
}catch (Exception e){
result=null;
e.printStackTrace();
......@@ -633,10 +637,11 @@ public class ChmConsignmentService {
return result;
}
public List<BasfcReceipt> getConsignmentCode(String[] consignmentCode) throws ParseException {
public List<BasfcReceipt> getConsignmentCode(String[] consignmentCode,String creator) throws ParseException {
DictionaryEntries consTypeC = dictionaryEntriesRepository.findDictionaryEntriesByCode(Constant.consType_C);
SysUser sysUser = sysUserRepository.findUserByLoginName(creator);
List<String> stringList = declaredInfoService.stringList(consignmentCode);
List<Object[]> chmByConsignmentCode = chmConsignmentRepository.findChmByConsignmentCode(stringList, consTypeC.getId());
List<Object[]> chmByConsignmentCode = chmConsignmentRepository.findChmByConsignmentCode(stringList, consTypeC.getId(),sysUser.getId());
List<BasfcReceipt> basfcReceiptList = new ArrayList<>();
if(chmByConsignmentCode.size()>0){
for (int i = 0; i < chmByConsignmentCode.size(); i++) {
......
......@@ -3,8 +3,10 @@ package com.erry.iclear.dateInterface.service;
import com.erry.iclear.dateInterface.common.Constant;
import com.erry.iclear.dateInterface.entity.DeclaredInfo;
import com.erry.iclear.dateInterface.entity.DictionaryEntries;
import com.erry.iclear.dateInterface.entity.SysUser;
import com.erry.iclear.dateInterface.repository.DeclaredInfoRepository;
import com.erry.iclear.dateInterface.repository.DictionaryEntriesRepository;
import com.erry.iclear.dateInterface.repository.SysUserRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -27,11 +29,15 @@ public class DeclaredInfoService {
@Autowired
private DictionaryEntriesRepository dictionaryEntriesRepository;
public List<DeclaredInfo> selectDeclaredInfo(String[] consignmentCode){
@Autowired
private SysUserRepository sysUserRepository;
public List<DeclaredInfo> selectDeclaredInfo(String[] consignmentCode, String creator){
List<DeclaredInfo> DeclaredInfo = new ArrayList<>();
DictionaryEntries consTypeC = dictionaryEntriesRepository.findDictionaryEntriesByCode(Constant.consType_C);
SysUser sysUser = sysUserRepository.findUserByLoginName(creator);
List<String> consignmentCodeList = stringList(consignmentCode);
DeclaredInfo = declaredInfoRepository.getDeclaredInfoByAll(consignmentCodeList,consTypeC.getId());
DeclaredInfo = declaredInfoRepository.getDeclaredInfoByAll(consignmentCodeList,consTypeC.getId(),sysUser.getId());
return DeclaredInfo;
}
......