cl
2024-01-19 e0fac38b26845f25de479783e0c76cf12a5311e0
提交 | 用户 | 时间
71e81e 1 package cn.stylefeng.guns.modular.em.equipmentMaintainPlan.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.em.equipmentMaintainPlan.entity.EquipmentMaintainPlan;
6 import cn.stylefeng.guns.modular.em.equipmentMaintainPlan.mapper.EquipmentMaintainPlanMapper;
7 import cn.stylefeng.guns.modular.em.equipmentMaintainPlan.model.params.EquipmentMaintainPlanParam;
8 import cn.stylefeng.guns.modular.em.equipmentMaintainPlan.model.result.EquipmentMaintainPlanResult;
9 import  cn.stylefeng.guns.modular.em.equipmentMaintainPlan.service.EquipmentMaintainPlanService;
10 import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.impl.ProductionOrdeInfoServiceImpl;
11 import cn.stylefeng.roses.core.util.ToolUtil;
12 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
13 import com.baomidou.mybatisplus.core.metadata.IPage;
14 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
15 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
16 import org.springframework.beans.factory.annotation.Autowired;
17 import org.springframework.stereotype.Service;
18
19 import java.io.Serializable;
20 import java.text.SimpleDateFormat;
21 import java.util.Date;
22 import java.util.List;
23
24 /**
25  * <p>
26  * 保养计划 服务实现类
27  * </p>
28  *
29  * @author ruimin
30  * @since 2023-02-20
31  */
32 @Service
33 public class EquipmentMaintainPlanServiceImpl extends ServiceImpl<EquipmentMaintainPlanMapper, EquipmentMaintainPlan> implements EquipmentMaintainPlanService {
34
35     private static SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
36     private static String date = format.format(new Date());
37     private static String planNum = "P"+date;
38
39     @Override
40     public void add(EquipmentMaintainPlanParam param){
41         param.setState("2");
42         EquipmentMaintainPlan entity = getEntity(param);
43         this.save(entity);
44     }
45
46     @Override
47     public void delete(EquipmentMaintainPlanParam param){
48         this.removeById(getKey(param));
49     }
50
51     @Override
52     public void update(EquipmentMaintainPlanParam param){
53         EquipmentMaintainPlan oldEntity = getOldEntity(param);
54         EquipmentMaintainPlan newEntity = getEntity(param);
55         ToolUtil.copyProperties(newEntity, oldEntity);
56         this.updateById(newEntity);
57     }
58
59     @Override
60     public EquipmentMaintainPlanResult findBySpec(EquipmentMaintainPlanParam param){
61         return null;
62     }
63
64     @Override
65     public List<EquipmentMaintainPlanResult> findListBySpec(EquipmentMaintainPlanParam param){
66         return null;
67     }
68
69     @Override
70     public LayuiPageInfo findPageBySpec(EquipmentMaintainPlanParam param){
71         Page pageContext = getPageContext();
72         IPage page = this.baseMapper.customPageList(pageContext, param);
73         return LayuiPageFactory.createPageInfo(page);
74     }
75
76     @Override
77     public String planNumberGenerate(EquipmentMaintainPlanParam equipmentMaintainPlanParam) {
78         String PlanNum = "";
79         List<EquipmentMaintainPlan> planNo = this.baseMapper.selectList(new QueryWrapper<EquipmentMaintainPlan>().like("plan_no", date));
80         if(planNo.size() == 0){
81             PlanNum = planNum+"0001";
82         }else {
83             PlanNum = planNum+String.format("%04d", planNo.size()+1);
84         }
85         return PlanNum;
86     }
87
88     private Serializable getKey(EquipmentMaintainPlanParam param){
89         return param.getId();
90     }
91
92     private Page getPageContext() {
93         return LayuiPageFactory.defaultPage();
94     }
95
96     private EquipmentMaintainPlan getOldEntity(EquipmentMaintainPlanParam param) {
97         return this.getById(getKey(param));
98     }
99
100     private EquipmentMaintainPlan getEntity(EquipmentMaintainPlanParam param) {
101         EquipmentMaintainPlan entity = new EquipmentMaintainPlan();
102         ToolUtil.copyProperties(param, entity);
103         return entity;
104     }
105
106 }