|
@ -119,21 +119,21 @@ public class PrescriptionDispensaryCodeService extends BaseService {
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
String year = String.valueOf(cal.get(Calendar.YEAR));
|
|
|
int temp = cal.get(Calendar.MONTH)+1;
|
|
|
String month = cal.get(Calendar.MONTH)+1<10?"0"+temp:""+temp;
|
|
|
String day = ""+cal.get(Calendar.DAY_OF_MONTH);
|
|
|
String ymd = year+month+day;
|
|
|
// String month = cal.get(Calendar.MONTH)+1<10?"0"+temp:""+temp;
|
|
|
// String day = ""+cal.get(Calendar.DAY_OF_MONTH);
|
|
|
// String ymd = year+month+day;
|
|
|
// 二维码内容
|
|
|
String code = "";
|
|
|
synchronized (obj){
|
|
|
boolean bl = true;
|
|
|
while (bl){
|
|
|
String randomNum = randomString("0123456789",6);
|
|
|
code = ymd +randomNum;
|
|
|
code = randomString("0123456789",8);
|
|
|
bl = getResidentQRCodeCount(code);
|
|
|
}
|
|
|
}
|
|
|
// 生成二维码
|
|
|
InputStream ipt = QrcodeUtil.createQrcode(Base64.encode(code.getBytes()),300,"png");
|
|
|
// InputStream ipt = QrcodeUtil.createQrcode(Base64.encode(code.getBytes()),300,"png");
|
|
|
InputStream ipt = QrcodeUtil.createQrcode(code,300,"png");
|
|
|
ObjectNode imgNode = FastDFSUtil.upload(ipt,"png","QRCode_"+System.currentTimeMillis());
|
|
|
// Prescription类 取药类型:1 自取 2快递配送 3健管师配送
|
|
|
String fileUrl = fastdfs_file_url + imgNode.get("groupName").toString().replaceAll("\"","")
|
|
@ -146,6 +146,7 @@ public class PrescriptionDispensaryCodeService extends BaseService {
|
|
|
prescriptionDispensaryCode.setImgUrl(fileUrl);
|
|
|
prescriptionDispensaryCode.setPrescriptionCode(prescriptionCode);
|
|
|
prescriptionDispensaryCode.setType(1);
|
|
|
prescriptionDispensaryCode.setIsUse(0);
|
|
|
return prescriptionDispensaryCodeDao.save(prescriptionDispensaryCode);
|
|
|
}
|
|
|
|
|
@ -164,7 +165,8 @@ public class PrescriptionDispensaryCodeService extends BaseService {
|
|
|
//String jgsID= "";//配送员用户ID后4位
|
|
|
// String jgsCode = code+"1234";//code+jgsID.substring(jgsID.length()-4);
|
|
|
// 生成二维码
|
|
|
InputStream ipt = QrcodeUtil.createQrcode(Base64.encode(jgsCode.getBytes()),300,"png");
|
|
|
// InputStream ipt = QrcodeUtil.createQrcode(Base64.encode(jgsCode.getBytes()),300,"png");
|
|
|
InputStream ipt = QrcodeUtil.createQrcode(jgsCode,300,"png");
|
|
|
ObjectNode imgNode = FastDFSUtil.upload(ipt,"png","QRCode_"+System.currentTimeMillis());
|
|
|
// Prescription类 取药类型:1 自取 2快递配送 3健管师配送
|
|
|
String fileUrl = fastdfs_file_url + imgNode.get("groupName").toString().replaceAll("\"","")
|
|
@ -176,6 +178,7 @@ public class PrescriptionDispensaryCodeService extends BaseService {
|
|
|
prescriptionDispensaryCode.setImgUrl(fileUrl);
|
|
|
prescriptionDispensaryCode.setPrescriptionCode(prescriptionCode);
|
|
|
prescriptionDispensaryCode.setType(type);
|
|
|
prescriptionDispensaryCode.setIsUse(0);
|
|
|
return prescriptionDispensaryCodeDao.save(prescriptionDispensaryCode);
|
|
|
|
|
|
}
|
|
@ -192,12 +195,26 @@ public class PrescriptionDispensaryCodeService extends BaseService {
|
|
|
return sb.toString();
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> getQrcode(String dispensaryCode ,String patientCode ,Integer type){
|
|
|
public Map<String, Object> getQrcode(String prescriptionCode ,String patientCode ,Integer type){
|
|
|
String sql = "select p2.is_use as isUse,p2.code as dispensaryCode,p2.img_url,p3.hospital_name as hospitalName from wlyy_prescription_dispensary_code p2 " +
|
|
|
" left join wlyy_prescription p1 on p2.prescription_code=p1.code LEFT JOIN wlyy_prescription_expressage p3 on p1.code=p3.prescription_code " +
|
|
|
" where p2.prescription_code=? and p1.patient=? and p2.type=? and p2.is_Use=0 ";
|
|
|
Map<String, Object> result = jdbcTemplate.queryForMap(sql,dispensaryCode,patientCode,type);
|
|
|
Map<String, Object> result = jdbcTemplate.queryForMap(sql,prescriptionCode,patientCode,type);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@Transactional
|
|
|
public PrescriptionDispensaryCode scanQrcode(String code) throws Exception{
|
|
|
|
|
|
PrescriptionDispensaryCode prescriptionDispensaryCode = prescriptionDispensaryCodeDao.findByCodeAndIsUse(code,0);
|
|
|
if(prescriptionDispensaryCode!=null){
|
|
|
|
|
|
prescriptionDispensaryCode.setIsUse(1);
|
|
|
prescriptionDispensaryCodeDao.save(prescriptionDispensaryCode);
|
|
|
}else{
|
|
|
throw new Exception("二维码输入错误或者已过期!");
|
|
|
}
|
|
|
return prescriptionDispensaryCode;
|
|
|
}
|
|
|
|
|
|
}
|