|
@@ -0,0 +1,114 @@
|
|
|
+package com.zjugis.yzt.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.zjugis.yzt.service.PewgService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import com.zjugis.yzt.beans.vo.PewgVO;
|
|
|
+import com.zjugis.yzt.beans.entity.Pewg;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+import org.springframework.format.annotation.DateTimeFormat;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api/pewg")
|
|
|
+public class PewgController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PewgService pewgService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取批而未供信息(分页)
|
|
|
+ */
|
|
|
+ @GetMapping("/page")
|
|
|
+ public IPage<PewgVO> getPewgList(
|
|
|
+ @RequestParam(defaultValue = "1") Integer current,
|
|
|
+ @RequestParam(defaultValue = "10") Integer size,
|
|
|
+ @RequestParam(required = false) String pcbh, // 批次名称
|
|
|
+ @RequestParam(required = false) String lx, // 类型
|
|
|
+ @RequestParam(required = false) String wgyy // 未供原因
|
|
|
+ ) {
|
|
|
+
|
|
|
+ QueryWrapper<Pewg> queryWrapper = new QueryWrapper<>();
|
|
|
+
|
|
|
+ if (pcbh != null && !pcbh.isEmpty()) {
|
|
|
+ queryWrapper.like("pcbh", pcbh);
|
|
|
+ }
|
|
|
+ if (lx != null && !lx.isEmpty()) {
|
|
|
+ queryWrapper.like("lx", lx);
|
|
|
+ }
|
|
|
+ if (wgyy != null && !wgyy.isEmpty()) {
|
|
|
+ queryWrapper.like("wgyy", wgyy);
|
|
|
+ }
|
|
|
+
|
|
|
+ Page<Pewg> page = new Page<>(current, size);
|
|
|
+ IPage<Pewg> pewgPage = pewgService.page(page, queryWrapper);
|
|
|
+
|
|
|
+ return pewgPage.convert(this::convertToVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据ID获取批而未供信息
|
|
|
+ */
|
|
|
+ @GetMapping("/{id}")
|
|
|
+ public PewgVO getPewgById(@PathVariable Integer id) {
|
|
|
+ Pewg pewg = pewgService.getById(id);
|
|
|
+ return convertToVO(pewg);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增批而未供
|
|
|
+ */
|
|
|
+ @PostMapping("/add")
|
|
|
+ public boolean addPewg(@RequestBody PewgVO pewgVO) {
|
|
|
+ Pewg pewg = new Pewg();
|
|
|
+ BeanUtils.copyProperties(pewgVO, pewg);
|
|
|
+ return pewgService.save(pewg);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新批而未供
|
|
|
+ */
|
|
|
+ @PutMapping("/update")
|
|
|
+ public boolean updatePewg(@RequestBody PewgVO pewgVO) {
|
|
|
+ if (pewgVO.getObjectid() == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ Pewg pewg = new Pewg();
|
|
|
+ BeanUtils.copyProperties(pewgVO, pewg);
|
|
|
+ return pewgService.updateById(pewg);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除批而未供
|
|
|
+ */
|
|
|
+ @DeleteMapping("/{id}")
|
|
|
+ public boolean deletePewg(@PathVariable Integer id) {
|
|
|
+ return pewgService.removeById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除批而未供
|
|
|
+ */
|
|
|
+ @DeleteMapping("/batch")
|
|
|
+ public boolean batchDeletePewg(@RequestBody List<Integer> ids) {
|
|
|
+ return pewgService.removeByIds(ids);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将实体对象转换为VO对象
|
|
|
+ */
|
|
|
+ private PewgVO convertToVO(Pewg pewg) {
|
|
|
+ if (pewg == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ PewgVO vo = new PewgVO();
|
|
|
+ BeanUtils.copyProperties(pewg, vo);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+}
|