KuaidiDetailService.java
1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.huaheng.pc.shipment.kuaidiDetail.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.config.material.domain.Material;
import com.huaheng.pc.config.material.service.MaterialService;
import com.huaheng.pc.shipment.kuaidiDetail.domain.KuaidiDetail;
import com.huaheng.pc.shipment.kuaidiDetail.mapper.KuaidiDetailMapper;
import com.huaheng.pc.shipment.kuaidiHeader.domain.KuaidiHeader;
import com.huaheng.pc.shipment.kuaidiHeader.service.KuaidiHeaderService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* 【请填写功能名称】 服务层实现
*
* @author huaheng
* @date 2022-09-07
*/
@Service
public class KuaidiDetailService extends ServiceImpl<KuaidiDetailMapper, KuaidiDetail> {
@Resource
private KuaidiHeaderService kuaidiHeaderService;
@Resource
private MaterialService materialService;
public AjaxResult insertDetail(KuaidiDetail kuaidiDetail) {
KuaidiHeader kuaidiHeader = kuaidiHeaderService.getById(kuaidiDetail.getShipmentId());
if(kuaidiHeader==null){
return AjaxResult.error("快递主单查找不到");
}
kuaidiDetail.setWarehouseId(kuaidiHeader.getWarehouseId());
kuaidiDetail.setWarehouseCode(kuaidiHeader.getWarehouseCode());
kuaidiDetail.setUWarehouseCode(kuaidiHeader.getUWarehouseCode());
Material material = materialService.getMaterialByCode(kuaidiDetail.getMaterialCode());
if(material==null){
return AjaxResult.error("物料编码错误,系统无此物料编码");
}
kuaidiDetail.setMaterialName(material.getName());
kuaidiDetail.setSpecification(material.getSpec());
kuaidiDetail.setUnit(material.getUnit());
this.save(kuaidiDetail);
return AjaxResult.success("添加物料成功");
}
}