package cn.stylefeng.guns.modular.cm.paramCollection.service.impl;
import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.cm.paramCollection.entity.ParamCollection;
import cn.stylefeng.guns.modular.cm.paramCollection.mapper.ParamCollectionMapper;
import cn.stylefeng.guns.modular.cm.paramCollection.model.params.ParamCollectionParam;
import cn.stylefeng.guns.modular.cm.paramCollection.model.result.ParamCollectionResult;
import cn.stylefeng.guns.modular.cm.paramCollection.service.ParamCollectionService;
import cn.stylefeng.roses.core.util.ToolUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
/**
*
* 设备产品过程参数采集 服务实现类
*
*
* @author zrm
* @since 2023-02-11
*/
@Service
public class ParamCollectionServiceImpl extends ServiceImpl implements ParamCollectionService {
private static SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Override
public void add(ParamCollectionParam param){
ParamCollection entity = getEntity(param);
this.save(entity);
}
@Override
public void delete(ParamCollectionParam param){
this.removeById(getKey(param));
}
@Override
public void update(ParamCollectionParam param){
ParamCollection oldEntity = getOldEntity(param);
ParamCollection newEntity = getEntity(param);
ToolUtil.copyProperties(newEntity, oldEntity);
this.updateById(newEntity);
}
@Override
public ParamCollectionResult findBySpec(ParamCollectionParam param){
return null;
}
@Override
public List findListBySpec(ParamCollectionParam param){
return null;
}
@Override
public LayuiPageInfo findPageBySpec(ParamCollectionParam param){
Page pageContext = getPageContext();
IPage page = this.baseMapper.customPageList(pageContext, param);
return LayuiPageFactory.createPageInfo(page);
}
private Serializable getKey(ParamCollectionParam param){
return param.getId();
}
private Page getPageContext() {
return LayuiPageFactory.defaultPage();
}
private ParamCollection getOldEntity(ParamCollectionParam param) {
return this.getById(getKey(param));
}
private ParamCollection getEntity(ParamCollectionParam param) {
ParamCollection entity = new ParamCollection();
ToolUtil.copyProperties(param, entity);
return entity;
}
@Override
public int updateSFC(String sfcCode, String childSfcCode) {
return this.baseMapper.updateSFC(sfcCode, childSfcCode);
}
@Override
public List exportTable(ParamCollectionParam param) {
return this.baseMapper.customList(param);
}
}