From bf8cf166f73d9466c68534957332cd572489f67e Mon Sep 17 00:00:00 2001 From: liuxiaoxu <1793812695@qq.com> Date: Thu, 23 May 2024 16:06:11 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=E5=94=AE=E5=90=8E=E7=AE=A1=E7=90=86:=20?= =?UTF-8?q?=E5=94=AE=E5=90=8E=E5=8D=95=20=E4=BF=AE=E6=94=B9=E5=94=AE?= =?UTF-8?q?=E5=90=8E=E8=AF=A6=E6=83=85=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9=E6=9F=A5=E8=AF=A2=E9=80=BB=E8=BE=91?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9=E6=B4=BE=E5=8D=95=E5=92=8C=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E6=8A=A5=E5=91=8A=E7=9A=84=E8=A1=A8=E6=A0=BC=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=20=E4=BF=AE=E6=94=B9=E4=B8=8A=E4=BC=A0=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E4=B8=9A=E5=8A=A1=E9=80=BB=E8=BE=91=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=A0=B9=E6=8D=AEid=E5=92=8C=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E9=99=84=E4=BB=B6=E4=BF=A1=E6=81=AF=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=A0=B9=E6=8D=AEid=E5=92=8C=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E6=9B=B4=E6=96=B0=E9=99=84=E4=BB=B6=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/AftersalesOrderServiceImpl.java | 41 +++++++++++++++---- .../ruoyi/system/mapper/SysAttachMapper.java | 13 ++++++ .../mapper/system/SysAttachMapper.xml | 22 +++++++++- .../aftersalesOrder/aftersalesOrder.html | 23 ----------- .../aftersalesOrder/sendOrders.html | 5 ++- .../aftersalesOrder/uploadReport.html | 3 +- 6 files changed, 71 insertions(+), 36 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesOrderServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesOrderServiceImpl.java index 87c508c7..8e9fd296 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesOrderServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesOrderServiceImpl.java @@ -8,6 +8,7 @@ import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.domain.SysAttach; +import com.ruoyi.system.mapper.SysAttachMapper; import com.ruoyi.system.service.ISysAttachFileService; import com.ruoyi.system.service.ISysAttachService; import org.springframework.beans.factory.annotation.Autowired; @@ -16,6 +17,7 @@ import com.ruoyi.aftersales.mapper.AftersalesOrderMapper; import com.ruoyi.aftersales.domain.AftersalesOrder; import com.ruoyi.aftersales.service.IAftersalesOrderService; import com.ruoyi.common.core.text.Convert; +import org.springframework.transaction.annotation.Transactional; /** * 售后单Service业务层处理 @@ -35,6 +37,10 @@ public class AftersalesOrderServiceImpl implements IAftersalesOrderService @Autowired private ISysAttachFileService attachFileService; + + @Autowired + private SysAttachMapper sysAttachMapper; + /** * 查询售后单 * @@ -96,6 +102,7 @@ public class AftersalesOrderServiceImpl implements IAftersalesOrderService * @param aftersalesOrder 售后单 * @return 结果 */ + @Transactional @Override public int updateAftersalesOrder(AftersalesOrder aftersalesOrder) { @@ -104,17 +111,33 @@ public class AftersalesOrderServiceImpl implements IAftersalesOrderService aftersalesOrder.setUpdateTime(DateUtils.getNowDate()); Long aftersalesOrderId = aftersalesOrder.getAftersalesOrderId(); String fileIdStr = aftersalesOrder.getFileIdStr(); + Long attachId = null; if (StringUtils.isNotEmpty(fileIdStr)){ - //保存文件附件关联 - SysAttach sysAttach = new SysAttach(); - sysAttach.setCreateBy(ShiroUtils.getLoginName()); - sysAttach.setCreateTime(new Date()); - sysAttach.setSourceType("aftersalesOrder"); - sysAttach.setSourceSubType("photo"); - sysAttach.setRelId(aftersalesOrderId); - attachService.insertSysAttach(sysAttach); + SysAttach tempSysAttach = new SysAttach(); + tempSysAttach.setSourceType("aftersalesOrder"); + tempSysAttach.setSourceSubType("photo"); + tempSysAttach.setRelId(aftersalesOrderId); + List sysAttaches = attachService.selectSysAttachList(tempSysAttach); + if (StringUtils.isEmpty(sysAttaches)){ + // 保存新的文件附件关联 + SysAttach newSysAttach = new SysAttach(); + newSysAttach.setCreateBy(loginName); + newSysAttach.setCreateTime(new Date()); + newSysAttach.setSourceType("aftersalesOrder"); + newSysAttach.setSourceSubType("photo"); + newSysAttach.setRelId(aftersalesOrderId); + attachService.insertSysAttach(newSysAttach); + // 假设insert后可以通过某种方式(如返回值)获取到新生成的ID,这里需要根据实际情况调整 + attachId = newSysAttach.getId(); // 确保这里能正确获取到ID + }else { + // 更新已存在的附件信息 + SysAttach sysAttachToUpdate = sysAttaches.get(0); // 假设只有一条记录,或按需处理多条 + sysAttachToUpdate.setUpdateBy(loginName); + sysAttachToUpdate.setUpdateTime(new Date()); + attachService.updateSysAttach(sysAttachToUpdate); // 假定有一个通用的更新方法 + attachId = sysAttachToUpdate.getId(); + } //更新附件与文件关联 - Long attachId = sysAttach.getId(); List fileIdList = Arrays.asList(fileIdStr.split(",")); attachFileService.updateAttachIdByIdList(attachId,fileIdList); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysAttachMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysAttachMapper.java index 5c1ecc08..e86c0694 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysAttachMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysAttachMapper.java @@ -20,6 +20,10 @@ public interface SysAttachMapper */ public SysAttach selectSysAttachById(Long id); + + + + /** * 查询附件业务关联列表 * @@ -44,6 +48,15 @@ public interface SysAttachMapper */ public int updateSysAttach(SysAttach sysAttach); + + /** + * 根据多个条件修改附件业务关联 + * + * @param sysAttach 附件业务关联 + * @return 结果 + */ + public int updateSysAttachByIdAndSourceType(SysAttach sysAttach); + /** * 删除附件业务关联 * diff --git a/ruoyi-admin/src/main/resources/mapper/system/SysAttachMapper.xml b/ruoyi-admin/src/main/resources/mapper/system/SysAttachMapper.xml index a623fe7d..fe269af2 100644 --- a/ruoyi-admin/src/main/resources/mapper/system/SysAttachMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/system/SysAttachMapper.xml @@ -34,7 +34,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} - + + insert into sys_attach @@ -77,6 +78,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} + + + update sys_attach + + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + rel_id = #{relId}, + source_type = #{sourceType}, + source_sub_type = #{sourceSubType}, + + where rel_id = #{relId} + and source_type = #{sourceType} + and source_sub_type = #{sourceSubType} + + delete from sys_attach where id = #{id} diff --git a/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/aftersalesOrder.html b/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/aftersalesOrder.html index 961cfa53..d294cf99 100644 --- a/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/aftersalesOrder.html +++ b/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/aftersalesOrder.html @@ -47,21 +47,6 @@ - - - - - - - - - - - - - - -
@@ -71,8 +56,6 @@ diff --git a/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/sendOrders.html b/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/sendOrders.html index 2447c6b0..c566658a 100644 --- a/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/sendOrders.html +++ b/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/sendOrders.html @@ -66,13 +66,14 @@ - -
+
+

选择设备

+

派单

diff --git a/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/uploadReport.html b/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/uploadReport.html index a6dfba35..8165cb9c 100644 --- a/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/uploadReport.html +++ b/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/uploadReport.html @@ -69,7 +69,8 @@
-
+
+

选择设备