Browse Source

复制增加原材料清单选项

ecss-tx
han\hanst 2 months ago
parent
commit
988fe7c284
  1. 19
      src/main/java/com/xujie/sys/modules/erf/controller/ErfExpApplyController.java
  2. 2
      src/main/java/com/xujie/sys/modules/erf/service/ErfExpApplyService.java
  3. 8
      src/main/java/com/xujie/sys/modules/erf/service/ErfExpRawMaterialService.java
  4. 29
      src/main/java/com/xujie/sys/modules/erf/service/impl/ErfExpApplyServiceImpl.java
  5. 27
      src/main/java/com/xujie/sys/modules/erf/service/impl/ErfExpRawMaterialServiceImpl.java

19
src/main/java/com/xujie/sys/modules/erf/controller/ErfExpApplyController.java

@ -216,19 +216,22 @@ public class ErfExpApplyController extends AbstractController {
public R copyExpApply(@RequestBody Map<String, Object> params) {
try {
String sourceApplyNo = (String) params.get("sourceApplyNo");
Boolean copyTriConfirm = params.get("copyTriConfirm") != null
? (Boolean) params.get("copyTriConfirm")
Boolean copyTriConfirm = params.get("copyTriConfirm") != null
? (Boolean) params.get("copyTriConfirm")
: false;
Boolean copyAttachment = params.get("copyAttachment") != null
? (Boolean) params.get("copyAttachment")
Boolean copyAttachment = params.get("copyAttachment") != null
? (Boolean) params.get("copyAttachment")
: false;
Long currentUserId = params.get("currentUserId") != null
? Long.valueOf(params.get("currentUserId").toString())
Boolean copyRawMaterialList = params.get("copyRawMaterialList") != null
? (Boolean) params.get("copyRawMaterialList")
: false;
Long currentUserId = params.get("currentUserId") != null
? Long.valueOf(params.get("currentUserId").toString())
: null;
String newApplyNo = erfExpApplyService.copyExpApply(
sourceApplyNo, copyTriConfirm, copyAttachment, currentUserId);
sourceApplyNo, copyTriConfirm, copyAttachment,copyRawMaterialList, currentUserId);
return R.ok("复制成功").put("newApplyNo", newApplyNo);
} catch (Exception e) {
log.error("复制失败: " + e.getMessage(), e);

2
src/main/java/com/xujie/sys/modules/erf/service/ErfExpApplyService.java

@ -160,5 +160,5 @@ public interface ErfExpApplyService extends IService<ErfExpApply> {
* @param currentUserId 当前操作用户ID
* @return 新申请单号
*/
String copyExpApply(String sourceApplyNo, Boolean copyTriConfirm, Boolean copyAttachment, Long currentUserId);
String copyExpApply(String sourceApplyNo, Boolean copyTriConfirm, Boolean copyAttachment,Boolean copyRawMaterialList, Long currentUserId);
}

8
src/main/java/com/xujie/sys/modules/erf/service/ErfExpRawMaterialService.java

@ -70,4 +70,12 @@ public interface ErfExpRawMaterialService {
* @return 物料描述如果不存在返回null
*/
String getPartDescByPartNo(String partNo, String site,String buNo);
/**
* 复制原材料清单从一个申请单到另一个申请单
*
* @param sourceApplyNo 源申请单号
* @param targetApplyNo 目标申请单号
*/
void copyRawMaterialList(String sourceApplyNo, String targetApplyNo);
}

29
src/main/java/com/xujie/sys/modules/erf/service/impl/ErfExpApplyServiceImpl.java

@ -18,9 +18,11 @@ import com.xujie.sys.modules.erf.mapper.ErfExpApplyMapper;
import com.xujie.sys.modules.erf.mapper.ErfFlowInstanceMapper;
import com.xujie.sys.modules.erf.mapper.ErfFlowNodeInstanceMapper;
import com.xujie.sys.modules.erf.service.ErfExpApplyService;
import com.xujie.sys.modules.erf.service.ErfExpRawMaterialService;
import com.xujie.sys.modules.erf.service.ErfFlowEngineService;
import com.xujie.sys.modules.erf.entity.ErfFlowApproveLog;
import com.xujie.sys.modules.erf.mapper.ErfFlowApproveLogMapper;
import com.xujie.sys.modules.erf.service.ErfTriConfirmService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -66,7 +68,10 @@ public class ErfExpApplyServiceImpl extends ServiceImpl<ErfExpApplyMapper, ErfEx
private ErfFlowApproveLogMapper erfFlowApproveLogMapper;
@Autowired
private com.xujie.sys.modules.erf.service.ErfTriConfirmService erfTriConfirmService;
private ErfTriConfirmService erfTriConfirmService;
@Autowired
private ErfExpRawMaterialService erfExpRawMaterialService;
@Autowired
private JdbcTemplate jdbcTemplate;
@ -418,7 +423,7 @@ public class ErfExpApplyServiceImpl extends ServiceImpl<ErfExpApplyMapper, ErfEx
// 9. 最后删除申请单主表
this.removeById(applyNo);
log.info("=== 删除申请单完成 === 申请单号: {}", applyNo);
}
@ -1231,7 +1236,7 @@ public class ErfExpApplyServiceImpl extends ServiceImpl<ErfExpApplyMapper, ErfEx
}
@Override
public String copyExpApply(String sourceApplyNo, Boolean copyTriConfirm, Boolean copyAttachment, Long currentUserId) {
public String copyExpApply(String sourceApplyNo, Boolean copyTriConfirm, Boolean copyAttachment,Boolean copyRawMaterialList, Long currentUserId) {
log.info("=== 开始复制申请单 === 源申请单号: {}, 复制三方确认: {}, 复制附件: {}",
sourceApplyNo, copyTriConfirm, copyAttachment);
@ -1295,6 +1300,16 @@ public class ErfExpApplyServiceImpl extends ServiceImpl<ErfExpApplyMapper, ErfEx
// 不抛出异常继续执行
}
}
// 9. 复制原材料清单
if (Boolean.TRUE.equals(copyRawMaterialList)) {
try {
erfExpRawMaterialService.copyRawMaterialList(sourceApplyNo, newApplyNo);
log.info("原材料清单复制成功");
} catch (Exception e) {
log.warn("复制原材料清单失败: {}", e.getMessage());
// 不抛出异常继续执行
}
}
log.info("=== 复制申请单完成 === 新申请单号: {}", newApplyNo);
return newApplyNo;
@ -1303,7 +1318,7 @@ public class ErfExpApplyServiceImpl extends ServiceImpl<ErfExpApplyMapper, ErfEx
/**
* 复制附件
* 使用OSS系统sys_oss表
*
*
* @param sourceApplyNo 源申请单号
* @param targetApplyNo 目标申请单号
*/
@ -1316,9 +1331,9 @@ public class ErfExpApplyServiceImpl extends ServiceImpl<ErfExpApplyMapper, ErfEx
" order_reftype, conclusion, c_additional_info, project_ispush " +
"FROM sys_oss " +
"WHERE order_ref1 = ? AND order_ref2 = ? AND order_ref6 = ?";
List<Map<String, Object>> attachments = jdbcTemplate.queryForList(sql, "ERF", sourceApplyNo, "EXP_APPLY");
if (attachments.isEmpty()) {
log.info("源申请单没有附件,跳过复制");
return;
@ -1330,7 +1345,7 @@ public class ErfExpApplyServiceImpl extends ServiceImpl<ErfExpApplyMapper, ErfEx
" order_ref1, order_ref2, order_ref3, order_ref4, order_ref5, order_ref6, " +
" file_suffix, file_type_code, order_reftype, conclusion, c_additional_info, project_ispush) " +
"VALUES (?, GETDATE(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
for (Map<String, Object> attachment : attachments) {
jdbcTemplate.update(insertSql,
attachment.get("url"),

27
src/main/java/com/xujie/sys/modules/erf/service/impl/ErfExpRawMaterialServiceImpl.java

@ -8,6 +8,7 @@ import com.xujie.sys.modules.erf.service.ErfExpRawMaterialService;
import com.xujie.sys.modules.part.entity.PartInformationEntity;
import com.xujie.sys.modules.part.mapper.PartInformationMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -251,4 +252,30 @@ public class ErfExpRawMaterialServiceImpl implements ErfExpRawMaterialService {
throw new XJException("数量必须大于0");
}
}
public void copyRawMaterialList(String sourceApplyNo, String targetApplyNo) {
log.info("复制原材料清单,从申请单 {} 到申请单 {}", sourceApplyNo, targetApplyNo);
if (!StringUtils.hasText(sourceApplyNo) || !StringUtils.hasText(targetApplyNo)) {
throw new XJException("源申请单号和目标申请单号不能为空");
}
try {
List<ErfExpRawMaterial> sourceList = getRawMaterialListByApplyNo(sourceApplyNo);
for (ErfExpRawMaterial item : sourceList) {
ErfExpRawMaterial newItem = new ErfExpRawMaterial();
BeanUtils.copyProperties(item, newItem);
newItem.setId(null); // 清空ID以便插入新记录
newItem.setApplyNo(targetApplyNo);
newItem.setCreatedBy(item.getCreatedBy());
newItem.setCreatedDate(new Date());
newItem.setIsDeleted("0");
erfExpRawMaterialMapper.insert(newItem);
}
log.info("复制原材料清单成功,复制了 {} 条记录", sourceList.size());
} catch (Exception e) {
log.error("复制原材料清单失败: " + e.getMessage(), e);
throw new XJException("复制原材料清单失败: " + e.getMessage());
}
}
}
Loading…
Cancel
Save