<!-- 批量更新UserIndex对象 -->
<update id="batchUpdateUserIndex" parameterType="java.util.List">
INSERT INTO sys_user_index (user_id, flag, blood_flag, blood_oxygen_flag)
VALUES
<foreach collection="list" item="userIndex" index="index" separator=",">
(#{userIndex.userId}, #{userIndex.flag}, #{userIndex.bloodFlag}, #{userIndex.bloodOxygenFlag})
</foreach>
ON DUPLICATE KEY UPDATE
flag = VALUES(flag),
blood_flag = VALUES(blood_flag),
blood_oxygen_flag = VALUES(blood_oxygen_flag);
</update>
void batchUpdateUserIndex(@Param("list") List<UserIndex> userIndexesToUpdate);
public List<SysUserExport> allUserDetectionDetailIndex(Map<String, Object> map) {
List<SysUserExport> SysUserList = sysUserInfoRecordMapper.selectAllSysUserInfoRecordListIndex(map);
List<UserIndex> userIndexesToUpdate = new ArrayList<>();
for (SysUserExport list : SysUserList) {
if (list.getAlcoholDetectionResult() != null && !list.getAlcoholDetectionResult().equals(" ")) {
String alcohol = list.getAlcoholDetectionResult();
alcohol = alcohol.replace("测酒结果:", "");
list.setAlcoholDetectionResult(alcohol);
String alcoholValue = alcohol.substring(0, alcohol.indexOf("mg"));
double alcoholNumber = Double.parseDouble(alcoholValue);
if (alcoholNumber >= 20.0) {
list.setHealth(list.getHealth() + "酒精检测不通过;");
list.setFlag("2");
} else {
list.setHealth(list.getHealth() + "酒精检测通过;");
list.setFlag("1");
}
}
if (list.getBloodPressureDetectionResult() != null && !list.getBloodPressureDetectionResult().equals(" ")) {
String blood = list.getBloodPressureDetectionResult();
blood = blood.replace("血压检测结果:", "");
list.setBloodPressureDetectionResult(blood);
if (blood.contains("高血压")) {
list.setHealth(list.getHealth() + "高血压;");
list.setBloodFlag("2");
} else if (blood.contains("低血压")) {
list.setHealth(list.getHealth() + "低血压;");
list.setBloodFlag("2");
} else if (blood.contains("Error")) {
list.setHealth(list.getHealth() + "检测过程异常");
list.setBloodFlag("2");
} else {
list.setHealth(list.getHealth() + "血压检测通过;");
list.setBloodFlag("1");
}
}
if (list.getBloodOxygenDetectionResult() != null && !list.getBloodOxygenDetectionResult().equals(" ")) {
String bloodO = list.getBloodOxygenDetectionResult();
int percentIndex = bloodO.indexOf("%");
String bloodONumS = bloodO.substring(13, percentIndex);
int bloodONum = Integer.parseInt(bloodONumS);
if (bloodONum >= 95 && bloodONum < 100) {
list.setHealth(list.getHealth() + "血氧正常;");
list.setBloodOxygenFlag("1");
} else {
list.setHealth(list.getHealth() + "低血氧;");
list.setBloodOxygenFlag("2");
}
}
if (list.getFlag() != null || list.getBloodFlag() != null || list.getBloodOxygenFlag() != null) {
UserIndex sysUser = new UserIndex();
sysUser.setUserId(list.getUserId());
sysUser.setFlag(list.getFlag());
sysUser.setBloodFlag(list.getBloodFlag());
sysUser.setBloodOxygenFlag(list.getBloodOxygenFlag());
userIndexesToUpdate.add(sysUser);
}
}
if (!userIndexesToUpdate.isEmpty()) {
userIndexMapper.batchUpdateUserIndex(userIndexesToUpdate);
}
return SysUserList;
}