package jnpf.dmsService.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import jnpf.dmsEntity.DmsDanganCundangShenqingDanganheEntity;
|
import jnpf.dmsEntity.form.DmsDanganCundangDanganhePrintCallbackForm;
|
import jnpf.dmsMapper.DmsDanganCundangShenqingDanganheMapper;
|
import jnpf.dmsService.DmsDanganCundangDanganhePrintCallbackService;
|
import jnpf.exception.DataException;
|
import lombok.RequiredArgsConstructor;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.LinkedHashSet;
|
import java.util.List;
|
import java.util.Set;
|
|
@Service
|
@RequiredArgsConstructor
|
public class DmsDanganCundangDanganhePrintCallbackServiceImpl
|
implements DmsDanganCundangDanganhePrintCallbackService {
|
|
private final DmsDanganCundangShenqingDanganheMapper danganheMapper;
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void markPrinted(List<DmsDanganCundangDanganhePrintCallbackForm> danganheList)
|
throws DataException {
|
Set<String> danganheIds = resolveDanganheIds(danganheList);
|
LambdaUpdateWrapper<DmsDanganCundangShenqingDanganheEntity> update = new LambdaUpdateWrapper<>();
|
update.in(DmsDanganCundangShenqingDanganheEntity::getId, danganheIds)
|
.isNull(DmsDanganCundangShenqingDanganheEntity::getDeleteMark)
|
.set(DmsDanganCundangShenqingDanganheEntity::getShifouYidayin, "yes");
|
danganheMapper.update(null, update);
|
}
|
|
private Set<String> resolveDanganheIds(
|
List<DmsDanganCundangDanganhePrintCallbackForm> danganheList) throws DataException {
|
if (danganheList == null || danganheList.isEmpty()) {
|
throw new DataException("档案盒打印回调参数不能为空");
|
}
|
Set<String> ids = new LinkedHashSet<>();
|
for (DmsDanganCundangDanganhePrintCallbackForm danganhe : danganheList) {
|
if (danganhe == null || trimToEmpty(danganhe.getFId()).isEmpty()) {
|
throw new DataException("档案盒打印回调中的f_id不能为空");
|
}
|
ids.add(danganhe.getFId().trim());
|
}
|
return ids;
|
}
|
|
private String trimToEmpty(String value) {
|
return value == null ? "" : value.trim();
|
}
|
}
|