|
@@ -12,13 +12,9 @@ import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.SneakyThrows;
|
|
|
import org.springblade.business.dto.*;
|
|
|
-import org.springblade.business.entity.EntrustInfo;
|
|
|
-import org.springblade.business.entity.TrialDetectionData;
|
|
|
-import org.springblade.business.entity.TrialSampleInfo;
|
|
|
-import org.springblade.business.entity.TrialSelfInspectionRecord;
|
|
|
-import org.springblade.business.service.ITrialDetectionDataService;
|
|
|
-import org.springblade.business.service.ITrialSampleInfoService;
|
|
|
-import org.springblade.business.service.ITrialSelfInspectionRecordService;
|
|
|
+import org.springblade.business.entity.*;
|
|
|
+import org.springblade.business.service.*;
|
|
|
+import org.springblade.business.utils.DateUtils;
|
|
|
import org.springblade.business.utils.FileUtils;
|
|
|
import org.springblade.business.vo.*;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
@@ -26,7 +22,6 @@ import org.springblade.core.boot.ctrl.BladeController;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
import org.springblade.core.oss.model.BladeFile;
|
|
|
-import org.springblade.core.secure.BladeUser;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.BeanUtil;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
@@ -37,16 +32,15 @@ import org.springblade.manager.entity.TrialSelfDataRecord;
|
|
|
import org.springblade.manager.entity.WbsTreePrivate;
|
|
|
import org.springblade.manager.feign.WbsTreePrivateClient;
|
|
|
import org.springblade.manager.vo.CheckRemoveBussTabInfoVo;
|
|
|
-import org.springblade.manager.vo.ContractInfoVO;
|
|
|
import org.springblade.manager.vo.TableFileVO;
|
|
|
import org.springblade.manager.vo.WbsTreePrivateVO;
|
|
|
-import org.springblade.meter.entity.MeterContractInfo;
|
|
|
import org.springblade.resource.feign.NewIOSSClient;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.File;
|
|
|
import java.io.FileNotFoundException;
|
|
@@ -66,6 +60,8 @@ public class TrialDetectionController extends BladeController {
|
|
|
private final WbsTreePrivateClient wbsTreePrivateClient;
|
|
|
private final JdbcTemplate jdbcTemplate;
|
|
|
private final NewIOSSClient newIOSSClient;
|
|
|
+ private final ITrialNumberRuleService trialNumberRuleService;
|
|
|
+ private final StandardInfoService uStandardInfoService;
|
|
|
|
|
|
@GetMapping("/data/detail")
|
|
|
@ApiOperationSupport(order = 1)
|
|
@@ -546,7 +542,7 @@ public class TrialDetectionController extends BladeController {
|
|
|
@GetMapping("/self/getBaseInfo")
|
|
|
@ApiOperationSupport(order = 30)
|
|
|
@ApiOperation(value = "获取试验自检基础信息", notes = "传入节点pKeyId")
|
|
|
- public R<TrialSeleInspectionRecordBaseInfoVO> getBaseInfo(@RequestParam Long projectId, @RequestParam Long contractId, @RequestParam(required = false) Long id) {
|
|
|
+ public R<TrialSeleInspectionRecordBaseInfoDTO> getBaseInfo(@RequestParam Long projectId, @RequestParam Long contractId, @RequestParam Long nodeId, @RequestParam(required = false) Long id) {
|
|
|
ProjectInfo projectInfo = jdbcTemplate.query("select * from m_project_info where id = " + projectId, new BeanPropertyRowMapper<>(ProjectInfo.class)).stream().findAny().orElse(null);
|
|
|
if (projectInfo == null) {
|
|
|
return R.fail("未获取到项目信息");
|
|
@@ -555,13 +551,17 @@ public class TrialDetectionController extends BladeController {
|
|
|
if (contractInfo == null) {
|
|
|
return R.fail("未获取到合同信息");
|
|
|
}
|
|
|
- TrialSeleInspectionRecordBaseInfoVO vo = new TrialSeleInspectionRecordBaseInfoVO();
|
|
|
+ TrialSeleInspectionRecordBaseInfoDTO vo = new TrialSeleInspectionRecordBaseInfoDTO();
|
|
|
vo.setProjectName(projectInfo.getProjectName());
|
|
|
vo.setConstructionUnit(contractInfo.getConstructionUnitName());
|
|
|
if (contractInfo.getContractType().equals(2)) {
|
|
|
- // todo 获取该监理下的所有施工单位
|
|
|
+ List<ContractInfo> query = jdbcTemplate.query("select contract_name from m_contract_info where is_deleted = 0 and p_id = " + projectId + " and contract_type = 1", new BeanPropertyRowMapper<>(ContractInfo.class));
|
|
|
+ vo.setConstructionUnit(org.apache.commons.lang.StringUtils.join(query.stream().map(ContractInfo::getContractName).collect(Collectors.toList()), ","));
|
|
|
} else if (contractInfo.getContractType().equals(3)) {
|
|
|
- // todo 获取该业主下的所有监理单位
|
|
|
+ List<ContractInfo> query = jdbcTemplate.query("select contract_name from m_contract_info where is_deleted = 0 and p_id = " + projectId + " and contract_type = 1", new BeanPropertyRowMapper<>(ContractInfo.class));
|
|
|
+ vo.setConstructionUnit(org.apache.commons.lang.StringUtils.join(query.stream().map(ContractInfo::getContractName).collect(Collectors.toList()), ","));
|
|
|
+ List<ContractInfo> query1 = jdbcTemplate.query("select contract_name from m_contract_info where is_deleted = 0 and p_id = " + projectId + " and contract_type = 2", new BeanPropertyRowMapper<>(ContractInfo.class));
|
|
|
+ vo.setSupervisionUnit(org.apache.commons.lang.StringUtils.join(query1.stream().map(ContractInfo::getContractName).collect(Collectors.toList()), ","));
|
|
|
}
|
|
|
vo.setSupervisionUnit(contractInfo.getSupervisionUnitName());
|
|
|
vo.setLabName(contractInfo.getLaboratoryName());
|
|
@@ -578,14 +578,86 @@ public class TrialDetectionController extends BladeController {
|
|
|
}
|
|
|
}
|
|
|
List<TrialSelfSample> selfSampleList = jdbcTemplate.query("select * from u_trial_self_sample where self_id = " + id, new BeanPropertyRowMapper<>(TrialSelfSample.class));
|
|
|
- String samplingIds = selfSampleList.stream().map(TrialSelfSample::getSamplingId).map(String::valueOf).collect(Collectors.joining(","));
|
|
|
- List<TrialSampleInfo> trialSampleInfoList = jdbcTemplate.query("select * from u_trial_sample_info where id in (" + samplingIds + ")", new BeanPropertyRowMapper<>(TrialSampleInfo.class));
|
|
|
- vo.setTrialSampleInfoList(trialSampleInfoList);
|
|
|
+ if (!selfSampleList.isEmpty()) {
|
|
|
+ String samplingIds = selfSampleList.stream().map(TrialSelfSample::getSamplingId).map(String::valueOf).collect(Collectors.joining(","));
|
|
|
+ List<TrialSampleInfo> trialSampleInfoList = jdbcTemplate.query("select * from u_trial_sample_info where id in (" + samplingIds + ")", new BeanPropertyRowMapper<>(TrialSampleInfo.class));
|
|
|
+ vo.setTrialSampleInfoList(trialSampleInfoList);
|
|
|
+ vo.setTrialSampleInfo(trialSampleInfoList.isEmpty() ? new TrialSampleInfo() : trialSampleInfoList.get(0));
|
|
|
+ }
|
|
|
if (vo.getProjectPosition() == null) {
|
|
|
vo.setProjectPosition(record.getProjectPosition());
|
|
|
}
|
|
|
+ vo.setStandardId(record.getStandardId());
|
|
|
+ vo.setReportNo(record.getReportNo());
|
|
|
+ vo.setRecordNo(record.getRecordNo());
|
|
|
+ // 获取设备信息和使用信息
|
|
|
+ List<TrailDeviceUseInfoDTO> trialDeviceUseList = jdbcTemplate.query("select * from u_trial_device_use where self_inspection_record_id = " + id, new BeanPropertyRowMapper<>(TrailDeviceUseInfoDTO.class));
|
|
|
+ if (!trialDeviceUseList.isEmpty()) {
|
|
|
+ Set<Long> ids = trialDeviceUseList.stream().map(TrailDeviceUseInfoDTO::getDeviceInfoId).collect(Collectors.toSet());
|
|
|
+ List<TrialDeviceInfo> deviceInfoList = jdbcTemplate.query("select * from u_device_info where id in (" + org.apache.commons.lang.StringUtils.join(ids, ",") + ")", new BeanPropertyRowMapper<>(TrialDeviceInfo.class));
|
|
|
+ Map<Long, TrialDeviceInfo> trialDeviceInfoMap = deviceInfoList.stream().collect(Collectors.toMap(TrialDeviceInfo::getId, trailDeviceInfo -> trailDeviceInfo));
|
|
|
+ trialDeviceUseList.forEach(trailDeviceUseInfoDTO -> {
|
|
|
+ TrialDeviceInfo deviceInfo = trialDeviceInfoMap.get(trailDeviceUseInfoDTO.getDeviceInfoId());
|
|
|
+ if (deviceInfo != null) {
|
|
|
+ trailDeviceUseInfoDTO.setMeasuringRange(deviceInfo.getMeasuringRange());
|
|
|
+ trailDeviceUseInfoDTO.setAccuracy(deviceInfo.getAccuracy());
|
|
|
+ // 计算使用时长
|
|
|
+ trailDeviceUseInfoDTO.setUseDuration(DateUtils.dateDiff(trailDeviceUseInfoDTO.getStartDate(), trailDeviceUseInfoDTO.getEndDate()));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ vo.setTrailDeviceUseInfoDTOS(trialDeviceUseList);
|
|
|
}
|
|
|
}
|
|
|
+ if (vo.getRecordNo() == null) {
|
|
|
+ Map<String, String> map = trialNumberRuleService.getTrialNumber(projectId, contractId, 4, nodeId, true);
|
|
|
+ vo.setRecordNo(map.get("trialNumber"));
|
|
|
+ }
|
|
|
+ if (vo.getReportNo() == null) {
|
|
|
+ Map<String, String> map = trialNumberRuleService.getTrialNumber(projectId, contractId, 5, nodeId, true);
|
|
|
+ vo.setReportNo(map.get("trialNumber"));
|
|
|
+ }
|
|
|
+ List<TrialSeleInspectionRecordBaseInfoDTO.StandardVo> mapList = jdbcTemplate.query("SELECT id,name from u_wbs_private_standard WHERE type = 2 and is_deleted = 0 and status = 1 and private_id = " + nodeId,
|
|
|
+ new BeanPropertyRowMapper<>(TrialSeleInspectionRecordBaseInfoDTO.StandardVo.class));
|
|
|
+ vo.setStandardVos(mapList);
|
|
|
return R.data(vo);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取最近一次使用的设备信息
|
|
|
+ */
|
|
|
+ @GetMapping("/self/lastTrailDeviceInfo")
|
|
|
+ @ApiOperationSupport(order = 30)
|
|
|
+ @ApiOperation(value = "获取上一次使用设备信息", notes = "传入节点pKeyId")
|
|
|
+ public R<List<TrialDeviceInfo>> getTrailDeviceInfo( @RequestParam Long contractId, @RequestParam Long nodeId) {
|
|
|
+ TrialSelfInspectionRecord record = iTrialSelfInspectionRecordService.getOne(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().select(TrialSelfInspectionRecord::getId)
|
|
|
+ .eq(TrialSelfInspectionRecord::getContractId, contractId).eq(TrialSelfInspectionRecord::getNodeId, nodeId).last(" order by id desc limit 1"));
|
|
|
+ if (record == null) {
|
|
|
+ return R.data(new ArrayList<>());
|
|
|
+ }
|
|
|
+ List<TrialDeviceInfo> trialDeviceUseList = jdbcTemplate.query("select * from u_trial_device_info WHERE id in ( select device_info_id from u_trial_device_use where self_inspection_record_id = ? and node_id = ?)" ,
|
|
|
+ new BeanPropertyRowMapper<>(TrialDeviceInfo.class), record.getId(), nodeId);
|
|
|
+ return R.data(trialDeviceUseList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据standardId 查询 样品品种,代号和强度等级
|
|
|
+ */
|
|
|
+ @GetMapping("/self/getStandardInfoByStandardId")
|
|
|
+ @ApiOperationSupport(order = 30)
|
|
|
+ @ApiOperation(value = "根据 standardId 查询 样品品种,代号和强度等级", notes = "standardId")
|
|
|
+ public R<Map<String, List<StandardInfo>>> getStandardInfoByStandardId( @RequestParam Long standardId) {
|
|
|
+ List<StandardInfo> list = uStandardInfoService.list(Wrappers.<StandardInfo>lambdaQuery().eq(StandardInfo::getStandardId, standardId).eq(StandardInfo::getType, 1)
|
|
|
+ .eq(StandardInfo::getParentId, 0).and(query -> query.eq(StandardInfo::getName, "样品品种").or().eq(StandardInfo::getName, "代号").or().eq(StandardInfo::getName, "强度等级")));
|
|
|
+ if (list == null || list.isEmpty()) {
|
|
|
+ return R.data(new HashMap<>());
|
|
|
+ }
|
|
|
+ List<Long> ids = list.stream().map(StandardInfo::getId).collect(Collectors.toList());
|
|
|
+ List<StandardInfo> childList = uStandardInfoService.list(Wrappers.<StandardInfo>lambdaQuery().in(StandardInfo::getParentId, ids).eq(StandardInfo::getType, 1));
|
|
|
+ Map<Long, List<StandardInfo>> map = childList.stream().collect(Collectors.groupingBy(StandardInfo::getParentId));
|
|
|
+ Map<String, List<StandardInfo>> result = new HashMap<>();
|
|
|
+ list.forEach(standardInfo -> result.put(standardInfo.getName(), map.get(standardInfo.getId()) == null ? new ArrayList<>() : map.get(standardInfo.getId())));
|
|
|
+ return R.data(result);
|
|
|
+ }
|
|
|
}
|