package com.steerinfo.dil.controller; import com.steerinfo.dil.feign.ESFeign; import com.steerinfo.dil.model.WmspGridMaterial; import com.steerinfo.dil.service.IWmspGridMaterialService; import com.steerinfo.dil.service.impl.WmspGridMaterialServiceImpl; import com.steerinfo.dil.util.BaseRESTfulController; import com.steerinfo.dil.util.ColumnDataUtil; import com.steerinfo.dil.util.PageListAdd; import com.steerinfo.framework.controller.RESTfulResult; import com.steerinfo.framework.service.pagehelper.PageHelper; import com.steerinfo.framework.service.pagehelper.PageList; import com.steerinfo.framework.utils.collection.ListUtils; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.apache.xmlbeans.impl.xb.xsdschema.Public; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.math.BigDecimal; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; /** * WmspGridMaterial RESTful接口: * @author generator * @version 1.0-SNAPSHORT 2021-09-08 06:02 * 类描述 * 修订历史: * 日期:2021-09-08 * 作者:generator * 参考: * 描述:WmspGridMaterial RESTful接口 * @see null * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved. */ @RestController @RequestMapping("/${api.version}/wmspgridmaterials") public class WmspGridMaterialController extends BaseRESTfulController { @Autowired WmspGridMaterialServiceImpl wmspGridMaterialService; @Autowired ColumnDataUtil columnDataUtil; @Autowired ESFeign esFeign; @PostMapping(value = "/insertGridMaterial") public RESTfulResult insertGridMaterial(@RequestBody WmspGridMaterial wmspGridMaterial) { int code = wmspGridMaterialService.insertSelective(wmspGridMaterial); return success(code); } @PostMapping(value = "/updateGridMeterial") public RESTfulResult updateGridMeterial(@RequestBody WmspGridMaterial wmspGridMaterial) { int data = wmspGridMaterialService.updateByPrimaryKeySelective(wmspGridMaterial); return success(data); } // 查询实时库存 @ApiImplicitParam("api:167") @PostMapping(value = "/selectGridMaterialList") public RESTfulResult selectGridMaterialList(@RequestBody(required = false) Map mapVal, Integer pageNum, Integer pageSize, Integer apiId, String con) { if (con != null) { if (!"undefined".equals(con)) { String index = "get_gird_materiallist";//设置要查询的索引名称 return success(esFeign.getConResult(mapVal, index, apiId, pageNum, pageSize, con));//获取查询结果 } } List> libaryInBoundList = null; if (mapVal.size() == 0) { //将查询结果存入索引中 libaryInBoundList = wmspGridMaterialService.selectGridMaterial(mapVal); Map map1 = new HashMap<>(); //添加索引 map1.put("index", "get_gird_materiallist"); //添加id map1.put("indexId", "GridMaterialListId"); libaryInBoundList.add(map1); //新建索引 esFeign.insertIndex(libaryInBoundList); //删除 libaryInBoundList.remove(libaryInBoundList.size() - 1); } if (libaryInBoundList == null) { libaryInBoundList = wmspGridMaterialService.selectGridMaterial(mapVal); } PageHelper.startPage(pageNum, pageSize); List> columnList = wmspGridMaterialService.selectGridMaterial(mapVal); PageListAdd pageList = columnDataUtil.tableColumnData(apiId, libaryInBoundList, columnList); //库龄预警 for (Map mapValue : columnList) { BigDecimal gridId = (BigDecimal) mapValue.get("gridId"); List> map2 = wmspGridMaterialService.selectInboundTimeAndThreshold(gridId); //取出入库日期转换为时间戳 for (Map map1 : map2) { Date inboundTime = (Date) map1.get("inboundTime"); Date date1 = new Date(); //当前时间减去入库日期 long data1 = date1.getTime() - inboundTime.getTime(); //日期 long days = data1 / (1000 * 60 * 60 * 24); //小时 long hours = (data1 - days * (1000 * 60 * 60 * 24)) / (1000 * 60 * 60); //分钟 long minutes = (data1 - days * (1000 * 60 * 60 * 24) - hours * (1000 * 60 * 60)) / (1000 * 60); //获取标准值 BigDecimal max = (BigDecimal) map1.get("max"); Long Max = max.longValue(); BigDecimal min = (BigDecimal) map1.get("min"); Long Min = min.longValue(); if (days < Max && days >= Min) { return success(); } } } return success(pageList); } //统计实时库存数量 @PostMapping(value = "/countByGmId") public RESTfulResult countByGmId() { Long code = wmspGridMaterialService.countByGmId(); return success(code); } // 通过成品仓库网格ID查询实时库存 @ApiImplicitParam("通过成品仓库网格ID查询实时库存") @PostMapping(value = "/selectGridMaterialListByGridId") public RESTfulResult selectGridMaterialListByGridId(BigDecimal gridId) { Map mapVal = new HashMap<>(); mapVal.put("gridId",gridId); List> list = wmspGridMaterialService.selectGridMaterialListByGridId(mapVal); return success(list); } // 修改物资钢材表的质量是否合格字段和逻辑删除 @ApiImplicitParam("修改物资钢材表的质量是否合格字段和逻辑删除") @PostMapping(value = "/updateRmsMaterialSteelDemotion") public RESTfulResult updateRmsMaterialSteelDemotion(@RequestBody Map map) { int i = wmspGridMaterialService.updateRmsMaterialSteelDemotion(map); return success(i); } /** * 1.查看实时库存物质在实时库存里面没有出库的物质!!! * @param * @return */ @ApiOperation(value = "新增扫描吊牌实绩") @PostMapping("/getReboundScanResultByResultMaterial") @Transactional public synchronized RESTfulResult getReboundScanResultByResultMaterial(@RequestBody(required = false)Mapmap) throws ParseException { //已存在的集合 List> list=null; if (map.containsKey("dateList")&&map.get("dateList")!=null){ list=(List>) map.get("dateList"); }else{ list=new ArrayList<>(); } //判断是否重复扫描 for (int i=0;i item=list.get(i); if (item.get("resultMaterial").toString().equals(map.get("resultMaterial").toString())){ return success(list); } } //解析扫描信息 //将扫描吊牌结果根据分隔符截取字符串 String[] split = map.get("resultMaterial").toString().split("-"); //唯一编码 String MaterialOnlyCode=split[7]; //查询是否未出库 Map result= wmspGridMaterialService.getReboundScanResultByResultMaterial(map.get("resultMaterial").toString().substring(0,map.get("resultMaterial").toString().length()-1),MaterialOnlyCode); if (result!=null){ //赋值一个主键 result.put("resultMaterial",map.get("resultMaterial").toString()); //如果没有出库就需要这件钢材放到未出库钢材集合里面 list.add(result); } return success(list); } @ApiOperation(value = "获得物质类型",notes = "根据仓库垛位层号获得物质类型") @ApiImplicitParams({ @ApiImplicitParam(name = "warehouseid",dataType = "DECIMAL",value = "仓库"), @ApiImplicitParam(name = "stackingId",dataType = "BigDicemal",value = "垛位"), @ApiImplicitParam(name = "gradtionNumber",dataType = "BigDicemal",value = "层号") }) @GetMapping("/getMaterialTypeList") public RESTfulResult getMaterialTypeList(String warehouseid,BigDecimal stackingId,BigDecimal gradtionNumber){ //获得一个list> map里面包括:物质Id、物质名称、物质型号、理论重量、物质件数 List> map=wmspGridMaterialService.getMaterialTypeList(warehouseid,stackingId,gradtionNumber); return success(); } }