选煤厂生产管理平台后台代码
Jay
6 天以前 8d3ff63ab144ad6b48015b01196bc901944a48f9
提交 | 用户 | 时间
8d3ff6 1 package com.iailab.module.pms.coalquality.modules.plan.service.impl;
J 2
3 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 import com.iailab.framework.common.pojo.PageResult;
5 import com.iailab.framework.common.service.impl.BaseServiceImpl;
6 import com.iailab.framework.common.util.object.BeanUtils;
7 import com.iailab.framework.common.util.object.ConvertUtils;
8 import com.iailab.module.pms.coalquality.modules.plan.dao.QualityPlanDao;
9 import com.iailab.module.pms.coalquality.modules.plan.dto.QualityPlanDTO;
10 import com.iailab.module.pms.coalquality.modules.plan.dto.QualityPlanDetDTO;
11 import com.iailab.module.pms.coalquality.modules.plan.entity.QualityPlanEntity;
12 import com.iailab.module.pms.coalquality.modules.plan.service.QualityPlanDetService;
13 import com.iailab.module.pms.coalquality.modules.plan.service.QualityPlanService;
14 import com.iailab.module.pms.coalquality.modules.plan.vo.PlanMonthPageReqVO;
15 import org.apache.commons.lang3.StringUtils;
16 import org.springframework.beans.factory.annotation.Autowired;
17 import org.springframework.stereotype.Service;
18 import org.springframework.transaction.annotation.Transactional;
19 import org.springframework.util.CollectionUtils;
20
21 import java.util.Arrays;
22 import java.util.Date;
23 import java.util.List;
24 import java.util.UUID;
25
26 /**
27  * 质量计划
28  *
29  * @author PanZhibao
30  * @Description
31  * @createTime 2023年02月04日 14:45:00
32  */
33 @Service
34 public class QualityPlanServiceImpl extends BaseServiceImpl<QualityPlanDao, QualityPlanEntity>
35         implements QualityPlanService {
36     @Autowired
37     private QualityPlanDetService qualityPlanDetService;
38
39     private String BUSINESS_CODE = "QualityPlan";
40
41     @Override
42     public PageResult<QualityPlanDTO> page(PlanMonthPageReqVO planMonthPageReqVO) {
43         PageResult<QualityPlanEntity> page = baseDao.selectPage(planMonthPageReqVO);
44
45         return BeanUtils.toBean(page, QualityPlanDTO.class);
46     }
47
48     @Override
49     public QualityPlanDTO get(String id) {
50         QualityPlanEntity entity = baseDao.selectById(id);
51
52         QualityPlanDTO result = ConvertUtils.sourceToTarget(entity, QualityPlanDTO.class);
53         result.setDetList(qualityPlanDetService.getListByPlanId(id));
54         return result;
55     }
56
57     @Override
58     @Transactional(rollbackFor = Exception.class)
59     public void save(QualityPlanDTO dto) {
60 //        dto.setCode(serialNumUtils.getByBusinessDate(BUSINESS_CODE, new Date(), 4));
61         QualityPlanEntity entity = ConvertUtils.sourceToTarget(dto, QualityPlanEntity.class);
62         entity.setId(UUID.randomUUID().toString());
63         entity.setCreateDate(new Date());
64 //        entity.setCreator(SecurityUser.getUser().getId().toString());
65         insert(entity);
66
67         List<QualityPlanDetDTO> detList = dto.getDetList();
68         if (!CollectionUtils.isEmpty(detList)) {
69             qualityPlanDetService.saveList(detList, entity.getId());
70         }
71     }
72
73     @Override
74     @Transactional(rollbackFor = Exception.class)
75     public void update(QualityPlanDTO dto) {
76         QualityPlanEntity entity = ConvertUtils.sourceToTarget(dto, QualityPlanEntity.class);
77         entity.setUpdateDate(new Date());
78 //        entity.setUpdater(SecurityUser.getUserId().toString());
79         updateById(entity);
80
81         List<QualityPlanDetDTO> detList = dto.getDetList();
82         if (!CollectionUtils.isEmpty(detList)) {
83             qualityPlanDetService.deleteByPlanId(entity.getId());
84             qualityPlanDetService.saveList(detList, entity.getId());
85         }
86     }
87
88     @Override
89     @Transactional(rollbackFor = Exception.class)
90     public void delete(String[] ids) {
91         baseDao.deleteByIds(Arrays.asList(ids));
92         qualityPlanDetService.deleteByPlanIds(ids);
93     }
94
95     @Override
96     public Long cheack(QualityPlanDTO dto) {
97         String id = dto.getId();
98         String code = dto.getCode();
99
100         QueryWrapper<QualityPlanEntity> queryWrapper = new QueryWrapper<>();
101         queryWrapper.ne(StringUtils.isNotBlank(id), "id", id);
102         queryWrapper.and(wrapper -> wrapper.eq("code", code));
103         return baseDao.selectCount(queryWrapper);
104     }
105 }