|  |  |  | 
|---|
|  |  |  | import org.springframework.beans.BeanUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Repository; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Repository | 
|---|
|  |  |  | 
|---|
|  |  |  | param.setFoodVariety(data.getFoodVariety()); | 
|---|
|  |  |  | param.setYear(data.getYear()); | 
|---|
|  |  |  | //若有合同信息,添加合同信息 | 
|---|
|  |  |  | if(StringUtils.isNotEmpty(data.getContractId())){ | 
|---|
|  |  |  | if (StringUtils.isNotEmpty(data.getContractId())) { | 
|---|
|  |  |  | param.setContractId(data.getContractId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //若有计划信息,添加计划信息 | 
|---|
|  |  |  | if(StringUtils.isNotEmpty(data.getPlanId())){ | 
|---|
|  |  |  | if (StringUtils.isNotEmpty(data.getPlanId())) { | 
|---|
|  |  |  | param.setPlanId(data.getPlanId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | param.setCompleteStatus(InoutConstant.COMPLETE_STATUS_NONE); | 
|---|
|  |  |  | 
|---|
|  |  |  | param.setFoodVariety(data.getFoodVariety()); | 
|---|
|  |  |  | param.setYear(data.getYear()); | 
|---|
|  |  |  | //若有合同信息,添加合同信息 | 
|---|
|  |  |  | if(StringUtils.isNotEmpty(data.getContractId())){ | 
|---|
|  |  |  | if (StringUtils.isNotEmpty(data.getContractId())) { | 
|---|
|  |  |  | param.setContractId(data.getContractId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //若有计划信息,添加计划信息 | 
|---|
|  |  |  | if(StringUtils.isNotEmpty(data.getPlanId())){ | 
|---|
|  |  |  | if (StringUtils.isNotEmpty(data.getPlanId())) { | 
|---|
|  |  |  | param.setPlanId(data.getPlanId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | param.setCompleteStatus(InoutConstant.COMPLETE_STATUS_NONE); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 根据参数查询出入库通知单 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param parameter | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | 
|---|
|  |  |  | String hql = " from "; | 
|---|
|  |  |  | if (InoutConstant.TYPE_IN.equals(type)) { | 
|---|
|  |  |  | hql += InoutNoticeIn.class.getName(); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | hql += InoutNoticeOut.class.getName(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | hql += " where companyId =:companyId and deptId =:deptId"; | 
|---|
|  |  |  | hql += " where companyId =:companyId and deptId =:deptId and completeStatus =:completeStatus"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map<String, Object> args = new HashMap<>(); | 
|---|
|  |  |  | args.put("companyId", ContextUtil.getCompanyId()); | 
|---|
|  |  |  | args.put("deptId", ContextUtil.subDeptId(null)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | args.put("completeStatus", "NONE"); | 
|---|
|  |  |  | String str = (String) parameter.get("customerId"); | 
|---|
|  |  |  | if (StringUtils.isNotEmpty(str)) { | 
|---|
|  |  |  | hql += " and customerId =:customerId"; | 
|---|
|  |  |  | 
|---|
|  |  |  | args.put("foodVariety", str); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(InoutConstant.TYPE_OUT.equals(type)){ | 
|---|
|  |  |  | if (InoutConstant.TYPE_OUT.equals(type)) { | 
|---|
|  |  |  | str = (String) parameter.get("depotId"); | 
|---|
|  |  |  | if (StringUtils.isNotEmpty(str)) { | 
|---|
|  |  |  | hql += " and depotId =:depotId"; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Object> list1 = this.query(hql, args); | 
|---|
|  |  |  | List<NoticeDto> list = new ArrayList<>(); | 
|---|
|  |  |  | if(list1 == null || list1.isEmpty()){ | 
|---|
|  |  |  | if (list1 == null || list1.isEmpty()) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | NoticeDto dto; | 
|---|
|  |  |  | for (Object o : list1) { | 
|---|
|  |  |  | dto = new NoticeDto(); | 
|---|
|  |  |  | BeanUtils.copyProperties(o,dto); | 
|---|
|  |  |  | BeanUtils.copyProperties(o, dto); | 
|---|
|  |  |  | list.add(dto); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return list; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 根据id获取通知单信息 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param id | 
|---|
|  |  |  | * @param type | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public NoticeDto queryNoticeById(String id, String type) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(StringUtils.isEmpty(id) || StringUtils.isEmpty(type)){ | 
|---|
|  |  |  | if (StringUtils.isEmpty(id) || StringUtils.isEmpty(type)) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String hql = " from "; | 
|---|
|  |  |  | if (InoutConstant.TYPE_IN.equals(type)) { | 
|---|
|  |  |  | hql += InoutNoticeIn.class.getName(); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | hql += InoutNoticeOut.class.getName(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | hql += " where companyId =:companyId and deptId =:deptId and id =:id"; | 
|---|
|  |  |  | 
|---|
|  |  |  | hql += " order by id "; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Object> list = this.query(hql, args); | 
|---|
|  |  |  | if(list == null || list.isEmpty()){ | 
|---|
|  |  |  | if (list == null || list.isEmpty()) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | NoticeDto dto = new NoticeDto(); | 
|---|