package com.steerinfo.dil.controller; import com.steerinfo.dil.feign.ESFeign; import com.steerinfo.dil.mapper.WmspGridMaterialMapper; import com.steerinfo.dil.model.*; import com.steerinfo.dil.service.ICommonService; import com.steerinfo.dil.service.IWmspInboundDistributeService; import com.steerinfo.dil.service.impl.*; import com.steerinfo.dil.util.*; import com.steerinfo.framework.controller.RESTfulResult; import com.steerinfo.framework.service.pagehelper.PageHelper; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import io.swagger.models.auth.In; 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.util.*; //import java.util.*; /** * @author luobang * @create 2021-09-06 18:13 */ @Api("入库实绩") @RestController @RequestMapping("${api.version}/inboundResult") public class WmsInboundResultController extends BaseRESTfulController { @Autowired ColumnDataUtil columnDataUtil; @Autowired ESFeign esFeign; @Autowired WmsInboundResultServiceImpl wmsInboundResultServiceImpl; @Autowired WmsInboundScanResultServiceImpl wmsInboundScanResultServiceImpl; @Autowired WmsInboundDrivingResultServiceImpl wmsInboundDrivingResultServiceImpl; @Autowired RmsStackingServiceImpl rmsStackingService; @Autowired RmsPwarehouseGridServiceImpl rmsPwarehouseGridService; @Autowired WmspGridMaterialServiceImpl wmspGridMaterialService; @Autowired WmspGridMaterialMapper wmspGridMaterialMapper; @Autowired WmsInboundStackResultServiceImpl wmsInboundStackResultServiceImpl; @Autowired WmspInboundDistributeServiceImpl wmspInboundDistributeService; @Autowired ICommonService commonService; /** * 展示入库实绩 * @param mapValue * @param apiId * @param pageNum * @param pageSize * @return */ @PostMapping("/getWmsInboundResult2") @ApiOperation(value = "展示入库实绩信息") @ApiImplicitParams({ @ApiImplicitParam(name = "apiId", value = "90", required = false, dataType = "BigDecimal"), }) public RESTfulResult getWmsInboundResult(@RequestBody(required = false) Map mapValue, Integer apiId, Integer pageNum, Integer pageSize, String con) { if(con != null){ if(!"undefined".equals(con)){ String index = "get_wms_inboundresult"; return success(esFeign.getConResult(mapValue,index,apiId,pageNum,pageSize,con)); } } List>inboundResultList = null; if(mapValue.size() == 0){ //将查询结果存入索引中 inboundResultList = wmsInboundResultServiceImpl.getInboundResult(mapValue); Map inboundResultMap = new HashMap<>(); //添加索引 inboundResultMap.put("index","get_wms_inboundresultse"); //添加ID inboundResultMap.put("indexId","inboundresultId"); inboundResultList.add(inboundResultMap); //新建索引 esFeign.insertIndex(inboundResultList); //删除 inboundResultList.remove(inboundResultList.size() -1); } if(inboundResultList == null) { inboundResultList = wmsInboundResultServiceImpl.getInboundResult(mapValue); } /*分页*/ PageHelper.startPage(pageNum, pageSize); List> columnList = wmsInboundResultServiceImpl.getInboundResult(mapValue); PageListAdd pageList = columnDataUtil.tableColumnData(apiId,inboundResultList,columnList); return success(pageList); } /** * 新增入库实绩 * * @param * @return */ @ApiOperation("新增入库实绩") @PostMapping("/insertInboundResult2") @Transactional public RESTfulResult addInvoice(@RequestParam("userName") String userName,@RequestParam("groupId") BigDecimal groupId,@RequestParam("personnelWorkshopid") BigDecimal personnelWorkshopid, @RequestBody(required = false) List> mapList) { //首先做的判断处理 //由于钢材是分批次、一批四件的(有特殊情况不是一批四件) //所有需要设置他们批次不能跨越一个应该是相连的,如果批次跨过两个说明有一个多按了一次,或者是有了一个人少按了一次,所以需要少下发的和多下发的对其。 //使两个人批次相同 //查询当前分组下次最新的一次下发、 // 第一、判断库状态是否是下发中的 // 第二、判断自己上一组是否完成,如果上一组已经完成则开始下一组、没有完成给一点提示 //遗留 查询批次、以及状态 //一、创建一个批次信息 WmspInboundDistribute wmspInboundDistribute=new WmspInboundDistribute(); //初始化下发批次信息 //主键 wmspInboundDistribute.setDistributeId(IDUtils.createIDYMDHMS(commonService.getSeqCount("seq_WMSP_INBOUND_DISTRIBUTE"))); //分组 wmspInboundDistribute.setInboundGroupId(groupId); //入库状态 1、下发中、2、已完成、3、已接受、4、已结束 //如果两个都已经下发改变状态为已下发、只有一个下发改变状态为下发中 //2、并且当前改变当前用户的,未下发状态为已经下发(给扫码实绩赋值入库实绩id) wmspInboundDistribute.setResultStatus(new BigDecimal(1)); //当前用户批次 wmspInboundDistribute.setBatch(new BigDecimal(1)); //行车工 没有接收是没有这个字段的 //wmspInboundDistribute.setDistributeId(); //创建用户 wmspInboundDistribute.setInsertUsername(userName); for (int i=0;i item=mapList.get(i); //二、智能的设置好这批钢材的位置、网格图 //二、创建一个默认的网格 解释:目前还没有设计出来网格的结构 没有做默认为 第一库、第一月台、第一垛位、第一行、第一列 //遗留 批次、网格 //三、创建一个入库作业实绩 WmspInboundResult wmspInboundResult=new WmspInboundResult(); //1、给实绩属性赋值 int orderNumber = wmsInboundResultServiceImpl.count(); // 主键ID wmspInboundResult.setInboundId(IDUtils.createIDYMD(String.valueOf(orderNumber))); //批次ID wmspInboundResult.setInboundDistributeId(wmspInboundDistribute.getDistributeId()); //入库类型 wmspInboundResult.setInboundType(new BigDecimal(0)); //入库单/退库单/倒库单编号(WRKD-年月日-8位数的顺序号) String number=Liushuih.generateNextNumber("WRKD-", "yyyyMMdd-", 8, orderNumber); wmspInboundResult.setInboundNumber(number); //仓储网格 //wmspInboundResult.setGridId(new BigDecimal(1)); //入库单是否下发:0:未下发;1:已下发; 2:已接收 wmspInboundResult.setResultStatus(new BigDecimal(0)); //物资ID wmspInboundResult.setMaterialId(new BigDecimal(item.get("materialId").toString())); //入库是否完成(0:未完成,1:已完成) wmspInboundResult.setInboundIscomplete(new BigDecimal(0)); //逻辑删除:1:删除;0:未删除 wmspInboundResult.setResultDeleted(new BigDecimal(0)); //入库日期 wmspInboundResult.setInboundTime(new Date()); //记录创建人 wmspInboundResult.setInsertUsername(userName); //记录创建时间 wmspInboundResult.setInsertTime(new Date()); } //四、推送信息给行车工、让他们抢单 return success(null); } /** * 新增入库实绩 * * @param * @return */ @ApiOperation("新增入库实绩") @PostMapping("/insertInboundResult") @Transactional public RESTfulResult addInvoice( @RequestBody(required = false) List> mapList) { //获取前方传来的仓库ID进行入库 BigDecimal warehouseId = new BigDecimal((Integer)mapList.get(0).get("personnelWorkshopid")); String inboundValue = null; BigDecimal ST = null; if(warehouseId.intValue() == 3){ inboundValue = wmsInboundResultServiceImpl.selectWarehouseName(new BigDecimal(3)); } //!!!默认该仓库的所有行车工都能看到 //!!!待添加,查询该仓库所有在班的行车工 String personnelJobNumber = "000417"; if(warehouseId.intValue() != 3){ //查询入库垛位信息 Map stackingMap = rmsStackingService.getStackingToUpdate(mapList.size(),warehouseId,personnelJobNumber); //获取入库垛位ID ST = (BigDecimal) stackingMap.get("stackingId"); inboundValue = stackingMap.get("stackingNo").toString(); } for (Map map:mapList ) { WmspInboundResult wmspInboundResult = new WmspInboundResult(); wmspInboundResult.setId(new BigDecimal(wmsInboundResultServiceImpl.count() + 1)); /* 设置入库类型为生产入库 */ wmspInboundResult.setInboundType(new BigDecimal(0)); /* 设置入库单编号 */ String number=Liushuih.generateNextNumber("WRKD-", "yyyyMMdd-", 8, 12); wmspInboundResult.setInboundNumber(number); /* 设置逻辑删除字段 */ wmspInboundResult.setResultDeleted(new BigDecimal(0)); /* 设置常规字段 */ wmspInboundResult.setInsertUsername("admin"); wmspInboundResult.setInsertTime(new Date()); wmspInboundResult.setUpdateUsername("admin"); wmspInboundResult.setUpdateTime(new Date()); wmspInboundResult.setInsertUpdateRemark("无"); /* 设置入库日期 */ wmspInboundResult.setInboundTime(new Date()); /* 设置入库单状态为已下发 */ wmspInboundResult.setResultStatus(new BigDecimal(1)); /* 设置入库状态,当异常值为0时,入库状态设为未完成;当异常值为1时,入库状态设为完成 */ Integer K = 1; if(warehouseId.intValue() != 3){ System.out.println(map.containsKey("abnormalis")); System.out.println(map.get("abnormalis")); K = (map.containsKey("abnormalis")&&map.get("abnormalis").toString().isEmpty())?Integer.valueOf(map.get("abnormalis").toString()):0; } if (K==0){ wmspInboundResult.setResultStatus(new BigDecimal(0)); wmspInboundResult.setInboundIscomplete(new BigDecimal(0)); } else{ wmspInboundResult.setResultStatus(new BigDecimal(1)); wmspInboundResult.setInboundIscomplete(new BigDecimal(1)); } Integer MN = null ; Integer CC = null ; Integer CX = null ; if(warehouseId.intValue() != 3){ //根据垛位ID查询物资数,确定层次层序,即网格ID HashMap map1 = new HashMap<>(); map1.put("stackingId",ST); //获取物资数 MN=rmsStackingService.selectMaterialNumber(map1); //计算层次号 CC=(MN+1)/24+1; //计算层序号 CX=(MN+1)%24; //更新垛位表 rmsStackingService.updateStack(ST); } //根据仓库id、垛位ID,层次号,层序号查找仓储网格 HashMap map3 = new HashMap<>(); map3.put("warehouseId",warehouseId); map3.put("stackingID",ST); map3.put("gradationNumber",CC); map3.put("sequenceNumber",CX); BigDecimal gridId=rmsPwarehouseGridService.getGridId(map3); //设置入库实绩里面的网格ID wmspInboundResult.setGridId(gridId); /* 插入一条网格物资中间表 */ WmspGridMaterial wmspGridMaterial = new WmspGridMaterial(); //设置主键ID wmspGridMaterial.setGmId(wmspGridMaterialMapper.getCount()); wmspGridMaterial.setGridId(gridId); wmspGridMaterial.setGmNumber(new BigDecimal(1)); wmspGridMaterial.setStandardDataId(new BigDecimal(1)); //设置网格物资表里面的物资ID BigDecimal materialId= DataChange.dataToBigDecimal(map.get("materialId")); wmspInboundResult.setMaterialId(materialId); wmspGridMaterial.setMaterialId(materialId); //设置逻辑删除字段 wmspGridMaterial.setDeleted(new BigDecimal(0)); //设置常规字段 wmspGridMaterial.setInsertUsername("admin"); wmspGridMaterial.setInsertTime(new Date()); wmspGridMaterial.setUpdateUsername("admin"); wmspGridMaterial.setUpdateTime(new Date()); wmspGridMaterial.setInsertUpdateRemark("无"); wmspGridMaterial.setStatus(new BigDecimal(2)); wmspGridMaterialService.insertWmspGridMaterial(wmspGridMaterial); /* 新增入库实绩主表 */ wmsInboundResultServiceImpl.insertWmsInboundResult(wmspInboundResult); /* 新增天车司机接收实绩 */ WmspInboundDrivingResult wmspInboundDrivingResult = new WmspInboundDrivingResult(); wmspInboundDrivingResult.setDrivingId(new BigDecimal(wmsInboundDrivingResultServiceImpl.count()+1)); wmspInboundDrivingResult.setDriverId(new BigDecimal(9)); wmspInboundDrivingResult.setDrivingReceiveTime(new Date()); wmspInboundDrivingResult.setInboundResultId(wmspInboundResult.getInboundId()); wmspInboundDrivingResult.setInsertUsername("admin"); wmspInboundDrivingResult.setInsertTime(new Date()); wmspInboundDrivingResult.setUpdateUsername("admin"); wmspInboundDrivingResult.setResultDeleted(new BigDecimal(1)); wmsInboundDrivingResultServiceImpl.insertWmspInboundDrivingResult(wmspInboundDrivingResult); /* 新增选择垛位实绩 */ WmspInboundStackResult wmspInboundStackResult = new WmspInboundStackResult(); wmspInboundStackResult.setResultId(new BigDecimal(wmsInboundStackResultServiceImpl.count()+1)); wmspInboundStackResult.setInboundResultId(wmspInboundResult.getInboundId()); wmspInboundStackResult.setStackingId(ST); wmspInboundStackResult.setResultDeleted(new BigDecimal(1)); //设置常规字段 wmspInboundStackResult.setInsertUsername("admin"); wmspInboundStackResult.setInsertTime(new Date()); wmspInboundStackResult.setUpdateUsername("admin"); wmspInboundStackResult.setUpdateTime(new Date()); wmspInboundStackResult.setInsertUpdateRemark("无"); wmspInboundStackResult.setStackingStatus(new BigDecimal(0)); wmsInboundStackResultServiceImpl.insertWmsInboundStackResult(wmspInboundStackResult); System.out.println(map.get("LOADA")); System.out.println(map.get("LOADB")); //判断物资是否为线材 BigDecimal count = wmsInboundScanResultServiceImpl.selectMaterialTypeByMaterialId(materialId); BigDecimal resultId= new BigDecimal((Integer)map.get("resultId")) ; // BigDecimal RESULTBID= new BigDecimal((Integer)map.get("RESULTBID")) ; BigDecimal InbounId=wmspInboundResult.getInboundId(); if(count!=null){ /* 编辑扫描实绩-根据前台返回的扫描实绩ID修改扫描实绩 */ HashMap map5 = new HashMap<>(); Map otherLoadMap = new HashMap<>(); otherLoadMap.put("personnelWorkshopid",map.get("personnelWorkshopid")); otherLoadMap.put("personnelShifts",map.get("personnelShifts")); otherLoadMap.put("personnelTeam",map.get("personnelTeam")); otherLoadMap.put("resultId",resultId); //获取同一班次班组车间扫描次数扫描实绩 List> otherResultIds = wmsInboundScanResultServiceImpl.getOntherLoadId(otherLoadMap); //根据物资id查询是否该物资为线材 //设置另一个扫描实绩id为空 BigDecimal otherResultId = null; //遍历查询出的同一班次班组车间扫描次数所有扫描实绩 for (Map otherMap : otherResultIds) { //判断,查询出来的扫描实绩id是否于点击下发的扫描实绩的id相同 //如果不同,将获取到的扫描实绩主键id赋予otherResultId if (((BigDecimal) otherMap.get("resultId")).intValue() != resultId.intValue()) { otherResultId = (BigDecimal) otherMap.get("resultId"); } } //更新扫描实绩 map5.put("resultId",resultId); map5.put("InbounId",InbounId); wmsInboundScanResultServiceImpl.updateWmsInboundScanById(map5); map5.remove("resultId"); map5.put("resultId",otherResultId); wmsInboundScanResultServiceImpl.updateWmsInboundScanById(map5); } //更新扫描实绩状态 Map map7=new HashMap<>(); map7.put("resultId",resultId); map7.put("InbounId",InbounId); wmsInboundScanResultServiceImpl.updateWmsInboundScanById(map7); } return success(inboundValue); } //根据入库实绩id查找扫描实绩 @PostMapping("/selectScanResultByIboundResultId") @ApiOperation(value = "根据入库实绩id获得扫描实绩数据") @ApiImplicitParams({ @ApiImplicitParam(name = "apiId", value = "", required = false, dataType = "BigDecimal"), }) public RESTfulResult selectScanResultByIboundResultId(@RequestBody(required = false) Map mapValue, Integer apiId, Integer pageNum, Integer pageSize, String con ) { if(con != null){ if(!"undefined".equals(con)){ String index = "get_wms_inboundScanResult"; return success(esFeign.getConResult(mapValue,index,apiId,pageNum,pageSize,con)); } } List>inboundScanResultList = null; if(mapValue.size() == 0){ //将查询结果存入索引中 inboundScanResultList = wmsInboundResultServiceImpl.selectScanResultByIboundResultId(mapValue); Map inboundScanResultMap = new HashMap<>(); //添加索引 inboundScanResultMap.put("index","get_wms_inboundScanResult"); //添加ID inboundScanResultMap.put("indexId","inboundScanResultId"); inboundScanResultList.add(inboundScanResultMap); //新建索引 esFeign.insertIndex(inboundScanResultList); //删除 inboundScanResultList.remove(inboundScanResultList.size() -1); } if(inboundScanResultList == null) { inboundScanResultList = wmsInboundResultServiceImpl.selectScanResultByIboundResultId(mapValue); } /*分页*/ PageHelper.startPage(pageNum, pageSize); List> columnList = wmsInboundResultServiceImpl.selectScanResultByIboundResultId(mapValue); PageListAdd pageList = columnDataUtil.tableColumnData(apiId,inboundScanResultList,columnList); return success(pageList); } }