his病案终审按需采集
parent
8f3f8fdc1d
commit
3663d253cb
@ -0,0 +1,24 @@
|
||||
package com.emr.dao;
|
||||
|
||||
import com.emr.vo.CompenSateVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @InterfaceName CompenSateMapper
|
||||
* @Description 按需采集接口
|
||||
* @Author linjj
|
||||
* @Date 2024/3/25 14:16
|
||||
* @Version 1.0
|
||||
*/
|
||||
public interface CompenSateMapper {
|
||||
|
||||
List<CompenSateVo> selectAll(@Param(value = "ids")String ids);
|
||||
|
||||
int updateCompenSate(String masterId);
|
||||
|
||||
List<CompenSateVo> selectAllByMasterId(String masterId);
|
||||
|
||||
int addCompenSate(@Param(value = "masterId")String masterId,@Param(value = "patientId")String patientId,@Param(value = "compensateState")int compensateState);
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.emr.service;
|
||||
|
||||
/**
|
||||
* @InterfaceName CompenSateService
|
||||
* @Description
|
||||
* @Author linjj
|
||||
* @Date 2024/3/25 14:42
|
||||
* @Version 1.0
|
||||
*/
|
||||
public interface CompenSateService {
|
||||
|
||||
int updateCompenSate(String masterId,String patientId);
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.emr.service.ipml;
|
||||
|
||||
import com.emr.dao.CompenSateMapper;
|
||||
import com.emr.service.CompenSateService;
|
||||
import com.emr.vo.CompenSateVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName CompenSateServiceImpl
|
||||
* @Description
|
||||
* @Author linjj
|
||||
* @Date 2024/3/25 14:42
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Service
|
||||
public class CompenSateServiceImpl implements CompenSateService {
|
||||
|
||||
@Autowired
|
||||
private CompenSateMapper compenSateMapper;
|
||||
|
||||
@Override
|
||||
public int updateCompenSate(String masterId, String patientId) {
|
||||
//判断按需表中是否存在当前记录
|
||||
List<CompenSateVo> list = compenSateMapper.selectAllByMasterId(masterId);
|
||||
//如果不存在则新增任务,存在则更新任务状态
|
||||
if (list == null || list.isEmpty()) {
|
||||
return compenSateMapper.addCompenSate(masterId, patientId, 0);
|
||||
} else {
|
||||
return compenSateMapper.updateCompenSate(masterId);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.emr.util;
|
||||
|
||||
/**
|
||||
* @InterfaceName FieldSelector
|
||||
* @Description
|
||||
* @Author linjj
|
||||
* @Date 2023/6/29 16:41
|
||||
* @Version 1.0
|
||||
*/
|
||||
public interface FieldSelector<Type, FieldType> {
|
||||
FieldType select(Type type);
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.emr.util;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ListPropertySetter<T> {
|
||||
|
||||
private final List<T> values;
|
||||
|
||||
public ListPropertySetter(List<T> values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
public List<T> cycleSetProperties(PropertySetter<T> setter) {
|
||||
|
||||
if (null == values) return values;
|
||||
|
||||
for (T value : values) {
|
||||
setter.apply(value);
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package com.emr.util;
|
||||
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public final class ListUtil {
|
||||
public static <T, K> Map<K, T> toMap(List<T> list, FieldSelector<T, K> selector) {
|
||||
if (CollectionUtils.isEmpty(list)) return Collections.emptyMap();
|
||||
Map<K, T> map = new HashMap<>(list.size());
|
||||
for (T t : list) {
|
||||
K key = selector.select(t);
|
||||
if (key != null) map.put(key, t);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public static <T, K> Map<K, List<T>> groupBy(List<T> list, FieldSelector<T, K> selector) {
|
||||
if (CollectionUtils.isEmpty(list)) return Collections.emptyMap();
|
||||
Map<K, List<T>> map = new HashMap<>();
|
||||
for (T t : list) {
|
||||
K key = selector.select(t);
|
||||
if (key == null) continue;
|
||||
if (!map.containsKey(key)) {
|
||||
map.put(key, new ArrayList<T>());
|
||||
}
|
||||
map.get(key).add(t);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public static <T, K> List<K> select(List<T> list, FieldSelector<T, K> selector) {
|
||||
if (CollectionUtils.isEmpty(list)) return Collections.emptyList();
|
||||
List<K> filedList = new ArrayList<>(list.size());
|
||||
for (T t : list) {
|
||||
K key = selector.select(t);
|
||||
if (key != null) filedList.add(key);
|
||||
}
|
||||
return filedList;
|
||||
}
|
||||
|
||||
public static <T, K> List<K> distinctSelect(List<T> list, FieldSelector<T, K> selector) {
|
||||
if (CollectionUtils.isEmpty(list)) return Collections.emptyList();
|
||||
Set<K> filedSet = new HashSet<>();
|
||||
for (T t : list) {
|
||||
K key = selector.select(t);
|
||||
if (key != null) filedSet.add(key);
|
||||
}
|
||||
return new ArrayList<>(filedSet);
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public static <T> List<T> unionWithoutDuplicate(List<T>... values) {
|
||||
if (null == values || values.length <= 0) return Collections.emptyList();
|
||||
Set<T> unionFiledSet = new HashSet<>();
|
||||
for (List<T> value : values) {
|
||||
if (!CollectionUtils.isEmpty(value)) {
|
||||
unionFiledSet.addAll(value);
|
||||
}
|
||||
}
|
||||
return new ArrayList<>(unionFiledSet);
|
||||
}
|
||||
|
||||
public static <T, K> List<T> skipDuplicateKey(List<T> list, FieldSelector<T, K> selector) {
|
||||
if (CollectionUtils.isEmpty(list)) return Collections.emptyList();
|
||||
List<T> filedList = new ArrayList<>(list.size());
|
||||
Map<K, T> map = toMap(list, selector);
|
||||
for (K key : map.keySet()) {
|
||||
filedList.add(map.get(key));
|
||||
}
|
||||
return filedList;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.emr.util;
|
||||
|
||||
public interface PropertySetter<T> {
|
||||
|
||||
void apply(T t);
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.emr.util;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Setters<T> {
|
||||
|
||||
public static <T> Setters<T> instance() {
|
||||
return new Setters<>();
|
||||
}
|
||||
|
||||
public ListPropertySetter<T> list(List<T> values) {
|
||||
return new ListPropertySetter<>(values);
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.emr.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @ClassName CompenSateVo
|
||||
* @Description 按需采集返回
|
||||
* @Author linjj
|
||||
* @Date 2024/3/25 14:15
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Data
|
||||
public class CompenSateVo {
|
||||
private String masterId;
|
||||
private String patientId;
|
||||
private int compensateState;
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.emr.dao.CompenSateMapper" >
|
||||
<insert id="addCompenSate">
|
||||
insert into compensate (masterId, patientId,
|
||||
compensateState)
|
||||
values (#{masterId}, #{patientId},
|
||||
#{compensateState})
|
||||
</insert>
|
||||
<update id="updateCompenSate">
|
||||
update compensate set compensateState=0 where masterId=#{masterId}
|
||||
</update>
|
||||
|
||||
<select id="selectAll" resultType="com.emr.vo.CompenSateVo">
|
||||
select * from compensate where
|
||||
masterId in
|
||||
<foreach item="item" collection="ids.split(',')" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="selectAllByMasterId" resultType="com.emr.vo.CompenSateVo">
|
||||
select * from compensate where masterId=#{masterId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue