| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.core.annotations.AppAuth; |
| | | import com.core.common.*; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.mapper.LocDetlMapper; |
| | | import com.zy.asrs.service.OpenService; |
| | | import com.zy.common.service.wms.Result; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.web.BaseController; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * Created by vincent on 2022/4/8 |
| | |
| | | @RestController |
| | | @RequestMapping("open/asrs") |
| | | public class OpenController extends BaseController { |
| | | @Autowired |
| | | private LocDetlMapper locDetlMapper; |
| | | |
| | | private static final String MES_WAREHOUSE_ID = "WH01"; |
| | | |
| | | private static final boolean auth = true; |
| | | public static final ArrayList<String> APP_KEY_LIST = new ArrayList<String>() {{ |
| | |
| | | return R.ok().add(openService.queryStock()); |
| | | } |
| | | |
| | | |
| | | @PostMapping(value = "/MES/inventory/details", consumes = "application/json;charset=UTF-8", produces = "application/json;charset=UTF-8") |
| | | public Result details(@RequestBody(required = false) JSONObject body) { |
| | | try { |
| | | String wareHouseId = body == null ? null : body.getString("wareHouseId"); |
| | | String locId = body == null ? null : body.getString("locId"); |
| | | String matNr = body == null ? null : body.getString("matNr"); |
| | | String orderNo = body == null ? null : body.getString("orderNo"); |
| | | String batch = body == null ? null : body.getString("batch"); |
| | | if (!Cools.isEmpty(wareHouseId) && !MES_WAREHOUSE_ID.equalsIgnoreCase(wareHouseId)) { |
| | | return new Result(200, "操作成功", Collections.emptyList()); |
| | | } |
| | | return new Result(200, "操作成功", locDetlMapper.mesInventoryDetails(wareHouseId, locId, matNr, orderNo, batch)); |
| | | } catch (Exception e) { |
| | | return new Result(500, e.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @PostMapping(value = "/MES/inventory/summary", consumes = "application/json;charset=UTF-8", produces = "application/json;charset=UTF-8") |
| | | public Result summary(@RequestBody(required = false) JSONObject body) { |
| | | try { |
| | | String wareHouseId = body == null ? null : body.getString("wareHouseId"); |
| | | String matNr = body == null ? null : body.getString("matNr"); |
| | | if (!Cools.isEmpty(wareHouseId) && !MES_WAREHOUSE_ID.equalsIgnoreCase(wareHouseId)) { |
| | | return new Result(200, "操作成功", Collections.emptyList()); |
| | | } |
| | | Collection<String> matNrs = null; |
| | | if (!Cools.isEmpty(matNr)) { |
| | | matNrs = Arrays.stream(matNr.split(",")) |
| | | .map(String::trim) |
| | | .filter(s -> !s.isEmpty()) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | return new Result(200, "操作成功", locDetlMapper.mesInventorySummary(wareHouseId, matNrs)); |
| | | } catch (Exception e) { |
| | | return new Result(500, e.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @RestController |
| | | @RequestMapping("/MES/inventory") |
| | | public static class MesInventoryController { |
| | | |
| | | @Autowired |
| | | private LocDetlMapper locDetlMapper; |
| | | |
| | | @PostMapping(value = "/details", consumes = "application/json;charset=UTF-8", produces = "application/json;charset=UTF-8") |
| | | public Result details(@RequestBody(required = false) JSONObject body) { |
| | | try { |
| | | String wareHouseId = body == null ? null : body.getString("wareHouseId"); |
| | | String locId = body == null ? null : body.getString("locId"); |
| | | String matNr = body == null ? null : body.getString("matNr"); |
| | | String orderNo = body == null ? null : body.getString("orderNo"); |
| | | String batch = body == null ? null : body.getString("batch"); |
| | | if (!Cools.isEmpty(wareHouseId) && !MES_WAREHOUSE_ID.equalsIgnoreCase(wareHouseId)) { |
| | | return new Result(200, "操作成功", Collections.emptyList()); |
| | | } |
| | | return new Result(200, "操作成功", locDetlMapper.mesInventoryDetails(wareHouseId, locId, matNr, orderNo, batch)); |
| | | } catch (Exception e) { |
| | | return new Result(500, e.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @PostMapping(value = "/summary", consumes = "application/json;charset=UTF-8", produces = "application/json;charset=UTF-8") |
| | | public Result summary(@RequestBody(required = false) JSONObject body) { |
| | | try { |
| | | String wareHouseId = body == null ? null : body.getString("wareHouseId"); |
| | | String matNr = body == null ? null : body.getString("matNr"); |
| | | if (!Cools.isEmpty(wareHouseId) && !MES_WAREHOUSE_ID.equalsIgnoreCase(wareHouseId)) { |
| | | return new Result(200, "操作成功", Collections.emptyList()); |
| | | } |
| | | Collection<String> matNrs = null; |
| | | if (!Cools.isEmpty(matNr)) { |
| | | matNrs = Arrays.stream(matNr.split(",")) |
| | | .map(String::trim) |
| | | .filter(s -> !s.isEmpty()) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | return new Result(200, "操作成功", locDetlMapper.mesInventorySummary(wareHouseId, matNrs)); |
| | | } catch (Exception e) { |
| | | return new Result(500, e.getMessage(), null); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void auth(String appkey, Object obj, HttpServletRequest request) { |
| | | log.info("{}接口被访问;appkey:{};请求数据:{}", "open/sensorType/list/auth/v1", appkey, JSON.toJSONString(obj)); |
| | | request.setAttribute("cache", obj); |