|
@@ -9,6 +9,7 @@ import io.micrometer.core.instrument.util.StringUtils;
|
|
|
import io.swagger.annotations.ApiModelProperty;
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.common.system.vo.DictModel;
|
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
|
import org.jeecg.modules.baseCode.entity.BaseProductArchive;
|
|
|
import org.jeecg.modules.baseCode.entity.BaseShipArchive;
|
|
@@ -17,11 +18,14 @@ import org.jeecg.modules.baseCode.service.IBaseProductArchiveService;
|
|
|
import org.jeecg.modules.baseCode.service.IBaseShipArchiveService;
|
|
|
import org.jeecg.modules.baseCode.service.ISerialPatternService;
|
|
|
import org.jeecg.modules.cuspCode.entity.CuspCustomerProfile;
|
|
|
+import org.jeecg.modules.cuspCode.entity.CuspCustomerProfileMan;
|
|
|
+import org.jeecg.modules.cuspCode.mapper.CuspCustomerProfileManMapper;
|
|
|
import org.jeecg.modules.cuspCode.service.ICuspCustomerProfileService;
|
|
|
import org.jeecg.modules.saleCode.entity.*;
|
|
|
import org.jeecg.modules.saleCode.mapper.*;
|
|
|
import org.jeecg.modules.saleCode.service.ISaleInterfaceSyncService;
|
|
|
import org.jeecg.modules.saleCode.util.HttpUtils;
|
|
|
+import org.jeecg.modules.system.mapper.SysDictMapper;
|
|
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -49,6 +53,8 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
|
|
|
@Autowired
|
|
|
private ICuspCustomerProfileService cuspCustomerProfileService;
|
|
|
@Autowired
|
|
|
+ private CuspCustomerProfileManMapper cuspCustomerProfileManMapper;
|
|
|
+ @Autowired
|
|
|
private ISerialPatternService serialPatternService;
|
|
|
@Autowired
|
|
|
private IBaseShipArchiveService baseShipArchiveService;
|
|
@@ -62,6 +68,8 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
|
|
|
private IBaseProductArchiveService baseProductArchiveService;
|
|
|
@Autowired
|
|
|
private BaseProductArchiveMapper baseProductArchiveMapper;
|
|
|
+ @Autowired
|
|
|
+ private SysDictMapper sysDictMapper;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -275,17 +283,27 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
|
|
|
String currencyCode = ent.getCurrencyCode();//币种
|
|
|
|
|
|
QueryWrapper<CuspCustomerProfile> customerQuery = new QueryWrapper<>();
|
|
|
-// if(StringUtils.isNotBlank(currencyCode)){
|
|
|
-// customerQuery.eq("currency",currencyCode);
|
|
|
-// }
|
|
|
+ if(StringUtils.isNotBlank(currencyCode)){
|
|
|
+ List<DictModel> dict = sysDictMapper.selectByChild("currency",null,currencyCode);
|
|
|
+ if(dict.size() > 0){
|
|
|
+ customerQuery.eq("currency",dict.get(0).getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ customerQuery.eq("name", buyerName);
|
|
|
customerQuery.eq("status", 1);
|
|
|
customerQuery.eq("del_flag", 0);
|
|
|
List<CuspCustomerProfile> listCustomer = cuspCustomerProfileService.list(customerQuery);
|
|
|
if (listCustomer.size() == 0) {
|
|
|
- builder.append("客户'" + buyerName + "'未找到有效数据,请先维护客户档案;");
|
|
|
+ if(StringUtils.isBlank(currencyCode)){
|
|
|
+ builder.append("客户'" + buyerName +"'未找到档案数据,请先维护客户档案;");
|
|
|
+ }else{
|
|
|
+ builder.append("客户'" + buyerName +",币种"+ currencyCode+ " '未找到档案数据,请先维护客户档案;");
|
|
|
+ }
|
|
|
+
|
|
|
continue;
|
|
|
}
|
|
|
+ List<CuspCustomerProfileMan> cusMan = cuspCustomerProfileManMapper.selectByMainId(listCustomer.get(0).getId());
|
|
|
|
|
|
Date adviseBeforeDate = ent.getAdviseBeforeDate();//询价有效期尾
|
|
|
Date submittedDate = ent.getSubmittedDate();//客户询价日期
|
|
@@ -293,9 +311,52 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
|
|
|
String vesselImo = ent.getVesselImo();//船imo
|
|
|
String vesselCode = ent.getVesselCode();//船名
|
|
|
String priority = ent.getPriority();//优先级
|
|
|
+ if("Low".equals(priority)){
|
|
|
+ priority = "L";
|
|
|
+ }else if("Medium".equals(priority)){
|
|
|
+ priority = "M";
|
|
|
+ }else if("High".equals(priority)){
|
|
|
+ priority = "H";
|
|
|
+ }
|
|
|
+ String buyerContactName = ent.getBuyerContactName();//客户联系人姓名
|
|
|
+ String buyerContactJob = ent.getBuyerContactJob();//客户联系人职位
|
|
|
+ String buyerTelephone = ent.getBuyerTelephone();//客户联系人电话
|
|
|
+ String buyerEmail = ent.getBuyerEmail();//客户联系人Email
|
|
|
|
|
|
SaleInquiryForm saleInquiryForm = new SaleInquiryForm();
|
|
|
|
|
|
+ String contactName = "";
|
|
|
+ String contactId = "";
|
|
|
+
|
|
|
+ if(StringUtils.isNotBlank(buyerContactName) && cusMan.size() > 0){
|
|
|
+
|
|
|
+ for(CuspCustomerProfileMan o:cusMan){
|
|
|
+ String name = o.getName();
|
|
|
+ if(buyerContactName.equals(name)){
|
|
|
+ contactId = o.getId();
|
|
|
+ contactName = o.getName();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //未找到联系人时,新增一个联系人
|
|
|
+ if(StringUtils.isBlank(contactId)){
|
|
|
+
|
|
|
+ CuspCustomerProfileMan man = new CuspCustomerProfileMan();
|
|
|
+ man.setName(buyerContactName);
|
|
|
+ man.setMobile(buyerTelephone);
|
|
|
+ man.setEmail(buyerEmail);
|
|
|
+ man.setPosition(buyerContactJob);
|
|
|
+ man.setHeadId(listCustomer.get(0).getId());
|
|
|
+ cuspCustomerProfileManMapper.insert(man);
|
|
|
+
|
|
|
+ contactName = buyerContactName;
|
|
|
+ contactId = man.getId();
|
|
|
+ }
|
|
|
+ saleInquiryForm.setLiaisonId(contactId);//单据日期
|
|
|
+ saleInquiryForm.setLiaisonInfo(contactName);//单据日期
|
|
|
+
|
|
|
saleInquiryForm.setBillDate(new Date());//单据日期
|
|
|
saleInquiryForm.setInquiryTime(submittedDate);//客户询价日期
|
|
|
saleInquiryForm.setInquiryCustomer(listCustomer.get(0).getId());//询价客户
|
|
@@ -306,6 +367,9 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
|
|
|
saleInquiryForm.setPriority(priority);//询价有效期尾
|
|
|
saleInquiryForm.setInquiryNotes(comment);//询价表头备注
|
|
|
|
|
|
+ saleInquiryForm.setShipName(vesselCode);//船名称
|
|
|
+ saleInquiryForm.setImo(vesselImo);//船IMO
|
|
|
+
|
|
|
saleInquiryForm.setSaleDepartment(sysUser.getOrgCode());
|
|
|
// saleInquiryForm.setSaleDepartmentName();
|
|
|
saleInquiryForm.setSalesman(sysUser.getUsername());
|
|
@@ -339,8 +403,12 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
|
|
|
}
|
|
|
saleInquiryForm.setBillCode(result.getMessage());
|
|
|
|
|
|
- saleInquiryFormMapper.insert(saleInquiryForm);
|
|
|
List<SaleInterfaceItem> interfaceItemList = saleInterfaceItemMapper.selectByMainId(ent.getId());
|
|
|
+ if(interfaceItemList.size() == 0){
|
|
|
+ builder.append("编号:" + referenceNumber + "子表数据为空,无法执行;");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ saleInquiryFormMapper.insert(saleInquiryForm);
|
|
|
for (SaleInterfaceItem interfaceItem : interfaceItemList) {
|
|
|
String description = interfaceItem.getDescription();
|
|
|
String supplierPartNumber = interfaceItem.getSupplierPartNumber();
|
|
@@ -413,7 +481,7 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotBlank(builder.toString())) {
|
|
|
- return Result.OK(builder.toString());
|
|
|
+ return Result.error(builder.toString());
|
|
|
}
|
|
|
|
|
|
return Result.OK("同步订单成功!");
|