chenlu
2024-06-07 2f640b1038fa331954f78ed1f4317212cf5bb34d
north-glass-erp/src/main/java/com/example/erp/service/sd/OrderService.java
@@ -9,11 +9,13 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.example.erp.common.Constants;
import com.example.erp.dto.sd.OrderDTO;
import com.example.erp.entity.sd.*;
import com.example.erp.entity.userInfo.SysError;
import com.example.erp.exception.ServiceException;
import com.example.erp.mapper.sd.*;
import com.example.erp.service.userInfo.SysErrorService;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
@@ -47,6 +49,7 @@
        Order order = JSONObject.parseObject(JSONObject.toJSONString(orderJson.get("title")), Order.class);
        List<OrderDetail> OrderDetails = JSONArray.parseArray(JSONObject.toJSONString(orderJson.get("detail")), OrderDetail.class);
        List<OrderOtherMoney> orderOtherMoneyList = JSONArray.parseArray(JSONObject.toJSONString(orderJson.get("otherMoney")), OrderOtherMoney.class);
        boolean saveState = true;
        //设置回滚点
        Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint();
@@ -99,6 +102,7 @@
        //删除其他金额明细表
        orderOtherMoneyMapper.delete(new LambdaQueryWrapper<OrderOtherMoney>().eq(OrderOtherMoney::getOrderId, order.getOrderId()));
        //删除订单工艺表
       // orderProcessDetailMapper.delete(new LambdaQueryWrapper<OrderProcessDetail>().eq(OrderProcessDetail::getOrderId, order.getOrderId()));
        insertOtherDetail(order.getOrderId(),OrderDetails,orderOtherMoneyList);
@@ -107,6 +111,7 @@
    //插入其他副表数据,被其他方法引用
    public void insertOtherDetail(String orderId,List<OrderDetail> OrderDetails,List<OrderOtherMoney> orderOtherMoneyList) {
        //先把其他金额副表的金额与数量置0
        orderOtherMoneyList.forEach(orderOtherMoney -> {
            orderOtherMoney.setQuantity(0.0);
@@ -118,16 +123,15 @@
            OrderDetails.get(i).setOrderId(orderId);
            OrderDetails.get(i).setPerimeter(OrderDetails.get(i).getWidth()*OrderDetails.get(i).getHeight()*2/1000);
            OrderDetails.get(i).setWeight(1.0);
            Map<String,Double> otherColumns = JSON.parseObject(OrderDetails.get(i).getOtherColumns(), new TypeReference<Map<String, Double>>(){});
            Map<String,Object> otherColumns = JSON.parseObject(OrderDetails.get(i).getOtherColumns(), new TypeReference<Map<String, Object>>(){});
            int finalI = i;
            if(otherColumns!=null){
                otherColumns.forEach((key, value) ->{
                    if(value!=null) {
                    if(value!=null && key.contains("M")) {
                        orderOtherMoneyList.forEach(orderOtherMoney -> {
                            if (orderOtherMoney.getColumn().equals(key)) {
                                orderOtherMoney.setQuantity(orderOtherMoney.getQuantity()+(value * OrderDetails.get(finalI).getQuantity()));
                                orderOtherMoney.setQuantity(orderOtherMoney.getQuantity()+(Double.parseDouble((String) value)  * OrderDetails.get(finalI).getQuantity()));
                            }
                        });
                    }
@@ -311,7 +315,7 @@
        return map;
    }
    public List<Order> exportOrderReport(List<LocalDate> dates) {
    public List<OrderDTO> exportOrderReport(List<LocalDate> dates) {
        return orderDetailMapper.exportOrderReport(dates);
    }
@@ -338,4 +342,20 @@
//        map.put("total",orderMapper.getPageTotal(offset, pageSize, startDate, endDate, orderDetail));
        return map;
    }
    public List<OrderDTO> exportOrderProductSummary(List<LocalDate> dates) {
        return orderDetailMapper.exportOrderProductSummary(dates);
    }
    public Map<String,String> getOrderProductDetailTag(String orderId) {
        return orderDetailMapper.getOrderProductDetailTag(orderId);
    }
    public List<OrderDetail> getOrderDetailById(String id) {
        return orderDetailMapper.selectList(new QueryWrapper<OrderDetail>().eq("order_id",id));
    }
    public List<OrderGlassDetail> getOrderCraftDetailById(String id) {
         return orderGlassDetailMapper.selectOrderGlassDetailByOrderId(id);
    }
}