懒羊羊
2024-01-11 be26d5065b4a07123638c220c0792e9250a458e6
提交 | 用户 | 时间
71e81e 1 package cn.stylefeng.guns.modular.om.productionOrderBatchInfo.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.service.BomInfoService;
7 import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.entity.ProductionOrderBatchInfo;
8 import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.mapper.ProductionOrderBatchInfoMapper;
9 import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam;
10 import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.result.ProductionOrderBatchInfoResult;
11 import  cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService;
12 import cn.stylefeng.roses.core.util.ToolUtil;
13 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
14 import com.baomidou.mybatisplus.core.metadata.IPage;
15 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
16 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
17 import org.springframework.beans.factory.annotation.Autowired;
18 import org.springframework.stereotype.Service;
19
20 import java.io.Serializable;
21 import java.util.List;
22
23 /**
24  * <p>
25  * 工单批次上料信息 服务实现类
26  * </p>
27  *
28  * @author ruimin
29  * @since 2023-02-24
30  */
31 @Service
32 public class ProductionOrderBatchInfoServiceImpl extends ServiceImpl<ProductionOrderBatchInfoMapper, ProductionOrderBatchInfo> implements ProductionOrderBatchInfoService {
33
34     @Autowired
35     private BomInfoService bomInfoService;
36
37     @Autowired
38     private ProductionOrderBatchInfoService infoService;
39
40     @Override
41     public void add(ProductionOrderBatchInfoParam param){
42         ProductionOrderBatchInfo entity = getEntity(param);
43         this.save(entity);
44     }
45
46     @Override
47     public void delete(ProductionOrderBatchInfoParam param){
48         this.removeById(getKey(param));
49     }
50
51     @Override
52     public void update(ProductionOrderBatchInfoParam param){
53         ProductionOrderBatchInfo oldEntity = getOldEntity(param);
54         ProductionOrderBatchInfo newEntity = getEntity(param);
55         ToolUtil.copyProperties(newEntity, oldEntity);
56         this.updateById(newEntity);
57     }
58
59     @Override
60     public ProductionOrderBatchInfoResult findBySpec(ProductionOrderBatchInfoParam param){
61         return null;
62     }
63
64     @Override
65     public List<ProductionOrderBatchInfoResult> findListBySpec(ProductionOrderBatchInfoParam param){
4a2c67 66         return this.baseMapper.customList(param);
71e81e 67     }
68
69     @Override
70     public LayuiPageInfo findPageBySpec(ProductionOrderBatchInfoParam param){
71         Page pageContext = getPageContext();
72         IPage page = this.baseMapper.customPageList(pageContext, param);
73         return LayuiPageFactory.createPageInfo(page);
74     }
75
76     @Override
77     public int barCodeCheck(ProductionOrderBatchInfoParam productionOrderBatchInfoParam) {
78         int i =  infoService.count(new QueryWrapper<ProductionOrderBatchInfo>()
79                 .eq("work_order_no", productionOrderBatchInfoParam.getWorkOrderNo())
80                 .eq("material_code", productionOrderBatchInfoParam.getMaterialCode())
81                 .eq("state","是")
82         );
83         return i;
84     }
85
86     @Override
87     public void updateState(ProductionOrderBatchInfoParam productionOrderBatchInfoParam) {
88         ProductionOrderBatchInfo one = infoService.getOne(new QueryWrapper<ProductionOrderBatchInfo>()
89                 .eq("work_order_no", productionOrderBatchInfoParam.getWorkOrderNo())
90                 .eq("material_code", productionOrderBatchInfoParam.getMaterialCode())
91         );
be26d5 92         one.setStatus("是");
71e81e 93         infoService.saveOrUpdate(one);
94     }
95
96     private Serializable getKey(ProductionOrderBatchInfoParam param){
97         return param.getId();
98     }
99
100     private Page getPageContext() {
101         return LayuiPageFactory.defaultPage();
102     }
103
104     private ProductionOrderBatchInfo getOldEntity(ProductionOrderBatchInfoParam param) {
105         return this.getById(getKey(param));
106     }
107
108     private ProductionOrderBatchInfo getEntity(ProductionOrderBatchInfoParam param) {
109         ProductionOrderBatchInfo entity = new ProductionOrderBatchInfo();
110         ToolUtil.copyProperties(param, entity);
111         return entity;
112     }
113
114 }