diff --git a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/controller/AftersalesWarehouseOutController.java b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/controller/AftersalesWarehouseOutController.java index 163c8516..f083025a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/controller/AftersalesWarehouseOutController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/controller/AftersalesWarehouseOutController.java @@ -11,11 +11,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.aftersales.service.IAftersalesWarehouseOutService; @@ -265,15 +261,15 @@ public class AftersalesWarehouseOutController extends BaseController } /** - * 展示售后第一次维护设备料号相关出货设备信息 + * 展示售后第一次维护设备料号已选择添加出货设备的相关出货设备信息 */ - @PostMapping("/showAftersalesShippingDevicelist") + @PostMapping("/showAftersalesShippingDeviceList") @ResponseBody - public TableDataInfo showAftersalesShippingDevicelist(WarehouseOutOrder warehouseOutOrder) + public TableDataInfo showAftersalesShippingDeviceList(@RequestParam("materialNo") String materialNo) { startPage(); - List list = warehouseOutOrderService.selectAftersalesShippingDevicelistByCodeAndNo(warehouseOutOrder); + List list = warehouseOutOrderService.showAftersalesShippingDeviceList(materialNo); return getDataTable(list); } @@ -293,6 +289,17 @@ public class AftersalesWarehouseOutController extends BaseController + /** + * 修改保存售后第一次维护设备 添加出货设备信息 + */ + @ResponseBody + @PostMapping("/addShippingDevicesOne") + public AjaxResult addShippingDevicesOne(@RequestBody WarehouseOutOrderDetail warehouseOutOrderDetail) + { + + return toAjax(outOrderDetailService.addShippingDevicesOne(warehouseOutOrderDetail)); + } + /** @@ -310,8 +317,6 @@ public class AftersalesWarehouseOutController extends BaseController - - /** * 第一次维护设备删除物料信息出货设备信息 */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/domain/AfterSalesShippingDevice.java b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/domain/AfterSalesShippingDevice.java index 1bdffb92..6bf4cece 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/domain/AfterSalesShippingDevice.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/domain/AfterSalesShippingDevice.java @@ -158,7 +158,8 @@ public class AfterSalesShippingDevice extends BaseEntity @Excel(name = "维修时间", width = 30, dateFormat = "yyyy-MM-dd") private Date maintainTime; - + /** 是否添加出货设备(0代表是 1代表否) */ + private String addShippingDeviceFlag; public void setShippingDeviceCode(Long shippingDeviceCode) { this.shippingDeviceCode = shippingDeviceCode; @@ -464,6 +465,14 @@ public class AfterSalesShippingDevice extends BaseEntity this.maintainTime = maintainTime; } + public String getAddShippingDeviceFlag() { + return addShippingDeviceFlag; + } + + public void setAddShippingDeviceFlag(String addShippingDeviceFlag) { + this.addShippingDeviceFlag = addShippingDeviceFlag; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -505,6 +514,7 @@ public class AfterSalesShippingDevice extends BaseEntity .append("createTime", getCreateTime()) .append("updateBy", getUpdateBy()) .append("updateTime", getUpdateTime()) + .append("addShippingDeviceFlag",getAddShippingDeviceFlag()) .toString(); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/IAftersalesWarehouseOutService.java b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/IAftersalesWarehouseOutService.java index 2e95ce8b..1420df74 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/IAftersalesWarehouseOutService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/IAftersalesWarehouseOutService.java @@ -119,4 +119,10 @@ public interface IAftersalesWarehouseOutService * 展示售后第一次维护设备 添加出货设备 料号相关出货设备信息 * */ List selectAftersalesShippingDeviceListByMaterialNo(WarehouseOutOrderDetail warehouseOutOrderDetail); + + /** + * 展示售后第一次维护设备料号已选择添加出货设备的相关出货设备信息 + * */ + List showAftersalesShippingDeviceList(String materialNo); + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesWarehouseOutServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesWarehouseOutServiceImpl.java index 1291ad81..d4859b94 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesWarehouseOutServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesWarehouseOutServiceImpl.java @@ -2,6 +2,7 @@ package com.ruoyi.aftersales.service.impl; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import com.ruoyi.aftersales.domain.AfterSalesShippingDevice; import com.ruoyi.aftersales.domain.vo.SelectMaterialsVO; @@ -211,6 +212,34 @@ public class AftersalesWarehouseOutServiceImpl implements IAftersalesWarehouseOu return selectShippingDeviceVOs; } + /** + * 展示售后第一次维护设备料号已选择添加出货设备的相关出货设备信息 + * */ + @Override + public List showAftersalesShippingDeviceList(String materialNo) { + + List selectShippingDeviceVOs = new ArrayList<>(); + AfterSalesShippingDevice afterSalesShippingDevice = new AfterSalesShippingDevice(); + afterSalesShippingDevice.setMaterialNo(materialNo); + List afterSalesShippingDevices = shippingDeviceMapper.selectShippingDeviceListByMaterialNo(afterSalesShippingDevice); + List filterAfterSalesShippingDevices = afterSalesShippingDevices.stream().filter(shippingDevice -> "0".equals(shippingDevice.getAddShippingDeviceFlag())).collect(Collectors.toList()); + if (!StringUtils.isNotEmpty(filterAfterSalesShippingDevices)) { + // 记录日志 + log.warn("未查找到与物料号关联的出库设备数据, 物料号: {}",materialNo); + } + + for (AfterSalesShippingDevice tempAfterSalesShippingDevice : filterAfterSalesShippingDevices) { + SelectShippingDeviceVO shippingDeviceVO = new SelectShippingDeviceVO(); + shippingDeviceVO.setShippingDeviceId(tempAfterSalesShippingDevice.getShippingDeviceId()); + shippingDeviceVO.setDeviceModelCode(tempAfterSalesShippingDevice.getDeviceModelCode()); + shippingDeviceVO.setDeviceRunningNumber(tempAfterSalesShippingDevice.getDeviceRunningNumber()); + shippingDeviceVO.setMakePhotoUrl(tempAfterSalesShippingDevice.getMakePhotourl()); + shippingDeviceVO.setQuoteId(tempAfterSalesShippingDevice.getSalesOrderCode()); + selectShippingDeviceVOs.add(shippingDeviceVO); + } + return selectShippingDeviceVOs; + } + /* * 售后第一次维护设备信息根据设备ID删除出货设备信息 * */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseOutOrderDetail.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseOutOrderDetail.java index 777e0796..57f887ad 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseOutOrderDetail.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseOutOrderDetail.java @@ -1,7 +1,10 @@ package com.ruoyi.warehouse.domain; import java.util.Date; +import java.util.List; + import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.aftersales.domain.vo.SelectShippingDeviceVO; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.annotation.Excel; @@ -199,6 +202,10 @@ public class WarehouseOutOrderDetail extends BaseEntity @Excel(name = "收货电话") private String deliveryNumber; + /** 添加出货设备列表*/ + private List SelectShippingDeviceVOList; + + public void setOutOrderDetailId(Long outOrderDetailId) { this.outOrderDetailId = outOrderDetailId; @@ -605,6 +612,14 @@ public class WarehouseOutOrderDetail extends BaseEntity return deliveryNumber; } + public List getSelectShippingDeviceVOList() { + return SelectShippingDeviceVOList; + } + + public void setSelectShippingDeviceVOList(List selectShippingDeviceVOList) { + SelectShippingDeviceVOList = selectShippingDeviceVOList; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -658,6 +673,7 @@ public class WarehouseOutOrderDetail extends BaseEntity .append("createTime", getCreateTime()) .append("updateBy", getUpdateBy()) .append("updateTime", getUpdateTime()) + .append("selectShippingDeviceVOList",getSelectShippingDeviceVOList()) .toString(); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseOutOrderDetailService.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseOutOrderDetailService.java index 0739d3d2..ed3624bb 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseOutOrderDetailService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseOutOrderDetailService.java @@ -91,4 +91,9 @@ public interface IWarehouseOutOrderDetailService * 退换货-出库 供应商物料详情列表 */ List selectWarehouseOutOrderDetailListByCode(String outOrderCode); + + /** + * 修改保存售后第一次维护设备 添加出货设备信息 + */ + int addShippingDevicesOne(WarehouseOutOrderDetail warehouseOutOrderDetail); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseOutOrderDetailServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseOutOrderDetailServiceImpl.java index 9b70eca2..c4dcb061 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseOutOrderDetailServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseOutOrderDetailServiceImpl.java @@ -3,7 +3,9 @@ package com.ruoyi.warehouse.service.impl; import java.util.List; import com.ruoyi.aftersales.domain.AfterSalesShippingDevice; +import com.ruoyi.aftersales.domain.vo.SelectShippingDeviceVO; import com.ruoyi.aftersales.mapper.AfterSalesShippingDeviceMapper; +import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.StringUtils; @@ -16,6 +18,7 @@ import com.ruoyi.warehouse.mapper.WarehouseOutOrderDetailMapper; import com.ruoyi.warehouse.domain.WarehouseOutOrderDetail; import com.ruoyi.warehouse.service.IWarehouseOutOrderDetailService; import com.ruoyi.common.core.text.Convert; +import org.springframework.transaction.annotation.Transactional; /** * 出库单详情Service业务层处理 @@ -165,4 +168,25 @@ public class WarehouseOutOrderDetailServiceImpl implements IWarehouseOutOrderDet return warehouseOutOrderDetailMapper.selectOutOrderDetailListByCode(outOrderCode); } + + /** + * 修改保存售后第一次维护设备 添加出货设备信息 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int addShippingDevicesOne(WarehouseOutOrderDetail warehouseOutOrderDetail) { + List selectShippingDeviceVOList = warehouseOutOrderDetail.getSelectShippingDeviceVOList(); + int updateShippingDeviceResult = 0; + for (SelectShippingDeviceVO selectShippingDeviceVO : selectShippingDeviceVOList) { + AfterSalesShippingDevice afterSalesShippingDevice = new AfterSalesShippingDevice(); + afterSalesShippingDevice.setShippingDeviceId(selectShippingDeviceVO.getShippingDeviceId()); + //设置为已经添加出货设备 + afterSalesShippingDevice.setAddShippingDeviceFlag("0"); + updateShippingDeviceResult += afterSalesShippingDeviceMapper.updateAfterSalesShippingDevice(afterSalesShippingDevice); + if (updateShippingDeviceResult <= 0){ + throw new BusinessException("更新出货设备信息失败"); + } + } + return updateShippingDeviceResult; + } } diff --git a/ruoyi-admin/src/main/resources/mapper/aftersales/AfterSalesShippingDeviceMapper.xml b/ruoyi-admin/src/main/resources/mapper/aftersales/AfterSalesShippingDeviceMapper.xml index d5a9f599..c93078fa 100644 --- a/ruoyi-admin/src/main/resources/mapper/aftersales/AfterSalesShippingDeviceMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/aftersales/AfterSalesShippingDeviceMapper.xml @@ -43,10 +43,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + - select shipping_device_code, shipping_device_id, make_no,sales_order_code, material_no, material_photoUrl, material_name, material_type, material_class, material_model_code, material_unit, material_brand, material_describe, device_model_code, device_running_number, make_photoUrl, sn_code, aftersales_photoUrl, factory_date, guarantee_period, guarantee_period_flag, lock_date, lock_date_flag, wastage_expire_date, wastage_expire_flag, component_guarantee_date, component_guarantee_flag, engineer_name, salesman_name, make_name,customer_id, customer_name, maintain_order_code, maintain_time, create_by, create_time, update_by, update_time from aftersales_shipping_device + select shipping_device_code, shipping_device_id, make_no,sales_order_code, material_no, material_photoUrl, material_name, material_type, material_class, material_model_code, material_unit, material_brand, material_describe, device_model_code, device_running_number, make_photoUrl, sn_code, aftersales_photoUrl, factory_date, guarantee_period, guarantee_period_flag, lock_date, lock_date_flag, wastage_expire_date, wastage_expire_flag, component_guarantee_date, component_guarantee_flag, engineer_name, salesman_name, make_name,customer_id, customer_name, maintain_order_code, maintain_time, create_by, create_time, update_by, update_time, add_shipping_device_flag from aftersales_shipping_device + @@ -111,12 +111,47 @@ focusCleanup: true }); + /* + * 提交设备履历信息 + * */ function submitHandler() { - if ($.validate.form()) { - $.operate.save(prefix + "/edit", $('#form-addShippingDevicesOne-edit').serialize()); + // 获取表单数据 + const shippingDevicesData = $("#form-addShippingDevicesOne-edit").serializeArray().reduce((obj, item) => { + obj[item.name] = item.value; + return obj; + }, {}); + // 获取bootstrap-table的数据,这里假设你使用bootstrap-table的API获取所有数据 + // var table = $('#table-shippingDevices').bootstrapTable('getData'); + //获取选中复选框行的数据 + const selectedRows = $("#table-shippingDevices").bootstrapTable('getSelections'); + // 检查表格数据是否为空 + if (selectedRows.length===0){ + $.modal.alertWarning("请至少选择一条出货设备信息后再保存!"); + return; } + // 将表数据转换成与complaintNoticeData格式一致的数组 + var equipDetailDataList = selectedRows.map(function(item) { + // 根据实际字段名调整 + return { + "shippingDeviceId": item.shippingDeviceId, + "deviceModelCode": item.deviceModelCode, + "deviceRunningNumber": item.deviceRunningNumber, + "makePhotoUrl": item.makePhotoUrl + // ...其他字段 + }; + }); + + // 合并表单数据和表格数据 + const combinedData = Object.assign({}, shippingDevicesData, { selectShippingDeviceVOList: equipDetailDataList }); + + console.log(combinedData) + // 使用 JSON.stringify() 序列化数据 + const jsonData = JSON.stringify(combinedData); + // 发送 AJAX 请求到后端接口 + $.operate.saveJson(prefix + "/addShippingDevicesOne", jsonData); } + $("input[name='outOrderTime']").datetimepicker({ format: "yyyy-mm-dd", minView: "month", @@ -195,7 +230,7 @@ $(function(){ var options = { - id: "form-equipMaterialDetail-add", + id: "table-shippingDevices", url: prefix + "/getEquipMaterialDetailByMaterialNo", pagination: false, showSearch: false, @@ -217,22 +252,22 @@ } }, { - field: 'equipmentId', + field: 'shippingDeviceId', align: 'center', title: '出货设备id', }, { - field: 'equipmentModel', + field: 'deviceModelCode', align: 'center', title: '设备型号', }, { - field: 'serialNo', + field: 'deviceRunningNumber', align: 'center', title: '流水号', }, { - field: 'producePic', + field: 'makePhotoUrl', align: 'center', title: '生产图片', }, @@ -259,10 +294,10 @@ } function removeRow(index) { - var data = $('#form-equipMaterialDetail-add').bootstrapTable('getData'); + var data = $('#table-shippingDevices').bootstrapTable('getData'); var row = data[index]; // 获取要删除的行数据 if (row) { - $('#form-equipMaterialDetail-add').bootstrapTable('remove', { + $('#table-shippingDevices').bootstrapTable('remove', { field: 'equipmentIndex', values: [row.equipmentIndex] }); diff --git a/ruoyi-admin/src/main/resources/templates/aftersales/warehouseOutOrder/maintenanceEquipmentOne.html b/ruoyi-admin/src/main/resources/templates/aftersales/warehouseOutOrder/maintenanceEquipmentOne.html index 304c596e..3adb18d3 100644 --- a/ruoyi-admin/src/main/resources/templates/aftersales/warehouseOutOrder/maintenanceEquipmentOne.html +++ b/ruoyi-admin/src/main/resources/templates/aftersales/warehouseOutOrder/maintenanceEquipmentOne.html @@ -200,12 +200,12 @@ var childTableId = 'child_table_'+index; $detail.html('
'); $('#'+childTableId).bootstrapTable({ - url: prefix + "/showAftersalesShippingDevicelist", + url: prefix + "/showAftersalesShippingDeviceList", method: 'post', sidePagination: "server", contentType: "application/x-www-form-urlencoded", queryParams : { - salesOrderCode: warehouseOutOrder.salesOrderCode, + // salesOrderCode: warehouseOutOrder.salesOrderCode, materialNo: parentRow.materialNo }, columns: [