| | |
| | | import com.bstek.bdf2.core.orm.hibernate.HibernateDao; |
| | | import com.bstek.dorado.data.provider.Page; |
| | | import com.ld.igds.m.InoutManageUtil; |
| | | import com.ld.igds.models.MPlan; |
| | | import com.ld.igds.models.MPlanDetail; |
| | | import com.ld.igds.models.InoutPlan; |
| | | import com.ld.igds.models.InoutPlanDetail; |
| | | import com.ld.igds.util.ContextUtil; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.hibernate.Session; |
| | |
| | | @Component |
| | | public class HPlanManageService extends HibernateDao { |
| | | |
| | | public void pagePlan(Page<MPlan> page, Map<String, Object> param) |
| | | public void pagePlan(Page<InoutPlan> page, Map<String, Object> param) |
| | | throws Exception { |
| | | String hql = " from " + MPlan.class.getName() |
| | | String hql = " from " + InoutPlan.class.getName() |
| | | + " where companyId =:companyId and deptId =:deptId"; |
| | | |
| | | Map<String, Object> args = new HashMap<String, Object>(); |
| | |
| | | |
| | | |
| | | |
| | | public List<MPlanDetail> listPlanDetail(String planId) { |
| | | public List<InoutPlanDetail> listPlanDetail(String planId) { |
| | | |
| | | String hql = " from " + MPlanDetail.class.getName(); |
| | | String hql = " from " + InoutPlanDetail.class.getName(); |
| | | |
| | | if(null != planId){ |
| | | hql += " where planId=:planId "; |
| | |
| | | } |
| | | |
| | | @Transactional |
| | | public String delPlan(MPlan data) { |
| | | public String delPlan(InoutPlan data) { |
| | | Session session = this.getSessionFactory().openSession(); |
| | | try { |
| | | if (null != data.getId()) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | public String delPlanDetail(MPlanDetail data) { |
| | | public String delPlanDetail(InoutPlanDetail data) { |
| | | Session session = this.getSessionFactory().openSession(); |
| | | try { |
| | | if (null != data.getId()) { |
| | |
| | | } |
| | | |
| | | private void delPlanDetailByPlanId(String id, Session session) { |
| | | String hql = " delete from " + MPlanDetail.class.getName() |
| | | String hql = " delete from " + InoutPlanDetail.class.getName() |
| | | + " where planId=:planId"; |
| | | |
| | | session.createQuery(hql).setString("planId", id).executeUpdate(); |
| | | } |
| | | |
| | | public void savePlan(MPlan data) { |
| | | public void savePlan(InoutPlan data) { |
| | | if (null == data.getCompanyId()) { |
| | | data.setCompanyId(ContextUtil.getCompanyId()); |
| | | } |
| | |
| | | Session session = this.getSessionFactory().openSession(); |
| | | try { |
| | | if (null == data.getId()) { |
| | | List<MPlan> list = getPlanId(data); |
| | | List<InoutPlan> list = getPlanId(data); |
| | | data.setId(InoutManageUtil.createPlanId(data.getType(), data.getYear(), list)); |
| | | data.setCreateUser(ContextUtil.getLoginUserCName()); |
| | | data.setCreateTime(new Date()); |
| | |
| | | } |
| | | } |
| | | |
| | | private void savePlanDetail(List<MPlanDetail> details, String planId, |
| | | Session session) { |
| | | private void savePlanDetail(List<InoutPlanDetail> details, String planId, |
| | | Session session) { |
| | | if (null == details || details.isEmpty()) |
| | | return; |
| | | for (MPlanDetail planDetail : details) { |
| | | for (InoutPlanDetail planDetail : details) { |
| | | if (null == planDetail.getId()) { |
| | | planDetail.setPlanId(planId); |
| | | planDetail.setId(ContextUtil.getUUID()); |
| | | planDetail.setCreateTime(new Date()); |
| | | session.save(planDetail); |
| | | } else { |
| | | session.update(planDetail); |
| | |
| | | } |
| | | } |
| | | |
| | | public List<MPlan> getPlanId(MPlan plan){ |
| | | String hql = " from " + MPlan.class.getName() |
| | | public List<InoutPlan> getPlanId(InoutPlan plan){ |
| | | String hql = " from " + InoutPlan.class.getName() |
| | | + " where companyId =:companyId and deptId =:deptId and year =:year"; |
| | | |
| | | Map<String,Object> args = new HashMap<String,Object>(); |