| | |
| | | |
| | | @Component |
| | | public class HInoutSettleService extends HibernateDao { |
| | | |
| | | |
| | | public void pageIoutRecord(Page<InoutRecord> page, InoutParam param) throws Exception { |
| | | String hql = " from " + InoutRecord.class.getName() |
| | | + " where companyId =:companyId and progress =:progress"; |
| | | Map<String, Object> args = new HashMap<String, Object>(); |
| | | |
| | | args.put("companyId", ContextUtil.getCompanyId()); |
| | | args.put("progress", InoutConstant.PROGRESS_RECORD); |
| | | |
| | | if (StringUtils.isNotEmpty(param.getType())) { |
| | | hql += " and type =:type"; |
| | | args.put("type", param.getType()); |
| | | } |
| | | public void pageIoutRecord(Page<InoutRecord> page, InoutParam param) throws Exception { |
| | | String hql = " from " + InoutRecord.class.getName() |
| | | + " where companyId =:companyId and progress =:progress"; |
| | | Map<String, Object> args = new HashMap<String, Object>(); |
| | | |
| | | if (StringUtils.isNotEmpty(param.getId())) { |
| | | hql += " and id like:id"; |
| | | args.put("id", "%" + param.getId() + "%"); |
| | | } |
| | | args.put("companyId", ContextUtil.getCompanyId()); |
| | | args.put("progress", InoutConstant.PROGRESS_RECORD); |
| | | |
| | | if (StringUtils.isNotEmpty(param.getPlateNum())) { |
| | | hql += " and plateNum like:plateNum"; |
| | | args.put("plateNum", "%" + param.getPlateNum() + "%"); |
| | | } |
| | | if (StringUtils.isNotEmpty(param.getType())) { |
| | | hql += " and type =:type"; |
| | | args.put("type", param.getType()); |
| | | } |
| | | |
| | | if (StringUtils.isNotEmpty(param.getCustomerId())) { |
| | | hql += " and customerId =:customerId"; |
| | | args.put("customerId", param.getCustomerId()); |
| | | } |
| | | if (StringUtils.isNotEmpty(param.getId())) { |
| | | hql += " and id like:id"; |
| | | args.put("id", "%" + param.getId() + "%"); |
| | | } |
| | | |
| | | if (StringUtils.isNotEmpty(param.getDepotId())) { |
| | | hql += " and depotId =:depotId"; |
| | | args.put("depotId", param.getDepotId()); |
| | | } |
| | | if (StringUtils.isNotEmpty(param.getPlateNum())) { |
| | | hql += " and plateNum like:plateNum"; |
| | | args.put("plateNum", "%" + param.getPlateNum() + "%"); |
| | | } |
| | | |
| | | if (StringUtils.isNotEmpty(param.getFoodVariety())) { |
| | | hql += " and foodVariety =:foodVariety"; |
| | | args.put("foodVariety", param.getFoodVariety()); |
| | | } |
| | | if (StringUtils.isNotEmpty(param.getCustomerId())) { |
| | | hql += " and customerId =:customerId"; |
| | | args.put("customerId", param.getCustomerId()); |
| | | } |
| | | |
| | | if (StringUtils.isNotEmpty(param.getSettleTag())) { |
| | | hql += " and settleTag =:settleTag"; |
| | | args.put("settleTag", param.getSettleTag()); |
| | | } |
| | | if (StringUtils.isNotEmpty(param.getDepotId())) { |
| | | hql += " and depotId =:depotId"; |
| | | args.put("depotId", param.getDepotId()); |
| | | } |
| | | |
| | | if (null != param.getStart()) { |
| | | hql += " and completeTime >=:start"; |
| | | args.put("start", DateUtil.getCurZero(param.getStart())); |
| | | } |
| | | if (StringUtils.isNotEmpty(param.getFoodVariety())) { |
| | | hql += " and foodVariety =:foodVariety"; |
| | | args.put("foodVariety", param.getFoodVariety()); |
| | | } |
| | | |
| | | if (null != param.getEnd()) { |
| | | hql += " and completeTime <=:end"; |
| | | args.put("end", DateUtil.getNextZero(param.getEnd())); |
| | | } |
| | | |
| | | hql += " and RECORD_STATUS_ <> 'ERROR' and RECORD_STATUS_ <> 'DEL'"; |
| | | if (null != param.getStart()) { |
| | | hql += " and completeTime >=:start"; |
| | | args.put("start", DateUtil.getCurZero(param.getStart())); |
| | | } |
| | | |
| | | String countHql = " select count(*) " + hql; |
| | | |
| | | hql += " order by id desc "; |
| | | if (null != param.getEnd()) { |
| | | hql += " and completeTime <=:end"; |
| | | args.put("end", DateUtil.getNextZero(param.getEnd())); |
| | | } |
| | | |
| | | this.pagingQuery(page, hql, countHql, args); |
| | | } |
| | | hql += " and RECORD_STATUS_ <> 'ERROR' and RECORD_STATUS_ <> 'DEL'"; |
| | | |
| | | public InoutSettle getSettleById(String companyId, String id) { |
| | | String hql = " from " + InoutSettle.class.getName() |
| | | + " where companyId=:companyId"; |
| | | String countHql = " select count(*) " + hql; |
| | | |
| | | Map<String, Object> args = new HashMap<String, Object>(); |
| | | if (StringUtils.isEmpty(companyId)) { |
| | | companyId = ContextUtil.getCompanyId(); |
| | | } |
| | | args.put("companyId", ContextUtil.getCompanyId()); |
| | | if (StringUtils.isNotEmpty(id)) { |
| | | hql += " and id=:id"; |
| | | args.put("id", id); |
| | | } |
| | | hql += " order by id desc "; |
| | | |
| | | hql += " order by payTime desc"; |
| | | List<InoutSettle> list = this.query(hql, args); |
| | | if (list != null && list.size() > 0) { |
| | | return list.get(0); |
| | | } |
| | | return null; |
| | | } |
| | | this.pagingQuery(page, hql, countHql, args); |
| | | } |
| | | |
| | | |
| | | public String saveOrUpdateData(InoutSettle data) { |
| | | Session session = this.getSessionFactory().openSession(); |
| | | |
| | | try { |
| | | if(null == data.getPayTime()){ |
| | | data.setPayTime(new Date()); |
| | | } |
| | | |
| | | if (null == data.getCompanyId()) { |
| | | data.setCompanyId(ContextUtil.getCompanyId()); |
| | | session.save(data); |
| | | } else { |
| | | session.update(data); |
| | | } |
| | | } finally { |
| | | session.flush(); |
| | | session.close(); |
| | | } |
| | | return null; |
| | | } |
| | | public InoutSettle getSettleById(String companyId, String id) { |
| | | String hql = " from " + InoutSettle.class.getName() |
| | | + " where companyId=:companyId"; |
| | | |
| | | public void updateInoutRecordPay(String id) { |
| | | String hql = " update "+InoutRecord.class.getName() +" set settleTag=:settleTag where id=:id"; |
| | | Session session = this.getSessionFactory().openSession(); |
| | | try { |
| | | Query query = session.createQuery(hql); |
| | | query.setString("settleTag", Constant.YN_Y); |
| | | query.setString("id", id); |
| | | query.executeUpdate(); |
| | | } finally { |
| | | session.flush(); |
| | | session.close(); |
| | | } |
| | | } |
| | | Map<String, Object> args = new HashMap<String, Object>(); |
| | | if (StringUtils.isEmpty(companyId)) { |
| | | companyId = ContextUtil.getCompanyId(); |
| | | } |
| | | args.put("companyId", ContextUtil.getCompanyId()); |
| | | if (StringUtils.isNotEmpty(id)) { |
| | | hql += " and id=:id"; |
| | | args.put("id", id); |
| | | } |
| | | |
| | | |
| | | hql += " order by payTime desc"; |
| | | List<InoutSettle> list = this.query(hql, args); |
| | | if (list != null && list.size() > 0) { |
| | | return list.get(0); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | public String saveOrUpdateData(InoutSettle data) { |
| | | Session session = this.getSessionFactory().openSession(); |
| | | |
| | | try { |
| | | if (null == data.getPayTime()) { |
| | | data.setPayTime(new Date()); |
| | | } |
| | | |
| | | if (null == data.getCompanyId()) { |
| | | data.setCompanyId(ContextUtil.getCompanyId()); |
| | | session.save(data); |
| | | } else { |
| | | session.update(data); |
| | | } |
| | | } finally { |
| | | session.flush(); |
| | | session.close(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public void updateInoutRecordPay(String id) { |
| | | String hql = " update " + InoutRecord.class.getName() + " set settleTag=:settleTag where id=:id"; |
| | | Session session = this.getSessionFactory().openSession(); |
| | | try { |
| | | Query query = session.createQuery(hql); |
| | | query.setString("settleTag", Constant.YN_Y); |
| | | query.setString("id", id); |
| | | query.executeUpdate(); |
| | | } finally { |
| | | session.flush(); |
| | | session.close(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据条件分页获取结算信息 |
| | | * |
| | | * @param page |
| | | * @param param |
| | | */ |
| | | public void pageSettle(Page<InoutSettle> page, InoutParam param) throws Exception { |
| | | String hql = " from " + InoutSettle.class.getName() |
| | | + " where companyId =:companyId and deptId=:deptId"; |
| | | Map<String, Object> args = new HashMap<>(); |
| | | |
| | | args.put("companyId", param.getCompanyId()); |
| | | args.put("deptId", param.getDeptId()); |
| | | |
| | | if (StringUtils.isNotEmpty(param.getType())) { |
| | | hql += " and inoutType =:inoutType"; |
| | | args.put("inoutType", param.getType()); |
| | | } |
| | | |
| | | if (StringUtils.isNotEmpty(param.getId())) { |
| | | hql += " and id like:id"; |
| | | args.put("id", "%" + param.getId() + "%"); |
| | | } |
| | | |
| | | if (StringUtils.isNotEmpty(param.getDepotId())) { |
| | | hql += " and depotId =:depotId"; |
| | | args.put("depotId", param.getDepotId()); |
| | | } |
| | | if (null != param.getStart()) { |
| | | hql += " and payTime >=:start"; |
| | | args.put("start", DateUtil.getCurZero(param.getStart())); |
| | | } |
| | | if (null != param.getEnd()) { |
| | | hql += " and payTime <=:end"; |
| | | args.put("end", DateUtil.getNextZero(param.getEnd())); |
| | | } |
| | | |
| | | String countHql = " select count(*) " + hql; |
| | | |
| | | hql += " order by id desc "; |
| | | |
| | | this.pagingQuery(page, hql, countHql, args); |
| | | } |
| | | |
| | | |
| | | } |