feat(pocket): 新增工厂状态数据的CURD功能
- 为Klptcm1ProPlantStateCurrent实体增加完整的增删改查接口 - 实现按复合键(INSDATE+TYPE)查询、插入、更新和删除逻辑 - 在Mapper层添加对应的XML SQL映射支持 - 为Klptcm1ProPlantStateDefine增加ID查询、批量删除等功能 - 添加PlantStateWithValueVo视图对象及相关联查逻辑 - 提供根据名称获取带值的状态定义列表方法 - 控制器层新增RESTful API endpoints支持完整操作- 完善服务层实现并暴露统一的服务接口供调用
This commit is contained in:
@@ -9,6 +9,9 @@ import com.klp.pocket.service.IKlptcm1ProPlantStateCurrentService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/pocket/proPlantStateCurrent")
|
||||
@@ -26,4 +29,40 @@ public class Klptcm1ProPlantStateCurrentController extends BaseController {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询单条(按 INSDATE + TYPE)
|
||||
*/
|
||||
@GetMapping("/one")
|
||||
public R<Klptcm1ProPlantStateCurrent> getOne(
|
||||
@RequestParam("type") BigDecimal type,
|
||||
@RequestParam("insdate") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date insdate) {
|
||||
return R.ok(klptcm1ProPlantStateCurrentService.selectOne(insdate, type));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增一条 current 记录
|
||||
*/
|
||||
@PostMapping
|
||||
public R<Void> add(@RequestBody Klptcm1ProPlantStateCurrent entity) {
|
||||
return toAjax(klptcm1ProPlantStateCurrentService.insert(entity));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改一条 current 记录(依据 INSDATE + TYPE)
|
||||
*/
|
||||
@PutMapping
|
||||
public R<Void> edit(@RequestBody Klptcm1ProPlantStateCurrent entity) {
|
||||
return toAjax(klptcm1ProPlantStateCurrentService.updateByKey(entity));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除一条 current 记录(按 INSDATE + TYPE)
|
||||
*/
|
||||
@DeleteMapping
|
||||
public R<Void> remove(
|
||||
@RequestParam("type") BigDecimal type,
|
||||
@RequestParam("insdate") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date insdate) {
|
||||
return toAjax(klptcm1ProPlantStateCurrentService.deleteByKey(insdate, type));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,11 +4,13 @@ import com.klp.common.core.controller.BaseController;
|
||||
import com.klp.common.core.domain.PageQuery;
|
||||
import com.klp.common.core.page.TableDataInfo;
|
||||
import com.klp.pocket.domain.Klptcm1ProPlantStateDefine;
|
||||
import com.klp.pocket.domain.vo.PlantStateWithValueVo;
|
||||
import com.klp.pocket.service.IKlptcm1ProPlantStateDefineService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import com.klp.common.core.domain.R;
|
||||
|
||||
/**
|
||||
* 工厂状态定义表Controller
|
||||
@@ -21,6 +23,10 @@ public class Klptcm1ProPlantStateDefineController extends BaseController {
|
||||
@Resource
|
||||
private IKlptcm1ProPlantStateDefineService defineService;
|
||||
|
||||
@GetMapping("/plant/state")
|
||||
public List<PlantStateWithValueVo> getTopByValue(@RequestParam String name) {
|
||||
return defineService.selectByValue(name);
|
||||
}
|
||||
/**
|
||||
* 分页查询状态定义列表
|
||||
* @param pageQuery 分页参数(请求参数,如?pageNum=1&pageSize=10)
|
||||
@@ -31,4 +37,25 @@ public class Klptcm1ProPlantStateDefineController extends BaseController {
|
||||
return defineService.getDefinePage(pageQuery);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public R<Klptcm1ProPlantStateDefine> getInfo(@PathVariable BigDecimal id) {
|
||||
return R.ok(defineService.selectById(id));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public R<Void> add(@RequestBody Klptcm1ProPlantStateDefine entity) {
|
||||
return toAjax(defineService.insert(entity));
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public R<Void> edit(@RequestBody Klptcm1ProPlantStateDefine entity) {
|
||||
return toAjax(defineService.updateById(entity));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@PathVariable List<BigDecimal> ids) {
|
||||
return toAjax(defineService.deleteByIds(ids));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.klp.pocket.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
public class PlantStateWithValueVo {
|
||||
// define表基础字段
|
||||
private BigDecimal id;
|
||||
private String name;
|
||||
private String units;
|
||||
private String comments;
|
||||
private Date insdate;
|
||||
private BigDecimal modeltype;
|
||||
|
||||
// current表关联字段(VALUE{ID} + 时间)
|
||||
private BigDecimal currentValue;
|
||||
private Date currentInsdate;
|
||||
|
||||
// history表关联字段(VALUE{ID} + 时间)
|
||||
private BigDecimal historyValue;
|
||||
private Date historyInsdate;
|
||||
|
||||
}
|
||||
@@ -6,10 +6,25 @@ import com.klp.common.core.page.TableDataInfo;
|
||||
import com.klp.pocket.domain.Klptcm1ProPlantStateCurrent;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface Klptcm1ProPlantStateCurrentMapper {
|
||||
|
||||
// 查询所有
|
||||
Page<Klptcm1ProPlantStateCurrent> selectAll(Page<Object> build);
|
||||
|
||||
// 按复合键查询
|
||||
Klptcm1ProPlantStateCurrent selectOne(@Param("insdate") Date insdate, @Param("type") BigDecimal type);
|
||||
|
||||
// 新增
|
||||
int insert(Klptcm1ProPlantStateCurrent entity);
|
||||
|
||||
// 修改(按复合键)
|
||||
int updateByKey(Klptcm1ProPlantStateCurrent entity);
|
||||
|
||||
// 删除(按复合键)
|
||||
int deleteByKey(@Param("insdate") Date insdate, @Param("type") BigDecimal type);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.klp.pocket.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.klp.pocket.domain.Klptcm1ProPlantStateDefine;
|
||||
import com.klp.pocket.domain.vo.PlantStateWithValueVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
||||
@@ -22,4 +23,25 @@ public interface Klptcm1ProPlantStateDefineMapper {
|
||||
*/
|
||||
Page<Klptcm1ProPlantStateDefine> selectPage(Page<Object> page);
|
||||
|
||||
List<PlantStateWithValueVo> selectByValue(String name);
|
||||
|
||||
/**
|
||||
* 按ID查询
|
||||
*/
|
||||
Klptcm1ProPlantStateDefine selectById(BigDecimal id);
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
int insert(Klptcm1ProPlantStateDefine entity);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
int updateById(Klptcm1ProPlantStateDefine entity);
|
||||
|
||||
/**
|
||||
* 删除(批量)
|
||||
*/
|
||||
int deleteByIds(List<BigDecimal> ids);
|
||||
}
|
||||
|
||||
@@ -4,9 +4,18 @@ import com.klp.common.core.domain.PageQuery;
|
||||
import com.klp.common.core.page.TableDataInfo;
|
||||
import com.klp.pocket.domain.Klptcm1ProPlantStateCurrent;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public interface IKlptcm1ProPlantStateCurrentService {
|
||||
|
||||
TableDataInfo<Klptcm1ProPlantStateCurrent> selectAll(PageQuery pageQuery);
|
||||
|
||||
Klptcm1ProPlantStateCurrent selectOne(Date insdate, BigDecimal type);
|
||||
|
||||
int insert(Klptcm1ProPlantStateCurrent entity);
|
||||
|
||||
int updateByKey(Klptcm1ProPlantStateCurrent entity);
|
||||
|
||||
int deleteByKey(Date insdate, BigDecimal type);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.klp.pocket.service;
|
||||
import com.klp.common.core.domain.PageQuery;
|
||||
import com.klp.common.core.page.TableDataInfo;
|
||||
import com.klp.pocket.domain.Klptcm1ProPlantStateDefine;
|
||||
|
||||
import com.klp.pocket.domain.vo.PlantStateWithValueVo;
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -23,5 +23,13 @@ public interface IKlptcm1ProPlantStateDefineService {
|
||||
*/
|
||||
TableDataInfo<Klptcm1ProPlantStateDefine> getDefinePage(PageQuery pageQuery);
|
||||
|
||||
List<PlantStateWithValueVo> selectByValue(String name);
|
||||
|
||||
Klptcm1ProPlantStateDefine selectById(BigDecimal id);
|
||||
|
||||
int insert(Klptcm1ProPlantStateDefine entity);
|
||||
|
||||
int updateById(Klptcm1ProPlantStateDefine entity);
|
||||
|
||||
int deleteByIds(List<BigDecimal> ids);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import com.klp.pocket.service.IKlptcm1ProPlantStateCurrentService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@DS("slave")
|
||||
@Service
|
||||
@@ -18,11 +20,30 @@ public class Klptcm1ProPlantStateCurrentServiceImpl implements IKlptcm1ProPlantS
|
||||
@Resource
|
||||
private Klptcm1ProPlantStateCurrentMapper klptcm1ProPlantStateCurrentMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public TableDataInfo<Klptcm1ProPlantStateCurrent> selectAll(PageQuery pageQuery) {
|
||||
Page<Klptcm1ProPlantStateCurrent> result = klptcm1ProPlantStateCurrentMapper.selectAll(pageQuery.build());
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Klptcm1ProPlantStateCurrent selectOne(Date insdate, BigDecimal type) {
|
||||
return klptcm1ProPlantStateCurrentMapper.selectOne(insdate, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(Klptcm1ProPlantStateCurrent entity) {
|
||||
return klptcm1ProPlantStateCurrentMapper.insert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateByKey(Klptcm1ProPlantStateCurrent entity) {
|
||||
return klptcm1ProPlantStateCurrentMapper.updateByKey(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteByKey(Date insdate, BigDecimal type) {
|
||||
return klptcm1ProPlantStateCurrentMapper.deleteByKey(insdate, type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.klp.pocket.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.klp.common.core.domain.PageQuery;
|
||||
import com.klp.common.core.page.TableDataInfo;
|
||||
import com.klp.pocket.domain.Klptcm1ProPlantStateCurrent;
|
||||
import com.klp.pocket.domain.Klptcm1ProPlantStateDefine;
|
||||
import com.klp.pocket.domain.vo.PlantStateWithValueVo;
|
||||
import com.klp.pocket.mapper.Klptcm1ProPlantStateDefineMapper;
|
||||
import com.klp.pocket.service.IKlptcm1ProPlantStateDefineService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@@ -11,12 +13,14 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 工厂状态定义表Service实现类
|
||||
* 具体业务逻辑实现,依赖Mapper操作数据库
|
||||
*/
|
||||
@DS("slave")
|
||||
@Service
|
||||
public class Klptcm1ProPlantStateDefineServiceImpl implements IKlptcm1ProPlantStateDefineService {
|
||||
|
||||
@@ -33,4 +37,30 @@ public class Klptcm1ProPlantStateDefineServiceImpl implements IKlptcm1ProPlantSt
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlantStateWithValueVo> selectByValue(String name) {
|
||||
return defineMapper.selectByValue(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Klptcm1ProPlantStateDefine selectById(BigDecimal id) {
|
||||
return defineMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(Klptcm1ProPlantStateDefine entity) {
|
||||
return defineMapper.insert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateById(Klptcm1ProPlantStateDefine entity) {
|
||||
return defineMapper.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteByIds(List<BigDecimal> ids) {
|
||||
return defineMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user