|
@@ -38,6 +38,9 @@ import com.usoftchina.saas.purchase.service.ProdInOutService;
|
|
|
import com.usoftchina.saas.purchase.service.PurchaseService;
|
|
import com.usoftchina.saas.purchase.service.PurchaseService;
|
|
|
import com.usoftchina.saas.utils.BeanMapper;
|
|
import com.usoftchina.saas.utils.BeanMapper;
|
|
|
import com.usoftchina.saas.utils.CollectionUtils;
|
|
import com.usoftchina.saas.utils.CollectionUtils;
|
|
|
|
|
+import com.usoftchina.saas.utils.JsonUtils;
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -45,6 +48,7 @@ import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.concurrent.CountDownLatch;
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -81,6 +85,7 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private AccountApi accountApi;
|
|
private AccountApi accountApi;
|
|
|
|
|
|
|
|
|
|
+ private static final Logger LOGGER = LoggerFactory.getLogger(PurchaseServiceImpl.class);
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public PageInfo<PurchaseList> getListData(PageRequest page, ListReqDTO req) {
|
|
public PageInfo<PurchaseList> getListData(PageRequest page, ListReqDTO req) {
|
|
@@ -187,10 +192,10 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
|
|
|
return baseDTO;
|
|
return baseDTO;
|
|
|
}
|
|
}
|
|
|
//校验有来源的验收验退币别是否与源单据一致
|
|
//校验有来源的验收验退币别是否与源单据一致
|
|
|
- String puCode = purchaseMapper.validateCurrency(pu_id,purchase.getPu_currency());
|
|
|
|
|
- if(puCode!=null){
|
|
|
|
|
- throw new BizException(BizExceptionCode.CURRENCY_VALID);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // String puCode = purchaseMapper.validateCurrency(pu_id,purchase.getPu_currency());
|
|
|
|
|
+// if(puCode!=null){
|
|
|
|
|
+// throw new BizException(BizExceptionCode.CURRENCY_VALID);
|
|
|
|
|
+// }
|
|
|
//更新操作
|
|
//更新操作
|
|
|
purchaseMapper.updateByPrimaryKeySelective(purchase);
|
|
purchaseMapper.updateByPrimaryKeySelective(purchase);
|
|
|
//添加从表传输对象
|
|
//添加从表传输对象
|
|
@@ -682,9 +687,11 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
|
|
|
IPage<PurcInquiryItemInfo> purcInquiryItemInfoIPage = null;
|
|
IPage<PurcInquiryItemInfo> purcInquiryItemInfoIPage = null;
|
|
|
Long enUU = companyApi.getCompanyById(BaseContextHolder.getCompanyId()).getData().getUu();
|
|
Long enUU = companyApi.getCompanyById(BaseContextHolder.getCompanyId()).getData().getUu();
|
|
|
if (inquiryReqDTO.getQuoted() == 1){
|
|
if (inquiryReqDTO.getQuoted() == 1){
|
|
|
- purcInquiryItemInfoIPage = inquiryApi.findQuotationsByPage("done", enUU, inquiryReqDTO.getPageNumber(), inquiryReqDTO.getPageSize());
|
|
|
|
|
|
|
+ purcInquiryItemInfoIPage = inquiryApi.findQuotationsByPage("done", enUU, inquiryReqDTO.getPageNumber(), inquiryReqDTO.getPageSize(),
|
|
|
|
|
+ inquiryReqDTO.getFromDate(), inquiryReqDTO.getKeyword(), inquiryReqDTO.getOverdue(), inquiryReqDTO.getEndDate());
|
|
|
}else{
|
|
}else{
|
|
|
- purcInquiryItemInfoIPage = inquiryApi.getInquiryList(enUU, inquiryReqDTO.getOverdue(), inquiryReqDTO.getPageNumber(), inquiryReqDTO.getPageSize(), "todo");
|
|
|
|
|
|
|
+ purcInquiryItemInfoIPage = inquiryApi.getInquiryList(enUU, inquiryReqDTO.getOverdue(), inquiryReqDTO.getPageNumber(), inquiryReqDTO.getPageSize(),
|
|
|
|
|
+ "todo", inquiryReqDTO.getFromDate(), inquiryReqDTO.getKeyword(), inquiryReqDTO.getEndDate());
|
|
|
}
|
|
}
|
|
|
List<PurcInquiryItemInfo> purcInquiryItemInfoList = purcInquiryItemInfoIPage.getContent();
|
|
List<PurcInquiryItemInfo> purcInquiryItemInfoList = purcInquiryItemInfoIPage.getContent();
|
|
|
if (CollectionUtils.isEmpty(purcInquiryItemInfoList)){
|
|
if (CollectionUtils.isEmpty(purcInquiryItemInfoList)){
|
|
@@ -718,7 +725,7 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
|
|
|
* @param inquiryAddDTOList
|
|
* @param inquiryAddDTOList
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public void saveInquiry(List<InquiryAddDTO> inquiryAddDTOList) {
|
|
|
|
|
|
|
+ public List<Map<String, String>> saveInquiry(List<InquiryAddDTO> inquiryAddDTOList) {
|
|
|
List<PurcInquiry> purcInquiryList = new ArrayList<PurcInquiry>();
|
|
List<PurcInquiry> purcInquiryList = new ArrayList<PurcInquiry>();
|
|
|
CompanyRspDTO companyRspDTO = companyApi.getCompanyRspDTOById(BaseContextHolder.getCompanyId()).getData();
|
|
CompanyRspDTO companyRspDTO = companyApi.getCompanyRspDTOById(BaseContextHolder.getCompanyId()).getData();
|
|
|
AccountDTO accountDTO = accountApi.getAccountById(BaseContextHolder.getUserId()).getData();
|
|
AccountDTO accountDTO = accountApi.getAccountById(BaseContextHolder.getUserId()).getData();
|
|
@@ -734,6 +741,7 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
|
|
|
PurcInquiry purcInquiry = new PurcInquiry();
|
|
PurcInquiry purcInquiry = new PurcInquiry();
|
|
|
//询价主表信息
|
|
//询价主表信息
|
|
|
purcInquiry.setEnterprise(enterprise);
|
|
purcInquiry.setEnterprise(enterprise);
|
|
|
|
|
+ purcInquiry.setEnUU(companyRspDTO.getUu());
|
|
|
purcInquiry.setEnName(companyRspDTO.getName());
|
|
purcInquiry.setEnName(companyRspDTO.getName());
|
|
|
purcInquiry.setRecorderUU(accountDTO.getUu());
|
|
purcInquiry.setRecorderUU(accountDTO.getUu());
|
|
|
purcInquiry.setDate(new Date());
|
|
purcInquiry.setDate(new Date());
|
|
@@ -758,8 +766,37 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
|
|
|
purcInquiry.setInquiryItems(purcInquiryItemSet);
|
|
purcInquiry.setInquiryItems(purcInquiryItemSet);
|
|
|
purcInquiryList.add(purcInquiry);
|
|
purcInquiryList.add(purcInquiry);
|
|
|
}
|
|
}
|
|
|
- //调用商城ap,保存询价
|
|
|
|
|
-
|
|
|
|
|
|
|
+ //开启线程调用商城ap,保存询价
|
|
|
|
|
+ int length = purcInquiryList.size();
|
|
|
|
|
+ CountDownLatch latch = new CountDownLatch(length);
|
|
|
|
|
+ List<Map<String, String>> result = new ArrayList<Map<String, String>>(); //失败数据
|
|
|
|
|
+ for (int i = 0; i < length; i++) {
|
|
|
|
|
+ PurcInquiry purcInquiry = purcInquiryList.get(i);
|
|
|
|
|
+ new Thread(new Runnable() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void run() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ PurcInquiry result = inquiryApi.saveInquiry(purcInquiry);
|
|
|
|
|
+ LOGGER.info("发起询价,成功,返回数据: {}", JsonUtils.toJsonString(result));
|
|
|
|
|
+ latch.countDown();
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ LOGGER.info("发起询价,失败,传入数据: {}, 失败原因: {}, 返回结果: {}", JsonUtils.toJsonString(purcInquiry), e.getMessage(), JsonUtils.toJsonString(result));
|
|
|
|
|
+ Map<String, String> map = new HashMap<String, String>();
|
|
|
|
|
+ map.put("errCode", purcInquiry.getInquiryItems().iterator().next().getProdCode());
|
|
|
|
|
+ result.add(map);
|
|
|
|
|
+ latch.countDown();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }).start();
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ latch.await();
|
|
|
|
|
+ LOGGER.info("发起询价,处理完成.");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -777,7 +814,7 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
|
|
|
inquiryRspDTO.setProdBrand(purcInquiryItemInfo.getProduct().getBrand());
|
|
inquiryRspDTO.setProdBrand(purcInquiryItemInfo.getProduct().getBrand());
|
|
|
inquiryRspDTO.setProdName(purcInquiryItemInfo.getProdTitle());
|
|
inquiryRspDTO.setProdName(purcInquiryItemInfo.getProdTitle());
|
|
|
inquiryRspDTO.setProdSpec(purcInquiryItemInfo.getSpec());
|
|
inquiryRspDTO.setProdSpec(purcInquiryItemInfo.getSpec());
|
|
|
- inquiryRspDTO.setStartDate(purcInquiryItemInfo.getFromDate());
|
|
|
|
|
|
|
+ inquiryRspDTO.setStartDate(purcInquiryItemInfo.getDate());
|
|
|
inquiryRspDTO.setEndDate(purcInquiryItemInfo.getEndDate());
|
|
inquiryRspDTO.setEndDate(purcInquiryItemInfo.getEndDate());
|
|
|
inquiryRspDTO.setQuoted(purcInquiryItemInfo.getQuoted());
|
|
inquiryRspDTO.setQuoted(purcInquiryItemInfo.getQuoted());
|
|
|
//报价信息
|
|
//报价信息
|
|
@@ -792,6 +829,7 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
|
|
|
quotationRspDTO.setLeadTime(publicInquiryItem.getLeadtime());
|
|
quotationRspDTO.setLeadTime(publicInquiryItem.getLeadtime());
|
|
|
quotationRspDTO.setTel(publicInquiryItem.getUserTel());
|
|
quotationRspDTO.setTel(publicInquiryItem.getUserTel());
|
|
|
quotationRspDTO.setAgreed(publicInquiryItem.getAgreed());
|
|
quotationRspDTO.setAgreed(publicInquiryItem.getAgreed());
|
|
|
|
|
+ quotationRspDTO.setRefusereason(publicInquiryItem.getRefusereason());
|
|
|
quotationRspDTO.setReplaceOrispeccode(publicInquiryItem.getCmpCode());
|
|
quotationRspDTO.setReplaceOrispeccode(publicInquiryItem.getCmpCode());
|
|
|
//分段报价信息
|
|
//分段报价信息
|
|
|
List<PublicInquiryReply> publicInquiryReplyList = publicInquiryItem.getReplies();
|
|
List<PublicInquiryReply> publicInquiryReplyList = publicInquiryItem.getReplies();
|