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 @@
-
+
+

选择设备

diff --git a/ruoyi-admin/src/main/resources/templates/aftersales/complaintNotice/add.html b/ruoyi-admin/src/main/resources/templates/aftersales/complaintNotice/add.html index 869d562e..92f34b0f 100644 --- a/ruoyi-admin/src/main/resources/templates/aftersales/complaintNotice/add.html +++ b/ruoyi-admin/src/main/resources/templates/aftersales/complaintNotice/add.html @@ -2,6 +2,8 @@ + +
@@ -60,9 +62,50 @@
+
+ + + + +
+ + + + + \ No newline at end of file