2025-03-26 09:06:23 +08:00
|
|
|
|
package com.cim.idm.controller;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
2025-03-26 17:40:01 +08:00
|
|
|
|
import com.cim.idm.constants.ReceiveTypeEnums;
|
2025-03-26 09:06:23 +08:00
|
|
|
|
import com.cim.idm.model.DeliveryDto;
|
2025-03-27 16:41:05 +08:00
|
|
|
|
import com.cim.idm.model.MaterialReceiveRequest;
|
2025-03-26 10:32:09 +08:00
|
|
|
|
import com.cim.idm.model.PageDto;
|
2025-03-26 09:06:23 +08:00
|
|
|
|
import com.cim.idm.service.IDeliveryService;
|
|
|
|
|
import com.cim.idm.utils.AjaxResult;
|
|
|
|
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
2025-03-26 17:40:01 +08:00
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
2025-03-27 16:41:05 +08:00
|
|
|
|
import java.util.stream.Collectors;
|
2025-03-26 09:06:23 +08:00
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/delivery")
|
|
|
|
|
@EnableAutoConfiguration
|
|
|
|
|
public class DeliveryController {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private IDeliveryService deliveryService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 创建入库单
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping(value = "/create")
|
|
|
|
|
public AjaxResult createDelivery(@RequestBody JSONObject in) {
|
|
|
|
|
DeliveryDto dto = JSON.toJavaObject(in, DeliveryDto.class);
|
|
|
|
|
return AjaxResult.me().setSuccess(true).setMessage(deliveryService.createDelivery(dto));
|
|
|
|
|
}
|
2025-03-26 10:32:09 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取采购单
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping(value = "/getPurchase")
|
|
|
|
|
public AjaxResult getPurchase(@RequestBody PageDto in) {
|
|
|
|
|
return AjaxResult.me().setSuccess(true).setResultObj(deliveryService.getPurchase(in));
|
|
|
|
|
}
|
2025-03-26 17:40:01 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取入库详情
|
|
|
|
|
* 到货单/销售采购单,根据物料清单,创建批次,进行入库
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping(value = "/getStoreDetail")
|
|
|
|
|
public AjaxResult getStoreDetail(@RequestBody JSONObject in) {
|
|
|
|
|
Map<String, String> params = (Map<String, String>) in.get("params");
|
|
|
|
|
// siteName
|
|
|
|
|
String siteName = params.get("SITENAME");
|
|
|
|
|
String receiveRequestName = params.get("RECEIVEREQUESTNAME");
|
|
|
|
|
// 单据名称集合
|
|
|
|
|
List<String> nameList = new ArrayList<>();
|
|
|
|
|
// 判定是否是到库单
|
2025-03-27 16:41:05 +08:00
|
|
|
|
String typeByKey = deliveryService.getByKey(siteName, receiveRequestName).getReceiveRequestType();
|
2025-03-26 17:40:01 +08:00
|
|
|
|
if (typeByKey.equals(ReceiveTypeEnums.DK.getCode())) {
|
|
|
|
|
// 到库单(找出该单据下的所有的采购单)
|
2025-03-27 16:41:05 +08:00
|
|
|
|
nameList = deliveryService.getReceiveByDelivery(siteName, receiveRequestName)
|
|
|
|
|
.stream().map(MaterialReceiveRequest::getReceiveRequestName).collect(Collectors.toList());
|
2025-03-26 17:40:01 +08:00
|
|
|
|
} else {
|
|
|
|
|
// 采购单
|
|
|
|
|
nameList.add(receiveRequestName);
|
|
|
|
|
}
|
|
|
|
|
// 获取采购单明细及批次
|
|
|
|
|
return AjaxResult.me().setSuccess(true).setResultObj(deliveryService.getStoreDetail(siteName, nameList));
|
|
|
|
|
}
|
2025-03-26 09:06:23 +08:00
|
|
|
|
}
|