| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.common.openapi.entity.HostKey; |
| | | import com.zy.asrs.common.openapi.entity.dto.OrderListDto; |
| | | import com.zy.asrs.common.openapi.entity.param.CreateMatParam; |
| | | import com.zy.asrs.common.openapi.entity.param.GenerateOrderPakInParam; |
| | | import com.zy.asrs.common.openapi.entity.param.GenerateOrderPakOutParam; |
| | | import com.zy.asrs.common.openapi.entity.param.OrderListParam; |
| | | import com.zy.asrs.common.openapi.entity.param.*; |
| | | import com.zy.asrs.common.openapi.service.ApiService; |
| | | import com.zy.asrs.common.openapi.service.HostKeyService; |
| | | import com.zy.asrs.common.sys.entity.OperateLog; |
| | | import com.zy.asrs.common.sys.service.OperateLogService; |
| | | import com.zy.asrs.common.utils.Utils; |
| | | import com.zy.asrs.common.web.BaseController; |
| | | import com.zy.asrs.common.wms.entity.DocType; |
| | | import com.zy.asrs.common.wms.entity.OrderSettle; |
| | |
| | | import com.zy.asrs.framework.common.BaseRes; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.R; |
| | | import com.zy.asrs.framework.common.SpringUtils; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import com.zy.asrs.openapi.param.MatParam; |
| | | import com.zy.asrs.openapi.param.OrderParam; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.codec.digest.DigestUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | 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.util.Map; |
| | | |
| | |
| | | private HostKeyService hostKeyService; |
| | | @Autowired |
| | | private ApiService apiService; |
| | | |
| | | @PostMapping("/test") |
| | | public R test() { |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 生成入库订单 |
| | |
| | | return hostKey; |
| | | } |
| | | |
| | | @PostMapping("order/execute/auth/v1") |
| | | public R wms1(@RequestBody Map<String, Object> map) { |
| | | try { |
| | | // System.out.println(map.toString()); |
| | | log.info("order/execute/auth/v1:" + JSON.toJSONString(map)); |
| | | OrderParam orderParam = JSON.parseObject(JSON.toJSONString(map), OrderParam.class); |
| | | |
| | | OperateLogService operateLogService = SpringUtils.getBean(OperateLogService.class); |
| | | //记录上报数据 |
| | | OperateLog operateLog = new OperateLog(); |
| | | operateLog.setAction("ERP推送订单"); |
| | | operateLog.setRequest(orderParam.toString()); |
| | | operateLog.setResponse(""); |
| | | operateLog.setCreateTime(new Date()); |
| | | operateLog.setSystem("WMS"); |
| | | operateLog.setUserId(9527L); |
| | | operateLog.setIp("127.0.0.1"); |
| | | operateLogService.save(operateLog); |
| | | |
| | | List<DocType> list = apiService.getOrderType(); |
| | | DocType type = null; |
| | | for (DocType docType : list) { |
| | | if (docType.getDocName().equals(orderParam.getOrderType())) { |
| | | type = docType; |
| | | break; |
| | | } |
| | | } |
| | | if (type == null) { |
| | | return R.error("单据类型不存在"); |
| | | } |
| | | |
| | | ArrayList<GenerateOrderMatParam> mats = new ArrayList<>(); |
| | | String matnr=null; |
| | | for (MatParam matParam : orderParam.getList()) { |
| | | GenerateOrderMatParam mat = new GenerateOrderMatParam(); |
| | | mat.setMatnr(matParam.getMatnr()); |
| | | mat.setBatch(matParam.getBatch()); |
| | | mat.setAnfme(matParam.getCount()); |
| | | mat.setUnit(matParam.getUnit()); |
| | | mat.setWarehouse(matParam.getWarehouse()); |
| | | mat.setOrigin(matParam.getOrigin()); |
| | | mat.setOriginNo(matParam.getOriginNo()); |
| | | if(Cools.isEmpty(mats)){ |
| | | mats.add(mat); |
| | | }else{ |
| | | boolean boo=true; |
| | | for (GenerateOrderMatParam m:mats |
| | | ) { |
| | | if(m.getMatnr().equals(matParam.getMatnr())){ |
| | | m.setAnfme(m.getAnfme()+mat.getAnfme()); |
| | | boo=false; |
| | | break; |
| | | } |
| | | } |
| | | if(boo){ |
| | | mats.add(mat); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (orderParam.getInOut() == 1) { |
| | | //入库 |
| | | GenerateOrderPakInParam param = new GenerateOrderPakInParam(); |
| | | param.setHostId(1L); |
| | | param.setOrderType(type.getDocId().intValue()); |
| | | param.setOrderNo(orderParam.getOrderNo()); |
| | | param.setMats(mats); |
| | | apiService.generateOrderPakIn(param); |
| | | } else if (orderParam.getInOut() == 2) { |
| | | //出库 |
| | | GenerateOrderPakOutParam param = new GenerateOrderPakOutParam(); |
| | | param.setHostId(1L); |
| | | param.setOrderType(type.getDocId().intValue()); |
| | | param.setOrderNo(orderParam.getOrderNo()); |
| | | param.setMats(mats); |
| | | apiService.generateOrderPakOut(param); |
| | | } else { |
| | | //其他 |
| | | return R.error("出入库类型错误"); |
| | | } |
| | | |
| | | return R.ok(); |
| | | } catch (Exception e) { |
| | | return R.error(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | } |