cl
2024-01-19 e0fac38b26845f25de479783e0c76cf12a5311e0
提交 | 用户 | 时间
71e81e 1 package cn.stylefeng.guns.modular.bs.bomInfo.service.impl;
2
3 import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
4 import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
5 import cn.stylefeng.guns.modular.bs.bomInfo.entity.BomInfo;
6 import cn.stylefeng.guns.modular.bs.bomInfo.mapper.BomInfoMapper;
7 import cn.stylefeng.guns.modular.bs.bomInfo.model.params.BomInfoParam;
8 import cn.stylefeng.guns.modular.bs.bomInfo.model.result.BomInfoResult;
9 import  cn.stylefeng.guns.modular.bs.bomInfo.service.BomInfoService;
10 import cn.stylefeng.guns.modular.dq.materialTraceability.entity.MaterialTraceability;
11 import cn.stylefeng.guns.modular.dq.materialTraceability.service.MaterialTraceabilityService;
12 import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.entity.ProductionOrderBatchInfo;
13 import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService;
14 import cn.stylefeng.roses.core.util.ToolUtil;
15 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
16 import com.baomidou.mybatisplus.core.metadata.IPage;
17 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
18 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
19 import org.springframework.beans.factory.annotation.Autowired;
20 import org.springframework.stereotype.Service;
21
22 import java.io.Serializable;
23 import java.util.List;
24
25 /**
26  * <p>
27  * bom信息 服务实现类
28  * </p>
29  *
30  * @author 
31  * @since 2022-10-24
32  */
33 @Service
34 public class BomInfoServiceImpl extends ServiceImpl<BomInfoMapper, BomInfo> implements BomInfoService {
35     @Autowired
36     private ProductionOrderBatchInfoService batchInfoService;
37
38     @Autowired
39     private MaterialTraceabilityService materialTraceabilityService;
40
41     @Autowired
42     private BomInfoMapper bomInfoMapper;
43
44     @Override
45     public void add(BomInfoParam param){
46         BomInfo entity = getEntity(param);
47         this.save(entity);
48     }
49
50     @Override
51     public void delete(BomInfoParam param){
52         this.removeById(getKey(param));
53     }
54
55     @Override
56     public void update(BomInfoParam param){
57         BomInfo oldEntity = getOldEntity(param);
58         BomInfo newEntity = getEntity(param);
59         ToolUtil.copyProperties(newEntity, oldEntity);
60         this.updateById(newEntity);
61     }
62
63     @Override
64     public BomInfoResult findBySpec(BomInfoParam param){
65         return null;
66     }
67
68     @Override
69     public List<BomInfoResult> findListBySpec(BomInfoParam param){
70         return this.baseMapper.customList(param);
71     }
72
73     @Override
74     public LayuiPageInfo findPageBySpec(BomInfoParam param){
75         Page pageContext = getPageContext();
76         IPage page = this.baseMapper.customPageList(pageContext, param);
77         return LayuiPageFactory.createPageInfo(page);
78     }
79
80     @Override
81     public LayuiPageInfo kbListTable(BomInfoParam param) {
82         Page pageContext = getPageContext();
83         IPage page = bomInfoMapper.kbListTable(pageContext, param);
84         return LayuiPageFactory.createPageInfo(page);
85     }
86
87     @Override
88     public LayuiPageInfo viewList(BomInfoParam param) {
89         Page pageContext = getPageContext();
90         IPage page = this.baseMapper.customPageList(pageContext, param);
91         List<BomInfoResult> bomInfoResults = page.getRecords();
92         for (BomInfoResult bomInfoResult : bomInfoResults) {
93             List<MaterialTraceability> list = materialTraceabilityService.list(new QueryWrapper<MaterialTraceability>()
94                     .eq("product_code", param.getProductCode())
95                     .eq("work_order_no", param.getWorkorderNo())
96                     .eq("location_code", param.getLocationCode())
97             );
98             if (list.size()>0){
99                 for (MaterialTraceability materialTraceability : list) {
100                     if(bomInfoResult.getMaterialCode().equals(materialTraceability.getMaterialCode())){
101                         bomInfoResult.setState("是");
102                         break;
103                     }else {
104                         bomInfoResult.setState("否");
105                     }
106                 }
107             }else {
108                 bomInfoResult.setState("否");
109             }
110         }
111         return LayuiPageFactory.createPageInfo(page);
112     }
113
114     private Serializable getKey(BomInfoParam param){
115         return param.getId();
116     }
117
118     private Page getPageContext() {
119         return LayuiPageFactory.defaultPage();
120     }
121
122     private BomInfo getOldEntity(BomInfoParam param) {
123         return this.getById(getKey(param));
124     }
125
126     private BomInfo getEntity(BomInfoParam param) {
127         BomInfo entity = new BomInfo();
128         ToolUtil.copyProperties(param, entity);
129         return entity;
130     }
131
132 }