| New file |
| | |
| | | package com.example.erp.tools; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.example.erp.common.Constants; |
| | | import com.example.erp.entity.sd.Order; |
| | | import com.example.erp.mapper.sd.OrderMapper; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import java.text.DecimalFormat; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @RequiredArgsConstructor |
| | | public class AreaComputed { |
| | | private static final OrderMapper orderMapper = null; |
| | | |
| | | public static List<Map<String,Object>> computeArea( List<Map<String, Object>> list) { |
| | | |
| | | list.forEach(map -> { |
| | | //获取结算面积计算方式 |
| | | Order order = orderMapper.selectOne(new QueryWrapper<Order>().eq("order_id", map.get("orderId"))); |
| | | Integer width = Integer.parseInt(map.get("width").toString()); |
| | | Integer height = Integer.parseInt(map.get("height").toString()); |
| | | Integer quantity = Integer.parseInt(map.get("quantity").toString()); |
| | | |
| | | //设置面积保留位数 |
| | | Double area = Double.valueOf(String.format("%."+Constants.decimalPoint+"f", width * height /1000000 )); |
| | | |
| | | Double totalArea =0.00; |
| | | switch (order.getCalculateType()) { |
| | | // |
| | | case 2: |
| | | case 4: { |
| | | totalArea = Double.valueOf( |
| | | String.format("%."+Constants.decimalPoint+"f", |
| | | width * height*quantity /1000000 |
| | | ) |
| | | ); |
| | | break; |
| | | } |
| | | default:{ |
| | | totalArea = Double.valueOf( |
| | | String.format("%."+Constants.decimalPoint+"f", |
| | | area*quantity /1000000 |
| | | ) |
| | | ); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | map.put("computeGrossArea", totalArea); |
| | | |
| | | }); |
| | | |
| | | return list; |
| | | |
| | | } |
| | | } |