|
@ -21,6 +21,7 @@ import com.yihu.wlyy.repository.patient.SignFamilyDao;
|
|
|
import com.yihu.wlyy.service.app.device.DeviceDetailService;
|
|
|
import com.yihu.wlyy.service.app.device.PatientDeviceService;
|
|
|
import com.yihu.wlyy.service.app.health.bank.CreditLogService;
|
|
|
import com.yihu.wlyy.service.app.health.bank.TaskService;
|
|
|
import com.yihu.wlyy.util.*;
|
|
|
import net.sf.json.JSONArray;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
@ -72,6 +73,8 @@ public class DataHandingService {
|
|
|
private DeviceDetailDao deviceDetailDao;
|
|
|
@Autowired
|
|
|
private SignFamilyDao signFamilyDao;
|
|
|
@Autowired
|
|
|
private TaskService taskService;
|
|
|
|
|
|
@Transactional
|
|
|
public String producePatientAndDoctorPassword() {
|
|
@ -689,4 +692,58 @@ public class DataHandingService {
|
|
|
sqlStr = sqlList.toArray(sqlStr);
|
|
|
jdbcTemplate.batchUpdate(sqlStr);
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public int addHealthActivitRecord()throws Exception{
|
|
|
String creditsSql ="SELECT" +
|
|
|
" cd.patient_id," +
|
|
|
" bt.title," +
|
|
|
" bt.task_code" +
|
|
|
" FROM" +
|
|
|
" wlyy_health_bank.wlyy_health_bank_credits_detail cd" +
|
|
|
" LEFT JOIN wlyy_health_bank.wlyy_health_bank_task bt ON cd.transaction_id = bt.id" +
|
|
|
" WHERE" +
|
|
|
" (" +
|
|
|
" bt.task_code = 'GLU_BIND'" +
|
|
|
" OR task_code = 'BP_BIND'" +
|
|
|
" )" +
|
|
|
" AND cd.`status` = 1" +
|
|
|
" GROUP BY cd.patient_id";
|
|
|
List<Map<String,Object>> creditsRecordList = jdbcTemplate.queryForList(creditsSql);
|
|
|
|
|
|
String activitSql ="SELECT" +
|
|
|
" bar.patient_id,bt.title,bt.task_code" +
|
|
|
" FROM" +
|
|
|
" wlyy_health_bank.wlyy_health_bank_active_record bar" +
|
|
|
" LEFT JOIN wlyy_health_bank.wlyy_health_bank_task bt ON bar.task_id = bt.id" +
|
|
|
" WHERE" +
|
|
|
" (" +
|
|
|
" bt.task_code = 'GLU_BIND'" +
|
|
|
" OR task_code = 'BP_BIND'" +
|
|
|
" )" +
|
|
|
" GROUP BY bar.patient_id ";
|
|
|
List<Map<String,Object>> activitRecordList = jdbcTemplate.queryForList(activitSql);
|
|
|
|
|
|
int result =0;
|
|
|
for (Map<String,Object> creditMap : creditsRecordList){
|
|
|
String creditPatient = String.valueOf(creditMap.get("patient_id"));
|
|
|
int i =0;
|
|
|
for (Map<String,Object> activitMap : activitRecordList){
|
|
|
String acPatient = String.valueOf(activitMap.get("patient_id"));
|
|
|
if (creditPatient.equals(acPatient)){
|
|
|
i++;
|
|
|
}
|
|
|
}
|
|
|
if (i==0){
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
|
|
|
jsonObject.put("patientId",creditPatient);
|
|
|
jsonObject.put("taskCode",String.valueOf(creditMap.get("task_code")));
|
|
|
com.alibaba.fastjson.JSONObject resultJson = taskService.createActiveRecord(jsonObject);
|
|
|
if(resultJson!=null && resultJson.getInteger("status")==200){
|
|
|
result++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
}
|