| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.annotations.AppAuth; |
| | | import com.core.common.BaseRes; |
| | |
| | | import com.zy.asrs.entity.result.OpenInventoryVo; |
| | | import com.zy.asrs.entity.result.OpenSummaryVo; |
| | | import com.zy.asrs.entity.result.TokenVo; |
| | | import com.zy.asrs.mapper.LocDetlMapper; |
| | | import com.zy.asrs.service.LocDetlService; |
| | | import com.zy.asrs.service.LocMastService; |
| | | import com.zy.asrs.service.OpenService; |
| | | import com.zy.common.service.wms.Result; |
| | | import com.zy.common.web.BaseController; |
| | | import com.zy.system.entity.Config; |
| | | import com.zy.system.service.ConfigService; |
| | | import lombok.Synchronized; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * Created by vincent on 2022/4/8 |
| | |
| | | |
| | | @Autowired |
| | | private LocMastService locMastService; |
| | | |
| | | @Autowired |
| | | private LocDetlMapper locDetlMapper; |
| | | |
| | | @Value("${open-asrs.auth.app-id:wms_8f7c3d126a944e3ab5c89d21f4a7c6b2}") |
| | | private String openAppId; |
| | | |
| | | @Value("${open-asrs.auth.app-secret:D9f3A7xP1kLm8Q2tW5zH0sY6vR4bNcE7FjK3uM9pT2aL8qX6}") |
| | | private String openAppSecret; |
| | | |
| | | @Value("${open-asrs.auth.token-valid-minutes:30}") |
| | | private Integer tokenValidMinutes; |
| | | |
| | | private static final Map<String, TokenVo> TOKEN_CACHE = new ConcurrentHashMap<>(); |
| | | |
| | | @Deprecated |
| | | @PostMapping("/grouping") |
| | |
| | | * @return |
| | | */ |
| | | @PostMapping("/getToken") |
| | | public synchronized R getToken(@RequestBody(required = true) TokenParam param, |
| | | public synchronized R getToken(@RequestHeader(required = false) String appkey, |
| | | @RequestBody(required = true) TokenParam param, |
| | | HttpServletRequest request){ |
| | | authNew(param, param, request); |
| | | log.info("获取Token:/getToken接口被访问,appkey={},请求数据={}", appkey, JSON.toJSONString(param)); |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | TokenVo tokenVo = new TokenVo(); |
| | | String token = Cools.enToken(System.currentTimeMillis() + param.getAppId(), param.getAppSecret()); |
| | | tokenVo.setToken(token); |
| | | tokenVo.setValidTime(30); |
| | | return R.ok().add(tokenVo); |
| | | |
| | | String appId = param.getAppId(); |
| | | String appSecret = param.getAppSecret(); |
| | | if (Cools.isEmpty(appId)) { |
| | | return R.error("参数[appId]不能为空"); |
| | | } |
| | | if (Cools.isEmpty(appSecret)) { |
| | | return R.error("参数[appSecret]不能为空"); |
| | | } |
| | | if (Cools.isEmpty(openAppId) || Cools.isEmpty(openAppSecret)) { |
| | | throw new CoolException("系统未配置open-asrs.auth.app-id或open-asrs.auth.app-secret"); |
| | | } |
| | | if (!openAppId.equals(appId) || !openAppId.equals(appSecret)) { |
| | | throw new CoolException("认证失败,请确认appId或appSecret无误!"); |
| | | } |
| | | |
| | | String token = UUID.randomUUID().toString().replace("-", ""); |
| | | long expireAt = System.currentTimeMillis() + tokenValidMinutes * 60L * 1000L; |
| | | TOKEN_CACHE.put(token,new TokenVo(appId, expireAt)); |
| | | |
| | | Map<String, Object> result = new HashMap<>(); |
| | | result.put("token", token); |
| | | result.put("expireAt", expireAt); |
| | | return R.ok().add(result); |
| | | } |
| | | |
| | | private void authNew(TokenParam param, Object obj, HttpServletRequest request) { |
| | | log.info("{}接口被访问;appSecret:{};请求数据:{}", "open/sensorType/list/auth/v1", param.getAppSecret(), JSON.toJSONString(obj)); |
| | | private void authNew(String appkey, |
| | | Object obj, |
| | | HttpServletRequest request, |
| | | String url) { |
| | | log.info("{}接口被访问;appkey:{};请求数据:{}", url, appkey, JSON.toJSONString(obj)); |
| | | request.setAttribute("cache", obj); |
| | | if (!auth) { |
| | | return; |
| | | } |
| | | if (Cools.isEmpty(param.getAppId()) || Cools.isEmpty(param.getAppSecret())) { |
| | | throw new CoolException("认证失败,请确认appId和appSecret无误!"); |
| | | String authorization = request.getHeader("Authorization"); |
| | | if (Cools.isEmpty(authorization)) { |
| | | authorization = request.getHeader("authorization"); |
| | | } |
| | | if (!param.getAppId().contains("HLWMS")){ |
| | | throw new CoolException("认证失败,请确认appId无误!"); |
| | | if (!Cools.isEmpty(authorization)) { |
| | | String val = authorization.trim(); |
| | | if (val.toLowerCase().startsWith("bearer ")) { |
| | | int idx = val.indexOf(' '); |
| | | authorization = idx > -1 ? val.substring(idx + 1).trim() : ""; |
| | | }else { |
| | | authorization = val; |
| | | } |
| | | } |
| | | if (!APP_KEY_LIST.contains(param.getAppSecret())) { |
| | | throw new CoolException("认证失败,请确认appSecret无误!"); |
| | | if (!Cools.isEmpty(authorization)) { |
| | | if (validToken(authorization)){ |
| | | return; |
| | | } |
| | | throw new CoolException("认证失败,请确认Authorization无误!"); |
| | | } |
| | | throw new CoolException("认证失败,请确认Authorization无误!"); |
| | | } |
| | | |
| | | public static boolean validToken(String authorization){ |
| | | if (Cools.isEmpty(authorization)) { |
| | | return false; |
| | | } |
| | | TokenVo tokenInfo = TOKEN_CACHE.get(authorization); |
| | | if (tokenInfo == null) { |
| | | return false; |
| | | } |
| | | if (System.currentTimeMillis() > tokenInfo.getValidTime()) { |
| | | TOKEN_CACHE.remove(authorization); |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return |
| | | */ |
| | | @PostMapping("/erp/mat/sync") |
| | | public synchronized R syncMatInfoV2(@RequestHeader(required = false) String appkey, |
| | | public synchronized R syncMatInfoV2(@RequestHeader(required = false) String appKey, |
| | | @RequestBody(required = false) List<MatSyncParam.MatParam> param, |
| | | HttpServletRequest request){ |
| | | if (Cools.isEmpty(param)){ |
| | | authNew(appKey, param, request, "物料基础信息同步:/erp/mat/sync"); |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | MatSyncParam matSyncParam = new MatSyncParam(); |
| | | List<MatSyncParam.MatParam> objects = new ArrayList<>(); |
| | | objects = param; |
| | | matSyncParam.matDetails = objects; |
| | | |
| | | openService.syncMat(matSyncParam); |
| | | return R.ok(); |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | @PostMapping("/erp/order/add") |
| | | public synchronized R addOrder(@RequestBody OpenOrderParam param){ |
| | | public synchronized R addOrder(@RequestHeader(required = false) String appKey, |
| | | @RequestBody OpenOrderParam param, |
| | | HttpServletRequest request){ |
| | | authNew(appKey, param, request, "入/出库通知单下发:/erp/order/add"); |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | @PostMapping("/erp/inventory/details") |
| | | public synchronized R queryInventoryDetails(@RequestBody OpenInventoryParam param){ |
| | | if (Cools.isEmpty(param)){ |
| | | return R.parse(BaseRes.PARAM); |
| | | public synchronized Result inventory(@RequestHeader(required = false) String appKey, |
| | | @RequestBody JSONObject param, |
| | | HttpServletRequest request){ |
| | | authNew(appKey, param, request, "库存明细查询:/erp/inventory/details"); |
| | | try { |
| | | String wareHouseId = param == null ? null : param.getString("wareHouseId"); |
| | | String locId = param == null ? null : param.getString("locId"); |
| | | String matNr = param == null ? null : param.getString("matNr"); |
| | | String orderNo = param == null ? null : param.getString("orderNo"); |
| | | String batch = param == null ? null : param.getString("batch"); |
| | | return new Result(200, "操作成功", locDetlMapper.inventory(wareHouseId, locId, matNr, orderNo, batch)); |
| | | }catch (Exception e){ |
| | | return new Result(500, e.getMessage(), null); |
| | | } |
| | | OpenInventoryVo openInventoryVo = openService.queryInventoryDetails(param); |
| | | return R.ok(openInventoryVo); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return |
| | | */ |
| | | @PostMapping("/erp/inventory/summary") |
| | | public synchronized R queryInventorySummary(@RequestBody OpenSummaryParam param){ |
| | | if (Cools.isEmpty(param)){ |
| | | return R.parse(BaseRes.PARAM); |
| | | public synchronized Result invSummary(@RequestHeader(required = false) String appKey, |
| | | @RequestBody JSONObject param, |
| | | HttpServletRequest request){ |
| | | authNew(appKey, param, request, "库存汇总查询:/erp/inventory/summary"); |
| | | try { |
| | | String wareHouseId = param == null ? null : param.getString("wareHouseId"); |
| | | String matNr = param == null ? null : param.getString("matNr"); |
| | | 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.invSummary(wareHouseId, matNrs)); |
| | | }catch (Exception e){ |
| | | return new Result(500, e.getMessage(), null); |
| | | } |
| | | OpenSummaryVo openSummaryVo = openService.queryInventorySummary(param); |
| | | return R.ok(openSummaryVo); |
| | | } |
| | | } |
| | |
| | | * 客户编号 |
| | | */ |
| | | @ApiModelProperty(value= "客户编号") |
| | | private String cstmr; |
| | | private Long cstmr; |
| | | |
| | | /** |
| | | * 客户 |
| | |
| | | @TableField("temp3") |
| | | private String temp3; |
| | | |
| | | /** |
| | | * 状态 1: 进行中 0: 初始 2:已完成 |
| | | */ |
| | | @ApiModelProperty(value= "入出库类型(0:未知,1:入库,2:出库)") |
| | | @TableField("pakin_pakout_status") |
| | | private Integer pakinPakoutStatus; |
| | | |
| | | @ApiModelProperty(value = "订单类型 (1:出库单 2:入库单 3:调拨单)") |
| | | @TableField("order_type") |
| | | private Long orderType; |
| | | |
| | | public Order() {} |
| | | |
| | | public Order(String uuid,String orderNo,String orderTime,Long docType,Long itemId,String itemName,Long allotItemId,String defNumber,String number,String cstmr,String cstmrName,String tel,String operMemb,Double totalFee,Double discount,Double discountFee,Double otherFee,Double actFee,Integer payType,String salesman,Integer accountDay,Integer postFeeType,Double postFee,Date payTime,Date sendTime,String shipName,String shipCode,Long settle,Integer status,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo,Integer operateType) { |
| | | public Order(String uuid,String orderNo,String orderTime,Long docType,Long itemId,String itemName,Long allotItemId,String defNumber,String number,Long cstmr,String cstmrName,String tel,String operMemb,Double totalFee,Double discount,Double discountFee,Double otherFee,Double actFee,Integer payType,String salesman,Integer accountDay,Integer postFeeType,Double postFee,Date payTime,Date sendTime,String shipName,String shipCode,Long settle,Integer status,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo,Integer pakinPakoutStatus, Long orderType) { |
| | | this.uuid = uuid; |
| | | this.orderNo = orderNo; |
| | | this.orderTime = orderTime; |
| | |
| | | this.updateBy = updateBy; |
| | | this.updateTime = updateTime; |
| | | this.memo = memo; |
| | | this.operateType = operateType; |
| | | this.pakinPakoutStatus = pakinPakoutStatus; |
| | | this.orderType = orderType; |
| | | } |
| | | |
| | | public Order(String uuid,String orderNo,String orderTime,Long docType,Long itemId,String itemName,Long allotItemId,String defNumber,String number,String cstmr,String cstmrName,String tel,String operMemb,Double totalFee,Double discount,Double discountFee,Double otherFee,Double actFee,Integer payType,String salesman,Integer accountDay,Integer postFeeType,Double postFee,Date payTime,Date sendTime,String shipName,String shipCode,Long settle,Integer status,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) { |
| | | public Order(String uuid,String orderNo,String orderTime,Long docType,Long itemId,String itemName,Long allotItemId,String defNumber,String number,Long cstmr,String cstmrName,String tel,String operMemb,Double totalFee,Double discount,Double discountFee,Double otherFee,Double actFee,Integer payType,String salesman,Integer accountDay,Integer postFeeType,Double postFee,Date payTime,Date sendTime,String shipName,String shipCode,Long settle,Integer status,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) { |
| | | this.uuid = uuid; |
| | | this.orderNo = orderNo; |
| | | this.orderTime = orderTime; |
| New file |
| | |
| | | package com.zy.asrs.entity.emums; |
| | | |
| | | import com.core.exception.CoolException; |
| | | |
| | | public enum WKType { |
| | | MAT_INFO(1,"物料档案"), |
| | | SUPPLIER(2,"供应商"), |
| | | IN_WK(3,"收料单"), |
| | | PRO_IN_WK_UP(4,"采购入库单"), |
| | | PRO_OUT_MAT_WK(5,"采购退料单"), |
| | | PUR_OUT_WK_UP(6,"采购退货单"), |
| | | SALES_OUT_WK(7,"销售出库单"), |
| | | SALES_OUT_WK_UP(8,"销售出库单"), |
| | | SALES_PUR_OUT_WK(9,"销售退货通知单"), |
| | | PRO_MAT_PICK_WK(10,"生产领料单"), |
| | | PRO_MAT_PICK_WK_UP(11,"生产领料单"), |
| | | PRO_MAT_RETURN_WK(12,"生产退料单"), |
| | | PRO_MAT_RETURN_WK_UP(13,"生产退料单"), |
| | | PRO_SUP_ARY_MAT_WK(14,"生产补料单"), |
| | | PRO_SUP_ARY_MAT_UP_WK(15,"生产补料单"), |
| | | PRO_REP_WK(16,"生产汇报单"), |
| | | PRO_WAR_WK(17,"产品入库单"), |
| | | OTHER_WAR_WK(18,"其他入库单"), |
| | | OTHER_OUT_WK(19,"其他出库单"), |
| | | CHECK_WK_WK(20,"检验单"); |
| | | |
| | | public long wkType; |
| | | public String desc; |
| | | |
| | | |
| | | WKType(long wkType, String desc) { |
| | | this.wkType = wkType; |
| | | this.desc = desc; |
| | | } |
| | | |
| | | public static WKType query(String desc){ |
| | | for(WKType wkType1 : WKType.values()){ |
| | | if(wkType1.desc.equals(desc)){ |
| | | return wkType1; |
| | | } |
| | | } |
| | | throw new CoolException("WKType Error"); |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 有效时间 单位:分钟 |
| | | */ |
| | | private Integer validTime; |
| | | private long validTime; |
| | | |
| | | public TokenVo(String token, long validTime) { |
| | | this.token = token; |
| | | this.validTime = validTime; |
| | | } |
| | | } |
| | |
| | | import org.apache.ibatis.annotations.Update; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | |
| | | |
| | | long asrsAndErpCount(Map<String, Object> condition); |
| | | |
| | | List<LocDetl> queryInventoryDetails(String locId, String matNr, String orderNo, String planNo, String batch); |
| | | List<Map<String, Object>> inventory(@Param("wareHouseId") String wareHouseId,@Param("locId") String locId,@Param("matNr") String matNr,@Param("orderNo") String orderNo,@Param("batch") String batch); |
| | | |
| | | Double queryInventorySummary(String wareHouseId, String s); |
| | | List<Map<String, Object>> invSummary(@Param("wareHouseId") String wareHouseId,@Param("matNrs") Collection<String> matNrs); |
| | | } |
| | |
| | | void syncMat(MatSyncParam param); |
| | | |
| | | void orderCreate(OpenOrderParam param); |
| | | |
| | | OpenInventoryVo queryInventoryDetails(OpenInventoryParam param); |
| | | |
| | | OpenSummaryVo queryInventorySummary(OpenSummaryParam param); |
| | | } |
| | |
| | | import com.core.common.*; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.emums.WKType; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.entity.result.OpenInventoryVo; |
| | | import com.zy.asrs.entity.result.OpenOrderCompeteResult; |
| | |
| | | String.valueOf(snowflakeIdWorker.nextId()), // 编号[非空] |
| | | param.getOrderNo(), // 订单编码[非空] |
| | | DateUtils.convert(now), //单据日期 |
| | | param.getOrderType(), //订单类型 |
| | | WKType.query(param.getWkType()).wkType, //单据类型 |
| | | null, //项目编号 |
| | | null, //项目名称 客户PO号 |
| | | null, //调拨项目编号 |
| | |
| | | 9527L, //修改人员 |
| | | now, //修改时间 |
| | | param.getStationId(), //入/出库接驳站点 |
| | | param.getOperateType() // 操作类型 1.新增 2.修改 3.取消 |
| | | param.getOperateType(), // 操作类型 1.新增 2.修改 3.取消 |
| | | param.getOrderType() // 订单类型 1 出库单 2 入库单 3 调拨单 |
| | | ); |
| | | if (!orderService.insert(order)){ |
| | | throw new CoolException("保存订单主档失败,请联系管理员!"+order); |
| | |
| | | throw new CoolException("保存订单明细失败,请联系管理员!"+orderDetl); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public OpenInventoryVo queryInventoryDetails(OpenInventoryParam param) { |
| | | List<LocDetl> locDetlList = locDetlService.queryInventoryDetails(param.getLocId(), param.getMatNr(), param.getOrderNo(), param.getPlanNo(), param.getBatch()); |
| | | if (Cools.isEmpty(locDetlList)){ |
| | | return new OpenInventoryVo(); |
| | | } |
| | | return new OpenInventoryVo(locDetlList); |
| | | } |
| | | |
| | | @Override |
| | | public OpenSummaryVo queryInventorySummary(OpenSummaryParam param) { |
| | | String matNr = param.getMatNr(); |
| | | String[] split = matNr.split(","); |
| | | List<OpenSummaryVo.OpenSummary> openSummaryList = new ArrayList<>(); |
| | | for (String s : split) { |
| | | OpenSummaryVo.OpenSummary openSummary = new OpenSummaryVo.OpenSummary(); |
| | | Double summary = locDetlService.queryInventorySummary(param.getWareHouseId(), s); |
| | | openSummary.setWareHouseId(param.getWareHouseId()); // 仓库编码 |
| | | openSummary.setMatNr(s); // 物料编码 |
| | | openSummary.setAnfme(summary); // 数量 |
| | | openSummaryList.add(openSummary); |
| | | } |
| | | return new OpenSummaryVo(openSummaryList); |
| | | } |
| | | } |
| | |
| | | package com.zy.asrs.task; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.DocType; |
| | | import com.zy.asrs.entity.Order; |
| | | import com.zy.asrs.entity.OrderDetl; |
| | | import com.zy.asrs.service.ApiLogService; |
| | | import com.zy.asrs.service.DocTypeService; |
| | | import com.zy.asrs.service.OrderDetlService; |
| | | import com.zy.asrs.service.OrderService; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import com.zy.asrs.task.handler.OrderSyncHandler; |
| | | import com.zy.common.entity.Parameter; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * Created by vincent on 2020/7/7 |
| | |
| | | private OrderService orderService; |
| | | @Autowired |
| | | private ApiLogService apiLogService; |
| | | @Autowired |
| | | private DocTypeService docTypeService; |
| | | @Autowired |
| | | private OrderDetlService orderDetlService; |
| | | |
| | | @Scheduled(cron = "0 0 1 * * ? ") |
| | | public void clearApiLog(){ |
| | |
| | | } |
| | | } |
| | | |
| | | @Scheduled(cron = "0/5 * * * * ? ") |
| | | // @Scheduled(cron = "0/5 * * * * ? ") |
| | | @Async("orderThreadPool") |
| | | public void completeAndReport(){ |
| | | public void completeAndReport() { |
| | | String erpReport = Parameter.get().getErpReport(); |
| | | if (!Cools.isEmpty(erpReport) && erpReport.equals("true")) { |
| | | List<Order> orders = orderService.selectComplete(); |
| | | for (Order order : orders) { |
| | | ReturnT<String> result = orderSyncHandler.start(order); |
| | | ReturnT<String> result = reportToMesOrderReport(order); |
| | | if (!result.isSuccess()) { |
| | | log.error("单据[orderNo={}]上报erp失败", order.getOrderNo()); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | private ReturnT<String> reportToMesOrderReport(Order order) { |
| | | if (order == null) { |
| | | return new ReturnT<>(ReturnT.SUCCESS_CODE, "SUCCESS"); |
| | | } |
| | | |
| | | DocType docType = docTypeService.selectById(order.getDocType()); |
| | | if (docType == null) { |
| | | return new ReturnT<>(ReturnT.SUCCESS_CODE, "SUCCESS"); |
| | | } |
| | | |
| | | String wkType = docType.getDocName(); |
| | | List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order.getId()); |
| | | |
| | | String uri = "localhost:9090"; |
| | | String path = "/erp/open/asrs/MES/orderReport"; |
| | | String url = "http://" + uri + path; |
| | | |
| | | Map<String, Object> payload = new HashMap<>(); |
| | | payload.put("orderNo", order.getOrderNo()); |
| | | // payload.put("warehouseId", "WH01"); |
| | | payload.put("wkType", wkType); |
| | | payload.put("orderDetls", orderDetls); |
| | | String requestJson = JSON.toJSONString(payload); |
| | | |
| | | String response = ""; |
| | | boolean success = false; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(uri) |
| | | .setPath(path) |
| | | .setJson(requestJson) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject json = JSON.parseObject(response); |
| | | Integer code = json == null ? null : json.getInteger("code"); |
| | | success = code != null && code == 200; |
| | | if (!success) { |
| | | String msg = json == null ? null : json.getString("msg"); |
| | | throw new CoolException(!Cools.isEmpty(msg) ? msg : "接口返回失败:" + response); |
| | | } |
| | | if (!orderService.updateSettle(order.getId(), 6L, null)) { |
| | | throw new CoolException("更新单据状态失败"); |
| | | } |
| | | return new ReturnT<>(ReturnT.SUCCESS_CODE, "SUCCESS"); |
| | | } catch (IOException e) { |
| | | return new ReturnT<>(ReturnT.FAIL_CODE, e.getMessage()); |
| | | } catch (Exception e) { |
| | | return new ReturnT<>(ReturnT.FAIL_CODE, e.getMessage()); |
| | | } finally { |
| | | try { |
| | | apiLogService.save( |
| | | "MES订单上报", |
| | | url, |
| | | null, |
| | | "127.0.0.1", |
| | | requestJson, |
| | | response, |
| | | success |
| | | ); |
| | | } catch (Exception e) { |
| | | log.error("", e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="queryInventoryDetails" parameterType="map" resultMap="BaseResultMap"> |
| | | SELECT * |
| | | FROM asr_loc_detl |
| | | <where> |
| | | <if test="locId != null and locId != ''"> |
| | | AND loc_id = #{locId} |
| | | </if> |
| | | <if test="matNr != null and matNr != ''"> |
| | | AND mat_nr = #{matNr} |
| | | </if> |
| | | <if test="orderNo != null and orderNo != ''"> |
| | | AND order_no = #{orderNo} |
| | | </if> |
| | | <if test="planNo != null and planNo != ''"> |
| | | AND plan_no = #{planNo} |
| | | </if> |
| | | <if test="batch != null and batch != ''"> |
| | | AND batch = #{batch} |
| | | </if> |
| | | </where> |
| | | <select id="inventory" resultType="java.util.Map"> |
| | | select |
| | | ld.loc_no as locId, |
| | | ld.zpallet as palletId, |
| | | ld.matnr as matNr, |
| | | coalesce(m.maktx, ld.maktx) as makTx, |
| | | cast(round(ld.anfme, 4) as decimal(18, 4)) as anfme, |
| | | coalesce(m.unit, ld.unit) as unit, |
| | | 1 as status, |
| | | isnull(ld.batch, '') as batch |
| | | from asr_loc_detl as ld |
| | | left join asr_loc_mast as lm on ld.loc_no = lm.loc_no |
| | | left join man_mat as m on ld.matnr = m.matnr |
| | | where 1 = 1 |
| | | and lm.loc_sts = 'F' |
| | | <if test="locId != null and locId != ''"> |
| | | and ld.loc_no = #{locId} |
| | | </if> |
| | | <if test="matNr != null and matNr != ''"> |
| | | and ld.matnr = #{matNr} |
| | | </if> |
| | | <if test="orderNo != null and orderNo != ''"> |
| | | and ld.order_no = #{orderNo} |
| | | </if> |
| | | <if test="batch != null and batch != ''"> |
| | | and ld.batch = #{batch} |
| | | </if> |
| | | order by ld.loc_no, ld.zpallet, ld.matnr |
| | | </select> |
| | | |
| | | <select id="queryInventorySummary" resultType="java.lang.Double"> |
| | | SELECT SUM(anfme) FROM asr_loc_detl WHERE matnr = #{s} |
| | | <select id="invSummary" resultType="java.util.Map"> |
| | | select |
| | | ld.matnr as matNr, |
| | | coalesce(max(m.maktx), max(ld.maktx)) as matTx, |
| | | cast(round(sum(ld.anfme), 4) as decimal(18, 4)) as anfme, |
| | | coalesce(max(m.unit), max(ld.unit)) as unit |
| | | from asr_loc_detl as ld |
| | | left join asr_loc_mast as lm on ld.loc_no = lm.loc_no |
| | | left join man_mat as m on ld.matnr = m.matnr |
| | | where 1 = 1 |
| | | and lm.loc_sts = 'F' |
| | | <if test="matNrs != null and matNrs.size > 0"> |
| | | and ld.matnr in |
| | | <foreach item="item" collection="matNrs" separator="," open="(" close=")"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | group by ld.matnr |
| | | order by ld.matnr |
| | | </select> |
| | | </mapper> |