123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- package com.steerinfo.dil.controller;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.TypeReference;
- import com.github.pagehelper.PageHelper;
- import com.steerinfo.dil.feign.ColumnDataFeign;
- 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.PageListAdd;
- import com.steerinfo.framework.controller.RESTfulResult;
- import io.swagger.annotations.ApiImplicitParam;
- import io.swagger.annotations.ApiImplicitParams;
- import io.swagger.annotations.ApiOperation;
- import org.apache.commons.collections.MapUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- 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 springfox.documentation.spring.web.json.Json;
- import java.math.BigDecimal;
- 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;
- /**
- * 1.新增扫描吊牌实绩!!!此时入库实绩未生成
- * @param
- * @return
- */
- @ApiOperation(value = "新增扫描吊牌实绩")
- @PostMapping("/insertResult2")
- @Transactional
- public synchronized RESTfulResult insertScanResult(@RequestBody(required = false)Map<String,Object>map) throws ParseException {
- //这里需要的参数包括 扫码人账号 userId、二维码信息 resultMaterial
- //首先判断二维码是否已经被扫过了
- //判断条件是查询扫描实绩判断是否已经存在改唯一标识码并且扫码人是否是自己
- int isExist= wmsInboundScanResultService.isExist(map.get("userName").toString(),map.get("resultMaterial").toString().substring(0,map.get("resultMaterial").toString().length()-1));
- //通过用户ID查询、当前扫描没有下发的物质、最终展示的集合
- List<Map<String,Object>>mapList= wmsInboundScanResultService.noIssueScanResultList(map.get("userName").toString());
- if (isExist>0){
- //如果已经被少扫过了返回扫码实绩集合
- //返回结果显示
- return failed(mapList);
- }else {
- //如果没有被扫
- //创建一个扫码实绩
- Map<String, Object> wmspInboundScanResult =wmsInboundScanResultService.createInboundScanResultByResultMaterial(mapList.size(),map.get("userName").toString(),map.get("resultMaterial").toString());
- //判断是否创建成功、成功在添加
- if (wmspInboundScanResult!=null){
- mapList.add(wmspInboundScanResult);
- }
- }
- return success(mapList);
- }
- /**
- * 1.新增扫描吊牌实绩!!!此时入库实绩未生成
- * @param
- * @return
- */
- @ApiOperation(value = "新增扫描吊牌实绩")
- @PostMapping("/insertResult")
- @Transactional
- public synchronized RESTfulResult insertResult(@RequestBody(required = false)Map<String,Object>map) 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<Map<String,Object>>mapList =wmsInboundScanResultService.getScanResult(loadId);
- return failed(mapList);
- }
- }
- //设置入库物资件数,默认一件
- 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);
- 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<Map<String,Object>>mapList =wmsInboundScanResultService.getScanResult(loadId);
- return success(mapList);
- }
- /**
- * 展示未下发扫描实绩
- * @return
- */
- @ApiOperation(value="展示未下发扫描实绩")
- @PostMapping("/getScanResult")
- public RESTfulResult getScanResult(@RequestBody(required = false) Map<String,Object>map){
- BigDecimal loadId = wmsInboundScanResultService.getLoadId(map);
- map.put("loadId",loadId);
- List<Map<String,Object>>mapList =wmsInboundScanResultService.getScanResult(loadId);
- return success(mapList);
- }
- /**
- *
- * @return
- */
- @ApiOperation(value="展示垛位")
- @PostMapping("/selectStackingInfoByWarehouseId")
- public RESTfulResult selectStackingInfoByWarehouseId(@RequestBody(required = false) Map<String,Object>map){
- List<Map<String,Object>>mapList =wmsInboundScanResultService.selectStacking(map);
- return success(mapList);
- }
- /**
- *
- * @return
- */
- @ApiOperation(value="更新状态")
- @PostMapping("/updateStatus")
- public RESTfulResult updateStatus(@RequestBody(required = false) Map<String,Object>map){
- Integer integer =wmsInboundScanResultService.updateStatus(map);
- return success(integer);
- }
- /**
- * 展示异常入库吊钢工扫描吊牌实绩
- * @return
- */
- @ApiOperation(value="展示异常入库吊钢工扫描吊牌实绩")
- @PostMapping("/getIssuedTagNoResult")
- public RESTfulResult getIssuedTagNoResult(){
- HashMap<String, Object> map = new HashMap<>();
- List<Map<String, Object>> 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<String, Object> mapValue,
- Integer apiId,
- Integer pageNum,
- Integer pageSize,
- Integer inboundId) {
- if (inboundId!=null){
- mapValue.put("inboundId",inboundId);
- }
- List<Map<String, Object>> reboundResultTotal = wmsInboundResultService.selectScanResultByIboundResultId(mapValue);
- List<Map<String, Object>> columnDataList = columnDataFeign.getColumnData(apiId);
- /*分页*/
- PageHelper.startPage(pageNum, pageSize);
- /*返回中英文对照结果,计算表头*/
- List<Map<String, Object>> reboundResult = wmsInboundResultService.selectScanResultByIboundResultId(mapValue);
- for (Map<String, Object> columnData : columnDataList) {
- columnData.put("filters", setListMap(reboundResultTotal, columnData.get("prop").toString()));
- }
- PageListAdd pageList = new PageListAdd(reboundResult);
- pageList.setColumnData(columnDataList);
- return success(pageList);
- }
- Set<Map<String, Object>> setListMap(List<Map<String, Object>> list, String name) {
- Set<Map<String, Object>> setString = new HashSet<>();
- for (Map<String, Object> map : list) {
- Map<String, Object> 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;
- }
- }
|