|
|
@@ -46,6 +46,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
import org.springblade.common.http.HttpHelper;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
@@ -89,86 +90,86 @@ public class GmyDataExchangApiServiceImpl implements IGmyDataExchangApiService {
|
|
|
ObjectNode jn = objMap.createObjectNode();
|
|
|
jn.put("sucess", success);
|
|
|
jn.put("success", success);
|
|
|
- if(!success) {
|
|
|
+ if (!success) {
|
|
|
jn.put("Error", message);
|
|
|
}
|
|
|
response.getWriter().write(jn.toString());
|
|
|
}
|
|
|
|
|
|
- private static String getJsonObjValueAsString(JsonNode jn, String fieldName){
|
|
|
- if(ObjectUtils.isNotNull(jn) && jn.has(fieldName)){
|
|
|
+ private static String getJsonObjValueAsString(JsonNode jn, String fieldName) {
|
|
|
+ if (ObjectUtils.isNotNull(jn) && jn.has(fieldName)) {
|
|
|
return jn.get(fieldName).asText().trim();
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return "";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static Date getJsonObjValueAsDateTime(JsonNode jn, String fieldName){
|
|
|
+ private static Date getJsonObjValueAsDateTime(JsonNode jn, String fieldName) {
|
|
|
String s = getJsonObjValueAsString(jn, fieldName);
|
|
|
- if(s.isEmpty()){
|
|
|
+ if (s.isEmpty()) {
|
|
|
return null;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
Date r;
|
|
|
- try{
|
|
|
+ try {
|
|
|
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
r = df.parse(s);
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
r = null;
|
|
|
}
|
|
|
return r;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static Integer getJsonObjValueAsInteger(JsonNode jn, String fieldName){
|
|
|
+ private static Integer getJsonObjValueAsInteger(JsonNode jn, String fieldName) {
|
|
|
String s = getJsonObjValueAsString(jn, fieldName);
|
|
|
- if(s.isEmpty()){
|
|
|
+ if (s.isEmpty()) {
|
|
|
return 0;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
Integer r;
|
|
|
- try{
|
|
|
+ try {
|
|
|
r = Integer.parseInt(s);
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
r = 0;
|
|
|
}
|
|
|
return r;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static BigDecimal getJsonObjValueAsBigDecimal(JsonNode jn, String fieldName){
|
|
|
+ private static BigDecimal getJsonObjValueAsBigDecimal(JsonNode jn, String fieldName) {
|
|
|
String s = getJsonObjValueAsString(jn, fieldName);
|
|
|
- if(s.isEmpty()){
|
|
|
+ if (s.isEmpty()) {
|
|
|
BigDecimal r = new BigDecimal("0").setScale(3, BigDecimal.ROUND_HALF_UP);
|
|
|
return r;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
BigDecimal r;
|
|
|
- try{
|
|
|
+ try {
|
|
|
r = new BigDecimal(s);
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
r = new BigDecimal("0");
|
|
|
}
|
|
|
return r.setScale(3, BigDecimal.ROUND_HALF_UP);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public BCorps getCorpByGmyCode(List<BCorps> corps, String code){
|
|
|
+ public BCorps getCorpByGmyCode(List<BCorps> corps, String code) {
|
|
|
BCorps corp = null;
|
|
|
if (ObjectUtils.isNotNull(code)) {
|
|
|
- if(ObjectUtils.isNotNull(corps)){
|
|
|
+ if (ObjectUtils.isNotNull(corps)) {
|
|
|
Optional<BCorps> corpsOptional = corps.stream()
|
|
|
.filter(v -> {
|
|
|
- return code.compareToIgnoreCase(v.getType())==0;
|
|
|
+ return code.compareToIgnoreCase(v.getType()) == 0;
|
|
|
})
|
|
|
.findFirst();
|
|
|
corp = corpsOptional.isPresent() ? corpsOptional.get() : null;
|
|
|
}
|
|
|
|
|
|
- if(ObjectUtils.isNull(corp)) {
|
|
|
+ if (ObjectUtils.isNull(corp)) {
|
|
|
corp = corpService.getOne(new LambdaQueryWrapper<BCorps>()
|
|
|
.eq(BCorps::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(BCorps::getIsDeleted, 0)
|
|
|
.like(BCorps::getGmyCode, code)
|
|
|
.last("limit 1"));
|
|
|
- if(ObjectUtils.isNotNull(corp)){
|
|
|
+ if (ObjectUtils.isNotNull(corp)) {
|
|
|
corp.setType(code);
|
|
|
corps.add(corp);
|
|
|
}
|
|
|
@@ -178,25 +179,25 @@ public class GmyDataExchangApiServiceImpl implements IGmyDataExchangApiService {
|
|
|
return corp;
|
|
|
}
|
|
|
|
|
|
- public BCountrys getCountryByGmyCode(List<BCountrys> cntrys, String code){
|
|
|
+ public BCountrys getCountryByGmyCode(List<BCountrys> cntrys, String code) {
|
|
|
BCountrys cntry = null;
|
|
|
if (ObjectUtils.isNotNull(code)) {
|
|
|
- if(ObjectUtils.isNotNull(cntrys)){
|
|
|
+ if (ObjectUtils.isNotNull(cntrys)) {
|
|
|
Optional<BCountrys> optional = cntrys.stream()
|
|
|
.filter(v -> {
|
|
|
- return code.compareToIgnoreCase(v.getGmyCode())==0;
|
|
|
+ return code.compareToIgnoreCase(v.getGmyCode()) == 0;
|
|
|
})
|
|
|
.findFirst();
|
|
|
cntry = optional.isPresent() ? optional.get() : null;
|
|
|
}
|
|
|
|
|
|
- if(ObjectUtils.isNull(cntry)) {
|
|
|
+ if (ObjectUtils.isNull(cntry)) {
|
|
|
cntry = countrysService.getOne(new LambdaQueryWrapper<BCountrys>()
|
|
|
.eq(BCountrys::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(BCountrys::getIsDeleted, 0)
|
|
|
.eq(BCountrys::getGmyCode, code)
|
|
|
.last("limit 1"));
|
|
|
- if(ObjectUtils.isNotNull(cntry)){
|
|
|
+ if (ObjectUtils.isNotNull(cntry)) {
|
|
|
cntrys.add(cntry);
|
|
|
}
|
|
|
}
|
|
|
@@ -229,36 +230,36 @@ public class GmyDataExchangApiServiceImpl implements IGmyDataExchangApiService {
|
|
|
String billNo = getJsonObjValueAsString(jnHead, "BILL_NO");
|
|
|
JsonNode jnGoods = jsPayload.get("GOODS_LIST");
|
|
|
Boolean canProcess = false;
|
|
|
- if(!declNo.isEmpty() && !billNo.isEmpty()){
|
|
|
+ if (!declNo.isEmpty() && !billNo.isEmpty()) {
|
|
|
GmyDeclHead declHead = gmyDeclHeadService.getOne(new LambdaQueryWrapper<GmyDeclHead>()
|
|
|
.eq(GmyDeclHead::getTenantId, TENANT_ID)
|
|
|
.eq(GmyDeclHead::getBranchId, BRANCH_ID)
|
|
|
.eq(GmyDeclHead::getIsDeleted, 0)
|
|
|
.eq(GmyDeclHead::getBillNo, billNo)
|
|
|
.last("limit 1"));
|
|
|
- if(ObjectUtils.isNull(declHead)){
|
|
|
+ if (ObjectUtils.isNull(declHead)) {
|
|
|
declHead = new GmyDeclHead();
|
|
|
// 0 新建 5 已删除 9 已处理
|
|
|
declHead.setStatus(0);
|
|
|
canProcess = true;
|
|
|
- }else{
|
|
|
- if(declHead.getStatus()==5){
|
|
|
+ } else {
|
|
|
+ if (declHead.getStatus() == 5) {
|
|
|
declHead.setStatus(0);
|
|
|
}
|
|
|
- if(declHead.getStatus()==9){
|
|
|
+ if (declHead.getStatus() == 9) {
|
|
|
message = "已处理";
|
|
|
}
|
|
|
- canProcess = declHead.getStatus()==0;
|
|
|
+ canProcess = declHead.getStatus() == 0;
|
|
|
}
|
|
|
|
|
|
- if(canProcess) {
|
|
|
+ if (canProcess) {
|
|
|
declHead.setTenantId(TENANT_ID);
|
|
|
declHead.setBranchId(BRANCH_ID);
|
|
|
declHead.setDeclNo(declNo);
|
|
|
declHead.setBillNo(billNo);
|
|
|
|
|
|
// from BUSINESS_ORDER_INFO
|
|
|
- if(ObjectUtils.isNotNull(jnOrdrInfo)) {
|
|
|
+ if (ObjectUtils.isNotNull(jnOrdrInfo)) {
|
|
|
declHead.setCorpNo(getJsonObjValueAsString(jnOrdrInfo, "EXPORT_CODE"));// 客户编号
|
|
|
declHead.setWorkNo(getJsonObjValueAsString(jnOrdrInfo, "WORK_NO"));//业务关联号
|
|
|
declHead.setCorpCnName(getJsonObjValueAsString(jnOrdrInfo, "EXPORT_NAME"));//客户名称
|
|
|
@@ -380,28 +381,28 @@ public class GmyDataExchangApiServiceImpl implements IGmyDataExchangApiService {
|
|
|
declHead.setOrigBoxFlag(getJsonObjValueAsString(jnHead, "ORIG_BOX_FLAG"));//原箱运输
|
|
|
declHead.setEntryVersion(getJsonObjValueAsInteger(jnHead, "ENTRY_VERSION"));//报关单版本
|
|
|
|
|
|
- if(ObjectUtils.isNotNull(declHead.getId())){
|
|
|
+ if (ObjectUtils.isNotNull(declHead.getId())) {
|
|
|
gmyDeclGoodsService.remove(new LambdaQueryWrapper<GmyDeclGoods>()
|
|
|
.eq(GmyDeclGoods::getTenantId, TENANT_ID)
|
|
|
.eq(GmyDeclGoods::getBranchId, BRANCH_ID)
|
|
|
.eq(GmyDeclGoods::getPid, declHead.getId()));
|
|
|
}
|
|
|
|
|
|
- if(gmyDeclHeadService.saveOrUpdate(declHead)) {
|
|
|
+ if (gmyDeclHeadService.saveOrUpdate(declHead)) {
|
|
|
// from GOODS_LIST
|
|
|
List<GmyDeclGoods> declGoods = new ArrayList<>();
|
|
|
|
|
|
Long haad_id = declHead.getId();
|
|
|
|
|
|
if (ObjectUtils.isNotNull(jnGoods) && jnGoods.isArray()) {
|
|
|
- jnGoods.forEach(jnGood1->{
|
|
|
+ jnGoods.forEach(jnGood1 -> {
|
|
|
JsonNode jnGood = jnGood1.get("DECL_GOODS");
|
|
|
System.out.println(jnGood.toString());
|
|
|
System.out.println("isObject: " + jnGood.isObject());
|
|
|
System.out.println("isArray: " + jnGood.isArray());
|
|
|
System.out.println("fieldNames: " + jnGood.fieldNames().toString());
|
|
|
|
|
|
- // for (JsonNode jnGood : jnGoods) {
|
|
|
+ // for (JsonNode jnGood : jnGoods) {
|
|
|
GmyDeclGoods declGood = new GmyDeclGoods();
|
|
|
declGood.setTenantId(TENANT_ID);
|
|
|
declGood.setBranchId(BRANCH_ID);
|
|
|
@@ -463,21 +464,21 @@ public class GmyDataExchangApiServiceImpl implements IGmyDataExchangApiService {
|
|
|
declGood.setDeclGoodsEname1(getJsonObjValueAsString(jnGood, "DECL_GOODS_ENAME1'"));//商品英文名称
|
|
|
|
|
|
declGoods.add(declGood);
|
|
|
- // }
|
|
|
+ // }
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- if(!declGoods.isEmpty()){
|
|
|
+ if (!declGoods.isEmpty()) {
|
|
|
gmyDeclGoodsService.saveBatch(declGoods);
|
|
|
}
|
|
|
|
|
|
success = true;
|
|
|
}
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
message = "Body 数据解析失败 1!";
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
message = "Body 数据解析失败 2!";
|
|
|
}
|
|
|
|
|
|
@@ -542,15 +543,15 @@ public class GmyDataExchangApiServiceImpl implements IGmyDataExchangApiService {
|
|
|
declCosts.add(declCost);
|
|
|
}
|
|
|
|
|
|
- if(!declCosts.isEmpty()){
|
|
|
+ if (!declCosts.isEmpty()) {
|
|
|
gmyDeclCostsService.saveOrUpdateBatch(declCosts);
|
|
|
|
|
|
success = true;
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
message = "缺少 COSTS 节!";
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
message = "Body 数据解析失败!";
|
|
|
}
|
|
|
|
|
|
@@ -566,8 +567,8 @@ public class GmyDataExchangApiServiceImpl implements IGmyDataExchangApiService {
|
|
|
String transTypeCode = ObjectUtils.isNotNull(decl.getTransTypeCode()) ? decl.getTransTypeCode() : "";
|
|
|
String ieType = ObjectUtils.isNotNull(decl.getIeType()) ? decl.getIeType() : "";
|
|
|
|
|
|
- if(id<=0){
|
|
|
- if(transTypeCode.isEmpty() || ieType.isEmpty()) {
|
|
|
+ if (id <= 0) {
|
|
|
+ if (transTypeCode.isEmpty() || ieType.isEmpty()) {
|
|
|
throw new RuntimeException("缺少运输方式和进出口标志参数!");
|
|
|
}
|
|
|
}
|
|
|
@@ -576,7 +577,7 @@ public class GmyDataExchangApiServiceImpl implements IGmyDataExchangApiService {
|
|
|
lambdaQueryWrapper.eq(GmyDeclHead::getIsDeleted, 0)
|
|
|
.eq(GmyDeclHead::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(GmyDeclHead::getBranchId, BRANCH_ID)
|
|
|
- .eq(id>0, GmyDeclHead::getId, id)
|
|
|
+ .eq(id > 0, GmyDeclHead::getId, id)
|
|
|
// 2 海运 5 空运
|
|
|
.eq(ObjectUtils.isNotNull(transTypeCode), GmyDeclHead::getTransTypeCode, transTypeCode)
|
|
|
// E 出口 I 进口
|
|
|
@@ -594,9 +595,9 @@ public class GmyDataExchangApiServiceImpl implements IGmyDataExchangApiService {
|
|
|
lambdaQueryWrapper.ge(GmyDeclHead::getDeclDate, decl.getDeclDateList().get(0));
|
|
|
lambdaQueryWrapper.le(GmyDeclHead::getDeclDate, decl.getDeclDateList().get(1));
|
|
|
}
|
|
|
- if(ObjectUtils.isNotNull(decl.getStatus())) {
|
|
|
+ if (ObjectUtils.isNotNull(decl.getStatus())) {
|
|
|
lambdaQueryWrapper.eq(GmyDeclHead::getStatus, decl.getStatus());
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
lambdaQueryWrapper.eq(GmyDeclHead::getStatus, 0);
|
|
|
}
|
|
|
|
|
|
@@ -607,9 +608,9 @@ public class GmyDataExchangApiServiceImpl implements IGmyDataExchangApiService {
|
|
|
|
|
|
@Override
|
|
|
public R<GmyDeclHead> detail(String id) throws Exception {
|
|
|
- if(ObjectUtils.isNotNull(id)){
|
|
|
+ if (ObjectUtils.isNotNull(id)) {
|
|
|
GmyDeclHead declHead = gmyDeclHeadService.getById(id);
|
|
|
- if(ObjectUtils.isNotNull(declHead)) {
|
|
|
+ if (ObjectUtils.isNotNull(declHead)) {
|
|
|
List<GmyDeclGoods> goodsList = gmyDeclGoodsService.list(new LambdaQueryWrapper<GmyDeclGoods>()
|
|
|
.eq(GmyDeclGoods::getIsDeleted, 0)
|
|
|
.eq(GmyDeclGoods::getTenantId, AuthUtil.getTenantId())
|
|
|
@@ -621,7 +622,7 @@ public class GmyDataExchangApiServiceImpl implements IGmyDataExchangApiService {
|
|
|
}
|
|
|
|
|
|
return R.data(declHead);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return R.data(new GmyDeclHead());
|
|
|
}
|
|
|
}
|
|
|
@@ -629,7 +630,7 @@ public class GmyDataExchangApiServiceImpl implements IGmyDataExchangApiService {
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public R<List<GmyDeclHead>> importDecl(String ids) throws Exception {
|
|
|
- if(ObjectUtils.isNotNull(ids)) {
|
|
|
+ if (ObjectUtils.isNotNull(ids)) {
|
|
|
List<GmyDeclHead> declHeads = gmyDeclHeadService.list(new LambdaQueryWrapper<GmyDeclHead>()
|
|
|
.eq(GmyDeclHead::getIsDeleted, 0)
|
|
|
.eq(GmyDeclHead::getTenantId, AuthUtil.getTenantId())
|
|
|
@@ -638,7 +639,7 @@ public class GmyDataExchangApiServiceImpl implements IGmyDataExchangApiService {
|
|
|
.in(GmyDeclHead::getId, ids)
|
|
|
.eq(GmyDeclHead::getStatus, 0));
|
|
|
|
|
|
- if(ObjectUtils.isNotNull(declHeads) && !declHeads.isEmpty()){
|
|
|
+ if (ObjectUtils.isNotNull(declHeads) && !declHeads.isEmpty()) {
|
|
|
List<BCorps> corps = new ArrayList<>();
|
|
|
List<BCountrys> cntrys = new ArrayList<>();
|
|
|
List<String> updateIds = new ArrayList<>();
|
|
|
@@ -653,19 +654,22 @@ public class GmyDataExchangApiServiceImpl implements IGmyDataExchangApiService {
|
|
|
String ieType = ObjectUtils.isNotNull(declHead.getIeType()) ? declHead.getIeType() : "";
|
|
|
// BGSE=海运出口报关 BGSI=海运进口报关 BGAE=空运出口报关 BGAI=空运进口报关
|
|
|
String declBusinessType = "";
|
|
|
- if("2".equals(transTypeCode)){
|
|
|
- declBusinessType = ieType=="E" ? "BGSE" : "BGSI";
|
|
|
+ String billNoFormat = "";
|
|
|
+ if ("2".equals(transTypeCode)) {
|
|
|
+ declBusinessType = ieType == "E" ? "BGSE" : "BGSI";
|
|
|
+ billNoFormat = ieType == "E" ? "BG-HYCK" : "BG-HYJK";
|
|
|
}
|
|
|
- if("5".equals(transTypeCode)){
|
|
|
- declBusinessType = ieType=="E" ? "BGAE" : "BGAI";
|
|
|
+ if ("5".equals(transTypeCode)) {
|
|
|
+ declBusinessType = ieType == "E" ? "BGAE" : "BGAI";
|
|
|
+ billNoFormat = ieType == "E" ? "BG-KYCK" : "BG-KYJK";
|
|
|
}
|
|
|
|
|
|
String import_message = "";
|
|
|
|
|
|
- if(!declBusinessType.isEmpty() && ObjectUtils.isNotNull(declHead.getBillNo())) {
|
|
|
+ if (!declBusinessType.isEmpty() && ObjectUtils.isNotNull(declHead.getBillNo())) {
|
|
|
BCorps corp = null;
|
|
|
BCountrys cntry = null;
|
|
|
- // 1 校验是否允许导入
|
|
|
+ // 1 校验是否允许导入
|
|
|
// a: 导入的提单号在系统中已存在 cusDecl.getMblno()=>declHead.getBillNo()
|
|
|
CustomsDeclaration cusDecltmp = customsDeclarationService.getOne(new LambdaQueryWrapper<CustomsDeclaration>()
|
|
|
.eq(CustomsDeclaration::getTenantId, AuthUtil.getTenantId())
|
|
|
@@ -675,12 +679,12 @@ public class GmyDataExchangApiServiceImpl implements IGmyDataExchangApiService {
|
|
|
.eq(CustomsDeclaration::getMblno, declHead.getBillNo())
|
|
|
.notLike(CustomsDeclaration::getBillNo, "TAOCD")
|
|
|
.last("limit 1"));
|
|
|
- if(ObjectUtils.isNotNull(cusDecltmp)){
|
|
|
+ if (ObjectUtils.isNotNull(cusDecltmp)) {
|
|
|
canImport = false;
|
|
|
import_message += "导入的提单号在系统中已存在!\n";
|
|
|
}
|
|
|
// b: 导入的报关单号在系统中已存在 cusDecl.getCustomsDeclarationNumber()=>declHead.getCustomsNo()
|
|
|
- if(canImport){
|
|
|
+ if (canImport) {
|
|
|
CustomsDeclaration cusDecltmp2 = customsDeclarationService.getOne(new LambdaQueryWrapper<CustomsDeclaration>()
|
|
|
.eq(CustomsDeclaration::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(CustomsDeclaration::getBranchId, deptUtils.getDeptPid() + "")
|
|
|
@@ -689,24 +693,24 @@ public class GmyDataExchangApiServiceImpl implements IGmyDataExchangApiService {
|
|
|
.eq(CustomsDeclaration::getCustomsDeclarationNumber, declHead.getCustomsNo())
|
|
|
.notLike(CustomsDeclaration::getBillNo, "TAOCD")
|
|
|
.last("limit 1"));
|
|
|
- if(ObjectUtils.isNotNull(cusDecltmp2)){
|
|
|
+ if (ObjectUtils.isNotNull(cusDecltmp2)) {
|
|
|
canImport = false;
|
|
|
import_message += "导入的报关单号在系统中已存在!\n";
|
|
|
}
|
|
|
}
|
|
|
// c: 客户编号未匹配,不允许导入,请进行维护 bCorps.getGmyCode()=>
|
|
|
- if(canImport){
|
|
|
+ if (canImport) {
|
|
|
corp = getCorpByGmyCode(corps, declHead.getCorpNo());
|
|
|
- if(ObjectUtils.isNotNull(corp)){
|
|
|
+ if (ObjectUtils.isNull(corp)) {
|
|
|
canImport = false;
|
|
|
import_message += "客户编号未匹配,不允许导入,请进行维护!\n";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// d: 国家编号未匹配(运抵国 or 指运港),不允许导入,请进行维护!
|
|
|
- if(canImport){
|
|
|
+ if (canImport) {
|
|
|
cntry = getCountryByGmyCode(cntrys, declHead.getCountryCode());
|
|
|
- if(ObjectUtils.isNotNull(cntry)){
|
|
|
+ if (ObjectUtils.isNull(cntry)) {
|
|
|
canImport = false;
|
|
|
import_message += "国家编号未匹配(运抵国 or 指运港),不允许导入,请进行维护!\n";
|
|
|
}
|
|
|
@@ -715,54 +719,70 @@ public class GmyDataExchangApiServiceImpl implements IGmyDataExchangApiService {
|
|
|
// e: 导入的数据中没有费用,不允许导入 费用编号未匹配,不允许导入,请进行维护!
|
|
|
List<GmyDeclCosts> declCosts = null;
|
|
|
List<BFees> bFees = null;
|
|
|
- if(canImport){
|
|
|
+ if (canImport) {
|
|
|
declCosts = gmyDeclCostsService.list(new LambdaQueryWrapper<GmyDeclCosts>()
|
|
|
.eq(GmyDeclCosts::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(GmyDeclCosts::getBranchId, BRANCH_ID + "")
|
|
|
.eq(GmyDeclCosts::getIsDeleted, 0)
|
|
|
.eq(GmyDeclCosts::getWorkNo, declHead.getWorkNo()));
|
|
|
- if(ObjectUtils.isNull(declCosts) || declCosts.isEmpty()){
|
|
|
+ if (ObjectUtils.isNull(declCosts) || declCosts.isEmpty()) {
|
|
|
canImport = false;
|
|
|
import_message += "导入的数据中没有费用,不允许导入!\n";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(canImport){
|
|
|
+ if (canImport) {
|
|
|
List<String> feeTypeCodes = declCosts.stream().map(GmyDeclCosts::getFeeTypeCode).distinct().collect(Collectors.toList());
|
|
|
- if(!feeTypeCodes.isEmpty()){
|
|
|
+ if (!feeTypeCodes.isEmpty()) {
|
|
|
bFees = feeService.list(new LambdaQueryWrapper<BFees>()
|
|
|
.eq(BFees::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(BFees::getIsDeleted, 0)
|
|
|
.in(BFees::getGmyCode, feeTypeCodes));
|
|
|
}
|
|
|
|
|
|
- if(ObjectUtils.isNull(bFees)){
|
|
|
+ if (ObjectUtils.isNull(bFees)) {
|
|
|
bFees = new ArrayList<>();
|
|
|
}
|
|
|
|
|
|
for (String feeTypeCode : feeTypeCodes) {
|
|
|
- if(bFees.stream().filter(f->f.getGmyCode()==feeTypeCode).count()==0){
|
|
|
+ if (bFees.stream().noneMatch(f -> f.getGmyCode().equals(feeTypeCode))) {
|
|
|
canImport = false;
|
|
|
import_message += "关贸云费用代码 " + feeTypeCode + " 没有维护!\n";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// 2 导入生成新的报关单
|
|
|
- if(canImport) {
|
|
|
+ if (canImport) {
|
|
|
CustomsDeclaration cusDecl = new CustomsDeclaration();
|
|
|
List<CustomsDeclarationGoods> cusDeclGoods = new ArrayList<>();
|
|
|
|
|
|
// 1 维护主表
|
|
|
cusDecl.setBusinessType(declBusinessType);
|
|
|
cusDecl.setBusinessTypeCode(declBusinessType);
|
|
|
+ cusDecl.setBillNoFormat(billNoFormat);
|
|
|
cusDecl.setCorpId(corp.getId());
|
|
|
cusDecl.setCorpCnName(corp.getCnName());
|
|
|
cusDecl.setCorpEnName(corp.getEnName());
|
|
|
// if ((Pos('_01',Acds.Fieldbyname('BILL_NO').asString)>0) and (Copy(Acds.Fieldbyname('BILL_NO').asString,Pos('_01',Acds.Fieldbyname('BILL_NO').asString),20)<>''))
|
|
|
// or ((Pos('_',Acds.Fieldbyname('BILL_NO').asString)>0) and (Pos('_01',Acds.Fieldbyname('BILL_NO').asString)=0)) then
|
|
|
// Parambyname('MBLNO').asString:=Copy(Acds.Fieldbyname('BILL_NO').asString,Pos('_',Acds.Fieldbyname('BILL_NO').asString),20)
|
|
|
- // else Parambyname('MBLNO').asString:=Copy(Acds.Fieldbyname('BILL_NO').asString,1,20);
|
|
|
- String billNo=declHead.getBillNo(), mblNo = billNo.contains("_") ? billNo.substring(billNo.indexOf("_"), billNo.indexOf("_") + 20) : billNo.substring(0, 20);
|
|
|
+ // else Parambyname('MBLNO').asString:=Copy(Acds.Fieldbyname('BILL_NO').asString,1,20);
|
|
|
+ String billNo = declHead.getBillNo();
|
|
|
+ String mblNo;
|
|
|
+ if (billNo.contains("_")) {
|
|
|
+ String temporary = billNo.substring(billNo.indexOf("_"));
|
|
|
+ if (temporary.length()>20){
|
|
|
+ mblNo = billNo.substring(billNo.indexOf("_"), billNo.indexOf("_") + 20);
|
|
|
+ }else{
|
|
|
+ mblNo = billNo.substring(billNo.indexOf("_"));
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if (billNo.length()>20){
|
|
|
+ mblNo = billNo.substring(0, 20);
|
|
|
+ }else{
|
|
|
+ mblNo = billNo;
|
|
|
+ }
|
|
|
+ }
|
|
|
cusDecl.setMblno(mblNo);
|
|
|
cusDecl.setDeliveryNumbers(declHead.getContrNo());
|
|
|
cusDecl.setEtdDate(declHead.getIeDate());
|
|
|
@@ -795,7 +815,7 @@ public class GmyDataExchangApiServiceImpl implements IGmyDataExchangApiService {
|
|
|
.eq(GmyDeclGoods::getIsDeleted, 0)
|
|
|
// 根据 dcclNo 关联
|
|
|
.eq(GmyDeclGoods::getDeclNo, declHead.getDeclNo()));
|
|
|
- if(ObjectUtils.isNotNull(declGoods)){
|
|
|
+ if (ObjectUtils.isNotNull(declGoods)) {
|
|
|
for (GmyDeclGoods declGood : declGoods) {
|
|
|
CustomsDeclarationGoods cusDeclGood = new CustomsDeclarationGoods();
|
|
|
cusDeclGood.setSort(declGood.getGoodsSeq()); // cusDeclGoods.size() + 1
|
|
|
@@ -823,13 +843,13 @@ public class GmyDataExchangApiServiceImpl implements IGmyDataExchangApiService {
|
|
|
}
|
|
|
|
|
|
// 更新数据库
|
|
|
- if(!addedCusDecls.isEmpty()){
|
|
|
- for (CustomsDeclaration addedCusDecl: addedCusDecls) {
|
|
|
+ if (!addedCusDecls.isEmpty()) {
|
|
|
+ for (CustomsDeclaration addedCusDecl : addedCusDecls) {
|
|
|
// submit 同时保存商品和费用
|
|
|
customsDeclarationService.submit(addedCusDecl);
|
|
|
}
|
|
|
}
|
|
|
- if(!updateIds.isEmpty()) {
|
|
|
+ if (!updateIds.isEmpty()) {
|
|
|
gmyDeclHeadService.update(null, new LambdaUpdateWrapper<GmyDeclHead>()
|
|
|
.set(GmyDeclHead::getStatus, 9)
|
|
|
.in(GmyDeclHead::getId, updateIds)
|
|
|
@@ -838,7 +858,7 @@ public class GmyDataExchangApiServiceImpl implements IGmyDataExchangApiService {
|
|
|
}
|
|
|
|
|
|
return R.data(declHeads);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return R.data(new ArrayList<>());
|
|
|
}
|
|
|
}
|