package com.ld.igds.m.service; import com.bstek.bdf2.core.orm.hibernate.HibernateDao; import com.bstek.dorado.data.provider.Page; import com.ld.igds.models.InoutAppoint; import com.ld.igds.util.ContextUtil; import com.ld.igds.util.DateUtil; import org.apache.commons.lang3.StringUtils; import org.hibernate.Session; import org.springframework.stereotype.Component; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; /** * 预约管理 * * @author: czt * @date 2023-04-12 17:47 * */ @Component public class HAppointService extends HibernateDao { public void pageInoutAppoint(Page page, Map param) throws Exception { String hql = " from " + InoutAppoint.class.getName() + " where companyId =:companyId and deptId =:deptId"; Map args = new HashMap(); args.put("companyId", ContextUtil.getCompanyId()); args.put("deptId", ContextUtil.subDeptId(null)); if (null != param) { String str = (String) param.get("bizType"); if (StringUtils.isNotEmpty(str)) { hql += " and bizType =:bizType"; args.put("bizType", str); } str = (String) param.get("plateNum"); if (StringUtils.isNotEmpty(str)) { hql += " and plateNum like:plateNum"; args.put("plateNum", "%" + str + "%"); } str = (String) param.get("status"); if (StringUtils.isNotEmpty(str)) { hql += " and status =:status"; args.put("status", str); } str = (String) param.get("customerId"); if (StringUtils.isNotEmpty(str)) { hql += " and customerId =:customerId"; args.put("customerId", str); } Date date = (Date) param.get("date"); if (null != date) { hql += " and dataTime >=:start and dataTime <=:end"; args.put("start", DateUtil.getCurZero(date)); args.put("end", DateUtil.getNextZero(date)); } } String count = "select count(*) " + hql; hql += " order by updateTime desc"; this.pagingQuery(page, hql, count, args); } public void saveOrUpInoutAppoint(InoutAppoint data) { Session session = this.getSessionFactory().openSession(); try { session.saveOrUpdate(data); } catch (Exception e) { e.printStackTrace(); } finally { session.flush(); session.close(); } } public String delInoutAppoint(InoutAppoint data) { Session session = this.getSessionFactory().openSession(); try { if (null != data.getId()) { session.delete(data); } } catch (Exception e) { e.printStackTrace(); } finally { session.flush(); session.close(); } return null; } public InoutAppoint getInoutAppointById(String id, String deptId) { if(StringUtils.isEmpty(id) || StringUtils.isEmpty(deptId)){ return null; } String hql = " from " + InoutAppoint.class.getName() + " where id =:id and deptId =:deptId"; Map args = new HashMap(); args.put("id", id); args.put("deptId", deptId); List list = this.query(hql, args); if(null == list || list.isEmpty()){ return null; } return list.get(0); } }