From 71fb0226eba99f4bd9503c1da89925f53fd54d8a Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期五, 02 八月 2024 10:44:13 +0800
Subject: [PATCH] #组托规则

---
 zy-asrs-wms/src/main/resources/mapper/asrs/WaitPakinRuleMapper.xml                        |    5 
 zy-asrs-wms/src/main/java/com/zy/asrs/wms/utils/CodeBuilder.java                          |    4 
 zy-asrs-admin/src/views/strategy/waitPakinRule/edit.vue                                   |  194 +++++++++++
 zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/WaitPakinRuleService.java          |   11 
 zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/entity/WaitPakinRule.java                  |  227 +++++++++++++
 zy-asrs-wms/src/main/resources/sql/menu/waitPakinRule.sql                                 |    9 
 zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/WaitPakinService.java              |    3 
 zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/controller/WaitPakinRuleController.java    |  102 ++++++
 zy-asrs-admin/src/views/strategy/waitPakinRule/index.vue                                  |  223 +++++++++++++
 zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/mapper/WaitPakinRuleMapper.java            |   12 
 zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WaitPakinServiceImpl.java     |   79 ++++
 zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/controller/WaitPakinController.java        |   64 ---
 zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WaitPakinRuleServiceImpl.java |   58 +++
 13 files changed, 927 insertions(+), 64 deletions(-)

diff --git a/zy-asrs-admin/src/views/strategy/waitPakinRule/edit.vue b/zy-asrs-admin/src/views/strategy/waitPakinRule/edit.vue
new file mode 100644
index 0000000..f82077f
--- /dev/null
+++ b/zy-asrs-admin/src/views/strategy/waitPakinRule/edit.vue
@@ -0,0 +1,194 @@
+<script setup>
+import { ref, nextTick } from 'vue';
+import { get, post, postBlob, postForm } from '@/utils/request.js'
+import { formatMessage } from '@/utils/localeUtils.js';
+import { message } from 'ant-design-vue';
+
+const formTable = ref(null);
+const submitButton = ref(null);
+const isSave = ref(true);
+const open = ref(false);
+const initFormData = {}
+let formData = ref(initFormData);
+
+const emit = defineEmits(['tableReload'])
+
+const handleOk = (e) => {
+    nextTick(() => {
+        setTimeout(() => {
+            submitButton.value.$el.click();
+        }, 100);
+    });
+};
+
+const onFinish = values => {
+    // console.log('Success:', values);
+    open.value = false;
+    post(isSave.value ? '/api/waitPakinRule/save' : '/api/waitPakinRule/update', formData.value).then((resp) => {
+        let result = resp.data;
+        if (result.code === 200) {
+            message.success(isSave.value ? formatMessage('page.add.success', '鏂板鎴愬姛') : formatMessage('page.update.success', '鏇存柊鎴愬姛'));
+        } else {
+            message.error(result.msg);
+        }
+        emit('tableReload', 'reload')
+        nextTick(() => {
+            formTable.value.resetFields()
+        })
+    })
+};
+const onFinishFailed = errorInfo => {
+    console.log('Failed:', errorInfo);
+};
+
+const userQueryList = ref(null); 
+userQuery();
+function userQuery() { 
+    postForm('/api/user/query', {}).then(resp => { 
+        let result = resp.data;
+        userQueryList.value = result.data;
+    })
+}
+
+
+defineExpose({
+    open,
+    formData,
+    initFormData,
+    isSave,
+})
+
+</script>
+
+<script>
+export default {
+    name: '缁勬墭瑙勫垯-edit'
+}
+</script>
+
+<template>
+    <div>
+        <a-modal v-model:open="open"
+            :title="isSave ? formatMessage('page.add', '娣诲姞') : formatMessage('page.edit', '缂栬緫')" @ok="handleOk"
+            style="width: 600px;">
+            <a-form :model="formData" ref="formTable" name="formTable" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }"
+                style="display: flex;justify-content: space-between;flex-wrap: wrap;" autocomplete="off"
+                @finish="onFinish" @finishFailed="onFinishFailed">
+                    <a-form-item 
+                      :label="formatMessage('db.strategy_wait_pakin_rule.pallet_order', '鎵樼洏璁㈠崟') " 
+                      name="palletOrder" 
+                      style="width: 250px;" 
+                            >
+                    <a-select 
+                        v-model:value="formData.palletOrder" 
+                        :options="[
+                                { label: '鍗曡鍗�', value: 0 },
+                                { label: '澶氳鍗�', value: 1 },
+                            ]"
+                        >
+                    </a-select>
+                        </a-form-item>
+                    <a-form-item 
+                      :label="formatMessage('db.strategy_wait_pakin_rule.pallet_mixed', '鏄惁娣疯浇') " 
+                      name="palletMixed" 
+                      style="width: 250px;" 
+                            >
+                    <a-select 
+                        v-model:value="formData.palletMixed" 
+                        :options="[
+                                { label: '鍚�', value: 0 },
+                                { label: '鏄�', value: 1 },
+                            ]"
+                        >
+                    </a-select>
+                        </a-form-item>
+                    <a-form-item 
+                      :label="formatMessage('db.strategy_wait_pakin_rule.status', '鐘舵��') " 
+                      name="status" 
+                      style="width: 250px;" 
+                            >
+                    <a-select 
+                        v-model:value="formData.status" 
+                        :options="[
+                                { label: '姝e父', value: 1 },
+                                { label: '绂佺敤', value: 0 },
+                            ]"
+                        >
+                    </a-select>
+                        </a-form-item>
+                    <a-form-item 
+                      :label="formatMessage('db.strategy_wait_pakin_rule.create_time', '娣诲姞鏃堕棿') " 
+                      name="createTime" 
+                      style="width: 250px;" 
+                            >
+                    <a-date-picker 
+                        v-model:value="formData.createTime" 
+                        show-time 
+                        format="YYYY-MM-DD HH:mm:ss" 
+                        value-format="YYYY-MM-DD HH:mm:ss" 
+                     /> 
+                        </a-form-item>
+                    <a-form-item 
+                      :label="formatMessage('db.strategy_wait_pakin_rule.create_by', '娣诲姞浜哄憳') " 
+                      name="createBy" 
+                      style="width: 250px;" 
+                            >
+                    <a-select 
+                        v-model:value="formData.createBy" 
+                        :placeholder="formatMessage('common.select', '璇烽�夋嫨')" 
+                        style="width: 100%" 
+                        show-search 
+                        :options="userQueryList" 
+                        optionFilterProp="label" 
+                        optionLabelProp="label" 
+                     > 
+                    </a-select>
+                        </a-form-item>
+                    <a-form-item 
+                      :label="formatMessage('db.strategy_wait_pakin_rule.update_time', '淇敼鏃堕棿') " 
+                      name="updateTime" 
+                      style="width: 250px;" 
+                            >
+                    <a-date-picker 
+                        v-model:value="formData.updateTime" 
+                        show-time 
+                        format="YYYY-MM-DD HH:mm:ss" 
+                        value-format="YYYY-MM-DD HH:mm:ss" 
+                     /> 
+                        </a-form-item>
+                    <a-form-item 
+                      :label="formatMessage('db.strategy_wait_pakin_rule.update_by', '淇敼浜哄憳') " 
+                      name="updateBy" 
+                      style="width: 250px;" 
+                            >
+                    <a-select 
+                        v-model:value="formData.updateBy" 
+                        :placeholder="formatMessage('common.select', '璇烽�夋嫨')" 
+                        style="width: 100%" 
+                        show-search 
+                        :options="userQueryList" 
+                        optionFilterProp="label" 
+                        optionLabelProp="label" 
+                     > 
+                    </a-select>
+                        </a-form-item>
+                    <a-form-item 
+                      :label="formatMessage('db.strategy_wait_pakin_rule.memo', '澶囨敞') " 
+                      name="memo" 
+                      style="width: 250px;" 
+                            >
+                    <a-input 
+                        v-model:value="formData.memo" 
+                     /> 
+                        </a-form-item>
+
+                <a-form-item>
+                    <a-button type="primary" html-type="submit" ref="submitButton"
+                        style="visibility: hidden;">Submit</a-button>
+                </a-form-item>
+            </a-form>
+        </a-modal>
+    </div>
+</template>
+
+<style></style>
diff --git a/zy-asrs-admin/src/views/strategy/waitPakinRule/index.vue b/zy-asrs-admin/src/views/strategy/waitPakinRule/index.vue
new file mode 100644
index 0000000..3a82672
--- /dev/null
+++ b/zy-asrs-admin/src/views/strategy/waitPakinRule/index.vue
@@ -0,0 +1,223 @@
+<script setup>
+import { getCurrentInstance, ref, computed, reactive } from 'vue';
+import { useRouter } from "vue-router";
+import { get, post, postBlob } from '@/utils/request.js'
+import { message, Modal } from 'ant-design-vue';
+import { logout } from '@/config.js';
+import EditView from './edit.vue'
+import { formatMessage } from '@/utils/localeUtils.js';
+import useTableSearch from '@/utils/tableUtils.jsx';
+const context = getCurrentInstance()?.appContext.config.globalProperties;
+
+const router = useRouter();
+
+const TABLE_KEY = 'table-waitPakinRule';
+let currentPage = 1;
+let pageSize = 10;
+const searchInput = ref("")
+const editChild = ref(null)
+
+let tableData = ref([]);
+getPage();
+
+const {
+  getColumnSearchProps,
+  handleResizeColumn,
+} = useTableSearch();
+
+const columns = [
+        {
+            title: formatMessage('db.strategy_wait_pakin_rule.pallet_order', '鎵樼洏璁㈠崟'),
+            dataIndex: 'palletOrder$',
+            width: 140,
+            ellipsis: true,
+            ...getColumnSearchProps('palletOrder$'),
+        },
+        {
+            title: formatMessage('db.strategy_wait_pakin_rule.pallet_mixed', '鏄惁娣疯浇'),
+            dataIndex: 'palletMixed$',
+            width: 140,
+            ellipsis: true,
+            ...getColumnSearchProps('palletMixed$'),
+        },
+        {
+            title: formatMessage('db.strategy_wait_pakin_rule.status', '鐘舵��'),
+            dataIndex: 'status$',
+            width: 140,
+            ellipsis: true,
+            ...getColumnSearchProps('status$'),
+        },
+        {
+            title: formatMessage('db.strategy_wait_pakin_rule.create_time', '娣诲姞鏃堕棿'),
+            dataIndex: 'createTime$',
+            width: 140,
+            ellipsis: true,
+            ...getColumnSearchProps('createTime$'),
+        },
+        {
+            title: formatMessage('db.strategy_wait_pakin_rule.create_by', '娣诲姞浜哄憳'),
+            dataIndex: 'createBy$',
+            width: 140,
+            ellipsis: true,
+            ...getColumnSearchProps('createBy$'),
+        },
+        {
+            title: formatMessage('db.strategy_wait_pakin_rule.update_time', '淇敼鏃堕棿'),
+            dataIndex: 'updateTime$',
+            width: 140,
+            ellipsis: true,
+            ...getColumnSearchProps('updateTime$'),
+        },
+        {
+            title: formatMessage('db.strategy_wait_pakin_rule.update_by', '淇敼浜哄憳'),
+            dataIndex: 'updateBy$',
+            width: 140,
+            ellipsis: true,
+            ...getColumnSearchProps('updateBy$'),
+        },
+        {
+            title: formatMessage('db.strategy_wait_pakin_rule.memo', '澶囨敞'),
+            dataIndex: 'memo',
+            width: 140,
+            ellipsis: true,
+            ...getColumnSearchProps('memo'),
+        },
+
+  {
+    title: formatMessage('common.operation', '鎿嶄綔'),
+    name: 'oper',
+    dataIndex: 'oper',
+    key: 'oper',
+    width: 140,
+    fixed: 'right',
+  },
+];
+
+const state = reactive({
+  selectedRowKeys: [],
+  loading: false,
+});
+const hasSelected = computed(() => state.selectedRowKeys.length > 0);
+const start = () => {
+  state.loading = true;
+  // ajax request after empty completing
+  setTimeout(() => {
+    state.loading = false;
+    state.selectedRowKeys = [];
+  }, 1000);
+};
+const onSelectChange = selectedRowKeys => {
+  // console.log('selectedRowKeys changed: ', selectedRowKeys);
+  state.selectedRowKeys = selectedRowKeys;
+};
+
+function getPage() {
+  post('/api/waitPakinRule/page', {
+    current: currentPage,
+    pageSize: pageSize,
+    condition: searchInput.value
+  }).then((resp) => {
+    let result = resp.data;
+    if (result.code == 200) {
+      let data = result.data;
+      tableData.value = data;
+    } else if (result.code === 401) {
+      message.error(result.msg);
+      logout()
+    } else {
+      message.error(result.msg);
+    }
+  })
+}
+
+const handleEdit = (item) => {
+  editChild.value.open = true;
+  editChild.value.formData = item == null ? editChild.value.initFormData : JSON.parse(JSON.stringify(item));
+  editChild.value.isSave = item == null;
+}
+
+const handleDel = (rows) => {
+  Modal.confirm({
+    title: formatMessage('page.delete', '鍒犻櫎'),
+    content: formatMessage('page.delete.confirm', '纭畾鍒犻櫎璇ラ」鍚楋紵'),
+    maskClosable: true,
+    onOk: async () => {
+      const hide = message.loading(formatMessage('common.loading', '璇锋眰涓�'));
+      try {
+        post('/api/waitPakinRule/remove/' + rows.map((row) => row.id).join(','), {}).then(resp => {
+          let result = resp.data;
+          if (result.code === 200) {
+            message.success(result.msg);
+          } else {
+            message.error(result.msg);
+          }
+          getPage()
+          hide()
+        })
+      } catch (error) {
+        message.error(formatMessage('common.fail', '璇锋眰澶辫触'));
+      }
+    },
+  });
+}
+
+const handleExport = async (intl) => {
+  postBlob('/api/waitPakinRule/export', {}).then(result => {
+    const blob = new Blob([result.data], { type: 'application/vnd.ms-excel' });
+    window.location.href = window.URL.createObjectURL(blob);
+    return true;
+  })
+};
+
+const onSearch = () => {
+  // console.log('search');
+  getPage()
+}
+
+const onPageChange = (page, size) => {
+  currentPage = page;
+  pageSize = size;
+  getPage();
+}
+
+function handleTableReload(value) {
+  getPage()
+}
+
+</script>
+
+<script>
+export default {
+  name: '缁勬墭瑙勫垯'
+}
+</script>
+
+<template>
+  <div>
+    <EditView ref="editChild" @tableReload="handleTableReload" />
+    <div class="table-header">
+      <a-input-search v-model:value="searchInput" :placeholder="formatMessage('page.input', '璇疯緭鍏�')"
+        style="width: 200px;" @search="onSearch" />
+      <div class="table-header-right">
+        <a-button @click="handleEdit(null)" type="primary">{{ formatMessage('page.add', '娣诲姞') }}</a-button>
+        <a-button @click="handleExport">{{ formatMessage('page.export', '瀵煎嚭') }}</a-button>
+      </div>
+    </div>
+    <a-table :row-selection="{ selectedRowKeys: state.selectedRowKeys, onChange: onSelectChange }"
+      :data-source="tableData.records" :defaultExpandAllRows="false" :key="TABLE_KEY" rowKey="id"
+      :pagination="{ total: tableData.total, onChange: onPageChange }"
+      :scroll="{ y: 768, scrollToFirstRowOnChange: true }" :columns="columns" @resizeColumn="handleResizeColumn">
+      <template #bodyCell="{ column, text, record }">
+        <template v-if="column.dataIndex === 'oper'">
+          <div style="display: flex;justify-content: space-evenly;">
+            <a-button type="link" primary @click="handleEdit(record)">{{ formatMessage('page.edit', '缂栬緫') }}</a-button>
+            <a-button type="link" danger @click="handleDel([record])">{{ formatMessage('page.delete', '鍒犻櫎')
+              }}</a-button>
+          </div>
+        </template>
+      </template>
+    </a-table>
+  </div>
+</template>
+
+<style></style>
diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/controller/WaitPakinController.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/controller/WaitPakinController.java
index f8d976b..d7f845a 100644
--- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/controller/WaitPakinController.java
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/controller/WaitPakinController.java
@@ -5,9 +5,7 @@
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.zy.asrs.framework.common.Cools;
 import com.zy.asrs.framework.common.R;
-import com.zy.asrs.framework.exception.CoolException;
 import com.zy.asrs.wms.asrs.entity.*;
-import com.zy.asrs.wms.asrs.entity.enums.OrderSettleType;
 import com.zy.asrs.wms.asrs.service.*;
 import com.zy.asrs.wms.common.annotation.OperationLog;
 import com.zy.asrs.wms.common.domain.BaseParam;
@@ -29,14 +27,6 @@
 
     @Autowired
     private WaitPakinService waitPakinService;
-    @Autowired
-    private OrderService orderService;
-    @Autowired
-    private OrderDetlService orderDetlService;
-    @Autowired
-    private LocService locService;
-    @Autowired
-    private TaskService taskService;
 
     @PreAuthorize("hasAuthority('asrs:waitPakin:list')")
     @PostMapping("/waitPakin/page")
@@ -67,56 +57,12 @@
     @PreAuthorize("hasAuthority('asrs:waitPakin:save')")
     @OperationLog("娣诲姞缁勬墭閫氱煡妗�")
     @PostMapping("/waitPakin/save")
-    @Transactional
     public R save(@RequestBody WaitPakin waitPakin) {
-        if (waitPakin.getAnfme() <= 0) {
-            return R.error("缁勬墭鏁伴噺閿欒");
-        }
-
-        List<Loc> locList = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, waitPakin.getBarcode()));
-        if (!locList.isEmpty()) {
-            return R.error("鎵樼洏宸插湪搴�");
-        }
-
-        List<Task> taskList = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getBarcode, waitPakin.getBarcode()));
-        if (!taskList.isEmpty()) {
-            return R.error("鎵樼洏姝e湪鍏ュ簱涓�");
-        }
-
-        //鏌ヨ鏄惁瀛樺湪鐩稿悓鏄庣粏鍜屾墭鐩樼爜鐨勭粍鎵橀�氱煡妗�
-        WaitPakin waitPakin1 = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, waitPakin.getBarcode()).eq(WaitPakin::getDetlId, waitPakin.getDetlId()));
-        if (waitPakin1 == null) {
-            //涓嶅瓨鍦ㄧ粍鎵橀�氱煡妗o紝鍒涘缓
-            if (!waitPakinService.save(waitPakin)) {
-                return R.error("娣诲姞澶辫触");
-            }
-        }else {
-            //瀛樺湪缁勬墭閫氱煡妗o紝鏇存柊
-            waitPakin1.setAnfme(waitPakin1.getAnfme() + waitPakin.getAnfme());
-            waitPakin1.setUpdateTime(new Date());
-            if (!waitPakinService.updateById(waitPakin1)) {
-                return R.error("娣诲姞澶辫触");
-            }
-        }
-
-        OrderDetl orderDetl = orderDetlService.getById(waitPakin.getDetlId());
-        if (orderDetl == null) {
-            throw new CoolException("璁㈠崟鏄庣粏涓嶅瓨鍦�");
-        }
-
-        //鑾峰彇璁㈠崟
-        Order order = orderService.getById(orderDetl.getOrderId());
-        if(order == null){
-            throw new CoolException("璁㈠崟涓嶅瓨鍦�");
-        }
-
-        //鏇存柊璁㈠崟鐘舵��
-        if (order.getOrderSettle().equals(OrderSettleType.INIT.val())) {
-            order.setOrderSettle(OrderSettleType.WAIT.val());
-            order.setUpdateTime(new Date());
-            if (!orderService.updateById(order)) {
-                throw new CoolException("璁㈠崟鏁版嵁鏇存柊澶辫触");
-            }
+        try {
+            waitPakinService.comb(waitPakin);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return R.error(e.getMessage());
         }
         return R.ok("娣诲姞鎴愬姛");
     }
diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/controller/WaitPakinRuleController.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/controller/WaitPakinRuleController.java
new file mode 100644
index 0000000..c670fca
--- /dev/null
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/controller/WaitPakinRuleController.java
@@ -0,0 +1,102 @@
+package com.zy.asrs.wms.asrs.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zy.asrs.framework.common.Cools;
+import com.zy.asrs.framework.common.R;
+import com.zy.asrs.wms.common.annotation.OperationLog;
+import com.zy.asrs.wms.common.domain.BaseParam;
+import com.zy.asrs.wms.common.domain.KeyValVo;
+import com.zy.asrs.wms.common.domain.PageParam;
+import com.zy.asrs.wms.asrs.entity.WaitPakinRule;
+import com.zy.asrs.wms.asrs.service.WaitPakinRuleService;
+import com.zy.asrs.wms.system.controller.BaseController;
+import com.zy.asrs.wms.utils.ExcelUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/api")
+public class WaitPakinRuleController extends BaseController {
+
+    @Autowired
+    private WaitPakinRuleService waitPakinRuleService;
+
+    @PreAuthorize("hasAuthority('asrs:waitPakinRule:list')")
+    @PostMapping("/waitPakinRule/page")
+    public R page(@RequestBody Map<String, Object> map) {
+        BaseParam baseParam = buildParam(map, BaseParam.class);
+        PageParam<WaitPakinRule, BaseParam> pageParam = new PageParam<>(baseParam, WaitPakinRule.class);
+        return R.ok().add(waitPakinRuleService.page(pageParam, pageParam.buildWrapper(true)));
+    }
+
+    @PreAuthorize("hasAuthority('asrs:waitPakinRule:list')")
+    @PostMapping("/waitPakinRule/list")
+    public R list(@RequestBody Map<String, Object> map) {
+        return R.ok().add(waitPakinRuleService.list());
+    }
+
+    @PreAuthorize("hasAuthority('asrs:waitPakinRule:list')")
+    @GetMapping("/waitPakinRule/{id}")
+    public R get(@PathVariable("id") Long id) {
+        return R.ok().add(waitPakinRuleService.getById(id));
+    }
+
+    @PreAuthorize("hasAuthority('asrs:waitPakinRule:save')")
+    @OperationLog("娣诲姞缁勬墭瑙勫垯")
+    @PostMapping("/waitPakinRule/save")
+    public R save(@RequestBody WaitPakinRule waitPakinRule) {
+        if (!waitPakinRuleService.save(waitPakinRule)) {
+            return R.error("娣诲姞澶辫触");
+        }
+        return R.ok("娣诲姞鎴愬姛");
+    }
+
+    @PreAuthorize("hasAuthority('asrs:waitPakinRule:update')")
+    @OperationLog("淇敼缁勬墭瑙勫垯")
+    @PostMapping("/waitPakinRule/update")
+    public R update(@RequestBody WaitPakinRule waitPakinRule) {
+        if (!waitPakinRuleService.updateById(waitPakinRule)) {
+            return R.error("淇敼澶辫触");
+        }
+        return R.ok("淇敼鎴愬姛");
+    }
+
+    @PreAuthorize("hasAuthority('asrs:waitPakinRule:remove')")
+    @OperationLog("鍒犻櫎缁勬墭瑙勫垯")
+    @PostMapping("/waitPakinRule/remove/{ids}")
+    public R remove(@PathVariable Long[] ids) {
+        if (!waitPakinRuleService.removeByIds(Arrays.asList(ids))) {
+            return R.error("鍒犻櫎澶辫触");
+        }
+        return R.ok("鍒犻櫎鎴愬姛");
+    }
+
+    @PreAuthorize("hasAuthority('asrs:waitPakinRule:list')")
+    @PostMapping("/waitPakinRule/query")
+    public R query(@RequestParam(required = false) String condition) {
+        List<KeyValVo> vos = new ArrayList<>();
+        LambdaQueryWrapper<WaitPakinRule> wrapper = new LambdaQueryWrapper<>();
+        if (!Cools.isEmpty(condition)) {
+            wrapper.like(WaitPakinRule::getId, condition);
+        }
+        waitPakinRuleService.page(new Page<>(1, 30), wrapper).getRecords().forEach(
+                item -> vos.add(new KeyValVo(item.getId(), item.getId()))
+        );
+        return R.ok().add(vos);
+    }
+
+    @PreAuthorize("hasAuthority('asrs:waitPakinRule:list')")
+    @PostMapping("/waitPakinRule/export")
+    public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception {
+        ExcelUtil.build(ExcelUtil.create(waitPakinRuleService.list(), WaitPakinRule.class), response);
+    }
+
+}
diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/entity/WaitPakinRule.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/entity/WaitPakinRule.java
new file mode 100644
index 0000000..6fa511c
--- /dev/null
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/entity/WaitPakinRule.java
@@ -0,0 +1,227 @@
+package com.zy.asrs.wms.asrs.entity;
+
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import com.zy.asrs.wms.system.entity.Host;
+import com.zy.asrs.wms.system.entity.User;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import com.zy.asrs.framework.common.Cools;
+import com.zy.asrs.framework.common.SpringUtils;
+import com.zy.asrs.wms.system.service.UserService;
+import com.zy.asrs.wms.system.service.HostService;
+import com.zy.asrs.common.utils.Synchro;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+@TableName("strategy_wait_pakin_rule")
+public class WaitPakinRule implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * ID
+     */
+    @ApiModelProperty(value= "ID")
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 鎵樼洏璁㈠崟 0: 鍗曡鍗�  1: 澶氳鍗�  
+     */
+    @ApiModelProperty(value= "鎵樼洏璁㈠崟 0: 鍗曡鍗�  1: 澶氳鍗�  ")
+    private Integer palletOrder;
+
+    /**
+     * 鏄惁娣疯浇 0: 鍚�  1: 鏄�  
+     */
+    @ApiModelProperty(value= "鏄惁娣疯浇 0: 鍚�  1: 鏄�  ")
+    private Integer palletMixed;
+
+    /**
+     * 鎵�灞炴満鏋�
+     */
+    @ApiModelProperty(value= "鎵�灞炴満鏋�")
+    private Long hostId;
+
+    /**
+     * 鐘舵�� 1: 姝e父  0: 绂佺敤  
+     */
+    @ApiModelProperty(value= "鐘舵�� 1: 姝e父  0: 绂佺敤  ")
+    private Integer status;
+
+    /**
+     * 鏄惁鍒犻櫎 1: 鏄�  0: 鍚�  
+     */
+    @ApiModelProperty(value= "鏄惁鍒犻櫎 1: 鏄�  0: 鍚�  ")
+    @TableLogic
+    private Integer deleted;
+
+    /**
+     * 娣诲姞鏃堕棿
+     */
+    @ApiModelProperty(value= "娣诲姞鏃堕棿")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    /**
+     * 娣诲姞浜哄憳
+     */
+    @ApiModelProperty(value= "娣诲姞浜哄憳")
+    private Long createBy;
+
+    /**
+     * 淇敼鏃堕棿
+     */
+    @ApiModelProperty(value= "淇敼鏃堕棿")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
+
+    /**
+     * 淇敼浜哄憳
+     */
+    @ApiModelProperty(value= "淇敼浜哄憳")
+    private Long updateBy;
+
+    /**
+     * 澶囨敞
+     */
+    @ApiModelProperty(value= "澶囨敞")
+    private String memo;
+
+    public WaitPakinRule() {}
+
+    public WaitPakinRule(Integer palletOrder,Integer palletMixed,Long hostId,Integer status,Integer deleted,Date createTime,Long createBy,Date updateTime,Long updateBy,String memo) {
+        this.palletOrder = palletOrder;
+        this.palletMixed = palletMixed;
+        this.hostId = hostId;
+        this.status = status;
+        this.deleted = deleted;
+        this.createTime = createTime;
+        this.createBy = createBy;
+        this.updateTime = updateTime;
+        this.updateBy = updateBy;
+        this.memo = memo;
+    }
+
+//    WaitPakinRule waitPakinRule = new WaitPakinRule(
+//            null,    // 鎵樼洏璁㈠崟
+//            null,    // 鏄惁娣疯浇
+//            null,    // 鎵�灞炴満鏋�
+//            null,    // 鐘舵��
+//            null,    // 鏄惁鍒犻櫎
+//            null,    // 娣诲姞鏃堕棿
+//            null,    // 娣诲姞浜哄憳
+//            null,    // 淇敼鏃堕棿
+//            null,    // 淇敼浜哄憳
+//            null    // 澶囨敞
+//    );
+
+    public String getPalletOrder$(){
+        if (null == this.palletOrder){ return null; }
+        switch (this.palletOrder){
+            case 0:
+                return "鍗曡鍗�";
+            case 1:
+                return "澶氳鍗�";
+            default:
+                return String.valueOf(this.palletOrder);
+        }
+    }
+
+    public String getPalletMixed$(){
+        if (null == this.palletMixed){ return null; }
+        switch (this.palletMixed){
+            case 0:
+                return "鍚�";
+            case 1:
+                return "鏄�";
+            default:
+                return String.valueOf(this.palletMixed);
+        }
+    }
+
+    public String getHostId$(){
+        HostService service = SpringUtils.getBean(HostService.class);
+        Host host = service.getById(this.hostId);
+        if (!Cools.isEmpty(host)){
+            return String.valueOf(host.getName());
+        }
+        return null;
+    }
+
+    public String getStatus$(){
+        if (null == this.status){ return null; }
+        switch (this.status){
+            case 1:
+                return "姝e父";
+            case 0:
+                return "绂佺敤";
+            default:
+                return String.valueOf(this.status);
+        }
+    }
+
+    public String getDeleted$(){
+        if (null == this.deleted){ return null; }
+        switch (this.deleted){
+            case 1:
+                return "鏄�";
+            case 0:
+                return "鍚�";
+            default:
+                return String.valueOf(this.deleted);
+        }
+    }
+
+    public String getCreateTime$(){
+        if (Cools.isEmpty(this.createTime)){
+            return "";
+        }
+        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.createTime);
+    }
+
+    public String getCreateBy$(){
+        UserService service = SpringUtils.getBean(UserService.class);
+        User user = service.getById(this.createBy);
+        if (!Cools.isEmpty(user)){
+            return String.valueOf(user.getNickname());
+        }
+        return null;
+    }
+
+    public String getUpdateTime$(){
+        if (Cools.isEmpty(this.updateTime)){
+            return "";
+        }
+        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.updateTime);
+    }
+
+    public String getUpdateBy$(){
+        UserService service = SpringUtils.getBean(UserService.class);
+        User user = service.getById(this.updateBy);
+        if (!Cools.isEmpty(user)){
+            return String.valueOf(user.getNickname());
+        }
+        return null;
+    }
+
+
+
+    public void sync(Object source) {
+        Synchro.Copy(source, this);
+    }
+}
diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/mapper/WaitPakinRuleMapper.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/mapper/WaitPakinRuleMapper.java
new file mode 100644
index 0000000..bb8e53b
--- /dev/null
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/mapper/WaitPakinRuleMapper.java
@@ -0,0 +1,12 @@
+package com.zy.asrs.wms.asrs.mapper;
+
+import com.zy.asrs.wms.asrs.entity.WaitPakinRule;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+@Mapper
+@Repository
+public interface WaitPakinRuleMapper extends BaseMapper<WaitPakinRule> {
+
+}
diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/WaitPakinRuleService.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/WaitPakinRuleService.java
new file mode 100644
index 0000000..be14701
--- /dev/null
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/WaitPakinRuleService.java
@@ -0,0 +1,11 @@
+package com.zy.asrs.wms.asrs.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.zy.asrs.wms.asrs.entity.WaitPakin;
+import com.zy.asrs.wms.asrs.entity.WaitPakinRule;
+
+public interface WaitPakinRuleService extends IService<WaitPakinRule> {
+
+    boolean rule(WaitPakin waitPakin);
+
+}
diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/WaitPakinService.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/WaitPakinService.java
index 76b6a42..29c0996 100644
--- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/WaitPakinService.java
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/WaitPakinService.java
@@ -9,4 +9,7 @@
 
     List<WaitPakin> getByOrderDetlId(Long orderDetlId);
 
+    //缁勬墭
+    boolean comb(WaitPakin waitPakin);
+
 }
diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WaitPakinRuleServiceImpl.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WaitPakinRuleServiceImpl.java
new file mode 100644
index 0000000..89fffc5
--- /dev/null
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WaitPakinRuleServiceImpl.java
@@ -0,0 +1,58 @@
+package com.zy.asrs.wms.asrs.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zy.asrs.framework.exception.CoolException;
+import com.zy.asrs.wms.asrs.entity.WaitPakin;
+import com.zy.asrs.wms.asrs.mapper.WaitPakinRuleMapper;
+import com.zy.asrs.wms.asrs.entity.WaitPakinRule;
+import com.zy.asrs.wms.asrs.service.WaitPakinRuleService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zy.asrs.wms.asrs.service.WaitPakinService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service("waitPakinRuleService")
+public class WaitPakinRuleServiceImpl extends ServiceImpl<WaitPakinRuleMapper, WaitPakinRule> implements WaitPakinRuleService {
+
+    @Autowired
+    private WaitPakinService waitPakinService;
+
+    @Override
+    public boolean rule(WaitPakin waitPakin) {
+        List<WaitPakinRule> list = this.list(new LambdaQueryWrapper<WaitPakinRule>().eq(WaitPakinRule::getStatus, 1).orderByDesc(WaitPakinRule::getId));
+        if (list.isEmpty()) {
+            return true;//鏃犺鍒欙紝鐩存帴鏀捐
+        }
+
+        List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, waitPakin.getBarcode()));
+        if(waitPakins.isEmpty()) {
+            return true;//鏃犳墭鐩橈紝鏀捐
+        }
+
+        WaitPakinRule waitPakinRule = list.get(0);
+        //鍒ゆ柇鏄惁娣疯浇
+        if (waitPakinRule.getPalletMixed() == 1) {
+            //娣疯浇
+            //鍒ゆ柇鏄惁鍏佽澶氳鍗�
+            if (waitPakinRule.getPalletOrder() == 0) {
+                //鍗曡鍗�
+                for (WaitPakin pakin : waitPakins) {
+                    if (!pakin.getOrderId().equals(waitPakin.getOrderId())) {
+                        throw new CoolException("鎵樼洏涓嶅厑璁稿璁㈠崟");
+                    }
+                }
+            }
+
+        }else {
+            //鍗曟斁
+            //鍒ゆ柇缁勬墭閫氱煡妗f槸鍚﹀凡缁忓瓨鍦ㄦ墭鐩�
+            if(!waitPakins.isEmpty()) {
+                throw new CoolException("鎵樼洏宸茬粍鎵�");
+            }
+        }
+
+        return false;
+    }
+}
diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WaitPakinServiceImpl.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WaitPakinServiceImpl.java
index d66fb95..57b933e 100644
--- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WaitPakinServiceImpl.java
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WaitPakinServiceImpl.java
@@ -1,20 +1,93 @@
 package com.zy.asrs.wms.asrs.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zy.asrs.framework.exception.CoolException;
+import com.zy.asrs.wms.asrs.entity.*;
+import com.zy.asrs.wms.asrs.entity.enums.OrderSettleType;
 import com.zy.asrs.wms.asrs.mapper.WaitPakinMapper;
-import com.zy.asrs.wms.asrs.entity.WaitPakin;
-import com.zy.asrs.wms.asrs.service.WaitPakinService;
+import com.zy.asrs.wms.asrs.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
-import java.util.Collections;
+import java.util.Date;
 import java.util.List;
 
 @Service("waitPakinService")
 public class WaitPakinServiceImpl extends ServiceImpl<WaitPakinMapper, WaitPakin> implements WaitPakinService {
 
+    @Autowired
+    private OrderService orderService;
+    @Autowired
+    private OrderDetlService orderDetlService;
+    @Autowired
+    private LocService locService;
+    @Autowired
+    private TaskService taskService;
+    @Autowired
+    private WaitPakinRuleService waitPakinRuleService;
+
     @Override
     public List<WaitPakin> getByOrderDetlId(Long orderDetlId) {
         return this.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getDetlId, orderDetlId));
     }
+
+    @Override
+    @Transactional
+    public boolean comb(WaitPakin waitPakin) {
+        //缁勬墭瑙勫垯鏍¢獙
+        waitPakinRuleService.rule(waitPakin);
+
+        if (waitPakin.getAnfme() <= 0) {
+            throw new CoolException("缁勬墭鏁伴噺閿欒");
+        }
+
+        List<Loc> locList = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, waitPakin.getBarcode()));
+        if (!locList.isEmpty()) {
+            throw new CoolException("鎵樼洏宸插湪搴�");
+        }
+
+        List<Task> taskList = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getBarcode, waitPakin.getBarcode()));
+        if (!taskList.isEmpty()) {
+            throw new CoolException("鎵樼洏姝e湪鍏ュ簱涓�");
+        }
+
+        //鏌ヨ鏄惁瀛樺湪鐩稿悓鏄庣粏鍜屾墭鐩樼爜鐨勭粍鎵橀�氱煡妗�
+        WaitPakin waitPakin1 = this.getOne(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, waitPakin.getBarcode()).eq(WaitPakin::getDetlId, waitPakin.getDetlId()));
+        if (waitPakin1 == null) {
+            //涓嶅瓨鍦ㄧ粍鎵橀�氱煡妗o紝鍒涘缓
+            if (!this.save(waitPakin)) {
+                throw new CoolException("娣诲姞澶辫触");
+            }
+        }else {
+            //瀛樺湪缁勬墭閫氱煡妗o紝鏇存柊
+            waitPakin1.setAnfme(waitPakin1.getAnfme() + waitPakin.getAnfme());
+            waitPakin1.setUpdateTime(new Date());
+            if (!this.updateById(waitPakin1)) {
+                throw new CoolException("娣诲姞澶辫触");
+            }
+        }
+
+        OrderDetl orderDetl = orderDetlService.getById(waitPakin.getDetlId());
+        if (orderDetl == null) {
+            throw new CoolException("璁㈠崟鏄庣粏涓嶅瓨鍦�");
+        }
+
+        //鑾峰彇璁㈠崟
+        Order order = orderService.getById(orderDetl.getOrderId());
+        if(order == null){
+            throw new CoolException("璁㈠崟涓嶅瓨鍦�");
+        }
+
+        //鏇存柊璁㈠崟鐘舵��
+        if (order.getOrderSettle().equals(OrderSettleType.INIT.val())) {
+            order.setOrderSettle(OrderSettleType.WAIT.val());
+            order.setUpdateTime(new Date());
+            if (!orderService.updateById(order)) {
+                throw new CoolException("璁㈠崟鏁版嵁鏇存柊澶辫触");
+            }
+        }
+        return true;
+    }
 }
diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/utils/CodeBuilder.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/utils/CodeBuilder.java
index abd8c56..fc66e27 100644
--- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/utils/CodeBuilder.java
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/utils/CodeBuilder.java
@@ -22,8 +22,8 @@
 //        generator.username="sa";
 //        generator.password="Zoneyung@zy56$";
 
-        generator.table="strategy_order_no_rule";
-        generator.tableName="鍗曞彿瑙勫垯";
+        generator.table="strategy_wait_pakin_rule";
+        generator.tableName="缁勬墭瑙勫垯";
         generator.rootPackagePath="com.zy.asrs.wms";
         generator.packagePath="com.zy.asrs.wms.asrs";
 
diff --git a/zy-asrs-wms/src/main/resources/mapper/asrs/WaitPakinRuleMapper.xml b/zy-asrs-wms/src/main/resources/mapper/asrs/WaitPakinRuleMapper.xml
new file mode 100644
index 0000000..998e989
--- /dev/null
+++ b/zy-asrs-wms/src/main/resources/mapper/asrs/WaitPakinRuleMapper.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zy.asrs.wms.asrs.mapper.WaitPakinRuleMapper">
+
+</mapper>
diff --git a/zy-asrs-wms/src/main/resources/sql/menu/waitPakinRule.sql b/zy-asrs-wms/src/main/resources/sql/menu/waitPakinRule.sql
new file mode 100644
index 0000000..ac4eebd
--- /dev/null
+++ b/zy-asrs-wms/src/main/resources/sql/menu/waitPakinRule.sql
@@ -0,0 +1,9 @@
+-- save waitPakinRule record
+-- mysql
+insert into `sys_menu` ( `name`, `parent_id`, `route`, `component`, `type`, `sort`, `host_id`, `status`) values ( '缁勬墭瑙勫垯绠$悊', '0', '/asrs/waitPakinRule', '/asrs/waitPakinRule', '0' , '0', '1' , '1');
+
+insert into `sys_menu` ( `name`, `parent_id`, `type`, `authority`, `sort`, `host_id`, `status`) values ( '鏌ヨ缁勬墭瑙勫垯', '', '1', 'asrs:waitPakinRule:list', '0', '1', '1');
+insert into `sys_menu` ( `name`, `parent_id`, `type`, `authority`, `sort`, `host_id`, `status`) values ( '娣诲姞缁勬墭瑙勫垯', '', '1', 'asrs:waitPakinRule:save', '1', '1', '1');
+insert into `sys_menu` ( `name`, `parent_id`, `type`, `authority`, `sort`, `host_id`, `status`) values ( '淇敼缁勬墭瑙勫垯', '', '1', 'asrs:waitPakinRule:update', '2', '1', '1');
+insert into `sys_menu` ( `name`, `parent_id`, `type`, `authority`, `sort`, `host_id`, `status`) values ( '鍒犻櫎缁勬墭瑙勫垯', '', '1', 'asrs:waitPakinRule:remove', '3', '1', '1');
+

--
Gitblit v1.9.1