Browse Source

询价单接口

yuansh 1 week ago
parent
commit
ea2c828d18

+ 9 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/SysDictMapper.java

@@ -57,6 +57,15 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
 	 */
 	List<DictModel> queryEnableDictItemsByCode(@Param("code") String code);
 
+	/**
+	 *
+	 * @param dictCode
+	 * @param value
+	 * @param text
+	 * @return
+	 */
+	List<DictModel> selectByChild(@Param("dictCode") String dictCode,@Param("value") String value,@Param("text") String text);
+
 
 	/**
 	 * 通过多个字典code获取字典数据

+ 13 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/SysDictMapper.xml

@@ -2,6 +2,19 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.modules.system.mapper.SysDictMapper">
 
+	<select id="selectByChild" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
+
+		select s.item_value as "value",s.item_text as "text",s.item_color as color from sys_dict_item s
+		where dict_id = (select id from sys_dict where dict_code = #{dictCode})
+		<if test="value != null and value != ''">
+		  and item_value=#{value}
+		</if>
+		<if test="text != null and text != ''">
+		   and item_text=#{text}
+		</if>
+
+	</select>
+
 	<!-- 通过字典code获取字典数据 -->
 	<select id="queryDictItemsByCode" parameterType="String"  resultType="org.jeecg.common.system.vo.DictModel">
 		   select s.item_value as "value",s.item_text as "text",s.item_color as color from sys_dict_item s

+ 4 - 4
srm-module-code/src/main/java/org/jeecg/modules/cuspCode/mapper/xml/CuspCustomerProfileManMapper.xml

@@ -3,13 +3,13 @@
 <mapper namespace="org.jeecg.modules.cuspCode.mapper.CuspCustomerProfileManMapper">
 
 	<delete id="deleteByMainId" parameterType="java.lang.String">
-		DELETE 
-		FROM  cusp_customer_profile_man 
+		DELETE
+		FROM  cusp_customer_profile_man
 		WHERE
 			 head_id = #{mainId} 	</delete>
-	
+
 	<select id="selectByMainId" parameterType="java.lang.String" resultType="org.jeecg.modules.cuspCode.entity.CuspCustomerProfileMan">
-		SELECT * 
+		SELECT *
 		FROM  cusp_customer_profile_man
 		WHERE
 			 head_id = #{mainId} 	</select>

+ 26 - 4
srm-module-code/src/main/java/org/jeecg/modules/saleCode/controller/SaleInquiryFormController.java

@@ -1,10 +1,7 @@
 package org.jeecg.modules.saleCode.controller;
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 import javax.servlet.http.HttpServletRequest;
@@ -324,6 +321,31 @@ public class SaleInquiryFormController {
             String submit = o.getSubmit();
             String code = o.getBillCode();
 
+            String inquiryProject = o.getInquiryProject();
+            String inquiryCustomer = o.getInquiryCustomer();
+            String inquiryPlatform = o.getInquiryPlatform();
+            String liaisonId = o.getLiaisonId();
+            String customerInquiryNumber = o.getCustomerInquiryNumber();
+            Date inquiryTime = o.getInquiryTime();
+            String model = o.getModel();
+            String maker = o.getMaker();
+            String qualityGradeHead = o.getQualityGradeHead();
+
+            if(StringUtils.isBlank(inquiryProject) ||
+                    StringUtils.isBlank(inquiryCustomer) ||
+                    StringUtils.isBlank(inquiryPlatform) ||
+                    StringUtils.isBlank(liaisonId) ||
+                    StringUtils.isBlank(customerInquiryNumber) ||
+                    inquiryTime==null ||
+                    StringUtils.isBlank(model) ||
+                    StringUtils.isBlank(maker) ||
+                    StringUtils.isBlank(qualityGradeHead)
+
+            ){
+                sb.append("单据编码" + code).append("必填信息未完善,请先维护;");
+                continue;
+            }
+
             if (submit != null && submit != "" && submit.equals("1")) {
                 sb.append("单据编码" + code).append("已提交,请勿再次提交;");
                 continue;

+ 22 - 14
srm-module-code/src/main/java/org/jeecg/modules/saleCode/controller/SaleInterfaceSyncController.java

@@ -14,8 +14,8 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.lang.StringUtils;
-import org.jeecg.modules.saleCode.entity.SaleInterfaceSync;
-import org.jeecg.modules.saleCode.entity.SaleOrder;
+import org.jeecg.modules.saleCode.entity.*;
+import org.jeecg.modules.saleCode.service.ISaleInquiryFormService;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
 import org.jeecgframework.poi.excel.entity.ExportParams;
@@ -27,7 +27,6 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.query.QueryRuleEnum;
 import org.jeecg.common.util.oConvertUtils;
-import org.jeecg.modules.saleCode.entity.SaleInterfaceItem;
 import org.jeecg.modules.saleCode.entity.SaleInterfaceSync;
 import org.jeecg.modules.saleCode.vo.SaleInterfaceSyncPage;
 import org.jeecg.modules.saleCode.service.ISaleInterfaceSyncService;
@@ -64,6 +63,8 @@ public class SaleInterfaceSyncController {
 	private ISaleInterfaceSyncService saleInterfaceSyncService;
 	@Autowired
 	private ISaleInterfaceItemService saleInterfaceItemService;
+	 @Autowired
+	 private ISaleInquiryFormService saleInquiryFormService;
 	
 	/**
 	 * 分页列表查询
@@ -185,8 +186,14 @@ public class SaleInterfaceSyncController {
 		 for (SaleInterfaceSync o : list) {
 			 // 1-已提交,0-未提交
 			 Integer submit = o.getSubmit();
+			 // 1-已关闭,0-未关闭
+			 Integer close = o.getClose();
 			 String code = o.getReferenceNumber();
 
+			 if (close != null && close.equals(1)) {
+				 sb.append("编号" + code).append("已关闭,无法提交;");
+				 continue;
+			 }
 			 if (submit != null && submit.equals(1)) {
 				 sb.append("编号" + code).append("已提交,请勿再次提交;");
 				 continue;
@@ -229,23 +236,23 @@ public class SaleInterfaceSyncController {
 			 //提交(1-是 ,0-否)
 			 Integer submit = o.getSubmit();
 			 String code = o.getReferenceNumber();
+			 String syncCode = o.getSyncCode();
 
 			 if (submit == null || submit.equals(0)) {
 				 sb.append("单号" + code).append("已取消提交,请勿再次取消提交;");
 				 continue;
 			 }
 
-//			 QueryWrapper<SaleOrder> querySaleOrder = new QueryWrapper();
-//			 querySaleOrder.eq("source_code2", code);
-//			 querySaleOrder.eq("del_flag", "0");
-//
-//			 List<SaleOrder> listSaleOrder = saleOrderService.list(querySaleOrder);
-//			 if(listSaleOrder.size() > 0){
-//				 List<String> codeList = listSaleOrder.stream().map(SaleOrder::getBillCode).collect(Collectors.toList());
-//				 String codes = StringUtils.join(codeList.toArray(), ",");
-//				 sb.append("单号" + code).append("已被销售订单使用,请勿取消提交"+codes+";");
-//				 continue;
-//			 }
+			 QueryWrapper<SaleInquiryForm> querySaleOrder = new QueryWrapper();
+			 querySaleOrder.eq("bill_code", syncCode);
+			 querySaleOrder.eq("del_flag", "0");
+
+			 List<SaleInquiryForm> listSaleOrder = saleInquiryFormService.list(querySaleOrder);
+			 if(listSaleOrder.size() > 0){
+
+				 sb.append("单号" + code).append("已被销售询价单使用,请先删除销售询价单"+syncCode+";");
+				 continue;
+			 }
 		 }
 		 if (StringUtils.isNotBlank(sb.toString())) {
 
@@ -254,6 +261,7 @@ public class SaleInterfaceSyncController {
 
 		 SaleInterfaceSync ent = new SaleInterfaceSync();
 		 ent.setSubmit(0);
+		 ent.setSync(0);
 		 saleInterfaceSyncService.update(ent, queryWrapper);
 
 		 return Result.OK("取消提交成功!");

+ 74 - 6
srm-module-code/src/main/java/org/jeecg/modules/saleCode/service/impl/SaleInterfaceSyncServiceImpl.java

@@ -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("同步订单成功!");