| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649 |
- package com.chinaitop.depot.agent.quality.controller;
- import com.chinaitop.depot.agent.basic.service.agentService;
- import com.chinaitop.depot.agent.quality.model.BusinessAgentQuality;
- import com.chinaitop.depot.agent.quality.model.BusinessAgentQualityExample;
- import com.chinaitop.depot.agent.quality.model.BusinessAgentQualitySon;
- import com.chinaitop.depot.agent.quality.model.BusinessAgentQualitySonExample;
- import com.chinaitop.depot.agent.quality.service.AgentQualityService;
- import com.chinaitop.depot.agent.quality.service.AgentQualitySonService;
- import com.chinaitop.depot.utils.ImportServiceImpl;
- import com.chinaitop.utils.ParameterUtil;
- import com.fasterxml.jackson.core.type.TypeReference;
- import com.fasterxml.jackson.databind.ObjectMapper;
- import com.github.pagehelper.PageHelper;
- 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 org.springframework.web.multipart.MultipartFile;
- 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;
- /**
- * Created by product on 2017/10/11.
- */
- @RestController
- @RequestMapping(value = {"/agentQuality"})
- @Api(value= "AgentQualityController", description = "质量管理类")
- public class AgentQualityController {
- @Resource
- private AgentQualityService agentQualityService;
- @Resource
- private AgentQualitySonService agentQualitySonService;
- @Resource
- private ImportServiceImpl importService;
- @Resource
- private agentService agentService;
- /**
- * 封仓管理中查询出未封仓的质量管理信息,已经封仓的不要展示
- * 分页获取
- */
- @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 = "checktype", value = "检查的类型", paramType = "query"),
- @ApiImplicitParam(name = "checkResult", value = "检查结果", paramType = "query"),
- @ApiImplicitParam(name = "orgId", value = "粮库id", paramType = "query"),
- @ApiImplicitParam(name = "agentId", value = "代储点名称", paramType = "query"),
- @ApiImplicitParam(name = "agentDepotId", value = "粮库名称", paramType = "query"),
- @ApiImplicitParam(name = "storehouseId", value = "仓房名称", paramType = "query"),
- @ApiImplicitParam(name = "warehouseId", value = "货位名称", paramType = "query"),
- })
- public PageInfo<BusinessAgentQuality> listPage(Integer pageNum, Integer pageSize,String checktype, String checkResult, Integer orgId,
- Integer agentId,Integer agentDepotId,Integer storehouseId,Integer warehouseId) {
- BusinessAgentQuality qualityCheck = new BusinessAgentQuality();
- //根据后台传来的参数进行查找相应类型的类别0:初检 1:验收 2:质量普查 3:出库
- if (StringUtils.isNotBlank(checktype)){
- qualityCheck.setType(checktype);
- }
- // 粮库id.
- if (ParameterUtil.isnotnull(orgId)) {
- qualityCheck.setOrgId(orgId);
- }
- // 代储点名称.
- if (ParameterUtil.isnotnull(agentId)) {
- qualityCheck.setAgentId(agentId);
- }
- // 粮库名称.
- if (ParameterUtil.isnotnull(agentDepotId)) {
- qualityCheck.setAgentDepotId(agentDepotId);
- }
- // 仓房id.
- if (ParameterUtil.isnotnull(storehouseId)) {
- qualityCheck.setStorehouseId(storehouseId);
- }
- // 货位id.
- if (ParameterUtil.isnotnull(warehouseId)) {
- qualityCheck.setWarehouseId(warehouseId);
- }
- //检验结果(0:合格 , 1 :不合格)
- if (StringUtils.isNotBlank(checkResult)) {
- qualityCheck.setCheckResult(checkResult);
- }
- qualityCheck.setHistoryStatus(0);//0:最新数据 1:历史数据
- //查询出未封仓的质量管理信息 封仓状态:0:未封仓,1:已封仓
- qualityCheck.setSealStatus("0");
- if (pageNum!=null && pageSize!=null) {
- PageHelper.startPage(pageNum, pageSize);
- }
- List<BusinessAgentQuality> list = agentQualityService.queryByQualitycheck(qualityCheck);
- PageInfo<BusinessAgentQuality> pageInfo = new PageInfo<BusinessAgentQuality>(list);
- return pageInfo;
- }
-
- /**
- * 获取仓房或者货位(通过分组查询最新的满足条件的仓房或者货位).
- * @param qualitycheck
- * @return
- */
- @RequestMapping(value = "/getHouseOrWareList",produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
- @ApiOperation(value="获取仓房或者货位(通过分组查询最新的满足条件的仓房或者货位)", notes = "获取仓房或者货位(通过分组查询最新的满足条件的仓房或者货位)")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "qualitycheck", value = "质量管理对象", paramType = "query")
- })
- public List<BusinessAgentQuality> getHouseIdList(BusinessAgentQuality qualitycheck) {
- List<BusinessAgentQuality> list = agentQualityService.getHouseOrWareList(qualitycheck);
- return list;
- }
-
- /**
- * 获取第三方检验的质量标准字符串(手动拼写)
- * @param id
- * @return
- */
- @RequestMapping(value = "/getQualityStandardStr",produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
- @ApiOperation(value="获取第三方检验的质量标准字符串(手动拼写)", notes = "获取第三方检验的质量标准字符串(手动拼写)")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "id", value = "id", paramType = "form"),
- })
- public Map<String, Object> getQualityStandardStr(Integer id) {
- Map<String, Object> modelMap = new HashMap<String, Object>();
- if (id == null) {
- modelMap.put("status", "error");
- modelMap.put("msg", "id为空,查询质量标准失败!");
- } else {
- String qualityStandardStr = agentQualityService.getQualityStandardStr(id);
- modelMap.put("status", "success");
- modelMap.put("qualityStandard", qualityStandardStr);
- }
- return modelMap;
- }
-
-
- /**
- * 新增和修改的数据进行保存
- * @param qualitycheckJson
- * @return
- */
- @RequestMapping(value="/save", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
- @ApiOperation(value="新增/修改数据", notes = "新增/修改数据")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "qualitycheckJson", value = "质量基础信息JSON数据对象", paramType = "form"),
- @ApiImplicitParam(name = "qualityOneJson", value = "质量检测信息JSON数据对象", paramType = "form")
- })
- public Map<String, Object> save(String qualitycheckJson,String qualityOneJson) {
- Map<String, Object> modelMap = new HashMap<>();
- // JSON字符串转对象
- ObjectMapper mapper = new ObjectMapper();
- BusinessAgentQuality qualitycheck = null;
- List<BusinessAgentQualitySon> qualitycheckone = null;
- try {
- qualitycheck = (BusinessAgentQuality)mapper.readValue(qualitycheckJson, BusinessAgentQuality.class);
- //默认0:未封仓 1:已封仓
- qualitycheck.setSealStatus("0");
- qualitycheck.setHistoryStatus(0);//0:最新数据 1:历史数据
- Integer qualityCheckId = agentQualityService.save(qualitycheck);
- //关联保存日常检查和第三方检测的检测信息 如果为空则是对初检 验收等操作
- if(StringUtils.isNoneBlank(qualityOneJson)){
- qualitycheckone = mapper.readValue(qualityOneJson, new TypeReference<List<BusinessAgentQualitySon>>(){});
- for (int i = 0; i < qualitycheckone.size(); i++) {
- qualitycheckone.get(i).setQualitycheckId(qualityCheckId);
- agentQualityService.saveOne(qualitycheckone.get(i));
- }
- }
- modelMap.put("status", "success");
- } catch (IOException e) {
- modelMap.put("status", "error");
- e.printStackTrace();
- }
- return modelMap;
- }
- /**
- * 根据id加载对应数据
- * @param id
- * @return
- */
- @RequestMapping(value = "/loadDataById" ,produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
- @ApiOperation(value="根据id加载质量检查数据", notes = "根据id加载质量检查数据")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "id", value = "id", paramType = "query"),
- })
- public BusinessAgentQuality loadDataById(Integer id){
- BusinessAgentQuality qualitycheck=agentQualityService.loadDataById(id);
- return qualitycheck;
- }
- /**
- * 根据主键id移除数据
- * @param id
- * @return
- */
- @RequestMapping(value="/remove", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
- @ApiOperation(value="按ID删除质量检查信息", notes = "按ID删除质量检查信息")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "id", value = "数据ID", paramType = "form")
- })
- public Map<String, Object> remove(Integer id){
- Map<String,Object> retMap = new HashMap<String,Object>();
- agentQualityService.remove(id);
- //删除管理的数据
- BusinessAgentQualitySonExample qualitycheckSonExample = new BusinessAgentQualitySonExample();
- BusinessAgentQualitySonExample.Criteria criteria = qualitycheckSonExample.createCriteria();
- if(id != null){
- criteria.andQualitycheckIdEqualTo(id);
- }
- agentQualitySonService.removeSon(qualitycheckSonExample);
- retMap.put("msg","success");
- return retMap;
- }
- /**
- * 封仓管理中查询出所有仓已经封仓或者未封仓的质量管理信息
- * @param houseId
- * @param warehouseId
- * @return
- */
- @RequestMapping(value="/getFoodsealList",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 = "houseId", value = "仓房ID", paramType = "query"),
- @ApiImplicitParam(name = "warehouseId", value = "货位ID", paramType = "query")
- })
- public PageInfo<BusinessAgentQuality> listPage(Integer pageNum, Integer pageSize ,
- String houseId, String warehouseId) {
- BusinessAgentQuality qualityCheck = new BusinessAgentQuality();
- if(StringUtils.isNoneBlank(houseId)){
- qualityCheck.setStorehouseId(Integer.valueOf(houseId));
- }
- if(StringUtils.isNoneBlank(warehouseId)){
- qualityCheck.setWarehouseId(Integer.valueOf(warehouseId));
- }
- qualityCheck.setType("1");///查找验收质量管理的信息
- qualityCheck.setHistoryStatus(0);//0:最新数据 1:历史数据
- if (pageNum!=null && pageSize!=null) {
- PageHelper.startPage(pageNum, pageSize);
- }
- List<BusinessAgentQuality> list = agentQualityService.queryByQualitycheck(qualityCheck);
- PageInfo<BusinessAgentQuality> pageInfo = new PageInfo<BusinessAgentQuality>(list);
- return pageInfo;
- }
- /**
- * 根据仓号,货位号以及类型查找对应质量检查信息
- * @param houseId warehouseId
- * @return
- */
- @RequestMapping(value = "/findByStoreWarehouse", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
- @ApiOperation(value="根据仓号,货位号以及类型查找对应质量检查信息", notes = "根据仓号,货位号以及类型查找对应质量检查信息")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "houseId", value = "仓房ID", paramType = "query"),
- @ApiImplicitParam(name = "warehouseId", value = "货位ID", paramType = "query"),
- @ApiImplicitParam(name = "type", value = "检查类型", paramType = "query"),
- @ApiImplicitParam(name = "sealStatus", value = "封仓类型", paramType = "query")
- })
- public BusinessAgentQuality findByStoreWarehouse(Integer houseId, Integer warehouseId, String type,String sealStatus) {
- BusinessAgentQuality qualityCheckExample = new BusinessAgentQuality();
- BusinessAgentQuality qualitycheck = null;
- try {
- if (houseId != null && !"".equals(houseId)) {
- qualityCheckExample.setStorehouseId(houseId);
- }
- if(warehouseId != null && !"".equals(warehouseId)){
- qualityCheckExample.setWarehouseId(warehouseId);
- }
- if(StringUtils.isNotBlank(type)){
- qualityCheckExample.setType(type);//传入查找的质量类型
- }
- if(StringUtils.isNotBlank(sealStatus)){
- qualityCheckExample.setSealStatus(sealStatus);//传入查找的质量类型
- }
- //0:最新数据 1:历史数据
- qualityCheckExample.setHistoryStatus(0);
- List<BusinessAgentQuality> list = agentQualityService.queryByQualitycheck(qualityCheckExample);
- if (null != list && list.size() > 0) {
- qualitycheck = list.get(0);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return qualitycheck;
- }
- /**
- * 查询第三方检查
- * @param foodbasicinfoId
- * @return getThirdCheckList
- */
- @RequestMapping(value="/getThirdCheckList",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 = "houseId", value = "仓房id", paramType = "query"),
- @ApiImplicitParam(name = "warehouseId", value = "货位Id", paramType = "query"),
- @ApiImplicitParam(name = "foodbasicinfoId", value = "对应粮情专卡Id", paramType = "query"),
- })
- public PageInfo<BusinessAgentQuality> getThirdCheckList(Integer pageNum, Integer pageSize , Integer houseId, Integer warehouseId,
- Integer foodbasicinfoId) {
- BusinessAgentQuality qualityCheck = new BusinessAgentQuality();
- if(foodbasicinfoId != null){
- qualityCheck.setId(foodbasicinfoId);
- }
- if(houseId != null){
- qualityCheck.setStorehouseId(houseId);
- }
- if(warehouseId != null){
- qualityCheck.setWarehouseId(warehouseId);
- }
- if (pageNum!=null && pageSize!=null) {
- PageHelper.startPage(pageNum, pageSize);
- }
- List<BusinessAgentQuality> list = agentQualityService.getThirdCheckList(qualityCheck);
- PageInfo<BusinessAgentQuality> pageInfo = new PageInfo<BusinessAgentQuality>(list);
- return pageInfo;
- }
- /**
- * 获取第三方检查的不宜存的可用数据
- * @return
- */
- @RequestMapping(value = "/getStoreQualityList",produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET )
- @ApiOperation(value="获取第三方检查的不宜存的可用数据", notes = "获取第三方检查的不宜存的可用数据")
- public List<Map<String,Object>> getStoreQualityList(){
- List<Map<String,Object>> listQuality=agentQualityService.getStoreQualityList();
- return listQuality;
- }
- /**
- * 获取第三方检查的不宜存的可用数据
- * @return
- */
- @RequestMapping(value = "/getTrdStoreQualityList",produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET )
- @ApiOperation(value="获取第三方检查的不宜存的可用数据(集合格式)", notes = "获取第三方检查的不宜存的可用数据(集合格式)")
- public List<BusinessAgentQuality> getTrdStoreQualityList(){
- List<BusinessAgentQuality> listQuality=agentQualityService.getTrdStoreQualityList();
-
- return listQuality;
- }
-
- @RequestMapping(value = "/setQualityCheckByHistoryStatus", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
- @ApiOperation(value = "根据仓房和货位名称更新当前质量管理为历史记录", notes = "根据仓房和货位名称更新当前质量管理为历史记录")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "houseId", value = "仓房id", paramType = "query"),
- @ApiImplicitParam(name = "warehouseId", value = "货位Id", paramType = "query"),
- })
- public Map<String, Object> setQualityCheckByHistoryStatus(Integer houseId, Integer warehouseId) {
- Map<String, Object> modelMap = new HashMap<>();
- if (ParameterUtil.isnotnull(houseId) &&ParameterUtil.isnotnull(warehouseId) ) {
- agentQualityService.setQualityCheckByHistoryStatus(houseId,warehouseId);
- }
- modelMap.put("status", "success");
- return modelMap;
- }
- /**
- * 根据id查询质检信息
- * @param ZZid
- * @return
- */
- @RequestMapping(value="/getDataByZJId", produces = MediaType.APPLICATION_JSON_VALUE, method=RequestMethod.GET)
- @ApiOperation(value = "根据id查询质检信息", notes = "根据id查询质检信息,计划验收模块用到。")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "ZZid", value = "质检id", paramType = "query")
- })
- public Map<String,Object> getDataByZJId(Integer ZZid) {
- Map<String,Object> map = new HashMap<String, Object>();
- Map<String,Object> paramMap = new HashMap<String, Object>();
- paramMap.put("id", ZZid);
- List<BusinessAgentQuality> list = agentQualityService.getDataByZJId(paramMap);
- map.put("qualitycheck", list);
- return map;
- }
-
-
-
- /**
- * 根据仓房和货位获取第三方检查的数据
- * 分页获取
- */
- @RequestMapping(value = "/getListByhouseId",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 = "houseIds", value = "仓房id(数组)", paramType = "query"),
- @ApiImplicitParam(name = "warehouseIds", value = "货位id(数组)", paramType = "query")
- })
- public PageInfo<BusinessAgentQuality> getListByhouseId(Integer pageNum, Integer pageSize,
- Integer[] houseIds, Integer[] warehouseIds , String checktype) {
- BusinessAgentQuality qualityCheck = new BusinessAgentQuality();
- List<List<BusinessAgentQuality>> list = new ArrayList<List<BusinessAgentQuality>>();
- //根据后台传来的参数进行查找相应类型的类别0:初检 1:验收 2:质量普查 3:出库
- if (StringUtils.isNotBlank(checktype)){
- qualityCheck.setType(checktype);
- }
-
- qualityCheck.setHistoryStatus(0);//0:最新数据 1:历史数据
- //查询出未封仓的质量管理信息 封仓状态:0:未封仓,1:已封仓
- qualityCheck.setSealStatus("0");
-
- List<BusinessAgentQuality> qualityCheckList =null;
- for (int i = 0; i < houseIds.length; i++) {
- for (int j = 0; j < warehouseIds.length; j++) {
- if(i==j){
- Integer houseId = houseIds[i];
- Integer warehouseId = warehouseIds[j];
- //仓房id.
- if (qualityCheck.getStorehouseId() == null) {
- qualityCheck.setStorehouseId(houseId);
- }
- // 货位id.
- if (qualityCheck.getWarehouseId() == null) {
- qualityCheck.setWarehouseId(warehouseId);
- }
- if (pageNum!=null && pageSize!=null) {
- PageHelper.startPage(pageNum, pageSize);
- }
-
- qualityCheckList = agentQualityService.queryByQualitycheck(qualityCheck);
- }
- }
- }
-
-
-
- PageInfo<BusinessAgentQuality> pageInfo = new PageInfo<BusinessAgentQuality>(qualityCheckList);
- return pageInfo;
- }
- @RequestMapping(value = "/getNewList",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 = "houseId", value = "仓房ID", paramType = "query"),
- @ApiImplicitParam(name = "wareId", value = "货位ID", paramType = "query"),
- @ApiImplicitParam(name = "checktype", value = "检查的类型", paramType = "query"),
- @ApiImplicitParam(name = "checkResult", value = "检查结果", paramType = "query"),
- @ApiImplicitParam(name = "historyStatus", value = "数据状态", paramType = "query"),
- @ApiImplicitParam(name = "orgId", value = "单位ID", paramType = "query")
- })
- public PageInfo<BusinessAgentQuality> newListPage(Integer pageNum, Integer pageSize, Integer houseId, Integer wareId,
- String checkType, String checkResult, Integer historyStatus, Integer orgId) {
- BusinessAgentQualityExample example = new BusinessAgentQualityExample();
- BusinessAgentQualityExample.Criteria criteria = example.createCriteria();
- //根据后台传来的参数进行查找相应类型的类别0:初检 1:验收 2:质量普查 3:出库
- if (StringUtils.isNotBlank(checkType)){
- criteria.andTypeEqualTo(checkType);
- }
- // 仓房id.
- if (houseId != null) {
- criteria.andStorehouseIdEqualTo(houseId);
- }
- // 货位id.
- if (wareId != null) {
- criteria.andWarehouseIdEqualTo(wareId);
- }
- // 粮库id.
- if (orgId != null) {
- criteria.andOrgIdEqualTo(orgId);
- }
- //检验结果(0:合格 , 1 :不合格)
- if (StringUtils.isNotBlank(checkResult)) {
- criteria.andCheckResultEqualTo(checkResult);
- }
- //数据状态
- if (null != historyStatus) {
- //0:最新数据 1:历史数据
- criteria.andHistoryStatusEqualTo(historyStatus);
- }
- if (pageNum!=null && pageSize!=null) {
- PageHelper.startPage(pageNum, pageSize);
- }
- List<BusinessAgentQuality> list = agentQualityService.findByCondition(example);
- PageInfo<BusinessAgentQuality> pageInfo = new PageInfo<BusinessAgentQuality>(list);
- return pageInfo;
- }
- /**
- * 导入excel
- * @param file 文件
- * @param fileType 类型:如xlsx
- * @param orgId 组织机构id
- * @return
- */
- @RequestMapping(value="/importFile", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
- @ApiOperation(value="导入excel", notes = "导入excel")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "file", value = "文件数据", paramType = "query"),
- @ApiImplicitParam(name = "fileType", value = "文件名", paramType = "query"),
- @ApiImplicitParam(name = "rootPath", value = "路径", paramType = "query"),
- @ApiImplicitParam(name = "orgId", value = "组织机构id", paramType = "query"),
- @ApiImplicitParam(name = "checktype", value = "导入类型", paramType = "query")
- })
- public Map<String, Object> importFile(MultipartFile file, String fileType, HttpServletRequest request, Integer orgId,String checktype){
- Map<String, Object> fileMap = new HashMap<>();
- String errormsg = null;
- //0:初检 4:日常检验 5:第三方检查 3:出库检验
- if(ParameterUtil.isequal(checktype,"0") || ParameterUtil.isequal(checktype,"4") || ParameterUtil.isequal(checktype,"5") || ParameterUtil.isequal(checktype,"3")){
- String[] titleArr = {"仓房名称","货位名称","粮油品种","明细品种","粮油性质","数量","入仓日期","收获年度","产地","保管员",
- "扦样日期","扦样人","检验日期","报告出具日期","检验结论","检验机构","储存品质","水分%","容量(g/L)","杂质%",
- "矿物质%","不完善颗粒%","生霉粒%","完整粒率%","损伤粒率%","热损伤粒%","出糙率%","整精米率%","黄粒米%","谷外糙米%",
- "互混率%","色泽气味","等级","是否虫粮","备注"};//第一行的title
- boolean[] emptyArr = {false, false, false, false, false, false, false, false, false, false,
- false, false, false, false, false, false, false, false, false, false,
- false, false, false, false, false, false, false, false, false, false,
- false, false, false, false, false};//指定列可为空,不可为空值为false.
- List<List<String>> list = new ArrayList<List<String>>();//该list为数据返回的list
- try {
- errormsg = importService.importFile(file, fileType, request, titleArr, emptyArr, list,1);
- if (errormsg != null && !"".equals(errormsg)) {
- fileMap.put("errormsg",errormsg);
- return fileMap;
- }
- //查询代储点名称和代储库名称对应的id
- Map<String, Object> agentMap = agentService.getNameId(importService.nameData(file, fileType, request));
- if(ParameterUtil.isnull(agentMap)){
- fileMap.put("errormsg","代储点与代储库无关联,请查询后添加!");
- return fileMap;
- }
- if (list.size()>0) {
- errormsg = agentQualityService.importData(list, orgId, agentMap, checktype);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }else if(ParameterUtil.isequal(checktype,"1")){//1:验收
- String[] titleArr = {"仓房名称","货位名称","粮油品种","明细品种","粮油性质","数量","入仓日期","收获年度","产地","保管员",
- "申请验收日期","扦样日期","扦样人","检验日期","报告出具日期","检验结论","检验机构","储存品质","水分%","容量(g/L)",
- "杂质%","矿物质%","不完善颗粒%","生霉粒%","完整粒率%","损伤粒率%","热损伤粒%","出糙率%","整精米率%","黄粒米%",
- "谷外糙米%","互混率%","色泽气味","等级","是否虫粮","备注"};//第一行的title
- boolean[] emptyArr = {false, false, false, false, false, false, false, false, false, false,
- false, false, false, false, false, false, false, false, false, false,
- false, false, false, false, false, false, false, false, false, false,
- false, false, false, false, false, false};//指定列可为空,不可为空值为false.
- List<List<String>> list = new ArrayList<List<String>>();//该list为数据返回的list
- try {
- errormsg = importService.importFile(file, fileType, request, titleArr, emptyArr, list,1);
- if (errormsg != null && !"".equals(errormsg)) {
- fileMap.put("errormsg",errormsg);
- return fileMap;
- }
- //查询代储点名称和代储库名称对应的id
- Map<String, Object> agentMap = agentService.getNameId(importService.nameData(file, fileType, request));
- if(ParameterUtil.isnull(agentMap)){
- fileMap.put("errormsg","代储点与代储库无关联,请查询后添加!");
- return fileMap;
- }
- if (list.size()>0) {
- errormsg = agentQualityService.importDataCQ(list, orgId, agentMap, checktype);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }else if(ParameterUtil.isequal(checktype,"2")){//2:春秋普查
- String[] titleArr = {"仓房名称","货位名称","粮油品种","明细品种","粮油性质","数量","入仓日期","收获年度","产地","保管员",
- "普查类型","扦样日期","扦样人","检验日期","报告出具日期","检验结论","检验机构","储存品质","水分%","容量(g/L)","杂质%",
- "矿物质%","不完善颗粒%","生霉粒%","完整粒率%","损伤粒率%","热损伤粒%","出糙率%","整精米率%","黄粒米%","谷外糙米%",
- "互混率%","色泽气味","等级","是否虫粮","备注"};//第一行的title
- boolean[] emptyArr = {false, false, false, false, false, false, false, false, false, false,
- false, false, false, false, false, false, false, false, false, false,
- false, false, false, false, false, false, false, false, false, false,
- false, false, false, false, false, false};//指定列可为空,不可为空值为false.
- List<List<String>> list = new ArrayList<List<String>>();//该list为数据返回的list
- try {
- errormsg = importService.importFile(file, fileType, request, titleArr, emptyArr, list,1);
- if (errormsg != null && !"".equals(errormsg)) {
- fileMap.put("errormsg",errormsg);
- return fileMap;
- }
- //查询代储点名称和代储库名称对应的id
- Map<String, Object> agentMap = agentService.getNameId(importService.nameData(file, fileType, request));
- if(ParameterUtil.isnull(agentMap)){
- fileMap.put("errormsg","代储点与代储库无关联,请查询后添加!");
- return fileMap;
- }
- if (list.size()>0) {
- errormsg = agentQualityService.importDataCQ(list, orgId, agentMap, checktype);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- fileMap.put("errormsg",errormsg);
- return fileMap;
- }
- }
|