提交 5f5610bc 编写于 作者: wangyongbo's avatar wangyongbo

刷数据删除无用居民数据

上级 92f1b62a
...@@ -68,15 +68,17 @@ public class RefreshController extends BaseController { ...@@ -68,15 +68,17 @@ public class RefreshController extends BaseController {
return ReturnUtil.getPicaResponse(PicaResultCode.SUCCESS); return ReturnUtil.getPicaResponse(PicaResultCode.SUCCESS);
} }
@LoginPermission @LoginPermission
@PostMapping("/real") @PostMapping("/delPat")
public PicaResponse realPat(@RequestParam("id") Integer id) { public PicaResponse delPat(@RequestParam("id") Integer id) {
PicaUser picaUser = fetchPicaUser(); PicaUser picaUser = fetchPicaUser();
if (picaUser.getId() == 766) { if (picaUser.getId() == 766) {
refreshService.realPat(id); refreshService.delPat(id);
} }
return ReturnUtil.getPicaResponse(PicaResultCode.SUCCESS); return ReturnUtil.getPicaResponse(PicaResultCode.SUCCESS);
} }
} }
...@@ -21,5 +21,5 @@ public interface RefreshService { ...@@ -21,5 +21,5 @@ public interface RefreshService {
void patDocMapping2(Integer id); void patDocMapping2(Integer id);
void realPat(Integer id); void delPat(Integer id);
} }
...@@ -137,76 +137,23 @@ public class RefreshServiceImpl implements RefreshService { ...@@ -137,76 +137,23 @@ public class RefreshServiceImpl implements RefreshService {
} }
@Override @Override
public void realPat(Integer id) { public void delPat(Integer id) {
int index = 0; logger.info("开始处理数据delPat:");
int docIndex = 0; long start = System.currentTimeMillis();
int docLogIndex = 0; List<PatPatient> list = refreshMapper.queryDelPatList(id);
long begin = System.currentTimeMillis(); if (CollectionUtils.isNotEmpty(list)) {
while (true) { for (PatPatient pat : list) {
List<PatPatientReal> list = refreshMapper.queryRealPatientList(id); refreshMapper.deletePat(pat.getId());
if (CollectionUtils.isEmpty(list)) { refreshMapper.deletePatInfo(pat.getId());
long end = System.currentTimeMillis(); refreshMapper.deleteDocPat(pat.getId());
logger.info("刷新数据结束:共处理:【" + index + "】条real,【" + docIndex + "】条docPatReal, 【" + docLogIndex + "】条docPatRealLog,消耗:【" + (end - begin) / 1000 + "】s"); refreshMapper.deleteDocPatInfo(pat.getId());
break; refreshMapper.deleteLabel(pat.getId());
} refreshMapper.deletePlan(pat.getId());
for (PatPatientReal realPatient : list) { refreshMapper.deletePlan2(pat.getId());
if (refreshMapper.queryRealPatient(realPatient.getPatientId()) == null) {
PatPatientReal real = new PatPatientReal();
real.setId(realPatient.getId());
real.setPatientId(realPatient.getPatientId());
real.setNickname(realPatient.getNickname());
real.setMobilePhone(realPatient.getMobilePhone());
real.setStatus(realPatient.getStatus());
real.setDeleteFlag(realPatient.getDeleteFlag());
real.setCreatedId(realPatient.getCreatedId());
real.setCreatedTime(realPatient.getCreatedTime());
real.setModifiedId(realPatient.getModifiedId());
real.setModifiedTime(realPatient.getModifiedTime());
//验真通过赋值5字段
if (realPatient.getStatus() == 2) {
//验真类型:1、验证码验真 2、短信回复验真 3、小程序验真 4、手机号姓名跟医生一致自动验真
real.setValidateType(realPatient.getValidateType());
//验真的验证码:若验真类型是1和2,则有值
if (real.getValidateType() == 1 || real.getValidateType() == 2) {
real.setValidateCode(realPatient.getValidateCode());
}
//验真时间
real.setValidateTime(realPatient.getModifiedTime());
//验真人类型:1、医生 2、居民 和 验真人id
if (real.getValidateType() == 1 || real.getValidateType() == 4) {
real.setValidateUserType(1);
real.setValidateUserId(realPatient.getModifiedId());
} else {
real.setValidateUserType(2);
real.setValidateUserId(realPatient.getPatientId());
}
}
refreshMapper.insertRealPatient(real);
index++;
/**新增mapping表*/
List<PatDocPatReal> patDocList = refreshMapper.queryRealPatDocList(realPatient.getPatientId());
if (CollectionUtils.isNotEmpty(patDocList)) {
for (PatDocPatReal docPatReal : patDocList) {
if (refreshMapper.queryRealPatDoc(docPatReal.getPatientId(), docPatReal.getDoctorId()) == null) {
refreshMapper.insertRealDocPat(docPatReal);
docIndex++;
}
refreshMapper.insertRealDocPatLog(docPatReal);
docLogIndex++;
}
}
logger.info("开始处理数据:第" + index + "条, patientId=" + realPatient.getPatientId() + ",id=" + realPatient.getId());
}
id = realPatient.getId();
} }
} }
long end = System.currentTimeMillis();
logger.info("结束处理数据delPat:消耗:" + (end - start) / 1000 + "【s】");
} }
} }
...@@ -50,17 +50,12 @@ public interface RefreshMapper { ...@@ -50,17 +50,12 @@ public interface RefreshMapper {
void updateRepeatById2(@Param("id") Integer id); void updateRepeatById2(@Param("id") Integer id);
List<PatPatientReal> queryRealPatientList(@Param("id") Integer id); List<PatPatient> queryDelPatList(@Param("id") Integer id);
RealPatient queryRealPatient(@Param("patientId") Integer patientId); void deleteLabel(@Param("id") Integer id);
void insertRealPatient(PatPatientReal real); void deletePlan(@Param("id") Integer id);
void insertRealDocPat(PatDocPatReal docPatReal); void deletePlan2(@Param("id") Integer id);
List<PatDocPatReal> queryRealPatDocList(@Param("patientId") Integer patientId);
RealPatient queryRealPatDoc(@Param("patientId") Integer patientId, @Param("doctorId") Integer doctorId);
void insertRealDocPatLog(PatDocPatReal docPatReal);
} }
\ No newline at end of file
...@@ -200,129 +200,38 @@ ...@@ -200,129 +200,38 @@
where id = #{id} where id = #{id}
</update> </update>
<select id="queryRealPatientList" <select id="queryDelPatList" parameterType="java.lang.Object" resultType="com.pica.cloud.wechat.yunqueyilian.server.controller.refresh.PatPatient">
resultType="com.pica.cloud.wechat.yunqueyilian.server.controller.refresh.PatPatientReal"> select
select id as id, id,
patient_id as patientId,
nickname as nickname, nickname as nickname,
mobile_phone as mobilePhone, mobile_phone as mobilePhone
status as status, from pat_patient_del_0310
type as type,
validate_code as validateCode,
validate_type as validateType,
delete_flag AS deleteFlag,
created_id as createdId,
created_time as createdTime,
modified_id as modifiedId,
modified_time as modifiedTime
from pica_trade.trade_mobile_phone_real
where id > #{id} where id > #{id}
order by id
limit 0, 10000
</select>
<select id="queryRealPatient"
resultType="com.pica.cloud.wechat.yunqueyilian.server.controller.refresh.RealPatient">
select id as id,
patient_id as patientId
from pat_patient_real
where patient_id = #{patientId}
and delete_flag = 1
</select> </select>
<insert id="insertRealPatient"> <update id="deleteLabel" parameterType="java.lang.Integer" >
insert into pat_patient_real (id, patient_id, nickname, update lab_custom_label
mobile_phone, status, validate_type, set delete_flag = 2,
validate_code, validate_time, validate_user_type, modified_id = 3,
validate_user_id, delete_flag, created_id, modified_time = now()
created_time, modified_id, modified_time where patient_id = #{id}
) </update>
values (#{id,jdbcType=INTEGER}, #{patientId,jdbcType=INTEGER}, #{nickname,jdbcType=VARCHAR},
#{mobilePhone,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{validateType,jdbcType=TINYINT},
#{validateCode,jdbcType=VARCHAR}, #{validateTime,jdbcType=TIMESTAMP}, #{validateUserType,jdbcType=INTEGER},
#{validateUserId,jdbcType=INTEGER}, #{deleteFlag,jdbcType=TINYINT}, #{createdId,jdbcType=INTEGER},
#{createdTime,jdbcType=TIMESTAMP}, #{modifiedId,jdbcType=INTEGER}, #{modifiedTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertRealDocPat" parameterType="com.pica.cloud.wechat.yunqueyilian.server.controller.refresh.PatDocPatReal" >
insert into pat_doc_pat_real (doctor_id, patient_id,
type, validate_code, delete_flag,
created_id, created_time, modified_id,
modified_time)
values (#{doctorId,jdbcType=INTEGER}, #{patientId,jdbcType=INTEGER},
#{type,jdbcType=TINYINT}, #{validateCode,jdbcType=VARCHAR}, #{deleteFlag,jdbcType=TINYINT},
#{createdId,jdbcType=INTEGER}, #{createdTime,jdbcType=TIMESTAMP}, #{modifiedId,jdbcType=INTEGER},
#{modifiedTime,jdbcType=TIMESTAMP}
)
</insert>
<select id="queryRealPatDocList"
resultType="com.pica.cloud.wechat.yunqueyilian.server.controller.refresh.PatDocPatReal">
select
tmp.patient_id as patientId,
tor.prescriber_id as doctorId,
tor.user_type as type,
case when tor.user_type = 1 then tmp.validate_code else '' end as validateCode,
tmp.delete_flag AS deleteFlag,
tor.prescriber_id as createdId,
toa.created_time as createdTime,
tor.prescriber_id as modifiedId,
toa.created_time as modifiedTime
from
pica_trade.trade_mobile_phone_real tmp,
pica_trade.trade_order_address toa,
pica_trade.trade_order tor
where toa.order_no = tor.id
and tmp.patient_id = toa.patient_id
and tmp.delete_flag = 1
and toa.delete_flag = 1
and tor.delete_flag = 1
and tmp.patient_id = #{patientId}
union all
select <update id="deletePlan" parameterType="java.lang.Integer" >
tmp.patient_id as patientId, update pica_follow_up.fu_plan_patients
fpor.doctor_id as doctorId, set delete_flag = 2,
3 as type, modified_id = 3,
'' as validateCode, modified_time = now()
tmp.delete_flag AS deleteFlag, where patient_id = #{id}
fpor.doctor_id as createdId, </update>
fpor.created_time as createdTime,
fpor.doctor_id as modifiedId,
fpor.created_time as modifiedTime
from
pica_trade.trade_mobile_phone_real tmp,
pica_follow_up.fu_plan_order_scales fpor
where tmp.patient_id = fpor.patient_id
and tmp.delete_flag = 1
and fpor.delete_flag = 1
and tmp.patient_id = #{patientId}
</select>
<select id="queryRealPatDoc" <update id="deletePlan2" parameterType="java.lang.Integer" >
resultType="com.pica.cloud.wechat.yunqueyilian.server.controller.refresh.RealPatient"> update pica_follow_up.fu_plan_patients_edu_push
select id as id, set delete_flag = 2,
patient_id as patientId modified_id = 3,
from pat_doc_pat_real modified_time = now()
where patient_id = #{patientId} where patient_id = #{id}
and doctor_id = #{doctorId} </update>
and delete_flag = 1
</select>
<insert id="insertRealDocPatLog" parameterType="com.pica.cloud.wechat.yunqueyilian.server.controller.refresh.PatDocPatReal" >
insert into pat_doc_pat_real_log (doctor_id, patient_id,
type, validate_code, delete_flag,
created_id, created_time, modified_id,
modified_time)
values (#{doctorId,jdbcType=INTEGER}, #{patientId,jdbcType=INTEGER},
#{type,jdbcType=TINYINT}, #{validateCode,jdbcType=VARCHAR}, #{deleteFlag,jdbcType=TINYINT},
#{createdId,jdbcType=INTEGER}, #{createdTime,jdbcType=TIMESTAMP}, #{modifiedId,jdbcType=INTEGER},
#{modifiedTime,jdbcType=TIMESTAMP}
)
</insert>
</mapper> </mapper>
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册