package com.hotent.baseInfo.manager.impl; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.hotent.base.util.StringUtil; import com.hotent.baseInfo.manager.AuditedUnitManager; import com.hotent.baseInfo.model.AuditedUnit; import com.hotent.baseInfo.model.CostDocumentTemplateFile; import com.hotent.baseInfo.dao.CostDocumentTemplateFileDao; import com.hotent.baseInfo.manager.CostDocumentTemplateFileManager; import com.hotent.base.manager.impl.BaseManagerImpl; import com.hotent.project.model.CostProjectDocumentFile; import com.hotent.uc.api.model.IUser; import com.hotent.uc.exception.BaseException; import com.hotent.uc.manager.UserManager; import com.hotent.uc.model.User; import com.hotent.uc.util.ContextUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import java.time.LocalDateTime; import java.util.List; import javax.annotation.Resource; import com.hotent.base.util.BeanUtils; /** * 监审文书文件内容表 服务实现类 * * @author 超级管理员 * @company 山西清众科技股份有限公司 * @since 2025-10-14 */ @Service public class CostDocumentTemplateFileManagerImpl extends BaseManagerImpl implements CostDocumentTemplateFileManager { @Autowired private AuditedUnitManager auditedUnitManager; @Autowired private UserManager userService; @Override public CostDocumentTemplateFile getDetail(String id) { CostDocumentTemplateFile costDocumentTemplateFile = this.get(id); return costDocumentTemplateFile; } @Override @Transactional public void createOrUpdate(CostDocumentTemplateFile costDocumentTemplateFile) { //新建或更新 this.saveOrUpdate(costDocumentTemplateFile); } @Override public List queryByDocumentId(String documentId,String whereValue,String unitId) { List documentFileList = this.getDocumentFileList(documentId); QueryWrapper eq = new QueryWrapper().eq("document_id", documentId); for (CostDocumentTemplateFile costProjectDocumentFile : documentFileList) { try { if (StringUtil.isNotEmpty(costProjectDocumentFile.getTableName())){ if(StringUtil.isEmpty(costProjectDocumentFile.getWhereValue())){ costProjectDocumentFile.setWhereValue(whereValue); } else { String whereValue1 = costProjectDocumentFile.getWhereValue(); String replace = whereValue1.replace("?", "'" + whereValue + "'"); if (replace.contains("&")) { AuditedUnit auditedUnit = auditedUnitManager.get(unitId); replace = replace.replace("&", "'" + auditedUnit.getUnitId() + "'"); } costProjectDocumentFile.setWhereValue(replace); } String colValue = this.baseMapper.getColValue(costProjectDocumentFile.getTableName(), costProjectDocumentFile.getColName(), costProjectDocumentFile.getWhereName(), costProjectDocumentFile.getWhereValue()); //获取whereValue字段值 costProjectDocumentFile.setDataValue(colValue); } } catch (Exception e) { throw new BaseException("获取字段失败:" + costProjectDocumentFile.getColName()); } } return documentFileList; } @Override public List getDocumentFileList(String documentId) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(CostDocumentTemplateFile::getDocumentId, documentId); List list = this.list(queryWrapper); if (ObjectUtil.isEmpty(list)) { throw new BaseException("没有找到对应的数据"); } return list; } @Override public String getColValue(String tableName, String colName, String whereName, String whereValue) { return baseMapper.getColValue(tableName, colName, whereName, whereValue); } }