| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.core.annotations.AppAuth; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.entity.DocType; |
| | | import com.zy.asrs.entity.param.CheckParam; |
| | | import com.zy.asrs.entity.param.MatSyncParam; |
| | | import com.zy.asrs.entity.param.OrderProdSyncParam; |
| | | import com.zy.asrs.entity.param.OrderSyncParam; |
| | | import com.zy.asrs.service.DocTypeService; |
| | | import com.zy.asrs.service.OpenService; |
| | | import com.zy.common.web.BaseController; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | }}; |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private OpenService openService; |
| | | |
| | | @Autowired |
| | | private DocTypeService docTypeService; |
| | | |
| | | /** |
| | | * 库存统计 |
| | | */ |
| | | @RequestMapping("/stock/default/v1") |
| | | public R queryStock(@RequestHeader(required = false) String appkey, |
| | | HttpServletRequest request) { |
| | | public R queryStock(@RequestHeader(required = false) String appkey, HttpServletRequest request) { |
| | | auth(appkey, null, request); |
| | | return R.ok().add(openService.queryStock()); |
| | | } |
| | |
| | | */ |
| | | @PostMapping("/mat/v1") |
| | | @AppAuth(memo = "物料同步接口") |
| | | public synchronized R syncMatInfoErp(@RequestHeader(required = false) String appkey, |
| | | @RequestBody(required = false) MatSyncParam param, |
| | | HttpServletRequest request){ |
| | | public synchronized R syncMatInfoErp(@RequestHeader(required = false) String appkey, @RequestBody(required = false) MatSyncParam param, HttpServletRequest request) { |
| | | auth(appkey, param, request); |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | |
| | | return R.ok("更新成功"); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | private void auth(String appkey, Object obj, HttpServletRequest request) { |
| | |
| | | |
| | | @PostMapping("/order/pak/default/v1") |
| | | @AppAuth(memo = "生成退货补货单据") |
| | | public synchronized R orderAccept(@RequestHeader(required = false) String appkey, |
| | | @RequestBody(required = true) OrderSyncParam param, |
| | | HttpServletRequest request){ |
| | | public synchronized R orderAccept(@RequestHeader(required = false) String appkey, @RequestBody(required = true) OrderSyncParam param, HttpServletRequest request) { |
| | | log.info("生成退货补货单据,{}",JSON.toJSONString(param)); |
| | | auth(appkey, param, request); |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | |
| | | String docName = param.get操作单据(); |
| | | boolean pakin = param.getPakin() == 1 ? true : false; |
| | | |
| | | openService.syncOrder(param,pakin,docName); |
| | | DocType type = getType(param.get操作单据(), param.getChildren().get(0).getIQuantity()); |
| | | if (!Cools.isEmpty(type)) { |
| | | if (type.getPakin() == 1) { |
| | | openService.syncOrder(param, true, type.getDocName()); |
| | | } else { |
| | | openService.syncOrder(param, false, type.getDocName()); |
| | | } |
| | | } else { |
| | | return R.ok("单据接受失败,不是约定的单据l类型"); |
| | | } |
| | | // String docName = param.get操作单据(); |
| | | // boolean pakin = param.getPakin() == 1 ? true : false; |
| | | // |
| | | // openService.syncOrder(param, pakin, docName); |
| | | |
| | | return R.ok("单据接受成功"); |
| | | |
| | |
| | | |
| | | @PostMapping("/order/pakin/default/v1") |
| | | @AppAuth(memo = "生成入库单据") |
| | | public synchronized R orderPakin(@RequestHeader(required = false) String appkey, |
| | | @RequestBody(required = true) OrderSyncParam param, |
| | | HttpServletRequest request){ |
| | | public synchronized R orderPakin(@RequestHeader(required = false) String appkey, @RequestBody(required = true) OrderSyncParam param, HttpServletRequest request) { |
| | | log.info("生成入库单据,{}",JSON.toJSONString(param)); |
| | | auth(appkey, param, request); |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | |
| | | String docName = !Cools.isEmpty(param.getOrderType()) ? param.getOrderType() : param.getChildren().get(0).getIQuantity() > 0 ? "银座采购入库单" : "银座采购退货单"; |
| | | boolean pakin = param.getChildren().get(0).getIQuantity() > 0 ? true : false; |
| | | // String docName = !Cools.isEmpty(param.getOrderType()) ? param.getOrderType() : param.getChildren().get(0).getIQuantity() > 0 ? "银座采购入库单" : "银座采购退货单"; |
| | | // boolean pakin = param.getChildren().get(0).getIQuantity() > 0 ? true : false; |
| | | |
| | | openService.syncOrder(param,pakin,docName); |
| | | |
| | | DocType type = getType(param.get操作单据(), param.getChildren().get(0).getIQuantity()); |
| | | if (!Cools.isEmpty(type)) { |
| | | if (type.getPakin() == 1) { |
| | | openService.syncOrder(param, true, type.getDocName()); |
| | | } else { |
| | | openService.syncOrder(param, false, type.getDocName()); |
| | | } |
| | | } else { |
| | | return R.ok("单据接受失败,不是约定的单据l类型"); |
| | | } |
| | | return R.ok("单据接受成功"); |
| | | |
| | | } |
| | |
| | | */ |
| | | @PostMapping("/check/default/v1") |
| | | @AppAuth(memo = "库存盘点") |
| | | public synchronized R checkLoc(@RequestHeader(required = false) String appkey, |
| | | @RequestBody(required = true) CheckParam param, |
| | | HttpServletRequest request){ |
| | | public synchronized R checkLoc(@RequestHeader(required = false) String appkey, @RequestBody(required = true) CheckParam param, HttpServletRequest request) { |
| | | auth(appkey, param, request); |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | |
| | | @AppAuth(memo = "同步工单单据") |
| | | public synchronized R orderPakout(@RequestHeader(required = false) String appkey, |
| | | //@RequestBody(required = false) HashMap<String,Object> param, |
| | | @RequestBody(required = false) OrderProdSyncParam param, |
| | | HttpServletRequest request){ |
| | | @RequestBody(required = false) OrderProdSyncParam param, HttpServletRequest request) { |
| | | log.info("同步工单单据,{}",JSON.toJSONString(param)); |
| | | auth(appkey, param, request); |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | if(!Cools.eq("生产",param.getCVouchtype())){ |
| | | String docName = param.getIQuantity() > 0 ? "银座委外入库单" : "银座委外入库退货单"; |
| | | boolean pakin = param.getIQuantity() > 0 ? true : false; |
| | | mappingPakInOrderParam(param,pakin,docName); |
| | | |
| | | DocType type = getType(param.get操作单据(), param.getIQuantity()); |
| | | if (!Cools.isEmpty(type)) { |
| | | if (type.getDocName().equals("MO")) { |
| | | mappingPakInOrderParam(param, true, type.getDocName()); |
| | | mappingPakOutOrderParam(param, false, "银座委外材料出库单"); |
| | | } else if (type.getDocName().equals("OM")) { |
| | | mappingPakInOrderParam(param, true, type.getDocName()); |
| | | mappingPakOutOrderParam(param, false, "银座生产材料出库单"); |
| | | } else { |
| | | if (type.getPakin() == 1) { |
| | | mappingPakInOrderParam(param, true, type.getDocName()); |
| | | if(!Cools.isEmpty(param.getChildren())){ |
| | | String docName1 = param.getChildren().get(0).getIQuantity() > 0 ? "银座委外材料出库单" : "银座委外材料退料单"; |
| | | boolean pakin1 = param.getChildren().get(0).getIQuantity() > 0 ? true : false; |
| | | mappingPakOutOrderParam(param,pakin1,docName1); |
| | | mappingPakOutOrderParam(param, false, type.getDocName()); |
| | | } |
| | | } else { |
| | | mappingPakOutOrderParam(param, false, type.getDocName()); |
| | | } |
| | | } |
| | | } else { |
| | | return R.ok("单据接受失败,不是约定的单据l类型"); |
| | | } |
| | | |
| | | }else if(!Cools.isEmpty(param.getChildren())) { |
| | | String docName1 = param.getChildren().get(0).getIQuantity() > 0 ? "银座生产材料出库单" : "银座生产材料退料单"; |
| | | boolean pakin1 = param.getChildren().get(0).getIQuantity() > 0 ? true : false; |
| | | mappingPakOutOrderParam(param,pakin1,docName1); |
| | | } |
| | | // if (!Cools.eq("生产", param.getCVouchtype())) { |
| | | // String docName = param.getIQuantity() > 0 ? "银座委外入库单" : "银座委外入库退货单"; |
| | | // boolean pakin = param.getIQuantity() > 0 ? true : false; |
| | | // mappingPakInOrderParam(param, pakin, docName); |
| | | // |
| | | // if (!Cools.isEmpty(param.getChildren())) { |
| | | // String docName1 = param.getChildren().get(0).getIQuantity() > 0 ? "银座委外材料出库单" : "银座委外材料退料单"; |
| | | // boolean pakin1 = param.getChildren().get(0).getIQuantity() > 0 ? true : false; |
| | | // mappingPakOutOrderParam(param, pakin1, docName1); |
| | | // } |
| | | // |
| | | // } else if (!Cools.isEmpty(param.getChildren())) { |
| | | // String docName1 = param.getChildren().get(0).getIQuantity() > 0 ? "银座生产材料出库单" : "银座生产材料退料单"; |
| | | // boolean pakin1 = param.getChildren().get(0).getIQuantity() > 0 ? true : false; |
| | | // mappingPakOutOrderParam(param, pakin1, docName1); |
| | | // } |
| | | |
| | | return R.ok("单据接受成功"); |
| | | |
| | |
| | | |
| | | @PostMapping("/order/delete/default/v1") |
| | | @AppAuth(memo = "单据删除审核") |
| | | public synchronized R orderDelete(@RequestHeader(required = false) String appkey, |
| | | @RequestBody(required = false) Map<String, Object> param, |
| | | HttpServletRequest request){ |
| | | public synchronized R orderDelete(@RequestHeader(required = false) String appkey, @RequestBody(required = false) Map<String, Object> param, HttpServletRequest request) { |
| | | log.info("单据删除审核,{}",JSON.toJSONString(param)); |
| | | auth(appkey, param, request); |
| | | if (Cools.isEmpty(param)) { |
| | |
| | | //return orderSyncParam; |
| | | } |
| | | |
| | | |
| | | private DocType getType(String type, Double iQuantity) { |
| | | DocType docType = new DocType(); |
| | | switch (type) { |
| | | case "Purchase": |
| | | docType.setDocName("银座采购入库单"); |
| | | docType.setPakin(1); |
| | | break; |
| | | case "MO": |
| | | docType.setDocName("银座生产订单"); |
| | | docType.setPakin(0); |
| | | break; |
| | | case "OM": |
| | | docType.setDocName("银座委外生产订单"); |
| | | docType.setPakin(0); |
| | | break; |
| | | case "采购入库单退货": |
| | | docType.setDocName("银座采购入库单退货单"); |
| | | docType.setPakin(0); |
| | | break; |
| | | case "委外入库单退货": |
| | | docType.setDocName("银座委外入库单退货单"); |
| | | docType.setPakin(1); |
| | | break; |
| | | case "生产材料出库退料": |
| | | docType.setDocName("银座生产材料出库退料单"); |
| | | docType.setPakin(1); |
| | | break; |
| | | case "委外材料出库退料": |
| | | docType.setDocName("银座委外材料出库退料单"); |
| | | docType.setPakin(1); |
| | | break; |
| | | case "生产材料出库补料": |
| | | docType.setDocName("银座生产材料出库补料单"); |
| | | docType.setPakin(0); |
| | | break; |
| | | case "委外材料出库补料": |
| | | docType.setDocName("银座委外材料出库补料单"); |
| | | docType.setPakin(0); |
| | | break; |
| | | case "其他入库单": |
| | | docType.setDocName("银座其他入库单"); |
| | | docType.setPakin(1); |
| | | break; |
| | | case "其他出库单": |
| | | docType.setDocName("银座其他出库单"); |
| | | docType.setPakin(0); |
| | | break; |
| | | default: |
| | | docType = docTypeService.selectOrAdd(type, iQuantity > 0); |
| | | } |
| | | return docType; |
| | | } |
| | | } |