Browse Source

[feat] 售后管理

修改售后第一次维护设备出库添加出货设备前端页面:新增 submitHandler方法实现:需要维护的物料信息和不需要维护的物料信息进行整合,如果两者都为空 提示 ”没有数据可以提交“;如果两者至少有一个不为空 ,判断是否勾选了数据”请至少选择一条出货设备后再保存“;
修改 售后第一次维护设备前端页面:成品物料信息新增出货设备子表信息;可以维护设备SN号,没有值默认问”empty“;新增获取所有子表数据的前端方法getAllSubTablesData(),实现,以主表物料信息的准备出库数;如果主表的申请出库数大于子表的出货设备数,就进行要删除提示;如果小于,就进行需要添加提示;出货设备子表新增删除前端接口,删除前有一个提示;修改打开添加出货设备的addShippingDevicesOne方法,去除前端部分的url编码操作,解决多单号出现乱码问题
售后出货设备Controller层:修改 售后第一次维护设备 成品添加出货设备信息方法,和前端对接,url解码由后端操作,并且如果从前端传入的参数每个都加上校验没有值设置为null,而不是填充”null“;新增展示第一次维护设备出库,已经添加了的出货设备前端接口;新增第一次维护设备删除物料信息出货设备信息前端接口
impl层:重写 修改保存售后第一次维护设备出库后端方法,实现:处理前端需要维护设备出货的数据,加上校验,如果没有填写设备sn,要提示哪几个出货设备没有填写设备sn。同时更新售后出库单,销售出货单,仓库出库单的数据,更新出库状态
重写 售后第一次维护设备,添加出货设备信息,展示销售订单的出货设备信息后端方法,实现:添加出货设备前端列表数据,由出库单号和销售单号进行关联;修改 售后第一次维护设备,添加出货设备信息,展示其他销售订单的出货设备信息 实现:添加出货设备前端列表数据,由出库单号和销售单号进行关联;
新增 展示第一次维护设备出库,已经添加了的出货设备后端方法
新增 逻辑删除出货设备(也就是取消关联)方法
mapper层
新增 根据出库单号查询第一次维护设备已经添加的出货设备信息列表方法
新增 根据销售单号和物料号查询出货设备信息列表方法
新增 根据物料号和出库单号查询已经添加了的出货设备信息列表方法
新增 根据物料号查询出货设备信息列表方法
dev
liuxiaoxu 2 weeks ago
parent
commit
dbaa61b01a
  1. 98
      ruoyi-admin/src/main/java/com/ruoyi/aftersales/controller/AftersalesOutOrderController.java
  2. 20
      ruoyi-admin/src/main/java/com/ruoyi/aftersales/mapper/AfterSalesShippingDeviceMapper.java
  3. 9
      ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/IAftersalesOutOrderService.java
  4. 175
      ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesOutOrderServiceImpl.java
  5. 24
      ruoyi-admin/src/main/resources/mapper/aftersales/AfterSalesShippingDeviceMapper.xml
  6. 71
      ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOutOrder/addShippingDevicesOne.html
  7. 210
      ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOutOrder/maintenanceEquipmentOne.html

98
ruoyi-admin/src/main/java/com/ruoyi/aftersales/controller/AftersalesOutOrderController.java

@ -1,10 +1,13 @@
package com.ruoyi.aftersales.controller; package com.ruoyi.aftersales.controller;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
import com.ruoyi.aftersales.domain.AftersalesOutOrderDetail; import com.ruoyi.aftersales.domain.AftersalesOutOrderDetail;
import com.ruoyi.aftersales.domain.vo.SelectShippingDeviceVO; import com.ruoyi.aftersales.domain.vo.SelectShippingDeviceVO;
import com.ruoyi.aftersales.service.IAftersalesOutOrderDetailService; import com.ruoyi.aftersales.service.IAftersalesOutOrderDetailService;
import lombok.SneakyThrows;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -221,25 +224,44 @@ public class AftersalesOutOrderController extends BaseController
// //
// //
// //
/** @SneakyThrows
* 售后第一次维护设备 成品添加出货设备信息 @GetMapping("/addShippingDevicesOne")
*/ public String addShippingDevicesOne(@RequestParam("outOrderDetailId") Long outOrderDetailId,
@GetMapping("/addShippingDevicesOne") @RequestParam(value = "salesOrderCode", required = false, defaultValue = "") String salesOrderCode,
public String addShippingDevicesOne(@RequestParam("outOrderDetailId") Long outOrderDetailId, @RequestParam(value = "makeNo", required = false, defaultValue = "") String makeNo,
@RequestParam("salesOrderCode") String salesOrderCode, @RequestParam(value = "relatedOrderCode", required = false, defaultValue = "") String relatedOrderCode,
@RequestParam("makeNo") String makeNo, @RequestParam(value = "outOrderCode", required = false, defaultValue = "") String outOrderCode,
@RequestParam("relatedOrderCode") String relatedOrderCode, ModelMap mmap) {
@RequestParam("outOrderCode") String outOrderCode,
ModelMap mmap) AftersalesOutOrderDetail aftersalesOutOrderDetail = aftersalesOutOrderDetailService.selectAftersalesOutOrderDetailById(outOrderDetailId);
{
AftersalesOutOrderDetail aftersalesOutOrderDetail = aftersalesOutOrderDetailService.selectAftersalesOutOrderDetailById(outOrderDetailId);
mmap.put("salesOrderCode",salesOrderCode); // 手动解码参数
mmap.put("makeNo",makeNo); salesOrderCode = URLDecoder.decode(salesOrderCode, StandardCharsets.UTF_8.name());
mmap.put("relatedOrderCode",relatedOrderCode); makeNo = URLDecoder.decode(makeNo, StandardCharsets.UTF_8.name());
mmap.put("outOrderCode",outOrderCode); relatedOrderCode = URLDecoder.decode(relatedOrderCode, StandardCharsets.UTF_8.name());
mmap.put("aftersalesOutOrderDetail", aftersalesOutOrderDetail); outOrderCode = URLDecoder.decode(outOrderCode, StandardCharsets.UTF_8.name());
return prefix + "/addShippingDevicesOne";
// 非空检查并添加到 ModelMap
if (!"null".equalsIgnoreCase(salesOrderCode) && !salesOrderCode.isEmpty()) {
mmap.put("salesOrderCode", salesOrderCode);
}
if (!"null".equalsIgnoreCase(makeNo) && !makeNo.isEmpty()) {
mmap.put("makeNo", makeNo);
}
if (!"null".equalsIgnoreCase(relatedOrderCode) && !relatedOrderCode.isEmpty()) {
mmap.put("relatedOrderCode", relatedOrderCode);
} }
if (!"null".equalsIgnoreCase(outOrderCode) && !outOrderCode.isEmpty()) {
mmap.put("outOrderCode", outOrderCode);
}
// 无论是否为空,都添加 aftersalesOutOrderDetail
mmap.put("aftersalesOutOrderDetail", aftersalesOutOrderDetail);
return prefix + "/addShippingDevicesOne";
}
@ -285,6 +307,26 @@ public class AftersalesOutOrderController extends BaseController
return toAjax(aftersalesOutOrderService.addShippingDevicesOne(aftersalesOutOrder)); return toAjax(aftersalesOutOrderService.addShippingDevicesOne(aftersalesOutOrder));
} }
/**
* 展示第一次维护设备出库已经添加了的出货设备
*/
@ResponseBody
@PostMapping("/showAddShippingDevicesOne")
public TableDataInfo showAddShippingDevicesOne(AftersalesOutOrder aftersalesOutOrder)
{
startPage();
List<SelectShippingDeviceVO> list = aftersalesOutOrderService.showAddShippingDevicesOne(aftersalesOutOrder);
return getDataTable(list);
}
// //
// //
// //
@ -303,16 +345,16 @@ public class AftersalesOutOrderController extends BaseController
// //
// //
// //
// /** /**
// * 第一次维护设备删除物料信息出货设备信息 * 第一次维护设备删除物料信息出货设备信息
// */ */
// @Log(title = "售后维护设备出库", businessType = BusinessType.DELETE) @Log(title = "售后维护设备出库", businessType = BusinessType.DELETE)
// @PostMapping("/deleteRow") @PostMapping("/deleteRow")
// @ResponseBody @ResponseBody
// public AjaxResult deleteRow(String shippingDeviceId) public AjaxResult deleteRow(String shippingDeviceId)
// { {
// return toAjax(aftersalesOutOrderService.deleteAftersalesShippingDeviceById(shippingDeviceId)); return toAjax(aftersalesOutOrderService.deleteAftersalesShippingDeviceById(shippingDeviceId));
// } }

20
ruoyi-admin/src/main/java/com/ruoyi/aftersales/mapper/AfterSalesShippingDeviceMapper.java

@ -141,4 +141,24 @@ public interface AfterSalesShippingDeviceMapper
* 根据设备id批量查询出货设备信息列表 * 根据设备id批量查询出货设备信息列表
* */ * */
List<AfterSalesShippingDevice> selectBatchShippingDeviceById(List<String> otherShippingDeviceIds); List<AfterSalesShippingDevice> selectBatchShippingDeviceById(List<String> otherShippingDeviceIds);
/*
* 根据出库单号查询第一次维护设备已经添加的出货设备信息列表
* */
List<AfterSalesShippingDevice> selectShippingDeviceByOutOrderCode(String outOrderCode);
/*
* 根据销售单号和物料号查询出货设备信息列表
* */
List<AfterSalesShippingDevice> selectShippingDeviceByOrderCodeAndMaterialNo(AfterSalesShippingDevice afterSalesShippingDevice);
/*
* 根据物料号和出库单号查询已经添加了的出货设备信息列表
* */
List<AfterSalesShippingDevice> selectHasAddShippingDevice(AfterSalesShippingDevice tempShippingDevice);
/*
* 根据物料号查询出货设备信息列表
* */
List<AfterSalesShippingDevice> selectShippingDevicesByMaterialNo(String materialNo);
} }

9
ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/IAftersalesOutOrderService.java

@ -112,4 +112,13 @@ public interface IAftersalesOutOrderService
* */ * */
int addShippingDevicesOne(AftersalesOutOrder aftersalesOutOrder); int addShippingDevicesOne(AftersalesOutOrder aftersalesOutOrder);
/**
* 展示第一次维护设备出库已经添加了的出货设备
* */
List<SelectShippingDeviceVO> showAddShippingDevicesOne(AftersalesOutOrder aftersalesOutOrder);
/**
* 逻辑删除出货设备也就是取消关联
* */
int deleteAftersalesShippingDeviceById(String shippingDeviceId);
} }

175
ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesOutOrderServiceImpl.java

@ -1,9 +1,6 @@
package com.ruoyi.aftersales.service.impl; package com.ruoyi.aftersales.service.impl;
import java.util.ArrayList; import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.ruoyi.aftersales.domain.AfterSalesShippingDevice; import com.ruoyi.aftersales.domain.AfterSalesShippingDevice;
@ -15,12 +12,18 @@ import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysSalesShippingInform;
import com.ruoyi.system.mapper.SysSalesShippingInformMapper;
import com.ruoyi.warehouse.domain.WarehouseOutOrder;
import com.ruoyi.warehouse.mapper.WarehouseOutOrderMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.aftersales.mapper.AftersalesOutOrderMapper; import com.ruoyi.aftersales.mapper.AftersalesOutOrderMapper;
import com.ruoyi.aftersales.domain.AftersalesOutOrder; import com.ruoyi.aftersales.domain.AftersalesOutOrder;
import com.ruoyi.aftersales.service.IAftersalesOutOrderService; import com.ruoyi.aftersales.service.IAftersalesOutOrderService;
import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.core.text.Convert;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
/** /**
* 售后维护设备出库Service业务层处理 * 售后维护设备出库Service业务层处理
@ -40,6 +43,12 @@ public class AftersalesOutOrderServiceImpl implements IAftersalesOutOrderService
@Autowired @Autowired
private AfterSalesShippingDeviceMapper afterSalesShippingDeviceMapper; private AfterSalesShippingDeviceMapper afterSalesShippingDeviceMapper;
@Autowired
private WarehouseOutOrderMapper warehouseOutOrderMapper;
@Autowired
private SysSalesShippingInformMapper shippingInformMapper;
/** /**
* 查询售后维护设备出库 * 查询售后维护设备出库
* *
@ -148,24 +157,87 @@ public class AftersalesOutOrderServiceImpl implements IAftersalesOutOrderService
* @param aftersalesOutOrder * @param aftersalesOutOrder
* @return * @return
*/ */
@Transactional(rollbackFor = Exception.class)
@Override @Override
public int updateMaintenanceEquipmentOne(AftersalesOutOrder aftersalesOutOrder) { public int updateMaintenanceEquipmentOne(AftersalesOutOrder aftersalesOutOrder) {
String outOrderCode = aftersalesOutOrder.getOutOrderCode(); String outOrderCode = aftersalesOutOrder.getOutOrderCode();
int updateResult = 0;
List<SelectShippingDeviceVO> selectShippingDeviceVOList = aftersalesOutOrder.getSelectShippingDeviceVOList(); // 定义一个StringBuilder来收集所有缺少SN号的设备ID
for (SelectShippingDeviceVO selectShippingDeviceVO : selectShippingDeviceVOList) { StringBuilder missingSnIds = new StringBuilder();
AfterSalesShippingDevice afterSalesShippingDevice = new AfterSalesShippingDevice(); //物料信息主表的数据
afterSalesShippingDevice.setShippingDeviceId(selectShippingDeviceVO.getShippingDeviceId()); List<AftersalesOutOrderDetail> needShippingDeviceMaterialsOne = this.getNeedShippingDeviceMaterialsOne(aftersalesOutOrder);
afterSalesShippingDevice.setAddShippingDeviceFlag("0"); if (!CollectionUtils.isEmpty(needShippingDeviceMaterialsOne)){
afterSalesShippingDevice.setOutOrderCode(outOrderCode); List<SelectShippingDeviceVO> selectShippingDeviceVOList = aftersalesOutOrder.getSelectShippingDeviceVOList();
updateResult = afterSalesShippingDeviceMapper.updateAfterSalesShippingDevice(afterSalesShippingDevice); if (CollectionUtils.isEmpty(selectShippingDeviceVOList)){
if (updateResult <= 0){ throw new BusinessException("请展开物料详情并添加要出货的设备");
throw new BusinessException("更新出货设备信息失败"); }
// boolean anyNullSnCode = selectShippingDeviceVOList.stream().anyMatch(item -> item.getSnCode() == null);
// if (anyNullSnCode){
// throw new BusinessException("请展开物料详情并填写每个设备的SN号");
// }
// 遍历 selectShippingDeviceVOList 列表
selectShippingDeviceVOList.forEach(item -> {
// 检查 SnCode 是否为空
if (item.getSnCode() == null) {
// 如果是第一次添加,不加前缀“、”,否则加上
if (missingSnIds.length() > 0) {
missingSnIds.append("、");
}
missingSnIds.append(item.getShippingDeviceId());
}
});
// 检查是否有任何设备缺少SN号
if (missingSnIds.length() > 0) {
throw new BusinessException(missingSnIds.toString() + " SN未维护,请维护");
} }
/* 缺少校验规则后续补充
* 2.1已选出货设备是否可用(状态:可用即未被其他出库单添加或报损)若不可用则弹窗提示CHSB20240808004CHSB20240808005.不可用请重新添加
* */
for (SelectShippingDeviceVO selectShippingDeviceVO : selectShippingDeviceVOList) {
String shippingDeviceId = selectShippingDeviceVO.getShippingDeviceId();
AfterSalesShippingDevice tempShippingDevice = new AfterSalesShippingDevice();
tempShippingDevice.setShippingDeviceId(shippingDeviceId);
tempShippingDevice.setSnCode(selectShippingDeviceVO.getSnCode());
int updateShippingDeviceResult = afterSalesShippingDeviceMapper.updateAfterSalesShippingDevice(tempShippingDevice);
if (updateShippingDeviceResult <= 0){
throw new BusinessException("更新设备数据失败");
}
}
}
//更新出库单
WarehouseOutOrder warehouseOutOrder = new WarehouseOutOrder();
//更改状态未待确认发货
warehouseOutOrder.setOutOrderCode(outOrderCode);
warehouseOutOrder.setWarehouseOutStatus("2");
int updateWarehouseResult = warehouseOutOrderMapper.updateWarehouseOutOrderByCode(warehouseOutOrder);
if (updateWarehouseResult <= 0){
throw new BusinessException("更新销售售后通知单数据失败");
} }
return updateResult; //更新销售出货通知单
SysSalesShippingInform sysSalesShippingInform = new SysSalesShippingInform();
sysSalesShippingInform.setOutOrderCode(outOrderCode);
sysSalesShippingInform.setWarehouseOutStatus("2");
int updateShippingInformResult = shippingInformMapper.updateSysSalesShippingInformByOutOrderCode(sysSalesShippingInform);
if (updateShippingInformResult <= 0){
throw new BusinessException("更新销售出货通知单数据失败");
}
//更新售后维护设备出库单
aftersalesOutOrder.setWarehouseOutStatus("2");
int result = aftersalesOutOrderMapper.updateAftersalesOutOrder(aftersalesOutOrder);
return result;
} }
/** /**
@ -225,22 +297,41 @@ public class AftersalesOutOrderServiceImpl implements IAftersalesOutOrderService
* */ * */
@Override @Override
public List<SelectShippingDeviceVO> getThisSalesOrderShippingDevices(AftersalesOutOrder aftersalesOutOrder) { public List<SelectShippingDeviceVO> getThisSalesOrderShippingDevices(AftersalesOutOrder aftersalesOutOrder) {
// 输入验证
if (aftersalesOutOrder == null || StringUtils.isEmpty(aftersalesOutOrder.getRelatedOrderCode()) &&
StringUtils.isEmpty(aftersalesOutOrder.getSalesOrderCode())) {
return Collections.emptyList();
}
List<SelectShippingDeviceVO> selectShippingDeviceVOS = new ArrayList<>(); List<SelectShippingDeviceVO> selectShippingDeviceVOS = new ArrayList<>();
String materialNo = aftersalesOutOrder.getMaterialNo();
String relatedOrderCode = aftersalesOutOrder.getRelatedOrderCode(); // 优先使用销售订单号关联
String salesOrderCode = aftersalesOutOrder.getSalesOrderCode(); if (StringUtils.isNotEmpty(aftersalesOutOrder.getSalesOrderCode())) {
//优先使用销售订单号关联 AfterSalesShippingDevice tempAfterSalesShippingDevice = new AfterSalesShippingDevice();
if (StringUtils.isNotEmpty(salesOrderCode)){ tempAfterSalesShippingDevice.setMaterialNo(materialNo);
List<AfterSalesShippingDevice> afterSalesShippingDevices = afterSalesShippingDeviceMapper.selectShippingDeviceBySalesOrderCode(salesOrderCode); tempAfterSalesShippingDevice.setSalesOrderCode(aftersalesOutOrder.getSalesOrderCode());
convertToDeviceVOs(afterSalesShippingDevices, selectShippingDeviceVOS);
}else { List<AfterSalesShippingDevice> afterSalesShippingDevices = afterSalesShippingDeviceMapper.selectShippingDeviceByOrderCodeAndMaterialNo(tempAfterSalesShippingDevice);
// 关联订单号可能存在逗号分隔的情况
String[] splitRelatedOrderCode = relatedOrderCode.split(",");
List<AfterSalesShippingDevice> afterSalesShippingDevices = afterSalesShippingDeviceMapper.selectBatchShippingDeviceBySalesOrderCode(splitRelatedOrderCode);
convertToDeviceVOs(afterSalesShippingDevices, selectShippingDeviceVOS); convertToDeviceVOs(afterSalesShippingDevices, selectShippingDeviceVOS);
// 提前返回
return selectShippingDeviceVOS;
} }
// 处理关联订单号
String relatedOrderCode = aftersalesOutOrder.getRelatedOrderCode();
Arrays.stream(relatedOrderCode.split(","))
.map(String::trim)
.forEach(code -> {
AfterSalesShippingDevice tempAfterSalesShippingDevice = new AfterSalesShippingDevice();
tempAfterSalesShippingDevice.setMaterialNo(materialNo);
tempAfterSalesShippingDevice.setSalesOrderCode(code);
List<AfterSalesShippingDevice> afterSalesShippingDevices = afterSalesShippingDeviceMapper.selectShippingDeviceByOrderCodeAndMaterialNo(tempAfterSalesShippingDevice);
convertToDeviceVOs(afterSalesShippingDevices, selectShippingDeviceVOS);
});
return selectShippingDeviceVOS; return selectShippingDeviceVOS;
} }
@ -253,13 +344,14 @@ public class AftersalesOutOrderServiceImpl implements IAftersalesOutOrderService
List<SelectShippingDeviceVO> selectShippingDeviceVOS = new ArrayList<>(); List<SelectShippingDeviceVO> selectShippingDeviceVOS = new ArrayList<>();
String outOrderCode = aftersalesOutOrder.getOutOrderCode(); String outOrderCode = aftersalesOutOrder.getOutOrderCode();
String materialNo = aftersalesOutOrder.getMaterialNo();
List<SelectShippingDeviceVO> thisSalesOrderShippingDevices = this.getThisSalesOrderShippingDevices(aftersalesOutOrder); List<SelectShippingDeviceVO> thisSalesOrderShippingDevices = this.getThisSalesOrderShippingDevices(aftersalesOutOrder);
// 查找到当前销售订单的出货设备ID集合 // 查找到当前销售订单的出货设备ID集合
List<String> currentShippingDeviceIds = thisSalesOrderShippingDevices.stream() List<String> currentShippingDeviceIds = thisSalesOrderShippingDevices.stream()
.map(SelectShippingDeviceVO::getShippingDeviceId) .map(SelectShippingDeviceVO::getShippingDeviceId)
.collect(Collectors.toList()); .collect(Collectors.toList());
//查找到所有出货设备id集合 //查找到所有出货设备id集合
List<AfterSalesShippingDevice> afterSalesShippingDevices = afterSalesShippingDeviceMapper.selectAllShippingDevices(); List<AfterSalesShippingDevice> afterSalesShippingDevices = afterSalesShippingDeviceMapper.selectShippingDevicesByMaterialNo(materialNo);
//保留是否添加出货设备等于1的,以及等于0且出库单号等于本单据的 //保留是否添加出货设备等于1的,以及等于0且出库单号等于本单据的
List<AfterSalesShippingDevice> filteredDevices = afterSalesShippingDevices.stream().filter(device -> "1".equals(device.getAddShippingDeviceFlag()) List<AfterSalesShippingDevice> filteredDevices = afterSalesShippingDevices.stream().filter(device -> "1".equals(device.getAddShippingDeviceFlag())
@ -289,4 +381,35 @@ public class AftersalesOutOrderServiceImpl implements IAftersalesOutOrderService
} }
/**
* 展示第一次维护设备出库已经添加了的出货设备
* */
@Override
public List<SelectShippingDeviceVO> showAddShippingDevicesOne(AftersalesOutOrder aftersalesOutOrder) {
String outOrderCode = aftersalesOutOrder.getOutOrderCode();
String materialNo = aftersalesOutOrder.getMaterialNo();
List<SelectShippingDeviceVO> selectShippingDeviceVOS = new ArrayList<>();
AfterSalesShippingDevice tempShippingDevice = new AfterSalesShippingDevice();
tempShippingDevice.setMaterialNo(materialNo);
tempShippingDevice.setOutOrderCode(outOrderCode);
List<AfterSalesShippingDevice> afterSalesShippingDevices = afterSalesShippingDeviceMapper.selectHasAddShippingDevice(tempShippingDevice);
convertToDeviceVOs(afterSalesShippingDevices, selectShippingDeviceVOS);
return selectShippingDeviceVOS;
}
/**
* 逻辑删除出货设备也就是取消关联
* */
@Override
public int deleteAftersalesShippingDeviceById(String shippingDeviceId) {
AfterSalesShippingDevice tempShippingDevice = new AfterSalesShippingDevice();
tempShippingDevice.setAddShippingDeviceFlag("1");
tempShippingDevice.setShippingDeviceId(shippingDeviceId);
tempShippingDevice.setOutOrderCode("");
int updateAfterSalesShippingDevice = afterSalesShippingDeviceMapper.updateAfterSalesShippingDevice(tempShippingDevice);
return updateAfterSalesShippingDevice;
}
} }

24
ruoyi-admin/src/main/resources/mapper/aftersales/AfterSalesShippingDeviceMapper.xml

@ -154,6 +154,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach> </foreach>
</select> </select>
<select id="selectShippingDeviceByOutOrderCode" parameterType="String" resultMap="AfterSalesShippingDeviceResult">
<include refid="selectAfterSalesShippingDeviceVo"/>
where out_order_code = #{outOrderCode}
and add_shipping_device_flag = '0'
</select>
<select id="selectShippingDeviceByOrderCodeAndMaterialNo" parameterType="AfterSalesShippingDevice" resultMap="AfterSalesShippingDeviceResult">
<include refid="selectAfterSalesShippingDeviceVo"/>
where sales_order_code = #{salesOrderCode}
and material_no = #{materialNo}
</select>
<select id="selectHasAddShippingDevice" parameterType="AfterSalesShippingDevice" resultMap="AfterSalesShippingDeviceResult">
<include refid="selectAfterSalesShippingDeviceVo"/>
where out_order_code = #{outOrderCode}
and material_no = #{materialNo}
and add_shipping_device_flag = '0'
</select>
<select id="selectShippingDevicesByMaterialNo" parameterType="String" resultMap="AfterSalesShippingDeviceResult">
<include refid="selectAfterSalesShippingDeviceVo"/>
where material_no = #{materialNo}
</select>
<insert id="insertAfterSalesShippingDevice" parameterType="AfterSalesShippingDevice" useGeneratedKeys="true" keyProperty="shippingDeviceCode"> <insert id="insertAfterSalesShippingDevice" parameterType="AfterSalesShippingDevice" useGeneratedKeys="true" keyProperty="shippingDeviceCode">
insert into aftersales_shipping_device insert into aftersales_shipping_device

71
ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOutOrder/addShippingDevicesOne.html

@ -124,46 +124,53 @@
obj[item.name] = item.value; obj[item.name] = item.value;
return obj; return obj;
}, {}); }, {});
// 获取bootstrap-table的数据,这里假设你使用bootstrap-table的API获取所有数据
// var table = $('#table-shippingDevices').bootstrapTable('getData');
//获取选中复选框行的数据 //获取选中复选框行的数据
const selectedThisRows = $("#thisSalesOrderShippingDevice-table").bootstrapTable('getSelections'); const selectedThisRows = $("#thisSalesOrderShippingDevice-table").bootstrapTable('getSelections');
const selectedOtherRows = $("#otherSalesOrderShippingDevice-table").bootstrapTable('getSelections'); const selectedOtherRows = $("#otherSalesOrderShippingDevice-table").bootstrapTable('getSelections');
//获取所有数据
const allThisRows = $("#thisSalesOrderShippingDevice-table").bootstrapTable('getData');
const allOtherRows = $("#otherSalesOrderShippingDevice-table").bootstrapTable('getData');
// 将 outOrderCode 添加到 shippingDevicesData 对象中 // 将 outOrderCode 添加到 shippingDevicesData 对象中
shippingDevicesData.outOrderCode = outOrderCode; shippingDevicesData.outOrderCode = outOrderCode;
// 检查表格数据是否为空 // 检查是否有数据可以提交
if (selectedThisRows.length + selectedOtherRows.length === 0) { if (allThisRows.length === 0 && allOtherRows.length === 0) {
$.modal.alertWarning("请至少选择一条出货设备后再保存!"); $.modal.alertWarning("没有数据可以提交!");
return; return;
} }
// 将表数据转换成一致的数组 // 检查表格数据是否为空
const equipDetailDataList = [ if (selectedThisRows.length + selectedOtherRows.length === 0) {
...selectedThisRows.map(item => ({ $.modal.alertWarning("请至少选择一条出货设备后再保存!");
"shippingDeviceId": item.shippingDeviceId, return;
"deviceModelCode": item.deviceModelCode, }
"deviceRunningNumber": item.deviceRunningNumber, // 将表数据转换成一致的数组
"makePhotoUrl": item.makePhotoUrl const equipDetailDataList = [
// ...其他字段 ...selectedThisRows.map(item => ({
})), "shippingDeviceId": item.shippingDeviceId,
...selectedOtherRows.map(item => ({ "deviceModelCode": item.deviceModelCode,
"shippingDeviceId": item.shippingDeviceId, "deviceRunningNumber": item.deviceRunningNumber,
"deviceModelCode": item.deviceModelCode, "makePhotoUrl": item.makePhotoUrl
"deviceRunningNumber": item.deviceRunningNumber, // ...其他字段
"makePhotoUrl": item.makePhotoUrl })),
// ...其他字段 ...selectedOtherRows.map(item => ({
})) "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); // 合并表单数据和表格数据
const combinedData = Object.assign({}, shippingDevicesData, { selectShippingDeviceVOList: equipDetailDataList });
console.log(combinedData)
// 使用 JSON.stringify() 序列化数据
const jsonData = JSON.stringify(combinedData);
// 发送 AJAX 请求到后端接口
$.operate.saveJson(prefix + "/addShippingDevicesOne", jsonData);
} }

210
ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOutOrder/maintenanceEquipmentOne.html

@ -260,49 +260,76 @@
}) })
// initChildTable = function(index, row, $detail) { initChildTable = function(index, row, $detail) {
// var parentRow = row; var parentRow = row;
// var childTableId = 'child_table_'+index; var childTableId = 'child_table_'+index;
// $detail.html('<table id="'+childTableId+'"></table>'); $detail.html('<table id="'+childTableId+'"></table>');
// $('#'+childTableId).bootstrapTable({ $('#'+childTableId).bootstrapTable({
// url: prefix + "/showAftersalesShippingDeviceListOne", url: prefix + "/showAddShippingDevicesOne",
// method: 'post', method: 'post',
// sidePagination: "server", sidePagination: "server",
// contentType: "application/x-www-form-urlencoded", contentType: "application/x-www-form-urlencoded",
// queryParams : { queryParams : {
// // salesOrderCode: aftersalesOutOrder.salesOrderCode, outOrderCode: aftersalesOutOrder.outOrderCode,
// materialNo: parentRow.materialNo, materialNo: parentRow.materialNo,
// salesOrderCode:aftersalesOutOrder.salesOrderCode, // salesOrderCode:aftersalesOutOrder.salesOrderCode,
// makeNo:aftersalesOutOrder.makeNo // makeNo:aftersalesOutOrder.makeNo
// }, },
// columns: [ columns: [
// { {
// title: '出货设备ID', title: '出货设备ID',
// field: 'shippingDeviceId', field: 'shippingDeviceId',
// }, },
// { {
// title: '设备型号', title: '设备型号',
// field: 'deviceModelCode', field: 'deviceModelCode',
// }, },
// { {
// title: '流水号', title: '追踪码',
// field: 'deviceRunningNumber', field: 'deviceRunningNumber',
// }, },
// { {
// title: '设备SN号', title: '设备SN号',
// field: 'snCode', field: 'snCode',
// editable:true editable: {
// }, validate: function(value) {
// { if ($.trim(value) === '') {
// title: '操作', return '本次收货数不能为空';
// align: 'center', }
// formatter: function (value, row, index) { },
// return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="deleteRow(\'' + row.shippingDeviceId + '\')"><i class="fa fa-remove"></i>删除</a>'; },
// }
// }
// ], formatter: function (value, row) {
// }); // 检查 snCode 是否存在
// }; if (row.snCode === undefined || row.snCode === null) {
return "";
}
// 根据 snCode 的值决定返回值
if (row.snCode) {
return row.snCode;
} else {
return value;
}
}
},
// {
// title: '售后图片',
// field: 'deviceRunningNumber',
// },
{
title: '操作',
align: 'center',
formatter: function (value, row, index) {
return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="deleteRow(\'' + row.shippingDeviceId + '\')"><i class="fa fa-remove"></i>删除</a>';
}
}
],
});
};
function queryParams(params) { function queryParams(params) {
@ -393,51 +420,71 @@
// 获取所有子表数据的函数
// 获取所有子表数据的函数 // 获取所有子表数据的函数
function getAllSubTablesData() { function getAllSubTablesData() {
var allSubData = []; var allSubData = [];
// 获取所有被展开的行 var parentData = $("#needShippingDevice-table").bootstrapTable("getData");
var parentLength = $("#bootstrap-table").bootstrapTable("getData").length; var parentLength = parentData.length;
for (let i = 0; i < parentLength; i++) {
var sonData = $('#'+"child_table_" + i).bootstrapTable("getData"); if (parentLength !== 0) {
//循环获取子表中存在的行数据,每个行数据转换添加到allSubData数组中 for (let i = 0; i < parentLength; i++) {
allSubData = allSubData.concat(sonData); var sonData = $("#" + "child_table_" + i).bootstrapTable("getData");
allSubData = allSubData.concat(sonData);
// 获取主表的准备出库数
var prepareOutOrderSum = parentData[i].prepareOutOrderSum;
var sonDataLength = sonData.length;
// 比较主表的准备出库数和子表的长度
if (sonDataLength < prepareOutOrderSum) {
$.modal.alertWarning(`物料第 ${i + 1} 行的准备出库数为 ${prepareOutOrderSum},但已经添加出货设备为 ${sonDataLength},请添加出货设备`);
return;
}else if(sonDataLength > prepareOutOrderSum){
$.modal.alertWarning(`物料第 ${i + 1} 行的准备出库数为 ${prepareOutOrderSum},但已经添加出货设备为 ${sonDataLength},请删除出货设备`);
return;
}
}
} }
return allSubData; return allSubData;
} }
function deleteRow(shippingDeviceId) {
function deleteRow(shippingDeviceId, index) {
// 弹出确认框询问用户是否确定删除 // 弹出确认框询问用户是否确定删除
if (confirm("确定要删除这条记录吗?")) { $.modal.confirm("确定要删除这条记录吗?", function(confirmed) {
// 发送删除请求到服务器 if (confirmed) {
$.ajax({ // 发送删除请求到服务器
url: prefix + "/deleteRow", // 请根据实际API路径调整 $.ajax({
type: 'POST', url: prefix + "/deleteRow", // 请根据实际API路径调整
data: { type: 'POST',
shippingDeviceId: shippingDeviceId, // 传递需要删除的记录的ID data: {
}, shippingDeviceId: shippingDeviceId, // 传递需要删除的记录的ID
success: function(result) { },
if (result.success) { // 假设result是一个对象,包含success属性来表示操作是否成功 success: function(result) {
// 删除操作成功,从表格中移除这一行 handleDeleteResponse(result, shippingDeviceId, index);
$('#child_table_' + index).bootstrapTable('remove', { },
field: 'shippingDeviceId', error: function(xhr, status, error) {
values: [shippingDeviceId] $.modal.msgError("发生错误,删除失败: " + xhr.responseText);
});
toastr.success("删除成功!"); // 显示成功提示信息,这里使用toastr作为示例,确保已引入相关库
} else {
toastr.error("删除失败: " + result.message); // 显示失败原因,同样确保已引入toastr库
} }
}, });
error: function() { }
toastr.error("发生错误,删除失败!"); // 网络错误或后端错误处理 });
} }
function handleDeleteResponse(result, shippingDeviceId, index) {
if (result.code === 0) {
// 删除操作成功,从表格中移除这一行
$('#child_table_' + index).bootstrapTable('remove', {
field: 'shippingDeviceId',
values: [shippingDeviceId]
}); });
$.modal.msgSuccess("删除成功,请刷新表格");
} else {
$.modal.msgError("删除失败: " + result.message);
} }
}; }
/*添加出货设备*/ /*添加出货设备*/
@ -454,10 +501,13 @@
var makeNo = [[${aftersalesOutOrder.makeNo}]]; var makeNo = [[${aftersalesOutOrder.makeNo}]];
var queryParams = new URLSearchParams(); var queryParams = new URLSearchParams();
queryParams.append('outOrderDetailId', outOrderDetailId); queryParams.append('outOrderDetailId', outOrderDetailId);
queryParams.append('salesOrderCode', encodeURIComponent(salesOrderCode));
queryParams.append('makeNo',encodeURIComponent(makeNo)); // 仅对需要编码的部分进行编码
queryParams.append('relatedOrderCode',encodeURIComponent(relatedOrderCode)); queryParams.append('salesOrderCode', salesOrderCode);
queryParams.append('outOrderCode',encodeURIComponent(outOrderCode)); queryParams.append('makeNo', makeNo);
queryParams.append('relatedOrderCode', relatedOrderCode);
queryParams.append('outOrderCode', outOrderCode);
var url = prefix + '/addShippingDevicesOne?' + queryParams.toString(); var url = prefix + '/addShippingDevicesOne?' + queryParams.toString();
$.modal.open("添加出货设备", url); $.modal.open("添加出货设备", url);
} }

Loading…
Cancel
Save