|
@@ -34,21 +34,15 @@ public class MuseumInfoController {
|
|
|
@Resource
|
|
|
private MuseumInfoService museumInfoService;
|
|
|
|
|
|
- //TODO 判断标本编号是否重复
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "新增标本")
|
|
|
public CommonResult<Integer> createMuseumInfo(@Valid @RequestBody MuseumInfoSaveVO saveVO) {
|
|
|
- String sampleId = saveVO.getSampleId();
|
|
|
- String result = museumInfoService.getMuseumInfoBySampleId(sampleId);
|
|
|
- if (result != null) {
|
|
|
- return CommonResult.error(200, "标本编号已存在");
|
|
|
- } else {
|
|
|
return CommonResult.success(museumInfoService.createMuseumInfo(saveVO));
|
|
|
- }
|
|
|
}
|
|
|
@PutMapping("/update")
|
|
|
@Operation(summary = "更新标本")
|
|
|
public CommonResult<Boolean> updateSampleMuseumInfo(@Valid @RequestBody MuseumInfoSaveVO saveVO){
|
|
|
+
|
|
|
museumInfoService.updateSampleMuseumInfo(saveVO);
|
|
|
return success(true);
|
|
|
}
|
|
@@ -65,7 +59,6 @@ public class MuseumInfoController {
|
|
|
return success(true);
|
|
|
}
|
|
|
|
|
|
- //TODO 需要提供原因,调用更新方法
|
|
|
@DeleteMapping("/delete")
|
|
|
@Operation(summary = "删除标本")
|
|
|
public CommonResult<Boolean> deleteMuseumInfo(@RequestParam("id") Integer id,@RequestParam("reason") String reason){
|
|
@@ -81,21 +74,6 @@ public class MuseumInfoController {
|
|
|
return CommonResult.success(result1);
|
|
|
}
|
|
|
|
|
|
- @GetMapping("/getSampleId")
|
|
|
- @Operation(summary = "标本编号查寻")
|
|
|
- public CommonResult<MuseumInfoRespVO>selectMuseumInfoBySampleId(@RequestParam("sampleId") String sampleId){
|
|
|
- MuseumInfoDO result = museumInfoService.selectMuseumInfoBySampleId(sampleId);
|
|
|
- MuseumInfoRespVO result1 = BeanUtils.toBean(result,MuseumInfoRespVO.class);
|
|
|
- return CommonResult.success(result1);
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/getSample")
|
|
|
- @Operation(summary = "所有标本查寻")
|
|
|
- public CommonResult<List<MuseumInfoRespVO>>selectMuseumInfo(){
|
|
|
- List<MuseumInfoDO> result = museumInfoService.selectMuseumInfo();
|
|
|
- List<MuseumInfoRespVO> result1 = BeanUtils.toBean(result,MuseumInfoRespVO.class);
|
|
|
- return CommonResult.success(result1);
|
|
|
- }
|
|
|
|
|
|
@GetMapping("/getSampleType")
|
|
|
@Operation(summary = "标本类型查寻")
|
|
@@ -105,7 +83,7 @@ public class MuseumInfoController {
|
|
|
return CommonResult.success(result1);
|
|
|
}
|
|
|
|
|
|
- @GetMapping("/get-import-sample")
|
|
|
+ @GetMapping("/getImportSample")
|
|
|
@Operation(summary = "获得导入标本模板")
|
|
|
public void importSample(HttpServletResponse response) throws IOException {
|
|
|
List<MuseuminfoImportExcelVO> list = Arrays.asList(
|
|
@@ -166,11 +144,7 @@ public class MuseumInfoController {
|
|
|
Integer number =museumInfoService.MuseumInfoBySaveJoin(month,currentYear);
|
|
|
MuseuminfoMonthSaveVO re = new MuseuminfoMonthSaveVO();
|
|
|
re.setMonth(month);
|
|
|
- if (number == null) {
|
|
|
- re.setCount(0);
|
|
|
- }else {
|
|
|
- re.setCount(number);
|
|
|
- }
|
|
|
+ re.setCount(number);
|
|
|
result.add(re);
|
|
|
}
|
|
|
return CommonResult.success(result);
|
|
@@ -183,7 +157,6 @@ public class MuseumInfoController {
|
|
|
int currentYear =date.getYear();
|
|
|
List<MuseuminfoMonthSaveVO> result = new ArrayList<>();
|
|
|
for (int month = 1 ; month <= 12 ; month++) {
|
|
|
- //TODO 可以直接使用List<String>.size(),就不用写一个countSampleNumbers来计算list中元素的个数了
|
|
|
int number = museumInfoService.MuseumInfoBySaveOut(month, currentYear).size();
|
|
|
MuseuminfoMonthSaveVO re = new MuseuminfoMonthSaveVO();
|
|
|
re.setMonth(month);
|
|
@@ -201,7 +174,7 @@ public class MuseumInfoController {
|
|
|
|
|
|
List<MuseuminfoMonthSaveVO> result = new ArrayList<>();
|
|
|
for (int month = 1 ; month <= 12 ; month++) {
|
|
|
- int sample_number = countSampleNumbers(museumInfoService.MuseumInfoBySaveBack(month,currentYear));
|
|
|
+ int sample_number = museumInfoService.MuseumInfoBySaveBack(month,currentYear).size();
|
|
|
MuseuminfoMonthSaveVO re = new MuseuminfoMonthSaveVO();
|
|
|
re.setMonth(month);
|
|
|
re.setCount(sample_number);
|
|
@@ -220,8 +193,8 @@ public class MuseumInfoController {
|
|
|
for (int year = currentYear; year >= year1; year--) {
|
|
|
|
|
|
Integer number1 = museumInfoService.MuseumInfoYearJoin(year);
|
|
|
- int sample_number2 = countSampleNumbers(museumInfoService.MuseumInfoYearOutBack(1, year));
|
|
|
- int sample_number3 = countSampleNumbers(museumInfoService.MuseumInfoYearOutBack(0, year));
|
|
|
+ int sample_number2 = museumInfoService.MuseumInfoYearOutBack(1, year).size();
|
|
|
+ int sample_number3 = museumInfoService.MuseumInfoYearOutBack(0, year).size();
|
|
|
Map<Integer,Object> map = new HashMap<>();
|
|
|
|
|
|
Map<String, Integer> innerMap = new HashMap<>();
|
|
@@ -234,26 +207,6 @@ public class MuseumInfoController {
|
|
|
return CommonResult.success(result);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 统计样本数量
|
|
|
- * @param number 包含样本信息的列表
|
|
|
- * @return 样本数量
|
|
|
- */
|
|
|
- private int countSampleNumbers(List<String> number) {
|
|
|
- if (number == null) {
|
|
|
- return 0;
|
|
|
- }
|
|
|
- int count = 0;
|
|
|
- for (String numberStr : number) {
|
|
|
- //消除空格
|
|
|
- String processedStr = numberStr.replaceAll("\\[|\\]","");
|
|
|
- // 按逗号分割元素
|
|
|
- String[] groupElements = processedStr.split(",");
|
|
|
- count += groupElements.length;
|
|
|
- }
|
|
|
- return count;
|
|
|
- }
|
|
|
-
|
|
|
@GetMapping("/originCount")
|
|
|
@Operation(summary = "标本来源计数")
|
|
|
public CommonResult<List<Map<Integer,Object>>> getOrigin(){
|
|
@@ -262,6 +215,7 @@ public class MuseumInfoController {
|
|
|
LocalDate date = LocalDate.now();
|
|
|
int currentYear =date.getYear();
|
|
|
int year1 =currentYear-2;
|
|
|
+ //只展示前两年的数据
|
|
|
for (int year =currentYear ; year>=year1 ; year--) {
|
|
|
|
|
|
Integer number1 = museumInfoService.MuseumInfoByOrigin(year,1);
|