package com.chinaitop.depot.business.controller;
import com.chinaitop.depot.business.model.BusinessDeliveryStorageNotice;
import com.chinaitop.depot.business.model.BusinessStoreWareDetail;
import com.chinaitop.depot.business.model.enums.AuditType;
import com.chinaitop.depot.business.model.enums.StoreWareType;
import com.chinaitop.depot.business.model.vo.BusinessDeliveryStorageNoticeAuditVO;
import com.chinaitop.depot.business.service.BusinessDeliveryStorageNoticeService;
import com.chinaitop.depot.business.service.BusinessStoreWareDetailService;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 粮库业务管理-出入库通知单管理
*
Title: BusinessDeliveryStorageNoticeController
* Description:
* @author yaoyabin
* @date 2017年10月25日 下午5:36:15
*/
@RestController
@RequestMapping(value="/depot/business/deliveryStorageNotice")
@Api(value= "BusinessDeliveryStorageNoticeController", description = "出入库通知单管理")
public class BusinessDeliveryStorageNoticeController {
@Resource
private BusinessDeliveryStorageNoticeService deliveryStorageNoticeService;
@Resource
private BusinessStoreWareDetailService businessStoreWareDetailService;
/* @Resource
private BasicCodeRuleService basicCodeRuleService;*/
/**
* 申请列表.
* @param pageNum 页码
* @param pageSize 每页显示条数
* @return
*/
@RequestMapping(value="/getList", produces = MediaType.APPLICATION_JSON_VALUE, method=RequestMethod.GET)
@ApiOperation(value="申请列表", notes = "查询数据列表,支持分页")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query"),
@ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query"),
@ApiImplicitParam(name = "userId", value = "当前登录人id", paramType = "query")
})
public PageInfo getList(Integer pageNum, Integer pageSize,
HttpServletRequest request, BusinessDeliveryStorageNotice notice,Integer userId) {
/*UserInfo userInfo= (UserInfo) request.getSession().getAttribute("userInfo");
Integer userId = userInfo.getUserId();*/
List list = deliveryStorageNoticeService.queryByExample(pageNum, pageSize, userId, notice, "FIELD(audit_state,0,3,1,2,4 ), id desc");
PageInfo pageInfo = new PageInfo(list);
return pageInfo;
}
//中转
/**
* 申请列表.
* @param pageNum 页码
* @param pageSize 每页显示条数
* @return
*/
@RequestMapping(value="/getListTransfer", produces = MediaType.APPLICATION_JSON_VALUE, method=RequestMethod.GET)
@ApiOperation(value="申请列表(中转)", notes = "查询数据列表,支持分页")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query"),
@ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query"),
@ApiImplicitParam(name = "userId", value = "当前登录人id", paramType = "query")
})
public PageInfo getListTransfer(Integer pageNum, Integer pageSize,
HttpServletRequest request, BusinessDeliveryStorageNotice notice,Integer userId) {
/*UserInfo userInfo= (UserInfo) request.getSession().getAttribute("userInfo");
Integer userId = userInfo.getUserId();*/
List list = deliveryStorageNoticeService.queryByExampleTransfer(pageNum, pageSize, userId, notice, "FIELD(audit_state,0,3,1,2,4 ), id desc");
PageInfo pageInfo = new PageInfo(list);
return pageInfo;
}
/**
* 审批通过列表.
* @param pageNum 页码
* @param pageSize 每页显示条数
* @return
*/
@RequestMapping(value="/getAuditPassList", produces = MediaType.APPLICATION_JSON_VALUE, method=RequestMethod.GET)
@ApiOperation(value="通知单审批通过列表", notes = "查询数据列表,支持分页")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query"),
@ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query")
})
public PageInfo getAuditPassList(Integer pageNum, Integer pageSize, BusinessDeliveryStorageNotice notice) {
notice.setAuditState(AuditType.AGREE.getAuditCode());
List list = deliveryStorageNoticeService.queryByExample(pageNum, pageSize, null, notice, "agree_time desc");
PageInfo pageInfo = new PageInfo(list);
return pageInfo;
}
/**
* 获取进度列表.
* @param pageNum
* @param pageSize
* @param deliveryStorageNotice
* @return
*/
@RequestMapping(value="/getScheduleList",produces = MediaType.APPLICATION_JSON_VALUE, method=RequestMethod.GET)
@ApiOperation(value="获取通知单进度列表", notes = "查询数据列表,支持分页")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query"),
@ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query")
})
public PageInfo getScheduleList(Integer pageNum, Integer pageSize, BusinessDeliveryStorageNotice deliveryStorageNotice) {
PageInfo pageInfo = deliveryStorageNoticeService.getScheduleList(pageNum, pageSize, deliveryStorageNotice);
return pageInfo;
}
/**
* 根据id查询.
* @param id 主键
* @return
*/
@RequestMapping(value="/edit", produces = MediaType.APPLICATION_JSON_VALUE, method=RequestMethod.GET)
@ApiOperation(value="根据id查找", notes = "根据id查找")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "通知单id", paramType = "query")
})
public Map edit(Integer id) {
Map modelMap = new HashMap();
if (id != null) {
BusinessDeliveryStorageNotice deliveryStorageNotice = deliveryStorageNoticeService.findById(id);
modelMap.put("deliveryStorageNotice", deliveryStorageNotice);
List list = new ArrayList();
Integer plan_id = deliveryStorageNotice.getPlanBid(); //计划ID
Integer contract_id = deliveryStorageNotice.getContractBid(); //合同ID
Map param_map = new HashMap();
List