cl
2024-01-19 e0fac38b26845f25de479783e0c76cf12a5311e0
提交 | 用户 | 时间
71e81e 1 package cn.stylefeng.guns.modular.qc.badCollection.service.impl;
2
3 import cn.stylefeng.guns.base.auth.context.LoginContextHolder;
4 import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
5 import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
6 import cn.stylefeng.guns.modular.bs.locationInfo.entity.LocationInfo;
7 import cn.stylefeng.guns.modular.bs.locationInfo.service.LocationInfoService;
8 import cn.stylefeng.guns.modular.dq.materialTraceability.service.impl.MaterialTraceabilityServiceImpl;
9 import cn.stylefeng.guns.modular.qc.badCollection.entity.BadCollection;
10 import cn.stylefeng.guns.modular.qc.badCollection.mapper.BadCollectionMapper;
11 import cn.stylefeng.guns.modular.qc.badCollection.model.params.BadCollectionParam;
12 import cn.stylefeng.guns.modular.qc.badCollection.model.result.BadCollectionResult;
13 import  cn.stylefeng.guns.modular.qc.badCollection.service.BadCollectionService;
14 import cn.stylefeng.guns.modular.qc.badReasonConf.entity.BadReasonConf;
15 import cn.stylefeng.guns.modular.qc.badReasonConf.service.BadReasonConfService;
16 import cn.stylefeng.roses.core.util.ToolUtil;
17 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
18 import com.baomidou.mybatisplus.core.metadata.IPage;
19 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
20 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
21 import org.springframework.beans.factory.annotation.Autowired;
22 import org.springframework.stereotype.Service;
23
24 import java.io.Serializable;
25 import java.util.List;
26
27 /**
28  * <p>
29  * 不良数据采集 服务实现类
30  * </p>
31  *
32  * @author ruimin
33  * @since 2023-03-11
34  */
35 @Service
36 public class BadCollectionServiceImpl extends ServiceImpl<BadCollectionMapper, BadCollection> implements BadCollectionService {
37     @Autowired
38     private LocationInfoService locationInfoService;
39
40     @Autowired
41     private BadReasonConfService badReasonConfService;
42
43     @Override
44     public void add(BadCollectionParam param){
45         param.setCreateUser(LoginContextHolder.getContext().getUser().getName());
46 //        param.setSfcCode(MaterialTraceabilityServiceImpl.getSfcCode(param.getLocationCode()+"_S_SFC_CODE"));
47         BadCollection entity = getEntity(param);
48         this.save(entity);
49     }
50
51     @Override
52     public void delete(BadCollectionParam param){
53         this.removeById(getKey(param));
54     }
55
56     @Override
57     public void update(BadCollectionParam param){
58         BadCollection oldEntity = getOldEntity(param);
59         BadCollection newEntity = getEntity(param);
60         ToolUtil.copyProperties(newEntity, oldEntity);
61         this.updateById(newEntity);
62     }
63
64     @Override
65     public BadCollectionResult findBySpec(BadCollectionParam param){
66         return null;
67     }
68
69     @Override
70     public List<BadCollectionResult> findListBySpec(BadCollectionParam param){
71         return null;
72     }
73
74     @Override
75     public LayuiPageInfo findPageBySpec(BadCollectionParam param){
76         Page pageContext = getPageContext();
77         IPage page = this.baseMapper.customPageList(pageContext, param);
78         return LayuiPageFactory.createPageInfo(page);
79     }
80
81     private Serializable getKey(BadCollectionParam param){
82         return param.getId();
83     }
84
85     private Page getPageContext() {
86         return LayuiPageFactory.defaultPage();
87     }
88
89     private BadCollection getOldEntity(BadCollectionParam param) {
90         return this.getById(getKey(param));
91     }
92
93     private BadCollection getEntity(BadCollectionParam param) {
94         BadCollection entity = new BadCollection();
95         ToolUtil.copyProperties(param, entity);
96         return entity;
97     }
98
99 }