Browse Source

完善代码

yuansh 2 tuần trước cách đây
mục cha
commit
f347eb548f

+ 18 - 4
jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -8,10 +8,7 @@ import java.sql.Timestamp;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.time.Duration;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
+import java.time.*;
 import java.time.temporal.ChronoUnit;
 import java.util.Calendar;
 import java.util.Date;
@@ -854,6 +851,23 @@ public class DateUtils extends PropertyEditorSupport {
         return calendar.getTime();
     }
 
+    //当前时间增加1秒钟
+    //times 具体增加几秒
+    public static Date getNextTime(int times){
+
+        // 创建一个Date对象
+        Date date = new Date();
+//        System.out.println("原始时间: " + date);
+
+        // 使用Instant类增加一秒,然后转回Date对象
+        Instant instant = date.toInstant();
+        instant = instant.plusSeconds(times); // 增加一秒
+        date = Date.from(instant); // 转回Date对象
+
+//        System.out.println("增加一秒后的时间: " + date);
+        return date;
+    }
+
 
     public static void main(String[] args) {
         System.out.println(nowYear());

+ 8 - 27
srm-module-code/src/main/java/org/jeecg/modules/purCode/controller/PurOrderController.java

@@ -792,6 +792,9 @@ public class PurOrderController {
 
             for (PurOrderProduct product : purOrderProductList){
 
+                product.setDiscount(new BigDecimal("0"));
+                product.setTaxPriceOriginal(product.getTaxPrice());
+
                 SaleOrderProduct saleOrderProduct = saleOrderProductList.stream().filter(e -> e.getId().equals(product.getSourceId())).findFirst().orElse(null);
                 if (saleOrderProduct != null) {
 
@@ -809,32 +812,9 @@ public class PurOrderController {
                                 BigDecimal setTaxPrice = getSalePrice.divide(dis, 2, BigDecimal.ROUND_HALF_UP);
 
                                 product.setTaxPriceOriginal(setTaxPrice);
-                            }else{
-                                product.setDiscount(new BigDecimal("100"));
-                                product.setTaxPriceOriginal(quotationSelectionProduct.getTaxPrice());
                             }
-                        }else{
-                            product.setDiscount(new BigDecimal("100"));
-                            product.setTaxPriceOriginal(quotationSelectionProduct.getTaxPrice());
                         }
-//                        if (oConvertUtils.isNotEmpty(quotationSelectionProduct.getDiscount())) {
-//                            product.setDiscount(quotationSelectionProduct.getDiscount());
-//                            product.setTaxPriceOriginal(quotationSelectionProduct.getTaxPrice());
-//                        }else{
-//
-//                            BigDecimal dic = product.getDiscount() == null ? BigDecimal.ZERO : product.getDiscount();
-//                            BigDecimal dis = (new BigDecimal("100").subtract(dic)).divide(new BigDecimal("100"));
-//
-//                            BigDecimal getSalePrice = product.getTaxPrice() == null ? BigDecimal.ZERO : product.getTaxPrice();
-//                            BigDecimal setTaxPrice = getSalePrice.divide(dis, 4, BigDecimal.ROUND_HALF_UP);
-//
-//                            product.setTaxPriceOriginal(setTaxPrice);
-//                        }
-
-//
-//                        if (oConvertUtils.isNotEmpty(quotationSelectionProduct.getTaxPriceOriginal())) {
-//                            product.setTaxPriceOriginal(quotationSelectionProduct.getTaxPriceOriginal());
-//                        }
+
                     }
 
                 }
@@ -1054,13 +1034,14 @@ public class PurOrderController {
                     if (saleOrderProduct != null) {
 
                         SaleQuotationProduct saleQuotationProduct = saleQuotationProductList.stream().filter(e -> e.getId().equals(saleOrderProduct.getSourceId())).findFirst().orElse(null);
-                        if (saleOrderProduct != null) {
+                        if (saleQuotationProduct != null) {
                             PurQuotationSelectionProduct quotationSelectionProduct = purQuotationSelectionProductList.stream().filter(e -> e.getId().equals(saleQuotationProduct.getSourceId())).findFirst().orElse(null);
-                            if (oConvertUtils.isNotEmpty(quotationSelectionProduct.getDiscount())) {
+
+                            if (quotationSelectionProduct !=null && oConvertUtils.isNotEmpty(quotationSelectionProduct.getDiscount())) {
                                 product.setDiscountText(quotationSelectionProduct.getDiscount().intValue() + "%");
                             }
 
-                            BigDecimal dic = quotationSelectionProduct.getDiscount() ==null?BigDecimal.ZERO:quotationSelectionProduct.getDiscount();
+                            BigDecimal dic = quotationSelectionProduct==null || quotationSelectionProduct.getDiscount() ==null?BigDecimal.ZERO:quotationSelectionProduct.getDiscount();
                             BigDecimal dis = (new BigDecimal("100").subtract(dic)).divide(new BigDecimal("100"));
 
                             BigDecimal getSalePrice = product.getTaxPrice() == null ? BigDecimal.ZERO : product.getTaxPrice();

+ 1 - 1
srm-module-code/src/main/java/org/jeecg/modules/saleCode/mapper/xml/SaleOrderProductMapper.xml

@@ -60,7 +60,7 @@
 
 				where a.del_flag = 0
 				  and a.submit = 1
-				  and b.del_flag = 0
+				  and b.del_flag = 0 order by a.create_time
 			 ) a
 			${ew.customSqlSegment}
 	</select>

+ 18 - 1
srm-module-code/src/main/java/org/jeecg/modules/saleCode/service/impl/SaleInquiryFormServiceImpl.java

@@ -54,7 +54,7 @@ public class SaleInquiryFormServiceImpl extends ServiceImpl<SaleInquiryFormMappe
 
 		if(saleInquiryFormShipList!=null && saleInquiryFormShipList.size()>0) {
 
-			List<String> shipIds = saleInquiryFormShipList.stream().map(SaleInquiryFormShip::getId).collect(Collectors.toList());
+			List<String> shipIds = saleInquiryFormShipList.stream().map(SaleInquiryFormShip::getShipId).collect(Collectors.toList());
 			QueryWrapper<BaseShipArchive> queryShip = new QueryWrapper<>();
 			queryShip.eq("id",shipIds);
 			queryShip.eq("del_flag",0);
@@ -90,6 +90,23 @@ public class SaleInquiryFormServiceImpl extends ServiceImpl<SaleInquiryFormMappe
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void updateMain(SaleInquiryForm saleInquiryForm,List<SaleInquiryFormShip> saleInquiryFormShipList,List<SaleInquiryFormProduct> saleInquiryFormProductList) {
+
+		if(saleInquiryFormShipList!=null && saleInquiryFormShipList.size()>0) {
+
+			List<String> shipIds = saleInquiryFormShipList.stream().map(SaleInquiryFormShip::getShipId).collect(Collectors.toList());
+			QueryWrapper<BaseShipArchive> queryShip = new QueryWrapper<>();
+			queryShip.eq("id",shipIds);
+			queryShip.eq("del_flag",0);
+			List<BaseShipArchive> shipList = baseShipArchiveMapper.selectList(queryShip);
+			if(shipList.size() > 0){
+				String imos = shipList.stream().map(BaseShipArchive::getImo).collect(Collectors.joining(","));
+				saleInquiryForm.setImo(imos);
+			}
+
+			String names = saleInquiryFormShipList.stream().map(SaleInquiryFormShip::getShipName).collect(Collectors.joining(","));
+			saleInquiryForm.setShipName(names);
+		}
+
 		saleInquiryFormMapper.updateById(saleInquiryForm);
 		
 		//1.先删除子表数据

+ 8 - 3
srm-module-code/src/main/java/org/jeecg/modules/saleCode/service/impl/SaleOrderServiceImpl.java

@@ -2,6 +2,7 @@ package org.jeecg.modules.saleCode.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.baseCode.entity.BaseShipArchive;
 import org.jeecg.modules.baseCode.mapper.BaseShipArchiveMapper;
 import org.jeecg.modules.saleCode.entity.SaleDelivery;
@@ -47,7 +48,7 @@ public class SaleOrderServiceImpl extends ServiceImpl<SaleOrderMapper, SaleOrder
 
 		if(saleOrderShipList!=null && saleOrderShipList.size()>0) {
 
-			List<String> shipIds = saleOrderShipList.stream().map(SaleOrderShip::getId).collect(Collectors.toList());
+			List<String> shipIds = saleOrderShipList.stream().map(SaleOrderShip::getShipId).collect(Collectors.toList());
 			QueryWrapper<BaseShipArchive> queryShip = new QueryWrapper<>();
 			queryShip.eq("id",shipIds);
 			queryShip.eq("del_flag",0);
@@ -84,10 +85,14 @@ public class SaleOrderServiceImpl extends ServiceImpl<SaleOrderMapper, SaleOrder
 			}
 		}
 		if(saleOrderProductList!=null && saleOrderProductList.size()>0) {
+			int i = 0;
 			for(SaleOrderProduct entity:saleOrderProductList) {
+				i ++ ;
 				//外键设置
 				entity.setId(null);
 				entity.setHeadId(saleOrder.getId());
+				entity.setCreateTime(DateUtils.getNextTime(i));
+
 				saleOrderProductMapper.insert(entity);
 			}
 		}
@@ -100,7 +105,7 @@ public class SaleOrderServiceImpl extends ServiceImpl<SaleOrderMapper, SaleOrder
 
 		if(saleOrderShipList!=null && saleOrderShipList.size()>0) {
 
-			List<String> shipIds = saleOrderShipList.stream().map(SaleOrderShip::getId).collect(Collectors.toList());
+			List<String> shipIds = saleOrderShipList.stream().map(SaleOrderShip::getShipId).collect(Collectors.toList());
 			QueryWrapper<BaseShipArchive> queryShip = new QueryWrapper<>();
 			queryShip.eq("id",shipIds);
 			queryShip.eq("del_flag",0);
@@ -161,7 +166,7 @@ public class SaleOrderServiceImpl extends ServiceImpl<SaleOrderMapper, SaleOrder
 
 		if(saleOrderShipList!=null && saleOrderShipList.size()>0) {
 
-			List<String> shipIds = saleOrderShipList.stream().map(SaleOrderShip::getId).collect(Collectors.toList());
+			List<String> shipIds = saleOrderShipList.stream().map(SaleOrderShip::getShipId).collect(Collectors.toList());
 			QueryWrapper<BaseShipArchive> queryShip = new QueryWrapper<>();
 			queryShip.eq("id",shipIds);
 			queryShip.eq("del_flag",0);