Files
quote_price/src/main/java/lingtao/net/util/ZsPrice.java
T
2026-07-02 15:12:46 +08:00

119 lines
3.5 KiB
Java

package lingtao.net.util;
import com.aspose.pdf.Document;
import com.aspose.pdf.optimization.OptimizationOptions;
import lingtao.net.bean.Product;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
public class ZsPrice {
public List<Product> getPrice(int count, double length, double width, List<Product> list, int number, String shenzi) {
double price = 50;
double l = 438.0;
double w = 304.0;
length += 3;
width += 3;
// 一张l/w 大的纸张能做多少个此类尺寸的产品
double max = Math.max(Math.floor(l / length) * Math.floor(w / width),
Math.floor(l / width) * Math.floor(w / length));
// 报的数量需要多少张大纸
// 需要多少张大纸 = 数量 * 款数 /每张做多少个 ===总数量/每张多少个
int num = (int) Math.ceil(count * number / max);
price += (num - 1) * 15;
if ("绳子".equals(shenzi)) {
price += 1 * count * number;
}
if (number > 1) {//多款算设计费
price += 10 * number;
}
Product pro = new Product();
pro.setPrice(Math.ceil(price));
pro.setCount(count);
list.add(pro);
return list;
}
public static List<Product> getSmPrice(int count, Double length, Double width, List<Product> list, Integer number, String[] craft, Product dto, String role) {
double price = 60;
double l = 438.0;
double w = 304.0;
if ("10".equals(dto.getKindValue())) {
price = 90;
}
if ((length < 8.55 && width < 5.4) || (width < 8.55 && length < 5.4)) {
length = 8.55;
width = 5.4;
}
length = length * 10 + 3;
width = width * 10 + 3;
// 一张l/w 大的纸张能做多少个此类尺寸的产品
double max = Math.max(Math.floor(l / length) * Math.floor(w / width),
Math.floor(l / width) * Math.floor(w / length));
// 报的数量需要多少张大纸
// 需要多少张大纸 = 数量 * 款数 /每张做多少个 ===总数量/每张多少个
int num = (int) Math.ceil(count * number / max);
if ("10".equals(dto.getKindValue())) {
price += (num - 1) * 30;
} else {
price += (num - 1) * 15;
}
if (!StringUtils.isEmpty(craft) && craft[0].equals("背胶")) {
price += num * 10;
}
if (number > 1) {
double desFee = 0;
if (dto.getP() == 1) {
desFee = 0.5;
} else if (dto.getP() == 2) {
desFee = 2;
} else if (dto.getP() == 3) {
desFee = 1;
} else if (dto.getP() == 4) {
desFee = 3;
} else if (dto.getP() == 5) {
desFee = 3.5;
} else {
desFee = 5;
}
price += desFee * (number - 1);
}
Product pro = new Product();
pro.setPrice(Math.ceil(price));
pro.setCount(count);
list.add(pro);
return list;
}
public static void main(String[] args) {
}
public int[] twoSum(int[] nums, int target) {
List<Integer> list = new ArrayList<>();
for (int i = 0; i < nums.length; i++) {
if (list.get(target - nums[i]) != null) {
return new int[]{list.get(target - nums[i]), i};
}
list.add(target - nums[i], nums[i]);
}
return null;
}
}