From 1ab21365e8b41fb3c380284c33546b84015692b1 Mon Sep 17 00:00:00 2001 From: zxf <1532322479@qq.com> Date: Thu, 26 Mar 2026 12:34:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E3=80=81=E8=AE=A2=E5=8D=95=E7=9B=B8=E5=85=B3=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/api/pmdailymenu.js | 58 ++ .../ckwarehouse/components/BillEdit/index.vue | 25 +- .../views/pm/canteen/demand/DispatchList.vue | 11 +- .../demand/pmcanteendemand-add-and-update.vue | 30 +- ...pmcanteenpurchasedetail-add-and-update.vue | 45 +- .../purchase/order/OrderDetailList.vue | 248 +++++++ .../views/pm/canteen/purchase/order/index.vue | 31 +- .../pmcanteenpurchaseorder-add-and-update.vue | 371 +++++++++- .../pm/canteen/purchase/plan/DispatchList.vue | 131 +++- .../views/pm/canteen/purchase/plan/index.vue | 3 +- .../pmcanteenpurchaseplan-add-and-update.vue | 674 +++++++++++++++--- .../src/views/pm/daily/menu/DispatchList.vue | 122 +++- admin/src/views/pm/daily/menu/index.vue | 44 +- .../daily/menu/pmdailymenu-add-and-update.vue | 417 +++++++++-- .../controller/PmCanteenDemandController.java | 26 +- .../PmCanteenPurchasePlanController.java | 181 +++-- .../controller/PmDailyMenuController.java | 177 ++++- .../controller/PubNoticeController.java | 117 ++- .../autogencode/entity/PmCanteenDemand.java | 7 + .../entity/PmCanteenPurchasePlan.java | 3 + .../autogencode/entity/PmDailyMenu.java | 3 + .../autogencode/entity/PmDailyMenuDtl.java | 3 + .../modules/autogencode/entity/PubNotice.java | 7 + .../PmCanteenPurchaseOrderServiceImpl.java | 114 ++- 24 files changed, 2526 insertions(+), 322 deletions(-) create mode 100644 admin/src/views/pm/canteen/purchase/order/OrderDetailList.vue diff --git a/admin/src/api/pmdailymenu.js b/admin/src/api/pmdailymenu.js index 459d9ef..21d9b3f 100644 --- a/admin/src/api/pmdailymenu.js +++ b/admin/src/api/pmdailymenu.js @@ -36,6 +36,18 @@ export function pmdailymenuDetailApi(id) { }) } +/** + * 获取当天菜单详情(用于修改页面) + * @param params + */ +export function pmdailymenuDayDetailApi(params) { + return request({ + url: `autogencode/pmdailymenu/listByAll`, + method: 'GET', + params + }) +} + /** * pmdailymenu批量删除 * @param ids @@ -60,6 +72,52 @@ export function pmdailymenuBatchCreateApi(menus) { }) } +/** + * pmdailymenu批量更新 + * @param menus + */ +export function pmdailymenuBatchUpdateApi(menus) { + return request({ + url: `autogencode/pmdailymenu/batchUpdate`, + method: 'POST', + data: menus + }) +} + +/** + * pmdailymenu发布 + * @param id + */ +export function pmdailymenuPublishApi(id) { + return request({ + url: `autogencode/pmdailymenu/publish/${id}`, + method: 'POST' + }) +} + +/** + * pmdailymenu撤销发布 + * @param id + */ +export function pmdailymenuCancelPublishApi(id) { + return request({ + url: `autogencode/pmdailymenu/cancelPublish/${id}`, + method: 'POST' + }) +} + +/** + * pmdailymenu复制 + * @param params + */ +export function pmdailymenuCopyApi(params) { + return request({ + url: `autogencode/pmdailymenu/copy`, + method: 'POST', + data: params + }) +} + /** * pmdailymenu列表 diff --git a/admin/src/views/ck/ckwarehouse/components/BillEdit/index.vue b/admin/src/views/ck/ckwarehouse/components/BillEdit/index.vue index 738f737..6505c8b 100644 --- a/admin/src/views/ck/ckwarehouse/components/BillEdit/index.vue +++ b/admin/src/views/ck/ckwarehouse/components/BillEdit/index.vue @@ -202,28 +202,31 @@ header-align="center" align="center" label="单位" - width="80"> + > + + > + > + > @@ -239,7 +242,7 @@ @@ -286,7 +289,7 @@ export default { props: { }, - dicts: ['bm_measuring_unit', 'sys_origin_country', 'sys_curr_type', 'order_status'], + dicts: ['bm_measuring_unit', 'sys_measurement_unit', 'sys_origin_country', 'sys_curr_type', 'pm_order_status'], computed: { // 表格内容只读 tableReadonly() { @@ -901,7 +904,12 @@ export default { // 获取订单列表 getOrderList() { this.orderLoading = true - pmcanteenpurchaseorderListApi(this.orderSearchForm).then(res => { + const params = { + ...this.orderSearchForm, + status: 1 // 强制状态为1 + } + + pmcanteenpurchaseorderListApi(params).then(res => { this.orderList = res.list this.orderTotal = res.total this.orderLoading = false @@ -915,7 +923,8 @@ export default { page: 1, limit: 10, orderNo: '', - supplierName: '' + supplierName: '', + status: 1 // 重置时也默认状态1 } this.getOrderList() }, diff --git a/admin/src/views/pm/canteen/demand/DispatchList.vue b/admin/src/views/pm/canteen/demand/DispatchList.vue index aa5bad9..9aadeb6 100644 --- a/admin/src/views/pm/canteen/demand/DispatchList.vue +++ b/admin/src/views/pm/canteen/demand/DispatchList.vue @@ -9,7 +9,11 @@ - + + + @@ -34,7 +38,12 @@ diff --git a/admin/src/views/pm/canteen/purchase/detail/pmcanteenpurchasedetail-add-and-update.vue b/admin/src/views/pm/canteen/purchase/detail/pmcanteenpurchasedetail-add-and-update.vue index 4040a94..3192090 100644 --- a/admin/src/views/pm/canteen/purchase/detail/pmcanteenpurchasedetail-add-and-update.vue +++ b/admin/src/views/pm/canteen/purchase/detail/pmcanteenpurchasedetail-add-and-update.vue @@ -56,19 +56,38 @@ - + - + - + @@ -108,15 +127,21 @@ import * as api from '@/api/pmcanteenpurchasedetail.js' import * as cmcustproductApi from '@/api/cmcustproduct.js' export default { + props: { + planStatus: { + type: String, + default: '1' // 默认草稿状态 + } + }, data () { return { visible: false, goodsList: [], dataForm: { id: 0, - planId: '' , - goodsId: '' , - custId: '' , + planId: 0 , + goodsId: 0 , + custId: 0 , custName: '' , goodsName: '' , goodsCode: '' , @@ -201,13 +226,21 @@ if (this.dataForm.id) { api.pmcanteenpurchasedetailDetailApi(id).then(function(res) { this.dataForm = res; + this.calculatePlanAmount(); }.bind(this)) } else if (planId) { // 新增记录时,自动设置 planId this.dataForm.planId = planId; + this.calculatePlanAmount(); } }.bind(this)) }, + // 计算计划金额 + calculatePlanAmount () { + const planQuantity = parseFloat(this.dataForm.planQuantity) || 0 + const planPrice = parseFloat(this.dataForm.planPrice) || 0 + this.dataForm.planAmount = parseFloat((planQuantity * planPrice).toFixed(2)) + }, // 表单数据提交 dataSubmit () { this.$refs['dataForm'].validate((valid) => { diff --git a/admin/src/views/pm/canteen/purchase/order/OrderDetailList.vue b/admin/src/views/pm/canteen/purchase/order/OrderDetailList.vue new file mode 100644 index 0000000..ada843e --- /dev/null +++ b/admin/src/views/pm/canteen/purchase/order/OrderDetailList.vue @@ -0,0 +1,248 @@ + + + + + diff --git a/admin/src/views/pm/canteen/purchase/order/index.vue b/admin/src/views/pm/canteen/purchase/order/index.vue index a84f221..a3880c5 100644 --- a/admin/src/views/pm/canteen/purchase/order/index.vue +++ b/admin/src/views/pm/canteen/purchase/order/index.vue @@ -37,7 +37,19 @@ border v-loading="dataListLoading" @selection-change="selectionChangeHandle" + @expand-change="handleExpandChange" + :row-key="row => row.id" style="width: 100%;"> + + + import AddOrUpdate from './pmcanteenpurchaseorder-add-and-update' + import OrderDetailList from './OrderDetailList' import * as api from '@/api/pmcanteenpurchaseorder.js' export default { dicts: ['pm_order_status'], @@ -143,7 +156,8 @@ } }, components: { - AddOrUpdate + AddOrUpdate, + OrderDetailList }, activated () { this.getDataList() @@ -293,6 +307,21 @@ }) }) }, + // 处理展开行事件 + handleExpandChange(row, expandedRows) { + // 展开行事件由OrderDetailList组件内部处理 + }, + // 新增订单明细 + addOrderDetail(orderId) { + // 打开添加订单页面,传入订单ID + this.addOrUpdateHandle(orderId) + }, + // 编辑订单明细 + editOrderDetail(orderId, detailId) { + // 打开添加订单页面,传入订单ID和明细ID + console.log('编辑明细:', orderId, detailId) + + }, } } diff --git a/admin/src/views/pm/canteen/purchase/order/pmcanteenpurchaseorder-add-and-update.vue b/admin/src/views/pm/canteen/purchase/order/pmcanteenpurchaseorder-add-and-update.vue index 47f48f5..928153e 100644 --- a/admin/src/views/pm/canteen/purchase/order/pmcanteenpurchaseorder-add-and-update.vue +++ b/admin/src/views/pm/canteen/purchase/order/pmcanteenpurchaseorder-add-and-update.vue @@ -4,6 +4,7 @@ @@ -37,6 +38,7 @@ value-format="yyyy-MM-dd" placeholder="选择日期" style="width: 100%" + :disabled="isOrderConfirmed" /> @@ -52,12 +54,29 @@ + + + + + + + + + + + - 选择计划明细 + 选择计划明细 + 选择商品 @@ -102,31 +121,69 @@ header-align="center" align="center" label="单位"> + + + + @@ -142,8 +199,8 @@ 取消 - 保存 - 订单确认 + 保存 + 订单确认 @@ -222,6 +279,9 @@ header-align="center" align="center" label="单位"> + + + label="关联状态"> + + + + + + + + 取消 + 确认关联 + + + + + + + + + + + + + + + 查询 + 重置 + + + + + + + - + label="商品名称"> - + label="商品编码"> + label="规格"> + + + + + + - 取消 - 确认关联 + 取消 + 确认选择 + + + + + + + 确认添加 + @@ -299,7 +451,10 @@ import * as api from '@/api/pmcanteenpurchaseorder.js' import * as detailApi from '@/api/pmcanteenpurchasedetail.js' import { cmcustListByAll as listCust } from "@/api/cmcust" + import * as cmcustproductApi from '@/api/cmcustproduct.js' + import DictTag from '@/components/DictTag' export default { + dicts: ['sys_measurement_unit', 'pm_order_status'], data () { return { visible: false, @@ -311,7 +466,7 @@ orderDate: '' , deliveryDate: '' , totalAmount: 0 , - status: 0 , + status: '0' , remark: '' , }, dataRule: { @@ -344,7 +499,24 @@ pageIndex: 1, pageSize: 10, totalPage: 0, - selectedPlanDetails: [] // 选中的计划明细 + selectedPlanDetails: [], // 选中的计划明细 + // 选择商品弹窗相关 + selectGoodsVisible: false, // 选择商品弹窗 + goodsList: [], // 商品列表 + tempSelectedGoods: [], // 弹窗中临时选中的商品 + goodsSearchForm: { + goodsName: '', + spec: '' + }, + goodsPage: { + page: 1, + limit: 10, + total: 0 + }, + goodsLoading: false, + // 批量添加商品相关 + batchAddVisible: false, + selectedGoodsForBatch: [] } }, watch: { @@ -362,8 +534,23 @@ }, mounted() { this.getSuppliers() + this.loadGoodsList() + }, + computed: { + // 判断订单是否已确认 + isOrderConfirmed() { + return this.dataForm.status === '1' + } }, methods: { + // 加载商品列表(用于批量添加商品) + loadGoodsList() { + cmcustproductApi.cmcustproductListApi({ page: 1, limit: 9999 }).then(res => { + this.goodsList = res.list || [] + }).catch(e => { + console.error('获取商品列表失败', e) + }) + }, getSuppliers() { // 获取供应商列表 listCust({custBelong:1}).then(response => { @@ -372,6 +559,122 @@ console.error('获取供应商列表失败', e); }); }, + // 打开选择商品弹窗 + openSelectGoodsModal() { + this.selectGoodsVisible = true + this.getGoodsList() + }, + // 获取商品列表 + getGoodsList() { + this.goodsLoading = true + cmcustproductApi.cmcustproductListApi({ + page: this.goodsPage.page, + limit: this.goodsPage.limit, + goodsName: this.goodsSearchForm.goodsName, + spec: this.goodsSearchForm.spec + }).then(res => { + this.goodsList = res.list || [] + this.goodsPage.total = res.total || 0 + this.goodsLoading = false + }).catch(e => { + console.error('获取商品列表失败', e) + this.goodsLoading = false + }) + }, + // 重置商品搜索表单 + resetGoodsSearchForm() { + this.goodsSearchForm = { + goodsName: '', + spec: '' + } + this.getGoodsList() + }, + // 处理商品选择 + handleGoodsSelectionChange(selection) { + this.tempSelectedGoods = selection + }, + // 处理商品分页大小变化 + handleGoodsSizeChange(size) { + this.goodsPage.limit = size + this.getGoodsList() + }, + // 处理商品分页当前页变化 + handleGoodsCurrentChange(current) { + this.goodsPage.page = current + this.getGoodsList() + }, + // 确认选择商品 + confirmSelectGoods() { + if (this.tempSelectedGoods.length === 0) { + this.$message.warning('请选择商品') + return + } + + // 将选中的商品添加到计划明细中 + this.tempSelectedGoods.forEach(goods => { + const newDetail = { + id: 0, + orderId: this.dataForm.id, + goodsId: goods.id, + goodsName: goods.goodsName, + goodsCode: goods.goodsCode, + spec: goods.spec, + unit: goods.unit, + supplierName: goods.custName || '', + orderQuantity: 1, + orderPrice: goods.costPrice || 0, + orderAmount: goods.costPrice || 0 + } + this.planDetails.push(newDetail) + }) + + // 计算订单总金额 + this.calculateTotalAmount() + + // 关闭弹窗 + this.selectGoodsVisible = false + this.tempSelectedGoods = [] + }, + // 打开批量添加商品弹窗 + openBatchAddModal() { + this.selectedGoodsForBatch = [] + this.batchAddVisible = true + this.getGoodsList() + }, + // 确认批量添加商品 + confirmBatchAdd() { + if (this.selectedGoodsForBatch.length === 0) { + this.$message.warning('请选择商品') + return + } + + this.selectedGoodsForBatch.forEach(id => { + const selectedGoods = this.goodsList.find(goods => goods.id === id) + if (selectedGoods) { + const existingDetail = this.planDetails.find(detail => detail.goodsName === selectedGoods.goodsName && detail.spec === selectedGoods.spec) + if (!existingDetail) { + this.planDetails.push({ + id: 0, + orderId: this.dataForm.id, + goodsId: selectedGoods.id, + goodsName: selectedGoods.goodsName, + goodsCode: selectedGoods.goodsCode, + spec: selectedGoods.spec, + unit: selectedGoods.unit, + supplierName: selectedGoods.custName || '', + orderQuantity: 1, + orderPrice: selectedGoods.costPrice || 0, + orderAmount: selectedGoods.costPrice || 0 + }) + } + } + }) + + // 计算订单总金额 + this.calculateTotalAmount() + + this.batchAddVisible = false + }, init (id) { // 初始化表单验证规则 this.dataForm.id = id || 0 this.visible = true @@ -409,9 +712,16 @@ }, calculateTotalAmount() { this.dataForm.totalAmount = this.planDetails.reduce((total, item) => { - return total + item.orderAmount + return total + (parseFloat(item.orderAmount) || 0) }, 0) }, + // 更新订单金额 + updateOrderAmount(row) { + const orderQuantity = parseFloat(row.orderQuantity) || 0 + const orderPrice = parseFloat(row.orderPrice) || 0 + row.orderAmount = parseFloat((orderQuantity * orderPrice).toFixed(2)) + this.calculateTotalAmount() + }, // 检查计划明细是否已经被关联 isPlanDetailAssociated(detailId) { return this.planDetails.some(detail => detail.id === detailId) @@ -496,9 +806,9 @@ const exists = this.planDetails.some(detail => detail.id === item.id) if (!exists) { // 计算订单金额 - const orderQuantity = parseFloat(item.orderQuantity) || 0 - const orderPrice = parseFloat(item.orderPrice) || parseFloat(item.planPrice) || 0 - const orderAmount = parseFloat(item.orderAmount) || (orderQuantity * orderPrice) + const orderQuantity = parseFloat(item.planQuantity) || 0 + const orderPrice = parseFloat(item.orderPrice) || parseFloat(item.planPrice) || 0 + const orderAmount = parseFloat(item.orderAmount) || (orderQuantity * orderPrice) const newDetail = { id: item.id, @@ -506,6 +816,7 @@ planNo: item.planNo, supplierId: item.custId, supplierName: item.custName, + goodsId: item.goodsId, goodsName: item.goodsName, spec: item.spec, unit: item.unit, diff --git a/admin/src/views/pm/canteen/purchase/plan/DispatchList.vue b/admin/src/views/pm/canteen/purchase/plan/DispatchList.vue index a1e6071..2b8ea34 100644 --- a/admin/src/views/pm/canteen/purchase/plan/DispatchList.vue +++ b/admin/src/views/pm/canteen/purchase/plan/DispatchList.vue @@ -14,18 +14,68 @@ - - - - + + + + + + + + + + + + - + + + @@ -43,6 +93,7 @@ @@ -51,9 +102,12 @@ diff --git a/admin/src/views/pm/daily/menu/pmdailymenu-add-and-update.vue b/admin/src/views/pm/daily/menu/pmdailymenu-add-and-update.vue index af8002e..606eac7 100644 --- a/admin/src/views/pm/daily/menu/pmdailymenu-add-and-update.vue +++ b/admin/src/views/pm/daily/menu/pmdailymenu-add-and-update.vue @@ -1,77 +1,181 @@ + + diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmCanteenDemandController.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmCanteenDemandController.java index c423318..aa00141 100644 --- a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmCanteenDemandController.java +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmCanteenDemandController.java @@ -72,6 +72,23 @@ public class PmCanteenDemandController { if (request.getDemandUser() != null) { queryWrapper.eq(PmCanteenDemand::getDemandUser, request.getDemandUser()); } + + // 申请人姓名搜索(虚拟字段) + if (StrUtil.isNotBlank(request.getUserNameSearch())) { + // 使用INSQL的方式进行模糊查询 + List users = ebUserService.list(new LambdaQueryWrapper() + .like(User::getRealName, request.getUserNameSearch())); + if (!users.isEmpty()) { + List userIds = users.stream() + .map(User::getUid) + .map(Long::valueOf) + .collect(java.util.stream.Collectors.toList()); + queryWrapper.in(PmCanteenDemand::getDemandUser, userIds); + } else { + // 如果没有匹配的用户,添加一个永远为false的条件 + queryWrapper.eq(PmCanteenDemand::getId, -1); + } + } // 申请人类型 if (StrUtil.isNotBlank(request.getUserType())) { @@ -157,7 +174,7 @@ public class PmCanteenDemandController { : ebUserService.listByIds(userIds).stream() .collect(java.util.stream.Collectors.toMap(User::getUid, User::getRealName)); - // 在pmCanteenDemands中进行翻译,设置userName虚拟字段 + // 在pmCanteenDemands中进行翻译,设置userName虚拟字段并获取需求明细 page.getList().forEach(demand -> { if (demand.getDemandUser() != null) { String userName = userMap.get(demand.getDemandUser().intValue()); @@ -165,6 +182,13 @@ public class PmCanteenDemandController { demand.setUserName(userName); } } + + // 获取对应的需求明细 + LambdaQueryWrapper detailQueryWrapper = new LambdaQueryWrapper<>(); + detailQueryWrapper.eq(PmCanteenDemandDetail::getDemandId, demand.getId()); + detailQueryWrapper.eq(PmCanteenDemandDetail::getDelFlag, "0"); // 只查询未删除的明细 + List details = pmCanteenDemandDetailService.list(detailQueryWrapper); + demand.setPmCanteenDemandDetails(details); }); return CommonResult.success(page); diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmCanteenPurchasePlanController.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmCanteenPurchasePlanController.java index c46e1b3..5c8dac3 100644 --- a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmCanteenPurchasePlanController.java +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmCanteenPurchasePlanController.java @@ -1,5 +1,6 @@ package com.zbkj.modules.autogencode.controller; +import java.math.BigDecimal; import java.util.Arrays; import java.util.ArrayList; import java.util.Date; @@ -275,8 +276,9 @@ public class PmCanteenPurchasePlanController { public CommonResult info(@PathVariable("id") Long id){ PmCanteenPurchasePlan pmCanteenPurchasePlan = pmCanteenPurchasePlanService.getById(id); - // 查询计划对应的需求 + // 查询计划对应的需求和明细 if (pmCanteenPurchasePlan != null) { + // 查询需求 LambdaQueryWrapper demandPurchaseQueryWrapper = new LambdaQueryWrapper<>(); demandPurchaseQueryWrapper.eq(PmCanteenDemandPurchase::getPurchaseId, id); List demandPurchases = pmCanteenDemandPurchaseService.list(demandPurchaseQueryWrapper); @@ -289,6 +291,65 @@ public class PmCanteenPurchasePlanController { // 设置需求ID列表 pmCanteenPurchasePlan.setDemandIds(demandIds); + + // 查询采购明细 + LambdaQueryWrapper detailQueryWrapper = new LambdaQueryWrapper<>(); + detailQueryWrapper.eq(PmCanteenPurchaseDetail::getPlanId, id); + List pmCanteenPurchaseDetails = pmCanteenPurchaseDetailService.list(detailQueryWrapper); + + // 设置采购明细列表 + pmCanteenPurchasePlan.setPmCanteenPurchaseDetails(pmCanteenPurchaseDetails); + + // 翻译字段 + // 收集所有需要查询的部门ID + List deptIds = new ArrayList<>(); + // 收集所有需要查询的用户ID + List userIds = new ArrayList<>(); + + if (pmCanteenPurchasePlan.getApplyDept() != null) { + deptIds.add(pmCanteenPurchasePlan.getApplyDept()); + } + if (pmCanteenPurchasePlan.getApplyUser() != null) { + userIds.add(pmCanteenPurchasePlan.getApplyUser()); + } + if (pmCanteenPurchasePlan.getAuditUser() != null) { + userIds.add(pmCanteenPurchasePlan.getAuditUser()); + } + + // 去重 + deptIds = deptIds.stream().distinct().collect(Collectors.toList()); + userIds = userIds.stream().distinct().collect(Collectors.toList()); + + // 批量查询部门信息 + Map deptMap = new HashMap<>(); + if (!deptIds.isEmpty()) { + List depts = sysDeptService.listByIds(deptIds); + for (SysDept dept : depts) { + deptMap.put(dept.getDeptId(), dept.getDeptName()); + } + } + + // 批量查询用户信息 + Map userMap = new HashMap<>(); + if (!userIds.isEmpty()) { + List admins = systemAdminService.listByIds(userIds); + for (SystemAdmin admin : admins) { + userMap.put(Long.valueOf(admin.getId()), admin.getRealName()); + } + } + + // 翻译字段 + // 翻译部门 + if (pmCanteenPurchasePlan.getApplyDept() != null) { + pmCanteenPurchasePlan.setApplyDeptName(deptMap.get(pmCanteenPurchasePlan.getApplyDept())); + } + // 翻译用户 + if (pmCanteenPurchasePlan.getApplyUser() != null) { + pmCanteenPurchasePlan.setApplyUserName(userMap.get(pmCanteenPurchasePlan.getApplyUser())); + } + if (pmCanteenPurchasePlan.getAuditUser() != null) { + pmCanteenPurchasePlan.setAuditUserName(userMap.get(pmCanteenPurchasePlan.getAuditUser())); + } } return CommonResult.success(pmCanteenPurchasePlan); @@ -301,6 +362,7 @@ public class PmCanteenPurchasePlanController { public CommonResult save(@RequestBody PmCanteenPurchasePlan pmCanteenPurchasePlan){ List demandIds = pmCanteenPurchasePlan.getDemandIds(); + List pmCanteenPurchaseDetails = pmCanteenPurchasePlan.getPmCanteenPurchaseDetails(); // 保存采购计划 if (!pmCanteenPurchasePlanService.save(pmCanteenPurchasePlan)) { @@ -310,8 +372,20 @@ public class PmCanteenPurchasePlanController { // 获取保存后的计划ID Long planId = pmCanteenPurchasePlan.getId(); + // 处理需求采购关联表 if (demandIds != null && !demandIds.isEmpty()) { - + for (Long demandId : demandIds) { + // 生成需求采购关联表 + PmCanteenDemandPurchase demandPurchase = new PmCanteenDemandPurchase(); + demandPurchase.setDemandId(demandId); + demandPurchase.setPurchaseId(planId); + // 保存关联表 + pmCanteenDemandPurchaseService.save(demandPurchase); + } + } + + // 处理选中的商品 + if (pmCanteenPurchaseDetails != null && !pmCanteenPurchaseDetails.isEmpty()) { // 查询出所有的cm_cust_product,做成map,key为goodsName - goodsCode - spec - unit,value为CmCustProduct List cmCustProducts = cmCustProductService.list(); Map cmCustProductMap = new HashMap<>(); @@ -320,50 +394,21 @@ public class PmCanteenPurchasePlanController { cmCustProductMap.put(key, cmCustProduct); } - for (Long demandId : demandIds) { - // 获取需求信息 - PmCanteenDemand demand = pmCanteenDemandService.getById(demandId); - if (demand == null) { - continue; - } - - // 获取需求明细 - LambdaQueryWrapper detailQueryWrapper = new LambdaQueryWrapper<>(); - detailQueryWrapper.eq(PmCanteenDemandDetail::getDemandId, demandId); - List demandDetails = pmCanteenDemandDetailService.list(detailQueryWrapper); + for (PmCanteenPurchaseDetail purchaseDetail : pmCanteenPurchaseDetails) { + // 设置采购计划ID + purchaseDetail.setPlanId(planId); - // 根据需求明细生成采购计划明细 - for (PmCanteenDemandDetail demandDetail : demandDetails) { - PmCanteenPurchaseDetail purchaseDetail = new PmCanteenPurchaseDetail(); - // 设置采购计划ID - purchaseDetail.setPlanId(planId); - // 复制需求明细的相关字段 - purchaseDetail.setGoodsName(demandDetail.getGoodsName()); - purchaseDetail.setGoodsCode(demandDetail.getGoodsCode()); - purchaseDetail.setSpec(demandDetail.getSpec()); - purchaseDetail.setUnit(demandDetail.getUnit()); - purchaseDetail.setPlanQuantity(demandDetail.getDemandQuantity()); - purchaseDetail.setRemark(demandDetail.getRemark()); - - // 根据key从map中获取对应的CmCustProduct,并设置对应的字段 - String key = demandDetail.getGoodsName() + " - " + demandDetail.getGoodsCode() + " - " + demandDetail.getSpec() + " - " + demandDetail.getUnit(); - CmCustProduct cmCustProduct = cmCustProductMap.get(key); - if (cmCustProduct != null) { - purchaseDetail.setCustId(cmCustProduct.getCustId()); - purchaseDetail.setCustName(cmCustProduct.getCustName()); - purchaseDetail.setGoodsId(cmCustProduct.getId()); // 商品Id - } - - // 保存采购计划明细 - pmCanteenPurchaseDetailService.save(purchaseDetail); + // 根据key从map中获取对应的CmCustProduct,并设置对应的字段 + String key = purchaseDetail.getGoodsName() + " - " + purchaseDetail.getGoodsCode() + " - " + purchaseDetail.getSpec() + " - " + purchaseDetail.getUnit(); + CmCustProduct cmCustProduct = cmCustProductMap.get(key); + if (cmCustProduct != null) { + purchaseDetail.setCustId(cmCustProduct.getCustId()); + purchaseDetail.setCustName(cmCustProduct.getCustName()); + purchaseDetail.setGoodsId(cmCustProduct.getId()); // 商品Id } - // 生成需求采购关联表 - PmCanteenDemandPurchase demandPurchase = new PmCanteenDemandPurchase(); - demandPurchase.setDemandId(demandId); - demandPurchase.setPurchaseId(planId); - // 保存关联表 - pmCanteenDemandPurchaseService.save(demandPurchase); + // 保存采购计划明细 + pmCanteenPurchaseDetailService.save(purchaseDetail); } } @@ -375,10 +420,49 @@ public class PmCanteenPurchasePlanController { */ @RequestMapping(value = "/update", method = RequestMethod.POST) public CommonResult update(@RequestBody PmCanteenPurchasePlan pmCanteenPurchasePlan){ - if (pmCanteenPurchasePlanService.updateById(pmCanteenPurchasePlan)) { - return CommonResult.success(); + // 保存采购计划基本信息 + if (!pmCanteenPurchasePlanService.updateById(pmCanteenPurchasePlan)) { + return CommonResult.failed(); } - return CommonResult.failed(); + + // 获取采购计划ID + Long planId = pmCanteenPurchasePlan.getId(); + + // 处理选中的商品 + List pmCanteenPurchaseDetails = pmCanteenPurchasePlan.getPmCanteenPurchaseDetails(); + if (pmCanteenPurchaseDetails != null && !pmCanteenPurchaseDetails.isEmpty()) { + // 删除该采购计划下的所有现有明细 + LambdaQueryWrapper detailQueryWrapper = new LambdaQueryWrapper<>(); + detailQueryWrapper.eq(PmCanteenPurchaseDetail::getPlanId, planId); + pmCanteenPurchaseDetailService.remove(detailQueryWrapper); + + // 查询出所有的cm_cust_product,做成map,key为goodsName - goodsCode - spec - unit,value为CmCustProduct + List cmCustProducts = cmCustProductService.list(); + Map cmCustProductMap = new HashMap<>(); + for (CmCustProduct cmCustProduct : cmCustProducts) { + String key = cmCustProduct.getGoodsName() + " - " + cmCustProduct.getGoodsCode() + " - " + cmCustProduct.getSpec() + " - " + cmCustProduct.getUnit(); + cmCustProductMap.put(key, cmCustProduct); + } + + for (PmCanteenPurchaseDetail purchaseDetail : pmCanteenPurchaseDetails) { + // 设置采购计划ID + purchaseDetail.setPlanId(planId); + + // 根据key从map中获取对应的CmCustProduct,并设置对应的字段 + String key = purchaseDetail.getGoodsName() + " - " + purchaseDetail.getGoodsCode() + " - " + purchaseDetail.getSpec() + " - " + purchaseDetail.getUnit(); + CmCustProduct cmCustProduct = cmCustProductMap.get(key); + if (cmCustProduct != null) { + purchaseDetail.setCustId(cmCustProduct.getCustId()); + purchaseDetail.setCustName(cmCustProduct.getCustName()); + purchaseDetail.setGoodsId(cmCustProduct.getId()); // 商品Id + } + + // 保存采购计划明细 + pmCanteenPurchaseDetailService.save(purchaseDetail); + } + } + + return CommonResult.success(); } /** @@ -501,7 +585,10 @@ public class PmCanteenPurchasePlanController { } - +// 描写 去吃饭之前,请求帮助 巴麻美答应帮忙,其他人也答应帮忙 +// 因为枫在昨晚也帮助过其他人 +// 鹤乃表示大家一起帮忙,很快就可以解决了。 +// 前往中央电波塔 diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmDailyMenuController.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmDailyMenuController.java index 8063d74..3ca6822 100644 --- a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmDailyMenuController.java +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmDailyMenuController.java @@ -1,8 +1,6 @@ package com.zbkj.modules.autogencode.controller; -import java.util.Arrays; -import java.util.List; -import java.util.Map; +import java.util.*; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -132,7 +130,9 @@ public class PmDailyMenuController { // 应用搜索条件 condition(queryWrapper, request); - + queryWrapper.orderByDesc(PmDailyMenu::getMenuDate); + queryWrapper.orderByDesc(PmDailyMenu::getCanteenName); + queryWrapper.orderByDesc(PmDailyMenu::getMealType); CommonPage page = CommonPage.restPage(pmDailyMenuService.pageList(queryWrapper, pageParamRequest)); return CommonResult.success(page); } @@ -212,6 +212,18 @@ public class PmDailyMenuController { @RequestMapping(value = "/batchSave", method = RequestMethod.POST) public CommonResult batchSave(@RequestBody List menus){ try { + // 检查是否已存在相同日期和食堂的菜单 + for (PmDailyMenu menu : menus) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(PmDailyMenu::getMenuDate, menu.getMenuDate()); + queryWrapper.eq(PmDailyMenu::getCanteenName, menu.getCanteenName()); + queryWrapper.eq(PmDailyMenu::getMealType, menu.getMealType()); + if (pmDailyMenuService.count(queryWrapper) > 0) { + return CommonResult.failed("当天该食堂的" + getMealTypeLabel(menu.getMealType()) + "菜单已存在"); + } + } + + // 保存菜单和明细 for (PmDailyMenu menu : menus) { // 保存菜单 pmDailyMenuService.save(menu); @@ -230,5 +242,162 @@ public class PmDailyMenuController { return CommonResult.failed("批量创建失败"); } } + + /** + * 批量更新菜单(修改操作) + */ + @RequestMapping(value = "/batchUpdate", method = RequestMethod.POST) + public CommonResult batchUpdate(@RequestBody List menus){ + try { + if (menus == null || menus.isEmpty()) { + return CommonResult.failed("菜单数据不能为空"); + } + + // 获取日期和食堂名称 + PmDailyMenu firstMenu = menus.get(0); + Date menuDate = firstMenu.getMenuDate(); + String canteenName = firstMenu.getCanteenName(); + + // 删除当天旧菜单 + LambdaQueryWrapper deleteWrapper = new LambdaQueryWrapper<>(); + deleteWrapper.eq(PmDailyMenu::getMenuDate, menuDate); + deleteWrapper.eq(PmDailyMenu::getCanteenName, canteenName); + List oldMenus = pmDailyMenuService.list(deleteWrapper); + for (PmDailyMenu oldMenu : oldMenus) { + // 删除旧菜单明细 + LambdaQueryWrapper dtlDeleteWrapper = new LambdaQueryWrapper<>(); + dtlDeleteWrapper.eq(PmDailyMenuDtl::getMenuId, oldMenu.getId()); + pmDailyMenuDtlService.remove(dtlDeleteWrapper); + } + // 删除旧菜单 + pmDailyMenuService.remove(deleteWrapper); + + // 插入新菜单 + for (PmDailyMenu menu : menus) { + // 保存菜单 + pmDailyMenuService.save(menu); + + // 保存菜单明细 + if (menu.getPmDailyMenuDtls() != null && !menu.getPmDailyMenuDtls().isEmpty()) { + for (PmDailyMenuDtl dtl : menu.getPmDailyMenuDtls()) { + dtl.setMenuId(menu.getId()); + pmDailyMenuDtlService.save(dtl); + } + } + } + return CommonResult.success(); + } catch (Exception e) { + e.printStackTrace(); + return CommonResult.failed("批量更新失败"); + } + } + + /** + * 获取餐别标签 + */ + private String getMealTypeLabel(String mealType) { + if ("1".equals(mealType)) { + return "早餐"; + } else if ("2".equals(mealType)) { + return "中餐"; + } else if ("3".equals(mealType)) { + return "晚餐"; + } + return mealType; + } + + /** + * 发布菜单 + */ + @RequestMapping(value = "/publish/{id}", method = RequestMethod.POST) + public CommonResult publish(@PathVariable("id") Long id) { + try { + PmDailyMenu menu = pmDailyMenuService.getById(id); + if (menu == null) { + return CommonResult.failed("菜单不存在"); + } + menu.setStatus("1"); + pmDailyMenuService.updateById(menu); + return CommonResult.success(); + } catch (Exception e) { + e.printStackTrace(); + return CommonResult.failed("发布失败"); + } + } + + /** + * 撤销发布菜单 + */ + @RequestMapping(value = "/cancelPublish/{id}", method = RequestMethod.POST) + public CommonResult cancelPublish(@PathVariable("id") Long id) { + try { + PmDailyMenu menu = pmDailyMenuService.getById(id); + if (menu == null) { + return CommonResult.failed("菜单不存在"); + } + menu.setStatus("0"); + pmDailyMenuService.updateById(menu); + return CommonResult.success(); + } catch (Exception e) { + e.printStackTrace(); + return CommonResult.failed("撤销发布失败"); + } + } + + /** + * 复制菜单 + */ + @RequestMapping(value = "/copy", method = RequestMethod.POST) + public CommonResult> copy(@RequestBody Map params){ + try { + String sourceDate = params.get("sourceDate"); + String targetDate = params.get("targetDate"); + String canteenName = params.get("canteenName"); + + // 查询原菜单 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(PmDailyMenu::getMenuDate, sourceDate); + queryWrapper.eq(PmDailyMenu::getCanteenName, canteenName); + List sourceMenus = pmDailyMenuService.list(queryWrapper); + + List targetMenus = new ArrayList<>(); + + for (PmDailyMenu sourceMenu : sourceMenus) { + // 创建新菜单 + PmDailyMenu targetMenu = new PmDailyMenu(); + targetMenu.setMenuDate(java.sql.Date.valueOf(targetDate)); + targetMenu.setCanteenName(canteenName); + targetMenu.setMealType(sourceMenu.getMealType()); + targetMenu.setStatus(sourceMenu.getStatus()); + targetMenu.setRemark(sourceMenu.getRemark()); + targetMenu.setDelFlag("0"); + + // 查询原菜单明细 + LambdaQueryWrapper dtlQueryWrapper = new LambdaQueryWrapper<>(); + dtlQueryWrapper.eq(PmDailyMenuDtl::getMenuId, sourceMenu.getId()); + List sourceDtls = pmDailyMenuDtlService.list(dtlQueryWrapper); + + // 复制明细 + List targetDtls = new ArrayList<>(); + for (PmDailyMenuDtl sourceDtl : sourceDtls) { + PmDailyMenuDtl targetDtl = new PmDailyMenuDtl(); + targetDtl.setItemName(sourceDtl.getItemName()); + targetDtl.setItemType(sourceDtl.getItemType()); + targetDtl.setItemPrice(sourceDtl.getItemPrice()); + targetDtl.setRemark(sourceDtl.getRemark()); + targetDtl.setDelFlag("0"); + targetDtls.add(targetDtl); + } + + targetMenu.setPmDailyMenuDtls(targetDtls); + targetMenus.add(targetMenu); + } + + return CommonResult.success(targetMenus); + } catch (Exception e) { + e.printStackTrace(); + return CommonResult.failed("复制失败"); + } + } } diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PubNoticeController.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PubNoticeController.java index 5fd3b3d..27349d6 100644 --- a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PubNoticeController.java +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PubNoticeController.java @@ -23,6 +23,11 @@ import com.zbkj.common.model.system.SystemAttachment; import com.zbkj.service.service.SystemAttachmentService; import com.zbkj.common.model.system.SysDept; import com.zbkj.service.service.SysDeptService; +import com.zbkj.modules.autogencode.entity.PubNoticeRel; +import com.zbkj.modules.autogencode.service.PubNoticeRelService; +import com.zbkj.common.model.user.User; +import com.zbkj.service.service.UserService; +import org.springframework.security.core.context.SecurityContextHolder; @@ -42,6 +47,12 @@ public class PubNoticeController { @Autowired private SysDeptService sysDeptService; + @Autowired + private PubNoticeRelService pubNoticeRelService; + + @Autowired + private UserService userService; + /** @@ -164,6 +175,44 @@ public class PubNoticeController { if (StrUtil.isNotBlank(request.getDelFlag())) { queryWrapper.eq(PubNotice::getDelFlag, request.getDelFlag()); } + + // 是否已读(虚拟字段,用于过滤) + if (StrUtil.isNotBlank(request.getIsRead())) { + // 获取当前用户Id + Integer userId = userService.getUserId(); + if (userId != 0) { + // 查询用户的所有通知关联记录 + List relList = pubNoticeRelService.list(new LambdaQueryWrapper() + .eq(PubNoticeRel::getUserCode, userId.toString()) + .eq(PubNoticeRel::getDelFlag, "1")); + + if ("1".equals(request.getIsRead())) { + // 查询已读通知:筛选出isRead为1的记录 + List readNoticeIds = relList.stream() + .filter(rel -> "1".equals(rel.getIsRead())) + .map(PubNoticeRel::getNoticeId) + .collect(java.util.stream.Collectors.toList()); + + if (!readNoticeIds.isEmpty()) { + queryWrapper.in(PubNotice::getNoticeId, readNoticeIds); + } else { + // 如果没有已读记录,添加一个永远为false的条件 + queryWrapper.eq(PubNotice::getNoticeId, -1); + } + } else if ("0".equals(request.getIsRead())) { + // 查询未读通知:筛选出没有关联记录的通知 + if (!relList.isEmpty()) { + // 提取所有已关联的通知ID + List relatedNoticeIds = relList.stream() + .map(PubNoticeRel::getNoticeId) + .collect(java.util.stream.Collectors.toList()); + // 查询不在已关联列表中的通知 + queryWrapper.notIn(PubNotice::getNoticeId, relatedNoticeIds); + } + // 如果没有关联记录,则所有通知都是未读的,不需要添加条件 + } + } + } } @@ -182,7 +231,7 @@ public class PubNoticeController { condition(queryWrapper, request); List pubNotices = pubNoticeService.pageList(queryWrapper, pageParamRequest); - // 设置拟稿单位名称 + // 设置拟稿单位名称和已读状态 if (pubNotices != null && !pubNotices.isEmpty()) { // 查询所有部门 List deptList = sysDeptService.list(); @@ -193,11 +242,30 @@ public class PubNoticeController { deptMap.put(String.valueOf(dept.getDeptId()), dept.getDeptName()); } } - // 遍历通知列表,设置拟稿单位名称 + + // 获取当前用户Id + Integer userId = userService.getUserId(); + + // 构建通知ID到已读状态的映射 + Map readStatusMap = new HashMap<>(); + if (userId != 0) { + List relList = pubNoticeRelService.list(new LambdaQueryWrapper() + .eq(PubNoticeRel::getUserCode, userId.toString()) + .eq(PubNoticeRel::getDelFlag, "1")); + for (PubNoticeRel rel : relList) { + readStatusMap.put(rel.getNoticeId(), rel.getIsRead()); + } + } + + // 遍历通知列表,设置拟稿单位名称和已读状态 for (PubNotice notice : pubNotices) { + // 设置拟稿单位名称 if (StrUtil.isNotBlank(notice.getDraftDept())) { notice.setDraftDeptName(deptMap.getOrDefault(notice.getDraftDept(), "")); } + + // 设置已读状态 + notice.setIsRead(readStatusMap.getOrDefault(notice.getNoticeId(), "0")); } } @@ -291,4 +359,49 @@ public class PubNoticeController { return CommonResult.failed(); } + /** + * 设置用户已读 + * @param noticeId 通知ID + */ + @ApiOperation(value = "设置用户已读") + @RequestMapping(value = "/markAsRead/{noticeId}", method = RequestMethod.POST) + public CommonResult markAsRead(@PathVariable("noticeId") String noticeId){ + try { + // 获取当前用户Id + Integer userId = userService.getUserId(); + if (userId == 0) { + return CommonResult.failed("用户不存在"); + } + + // 查询是否存在关联记录 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(PubNoticeRel::getNoticeId, noticeId); + queryWrapper.eq(PubNoticeRel::getUserCode, userId.toString()); + PubNoticeRel pubNoticeRel = pubNoticeRelService.getOne(queryWrapper); + + if (pubNoticeRel != null) { + // 更新已读状态 + pubNoticeRel.setIsRead("1"); // 1表示已读 + pubNoticeRel.setReadTime(new Date()); + pubNoticeRelService.updateById(pubNoticeRel); + } else { + // 创建新的关联记录 + pubNoticeRel = new PubNoticeRel(); + pubNoticeRel.setRelId(UUID.randomUUID().toString()); + pubNoticeRel.setNoticeId(noticeId); + pubNoticeRel.setRelType("U"); // U表示用户 + pubNoticeRel.setUserCode(userId.toString()); + pubNoticeRel.setIsRead("1"); // 1表示已读 + pubNoticeRel.setReadTime(new Date()); + pubNoticeRel.setDelFlag("1"); // 1表示正常 + pubNoticeRelService.save(pubNoticeRel); + } + + return CommonResult.success("设置已读成功"); + } catch (Exception e) { + e.printStackTrace(); + return CommonResult.failed("设置已读失败"); + } + } + } diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PmCanteenDemand.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PmCanteenDemand.java index 0f73f80..2a4f873 100644 --- a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PmCanteenDemand.java +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PmCanteenDemand.java @@ -50,6 +50,13 @@ public class PmCanteenDemand implements Serializable { @ApiModelProperty(value = "申请人姓名") @TableField(exist = false) private String userName; + + /** + * 申请人姓名搜索(虚拟字段) + */ + @ApiModelProperty(value = "申请人姓名搜索") + @TableField(exist = false) + private String userNameSearch; /** * 状态 */ diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PmCanteenPurchasePlan.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PmCanteenPurchasePlan.java index 88b7ef1..b28a417 100644 --- a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PmCanteenPurchasePlan.java +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PmCanteenPurchasePlan.java @@ -138,5 +138,8 @@ public class PmCanteenPurchasePlan implements Serializable { @TableField(exist = false) private List demandIds; + @TableField(exist = false) + private List pmCanteenPurchaseDetails; + } diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PmDailyMenu.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PmDailyMenu.java index 8c6822e..77869b9 100644 --- a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PmDailyMenu.java +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PmDailyMenu.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.baomidou.mybatisplus.annotation.FieldFill; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import org.springframework.format.annotation.DateTimeFormat; @@ -70,6 +71,7 @@ public class PmDailyMenu implements Serializable { * 创建时间 */ @ApiModelProperty(value = "创建时间") + @TableField(fill = FieldFill.INSERT) private Date createTime; /** * 修改人 @@ -80,6 +82,7 @@ public class PmDailyMenu implements Serializable { * 修改时间 */ @ApiModelProperty(value = "修改时间") + @TableField(fill = FieldFill.INSERT_UPDATE) private Date updateTime; /** * 租户ID diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PmDailyMenuDtl.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PmDailyMenuDtl.java index 00cf1e8..b4763f9 100644 --- a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PmDailyMenuDtl.java +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PmDailyMenuDtl.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.baomidou.mybatisplus.annotation.FieldFill; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import org.springframework.format.annotation.DateTimeFormat; @@ -68,6 +69,7 @@ public class PmDailyMenuDtl implements Serializable { * 创建时间 */ @ApiModelProperty(value = "创建时间") + @TableField(fill = FieldFill.INSERT) private Date createTime; /** * 修改人 @@ -78,6 +80,7 @@ public class PmDailyMenuDtl implements Serializable { * 修改时间 */ @ApiModelProperty(value = "修改时间") + @TableField(fill = FieldFill.INSERT_UPDATE) private Date updateTime; /** * 租户ID diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PubNotice.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PubNotice.java index b5caf66..197ae5a 100644 --- a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PubNotice.java +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PubNotice.java @@ -152,6 +152,13 @@ public class PubNotice implements Serializable { @ApiModelProperty(value = "拟稿单位名称") @TableField(exist = false) private String draftDeptName; + + /** + * 是否已读(虚拟字段,用于过滤) + */ + @ApiModelProperty(value = "是否已读") + @TableField(exist = false) + private String isRead; } diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/service/impl/PmCanteenPurchaseOrderServiceImpl.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/service/impl/PmCanteenPurchaseOrderServiceImpl.java index ab833e9..b71030f 100644 --- a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/service/impl/PmCanteenPurchaseOrderServiceImpl.java +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/service/impl/PmCanteenPurchaseOrderServiceImpl.java @@ -3,20 +3,12 @@ package com.zbkj.modules.autogencode.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.pagehelper.PageHelper; +import com.zbkj.modules.autogencode.entity.*; +import com.zbkj.modules.autogencode.service.*; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.zbkj.modules.autogencode.dao.PmCanteenPurchaseOrderDao; -import com.zbkj.modules.autogencode.entity.PmCanteenPurchaseOrder; -import com.zbkj.modules.autogencode.entity.PmCanteenPlanOrderRel; -import com.zbkj.modules.autogencode.entity.PmCanteenPurchaseDetail; -import com.zbkj.modules.autogencode.entity.PmCanteenPurchasePlan; -import com.zbkj.modules.autogencode.entity.CmCust; -import com.zbkj.modules.autogencode.service.PmCanteenPurchaseOrderService; -import com.zbkj.modules.autogencode.service.PmCanteenPlanOrderRelService; -import com.zbkj.modules.autogencode.service.PmCanteenPurchaseDetailService; -import com.zbkj.modules.autogencode.service.PmCanteenPurchasePlanService; -import com.zbkj.modules.autogencode.service.CmCustService; import com.zbkj.common.page.CommonPage; import com.zbkj.common.request.PageParamRequest; @@ -44,6 +36,9 @@ public class PmCanteenPurchaseOrderServiceImpl extends ServiceImpl result = new ArrayList<>(); for (PmCanteenPlanOrderRel rel : relList) { + PmCanteenPurchaseOrder.PlanDetailDTO dto = new PmCanteenPurchaseOrder.PlanDetailDTO(); + // 从采购明细表中获取完整的商品信息 PmCanteenPurchaseDetail detail = pmCanteenPurchaseDetailService.getById(rel.getDetailId()); if (detail != null) { - PmCanteenPurchaseOrder.PlanDetailDTO dto = new PmCanteenPurchaseOrder.PlanDetailDTO(); dto.setId(detail.getId()); dto.setPlanId(detail.getPlanId()); @@ -120,11 +116,6 @@ public class PmCanteenPurchaseOrderServiceImpl extends ServiceImpl relList = new ArrayList<>(); for (PmCanteenPurchaseOrder.PlanDetailDTO detail : planDetails) { - PmCanteenPlanOrderRel rel = new PmCanteenPlanOrderRel(); - rel.setOrderId(orderId); - rel.setPlanId(detail.getPlanId()); - rel.setDetailId(detail.getId()); - rel.setOrderQuantity(BigDecimal.valueOf(detail.getOrderQuantity())); - rel.setOrderPrice(BigDecimal.valueOf(detail.getOrderPrice())); - rel.setOrderAmount(BigDecimal.valueOf(detail.getOrderAmount())); - rel.setDelFlag("0"); - relList.add(rel); + // 只有当明细ID大于0时才创建关联关系(直接添加的商品明细ID为0) + if (detail.getId() != null && detail.getId() > 0) { + PmCanteenPlanOrderRel rel = new PmCanteenPlanOrderRel(); + rel.setOrderId(orderId); + rel.setPlanId(detail.getPlanId()); + rel.setDetailId(detail.getId()); + rel.setGoodsId(detail.getGoodsId()); + rel.setOrderQuantity(BigDecimal.valueOf(detail.getOrderQuantity())); + rel.setOrderPrice(BigDecimal.valueOf(detail.getOrderPrice())); + rel.setOrderAmount(BigDecimal.valueOf(detail.getOrderAmount())); + rel.setDelFlag("0"); + relList.add(rel); + } + if (detail.getId() != null && detail.getId() == 0) { + PmCanteenPlanOrderRel rel = new PmCanteenPlanOrderRel(); + rel.setOrderId(orderId); + rel.setPlanId(detail.getPlanId()); + rel.setDetailId(detail.getId()); + rel.setGoodsId(detail.getGoodsId()); + rel.setOrderQuantity(BigDecimal.valueOf(detail.getOrderQuantity())); + rel.setOrderPrice(BigDecimal.valueOf(detail.getOrderPrice())); + rel.setOrderAmount(BigDecimal.valueOf(detail.getOrderAmount())); + rel.setDelFlag("0"); + relList.add(rel); + } } - return pmCanteenPlanOrderRelService.saveBatch(relList); + // 如果有需要保存的关联关系,则批量保存 + if (!relList.isEmpty()) { + return pmCanteenPlanOrderRelService.saveBatch(relList); + } + + // 如果没有关联关系需要保存,返回成功 + return true; } @Override