From 41cf941165039d0a8f55cd1a55f023d788f501ae Mon Sep 17 00:00:00 2001
From: 野心家 <1051256694@qq.com>
Date: 星期一, 28 四月 2025 10:38:13 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/controller/OrderController.java |  123 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 122 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/zy/asrs/controller/OrderController.java b/src/main/java/com/zy/asrs/controller/OrderController.java
index 8063a13..5832504 100644
--- a/src/main/java/com/zy/asrs/controller/OrderController.java
+++ b/src/main/java/com/zy/asrs/controller/OrderController.java
@@ -1,5 +1,7 @@
 package com.zy.asrs.controller;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.mapper.Wrapper;
@@ -8,16 +10,24 @@
 import com.core.common.*;
 import com.core.exception.CoolException;
 import com.zy.asrs.entity.*;
+import com.zy.asrs.entity.param.InFormIdParam;
 import com.zy.asrs.entity.param.OrderDomainParam;
 import com.zy.asrs.service.*;
+import com.zy.asrs.task.core.ReturnT;
 import com.zy.common.model.DetlDto;
+import com.zy.common.utils.HttpHandler;
 import com.zy.common.web.BaseController;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
+import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.*;
-
+@Slf4j
 @RestController
 public class OrderController extends BaseController {
 
@@ -33,6 +43,26 @@
     private WrkDetlService wrkDetlService;
     @Autowired
     private WaitPakinService waitPakinService;
+    @Autowired
+    private LocDetlService locDetlService;
+    @Value("${erp.address.URL}")
+    //绔彛
+    private String URL;
+
+    @Value("${erp.address.inaddress}")
+    //鍗曟嵁锛屽晢鍝佹。妗堝湴鍧�
+    private String inaddress;
+
+    @Autowired
+    private ApiLogService apiLogService;
+
+
+    @Autowired
+    private MatService matService;
+
+    @Autowired
+    private TagService tagService;
+
 
     @RequestMapping(value = "/order/nav/list/auth")
     @ManagerAuth
@@ -334,4 +364,95 @@
         return R.ok();
     }
 
+
+    @RequestMapping(value = "/order/form/add/authtest")
+    @ManagerAuth(memo = "鎵嬪姩娣诲姞璁㈠崟")
+    @Transactional
+    public R formAddTest(@RequestBody OrderDomainParam param){
+        if(Cools.isEmpty(param.getOrderNo())){
+            String prefix = "";
+            DocType docType = docTypeService.selectById(param.getDocType());
+            if(!Cools.isEmpty(docType)){
+                prefix = docType.getPakin() == 1 ? "RK" : "CK";
+            }
+            param.setOrderNo(prefix + snowflakeIdWorker.nextId());
+        }
+        Order order = orderService.selectByNo(param.getOrderNo());
+        if (order != null) {
+            return R.error("鍗曟嵁缂栧彿宸插瓨鍦�");
+        }
+        Date now = new Date();
+        order = new Order(
+                String.valueOf(snowflakeIdWorker.nextId()),    // 缂栧彿[闈炵┖]
+                param.getOrderNo(),    // 璁㈠崟缂栧彿
+                DateUtils.convert(now),    // 鍗曟嵁鏃ユ湡
+                param.getDocType(),    // 鍗曟嵁绫诲瀷
+                null,    // 椤圭洰缂栧彿
+                null,    //
+                null,    // 璋冩嫧椤圭洰缂栧彿
+                null,    // 鍒濆绁ㄦ嵁鍙�
+                null,    // 绁ㄦ嵁鍙�
+                null,    // 瀹㈡埛缂栧彿
+                null,    // 瀹㈡埛
+                null,    // 鑱旂郴鏂瑰紡
+                null,    // 鎿嶄綔浜哄憳
+                null,    // 鍚堣閲戦
+                null,    // 浼樻儬鐜�
+                null,    // 浼樻儬閲戦
+                null,    // 閿�鍞垨閲囪喘璐圭敤鍚堣
+                null,    // 瀹炰粯閲戦
+                null,    // 浠樻绫诲瀷
+                null,    // 涓氬姟鍛�
+                null,    // 缁撶畻澶╂暟
+                null,    // 閭垂鏀粯绫诲瀷
+                null,    // 閭垂
+                null,    // 浠樻鏃堕棿
+                null,    // 鍙戣揣鏃堕棿
+                null,    // 鐗╂祦鍚嶇О
+                null,    // 鐗╂祦鍗曞彿
+                1L,    // 璁㈠崟鐘舵��
+                1,    // 鐘舵��
+                getUserId(),    // 娣诲姞浜哄憳
+                now,    // 娣诲姞鏃堕棿
+                getUserId(),    // 淇敼浜哄憳
+                now,    // 淇敼鏃堕棿
+                null    // 澶囨敞
+        );
+        if (!orderService.insert(order)) {
+            throw new CoolException("淇濆瓨璁㈠崟涓绘。澶辫触");
+        }
+        List<DetlDto> list = new ArrayList<>();
+        for (OrderDetl orderDetl : param.getOrderDetlList()) {
+            DetlDto dto = new DetlDto(orderDetl.getMatnr(), orderDetl.getBatch());
+            if (DetlDto.has(list, dto)) {
+                OrderDetl item = orderDetlService.selectItem(order.getId(), orderDetl.getMatnr(), orderDetl.getBatch());
+                item.setAnfme(item.getAnfme() + orderDetl.getAnfme());
+                if (!orderDetlService.updateById(item)) {
+                    throw new CoolException("淇濆瓨璁㈠崟鏄庣粏妗eけ璐�");
+                }
+            } else {
+                list.add(dto);
+                orderDetl.setOrderId(order.getId());
+                orderDetl.setOrderNo(order.getOrderNo());
+                orderDetl.setCreateBy(getUserId());
+                orderDetl.setCreateTime(now);
+                orderDetl.setUpdateBy(getUserId());
+                orderDetl.setUpdateTime(now);
+                orderDetl.setStatus(1);
+                orderDetl.setQty(0.0D);
+
+                //缁欐坊鍔犲瓙璁㈠崟
+                Set<String> exist = new HashSet<>();
+                List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), null, exist);
+
+
+                if (!orderDetlService.insert(orderDetl)) {
+                    throw new CoolException("淇濆瓨璁㈠崟鏄庣粏妗eけ璐�");
+                }
+            }
+        }
+        return R.ok("璁㈠崟娣诲姞鎴愬姛");
+    }
+
+
 }

--
Gitblit v1.9.1