From b7afd45a5510bb328ee4e0c2b06b909140bc4a97 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期四, 24 三月 2022 12:51:27 +0800
Subject: [PATCH] #杰克缝纫机立库 【手动删除订单】 - java
---
src/main/java/com/zy/asrs/controller/OrderController.java | 133 +++++++++++++++++++++++++++++++++++++++++---
1 files changed, 123 insertions(+), 10 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/OrderController.java b/src/main/java/com/zy/asrs/controller/OrderController.java
index 21fba07..2ada0f8 100644
--- a/src/main/java/com/zy/asrs/controller/OrderController.java
+++ b/src/main/java/com/zy/asrs/controller/OrderController.java
@@ -1,19 +1,21 @@
package com.zy.asrs.controller;
-import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
-import com.core.common.DateUtils;
-import com.zy.asrs.entity.Order;
-import com.zy.asrs.service.OrderService;
import com.core.annotations.ManagerAuth;
-import com.core.common.BaseRes;
-import com.core.common.Cools;
-import com.core.common.R;
+import com.core.common.*;
+import com.core.exception.CoolException;
+import com.zy.asrs.entity.Order;
+import com.zy.asrs.entity.OrderDetl;
+import com.zy.asrs.entity.param.InitOrderParam;
+import com.zy.asrs.service.OrderDetlService;
+import com.zy.asrs.service.OrderService;
import com.zy.common.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.*;
@@ -23,6 +25,113 @@
@Autowired
private OrderService orderService;
+ @Autowired
+ private OrderDetlService orderDetlService;
+ @Autowired
+ private SnowflakeIdWorker snowflakeIdWorker;
+
+ @RequestMapping(value = "/order/head/page/auth")
+ @ManagerAuth
+ public R head(@RequestParam(defaultValue = "1")Integer curr,
+ @RequestParam(defaultValue = "10")Integer limit,
+ @RequestParam(required = false)String orderByField,
+ @RequestParam(required = false)String orderByType,
+ @RequestParam Map<String, Object> param){
+ EntityWrapper<Order> wrapper = new EntityWrapper<>();
+ excludeTrash(param);
+ convert(param, wrapper);
+ if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} else {
+ wrapper.orderBy("create_time", false);
+ }
+ wrapper.eq("status", 1);
+ return R.ok(orderService.selectPage(new Page<>(curr, limit), wrapper));
+ }
+
+ @RequestMapping(value = "/order/detl/all/auth")
+ @ManagerAuth
+ public R head(@RequestParam Long orderId){
+ return R.ok().add(orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("order_id", orderId)));
+ }
+
+ @RequestMapping(value = "/order/form/add/auth")
+ @ManagerAuth
+ @Transactional
+ public R formAdd(@RequestBody InitOrderParam param){
+ 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("淇濆瓨璁㈠崟涓绘。澶辫触");
+ }
+ for (OrderDetl orderDetl : param.getOrderDetlList()) {
+ orderDetl.setOrderId(order.getId());
+ orderDetl.setCreateBy(getUserId());
+ orderDetl.setCreateTime(now);
+ orderDetl.setUpdateBy(getUserId());
+ orderDetl.setUpdateTime(now);
+ orderDetl.setStatus(1);
+ if (!orderDetlService.insert(orderDetl)) {
+ throw new CoolException("淇濆瓨璁㈠崟鏄庣粏妗eけ璐�");
+ }
+ }
+ return R.ok("璁㈠崟娣诲姞鎴愬姛");
+ }
+
+ @RequestMapping(value = "/order/form/modify/auth")
+ @ManagerAuth
+ public R formModify(@RequestBody InitOrderParam param){
+ System.out.println(JSON.toJSONString(param));
+ return R.ok();
+ }
+
+
+
+
+
+
+
+
+
+
+ // ------------------------------------------------------------------------------------------------
@RequestMapping(value = "/order/{id}/auth")
@ManagerAuth
@@ -76,9 +185,13 @@
@RequestMapping(value = "/order/delete/auth")
@ManagerAuth
- public R delete(@RequestParam(value="ids[]") Long[] ids){
- for (Long id : ids){
- orderService.deleteById(id);
+ public R delete(@RequestParam Long orderId){
+ Order order = orderService.selectById(orderId);
+ if (order != null) {
+ order.setStatus(0);
+ }
+ if (!orderService.updateById(order)) {
+ throw new CoolException("鍒犻櫎璁㈠崟澶辫触");
}
return R.ok();
}
--
Gitblit v1.9.1