From 6c3c8b3e66acf2aeff85af46c7193aac3825bc3a Mon Sep 17 00:00:00 2001 From: zxf <1532322479@qq.com> Date: Tue, 3 Mar 2026 10:27:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E5=87=BA=E5=BA=93?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/api/ckbillcargo.js | 9 +- admin/src/api/ckcargostock.js | 28 + .../src/components/MyFormItemInput/index.vue | 2 +- admin/src/components/SearchBlock/index.vue | 28 +- admin/src/components/WarehouseName/index.vue | 28 + admin/src/directive/index.js | 2 + admin/src/directive/module/enterboard.js | 22 + admin/src/main.js | 2 +- admin/src/store/getters.js | 3 +- admin/src/store/modules/warehouse.js | 39 + .../components/StockChoose/index.vue | 248 ++++++ .../ckoutbound/components/StockOut/index.vue | 771 ++++++++++++++++++ admin/src/views/ck/ckoutbound/index.vue | 623 ++++++++++++++ admin/src/views/ck/ckstock/index.vue | 639 +++++++++++++++ .../ckwarehouse/components/BillEdit/index.vue | 209 ++++- .../ckwarehouse/components/BillList/index.vue | 15 +- admin/src/views/ck/ckwarehouse/index.vue | 121 +-- admin/src/views/ck/instock/index.vue | 731 +++++++++++++++++ .../controller/CkBillCargoController.java | 165 +++- .../controller/CkBillController.java | 334 ++++---- .../controller/CkCargoStockController.java | 248 +++++- .../modules/autogencode/entity/CkBill.java | 12 + .../autogencode/entity/CkBillCargo.java | 12 +- .../autogencode/entity/CkCargoStock.java | 51 ++ .../autogencode/service/CkBillService.java | 2 + .../service/impl/CkBillServiceImpl.java | 42 +- 26 files changed, 4143 insertions(+), 243 deletions(-) create mode 100644 admin/src/components/WarehouseName/index.vue create mode 100644 admin/src/directive/module/enterboard.js create mode 100644 admin/src/store/modules/warehouse.js create mode 100644 admin/src/views/ck/ckoutbound/components/StockChoose/index.vue create mode 100644 admin/src/views/ck/ckoutbound/components/StockOut/index.vue create mode 100644 admin/src/views/ck/ckoutbound/index.vue create mode 100644 admin/src/views/ck/ckstock/index.vue create mode 100644 admin/src/views/ck/instock/index.vue diff --git a/admin/src/api/ckbillcargo.js b/admin/src/api/ckbillcargo.js index 79c8e3c..781cd57 100644 --- a/admin/src/api/ckbillcargo.js +++ b/admin/src/api/ckbillcargo.js @@ -75,4 +75,11 @@ export function confirmPutBill(id) { }) } - +// 分页查询出入库单据明细列表 +export function selectTotalWt(query) { + return request({ + url: 'autogencode/ckbillcargo/selectTotalWt', + method: 'get', + params: query + }) +} diff --git a/admin/src/api/ckcargostock.js b/admin/src/api/ckcargostock.js index 3184d88..5d5b0ab 100644 --- a/admin/src/api/ckcargostock.js +++ b/admin/src/api/ckcargostock.js @@ -61,3 +61,31 @@ export function ckcargostockListApi(params) { }) } +/** + * ckcargostock列表 + * @param pram + */ +export function listCkstock(params) { + return request({ + url: `autogencode/ckcargostock/listCkstock`, + method: 'GET', + params + }) +} + +export function newList(query) { + return request({ + url: 'autogencode/ckcargostock/newList', + method: 'get', + params: query + }) +} + +// 查询仓库库存列表 +export function newListCkstock(query) { + return request({ + url: 'autogencode/ckcargostock/newList' , + method: 'get' + }) +} + diff --git a/admin/src/components/MyFormItemInput/index.vue b/admin/src/components/MyFormItemInput/index.vue index 38fe8b9..ff4595e 100644 --- a/admin/src/components/MyFormItemInput/index.vue +++ b/admin/src/components/MyFormItemInput/index.vue @@ -228,4 +228,4 @@ export default { .el-form-item { margin-bottom: 10px; } - \ No newline at end of file + diff --git a/admin/src/components/SearchBlock/index.vue b/admin/src/components/SearchBlock/index.vue index 6e82ea7..f1ce6dd 100644 --- a/admin/src/components/SearchBlock/index.vue +++ b/admin/src/components/SearchBlock/index.vue @@ -252,6 +252,28 @@ export default { return { ...item.inputStyle }; }, + formatDate(date) { + if (!date) return null; + + let dateObj; + + if (typeof date === 'string') { + dateObj = new Date(date); + } else if (date instanceof Date) { + dateObj = date; + } else { + return null; + } + + if (isNaN(dateObj.getTime())) { + return null; + } + + const year = dateObj.getFullYear(); + const month = String(dateObj.getMonth() + 1).padStart(2, '0'); + const day = String(dateObj.getDate()).padStart(2, '0'); + return `${year}-${month}-${day}`; + }, handleQuery() { const query = {...this.queryForm}; // 处理日期范围拆分 @@ -259,9 +281,9 @@ export default { if (item.type === 'daterange' && item.splitDaterange) { const range = query[item.prop]; if (range && range.length === 2) { - // 拆分日期范围为开始和结束参数 - query[`${item.prop}Begin`] = range[0]; - query[`${item.prop}End`] = range[1]; + // 拆分日期范围为开始和结束参数,并转换为 yyyy-MM-dd 格式 + query[`${item.prop}Begin`] = this.formatDate(range[0]); + query[`${item.prop}End`] = this.formatDate(range[1]); // 删除原有的日期范围字段 delete query[item.prop]; } diff --git a/admin/src/components/WarehouseName/index.vue b/admin/src/components/WarehouseName/index.vue new file mode 100644 index 0000000..c6b6b10 --- /dev/null +++ b/admin/src/components/WarehouseName/index.vue @@ -0,0 +1,28 @@ + + + + + \ No newline at end of file diff --git a/admin/src/directive/index.js b/admin/src/directive/index.js index 256f879..98cd73b 100644 --- a/admin/src/directive/index.js +++ b/admin/src/directive/index.js @@ -14,6 +14,7 @@ import dialogDrag from './dialog/drag' import dialogDragWidth from './dialog/dragWidth' import dialogDragHeight from './dialog/dragHeight' import copy from './copy/copy' +import enterboard from './module/enterboard' const install = function(Vue) { Vue.directive('hasRole', hasRole) @@ -22,6 +23,7 @@ const install = function(Vue) { Vue.directive('dialogDragWidth', dialogDragWidth) Vue.directive('dialogDragHeight', dialogDragHeight) Vue.directive('copy', copy) + Vue.directive('enterboard', enterboard) } if (window.Vue) { diff --git a/admin/src/directive/module/enterboard.js b/admin/src/directive/module/enterboard.js new file mode 100644 index 0000000..717e1a5 --- /dev/null +++ b/admin/src/directive/module/enterboard.js @@ -0,0 +1,22 @@ +export default { + inserted: function (el) { + const inputs = el.querySelectorAll("input"); + const inputArray = Array.from(inputs); + + inputArray.forEach((input, index) => { + input.setAttribute("keyFocusIndex", index); + input.addEventListener("keydown", (ev) => { + if (ev.keyCode === 13) { + const targetTo = ev.srcElement.getAttribute("keyFocusTo"); + if (targetTo) { + this.$refs[targetTo].$el.focus(); + } else { + const attrIndex = ev.srcElement.getAttribute("keyFocusIndex"); + const ctlI = parseInt(attrIndex); + if (ctlI < inputArray.length - 1) inputArray[ctlI + 1].focus(); + } + } + }); + }); + }, +} diff --git a/admin/src/main.js b/admin/src/main.js index c2a75a1..74d14c8 100644 --- a/admin/src/main.js +++ b/admin/src/main.js @@ -114,7 +114,7 @@ Vue.prototype.$validator = function(rule) { return new schema(rule); }; Vue.prototype.handleTree = handleTree -Vue.prototype.parseTime = parseTime +Vue.prototype.parseTime = parseTime Vue.prototype.resetForm = resetForm Vue.prototype.addDateRange = addDateRange Vue.prototype.$sortBy = sortBy diff --git a/admin/src/store/getters.js b/admin/src/store/getters.js index 198e729..a5d6a23 100644 --- a/admin/src/store/getters.js +++ b/admin/src/store/getters.js @@ -24,6 +24,7 @@ const getters = { permissions: state => state.user.permissions, sidebarRouters: state => state.permission.sidebarRouters, errorLogs: state => state.errorLog.logs, - isLogin: state => state.user.isLogin + isLogin: state => state.user.isLogin, + warehouseData: state => state.warehouse.warehouse } export default getters diff --git a/admin/src/store/modules/warehouse.js b/admin/src/store/modules/warehouse.js new file mode 100644 index 0000000..cfbd21f --- /dev/null +++ b/admin/src/store/modules/warehouse.js @@ -0,0 +1,39 @@ +import { listWarehouse } from "@/api/cmwarehouse"; + +const state = { + warehouse: {} +}; + +const mutations = { + SET_WAREHOUSE: (state, warehouse) => { + state.warehouse = warehouse; + } +}; + +const actions = { + // 获取仓库列表 + getWarehouse({ commit }, params) { + return new Promise((resolve, reject) => { + listWarehouse(params) + .then(response => { + const data = response.data || []; + const warehouseMap = {}; + data.forEach(item => { + warehouseMap[item.stockCode] = item; + }); + commit('SET_WAREHOUSE', warehouseMap); + resolve(warehouseMap); + }) + .catch(error => { + reject(error); + }); + }); + } +}; + +export default { + namespaced: true, + state, + mutations, + actions +}; diff --git a/admin/src/views/ck/ckoutbound/components/StockChoose/index.vue b/admin/src/views/ck/ckoutbound/components/StockChoose/index.vue new file mode 100644 index 0000000..a336477 --- /dev/null +++ b/admin/src/views/ck/ckoutbound/components/StockChoose/index.vue @@ -0,0 +1,248 @@ + + + + + diff --git a/admin/src/views/ck/ckoutbound/components/StockOut/index.vue b/admin/src/views/ck/ckoutbound/components/StockOut/index.vue new file mode 100644 index 0000000..6975f13 --- /dev/null +++ b/admin/src/views/ck/ckoutbound/components/StockOut/index.vue @@ -0,0 +1,771 @@ + + + + + diff --git a/admin/src/views/ck/ckoutbound/index.vue b/admin/src/views/ck/ckoutbound/index.vue new file mode 100644 index 0000000..b716592 --- /dev/null +++ b/admin/src/views/ck/ckoutbound/index.vue @@ -0,0 +1,623 @@ + + + + diff --git a/admin/src/views/ck/ckstock/index.vue b/admin/src/views/ck/ckstock/index.vue new file mode 100644 index 0000000..e8fb4be --- /dev/null +++ b/admin/src/views/ck/ckstock/index.vue @@ -0,0 +1,639 @@ + + + diff --git a/admin/src/views/ck/ckwarehouse/components/BillEdit/index.vue b/admin/src/views/ck/ckwarehouse/components/BillEdit/index.vue index 89dadc0..5c2f070 100644 --- a/admin/src/views/ck/ckwarehouse/components/BillEdit/index.vue +++ b/admin/src/views/ck/ckwarehouse/components/BillEdit/index.vue @@ -211,17 +211,11 @@ -
- - - -
- - + +
@@ -279,7 +273,7 @@ import { cmstoragelocationListByAll as listLocation } from "@/api/cmstoragelocat import { ckbillDetailApi as getCkbillInfo, putBill } from '@/api/ckbill'; import { ckbillcargoDeleteApi as delCkcargo, recallPutBill } from '@/api/ckbillcargo'; // import { listVessel } from "@/api/jxc/vessel"; -import FileUpload from "@/components/FileUploadVO"; +import FileUploadVO from "@/components/FileUploadVO/index.vue"; import MyFormItemInput from "@/components/MyFormItemInput"; import rq from "@/components/Rq"; import BillNumberInput from "@/components/BillNumberInput"; @@ -287,7 +281,7 @@ import BillNumberInput from "@/components/BillNumberInput"; export default { name: 'BillEdit', components: { - FileUpload, + FileUploadVO, MyFormItemInput, rq, BillNumberInput, @@ -427,6 +421,12 @@ export default { // type: 0修改 1新增 2查看,data: 新增传billInfo单据信息。修改时data为入库明细 open({ type, data }) { this.type = type; + // 新增单据时初始化form数据,避免旧数据残留 + if (type === 1) { + this.form = { + ckBillCargos: [] + }; + } //console.log("data", data); this.getCargoList(); this.getCustList(); @@ -445,10 +445,33 @@ export default { if (billId) { this.loading = true; getCkbillInfo(billId).then(res => { - const data = res.data || {}; + const data = res || {}; if (!data.ckBillCargos) { data.ckBillCargos = []; } + + // 处理HS编号字段映射和文件格式转换 + data.ckBillCargos.forEach(item => { + // 如果存在hsCode字段但不存在goodsCode字段,将hsCode赋值给goodsCode + if (item.hsCode && !item.goodsCode) { + item.goodsCode = item.hsCode; + } + + // 转换文件格式,将后端返回的file格式转换为FileUploadVO需要的格式 + if (item.file && item.file.length > 0) { + item.fileUploadFiles = item.file.map((file, index) => ({ + attachFileUrl: file.attDir || file.filePath || file.url || '', + attDir: file.attDir || file.filePath || file.url || '', + name: file.name || file.fileName || '', + oldName: file.name || file.fileName || '', + attId: file.attId || '', + uid: file.id || file.fileId || index + new Date().getTime() + })); + } else { + item.fileUploadFiles = []; + } + }); + const firstitem = data.ckBillCargos[0]; if (firstitem) { data.custId = firstitem.custId; @@ -456,7 +479,74 @@ export default { data.custCode = firstitem.custCode; } + // 处理货架名称和货位名称 + data.ckBillCargos.forEach(item => { + // 处理货架名称 + if (item.shelfId) { + // 尝试从仓库列表中查找货架名称 + // 注意:这里可能需要根据实际的API返回结构进行调整 + // 如果API返回的是货架ID,我们需要通过API获取货架名称 + // 暂时设置为默认值,确保显示不是空的 + if (!item.shelfName) { + item.shelfName = '货架 ' + item.shelfId; + } + } + + // 处理货位名称 + if (item.locationId) { + // 尝试从货位列表中查找货位名称 + // 暂时设置为默认值,确保显示不是空的 + if (!item.locationName) { + item.locationName = '货位 ' + item.locationId; + } + } + }); + + // 保存表单数据 this.form = data; + + // 加载货架和货位列表 + if (data.ckBillCargos.length > 0) { + data.ckBillCargos.forEach(item => { + if (item.stockCode) { + // 查找仓库对象获取仓库ID + const warehouse = this.warehouseList.find(warehouseItem => warehouseItem.stockCode === item.stockCode); + if (warehouse) { + // 保存当前的货架和货位信息 + const currentShelfId = item.shelfId; + const currentLocationId = item.locationId; + + // 加载货架列表 + this.getShelfList(warehouse.id).then(() => { + // 延迟执行,确保货架列表已经加载完成 + setTimeout(() => { + // 如果有货架ID,设置货架名称 + if (currentShelfId) { + const shelf = this.shelfList.find(shelfItem => shelfItem.id === currentShelfId); + if (shelf) { + item.shelfName = shelf.shelfName; + // 加载货位列表 + this.getLocationList(currentShelfId).then(() => { + // 延迟执行,确保货位列表已经加载完成 + setTimeout(() => { + // 如果有货位ID,设置货位名称 + if (currentLocationId) { + const location = this.locationList.find(locationItem => locationItem.id === currentLocationId); + if (location) { + item.locationName = location.storageLocationName; + } + } + }, 100); + }); + } + } + }, 100); + }); + } + } + }); + } + if (type === 1) { this.addBillTable(); } @@ -630,6 +720,9 @@ export default { stockName: '', shelfName: '', locationName: '', + file: [], // 存储后端需要的格式 + fileUploadFiles: [], // 存储FileUploadVO需要的格式 + fileId: '', }); this.$refs.table.bodyWrapper.scrollTop = this.$refs.table.bodyWrapper.scrollHeight; this.$nextTick(() => { @@ -644,13 +737,13 @@ export default { cancelButtonText: '取消', type: 'warning', }).then(() => { - const serveIds = this.selectedList.filter(val => val.id).map(val => val.id).join(); + const serveIds = this.selectedList.filter(val => val.id).map(val => val.id); const didDelete = () => { this.form.ckBillCargos = this.form.ckBillCargos.filter(val => !this.selectedList.includes(val)); this.selectedList = []; this.$refs.table.clearSelection(); } - if (serveIds) { + if (serveIds && serveIds.length > 0) { // 删除 this.loading = true; delCkcargo(serveIds).then(res => { @@ -683,8 +776,9 @@ export default { if (ele.id == cargoId) { form.cargoName = ele.cargoName; form.goodsCode = ele.goodsCode; - form.cargoSpec = ele.cargoSpec; - form.originCountry = ele.originCountry; + // 使用cargoList中的spec字段填充cargoSpec + form.cargoSpec = ele.spec || ''; + // 移除originCountry的自动填充,取消与货物名称的联动 } }) }, @@ -716,20 +810,28 @@ export default { }, // 获取货架列表 getShelfList(warehouseId) { - listShelf({ warehouseId }).then(response => { - this.shelfList = response || []; - }).catch(e => { - console.error('获取货架列表失败:', e); - this.shelfList = []; + return new Promise((resolve, reject) => { + listShelf({ warehouseId }).then(response => { + this.shelfList = response || []; + resolve(); + }).catch(e => { + console.error('获取货架列表失败:', e); + this.shelfList = []; + resolve(); // 即使失败也resolve,避免阻塞 + }); }); }, // 获取货位列表 getLocationList(shelfId) { - listLocation({ shelfId }).then(response => { - this.locationList = response || []; - }).catch(e => { - console.error('获取货位列表失败:', e); - this.locationList = []; + return new Promise((resolve, reject) => { + listLocation({ shelfId }).then(response => { + this.locationList = response || []; + resolve(); + }).catch(e => { + console.error('获取货位列表失败:', e); + this.locationList = []; + resolve(); // 即使失败也resolve,避免阻塞 + }); }); }, // 仓库选择变化 @@ -798,6 +900,57 @@ export default { // }).catch(e => { // }); // }, + // 更新文件列表 + updateFile(files, row) { + // 保存FileUploadVO返回的文件格式 + row.fileUploadFiles = files; + // 生成新的fileId + if (files && files.length > 0) { + const newId = Date.now() + Math.floor(Math.random() * 1000); + row.fileId = String(newId); + // 将FileUploadVO返回的文件格式转换为后端SystemAttachment需要的格式 + row.file = files.map(file => { + // 处理文件路径,确保符合后端要求的格式 + let attDir = file.attDir || file.attachFileUrl || ''; + // 如果路径以/file/public/开头,去掉这个前缀,因为后端存储格式不需要 + if (attDir.startsWith('/file/public/')) { + attDir = attDir.replace('/file/public/', ''); + } else if (attDir.startsWith('/file/')) { + attDir = attDir.replace('/file/', ''); + } + + return { + // 严格按照SystemAttachment的字段要求设置 + attId: file.id || file.attId || String(newId), // 确保转换为字符串 + name: file.name || file.oldName || '', // 附件名称 + attDir: attDir, // 附件路径 + attSize: file.attSize || '', // 附件大小 + attType: file.attType || '', // 附件类型 + // 保留原有字段以保持兼容性 + fileName: file.name || file.oldName || '', + filePath: attDir, + url: attDir, + createTime: null, + createdBy: null, + createTimeStr: null, + delFlag: '0', + updateBy: null, + updateTime: null, + i18nCode: '', + i18nLanguage: '', + originalFileName: file.name || file.oldName || '', + position: 0, + remark: file.remark || '', + sort: 0, + status: '' + } + }); + } else { + row.fileId = ''; + row.file = []; + row.fileUploadFiles = []; + } + }, } } diff --git a/admin/src/views/ck/ckwarehouse/components/BillList/index.vue b/admin/src/views/ck/ckwarehouse/components/BillList/index.vue index 613cb0a..277d176 100644 --- a/admin/src/views/ck/ckwarehouse/components/BillList/index.vue +++ b/admin/src/views/ck/ckwarehouse/components/BillList/index.vue @@ -86,10 +86,21 @@ export default { getList() { this.loading = true; this.queryParams.billType = this.billType; - stockPageListCkbill({ + // 构建请求参数,将 dateBegin/dateEnd 映射为 beginDate/endDate + const requestParams = { ...this.queryParams, ...this.params - }).then(response => { + }; + // 映射日期参数 + if (requestParams.dateBegin) { + requestParams.beginDate = requestParams.dateBegin; + delete requestParams.dateBegin; + } + if (requestParams.dateEnd) { + requestParams.endDate = requestParams.dateEnd; + delete requestParams.dateEnd; + } + stockPageListCkbill(requestParams).then(response => { this.list = response.list || []; this.total = response.total; diff --git a/admin/src/views/ck/ckwarehouse/index.vue b/admin/src/views/ck/ckwarehouse/index.vue index a9476dd..249a8b9 100644 --- a/admin/src/views/ck/ckwarehouse/index.vue +++ b/admin/src/views/ck/ckwarehouse/index.vue @@ -124,7 +124,7 @@ import { datePickerOpts } from "@/utils"; import SearchBlock from '@/components/SearchBlock'; import { - ckbillcargoListApi as pageListCkcargo, + ckbillcargoListApi, ckbillcargoDeleteApi as delCkcargo, recallPutBill, confirmPutBill @@ -164,8 +164,9 @@ export default { }, { label: '单据日期', - prop: 'queryTime', + prop: 'date', type: 'daterange', + splitDaterange: true, options: datePickerOpts() }, { @@ -269,6 +270,7 @@ export default { listNumber: null, beginDate: null, endDate: null, + queryTime: null, }, // 选中单据 selectedBill: {}, @@ -278,7 +280,7 @@ export default { }, created() { listWarehouse({}).then(response => { - this.warehouses = response.data || []; + this.warehouses = response || []; }).catch(error => { console.error('获取仓库列表失败:', error); this.warehouses = []; @@ -303,13 +305,6 @@ export default { // 刷新列表 refreshList() { this.queryParams.billNumber = ''; - if (this.billQuery.queryTime) { - this.billQuery.beginDate = this.billQuery.queryTime[0]; - this.billQuery.endDate = this.billQuery.queryTime[1]; - } else { - this.billQuery.beginDate = null; - this.billQuery.endDate = null; - } this.$nextTick(() => { this.$refs.billList.getList(); }) @@ -317,7 +312,27 @@ export default { /** 查询仓库入库管理列表 */ getList() { this.loading = true; - pageListCkcargo(this.queryParams).then(response => { + + // 构建查询参数,确保日期格式正确 + const params = { ...this.queryParams }; + + // 处理日期范围参数,确保不是数组格式 + if (Array.isArray(params.beginDate)) { + params.beginDate = params.beginDate[0]; + } + if (Array.isArray(params.endDate)) { + params.endDate = params.endDate[1]; + } + + // 确保日期格式为 yyyy-MM-dd HH:mm:ss + // if (params.beginDate && typeof params.beginDate === 'object') { + // params.beginDate = this.formatDate(params.beginDate, false); + // } + // if (params.endDate && typeof params.endDate === 'object') { + // params.endDate = this.formatDate(params.endDate, true); + // } + + ckbillcargoListApi(params).then(response => { this.ckcargoList = response.list; this.total = response.total; this.loading = false; @@ -338,12 +353,53 @@ export default { }, //排序 handleSortChange(col) { + // 保存当前的日期范围参数 + const beginDate = this.queryParams.beginDate; + const endDate = this.queryParams.endDate; + this.$sortBy(col, this.queryParams); + + // 恢复日期范围参数 + this.queryParams.beginDate = beginDate; + this.queryParams.endDate = endDate; + this.getList(); }, + /** 格式化日期为 yyyy-MM-dd 格式 */ + formatDate(date) { + if (!date) return null; + + let dateObj; + + if (typeof date === 'string') { + dateObj = new Date(date); + } else if (date instanceof Date) { + dateObj = date; + } else { + return null; + } + + if (isNaN(dateObj.getTime())) { + return null; + } + + const year = dateObj.getFullYear(); + const month = String(dateObj.getMonth() + 1).padStart(2, '0'); + const day = String(dateObj.getDate()).padStart(2, '0'); + return `${year}-${month}-${day}`; + }, /** 搜索按钮操作 */ handleQuery() { this.queryParams.pageNum = 1; + // 处理日期范围参数 + this.queryParams.beginDate = this.billQuery.dateBegin || null; + this.queryParams.endDate = this.billQuery.dateEnd || null; + // 将其他搜索参数复制到 queryParams 中 + this.queryParams.stockCode = this.billQuery.stockCode; + this.queryParams.cargoName = this.billQuery.cargoName; + this.queryParams.billNumber = this.billQuery.billNumber; + this.queryParams.customsNo = this.billQuery.customsNo; + this.queryParams.listNumber = this.billQuery.listNumber; this.refreshList(); }, /** 重置按钮操作 */ @@ -356,8 +412,8 @@ export default { stockName: null, customsNo: null, listNumber: null, - beginDateTwo: null, - endDateTwo: null, + dateBegin: null, + dateEnd: null, } this.handleQuery(); }, @@ -384,15 +440,10 @@ export default { /** 新增按钮操作 */ handleAdd(type) { this.hideEdit = false; - this.title = "添加"; if (type === 'bill') { this.open = true; this.$nextTick(() => { - if (this.$refs.billEdit) { - this.$refs.billEdit.open({ type: 1 }); - } else { - console.error('BillEdit component not found'); - } + this.$refs.billEdit.open({ type: 1 }); }) return; } @@ -404,22 +455,14 @@ export default { }).then(() => { this.open = true; this.$nextTick(() => { - if (this.$refs.billEdit) { - this.$refs.billEdit.open({ type: 1 }); - } else { - console.error('BillEdit component not found'); - } + this.$refs.billEdit.open({ type: 1 }); }) }); return; } this.open = true; this.$nextTick(() => { - if (this.$refs.billEdit) { - this.$refs.billEdit.open({ type: 1, data: this.selectedBill }); - } else { - console.error('BillEdit component not found'); - } + this.$refs.billEdit.open({ type: 1, data: this.selectedBill }); }) }, backBill() { @@ -462,37 +505,21 @@ export default { }); }); }, - /** 修改按钮操作 */ handleUpdate(row) { this.hideEdit = row.billStatus == '1'; - this.title = "修改"; this.open = true; this.$nextTick(() => { - if (this.$refs.billEdit) { - this.$refs.billEdit.open({ type: 0, data: row }); - } else { - console.error('BillEdit component not found'); - } + this.$refs.billEdit.open({ type: 0, data: row }); }) }, showDetail(row) { this.hideEdit = true; - this.title = "查看"; this.open = true; this.$nextTick(() => { - console.log(row.id) - if (this.$refs.billEdit) { - // 确保row对象包含billId属性 - const data = row.id ? row : this.modifyData; - console.log(data) - this.$refs.billEdit.open({ type: 2, data: data }); - } else { - console.error('BillEdit component not found'); - } + this.$refs.billEdit.open({ type: 2, data: row.id ? row : this.modifyData }); }) }, - /** 删除按钮操作 */ handleDelete(row) { const ids = row.id || this.ids; diff --git a/admin/src/views/ck/instock/index.vue b/admin/src/views/ck/instock/index.vue new file mode 100644 index 0000000..5843b4d --- /dev/null +++ b/admin/src/views/ck/instock/index.vue @@ -0,0 +1,731 @@ + + + diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/CkBillCargoController.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/CkBillCargoController.java index 258b7cd..cb44bad 100644 --- a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/CkBillCargoController.java +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/CkBillCargoController.java @@ -1,8 +1,10 @@ package com.zbkj.modules.autogencode.controller; +import java.math.BigDecimal; import java.util.Arrays; import java.util.Calendar; import java.util.Date; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -10,8 +12,10 @@ import java.util.Map; import cn.hutool.core.lang.Validator; import cn.hutool.core.util.StrUtil; import com.zbkj.modules.autogencode.entity.*; +import com.zbkj.modules.autogencode.service.CkStockChangeService; import org.apache.commons.lang3.StringUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zbkj.common.request.PageParamRequest; import com.zbkj.common.response.CommonResult; import com.zbkj.common.page.CommonPage; @@ -42,6 +46,8 @@ public class CkBillCargoController { @Autowired private CkBillStockService ckBillStockService; + @Autowired + private CkStockChangeService ckStockChangeService; /** * 条件设置 * 根据实体类字段自动生成查询条件 @@ -286,6 +292,39 @@ public class CkBillCargoController { } + /** + * 处理stockCode和shelfName参数 + */ + private void handleStockCodeParam(LambdaQueryWrapper queryWrapper, CkBillCargo request) { + if (StrUtil.isNotBlank(request.getStockCode()) || StrUtil.isNotBlank(request.getShelfName())) { + // 查询CkBillStock表中stockCode或shelfName等于该值的记录 + LambdaQueryWrapper stockQueryWrapper = new LambdaQueryWrapper<>(); + + // 添加stockCode条件 + if (StrUtil.isNotBlank(request.getStockCode())) { + stockQueryWrapper.eq(CkBillStock::getStockCode, request.getStockCode()); + } + + // 添加shelfName条件 + if (StrUtil.isNotBlank(request.getShelfName())) { + stockQueryWrapper.eq(CkBillStock::getShelfName, request.getShelfName()); + } + + List ckBillStockList = ckBillStockService.list(stockQueryWrapper); + + // 提取billCargoId列表 + List billCargoIds = new ArrayList<>(); + for (CkBillStock ckBillStock : ckBillStockList) { + billCargoIds.add(ckBillStock.getBillCargoId()); + } + + // 如果有billCargoId,添加in条件 + if (!billCargoIds.isEmpty()) { + queryWrapper.in(CkBillCargo::getId, billCargoIds); + } + } + } + /** * 分页显示出入库单据明细 * @param request 搜索条件 @@ -296,6 +335,9 @@ public class CkBillCargoController { public CommonResult> getList(@Validated CkBillCargo request, @Validated PageParamRequest pageParamRequest) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); + // 处理stockCode参数 + handleStockCodeParam(queryWrapper, request); + // 应用搜索条件 buildQueryWrapper(queryWrapper, request); @@ -391,6 +433,22 @@ public class CkBillCargoController { return ckBillService.warehouseWork(ckBill,false); } + /** + * 撤回入库单据 + */ + @ApiOperation("撤回入库单据") + @GetMapping(value = "/recallPutBill/{id}") + public CommonResult recallPutBill(@PathVariable("id") Long id) { + CkBill ckBill = ckBillService.getById(id); + if (!ckBill.getSourceType().equals("1")) { + return CommonResult.failed("非人工操作入库,不能撤回"); + } + if (ckBill.getBillStatus().equals("0")) { + return CommonResult.failed("未提交的出库单不允许做撤回操作"); + } + return ckBillService.recallPutBill(id); + } + /** * 详情数据 @@ -429,10 +487,111 @@ public class CkBillCargoController { */ @RequestMapping(value = "/delete", method = RequestMethod.POST) public CommonResult delete(@RequestBody Long[] ids){ - if (ckBillCargoService.removeByIds(Arrays.asList(ids))) { - return CommonResult.success(); + for (int i = 0; i < ids.length; i++) { + Long id = ids[i]; + CkBill ckBill = ckBillService.getById(id); + if (ckBill != null && ckBill.getBillStatus().equals("1")) { + return CommonResult.failed("此单据已经提交,不允许删除"); + } + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.select(CkBillCargo::getId); + wrapper.eq(CkBillCargo::getBillId,id); + List list = ckBillCargoService.listObjs(wrapper); + + ckBillCargoService.remove(wrapper); + //删除入库记录 + ckStockChangeService.remove(new LambdaQueryWrapper().eq(CkStockChange::getBillId,id)); + //单据明细下出入库信息 + if (!list.isEmpty()) { + LambdaQueryWrapper stockWapper = new LambdaQueryWrapper<>(); + stockWapper.in(CkBillStock::getBillCargoId,list); + ckBillStockService.remove(stockWapper); + } + ckBillService.removeById(id); } - return CommonResult.failed(); + return CommonResult.success("删除成功"); } + /** + * 查询总重量 + */ + @ApiOperation("查询总重量") + @GetMapping("/selectTotalWt") + public CommonResult selectTotalWt(CkBillCargo ckBillCargo) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); + + // 处理stockCode参数 + handleStockCodeParam(queryWrapper, ckBillCargo); + + buildQueryWrapper(queryWrapper, ckBillCargo); + List list = ckBillCargoService.list(queryWrapper); + BigDecimal totalWeight = list.stream() + .map(CkBillCargo::getCargoWt) + .reduce(BigDecimal.ZERO, BigDecimal::add); + return CommonResult.success(totalWeight); + } + +// public MPJLambdaWrapper buildQueryWrapper(CkBillCargo ckBillCargo) { +// MPJLambdaWrapper queryWrapper = new MPJLambdaWrapper(); +// queryWrapper.select(CkBillCargo::getId, CkBillCargo::getBillStatus, CkBillCargo::getSourceType +// , CkBillCargo::getBillId, CkBillCargo::getBillDate, CkBillCargo::getBillNumber +// ,CkBillCargo::getInoutType,CkBillCargo::getVoyageId,CkBillCargo::getVoyageNo +// ,CkBillCargo::getVesselId,CkBillCargo::getVesselName,CkBillCargo::getVesselCargoId +// ,CkBillCargo::getCargoId,CkBillCargo::getHsCode,CkBillCargo::getCargoName +// ,CkBillCargo::getBillNo,CkBillCargo::getCargoSpec,CkBillCargo::getOriginCountry +// ,CkBillCargo::getCustId,CkBillCargo::getCustName,CkBillCargo::getCargoNumber +// ,CkBillCargo::getItemNumber,CkBillCargo::getBookNumber,CkBillCargo::getExpiryDate +// ,CkBillCargo::getOpType,CkBillCargo::getTradType,CkBillCargo::getCustomsNo +// ,CkBillCargo::getListNumber) +// .select(CkBill::getBillNumber,CkBill::getTradWay) +// .select(CkBillStock::getStockName,CkBillStock::getCargoNum,CkBillStock::getCargoWt,CkBillStock::getCargoVol,CkBillStock::getCargoValue,CkBillStock::getStockCode) +// .selectAs(CkBillStock::getBillNumber,CkBillCargo::getOutBillNumber) +// .leftJoin(CkBill.class, CkBill::getId, CkBillCargo::getBillId) +// .leftJoin(CkBillStock.class,CkBillStock::getBillCargoId,CkBillCargo::getId); +// if (Validator.isNotEmpty(ckBillCargo.getInoutType())) { +// if ("3".equals(ckBillCargo.getInoutType())) { +// // 查询转场数据 +// queryWrapper.inSql(CkBillCargo::getBillId, "select id from ck_bill where bill_type = '3'"); +// } else if ("4".equals(ckBillCargo.getInoutType())) { +// // 查询混配数据 +// queryWrapper.inSql(CkBillCargo::getBillId, "select id from ck_bill where bill_type = '4'"); +// } else { +// queryWrapper.eq(CkBillCargo::getInoutType, ckBillCargo.getInoutType()); +// } +// } +// //出入库的页面需要查询所有 +// if(StringUtils.isEmpty(ckBillCargo.getInoutType())||(!ckBillCargo.getInoutType().equals("1")&&!ckBillCargo.getInoutType().equals("2"))){ +// queryWrapper.eq(CkBillCargo::getBillStatus,"1"); +// } +// queryWrapper.eq(ckBillCargo.getBillId()!=null,CkBillCargo::getBillId,ckBillCargo.getBillId()); +// queryWrapper.between(null != ckBillCargo.getBeginDate(),CkBillCargo::getBillDate, ckBillCargo.getBeginDate(), adjustEndDate(ckBillCargo.getEndDate())); +// queryWrapper.between(null != ckBillCargo.getBeginDateTwo(),CkBillCargo::getExpiryDate, ckBillCargo.getBeginDateTwo(), adjustEndDate(ckBillCargo.getEndDateTwo())); +// //单据编号 +// queryWrapper.like(Validator.isNotEmpty(ckBillCargo.getBillNumber()),CkBillCargo::getBillNumber,ckBillCargo.getBillNumber()); +// queryWrapper.like(Validator.isNotEmpty(ckBillCargo.getVesselName()),CkBillCargo::getVesselName,ckBillCargo.getVesselName()); +// //货物名称 +// queryWrapper.like(Validator.isNotEmpty(ckBillCargo.getCargoName()),CkBillCargo::getCargoName,ckBillCargo.getCargoName()); +// //货主名称 +// queryWrapper.like(Validator.isNotEmpty(ckBillCargo.getCustName()),CkBillCargo::getCustName,ckBillCargo.getCustName()); +// //航次号 +// queryWrapper.like(Validator.isNotEmpty(ckBillCargo.getVoyageNo()),CkBillCargo::getVoyageNo,ckBillCargo.getVoyageNo()); +// //核注清单号和报关单号,电子账册项号 +// queryWrapper.like(Validator.isNotEmpty(ckBillCargo.getCustomsNo()),CkBillCargo::getCustomsNo,ckBillCargo.getCustomsNo()); +// queryWrapper.like(Validator.isNotEmpty(ckBillCargo.getListNumber()),CkBillCargo::getListNumber,ckBillCargo.getListNumber()); +// queryWrapper.eq(Validator.isNotEmpty(ckBillCargo.getBookNumber()),CkBillCargo::getBookNumber,ckBillCargo.getBookNumber()); +// //业务性质和贸易性质 +// queryWrapper.eq(Validator.isNotEmpty(ckBillCargo.getOpType()),CkBillCargo::getOpType,ckBillCargo.getOpType()); +// queryWrapper.eq(Validator.isNotEmpty(ckBillCargo.getTradType()),CkBillCargo::getTradType,ckBillCargo.getTradType()); +// queryWrapper.eq(Validator.isNotEmpty(ckBillCargo.getStockCode()),CkBillStock::getStockCode,ckBillCargo.getStockCode()); +// queryWrapper.like(Validator.isNotEmpty(ckBillCargo.getStockName()),CkBillStock::getStockName,ckBillCargo.getStockName()); +// queryWrapper.like(Validator.isNotEmpty(ckBillCargo.getOutBillNumber()),CkBillStock::getBillNumber,ckBillCargo.getOutBillNumber()); +// queryWrapper.eq(Validator.isNotEmpty(ckBillCargo.getTradWay()),CkBill::getTradWay,ckBillCargo.getTradWay()); +// //商品编码 +// queryWrapper.eq(Validator.isNotEmpty(ckBillCargo.getHsCode()),CkBillCargo::getHsCode,ckBillCargo.getHsCode()); +// queryWrapper.orderByDesc(CkBillCargo::getBillDate); +// return queryWrapper; +// } + } + + diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/CkBillController.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/CkBillController.java index 10b4d97..c68e468 100644 --- a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/CkBillController.java +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/CkBillController.java @@ -1,5 +1,6 @@ package com.zbkj.modules.autogencode.controller; +import java.math.BigDecimal; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -14,6 +15,11 @@ import com.zbkj.common.response.CommonResult; import com.zbkj.common.page.CommonPage; import com.zbkj.common.exception.ExceptionCodeEnum; import com.zbkj.modules.autogencode.entity.CkBillCargo; +import com.zbkj.modules.autogencode.entity.CkBillStock; +import com.zbkj.modules.autogencode.entity.CkCargoStock; +import com.zbkj.modules.autogencode.service.CkBillCargoService; +import com.zbkj.modules.autogencode.service.CkBillStockService; +import com.zbkj.modules.autogencode.service.CkCargoStockService; import com.zbkj.service.service.SystemAttachmentService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -44,152 +50,122 @@ public class CkBillController { @Autowired private SystemAttachmentService systemAttachmentService; + @Autowired + private CkBillCargoService ckBillCargoService; + + @Autowired + private CkCargoStockService ckCargoStockService; + + @Autowired + private CkBillStockService ckBillStockService; + /** * 条件设置 - * 根据实体类字段自动生成查询条件 */ - private void condition(LambdaQueryWrapper queryWrapper, CkBill request) { - if (request == null) { - return; + private void condition(LambdaQueryWrapper queryWrapper, CkBill ckBill) { + + + + if (Validator.isNotEmpty(ckBill.getCargoName())) { + queryWrapper.inSql(CkBill::getId, "select bill_id from ck_bill_cargo where cargo_name like '%"+ ckBill.getCargoName() +"%'"); } - - // 根据实体类字段自动生成查询条件 - - // 主键 - if (request.getId() != null) { - queryWrapper.eq(CkBill::getId, request.getId()); - } - - // 区分直接出入库,1,与其他出入库0,(直接出入库,可以在出入库页面直接撤回,其他出入库,需要回到其他入库页面进行撤回) - if (StrUtil.isNotBlank(request.getSourceType())) { - queryWrapper.eq(CkBill::getSourceType, request.getSourceType()); - } - - // 单据状态 0未提交,1提交 默认1,主要用于出入库页面 - if (StrUtil.isNotBlank(request.getBillStatus())) { - queryWrapper.eq(CkBill::getBillStatus, request.getBillStatus()); - } - - // 单据类型 - if (StrUtil.isNotBlank(request.getBillType())) { - queryWrapper.eq(CkBill::getBillType, request.getBillType()); - } - - // 出库类型船舶、火车、车辆 - if (StrUtil.isNotBlank(request.getOutType())) { - queryWrapper.eq(CkBill::getOutType, request.getOutType()); - } - - // 混配比例 - if (request.getProportion() != null) { - queryWrapper.eq(CkBill::getProportion, request.getProportion()); - } - - // 单据日期 - if (request.getBillDate() != null) { - queryWrapper.eq(CkBill::getBillDate, request.getBillDate()); - } - - // 放行日期 - if (request.getReleaseDate() != null) { - queryWrapper.eq(CkBill::getReleaseDate, request.getReleaseDate()); - } - - // 提运单号 - if (StrUtil.isNotBlank(request.getBillNo())) { - queryWrapper.eq(CkBill::getBillNo, request.getBillNo()); - } - - // 单据编号 - if (StrUtil.isNotBlank(request.getBillNumber())) { - queryWrapper.eq(CkBill::getBillNumber, request.getBillNumber()); - } - - // 船舶航次ID - if (request.getVoyageId() != null) { - queryWrapper.eq(CkBill::getVoyageId, request.getVoyageId()); - } - - // 船舶航次货物ID - if (request.getVoyageCargoId() != null) { - queryWrapper.eq(CkBill::getVoyageCargoId, request.getVoyageCargoId()); - } - - // 航次号 - if (StrUtil.isNotBlank(request.getVoyageNo())) { - queryWrapper.eq(CkBill::getVoyageNo, request.getVoyageNo()); - } - - // 贸易方式 - if (StrUtil.isNotBlank(request.getTradWay())) { - queryWrapper.eq(CkBill::getTradWay, request.getTradWay()); - } - - // 船舶ID - if (request.getVesselId() != null) { - queryWrapper.eq(CkBill::getVesselId, request.getVesselId()); - } - - // 船舶名称 - if (StrUtil.isNotBlank(request.getVesselName())) { - queryWrapper.eq(CkBill::getVesselName, request.getVesselName()); - } - - // 委托单号 - if (StrUtil.isNotBlank(request.getWtNumber())) { - queryWrapper.eq(CkBill::getWtNumber, request.getWtNumber()); - } - - // 批次号 - if (StrUtil.isNotBlank(request.getBatchNumber())) { - queryWrapper.eq(CkBill::getBatchNumber, request.getBatchNumber()); - } - - // 状态 - if (StrUtil.isNotBlank(request.getStatus())) { - queryWrapper.eq(CkBill::getStatus, request.getStatus()); - } - - // 备注 - if (StrUtil.isNotBlank(request.getRemark())) { - queryWrapper.eq(CkBill::getRemark, request.getRemark()); - } - - // 删除标志(0代表存在 2代表删除) - if (StrUtil.isNotBlank(request.getDelFlag())) { - queryWrapper.eq(CkBill::getDelFlag, request.getDelFlag()); - } - - // 创建部门 - if (request.getCreateDept() != null) { - queryWrapper.eq(CkBill::getCreateDept, request.getCreateDept()); - } - - // 创建人 - if (request.getCreateBy() != null) { - queryWrapper.eq(CkBill::getCreateBy, request.getCreateBy()); - } - - // 创建时间 - if (request.getCreateTime() != null) { - queryWrapper.eq(CkBill::getCreateTime, request.getCreateTime()); - } - - // 修改人 - if (request.getUpdateBy() != null) { - queryWrapper.eq(CkBill::getUpdateBy, request.getUpdateBy()); - } - - // 修改时间 - if (request.getUpdateTime() != null) { - queryWrapper.eq(CkBill::getUpdateTime, request.getUpdateTime()); - } - - // - if (StrUtil.isNotBlank(request.getTenantId())) { - queryWrapper.eq(CkBill::getTenantId, request.getTenantId()); + + if (Validator.isNotEmpty(ckBill.getCustName())) { + queryWrapper.inSql(CkBill::getId, "select bill_id from ck_bill_cargo where cust_name like '%"+ ckBill.getCustName() +"%'"); } - + + if (Validator.isNotEmpty(ckBill.getBillNumber())) { + queryWrapper.like(CkBill::getBillNumber, ckBill.getBillNumber()); + } + + if (Validator.isNotEmpty(ckBill.getStockCode())) { + queryWrapper.inSql(CkBill::getId, "select a.bill_id from ck_bill_cargo a, ck_bill_stock b where a.id = b.bill_cargo_id and b.stock_code = '"+ ckBill.getStockCode() +"'"); + } + + if (Validator.isNotEmpty(ckBill.getOutBillNumber())) { + queryWrapper.inSql(CkBill::getId, "select a.bill_id from ck_bill_cargo a, ck_bill_stock b where a.id = b.bill_cargo_id and b.bill_number like '%"+ ckBill.getOutBillNumber() +"%'"); + } + + if (Validator.isNotEmpty(ckBill.getStockName())) { + queryWrapper.inSql(CkBill::getId, "select a.bill_id from ck_bill_cargo a, ck_bill_stock b where a.id = b.bill_cargo_id and b.stock_name like '%"+ ckBill.getStockName() +"%'"); + } + + if (Validator.isNotEmpty(ckBill.getCustomsNo())) { + queryWrapper.inSql(CkBill::getId, "select bill_id from ck_bill_cargo where customs_no like '%"+ ckBill.getCustomsNo() +"%'"); + } + + if (Validator.isNotEmpty(ckBill.getListNumber())) { + queryWrapper.inSql(CkBill::getId, "select bill_id from ck_bill_cargo where list_number like '%"+ ckBill.getListNumber() +"%'"); + } + //单据日期 +// if (ckBill.getBillDate() != null) { +// queryWrapper.eq(CkBill::getBillDate, ckBill.getBillDate()); +// } + + if (null != ckBill.getBeginDate()) { + queryWrapper.between(CkBill::getBillDate, ckBill.getBeginDate(), ckBill.getEndDate()); + } + + + //单据编号 + if (Validator.isNotEmpty(ckBill.getBillNo())) { + queryWrapper.like(CkBill::getBillNo, ckBill.getBillNo()); + } + + //贸易方式 + if (Validator.isNotEmpty(ckBill.getTradWay())) { + queryWrapper.like(CkBill::getTradWay, ckBill.getTradWay()); + } + + + if (Validator.isNotEmpty(ckBill.getWtNumber())) { + queryWrapper.like(CkBill::getWtNumber, ckBill.getWtNumber()); + } + + if (Validator.isNotEmpty(ckBill.getBatchNumber())) { + queryWrapper.like(CkBill::getBatchNumber, ckBill.getBatchNumber()); + } + + //船舶航次ID + if (ckBill.getVoyageId() != null) { + queryWrapper.eq(CkBill::getVoyageId, ckBill.getVoyageId()); + } + + //航次号 + if (Validator.isNotEmpty(ckBill.getVoyageNo())) { + queryWrapper.like(CkBill::getVoyageNo, ckBill.getVoyageNo()); + } + + //船舶ID + if (ckBill.getVesselId() != null) { + queryWrapper.eq(CkBill::getVesselId, ckBill.getVesselId()); + } + + //船舶名称 + if (Validator.isNotEmpty(ckBill.getVesselName())) { + queryWrapper.like(CkBill::getVesselName, ckBill.getVesselName()); + } + + //状态 + if (Validator.isNotEmpty(ckBill.getStatus())) { + queryWrapper.eq(CkBill::getStatus, ckBill.getStatus()); + } + + //备注 + if (Validator.isNotEmpty(ckBill.getRemark())) { + queryWrapper.eq(CkBill::getRemark, ckBill.getRemark()); + } + + //删除标志(0代表存在 2代表删除) + if (Validator.isNotEmpty(ckBill.getDelFlag())) { + queryWrapper.eq(CkBill::getDelFlag, ckBill.getDelFlag()); + } + + //租户ID + if (Validator.isNotEmpty(ckBill.getTenantId())) { + queryWrapper.eq(CkBill::getTenantId, ckBill.getTenantId()); + } + } @@ -254,7 +230,7 @@ public class CkBillController { private void updateFile(CkBillCargo ckbBillCargo) { Long newId = System.currentTimeMillis() + new Random().nextInt(1000); - List file = ckbBillCargo.getFile(); + List file = ckbBillCargo.getFileUploadFiles(); if (null != file) { for (SystemAttachment cmAttach : file) { cmAttach.setFileId(String.valueOf(newId)); @@ -318,11 +294,83 @@ public class CkBillController { */ @RequestMapping(value = "/info/{id}", method = RequestMethod.GET) public CommonResult info(@PathVariable("id") Long id){ - CkBill ckBill = ckBillService.getById(id); + CkBill ckBill = ckBillService.getById(id); + + // 查询CkBillCargo列表 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(CkBillCargo::getBillId, id); + queryWrapper.orderByDesc(CkBillCargo::getCreateTime); + List ckBillCargos = ckBillCargoService.list(queryWrapper); + + // 遍历处理每个CkBillCargo + ckBillCargos.forEach(ckBillCargo -> { + // 查询对应的CkBillStock信息 + LambdaQueryWrapper stockQueryWrapper = new LambdaQueryWrapper<>(); + stockQueryWrapper.eq(CkBillStock::getBillCargoId, ckBillCargo.getId()); + CkBillStock ckBillStock = ckBillStockService.getOne(stockQueryWrapper); + + if (ckBillStock != null) { + // 设置从CkBillStock获取的属性 + ckBillCargo.setStockName(ckBillStock.getStockName()); + ckBillCargo.setStockCode(ckBillStock.getStockCode()); + ckBillCargo.setInStockId(ckBillStock.getStockId()); + ckBillCargo.setOutBillNumber(ckBillStock.getBillNumber()); + ckBillCargo.setCargoNum(ckBillStock.getCargoNum()); + ckBillCargo.setCargoWt(ckBillStock.getCargoWt()); + ckBillCargo.setCargoVol(ckBillStock.getCargoVol()); + ckBillCargo.setCargoValue(ckBillStock.getCargoValue()); + ckBillCargo.setShelfId(ckBillStock.getShelfId()); + ckBillCargo.setShelfName(ckBillStock.getShelfName()); + ckBillCargo.setLocationName(ckBillStock.getLocationName()); + ckBillCargo.setLocationId(ckBillStock.getLocationId()); + } + + // 处理出库类型的逻辑 + if (ckBillCargo.getInoutType().equals("2")) { + ckBillCargo.setOutStockId(ckBillCargo.getInStockId()); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + wrapper.eq(CkCargoStock::getCargoId, ckBillCargo.getCargoId()); + wrapper.eq(CkCargoStock::getCustId, ckBillCargo.getCustId()); + wrapper.eq(CkCargoStock::getStockId, ckBillCargo.getOutStockId()); + wrapper.eq(CkCargoStock::getBillNumber, ckBillCargo.getOutBillNumber()); + CkCargoStock ckCargoStock = ckCargoStockService.getOne(wrapper); + if (ckCargoStock != null) { + ckBillCargo.setNowStockWt(ckCargoStock.getCargoWt()); + ckBillCargo.setNowStockVol(ckCargoStock.getCargoVol()); + ckBillCargo.setNowStockNum(ckCargoStock.getCargoNum()); + ckBillCargo.setNowCargoValue(ckCargoStock.getCargoValue()); + } else { + ckBillCargo.setNowStockWt(new BigDecimal(0)); + ckBillCargo.setNowStockVol(new BigDecimal(0)); + ckBillCargo.setNowStockNum(new BigDecimal(0)); + ckBillCargo.setNowCargoValue(new BigDecimal(0)); + } + } + }); + + ckBill.setCkBillCargos(ckBillCargos); + setFile(ckBill); return CommonResult.success(ckBill); } + + private void setFile(CkBill ckBill) { + if (null != ckBill) { + List ckBillCargos = ckBill.getCkBillCargos(); + if (null != ckBillCargos && ckBillCargos.size() > 0) { + for (CkBillCargo ckBillCargo : ckBillCargos) { + String fileId = ckBillCargo.getFileId(); + if (null != fileId) { + List cmAttaches = systemAttachmentService.list(new LambdaQueryWrapper().eq(SystemAttachment::getFileId, fileId)); + ckBillCargo.setFileUploadFiles(cmAttaches); + ckBillCargo.setFile(cmAttaches); + } + } + } + } + } + /** * 新增数据 */ diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/CkCargoStockController.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/CkCargoStockController.java index 1e5e6c3..7ca73dc 100644 --- a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/CkCargoStockController.java +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/CkCargoStockController.java @@ -1,13 +1,23 @@ package com.zbkj.modules.autogencode.controller; +import java.math.BigDecimal; import java.util.Arrays; +import java.util.List; import java.util.Map; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zbkj.common.request.PageParamRequest; import com.zbkj.common.response.CommonResult; import com.zbkj.common.page.CommonPage; +import com.zbkj.modules.autogencode.entity.CkBill; +import com.zbkj.modules.autogencode.entity.CkBillCargo; +import com.zbkj.modules.autogencode.entity.CkBillStock; +import com.zbkj.modules.autogencode.service.CkBillCargoService; +import com.zbkj.modules.autogencode.service.CkBillService; +import com.zbkj.modules.autogencode.service.CkBillStockService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -33,8 +43,15 @@ public class CkCargoStockController { @Autowired private CkCargoStockService ckCargoStockService; + @Autowired + private CkBillService ckBillService; + + @Autowired + private CkBillCargoService ckBillCargoService; + @Autowired + private CkBillStockService ckBillStockService; /** * 条件设置 * 根据实体类字段自动生成查询条件 @@ -266,11 +283,40 @@ public class CkCargoStockController { // 应用搜索条件 condition(queryWrapper, request); - - CommonPage page = CommonPage.restPage(ckCargoStockService.pageList(queryWrapper, pageParamRequest)); + if (null != request.getIsShow() && request.getIsShow()) { + queryWrapper.gt(CkCargoStock::getCargoWt, 0); + } + if (null != request.getBeginDateOut()) { + queryWrapper.gt(CkCargoStock::getStockDate, request.getBeginDateOut()); + } + List cargoStocks = ckCargoStockService.pageList(queryWrapper, pageParamRequest); + List ckCargoStocks = outRecovery(cargoStocks, request); + CommonPage page = CommonPage.restPage(ckCargoStocks); return CommonResult.success(page); } + /** + * 查询仓库库存重量 + */ + @ApiOperation("查询仓库库存重量") + @GetMapping("/listByAll") + public CommonResult listByAll(CkCargoStock ckCargoStock) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); + condition(queryWrapper, ckCargoStock); + if (null != ckCargoStock.getIsShow() && ckCargoStock.getIsShow()) { + queryWrapper.gt(CkCargoStock::getCargoWt, 0); + } + if (null != ckCargoStock.getBeginDateOut()) { + queryWrapper.gt(CkCargoStock::getStockDate, ckCargoStock.getBeginDateOut()); + } + List list = ckCargoStockService.list(queryWrapper); + List ckCargoStocks = outRecovery(list, ckCargoStock); + BigDecimal totalWeight = ckCargoStocks.stream() + .map(CkCargoStock::getCargoWt) + .reduce(BigDecimal.ZERO, BigDecimal::add); + return CommonResult.success(totalWeight); + } + /** * 详情数据 @@ -315,4 +361,202 @@ public class CkCargoStockController { return CommonResult.failed(); } + + /** + * 查询仓库库存列表(分页) + * + * @return + */ + @ApiOperation("查询仓库库存列表") + @GetMapping("/newList") + public CommonResult> ckCargoStockList(CkCargoStock ckCargoStock, @Validated PageParamRequest pageParamRequest) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + + // 选择字段和聚合函数 + queryWrapper.select( + "cargo_id", + "cargo_name", + "cust_id", + "cust_name", + "cargo_spec", + "origin_country", + "hs_code", + "cargo_number", + "stock_date", + "sum(cargo_num) as cargo_num", + "sum(cargo_wt) as cargo_wt", + "sum(cargo_vol) as cargo_vol" + ); + + // 应用搜索条件 + applyCondition(queryWrapper, ckCargoStock); + + // 添加条件:货物件数、重量、体积至少有一个大于0 + queryWrapper.and(wrapper -> { + wrapper.gt("cargo_num", 0).or(). + gt("cargo_wt", 0).or(). + gt("cargo_vol", 0); + }); + + // 添加分组 + queryWrapper.groupBy( + "cargo_id", + "cargo_name", + "cust_id", + "cust_name", + "cargo_spec", + "origin_country", + "hs_code", + "cargo_number", + "stock_date" + ); + + // 分页查询 + Page page = new Page<>(pageParamRequest.getPage(), pageParamRequest.getLimit()); + Page resultPage = ckCargoStockService.page(page, queryWrapper); + + CommonPage commonPage = new CommonPage<>(); + commonPage.setPage((int) resultPage.getCurrent()); + commonPage.setLimit((int) resultPage.getSize()); + commonPage.setTotal(resultPage.getTotal()); + commonPage.setTotalPage((int) resultPage.getPages()); + commonPage.setList(resultPage.getRecords()); + + return CommonResult.success(commonPage); + } + + + /** + * 查询仓库库存列表 + */ + @ApiOperation("查询仓库库存列表") + @GetMapping("/listCkstock") + public CommonResult> listCkstock(CkCargoStock ckCargoStock) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); + queryWrapper.select(CkCargoStock::getId, CkCargoStock::getStockDate, CkCargoStock::getCargoNumber, + CkCargoStock::getItemNumber, CkCargoStock::getBookNumber, CkCargoStock::getExpiryDate, CkCargoStock::getBillNumber, + CkCargoStock::getVoyageId, CkCargoStock::getVoyageNo, CkCargoStock::getVesselId, CkCargoStock::getVesselName, + CkCargoStock::getCargoId, CkCargoStock::getHsCode, CkCargoStock::getCargoName, + CkCargoStock::getBillNo, CkCargoStock::getCargoSpec, CkCargoStock::getOriginCountry, CkCargoStock::getFirstUnit, + CkCargoStock::getUnitPrice, CkCargoStock::getCurrType, CkCargoStock::getCustId, CkCargoStock::getCustName, CkCargoStock::getOpType, + CkCargoStock::getTradType, CkCargoStock::getCargoNum, CkCargoStock::getCargoWt, CkCargoStock::getCargoVol, CkCargoStock::getStockId, + CkCargoStock::getStockCode, CkCargoStock::getStockName, CkCargoStock::getCargoValue, CkCargoStock::getCustomsNo, CkCargoStock::getListNumber, + CkCargoStock::getRemark, CkCargoStock::getCreateDept, CkCargoStock::getCreateBy, CkCargoStock::getCreateTime, CkCargoStock::getUpdateBy, + CkCargoStock::getUpdateTime, CkCargoStock::getDelFlag); + condition(queryWrapper, ckCargoStock); + if(ckCargoStock.getCustId()!=null){ + queryWrapper.and(qw -> { + qw.gt(CkCargoStock::getCargoNum, "0") + .or().gt(CkCargoStock::getCargoWt, "0") + .or().gt(CkCargoStock::getCargoValue, "0") + .or().gt(CkCargoStock::getCargoVol, "0"); + }); + } + List list = ckCargoStockService.list(queryWrapper); + + for (CkCargoStock stock : list) { + if (StrUtil.isNotBlank(stock.getBillNumber())) { + LambdaQueryWrapper stockQueryWrapper = new LambdaQueryWrapper<>(); + stockQueryWrapper.eq(CkBillStock::getBillNumber, stock.getBillNumber()); + stockQueryWrapper.eq(CkBillStock::getStockId, stock.getStockId()); + stockQueryWrapper.last("LIMIT 1"); + CkBillStock ckBillStock = ckBillStockService.getOne(stockQueryWrapper); + if (ckBillStock != null) { + stock.setShelfName(ckBillStock.getShelfName()); + stock.setLocationName(ckBillStock.getLocationName()); + } + } + } + + return CommonResult.success(list); + } + + public List outRecovery(List list,CkCargoStock ckCargoStock) { + if (null != ckCargoStock.getEndDateOut()) { + for (CkCargoStock ckCargoStockVo : list) { + LambdaQueryWrapper queryWrapperBill = new LambdaQueryWrapper(); + queryWrapperBill.ne(CkBill::getBillType, "1"); + queryWrapperBill.inSql(CkBill::getId, "select a.bill_id from ck_bill_cargo a, ck_bill_stock b where a.id = b.bill_cargo_id and b.bill_number like '%"+ + ckCargoStockVo.getBillNumber() +"%'") + .eq(CkBill::getBillStatus,"1"); + List listBill = ckBillService.list(queryWrapperBill); + BigDecimal totalCargoWt = BigDecimal.ZERO; + BigDecimal totalCargoValue = BigDecimal.ZERO; + for (CkBill ckBill : listBill) { + LambdaQueryWrapper queryWrapperBillCargo = new LambdaQueryWrapper(); + queryWrapperBillCargo.eq(CkBillCargo::getInoutType, "2") + .eq(CkBillCargo::getBillNumber, ckBill.getBillNumber()) + .gt(CkBillCargo::getBillDate, ckCargoStock.getEndDateOut()); + if ("4".equals(ckBill.getBillType())) { + queryWrapperBillCargo.eq(CkBillCargo::getListNumber,ckCargoStockVo.getListNumber()); + } + List listBillCargo = ckBillCargoService.list(queryWrapperBillCargo); + for (CkBillCargo ckBillCargo : listBillCargo) { + System.out.println( ckBillCargo.getBillNumber() + "+++" + ckBillCargo.getCargoWt()); + totalCargoWt = totalCargoWt.add(ckBillCargo.getCargoWt()); + totalCargoValue = totalCargoValue.add(ckBillCargo.getCargoValue()); + } + } + ckCargoStockVo.setCargoWt(ckCargoStockVo.getCargoWt().add(totalCargoWt)); + ckCargoStockVo.setCargoValue(ckCargoStockVo.getCargoValue().add(totalCargoValue)); + } + } + return list; + } + + /** + * 应用搜索条件到QueryWrapper + */ + private void applyCondition(QueryWrapper queryWrapper, CkCargoStock request) { + if (request == null) { + return; + } + + // 货物ID + if (request.getCargoId() != null) { + queryWrapper.eq("cargo_id", request.getCargoId()); + } + + // 货物名称 + if (StrUtil.isNotBlank(request.getCargoName())) { + queryWrapper.like("cargo_name", request.getCargoName()); + } + + // 货主ID + if (request.getCustId() != null) { + queryWrapper.eq("cust_id", request.getCustId()); + } + + // 货主名称 + if (StrUtil.isNotBlank(request.getCustName())) { + queryWrapper.like("cust_name", request.getCustName()); + } + + // 规格类型品质 + if (StrUtil.isNotBlank(request.getCargoSpec())) { + queryWrapper.eq("cargo_spec", request.getCargoSpec()); + } + + // 原产国 + if (StrUtil.isNotBlank(request.getOriginCountry())) { + queryWrapper.eq("origin_country", request.getOriginCountry()); + } + + // HS编号 + if (StrUtil.isNotBlank(request.getHsCode())) { + queryWrapper.eq("hs_code", request.getHsCode()); + } + + // 货物自然序号 + if (StrUtil.isNotBlank(request.getCargoNumber())) { + queryWrapper.eq("cargo_number", request.getCargoNumber()); + } + + // 入库日期 + if (request.getStockDate() != null) { + queryWrapper.eq("stock_date", request.getStockDate()); + } + } + + } diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/CkBill.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/CkBill.java index bb23fb6..2b1f994 100644 --- a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/CkBill.java +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/CkBill.java @@ -3,6 +3,7 @@ package com.zbkj.modules.autogencode.entity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; @@ -10,6 +11,7 @@ import java.util.Date; import java.util.List; import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; @Data @@ -53,6 +55,16 @@ public class CkBill implements Serializable { */ @ApiModelProperty(value = "单据日期") private Date billDate; + + @TableField(exist = false) + @JsonFormat(pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern = "yyyy-MM-dd") + private Date beginDate; + + @TableField(exist = false) + @JsonFormat(pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern = "yyyy-MM-dd") + private Date endDate; /** * 放行日期 */ diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/CkBillCargo.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/CkBillCargo.java index a5df8d5..ca64453 100644 --- a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/CkBillCargo.java +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/CkBillCargo.java @@ -6,9 +6,10 @@ import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import com.zbkj.common.model.system.SystemAttachment; import io.swagger.annotations.ApiModelProperty; +import org.springframework.format.annotation.DateTimeFormat; - import java.math.BigDecimal; - import java.io.Serializable; +import java.math.BigDecimal; +import java.io.Serializable; import java.util.Date; import java.util.List; @@ -255,7 +256,8 @@ public class CkBillCargo implements Serializable { @TableField(exist = false) private List file; - + @TableField(exist = false) + private List fileUploadFiles; /** * 入库批次号 */ @@ -328,18 +330,22 @@ public class CkBillCargo implements Serializable { @TableField(exist = false) @JsonFormat(pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern = "yyyy-MM-dd") private Date beginDate; @TableField(exist = false) @JsonFormat(pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern = "yyyy-MM-dd") private Date endDate; @TableField(exist = false) @JsonFormat(pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern = "yyyy-MM-dd") private Date beginDateTwo; @TableField(exist = false) @JsonFormat(pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern = "yyyy-MM-dd") private Date endDateTwo; @TableField(exist = false) diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/CkCargoStock.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/CkCargoStock.java index e4e2ae5..ce0b7dd 100644 --- a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/CkCargoStock.java +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/CkCargoStock.java @@ -1,7 +1,9 @@ package com.zbkj.modules.autogencode.entity; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; @@ -181,6 +183,18 @@ public class CkCargoStock implements Serializable { */ @ApiModelProperty(value = "库场名称") private String stockName; + /** + * 货架名称 + */ + @ApiModelProperty(value = "货架名称") + @TableField(exist = false) + private String shelfName; + /** + * 货位名称 + */ + @ApiModelProperty(value = "货位名称") + @TableField(exist = false) + private String locationName; /** * 备注 */ @@ -222,4 +236,41 @@ public class CkCargoStock implements Serializable { @ApiModelProperty(value = "") private String tenantId; + + + @TableField(exist = false) + @JsonFormat(pattern = "yyyy-MM-dd") + private Date beginDate; + + @TableField(exist = false) + @JsonFormat(pattern = "yyyy-MM-dd") + private Date endDate; + + @TableField(exist = false) + @JsonFormat(pattern = "yyyy-MM-dd") + private Date beginDateTwo; + + @TableField(exist = false) + @JsonFormat(pattern = "yyyy-MM-dd") + private Date endDateTwo; + + @TableField(exist = false) + @JsonFormat(pattern = "yyyy-MM-dd") + private Date beginDateOut; + + @TableField(exist = false) + @JsonFormat(pattern = "yyyy-MM-dd") + private Date endDateOut; + + @TableField(exist = false) + private String isExpire; + + @TableField(exist = false) + private String gdsSeqno; + + /** 是否显示为0的库存 */ + @TableField(exist = false) + private Boolean isShow; + + } diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/service/CkBillService.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/service/CkBillService.java index 823f83a..20aef79 100644 --- a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/service/CkBillService.java +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/service/CkBillService.java @@ -37,5 +37,7 @@ public interface CkBillService extends IService { */ public CommonResult putCargo(CkBill ckBill); + CommonResult recallPutBill(Long id); + } diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/service/impl/CkBillServiceImpl.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/service/impl/CkBillServiceImpl.java index 1482912..f266226 100644 --- a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/service/impl/CkBillServiceImpl.java +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/service/impl/CkBillServiceImpl.java @@ -12,6 +12,7 @@ import com.zbkj.modules.autogencode.service.*; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateUtils; import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.zbkj.modules.autogencode.dao.CkBillDao; @@ -61,6 +62,9 @@ public class CkBillServiceImpl extends ServiceImpl implements @Resource private CmStorageLocationService cmStorageLocationService; + + @Autowired + private CmCustProductService cmCustProductService; /** * 带分页参数的列表查询实现 */ @@ -191,9 +195,11 @@ public class CkBillServiceImpl extends ServiceImpl implements BeanUtils.copyProperties(ckBillCargo,inCargoStock,"id"); inCargoStock.setStockDate(ckBillCargo.getBillDate()); CmWarehouse cmWarehouse = cmWarehouseService.getById(ckBillStock.getStockId()); - inCargoStock.setStockId(cmWarehouse.getId()); - inCargoStock.setStockCode(cmWarehouse.getStockCode()); - inCargoStock.setStockName(cmWarehouse.getStockName()); + if(cmWarehouse != null){ + inCargoStock.setStockId(cmWarehouse.getId()); + inCargoStock.setStockCode(cmWarehouse.getStockCode()); + inCargoStock.setStockName(cmWarehouse.getStockName()); + } inCargoStock.setCargoNum(ckBillStock.getCargoNum()); inCargoStock.setCargoWt(ckBillStock.getCargoWt()); inCargoStock.setCargoVol(ckBillStock.getCargoVol()); @@ -241,6 +247,17 @@ public class CkBillServiceImpl extends ServiceImpl implements return CommonResult.success(); } + /** + * 货物入库(撤回) + * @param id + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public CommonResult recallPutBill(Long id) { + return warehouseWork(this.getById(id),true); + } + /** * 货物入库 * @param ckBill @@ -262,6 +279,11 @@ public class CkBillServiceImpl extends ServiceImpl implements } Map billStockMap = new HashMap<>(); ckBillCargos.forEach(ckBillCargo->{ + CmCustProduct custProduct = cmCustProductService.getById(ckBillCargo.getCargoId()); + if (null != custProduct) { + ckBillCargo.setCargoName(custProduct.getGoodsName()); + ckBillCargo.setHsCode(custProduct.getGoodsCode()); + } ckBillCargo.setBillStatus("0"); //创建单据明细 ckBillCargo.setBillDate(ckBill.getBillDate()); @@ -295,9 +317,11 @@ public class CkBillServiceImpl extends ServiceImpl implements } ckBillCargoService.saveOrUpdate(ckBillCargo); ckBillStock.setInoutType("1"); - ckBillStock.setStockId(cmWarehouse.getId()); - ckBillStock.setStockName(cmWarehouse.getStockName()); - ckBillStock.setStockCode(cmWarehouse.getStockCode()); + if(cmWarehouse != null){ + ckBillStock.setStockId(cmWarehouse.getId()); + ckBillStock.setStockName(cmWarehouse.getStockName()); + ckBillStock.setStockCode(cmWarehouse.getStockCode()); + } // 设置货架信息 if(cmShelf != null){ @@ -354,8 +378,10 @@ public class CkBillServiceImpl extends ServiceImpl implements BeanUtils.copyProperties(ckBillCargo,ckStockChange,"id"); ckStockChange.setChangeType(ckBillCargo.getInoutType()); CmWarehouse cmWarehouse = cmWarehouseService.getById(ckBillStock.getStockId()); - ckStockChange.setStockId(cmWarehouse.getId()); - ckStockChange.setStockName(cmWarehouse.getStockName()); + if(cmWarehouse != null){ + ckStockChange.setStockId(cmWarehouse.getId()); + ckStockChange.setStockName(cmWarehouse.getStockName()); + } ckStockChange.setBeforeNum(countStock.getCargoNum()); ckStockChange.setBeforeWt(countStock.getCargoWt()); ckStockChange.setBeforeVol(countStock.getCargoVol());