Browse Source

承霖物流、荆海物流完成

jzkai 2 years ago
parent
commit
fcbf2c320a

+ 1 - 0
common/src/main/java/com/jpsoft/prices/modules/base/dao/StandardDAO.java

@@ -15,4 +15,5 @@ public interface StandardDAO {
 	int delete(String id);
 	List<Standard> list();
 	List<Standard> search(Map<String,Object> searchParams,List<Sort> sortList);
+	Standard getStandard(String companyId, String destinationId, String unitName);
 }

+ 32 - 0
common/src/main/java/com/jpsoft/prices/modules/base/dto/InvoiceInfoDTO.java

@@ -0,0 +1,32 @@
+package com.jpsoft.prices.modules.base.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+public class InvoiceInfoDTO {
+    @ApiModelProperty(value = "条形码")
+    private String barCode;
+    @ApiModelProperty(value = "长(CM)")
+    private Integer boxLength;
+    @ApiModelProperty(value = "宽(CM)")
+    private Integer boxWidth;
+    @ApiModelProperty(value = "高(CM)")
+    private Integer boxHight;
+    @ApiModelProperty(value = "净重(KG)")
+    private BigDecimal netWeight;
+    @ApiModelProperty(value = "毛重(KG)")
+    private BigDecimal grossWeight;
+    @ApiModelProperty(value = "单价")
+    private BigDecimal unitPrice;
+    @ApiModelProperty(value = "计费单位")
+    private String unitName;
+    @ApiModelProperty(value = "计费金额")
+    private BigDecimal amount;
+}

+ 4 - 3
common/src/main/java/com/jpsoft/prices/modules/base/dto/InvoiceQuotesDTO.java

@@ -8,10 +8,8 @@ import org.springframework.format.annotation.DateTimeFormat;
 
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
 
-/**
-  描述:base_invoice的实体类
- */
 @Data
 public class InvoiceQuotesDTO {
     @ApiModelProperty(value = "物流公司")
@@ -30,4 +28,7 @@ public class InvoiceQuotesDTO {
     private BigDecimal taxFee;
     @ApiModelProperty(value = "合计")
     private BigDecimal totalFee;
+
+    @ApiModelProperty(value = "子项")
+    private List<InvoiceInfoDTO> infoDTOS;
 }

+ 1 - 0
common/src/main/java/com/jpsoft/prices/modules/base/service/StandardService.java

@@ -14,4 +14,5 @@ public interface StandardService {
 	int delete(String id);
 	List<Standard> list();
 	Page<Standard> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,boolean count,List<Sort> sortList);
+	Standard getStandard(String companyId, String destinationId, String unitName);
 }

+ 5 - 0
common/src/main/java/com/jpsoft/prices/modules/base/service/impl/StandardServiceImpl.java

@@ -67,4 +67,9 @@ public class StandardServiceImpl implements StandardService {
         
         return page;
 	}
+
+	@Override
+	public Standard getStandard(String companyId, String destinationId, String unitName) {
+		return standardDAO.getStandard(companyId, destinationId, unitName);
+	}
 }

+ 7 - 0
common/src/main/resources/mapper/base/Standard.xml

@@ -160,4 +160,11 @@ id_,company_id,destination_id,logic_id,name_,first_weight,unit_price,unit_name,s
 	        ${sort.name} ${sort.order}
 	 	</foreach>
 	</select>
+	<select id="getStandard" parameterType="string" resultMap="StandardMap">
+		SELECT * FROM base_standard
+		WHERE del_flag = 0
+		AND company_id = #{companyId}
+		AND destination_id = #{destinationId}
+		AND unit_name LIKE CONCAT('%',#{unitName},'%')
+	</select>
 </mapper>

+ 93 - 8
web/src/main/java/com/jpsoft/prices/modules/base/controller/InvoiceQuotesController.java

@@ -1,13 +1,16 @@
 package com.jpsoft.prices.modules.base.controller;
 
 import com.github.pagehelper.Page;
+import com.jpsoft.prices.modules.base.dto.InvoiceInfoDTO;
 import com.jpsoft.prices.modules.base.dto.InvoiceQuotesDTO;
 import com.jpsoft.prices.modules.base.entity.Company;
 import com.jpsoft.prices.modules.base.entity.Invoice;
 import com.jpsoft.prices.modules.base.entity.InvoiceInfo;
+import com.jpsoft.prices.modules.base.entity.Standard;
 import com.jpsoft.prices.modules.base.service.CompanyService;
 import com.jpsoft.prices.modules.base.service.InvoiceInfoService;
 import com.jpsoft.prices.modules.base.service.InvoiceService;
+import com.jpsoft.prices.modules.base.service.StandardService;
 import com.jpsoft.prices.modules.common.dto.MessageResult;
 import com.jpsoft.prices.modules.common.dto.Sort;
 import com.jpsoft.prices.modules.common.utils.PojoUtils;
@@ -16,12 +19,16 @@ import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import java.math.BigDecimal;
 import java.util.*;
 
+import static com.jpsoft.prices.modules.common.controller.PlansController.piecePlan;
+import static com.jpsoft.prices.modules.common.controller.PlansController.weightPlan;
+
 @RestController
 @RequestMapping("/base/invoiceQuotes")
 @Api(description = "invoiceQuotes")
@@ -34,10 +41,12 @@ public class InvoiceQuotesController {
     private InvoiceService invoiceService;
     @Autowired
     private InvoiceInfoService invoiceInfoService;
+    @Autowired
+    private StandardService standardService;
 
     @ApiOperation(value="基于物流公司的报价单比对")
     @RequestMapping(value = "quotesList",method = RequestMethod.POST)
-    public MessageResult<List> quotesList(String invoiceId){
+    public MessageResult<List> quotesList(String invoiceId) {
         MessageResult<List> msgResult = new MessageResult<>();
 
         try {
@@ -54,17 +63,93 @@ public class InvoiceQuotesController {
             List<InvoiceQuotesDTO> list = new ArrayList<>();
             Page<Company> page = companyService.pageSearch(searchParams, 1, 100, false, sortList);
             for (Company company : page.getResult()) {
+                InvoiceQuotesDTO dto = new InvoiceQuotesDTO();
+
+                List<InvoiceInfoDTO> infoDTOS = new ArrayList<>();
+                BigDecimal transportFee = new BigDecimal(0);
+                BigDecimal deliveryFee = new BigDecimal(0);
+                BigDecimal storageFee = new BigDecimal(0);
+                BigDecimal insureFee = new BigDecimal(0);
+                BigDecimal taxFee = new BigDecimal(0);
+                BigDecimal totalFee = new BigDecimal(0);
                 List<InvoiceInfo> infoList = invoiceInfoService.findByInvoice(invoiceId);
+                for(InvoiceInfo info : infoList) {
+                    InvoiceInfoDTO infoDTO = new InvoiceInfoDTO();
+                    BeanUtils.copyProperties(info,infoDTO);
+
+                    Standard standard = new Standard();
+//                    if(info.getType().contains("石英棒")) {
+//                        standard = standardService.getStandard(company.getId(), invoice.getDestinationId(), "托盘");
+//                        transportFee = transportFee.add(piecePlan(standard,info));
+//                        deliveryFee = standard.getDeliveryFee();
+//                        storageFee = standard.getStorageFee();
+//                        insureFee = transportFee.multiply(standard.getInsureFee());
+//                        taxFee = transportFee.multiply(standard.getTaxFee());
+//                        totalFee = transportFee.add(deliveryFee).add(storageFee).add(insureFee).add(taxFee);
+//                        continue;
+//                    }
+                    if(info.getGrossWeight().compareTo(new BigDecimal(1000)) >= 0) {
+                        standard = standardService.getStandard(company.getId(), invoice.getDestinationId(), "重量");
+                        BigDecimal tempFee = weightPlan(standard,info);
+
+                        transportFee = transportFee.add(tempFee);
+                        deliveryFee = standard.getDeliveryFee();
+                        storageFee = standard.getStorageFee();
+                        insureFee = transportFee.multiply(standard.getInsureFee());
+                        taxFee = transportFee.multiply(standard.getTaxFee());
+                        totalFee = transportFee.add(deliveryFee).add(storageFee).add(insureFee).add(taxFee);
+
+                        infoDTO.setUnitName(standard.getUnitName());
+                        infoDTO.setUnitPrice(standard.getUnitPrice());
+                        infoDTO.setAmount(tempFee);
+                        infoDTOS.add(infoDTO);
+                        continue;
+                    }
+                    if(info.getBoxLength() >= 1000 || info.getBoxWidth() >= 1000 ||info.getBoxHight() >= 1000) {
+                        standard = standardService.getStandard(company.getId(), invoice.getDestinationId(), "木箱(1米及以上)");
+                        BigDecimal tempFee = piecePlan(standard,info);
+
+                        transportFee = transportFee.add(tempFee);
+                        deliveryFee = standard.getDeliveryFee();
+                        storageFee = standard.getStorageFee();
+                        insureFee = transportFee.multiply(standard.getInsureFee());
+                        taxFee = transportFee.multiply(standard.getTaxFee());
+                        totalFee = transportFee.add(deliveryFee).add(storageFee).add(insureFee).add(taxFee);
+
+                        infoDTO.setUnitName(standard.getUnitName());
+                        infoDTO.setUnitPrice(standard.getUnitPrice());
+                        infoDTO.setAmount(tempFee);
+                        infoDTOS.add(infoDTO);
+                        continue;
+                    }
+                    if(info.getBoxLength() < 1000 && info.getBoxWidth() < 1000 && info.getBoxHight() < 1000) {
+                        standard = standardService.getStandard(company.getId(), invoice.getDestinationId(), "木箱(1米以下)");
+                        BigDecimal tempFee = piecePlan(standard,info);
+
+                        transportFee = transportFee.add(tempFee);
+                        deliveryFee = standard.getDeliveryFee();
+                        storageFee = standard.getStorageFee();
+                        insureFee = transportFee.multiply(standard.getInsureFee());
+                        taxFee = transportFee.multiply(standard.getTaxFee());
+                        totalFee = transportFee.add(deliveryFee).add(storageFee).add(insureFee).add(taxFee);
+
+                        infoDTO.setUnitName(standard.getUnitName());
+                        infoDTO.setUnitPrice(standard.getUnitPrice());
+                        infoDTO.setAmount(tempFee);
+                        infoDTOS.add(infoDTO);
+                        continue;
+                    }
+                }
 
-                InvoiceQuotesDTO dto = new InvoiceQuotesDTO();
                 dto.setCompanyName(company.getName());
                 dto.setNumbers(infoList.size());
-                dto.setTransportFee(new BigDecimal(0));
-                dto.setDeliveryFee(new BigDecimal(0));
-                dto.setStorageFee(new BigDecimal(0));
-                dto.setInsureFee(new BigDecimal(0));
-                dto.setTaxFee(new BigDecimal(0));
-                dto.setTotalFee(new BigDecimal(0));
+                dto.setTransportFee(transportFee);
+                dto.setDeliveryFee(deliveryFee);
+                dto.setStorageFee(storageFee);
+                dto.setInsureFee(insureFee);
+                dto.setTaxFee(taxFee);
+                dto.setTotalFee(totalFee);
+                dto.setInfoDTOS(infoDTOS);
                 list.add(dto);
             }
 

+ 35 - 0
web/src/main/java/com/jpsoft/prices/modules/common/controller/PlansController.java

@@ -0,0 +1,35 @@
+package com.jpsoft.prices.modules.common.controller;
+
+import com.jpsoft.prices.modules.base.entity.InvoiceInfo;
+import com.jpsoft.prices.modules.base.entity.Standard;
+import com.jpsoft.prices.modules.common.dto.MessageResult;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+@RestController
+public class PlansController {
+    /**
+     * 计件方案
+     */
+    public static BigDecimal piecePlan(Standard standard, InvoiceInfo invoiceInfo){
+        BigDecimal val = new BigDecimal(0);
+
+        val = standard.getUnitPrice();
+
+        return val;
+    }
+
+    /**
+     * 计重方案
+     */
+    public static BigDecimal weightPlan(Standard standard, InvoiceInfo invoiceInfo){
+        BigDecimal val = new BigDecimal(0);
+
+        val = standard.getUnitPrice().multiply(invoiceInfo.getGrossWeight()).divide(new BigDecimal(1000));
+
+        return val;
+    }
+}