| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- package com.ydtech.modules.protocol.service.impl;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.ydtech.core.page.HttpResult;
- import com.ydtech.core.page.PageResult;
- import com.ydtech.modules.protocol.dao.PtlNewCarJudgeRulesMapper;
- import com.ydtech.modules.protocol.entity.po.PtlNewCarJudgeRules;
- import com.ydtech.modules.protocol.entity.vo.PtlNewCarJudgeRulesVo;
- import com.ydtech.modules.protocol.service.PtlNewCarJudgeRulesService;
- import com.ydtech.modules.protocol.utils.AssertionUtils;
- import com.ydtech.utils.StringUtils;
- import org.springframework.beans.BeanUtils;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import java.util.Collections;
- import java.util.Date;
- import java.util.List;
- /**
- * @author CXP
- * @description 针对表【ptl_new_car_judge_rules(新车判断规则)】的数据库操作Service实现
- * @createDate 2023年11月18日22:50:18
- */
- @Service
- public class PtlNewCarJudgeRulesServiceImpl extends ServiceImpl<PtlNewCarJudgeRulesMapper, PtlNewCarJudgeRules>
- implements PtlNewCarJudgeRulesService {
- @Override
- public HttpResult<Object> saveNewCarJudgeRules(PtlNewCarJudgeRulesVo newCarJudgeRulesVo) {
- PtlNewCarJudgeRules ptlNewCarJudgeRules = new PtlNewCarJudgeRules();
- BeanUtils.copyProperties(newCarJudgeRulesVo, ptlNewCarJudgeRules);
- ptlNewCarJudgeRules.setIsEffective("1");
- ptlNewCarJudgeRules.setSaveDate(new Date());
- boolean b = save(ptlNewCarJudgeRules);
- AssertionUtils.isSucceed(b, "保存失败");
- return HttpResult.ok("保存成功");
- }
- @Override
- @Transactional
- public HttpResult<Object> reviseNewCarJudgeRules(String ruleId, PtlNewCarJudgeRulesVo newCarJudgeRulesVo) {
- PtlNewCarJudgeRules newCarJudgeRules = getById(ruleId);
- BeanUtils.copyProperties(newCarJudgeRulesVo, newCarJudgeRules);
- newCarJudgeRules.setIsEffective("1");
- newCarJudgeRules.setSaveDate(new Date());
- boolean b = updateById(newCarJudgeRules);
- AssertionUtils.isSucceed(b, "修改失败");
- return HttpResult.ok("修改成功");
- }
- @Override
- public HttpResult<Object> deleteByRuleId(String ruleId) {
- boolean b = removeById(ruleId);
- AssertionUtils.isSucceed(b, "删除失败");
- return HttpResult.ok("删除成功");
- }
- @Override
- public HttpResult<PageResult<PtlNewCarJudgeRules>> pageNewCarJudgeRules(PtlNewCarJudgeRulesVo newCarJudgeRulesVo) {
- Integer pageNum = newCarJudgeRulesVo.getPageNum();
- Integer pageSize = newCarJudgeRulesVo.getPageSize();
- Page<PtlNewCarJudgeRules> ptlNewCarJudgeRulesPage = new Page<>(pageNum, pageSize);
- LambdaQueryWrapper<PtlNewCarJudgeRules> wrapper = new LambdaQueryWrapper<>();
- wrapper.eq(StringUtils.isNotEmpty(newCarJudgeRulesVo.getUnitTypeCode()),PtlNewCarJudgeRules::getUnitTypeCode,newCarJudgeRulesVo.getUnitTypeCode());
- wrapper.eq(StringUtils.isNotEmpty(newCarJudgeRulesVo.getUnitTypeValue()),PtlNewCarJudgeRules::getUnitTypeValue,newCarJudgeRulesVo.getUnitTypeValue());
- wrapper.eq(StringUtils.isNotEmpty(newCarJudgeRulesVo.getCompanyId()),PtlNewCarJudgeRules::getCompanyId,newCarJudgeRulesVo.getCompanyId());
- Page<PtlNewCarJudgeRules> newCarJudgeRulesPage = page(ptlNewCarJudgeRulesPage,wrapper);
- PageResult<PtlNewCarJudgeRules> ptlNewCarJudgeRulesPageResult = new PageResult<>(pageNum, pageSize, (int) newCarJudgeRulesPage.getTotal(), newCarJudgeRulesPage.getRecords());
- return HttpResult.ok(ptlNewCarJudgeRulesPageResult);
- }
- @Override
- public List<PtlNewCarJudgeRules> getByCompanyId(String companyId) {
- String code = "000000";
- String substring = companyId.substring(0, 5);
- String s = substring + code;
- List<PtlNewCarJudgeRules> list = lambdaQuery().eq(PtlNewCarJudgeRules::getCompanyId, s).list();
- if (list != null && !list.isEmpty()) {
- return list;
- }
- return Collections.emptyList();
- }
- @Override
- public HttpResult<PtlNewCarJudgeRulesVo> getByRuleId(String ruleId) {
- PtlNewCarJudgeRulesVo resultVo=new PtlNewCarJudgeRulesVo();
- //获取新车规则判断信息
- PtlNewCarJudgeRules newCarJudgeRules = getById(ruleId);
- BeanUtils.copyProperties(newCarJudgeRules, resultVo);
- AssertionUtils.isEmpty(newCarJudgeRules, "没有此新车判断规则");
- return HttpResult.ok(resultVo);
- }
- }
|