统计接口和增加标本上机接口

This commit is contained in:
jiangs 2026-04-08 16:34:44 +08:00
parent d11f9aac96
commit 35b7f74957
5 changed files with 88 additions and 44 deletions

View File

@ -3,6 +3,7 @@ package com.transitPlatForm.transitPF.controller;
import com.transitPlatForm.common.annotation.Anonymous; import com.transitPlatForm.common.annotation.Anonymous;
import com.transitPlatForm.common.core.domain.Result; import com.transitPlatForm.common.core.domain.Result;
import com.transitPlatForm.common.utils.DateUtils; import com.transitPlatForm.common.utils.DateUtils;
import com.transitPlatForm.interfaceCommon.utils.CommonUtil;
import com.transitPlatForm.transitPF.mapper.RegStatMapper; import com.transitPlatForm.transitPF.mapper.RegStatMapper;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -27,50 +28,67 @@ import java.util.stream.Collectors;
public class RegStatController { public class RegStatController {
@Autowired @Autowired
RegStatMapper regStatMapper; RegStatMapper regStatMapper;
@Autowired
private CommonUtil commonUtil;
@Anonymous @Anonymous
@ApiOperation("获取业务数据总数") @ApiOperation("获取业务数据总数")
@GetMapping("/getallcount") @GetMapping("/getallcount")
public Result getallcount() { public Result getallcount() {
Date st= DateUtils.parseDate("2025-10-01"); //获取当前日期的月份
Date et= DateUtils.parseDate("2025-11-01"); String currentDateTime = commonUtil.getCurrentDateTime();
Date st = DateUtils.parseDate(currentDateTime.substring(0,7)+"-01");
int month = Integer.parseInt(currentDateTime.substring(5, 7));
int nextMonth = month + 1;
// 补零
String monthStr = nextMonth < 10 ? "0" + nextMonth : String.valueOf(nextMonth);
String currentDateTime1 = currentDateTime.substring(0, 4) + "-" + monthStr + "-01 00:00:00";
Date et = DateUtils.parseDate(currentDateTime1);
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
Map<String, Object> regStatAll=regStatMapper.selectRegStatAll(); Map<String, Object> regStatAll = regStatMapper.selectRegStatAll();
//概况
map.put("regStatAll", regStatAll); map.put("regStatAll", regStatAll);
List<Map<String,Object>> regStatMonth=regStatMapper.selectRegStatMonth(st,et); List<Map<String, Object>> regStatMonth = regStatMapper.selectRegStatMonth(st, et);
List<Map<String, Object>> regStatMonth0 = regStatMonth.stream() List<Map<String, Object>> regStatMonth0 = regStatMonth.stream()
.sorted(Comparator.comparingInt(o -> (Integer) o.get("daynum"))).collect(Collectors.toList()); .sorted(Comparator.comparingInt(o -> (Integer) o.get("daynum"))).collect(Collectors.toList());
//委托机构当月送检标本数量(按天显示的)
map.put("regStatMonth", regStatMonth0); map.put("regStatMonth", regStatMonth0);
List<Map<String,Object>> regStatHospMonth=regStatMapper.selectRegStatHospMonth(st,et); List<Map<String, Object>> regStatHospMonth = regStatMapper.selectRegStatHospMonth(st, et);
if(!regStatHospMonth.isEmpty()) { if (!regStatHospMonth.isEmpty()) {
List<Map<String, Object>> regStatHospMonth0 = regStatHospMonth.stream() List<Map<String, Object>> regStatHospMonth0 = regStatHospMonth.stream()
.sorted(Comparator.comparingInt(o -> (Integer) o.get("daynum"))).collect(Collectors.toList()); .sorted(Comparator.comparingInt(o -> (Integer) o.get("daynum"))).collect(Collectors.toList());
List<Map<String, Object>> regStatHospMonth1=setmapgroup(regStatHospMonth0); List<Map<String, Object>> regStatHospMonth1 = setmapgroup(regStatHospMonth0);
List<Map<String, Object>> regStatHospMonth2 = regStatHospMonth1.stream() List<Map<String, Object>> regStatHospMonth2 = regStatHospMonth1.stream()
.sorted(Comparator.comparingInt((Map<String, Object> o) -> (Integer) o.get("groupsum")).reversed()).collect(Collectors.toList()); .sorted(Comparator.comparingInt((Map<String, Object> o) -> (Integer) o.get("groupsum")).reversed()).collect(Collectors.toList());
map.put("regStatHospMonth", regStatHospMonth2); map.put("regStatHospMonth", regStatHospMonth2);
} }
List<Map<String,Object>> regStatStatus=regStatMapper.selectRegStatStatus(st,et); List<Map<String, Object>> regStatStatus = regStatMapper.selectRegStatStatus(st, et);
List<Map<String, Object>> regStatStatus0 = regStatStatus.stream() List<Map<String, Object>> regStatStatus0 = regStatStatus.stream()
.sorted((o1, o2) -> { .sorted((o1, o2) -> {
int val1 = (Integer) o1.get("sl"); int val1 = (Integer) o1.get("sl");
int val2 = (Integer) o2.get("sl"); int val2 = (Integer) o2.get("sl");
return Integer.compare(val2, val1); return Integer.compare(val2, val1);
}).collect(Collectors.toList()); }).collect(Collectors.toList());
//送检样本状态占比
map.put("regStatStatus", regStatStatus0); map.put("regStatStatus", regStatStatus0);
List<Map<String,Object>> regStatSample=regStatMapper.selectRegStatSample(st,et); List<Map<String, Object>> regStatSample = regStatMapper.selectRegStatSample(st, et);
List<Map<String, Object>> regStatSample0 = regStatSample.stream() List<Map<String, Object>> regStatSample0 = regStatSample.stream()
.sorted((o1, o2) -> { .sorted((o1, o2) -> {
int val1 = (Integer) o1.get("sl"); int val1 = (Integer) o1.get("sl");
int val2 = (Integer) o2.get("sl"); int val2 = (Integer) o2.get("sl");
return Integer.compare(val2, val1); return Integer.compare(val2, val1);
}).collect(Collectors.toList()); }).collect(Collectors.toList());
//送检样本占比
map.put("regStatSample", regStatSample0); map.put("regStatSample", regStatSample0);
return new Result("0","成功",map); return new Result("0", "成功", map);
} }
private List<Map<String,Object>> setmapgroup(List<Map<String,Object>> maps){
List<Map<String,Object>> mapref=new ArrayList<>(); private List<Map<String, Object>> setmapgroup(List<Map<String, Object>> maps) {
if(!maps.isEmpty()) { List<Map<String, Object>> mapref = new ArrayList<>();
if (!maps.isEmpty()) {
OptionalInt maxOpt = maps.stream().mapToInt(map -> (Integer) map.get("daynum")).max(); OptionalInt maxOpt = maps.stream().mapToInt(map -> (Integer) map.get("daynum")).max();
int lastday = maxOpt.orElse(0); int lastday = maxOpt.orElse(0);
int total = maps.stream().mapToInt(map2 -> ((int) map2.get("sl"))).sum(); int total = maps.stream().mapToInt(map2 -> ((int) map2.get("sl"))).sum();
@ -83,18 +101,18 @@ public class RegStatController {
DecimalFormat df = new DecimalFormat("0.00%"); DecimalFormat df = new DecimalFormat("0.00%");
df.setRoundingMode(RoundingMode.HALF_UP); df.setRoundingMode(RoundingMode.HALF_UP);
for (Map<String, Object> map1 : distinctList) { for (Map<String, Object> map1 : distinctList) {
String srcHospName= map1.get("SrcHospName").toString(); String srcHospName = map1.get("SrcHospName").toString();
List<Map<String, Object>> result = maps.stream() List<Map<String, Object>> result = maps.stream()
.filter(map2 -> Objects.equals(map2.get("SrcHospName"), srcHospName)) .filter(map2 -> Objects.equals(map2.get("SrcHospName"), srcHospName))
.collect(Collectors.toList()); .collect(Collectors.toList());
if(!result.isEmpty()) { if (!result.isEmpty()) {
int total0 = result.stream().mapToInt(map2 -> ((int) map2.get("sl"))).sum(); int total0 = result.stream().mapToInt(map2 -> ((int) map2.get("sl"))).sum();
double percentage = (double) total0 / (double)total; double percentage = (double) total0 / (double) total;
Map<String, Object> maptemp = new HashMap<>(); Map<String, Object> maptemp = new HashMap<>();
maptemp.put("groupname", srcHospName); maptemp.put("groupname", srcHospName);
maptemp.put("groupsum",total0); maptemp.put("groupsum", total0);
maptemp.put("percentage", df.format(percentage)); maptemp.put("percentage", df.format(percentage));
maptemp.put("dayline", setdayline(result,lastday)); maptemp.put("dayline", setdayline(result, lastday));
mapref.add(maptemp); mapref.add(maptemp);
} }
} }
@ -102,32 +120,33 @@ public class RegStatController {
} }
return mapref; return mapref;
} }
List<Map<String, Object>> setdayline(List<Map<String, Object>> maps,Integer lastnum){
List<Map<String, Object>> mapref=new ArrayList<>(); List<Map<String, Object>> setdayline(List<Map<String, Object>> maps, Integer lastnum) {
if(!maps.isEmpty()) { List<Map<String, Object>> mapref = new ArrayList<>();
int i=0; if (!maps.isEmpty()) {
int i = 0;
for (Map<String, Object> map : maps) { for (Map<String, Object> map : maps) {
i++; i++;
int daynum=(Integer)map.get("daynum"); int daynum = (Integer) map.get("daynum");
if(daynum>i){ if (daynum > i) {
while (daynum>i){ while (daynum > i) {
Map<String, Object> maptemp = new HashMap<>(); Map<String, Object> maptemp = new HashMap<>();
maptemp.put("daynum",i); maptemp.put("daynum", i);
maptemp.put("sl",0); maptemp.put("sl", 0);
mapref.add(maptemp); mapref.add(maptemp);
i++; i++;
} }
} }
Map<String, Object> maptemp = new HashMap<>(); Map<String, Object> maptemp = new HashMap<>();
maptemp.put("daynum",daynum); maptemp.put("daynum", daynum);
maptemp.put("sl",map.get("sl")); maptemp.put("sl", map.get("sl"));
mapref.add(maptemp); mapref.add(maptemp);
} }
if(lastnum>i){ if (lastnum > i) {
while (lastnum>i){ while (lastnum > i) {
Map<String, Object> maptemp = new HashMap<>(); Map<String, Object> maptemp = new HashMap<>();
maptemp.put("daynum",i); maptemp.put("daynum", i);
maptemp.put("sl",0); maptemp.put("sl", 0);
mapref.add(maptemp); mapref.add(maptemp);
i++; i++;
} }

View File

@ -4,6 +4,8 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.Date;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ -12,4 +14,6 @@ public class RegItemVO {
private String SrcOrderItemCode; private String SrcOrderItemCode;
private String SrcOrderItemName; private String SrcOrderItemName;
private String DstHospName; private String DstHospName;
private Date DateStart;
private Date DateEnd;
} }

View File

@ -58,4 +58,10 @@ public class SampleSignVO {
private String cancelName; private String cancelName;
@ApiModelProperty(value = "标本退回时间") @ApiModelProperty(value = "标本退回时间")
private Date backTime; private Date backTime;
@ApiModelProperty(value = "上机时间")
private Date operdatetime;
@ApiModelProperty(value = "上机操作人代码")
private String opercode;
@ApiModelProperty(value = "上机操作人姓名")
private String opername;
} }

View File

@ -258,6 +258,20 @@ public class RegInterfaceImpl {
requestInfoUtil.updateRegTransitSampleStatus(regTransitSample50,regApply); requestInfoUtil.updateRegTransitSampleStatus(regTransitSample50,regApply);
break; break;
case "60": //上机检测 case "60": //上机检测
if(Integer.parseInt(status) == 90 || Integer.parseInt(status) == 70) return new Result("-1","该标本已经作废或者已经审核,不允许再上机!");
Date operdatetime = sampleSignVO.getOperdatetime();
String opercode = sampleSignVO.getOpercode();
String opername = sampleSignVO.getOpername();
if(operdatetime == null) return new Result("-1","上机时间不能为空!");
if(opername == null || opername.equals("")) return new Result("-1","上机人姓名不能为空!");
RegTransitSample regTransitSample60 = new RegTransitSample();
regTransitSample60.setBarcode(barcode);
regTransitSample60.setOperdatetime(operdatetime);
regTransitSample60.setOpercode(opercode);
regTransitSample60.setOpername(opername);
regTransitSample60.setStatus("60");
requestInfoUtil.updateRegTransitSampleStatus(regTransitSample60,regApply);
break; break;
case "70": //结果审核 case "70": //结果审核
Date reportTime = sampleSignVO.getReportTime(); Date reportTime = sampleSignVO.getReportTime();

View File

@ -8,20 +8,21 @@
select srchospname,sampletypecode,sampletypename,count(1) as sl from reg_TransitSample select srchospname,sampletypecode,sampletypename,count(1) as sl from reg_TransitSample
<where> <where>
<if test="SrcHospName != null and SrcHospName !=''">and SrcHospName = #{SrcHospName}</if> <if test="SrcHospName != null and SrcHospName !=''">and SrcHospName = #{SrcHospName}</if>
<if test="SampleTypeCode != null and SampleTypeCode !=''">and sampletypecode = #{SampleTypeCode}</if> <if test="SampleTypeCode != null and SampleTypeCode !=''">and sampletypecode like '%'+#{SampleTypeCode}+'%' </if>
<if test="SampleTypeName != null and SampleTypeName !=''">and sampletypename = #{SampleTypeName}</if> <if test="SampleTypeName != null and SampleTypeName !=''">and sampletypename like '%'+#{SampleTypeName}+'%'</if>
<if test="OrderTime != null">and (OrderTime between #{DateStart} and #{DateEnd})</if> <if test="DateStart != null">and (OrderTime between #{DateStart} and #{DateEnd})</if>
</where> </where>
group by srchospname,sampletypecode,sampletypename group by srchospname,sampletypecode,sampletypename
</select> </select>
<select id="getItemCount" resultType="map"> <select id="getItemCount" resultType="map">
select a.SrcHospName,b.SrcOrderItemCode,b.SrcOrderItemName,count(1) as sl,b.cost,a.DstHospName from reg_TransitSample a,reg_TransitSample_detail b where a.barcode = b.barcode select a.SrcHospName,isnull(b.SrcOrderItemCode,b.orderitemcode) as SrcOrderItemCode,isnull(b.SrcOrderItemName,b.orderitemname) as SrcOrderItemName ,count(1) as sl,b.cost,a.DstHospName from reg_TransitSample a,reg_TransitSample_detail b where a.barcode = b.barcode
<if test="SrcHospName != null and SrcHospName !=''">and SrcHospName = #{SrcHospName}</if> <if test="SrcHospName != null and SrcHospName !=''">and SrcHospName = #{SrcHospName}</if>
<if test="SrcOrderItemCode != null and SrcOrderItemCode !=''">and SrcOrderItemCode = #{SrcOrderItemCode}</if> <if test="SrcOrderItemCode != null and SrcOrderItemCode !=''">and SrcOrderItemCode like '%'+#{SrcOrderItemCode}+'%' </if>
<if test="SrcOrderItemName != null and SrcOrderItemName !=''">and SrcOrderItemName = #{SrcOrderItemName}</if> <if test="SrcOrderItemName != null and SrcOrderItemName !=''">and isnull(b.SrcOrderItemName,b.orderitemname) like '%'+#{SrcOrderItemName}+'%' </if>
<if test="DstHospName != null and DstHospName !=''">and DstHospName = #{DstHospName}</if> <if test="DstHospName != null and DstHospName !=''">and DstHospName = #{DstHospName}</if>
group by a.SrcHospName,b.SrcOrderItemCode,b.SrcOrderItemName,b.cost,a.DstHospName <if test="DateStart != null">and (a.OrderTime between #{DateStart} and #{DateEnd})</if>
group by a.SrcHospName,isnull(b.SrcOrderItemCode,b.orderitemcode),isnull(b.SrcOrderItemName,b.orderitemname),b.cost,a.DstHospName
</select> </select>
</mapper> </mapper>