优化
This commit is contained in:
@@ -1,24 +1,36 @@
|
||||
package com.ruoyi.api.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.ruoyi.api.domain.ErpProduct;
|
||||
import com.ruoyi.api.domain.ReMaterialParam;
|
||||
import com.ruoyi.api.domain.RequestEnter;
|
||||
import com.ruoyi.api.domain.WmsJobRequest;
|
||||
import com.ruoyi.api.service.IToWmsService;
|
||||
import com.ruoyi.bas.BasCustomer.domain.BasCustomer;
|
||||
import com.ruoyi.bas.BasCustomer.service.IBasCustomerService;
|
||||
import com.ruoyi.bas.BasProduct.domain.BasProduct;
|
||||
import com.ruoyi.bas.BasProduct.service.IBasProductService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.uuid.UUID;
|
||||
import com.ruoyi.log.domain.RequestLog;
|
||||
import com.ruoyi.log.service.IRequestLogService;
|
||||
import com.ruoyi.out.outStockout.domain.OutStockout;
|
||||
import com.ruoyi.out.outStockout.domain.OutStockoutVo;
|
||||
import com.ruoyi.out.outStockout.service.IOutStockoutService;
|
||||
import com.ruoyi.out.outStockoutDetail.domain.OutStockoutDetail;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -36,6 +48,8 @@ public class ToWmsApiController {
|
||||
private IOutStockoutService outStockoutService;
|
||||
@Autowired
|
||||
private IBasProductService basProductService;
|
||||
@Autowired
|
||||
private IBasCustomerService basCustomerService;
|
||||
|
||||
/**
|
||||
* 入库请求生成作业
|
||||
@@ -117,16 +131,66 @@ public class ToWmsApiController {
|
||||
/**
|
||||
* 出库单据保存
|
||||
*
|
||||
* @param outStockoutVo
|
||||
* @param json
|
||||
* @return
|
||||
*/
|
||||
@Log(title = "出库主单保存", businessType = BusinessType.OTHER)
|
||||
//@Log(title = "出库主单保存", businessType = BusinessType.OTHER)
|
||||
@PostMapping("/saveOutBill")
|
||||
@ResponseBody
|
||||
public AjaxResult saveBill(@RequestBody OutStockoutVo outStockoutVo) {
|
||||
String stockOutId = outStockoutService.saveBill(outStockoutVo);
|
||||
public AjaxResult saveBill(@RequestBody String json) {
|
||||
JSONObject jsonObject = JSONUtil.parseObj(json);
|
||||
Object codeObj = jsonObject.get("std_data");
|
||||
JSONObject obj = JSONUtil.parseObj(codeObj.toString());
|
||||
String doc = JSONUtil.parseObj(obj.get("parameter").toString()).get("data").toString();
|
||||
JSONObject param = JSONUtil.parseObj(doc);
|
||||
OutStockoutVo outStockoutVo = new OutStockoutVo();
|
||||
OutStockout outStockout = new OutStockout();
|
||||
List<OutStockoutDetail> list = new ArrayList<>();
|
||||
outStockout.setStockoutId(param.get("doc_no").toString());
|
||||
List<OutStockout> outStockout1 = outStockoutService.selectOutStockoutList(outStockout);
|
||||
if(outStockout1.size()>0){
|
||||
return AjaxResult.error("单据已推送!");
|
||||
}
|
||||
outStockout.setStockoutGuid(UUID.randomUUID().toString());
|
||||
outStockout.setOutType("1");
|
||||
outStockout.setCreateDate(DateUtil.formatDateTime(new Date()));
|
||||
outStockout.setCreateManId(param.get("create_user_name").toString());
|
||||
outStockout.setCustomerNo(param.get("customer_no").toString());
|
||||
BasCustomer customer = basCustomerService.selectBasCustomerByNo(param.get("customer_no").toString());
|
||||
if(customer == null){
|
||||
BasCustomer basCustomer = new BasCustomer();
|
||||
basCustomer.setId(UUID.randomUUID().toString());
|
||||
basCustomer.setCustomerNo(param.get("customer_no").toString());
|
||||
basCustomer.setCustomerName(param.get("customer_name").toString());
|
||||
basCustomer.setUseable("1");
|
||||
basCustomerService.insertBasCustomer(basCustomer);
|
||||
}
|
||||
outStockout.setStatus("1");
|
||||
outStockout.setStockoutSource("1");
|
||||
outStockout.setWarehouseId("01");
|
||||
JSONArray erpList = JSONUtil.parseArray(param.get("sales_issue_detail").toString());
|
||||
if(erpList.size()>0){
|
||||
for(int i=0;i<erpList.size();i++){
|
||||
JSONObject msg = (JSONObject) erpList.get(i);
|
||||
OutStockoutDetail detail = new OutStockoutDetail();
|
||||
detail.setStockoutDetailId(msg.get("sales_delivery_no").toString());
|
||||
detail.setStockoutGuid(outStockout.getStockoutGuid());
|
||||
detail.setStockoutId(outStockout.getStockoutId());
|
||||
detail.setProductId(msg.get("item_no").toString());
|
||||
detail.setProductName(msg.get("item_name").toString());
|
||||
detail.setSpec(msg.get("item_spec").toString());
|
||||
detail.setQuantity(new BigDecimal(msg.get("business_qty").toString()));
|
||||
detail.setAllotQuantity(BigDecimal.ZERO);
|
||||
detail.setAssignNum(BigDecimal.ZERO);
|
||||
detail.setRemark(msg.get("udf021").toString());
|
||||
list.add(detail);
|
||||
}
|
||||
}
|
||||
outStockoutVo.setOutStockout(outStockout);
|
||||
outStockoutVo.setDetailList(list);
|
||||
String stockOutId = outStockoutService.saveBillErp(outStockoutVo);
|
||||
AjaxResult ajaxResult = AjaxResult.success(stockOutId);
|
||||
RequestLog requestLog = requestLogService.getRequestLog(JSONUtil.toJsonStr(outStockoutVo), "出库单据保存", ajaxResult);
|
||||
RequestLog requestLog = requestLogService.getRequestLog(json, "出库单据保存", ajaxResult);
|
||||
requestLogService.insertRequestLog(requestLog);
|
||||
return ajaxResult;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user