package com.steerinfo.dil.controller; import com.github.pagehelper.PageHelper; import com.steerinfo.dil.feign.BmsTruckFeign; import com.steerinfo.dil.feign.ColumnDataFeign; import com.steerinfo.dil.feign.OmsFeign; import com.steerinfo.dil.feign.TmstruckFeign; import com.steerinfo.dil.mapper.WmspInboundResultMapper; import com.steerinfo.dil.model.*; import com.steerinfo.dil.service.impl.RmsMaterialServiceImpl; import com.steerinfo.dil.service.impl.RmsMaterialSteelServiceImpl; import com.steerinfo.dil.service.impl.WmsInboundResultServiceImpl; import com.steerinfo.dil.service.impl.WmsInboundScanResultServiceImpl; import com.steerinfo.dil.util.BaseRESTfulController; import com.steerinfo.dil.util.ColumnDataUtil; import com.steerinfo.dil.util.DataChange; import com.steerinfo.dil.util.PageListAdd; import com.steerinfo.framework.controller.RESTfulResult; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.annotation.Order; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.math.BigDecimal; import java.text.DateFormat; import java.text.ParseException; import java.util.*; /** * @author luobang * @create 2021-09-07 15:15 */ @RestController @RequestMapping("${api.version}/inboundScanResult") public class WmsInboundScanResultController extends BaseRESTfulController { @Autowired WmsInboundResultServiceImpl wmsInboundResultService; @Autowired WmsInboundScanResultServiceImpl wmsInboundScanResultService; @Autowired RmsMaterialServiceImpl rmsMaterialService; @Autowired RmsMaterialSteelServiceImpl rmsMaterialSteelService; @Autowired WmspInboundResultMapper wmspInboundResultMapper; @Autowired ColumnDataUtil columnDataUtil; @Autowired ColumnDataFeign columnDataFeign; @Autowired OmsFeign omsFeign; @Autowired BmsTruckFeign bmsTruckFeign; @Autowired TmstruckFeign tmstruckFeign; @Autowired WmsInboundResultController inboundResultController; /** * 1.新增扫描吊牌实绩!!!此时入库实绩未生成 * @param * @return */ @ApiOperation(value = "新增扫描吊牌实绩") @PostMapping("/insertResult") @Transactional public synchronized RESTfulResult insertResult(@RequestBody(required = false)Mapmap) throws Exception { //这里需要的参数包括 扫码人账号 userId、二维码信息 resultMaterial //首先判断二维码是否已经被扫过了 //判断条件是查询扫描实绩判断是否已经存在改唯一标识码并且扫码人是否是自己 System.out.println(map.get("resultMaterial")); //订单类型为倒库,直接扫码所有并返回数据 Map order=wmsInboundScanResultService.getOrderTypeByNum((String)map.get("resultMaterial")); if(order !=null && order.get("orderType")!=null && DataChange.dataToBigDecimal(order.get("orderType")).intValue() == 25){ Integer orderType=DataChange.dataToBigDecimal(order.get("orderType")).intValue(); BigDecimal orderId=DataChange.dataToBigDecimal(order.get("orderId")); //校验是否有装货实绩,若没有则不允许入库 Integer count=wmsInboundScanResultService.isExistLoad((String)map.get("resultMaterial")); if(count==null|| count<=0){ return failed(null); } //根据运输订单号查询出库扫码实绩 List> inboundOld= wmsInboundScanResultService.findInboundScanResult((String)map.get("resultMaterial")); //批量新增扫码实绩 if(inboundOld!=null || inboundOld.size()>0 || inboundOld.get(0)!=null){ wmsInboundScanResultService.createInboundScanResultByFind(inboundOld,map); } else{ System.out.println("物资暂未出库,请先出库再入库!"); return failed(null); } //返回新建的扫码实绩数据 List> mapList= wmsInboundScanResultService.noIssueScanResultList(map.get("userName").toString()); //新增卸货实绩 tmstruckFeign.updateUnloadResult(order); //关闭运输订单 omsFeign.closeInwardOrder(orderId.intValue(),2,null); //生成计费详单 bmsTruckFeign.addInwardDetailsOrder(order); return success(mapList); } int isExist= wmsInboundScanResultService.isExist(map.get("userName").toString(),map.get("resultMaterial").toString().substring(0,map.get("resultMaterial").toString().length()-1)); //通过用户ID查询、当前扫描没有下发的物质、最终展示的集合 List>mapList= wmsInboundScanResultService.noIssueScanResultList(map.get("userName").toString()); if (isExist>0){ //如果已经被扫过了返回扫码实绩集合 //返回结果显示 return failed(mapList); }else { //如果没有被扫 //创建一个扫码实绩 Map wmspInboundScanResult =wmsInboundScanResultService.createInboundScanResultByResultMaterial(mapList.size(),map.get("userName").toString(),map.get("resultMaterial").toString(),""+map.get("hookNo")); //判断是否创建成功、成功在添加 // if (wmspInboundScanResult!=null){ // mapList.add(wmspInboundScanResult); // } mapList= wmsInboundScanResultService.noIssueScanResultList(map.get("userName").toString()); } System.out.println(mapList); return success(mapList); } /** * 1.新增扫描吊牌实绩!!!此时入库实绩未生成 * @param * @return */ @ApiOperation(value = "新增扫描吊牌实绩") @PostMapping("/insertScanResultGroup") @Transactional public synchronized RESTfulResult insertScanResultGroup(@RequestBody(required = false)Mapmap) throws ParseException { //这里需要的参数包括 扫码人账号 userId、二维码信息 resultMaterial //首先判断二维码是否已经被扫过了 int isExist= wmsInboundScanResultService.isExistInboundScanResult(map.get("resultMaterial").toString().substring(0,map.get("resultMaterial").toString().length()-1)); //通过用户ID查询、当前扫描没有下发的物质、最终展示的集合 List>mapList= wmsInboundScanResultService.noIssueScanResultList(map.get("userName").toString()); if (isExist>0){ //如果已经被少扫过了返回扫码实绩集合 //返回结果显示 return failed(mapList); }else { //如果没有被扫 //创建一个扫码实绩 Map wmspInboundScanResult =wmsInboundScanResultService.createInboundScanResultByResultMaterial(mapList.size(),map.get("userName").toString(),map.get("resultMaterial").toString(),""+map.get("hookNo")); //判断是否创建成功、成功在添加 // if (wmspInboundScanResult!=null){ // mapList.add(wmspInboundScanResult); // } mapList= wmsInboundScanResultService.noIssueScanResultList(map.get("userName").toString()); } return success(mapList); } /** * 1.新增扫描吊牌实绩!!!此时入库实绩未生成 * @param * @return */ @ApiOperation(value = "新增扫描吊牌实绩") @PostMapping("/insertResult2") @Transactional public synchronized RESTfulResult insertResult2(@RequestBody(required = false)Mapmap) throws ParseException { int i=0; WmspInboundScanResult wmspInboundScanResult = new WmspInboundScanResult(); //获取工号查找id BigDecimal loadId = wmsInboundScanResultService.getLoadId(map); map.put("loadId",loadId); BigDecimal inboundResultId = new BigDecimal((Integer)map.get("inboundId")); //判断是否重复扫码 //调用判断是否重复扫码的方法 if(inboundResultId.intValue() == -1){ if(wmsInboundScanResultService.checkScanTag(map,loadId) == 0){ List>mapList =wmsInboundScanResultService.getScanResult(loadId); return failed(mapList); } } wmspInboundScanResult.setResultId(new BigDecimal(String.valueOf(wmsInboundScanResultService.count()))); //设置入库物资件数,默认一件 wmspInboundScanResult.setInboundMaterialNumber(new BigDecimal(1)); //设置吊钢工已扫物资件数 wmspInboundScanResult.setResultNumber(new BigDecimal(wmsInboundScanResultService.scanNumber(map)+1)); map.put("resultNumber",wmspInboundScanResult.getResultNumber()); //设置常规字段 插入人为吊钢工的名字 wmspInboundScanResult.setInsertTime(new Date()); //设置吊钢工扫描吊牌时间 wmspInboundScanResult.setResultLoadTime(new Date()); //设置状态为未下发 wmspInboundScanResult.setResultStatus(new BigDecimal(0)); //设置吊钢工Id wmspInboundScanResult.setLoadId(loadId); //设置扫描吊牌实绩 String str = (String) map.get("resultMaterial"); wmspInboundScanResult.setResultMaterial(str); //设置入库实绩ID if (inboundResultId.intValue() != -1){ BigDecimal hh=wmspInboundScanResult.getInboundResultId() ; wmspInboundScanResult.setInboundResultId(inboundResultId); wmspInboundScanResult.setResultStatus(new BigDecimal(1)); } //设置逻辑删除字段 wmspInboundScanResult.setResultDeleted(new BigDecimal(1)); //新增钢材物资ID Integer k = rmsMaterialSteelService.insertRmsMaterialSteel(str,""+map.get("hookNo")); wmspInboundScanResult.setMaterialId(new BigDecimal(k)); //根据班次班组查找同一车间的另一位小伙伴 //判断物资是否为线材 BigDecimal count = wmsInboundScanResultService.selectMaterialTypeByMaterialId(new BigDecimal(k)); wmspInboundScanResult.setInboundAbnormalis(new BigDecimal(0)); if(count != null){ BigDecimal otherLoadId = wmsInboundScanResultService.getOtherLoadId(map); map.put("otherLoadId",otherLoadId); //查找另一位兄弟的相同次数的扫描实绩里面的物资ID Integer otherMaterialId = wmsInboundScanResultService.getOtherMaterialSteelId(map); if (otherMaterialId==k) { wmspInboundScanResult.setInboundAbnormalis(new BigDecimal(1)); } else{ wmspInboundScanResult.setInboundAbnormalis(new BigDecimal(0)); } } //插入扫描吊牌实绩 Integer integer = wmsInboundScanResultService.insertWmsInboundScanResult(wmspInboundScanResult); System.out.println("-----------"+integer); if (integer!=1){ return failed(); } //判断物资是否为线材 if(count != null){ //如果不为线材 //更新异常值 wmsInboundScanResultService.updateInboundAbnormal(map); } List>mapList =wmsInboundScanResultService.getScanResult(loadId); return success(mapList); } /** * 展示未下发扫描实绩 * @return */ @ApiOperation(value="展示未下发扫描实绩") @PostMapping("/getScanResult") public RESTfulResult getScanResult(@RequestBody(required = false) Mapmap){ BigDecimal loadId = wmsInboundScanResultService.getLoadId(map); map.put("loadId",loadId); List>mapList =wmsInboundScanResultService.getScanResult(loadId); return success(mapList); } /** * * @return */ @ApiOperation(value="展示垛位") @PostMapping("/selectStackingInfoByWarehouseId") public RESTfulResult selectStackingInfoByWarehouseId(@RequestBody(required = false) Mapmap){ List>mapList =wmsInboundScanResultService.selectStacking(map); return success(mapList); } /** * * @return */ @ApiOperation(value="更新状态") @PostMapping("/updateStatus") public RESTfulResult updateStatus(@RequestBody(required = false) Mapmap){ Integer integer =wmsInboundScanResultService.updateStatus(map); return success(integer); } /** * 展示异常入库吊钢工扫描吊牌实绩 * @return */ @ApiOperation(value="展示异常入库吊钢工扫描吊牌实绩") @PostMapping("/getIssuedTagNoResult") public RESTfulResult getIssuedTagNoResult(){ HashMap map = new HashMap<>(); List> scanIssuedTagResult = wmsInboundScanResultService.getIssuedScanTagNoResult(map); return success(scanIssuedTagResult); } //根据入库实绩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, Integer inboundId) { if (inboundId!=null){ mapValue.put("inboundId",inboundId); } List> reboundResultTotal = wmsInboundResultService.selectScanResultByIboundResultId(mapValue); List> columnDataList = columnDataFeign.getColumnData(apiId); /*分页*/ PageHelper.startPage(pageNum, pageSize); /*返回中英文对照结果,计算表头*/ List> reboundResult = wmsInboundResultService.selectScanResultByIboundResultId(mapValue); for (Map columnData : columnDataList) { columnData.put("filters", setListMap(reboundResultTotal, columnData.get("prop").toString())); } PageListAdd pageList = new PageListAdd(reboundResult); pageList.setColumnData(columnDataList); return success(pageList); } Set> setListMap(List> list, String name) { Set> setString = new HashSet<>(); for (Map map : list) { Map map1 = new HashMap<>(); map1.put("text", map.get(name)); if (map.get(name) != null) { //判断是否是运力类型 if ("capacity_type".equals(name)) { switch (map.get(name).toString().trim()) { case "自有电车": map1.put("value", 0); break; case "自有汽车": map1.put("value", 1); break; case "社会车辆": map1.put("value", 2); break; } } else { map1.put("value", map.get(name)); } setString.add(map1); } } return setString; } // 根据index找到对应的成品并改变其入库状态 @ApiOperation(value="展示垛位") @PostMapping("/changeInboundIscomplete") public RESTfulResult changeInboundIscomplete(@RequestBody(required = false) Mapmap){ Integer stackResultId1= (Integer) map.get("stackResultId"); BigDecimal stackResultId=new BigDecimal(stackResultId1); int result =wmsInboundScanResultService.changeInboundIscomplete(stackResultId); return success(result); } /** * 1.新增退货扫描吊牌实绩!!!此时入库实绩未生成 * @param * @return */ @ApiOperation(value = "新增扫描吊牌实绩") @PostMapping("/insertReboundScanResult") @Transactional public synchronized RESTfulResult insertReboundScanResult(@RequestBody(required = false)Mapmap) throws ParseException { //判断自己是否已经扫过了、并且没有出库过 int isExist= wmsInboundScanResultService.isExist2(map.get("userName").toString(),map.get("resultMaterial").toString().substring(0,map.get("resultMaterial").toString().length()-1)); //通过用户ID查询、当前扫描没有下发的物质、最终展示的集合 List>mapList= wmsInboundScanResultService.noIssueScanResultList2(map.get("userName").toString()); if (isExist>0){ //如果已经被少扫过了返回扫码实绩集合 //返回结果显示 return failed(mapList); }else { //如果没有被扫 //创建一个扫码实绩 Map wmspInboundScanResult =wmsInboundScanResultService.createInboundScanResultByResultMaterial2(mapList.size(),map.get("userName").toString(),map.get("resultMaterial").toString(),""+map.get("hookNo")); //判断是否创建成功、成功在添加 if (wmspInboundScanResult!=null){ mapList.add(wmspInboundScanResult); } } return success(mapList); } @ApiOperation(value = "补录吊牌入库实绩") @PostMapping("/recordScanResult") @Transactional public synchronized RESTfulResult recordScanResult(@RequestBody(required = false)Map map) throws Exception { //System.out.println(map); if(map.get("materialOnlyCode") != null && DataChange.dataToBigDecimal(map.get("deleteFlag")).intValue() == 1) { //走删除接口 int i = wmsInboundScanResultService.deleteMaterialSteelMes(map); if(i == 0) { return failed("物资不存在"); } return success(); } if(map.get("number")==null){ //return failed("请输入数量"); map.put("number",1); } if(map.get("materialCode")==null){ return failed("请输入物资编码"); } if(map.get("furnaceNumber")==null){ return failed("请输入炉号"); } if(map.get("userName")==null){ map.put("userName","L1267"); //return failed("请输入用户名"); } if(map.get("theoreticalWeight")==null){ return failed("请输入理重"); } if(map.get("warehouseId")==null && map.get("warehouseName") == null){ return failed("请输入仓库id"); } //根据仓库名称寻找仓库id BigDecimal warehouseId = wmspInboundResultMapper.selectWarehouseIdByName(map.get("warehouseName").toString()); if(warehouseId != null) { map.put("warehouseId",warehouseId); } Integer number=Integer.parseInt(map.get("number").toString()); String userName=map.get("userName").toString(); if(number<=0){ return failed("数量错误,结束"); } //创建扫描实绩 List> resultMaterials=wmsInboundScanResultService.createResultMaterials(map);//创建吊牌 wmsInboundScanResultService.createInboundScanResultByFind(resultMaterials,map);//新增扫描实绩 List> inboundScans=wmsInboundScanResultService.noIssueScanResultList(userName);//查询入库扫描实绩 //创建入库实绩 BigDecimal groupId=new BigDecimal(2),personnelWorkshopid=DataChange.dataToBigDecimal(map.get("warehouseId").toString()); return inboundResultController.addInvoice(userName,groupId,personnelWorkshopid,inboundScans,"物流系统补录"); } }