AgentQualityController.java 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. package com.chinaitop.depot.agent.quality.controller;
  2. import com.chinaitop.depot.agent.basic.service.agentService;
  3. import com.chinaitop.depot.agent.quality.model.BusinessAgentQuality;
  4. import com.chinaitop.depot.agent.quality.model.BusinessAgentQualityExample;
  5. import com.chinaitop.depot.agent.quality.model.BusinessAgentQualitySon;
  6. import com.chinaitop.depot.agent.quality.model.BusinessAgentQualitySonExample;
  7. import com.chinaitop.depot.agent.quality.service.AgentQualityService;
  8. import com.chinaitop.depot.agent.quality.service.AgentQualitySonService;
  9. import com.chinaitop.depot.utils.ImportServiceImpl;
  10. import com.chinaitop.utils.ParameterUtil;
  11. import com.fasterxml.jackson.core.type.TypeReference;
  12. import com.fasterxml.jackson.databind.ObjectMapper;
  13. import com.github.pagehelper.PageHelper;
  14. import com.github.pagehelper.PageInfo;
  15. import io.swagger.annotations.Api;
  16. import io.swagger.annotations.ApiImplicitParam;
  17. import io.swagger.annotations.ApiImplicitParams;
  18. import io.swagger.annotations.ApiOperation;
  19. import org.apache.commons.lang3.StringUtils;
  20. import org.springframework.http.MediaType;
  21. import org.springframework.web.bind.annotation.RequestMapping;
  22. import org.springframework.web.bind.annotation.RequestMethod;
  23. import org.springframework.web.bind.annotation.RestController;
  24. import org.springframework.web.multipart.MultipartFile;
  25. import javax.annotation.Resource;
  26. import javax.servlet.http.HttpServletRequest;
  27. import java.io.IOException;
  28. import java.util.ArrayList;
  29. import java.util.HashMap;
  30. import java.util.List;
  31. import java.util.Map;
  32. /**
  33. * Created by product on 2017/10/11.
  34. */
  35. @RestController
  36. @RequestMapping(value = {"/agentQuality"})
  37. @Api(value= "AgentQualityController", description = "质量管理类")
  38. public class AgentQualityController {
  39. @Resource
  40. private AgentQualityService agentQualityService;
  41. @Resource
  42. private AgentQualitySonService agentQualitySonService;
  43. @Resource
  44. private ImportServiceImpl importService;
  45. @Resource
  46. private agentService agentService;
  47. /**
  48. * 封仓管理中查询出未封仓的质量管理信息,已经封仓的不要展示
  49. * 分页获取
  50. */
  51. @RequestMapping(value = "/getList",produces = MediaType.APPLICATION_JSON_VALUE,method = RequestMethod.GET)
  52. @ApiOperation(value="查询质量管理列表", notes = "查询质量管理信息列表,支持分页")
  53. @ApiImplicitParams({
  54. @ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query"),
  55. @ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query"),
  56. @ApiImplicitParam(name = "checktype", value = "检查的类型", paramType = "query"),
  57. @ApiImplicitParam(name = "checkResult", value = "检查结果", paramType = "query"),
  58. @ApiImplicitParam(name = "orgId", value = "粮库id", paramType = "query"),
  59. @ApiImplicitParam(name = "agentId", value = "代储点名称", paramType = "query"),
  60. @ApiImplicitParam(name = "agentDepotId", value = "粮库名称", paramType = "query"),
  61. @ApiImplicitParam(name = "storehouseId", value = "仓房名称", paramType = "query"),
  62. @ApiImplicitParam(name = "warehouseId", value = "货位名称", paramType = "query"),
  63. })
  64. public PageInfo<BusinessAgentQuality> listPage(Integer pageNum, Integer pageSize,String checktype, String checkResult, Integer orgId,
  65. Integer agentId,Integer agentDepotId,Integer storehouseId,Integer warehouseId) {
  66. BusinessAgentQuality qualityCheck = new BusinessAgentQuality();
  67. //根据后台传来的参数进行查找相应类型的类别0:初检 1:验收 2:质量普查 3:出库
  68. if (StringUtils.isNotBlank(checktype)){
  69. qualityCheck.setType(checktype);
  70. }
  71. // 粮库id.
  72. if (ParameterUtil.isnotnull(orgId)) {
  73. qualityCheck.setOrgId(orgId);
  74. }
  75. // 代储点名称.
  76. if (ParameterUtil.isnotnull(agentId)) {
  77. qualityCheck.setAgentId(agentId);
  78. }
  79. // 粮库名称.
  80. if (ParameterUtil.isnotnull(agentDepotId)) {
  81. qualityCheck.setAgentDepotId(agentDepotId);
  82. }
  83. // 仓房id.
  84. if (ParameterUtil.isnotnull(storehouseId)) {
  85. qualityCheck.setStorehouseId(storehouseId);
  86. }
  87. // 货位id.
  88. if (ParameterUtil.isnotnull(warehouseId)) {
  89. qualityCheck.setWarehouseId(warehouseId);
  90. }
  91. //检验结果(0:合格 , 1 :不合格)
  92. if (StringUtils.isNotBlank(checkResult)) {
  93. qualityCheck.setCheckResult(checkResult);
  94. }
  95. qualityCheck.setHistoryStatus(0);//0:最新数据 1:历史数据
  96. //查询出未封仓的质量管理信息 封仓状态:0:未封仓,1:已封仓
  97. qualityCheck.setSealStatus("0");
  98. if (pageNum!=null && pageSize!=null) {
  99. PageHelper.startPage(pageNum, pageSize);
  100. }
  101. List<BusinessAgentQuality> list = agentQualityService.queryByQualitycheck(qualityCheck);
  102. PageInfo<BusinessAgentQuality> pageInfo = new PageInfo<BusinessAgentQuality>(list);
  103. return pageInfo;
  104. }
  105. /**
  106. * 获取仓房或者货位(通过分组查询最新的满足条件的仓房或者货位).
  107. * @param qualitycheck
  108. * @return
  109. */
  110. @RequestMapping(value = "/getHouseOrWareList",produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
  111. @ApiOperation(value="获取仓房或者货位(通过分组查询最新的满足条件的仓房或者货位)", notes = "获取仓房或者货位(通过分组查询最新的满足条件的仓房或者货位)")
  112. @ApiImplicitParams({
  113. @ApiImplicitParam(name = "qualitycheck", value = "质量管理对象", paramType = "query")
  114. })
  115. public List<BusinessAgentQuality> getHouseIdList(BusinessAgentQuality qualitycheck) {
  116. List<BusinessAgentQuality> list = agentQualityService.getHouseOrWareList(qualitycheck);
  117. return list;
  118. }
  119. /**
  120. * 获取第三方检验的质量标准字符串(手动拼写)
  121. * @param id
  122. * @return
  123. */
  124. @RequestMapping(value = "/getQualityStandardStr",produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
  125. @ApiOperation(value="获取第三方检验的质量标准字符串(手动拼写)", notes = "获取第三方检验的质量标准字符串(手动拼写)")
  126. @ApiImplicitParams({
  127. @ApiImplicitParam(name = "id", value = "id", paramType = "form"),
  128. })
  129. public Map<String, Object> getQualityStandardStr(Integer id) {
  130. Map<String, Object> modelMap = new HashMap<String, Object>();
  131. if (id == null) {
  132. modelMap.put("status", "error");
  133. modelMap.put("msg", "id为空,查询质量标准失败!");
  134. } else {
  135. String qualityStandardStr = agentQualityService.getQualityStandardStr(id);
  136. modelMap.put("status", "success");
  137. modelMap.put("qualityStandard", qualityStandardStr);
  138. }
  139. return modelMap;
  140. }
  141. /**
  142. * 新增和修改的数据进行保存
  143. * @param qualitycheckJson
  144. * @return
  145. */
  146. @RequestMapping(value="/save", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
  147. @ApiOperation(value="新增/修改数据", notes = "新增/修改数据")
  148. @ApiImplicitParams({
  149. @ApiImplicitParam(name = "qualitycheckJson", value = "质量基础信息JSON数据对象", paramType = "form"),
  150. @ApiImplicitParam(name = "qualityOneJson", value = "质量检测信息JSON数据对象", paramType = "form")
  151. })
  152. public Map<String, Object> save(String qualitycheckJson,String qualityOneJson) {
  153. Map<String, Object> modelMap = new HashMap<>();
  154. // JSON字符串转对象
  155. ObjectMapper mapper = new ObjectMapper();
  156. BusinessAgentQuality qualitycheck = null;
  157. List<BusinessAgentQualitySon> qualitycheckone = null;
  158. try {
  159. qualitycheck = (BusinessAgentQuality)mapper.readValue(qualitycheckJson, BusinessAgentQuality.class);
  160. //默认0:未封仓 1:已封仓
  161. qualitycheck.setSealStatus("0");
  162. qualitycheck.setHistoryStatus(0);//0:最新数据 1:历史数据
  163. Integer qualityCheckId = agentQualityService.save(qualitycheck);
  164. //关联保存日常检查和第三方检测的检测信息 如果为空则是对初检 验收等操作
  165. if(StringUtils.isNoneBlank(qualityOneJson)){
  166. qualitycheckone = mapper.readValue(qualityOneJson, new TypeReference<List<BusinessAgentQualitySon>>(){});
  167. for (int i = 0; i < qualitycheckone.size(); i++) {
  168. qualitycheckone.get(i).setQualitycheckId(qualityCheckId);
  169. agentQualityService.saveOne(qualitycheckone.get(i));
  170. }
  171. }
  172. modelMap.put("status", "success");
  173. } catch (IOException e) {
  174. modelMap.put("status", "error");
  175. e.printStackTrace();
  176. }
  177. return modelMap;
  178. }
  179. /**
  180. * 根据id加载对应数据
  181. * @param id
  182. * @return
  183. */
  184. @RequestMapping(value = "/loadDataById" ,produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
  185. @ApiOperation(value="根据id加载质量检查数据", notes = "根据id加载质量检查数据")
  186. @ApiImplicitParams({
  187. @ApiImplicitParam(name = "id", value = "id", paramType = "query"),
  188. })
  189. public BusinessAgentQuality loadDataById(Integer id){
  190. BusinessAgentQuality qualitycheck=agentQualityService.loadDataById(id);
  191. return qualitycheck;
  192. }
  193. /**
  194. * 根据主键id移除数据
  195. * @param id
  196. * @return
  197. */
  198. @RequestMapping(value="/remove", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
  199. @ApiOperation(value="按ID删除质量检查信息", notes = "按ID删除质量检查信息")
  200. @ApiImplicitParams({
  201. @ApiImplicitParam(name = "id", value = "数据ID", paramType = "form")
  202. })
  203. public Map<String, Object> remove(Integer id){
  204. Map<String,Object> retMap = new HashMap<String,Object>();
  205. agentQualityService.remove(id);
  206. //删除管理的数据
  207. BusinessAgentQualitySonExample qualitycheckSonExample = new BusinessAgentQualitySonExample();
  208. BusinessAgentQualitySonExample.Criteria criteria = qualitycheckSonExample.createCriteria();
  209. if(id != null){
  210. criteria.andQualitycheckIdEqualTo(id);
  211. }
  212. agentQualitySonService.removeSon(qualitycheckSonExample);
  213. retMap.put("msg","success");
  214. return retMap;
  215. }
  216. /**
  217. * 封仓管理中查询出所有仓已经封仓或者未封仓的质量管理信息
  218. * @param houseId
  219. * @param warehouseId
  220. * @return
  221. */
  222. @RequestMapping(value="/getFoodsealList",produces = MediaType.APPLICATION_JSON_VALUE,method = RequestMethod.GET)
  223. @ApiOperation(value="封仓管理列表中查询出封仓或未封仓的质量管理信息", notes = "封仓管理列表中查询出封仓或未封仓的质量管理信息")
  224. @ApiImplicitParams({
  225. @ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query"),
  226. @ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query"),
  227. @ApiImplicitParam(name = "houseId", value = "仓房ID", paramType = "query"),
  228. @ApiImplicitParam(name = "warehouseId", value = "货位ID", paramType = "query")
  229. })
  230. public PageInfo<BusinessAgentQuality> listPage(Integer pageNum, Integer pageSize ,
  231. String houseId, String warehouseId) {
  232. BusinessAgentQuality qualityCheck = new BusinessAgentQuality();
  233. if(StringUtils.isNoneBlank(houseId)){
  234. qualityCheck.setStorehouseId(Integer.valueOf(houseId));
  235. }
  236. if(StringUtils.isNoneBlank(warehouseId)){
  237. qualityCheck.setWarehouseId(Integer.valueOf(warehouseId));
  238. }
  239. qualityCheck.setType("1");///查找验收质量管理的信息
  240. qualityCheck.setHistoryStatus(0);//0:最新数据 1:历史数据
  241. if (pageNum!=null && pageSize!=null) {
  242. PageHelper.startPage(pageNum, pageSize);
  243. }
  244. List<BusinessAgentQuality> list = agentQualityService.queryByQualitycheck(qualityCheck);
  245. PageInfo<BusinessAgentQuality> pageInfo = new PageInfo<BusinessAgentQuality>(list);
  246. return pageInfo;
  247. }
  248. /**
  249. * 根据仓号,货位号以及类型查找对应质量检查信息
  250. * @param houseId warehouseId
  251. * @return
  252. */
  253. @RequestMapping(value = "/findByStoreWarehouse", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
  254. @ApiOperation(value="根据仓号,货位号以及类型查找对应质量检查信息", notes = "根据仓号,货位号以及类型查找对应质量检查信息")
  255. @ApiImplicitParams({
  256. @ApiImplicitParam(name = "houseId", value = "仓房ID", paramType = "query"),
  257. @ApiImplicitParam(name = "warehouseId", value = "货位ID", paramType = "query"),
  258. @ApiImplicitParam(name = "type", value = "检查类型", paramType = "query"),
  259. @ApiImplicitParam(name = "sealStatus", value = "封仓类型", paramType = "query")
  260. })
  261. public BusinessAgentQuality findByStoreWarehouse(Integer houseId, Integer warehouseId, String type,String sealStatus) {
  262. BusinessAgentQuality qualityCheckExample = new BusinessAgentQuality();
  263. BusinessAgentQuality qualitycheck = null;
  264. try {
  265. if (houseId != null && !"".equals(houseId)) {
  266. qualityCheckExample.setStorehouseId(houseId);
  267. }
  268. if(warehouseId != null && !"".equals(warehouseId)){
  269. qualityCheckExample.setWarehouseId(warehouseId);
  270. }
  271. if(StringUtils.isNotBlank(type)){
  272. qualityCheckExample.setType(type);//传入查找的质量类型
  273. }
  274. if(StringUtils.isNotBlank(sealStatus)){
  275. qualityCheckExample.setSealStatus(sealStatus);//传入查找的质量类型
  276. }
  277. //0:最新数据 1:历史数据
  278. qualityCheckExample.setHistoryStatus(0);
  279. List<BusinessAgentQuality> list = agentQualityService.queryByQualitycheck(qualityCheckExample);
  280. if (null != list && list.size() > 0) {
  281. qualitycheck = list.get(0);
  282. }
  283. } catch (Exception e) {
  284. e.printStackTrace();
  285. }
  286. return qualitycheck;
  287. }
  288. /**
  289. * 查询第三方检查
  290. * @param foodbasicinfoId
  291. * @return getThirdCheckList
  292. */
  293. @RequestMapping(value="/getThirdCheckList",produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
  294. @ApiOperation(value="查询获得第三方检查列表", notes = "查询获得第三方检查列表,支持分页")
  295. @ApiImplicitParams({
  296. @ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query"),
  297. @ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query"),
  298. @ApiImplicitParam(name = "houseId", value = "仓房id", paramType = "query"),
  299. @ApiImplicitParam(name = "warehouseId", value = "货位Id", paramType = "query"),
  300. @ApiImplicitParam(name = "foodbasicinfoId", value = "对应粮情专卡Id", paramType = "query"),
  301. })
  302. public PageInfo<BusinessAgentQuality> getThirdCheckList(Integer pageNum, Integer pageSize , Integer houseId, Integer warehouseId,
  303. Integer foodbasicinfoId) {
  304. BusinessAgentQuality qualityCheck = new BusinessAgentQuality();
  305. if(foodbasicinfoId != null){
  306. qualityCheck.setId(foodbasicinfoId);
  307. }
  308. if(houseId != null){
  309. qualityCheck.setStorehouseId(houseId);
  310. }
  311. if(warehouseId != null){
  312. qualityCheck.setWarehouseId(warehouseId);
  313. }
  314. if (pageNum!=null && pageSize!=null) {
  315. PageHelper.startPage(pageNum, pageSize);
  316. }
  317. List<BusinessAgentQuality> list = agentQualityService.getThirdCheckList(qualityCheck);
  318. PageInfo<BusinessAgentQuality> pageInfo = new PageInfo<BusinessAgentQuality>(list);
  319. return pageInfo;
  320. }
  321. /**
  322. * 获取第三方检查的不宜存的可用数据
  323. * @return
  324. */
  325. @RequestMapping(value = "/getStoreQualityList",produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET )
  326. @ApiOperation(value="获取第三方检查的不宜存的可用数据", notes = "获取第三方检查的不宜存的可用数据")
  327. public List<Map<String,Object>> getStoreQualityList(){
  328. List<Map<String,Object>> listQuality=agentQualityService.getStoreQualityList();
  329. return listQuality;
  330. }
  331. /**
  332. * 获取第三方检查的不宜存的可用数据
  333. * @return
  334. */
  335. @RequestMapping(value = "/getTrdStoreQualityList",produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET )
  336. @ApiOperation(value="获取第三方检查的不宜存的可用数据(集合格式)", notes = "获取第三方检查的不宜存的可用数据(集合格式)")
  337. public List<BusinessAgentQuality> getTrdStoreQualityList(){
  338. List<BusinessAgentQuality> listQuality=agentQualityService.getTrdStoreQualityList();
  339. return listQuality;
  340. }
  341. @RequestMapping(value = "/setQualityCheckByHistoryStatus", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
  342. @ApiOperation(value = "根据仓房和货位名称更新当前质量管理为历史记录", notes = "根据仓房和货位名称更新当前质量管理为历史记录")
  343. @ApiImplicitParams({
  344. @ApiImplicitParam(name = "houseId", value = "仓房id", paramType = "query"),
  345. @ApiImplicitParam(name = "warehouseId", value = "货位Id", paramType = "query"),
  346. })
  347. public Map<String, Object> setQualityCheckByHistoryStatus(Integer houseId, Integer warehouseId) {
  348. Map<String, Object> modelMap = new HashMap<>();
  349. if (ParameterUtil.isnotnull(houseId) &&ParameterUtil.isnotnull(warehouseId) ) {
  350. agentQualityService.setQualityCheckByHistoryStatus(houseId,warehouseId);
  351. }
  352. modelMap.put("status", "success");
  353. return modelMap;
  354. }
  355. /**
  356. * 根据id查询质检信息
  357. * @param ZZid
  358. * @return
  359. */
  360. @RequestMapping(value="/getDataByZJId", produces = MediaType.APPLICATION_JSON_VALUE, method=RequestMethod.GET)
  361. @ApiOperation(value = "根据id查询质检信息", notes = "根据id查询质检信息,计划验收模块用到。")
  362. @ApiImplicitParams({
  363. @ApiImplicitParam(name = "ZZid", value = "质检id", paramType = "query")
  364. })
  365. public Map<String,Object> getDataByZJId(Integer ZZid) {
  366. Map<String,Object> map = new HashMap<String, Object>();
  367. Map<String,Object> paramMap = new HashMap<String, Object>();
  368. paramMap.put("id", ZZid);
  369. List<BusinessAgentQuality> list = agentQualityService.getDataByZJId(paramMap);
  370. map.put("qualitycheck", list);
  371. return map;
  372. }
  373. /**
  374. * 根据仓房和货位获取第三方检查的数据
  375. * 分页获取
  376. */
  377. @RequestMapping(value = "/getListByhouseId",produces = MediaType.APPLICATION_JSON_VALUE,method = RequestMethod.GET)
  378. @ApiOperation(value="根据仓房和货位获取第三方检查的数据", notes = "支持分页")
  379. @ApiImplicitParams({
  380. @ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query"),
  381. @ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query"),
  382. @ApiImplicitParam(name = "houseIds", value = "仓房id(数组)", paramType = "query"),
  383. @ApiImplicitParam(name = "warehouseIds", value = "货位id(数组)", paramType = "query")
  384. })
  385. public PageInfo<BusinessAgentQuality> getListByhouseId(Integer pageNum, Integer pageSize,
  386. Integer[] houseIds, Integer[] warehouseIds , String checktype) {
  387. BusinessAgentQuality qualityCheck = new BusinessAgentQuality();
  388. List<List<BusinessAgentQuality>> list = new ArrayList<List<BusinessAgentQuality>>();
  389. //根据后台传来的参数进行查找相应类型的类别0:初检 1:验收 2:质量普查 3:出库
  390. if (StringUtils.isNotBlank(checktype)){
  391. qualityCheck.setType(checktype);
  392. }
  393. qualityCheck.setHistoryStatus(0);//0:最新数据 1:历史数据
  394. //查询出未封仓的质量管理信息 封仓状态:0:未封仓,1:已封仓
  395. qualityCheck.setSealStatus("0");
  396. List<BusinessAgentQuality> qualityCheckList =null;
  397. for (int i = 0; i < houseIds.length; i++) {
  398. for (int j = 0; j < warehouseIds.length; j++) {
  399. if(i==j){
  400. Integer houseId = houseIds[i];
  401. Integer warehouseId = warehouseIds[j];
  402. //仓房id.
  403. if (qualityCheck.getStorehouseId() == null) {
  404. qualityCheck.setStorehouseId(houseId);
  405. }
  406. // 货位id.
  407. if (qualityCheck.getWarehouseId() == null) {
  408. qualityCheck.setWarehouseId(warehouseId);
  409. }
  410. if (pageNum!=null && pageSize!=null) {
  411. PageHelper.startPage(pageNum, pageSize);
  412. }
  413. qualityCheckList = agentQualityService.queryByQualitycheck(qualityCheck);
  414. }
  415. }
  416. }
  417. PageInfo<BusinessAgentQuality> pageInfo = new PageInfo<BusinessAgentQuality>(qualityCheckList);
  418. return pageInfo;
  419. }
  420. @RequestMapping(value = "/getNewList",produces = MediaType.APPLICATION_JSON_VALUE,method = RequestMethod.GET)
  421. @ApiOperation(value="查询质量管理列表", notes = "查询质量管理信息列表,支持分页")
  422. @ApiImplicitParams({
  423. @ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query"),
  424. @ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query"),
  425. @ApiImplicitParam(name = "houseId", value = "仓房ID", paramType = "query"),
  426. @ApiImplicitParam(name = "wareId", value = "货位ID", paramType = "query"),
  427. @ApiImplicitParam(name = "checktype", value = "检查的类型", paramType = "query"),
  428. @ApiImplicitParam(name = "checkResult", value = "检查结果", paramType = "query"),
  429. @ApiImplicitParam(name = "historyStatus", value = "数据状态", paramType = "query"),
  430. @ApiImplicitParam(name = "orgId", value = "单位ID", paramType = "query")
  431. })
  432. public PageInfo<BusinessAgentQuality> newListPage(Integer pageNum, Integer pageSize, Integer houseId, Integer wareId,
  433. String checkType, String checkResult, Integer historyStatus, Integer orgId) {
  434. BusinessAgentQualityExample example = new BusinessAgentQualityExample();
  435. BusinessAgentQualityExample.Criteria criteria = example.createCriteria();
  436. //根据后台传来的参数进行查找相应类型的类别0:初检 1:验收 2:质量普查 3:出库
  437. if (StringUtils.isNotBlank(checkType)){
  438. criteria.andTypeEqualTo(checkType);
  439. }
  440. // 仓房id.
  441. if (houseId != null) {
  442. criteria.andStorehouseIdEqualTo(houseId);
  443. }
  444. // 货位id.
  445. if (wareId != null) {
  446. criteria.andWarehouseIdEqualTo(wareId);
  447. }
  448. // 粮库id.
  449. if (orgId != null) {
  450. criteria.andOrgIdEqualTo(orgId);
  451. }
  452. //检验结果(0:合格 , 1 :不合格)
  453. if (StringUtils.isNotBlank(checkResult)) {
  454. criteria.andCheckResultEqualTo(checkResult);
  455. }
  456. //数据状态
  457. if (null != historyStatus) {
  458. //0:最新数据 1:历史数据
  459. criteria.andHistoryStatusEqualTo(historyStatus);
  460. }
  461. if (pageNum!=null && pageSize!=null) {
  462. PageHelper.startPage(pageNum, pageSize);
  463. }
  464. List<BusinessAgentQuality> list = agentQualityService.findByCondition(example);
  465. PageInfo<BusinessAgentQuality> pageInfo = new PageInfo<BusinessAgentQuality>(list);
  466. return pageInfo;
  467. }
  468. /**
  469. * 导入excel
  470. * @param file 文件
  471. * @param fileType 类型:如xlsx
  472. * @param orgId 组织机构id
  473. * @return
  474. */
  475. @RequestMapping(value="/importFile", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
  476. @ApiOperation(value="导入excel", notes = "导入excel")
  477. @ApiImplicitParams({
  478. @ApiImplicitParam(name = "file", value = "文件数据", paramType = "query"),
  479. @ApiImplicitParam(name = "fileType", value = "文件名", paramType = "query"),
  480. @ApiImplicitParam(name = "rootPath", value = "路径", paramType = "query"),
  481. @ApiImplicitParam(name = "orgId", value = "组织机构id", paramType = "query"),
  482. @ApiImplicitParam(name = "checktype", value = "导入类型", paramType = "query")
  483. })
  484. public Map<String, Object> importFile(MultipartFile file, String fileType, HttpServletRequest request, Integer orgId,String checktype){
  485. Map<String, Object> fileMap = new HashMap<>();
  486. String errormsg = null;
  487. //0:初检 4:日常检验 5:第三方检查 3:出库检验
  488. if(ParameterUtil.isequal(checktype,"0") || ParameterUtil.isequal(checktype,"4") || ParameterUtil.isequal(checktype,"5") || ParameterUtil.isequal(checktype,"3")){
  489. String[] titleArr = {"仓房名称","货位名称","粮油品种","明细品种","粮油性质","数量","入仓日期","收获年度","产地","保管员",
  490. "扦样日期","扦样人","检验日期","报告出具日期","检验结论","检验机构","储存品质","水分%","容量(g/L)","杂质%",
  491. "矿物质%","不完善颗粒%","生霉粒%","完整粒率%","损伤粒率%","热损伤粒%","出糙率%","整精米率%","黄粒米%","谷外糙米%",
  492. "互混率%","色泽气味","等级","是否虫粮","备注"};//第一行的title
  493. boolean[] emptyArr = {false, false, false, false, false, false, false, false, false, false,
  494. false, false, false, false, false, false, false, false, false, false,
  495. false, false, false, false, false, false, false, false, false, false,
  496. false, false, false, false, false};//指定列可为空,不可为空值为false.
  497. List<List<String>> list = new ArrayList<List<String>>();//该list为数据返回的list
  498. try {
  499. errormsg = importService.importFile(file, fileType, request, titleArr, emptyArr, list,1);
  500. if (errormsg != null && !"".equals(errormsg)) {
  501. fileMap.put("errormsg",errormsg);
  502. return fileMap;
  503. }
  504. //查询代储点名称和代储库名称对应的id
  505. Map<String, Object> agentMap = agentService.getNameId(importService.nameData(file, fileType, request));
  506. if(ParameterUtil.isnull(agentMap)){
  507. fileMap.put("errormsg","代储点与代储库无关联,请查询后添加!");
  508. return fileMap;
  509. }
  510. if (list.size()>0) {
  511. errormsg = agentQualityService.importData(list, orgId, agentMap, checktype);
  512. }
  513. } catch (Exception e) {
  514. e.printStackTrace();
  515. }
  516. }else if(ParameterUtil.isequal(checktype,"1")){//1:验收
  517. String[] titleArr = {"仓房名称","货位名称","粮油品种","明细品种","粮油性质","数量","入仓日期","收获年度","产地","保管员",
  518. "申请验收日期","扦样日期","扦样人","检验日期","报告出具日期","检验结论","检验机构","储存品质","水分%","容量(g/L)",
  519. "杂质%","矿物质%","不完善颗粒%","生霉粒%","完整粒率%","损伤粒率%","热损伤粒%","出糙率%","整精米率%","黄粒米%",
  520. "谷外糙米%","互混率%","色泽气味","等级","是否虫粮","备注"};//第一行的title
  521. boolean[] emptyArr = {false, false, false, false, false, false, false, false, false, false,
  522. false, false, false, false, false, false, false, false, false, false,
  523. false, false, false, false, false, false, false, false, false, false,
  524. false, false, false, false, false, false};//指定列可为空,不可为空值为false.
  525. List<List<String>> list = new ArrayList<List<String>>();//该list为数据返回的list
  526. try {
  527. errormsg = importService.importFile(file, fileType, request, titleArr, emptyArr, list,1);
  528. if (errormsg != null && !"".equals(errormsg)) {
  529. fileMap.put("errormsg",errormsg);
  530. return fileMap;
  531. }
  532. //查询代储点名称和代储库名称对应的id
  533. Map<String, Object> agentMap = agentService.getNameId(importService.nameData(file, fileType, request));
  534. if(ParameterUtil.isnull(agentMap)){
  535. fileMap.put("errormsg","代储点与代储库无关联,请查询后添加!");
  536. return fileMap;
  537. }
  538. if (list.size()>0) {
  539. errormsg = agentQualityService.importDataCQ(list, orgId, agentMap, checktype);
  540. }
  541. } catch (Exception e) {
  542. e.printStackTrace();
  543. }
  544. }else if(ParameterUtil.isequal(checktype,"2")){//2:春秋普查
  545. String[] titleArr = {"仓房名称","货位名称","粮油品种","明细品种","粮油性质","数量","入仓日期","收获年度","产地","保管员",
  546. "普查类型","扦样日期","扦样人","检验日期","报告出具日期","检验结论","检验机构","储存品质","水分%","容量(g/L)","杂质%",
  547. "矿物质%","不完善颗粒%","生霉粒%","完整粒率%","损伤粒率%","热损伤粒%","出糙率%","整精米率%","黄粒米%","谷外糙米%",
  548. "互混率%","色泽气味","等级","是否虫粮","备注"};//第一行的title
  549. boolean[] emptyArr = {false, false, false, false, false, false, false, false, false, false,
  550. false, false, false, false, false, false, false, false, false, false,
  551. false, false, false, false, false, false, false, false, false, false,
  552. false, false, false, false, false, false};//指定列可为空,不可为空值为false.
  553. List<List<String>> list = new ArrayList<List<String>>();//该list为数据返回的list
  554. try {
  555. errormsg = importService.importFile(file, fileType, request, titleArr, emptyArr, list,1);
  556. if (errormsg != null && !"".equals(errormsg)) {
  557. fileMap.put("errormsg",errormsg);
  558. return fileMap;
  559. }
  560. //查询代储点名称和代储库名称对应的id
  561. Map<String, Object> agentMap = agentService.getNameId(importService.nameData(file, fileType, request));
  562. if(ParameterUtil.isnull(agentMap)){
  563. fileMap.put("errormsg","代储点与代储库无关联,请查询后添加!");
  564. return fileMap;
  565. }
  566. if (list.size()>0) {
  567. errormsg = agentQualityService.importDataCQ(list, orgId, agentMap, checktype);
  568. }
  569. } catch (Exception e) {
  570. e.printStackTrace();
  571. }
  572. }
  573. fileMap.put("errormsg",errormsg);
  574. return fileMap;
  575. }
  576. }