From b004bb5a9a1724829c42c33cfa2963eea4766278 Mon Sep 17 00:00:00 2001 From: zxy Date: Thu, 8 Jan 2026 11:13:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E6=96=99=E6=8A=A5=E5=B7=A5=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../taskinreport/TaskInReportController.java | 8 + .../vo/TaskInReportSaveReqVO.java | 2 +- .../taskinreport/vo/TaskReworkReqVO.java | 10 + .../taskdispatch/TaskDispatchDetailDO.java | 4 + .../taskinreport/TaskInReportService.java | 117 +++--- .../taskinreport/TaskInReportServiceImpl.java | 41 +- .../src/api/heli/taskinreport/index.ts | 104 +++++ .../mes-ui-admin-vue3/src/utils/formatter.ts | 18 +- .../heli/taskinreport/TaskInReportForm.vue | 91 +++-- .../src/views/heli/taskinreport/index.vue | 364 ++++++++++++++++++ 10 files changed, 661 insertions(+), 98 deletions(-) create mode 100644 mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/taskinreport/vo/TaskReworkReqVO.java create mode 100644 mes-ui/mes-ui-admin-vue3/src/api/heli/taskinreport/index.ts create mode 100644 mes-ui/mes-ui-admin-vue3/src/views/heli/taskinreport/index.vue diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/taskinreport/TaskInReportController.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/taskinreport/TaskInReportController.java index de6a3955..8a63f025 100644 --- a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/taskinreport/TaskInReportController.java +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/taskinreport/TaskInReportController.java @@ -53,6 +53,14 @@ public class TaskInReportController { return success(true); } + // 返工 + @PostMapping("/rework") + @Operation(summary = "返工") + @PreAuthorize("@ss.hasPermission('heli:task-in-report:update')") + public CommonResult rework(@Valid @RequestBody TaskReworkReqVO reworkReqVO) { + taskInReportService.rework(reworkReqVO.getId(), reworkReqVO.getRemark()); + return success(true); + } @DeleteMapping("/delete") @Operation(summary = "删除下料报工") @Parameter(name = "id", description = "编号", required = true) diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/taskinreport/vo/TaskInReportSaveReqVO.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/taskinreport/vo/TaskInReportSaveReqVO.java index 70ef674a..fd89bd0d 100644 --- a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/taskinreport/vo/TaskInReportSaveReqVO.java +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/taskinreport/vo/TaskInReportSaveReqVO.java @@ -30,7 +30,7 @@ public class TaskInReportSaveReqVO { @Schema(description = "报工日期") private LocalDateTime reportTime; - @Schema(description = "长度(半径)") + @Schema(description = "长度(直径)") private BigDecimal length; @Schema(description = "是否已报工 0 默认否 1 是", requiredMode = Schema.RequiredMode.REQUIRED) diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/taskinreport/vo/TaskReworkReqVO.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/taskinreport/vo/TaskReworkReqVO.java new file mode 100644 index 00000000..bc2eb650 --- /dev/null +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/controller/admin/taskinreport/vo/TaskReworkReqVO.java @@ -0,0 +1,10 @@ +package com.chanko.yunxi.mes.module.heli.controller.admin.taskinreport.vo; + +import lombok.Data; + +@Data +public class TaskReworkReqVO { + + private Long id; + private String remark; +} diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/dataobject/taskdispatch/TaskDispatchDetailDO.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/dataobject/taskdispatch/TaskDispatchDetailDO.java index 295ded67..ea355f63 100644 --- a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/dataobject/taskdispatch/TaskDispatchDetailDO.java +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/dal/dataobject/taskdispatch/TaskDispatchDetailDO.java @@ -104,6 +104,10 @@ public class TaskDispatchDetailDO extends BaseDO { private Long projectMaterialPlanDetailId; private Integer planStatus; private Integer isReport; + + private Integer inReportProcess; + private String returnRemark; + /** * 工序状态 默认 已提交 已完成 0 1 2 */ diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/taskinreport/TaskInReportService.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/taskinreport/TaskInReportService.java index cb89f2c7..07eb8d62 100644 --- a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/taskinreport/TaskInReportService.java +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/taskinreport/TaskInReportService.java @@ -1,55 +1,62 @@ -package com.chanko.yunxi.mes.module.heli.service.taskinreport; - -import java.util.*; -import javax.validation.*; -import com.chanko.yunxi.mes.module.heli.controller.admin.taskinreport.vo.*; -import com.chanko.yunxi.mes.module.heli.dal.dataobject.taskinreport.TaskInReportDO; -import com.chanko.yunxi.mes.framework.common.pojo.PageResult; -import com.chanko.yunxi.mes.framework.common.pojo.PageParam; - -/** - * 下料报工 Service 接口 - * - * @author 管理员 - */ -public interface TaskInReportService { - - /** - * 创建下料报工 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createTaskInReport(@Valid TaskInReportSaveReqVO createReqVO); - - /** - * 更新下料报工 - * - * @param updateReqVO 更新信息 - */ - void updateTaskInReport(@Valid TaskInReportSaveReqVO updateReqVO); - - /** - * 删除下料报工 - * - * @param id 编号 - */ - void deleteTaskInReport(Long id); - - /** - * 获得下料报工 - * - * @param id 编号 - * @return 下料报工 - */ - TaskInReportDO getTaskInReport(Long id); - - /** - * 获得下料报工分页 - * - * @param pageReqVO 分页查询 - * @return 下料报工分页 - */ - PageResult getTaskInReportPage(TaskInReportPageReqVO pageReqVO); - -} \ No newline at end of file +package com.chanko.yunxi.mes.module.heli.service.taskinreport; + +import java.util.*; +import javax.validation.*; +import com.chanko.yunxi.mes.module.heli.controller.admin.taskinreport.vo.*; +import com.chanko.yunxi.mes.module.heli.dal.dataobject.taskinreport.TaskInReportDO; +import com.chanko.yunxi.mes.framework.common.pojo.PageResult; +import com.chanko.yunxi.mes.framework.common.pojo.PageParam; + +/** + * 下料报工 Service 接口 + * + * @author 管理员 + */ +public interface TaskInReportService { + + /** + * 创建下料报工 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createTaskInReport(@Valid TaskInReportSaveReqVO createReqVO); + + /** + * 更新下料报工 + * + * @param updateReqVO 更新信息 + */ + void updateTaskInReport(@Valid TaskInReportSaveReqVO updateReqVO); + + /** + * 返工 + * + * @param id 编号 + */ + void rework(Long id, String remark); + + /** + * 删除下料报工 + * + * @param id 编号 + */ + void deleteTaskInReport(Long id); + + /** + * 获得下料报工 + * + * @param id 编号 + * @return 下料报工 + */ + TaskInReportDO getTaskInReport(Long id); + + /** + * 获得下料报工分页 + * + * @param pageReqVO 分页查询 + * @return 下料报工分页 + */ + PageResult getTaskInReportPage(TaskInReportPageReqVO pageReqVO); + +} diff --git a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/taskinreport/TaskInReportServiceImpl.java b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/taskinreport/TaskInReportServiceImpl.java index fec63e90..a826896d 100644 --- a/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/taskinreport/TaskInReportServiceImpl.java +++ b/mes-module-heli/mes-module-heli-biz/src/main/java/com/chanko/yunxi/mes/module/heli/service/taskinreport/TaskInReportServiceImpl.java @@ -1,7 +1,12 @@ package com.chanko.yunxi.mes.module.heli.service.taskinreport; +import com.chanko.yunxi.mes.module.heli.dal.dataobject.taskdispatch.TaskDispatchDetailDO; +import com.chanko.yunxi.mes.module.heli.dal.mysql.taskdispatch.TaskDispatchDetailMapper; import org.springframework.stereotype.Service; + import javax.annotation.Resource; + +import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import com.chanko.yunxi.mes.module.heli.controller.admin.taskinreport.vo.*; @@ -11,6 +16,8 @@ import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils; import com.chanko.yunxi.mes.module.heli.dal.mysql.taskinreport.TaskInReportMapper; +import java.util.List; + import static com.chanko.yunxi.mes.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.chanko.yunxi.mes.module.heli.enums.ErrorCodeConstants.*; @@ -26,6 +33,9 @@ public class TaskInReportServiceImpl implements TaskInReportService { @Resource private TaskInReportMapper taskInReportMapper; + @Resource + private TaskDispatchDetailMapper taskDispatchDetailMapper; + @Override public Long createTaskInReport(TaskInReportSaveReqVO createReqVO) { // 插入 @@ -45,9 +55,32 @@ public class TaskInReportServiceImpl implements TaskInReportService { } @Override + public void rework(Long id, String remark) { + TaskInReportDO taskInReportDO = taskInReportMapper.selectById(id); + TaskDispatchDetailDO taskDispatchDetailDO = taskDispatchDetailMapper.selectById(taskInReportDO.getDispatchDetailId()); + if (taskDispatchDetailDO != null) { + if (taskDispatchDetailDO.getInReportProcess() != 2) { + throw new RuntimeException("当前报工状态不允许重新报工"); + } + taskDispatchDetailDO.setInReportProcess(1); + taskDispatchDetailDO.setReturnRemark(remark); + taskDispatchDetailMapper.updateById(taskDispatchDetailDO); + } + + } + + @Override + @Transactional public void deleteTaskInReport(Long id) { - // 校验存在 - validateTaskInReportExists(id); + TaskInReportDO taskInReportDO = taskInReportMapper.selectById(id); + TaskDispatchDetailDO taskDispatchDetailDO = taskDispatchDetailMapper.selectById(taskInReportDO.getDispatchDetailId()); + if (taskDispatchDetailDO != null) { + if (taskDispatchDetailDO.getInReportProcess() != 2) { + throw new RuntimeException("当前报工状态不允许删除"); + } else { + taskDispatchDetailDO.setInReportProcess(0); + } + } // 删除 taskInReportMapper.deleteById(id); } @@ -60,7 +93,9 @@ public class TaskInReportServiceImpl implements TaskInReportService { @Override public TaskInReportDO getTaskInReport(Long id) { - return taskInReportMapper.selectById(id); + TaskInReportDO taskInReportDO = taskInReportMapper.selectById(id); + + return taskInReportDO; } @Override diff --git a/mes-ui/mes-ui-admin-vue3/src/api/heli/taskinreport/index.ts b/mes-ui/mes-ui-admin-vue3/src/api/heli/taskinreport/index.ts new file mode 100644 index 00000000..cff6313a --- /dev/null +++ b/mes-ui/mes-ui-admin-vue3/src/api/heli/taskinreport/index.ts @@ -0,0 +1,104 @@ +import request from '@/config/axios' + +export interface TaskInReportVO { + id: number + dispatchDetailId: number + owner: number + amount: number + reportTime: Date + length: number + hasReport: boolean + status: boolean + workType: string + remark: string + widht: number + hight: number + density: number + weight: number + price: number + reportPrice: number + matType: string + formalId: number + calFormal: string +} + +// 查询下料报工分页 +export const getTaskInReportPage = async (params) => { + return await request.get({ url: `/heli/task-in-report/page`, params }) +} + +// 查询下料报工详情 +export const getTaskInReport = async (id: number) => { + return await request.get({ url: `/heli/task-in-report/get?id=` + id }) +} + +// 新增下料报工 +export const createTaskInReport = async (data: TaskInReportVO) => { + return await request.post({ url: `/heli/task-in-report/create`, data }) +} + +// 修改下料报工 +export const updateTaskInReport = async (data: TaskInReportVO) => { + return await request.put({ url: `/heli/task-in-report/update`, data }) +} + +// 返工 +export const rework = async (data: TaskInReportVO) => { + return await request.post({url: `/heli/task-in-report/rework`, data}) +} +// 删除下料报工 +export const deleteTaskInReport = async (id: number) => { + return await request.delete({ url: `/heli/task-in-report/delete?id=` + id }) +} + +// 导出下料报工 Excel +export const exportTaskInReport = async (params) => { + return await request.download({ url: `/heli/task-in-report/export-excel`, params }) +} + +// 物料类型选项 +export const matTypeOptions = [ + {value: "1", label: "块料"}, + {value: "2", label: "棒料"}, + {value: "3", label: "方料"} +]; + +/** 获取下料类型 */ +export const getMatType = ({value}: { value: any }) => { + // 从选项数组中查找对应的标签 + const option = matTypeOptions.find(item => item.value === value); + return option ? option.label : "未知类型"; +}; + +// 报工状态配置 +const reportStatusConfig = { + 0: { label: "未报工", color: "#909399" }, + 1: { label: "已报工", color: "#E6A23C" }, + 2: { label: "报工完成", color: "#67C23A" } +}; + +/** 获取报工状态 */ +export const getReportStatus = ({value}: { value: any }) => { + // 处理各种可能的数据类型和空值情况 + if (value === null || value === undefined) { + return "未知状态"; + } + + // 转换为数字进行比较 + const numValue = Number(value); + const status = reportStatusConfig[numValue]; + + return status ? status.label : `未知状态(${value})`; +}; + +/** 获取报工状态颜色 */ +export const getReportStatusColor = (value: any) => { + if (value === null || value === undefined) { + return '#909399'; // 灰色 + } + + const numValue = Number(value); + const status = reportStatusConfig[numValue]; + + return status ? status.color : '#909399'; +}; diff --git a/mes-ui/mes-ui-admin-vue3/src/utils/formatter.ts b/mes-ui/mes-ui-admin-vue3/src/utils/formatter.ts index 63548ba3..de07ec28 100644 --- a/mes-ui/mes-ui-admin-vue3/src/utils/formatter.ts +++ b/mes-ui/mes-ui-admin-vue3/src/utils/formatter.ts @@ -7,14 +7,14 @@ export const fenToYuanFormat = (_, __, cellValue: any, ___) => { } /** 数字格式化为两位小数 */ -const formatNumber = (row: any, column: any, cellValue: any) => { - if (cellValue === null || cellValue === undefined) { - return '-' - } - // 确保是数字类型后再格式化 +// 格式化金额:保留两位小数,加千分位逗号 +export const formatAmount = (row, column, cellValue) => { + if (cellValue == null || cellValue === '') return '' + + // 转为数字 const num = Number(cellValue) - if (isNaN(num)) { - return cellValue - } - return num.toFixed(2) + if (isNaN(num)) return cellValue + + // 使用 toFixed(2) 保证两位小数,再用 toLocaleString 加千分位 + return num.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ',') } diff --git a/mes-ui/mes-ui-admin-vue3/src/views/heli/taskinreport/TaskInReportForm.vue b/mes-ui/mes-ui-admin-vue3/src/views/heli/taskinreport/TaskInReportForm.vue index ba5c91cd..2ecb080a 100644 --- a/mes-ui/mes-ui-admin-vue3/src/views/heli/taskinreport/TaskInReportForm.vue +++ b/mes-ui/mes-ui-admin-vue3/src/views/heli/taskinreport/TaskInReportForm.vue @@ -3,17 +3,24 @@ - + + + @@ -34,26 +41,41 @@ - - - - + + + @@ -103,6 +125,7 @@ import * as TaskInReportApi from '@/api/heli/taskinreport' const {t} = useI18n() // 国际化 const message = useMessage() // 消息弹窗 +import {formatAmount} from '@/utils/formatter' const dialogVisible = ref(false) // 弹窗的是否展示 const dialogTitle = ref('') // 弹窗的标题 @@ -132,7 +155,6 @@ const formData = ref({ const formRules = reactive({ length: [{required: true, message: '长(直径)不能为空', trigger: 'blur'}], hight: [{required: true, message: '高度不能为空', trigger: 'blur'}], - widht: [{required: true, message: '宽度是不能为空', trigger: 'blur'}], weight: [{required: true, message: '重量不能为空', trigger: 'blur'}], reportPrice: [{required: true, message: '总价不能为空', trigger: 'blur'}], }) @@ -161,6 +183,16 @@ const emit = defineEmits(['success']) // 定义 success 事件,用于操作成 const submitForm = async () => { // 校验表单 await formRef.value.validate() + if (formData.value.matType === '1' || formData.value.matType === '3') { + if (formData.value.widht == 0) { + message.error('宽度不能为0'); + return; + } + } + if (formData.value.reportPrice === 0) { + //弹出提示,本次下料总价为0,是否继续 + await message.confirm('本次下料总价为0,是否继续?') + } // 提交请求 formLoading.value = true try { @@ -180,6 +212,11 @@ const submitForm = async () => { } } +const handleChange = () => { + handleDimensionChange(); + handleReportPriceChange(); +}; + const handleReportPriceChange = () => { if (formData.value.weight) { formData.value.reportPrice = Number((formData.value.weight * formData.value.price).toFixed(2)); @@ -192,37 +229,31 @@ const handleDimensionChange = () => { const calculateWeight = () => { if (!validateNumericValue(formData.value.length) || - !validateNumericValue(formData.value.hight) || - !validateNumericValue(formData.value.density)) { + !validateNumericValue(formData.value.hight) || + !validateNumericValue(formData.value.density)) { return 0; } let totalWeight = 0; if (formData.value.matType === "1" || formData.value.matType === "3") { if (!validateNumericValue(formData.value.widht)) { + message.error('宽度不能为0'); return 0; } totalWeight = Number( - (formData.value.length * formData.value.widht * formData.value.hight * formData.value.density) / - 1000000 * 100 + (formData.value.length * formData.value.widht * formData.value.hight * formData.value.density) / + 1000000 ).toFixed(2); } if (formData.value.matType === "2") { totalWeight = Number( - (3.14 * Math.pow(formData.value.length / 2, 2) * formData.value.hight * formData.value.density) / - 1000000 + (3.14 * Math.pow(formData.value.length / 2, 2) * formData.value.hight * formData.value.density) / + 1000000 ).toFixed(2); } return totalWeight; }; - formData.value.weight = calculateWeight(); - - if (validateNumericValue(formData.value.weight) && validateNumericValue(formData.value.price)) { - formData.value.reportPrice = Number(formData.value.weight * formData.value.price).toFixed(2); - } else { - formData.value.reportPrice = 0; - } }; diff --git a/mes-ui/mes-ui-admin-vue3/src/views/heli/taskinreport/index.vue b/mes-ui/mes-ui-admin-vue3/src/views/heli/taskinreport/index.vue new file mode 100644 index 00000000..9e1cb95b --- /dev/null +++ b/mes-ui/mes-ui-admin-vue3/src/views/heli/taskinreport/index.vue @@ -0,0 +1,364 @@ + + + +