|
|
@@ -1,9 +1,16 @@
|
|
|
package com.ruoyi.web.controller;
|
|
|
|
|
|
+import java.text.DecimalFormat;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.ruoyi.web.domain.CgYmq;
|
|
|
+import com.ruoyi.web.service.ICgYmqService;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
@@ -27,7 +34,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
* 采购信息Controller
|
|
|
*
|
|
|
* @author shenzx
|
|
|
- * @date 2025-09-26
|
|
|
+ * @date 2025-09-28
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/cg/info")
|
|
|
@@ -39,10 +46,35 @@ public class CgInfoController extends BaseController
|
|
|
this.cgInfoService = cgInfoService;
|
|
|
}
|
|
|
|
|
|
+ private ICgYmqService cgYmqService;
|
|
|
+ @Autowired
|
|
|
+ public void setCgYmqService(ICgYmqService cgYmqService) {
|
|
|
+ this.cgYmqService = cgYmqService;
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("cgpc")
|
|
|
+ @ApiOperation("获取采购批次")
|
|
|
+ public AjaxResult cgpc(String splx){
|
|
|
+ QueryWrapper<CgInfo> qw = new QueryWrapper<>();
|
|
|
+ qw.lambda().eq(CgInfo::getSplx,splx).orderByDesc(CgInfo::getCgsj);
|
|
|
+ return success(cgInfoService.list(qw));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询采购信息全部列表
|
|
|
+ */
|
|
|
+ @GetMapping("/all")
|
|
|
+ public AjaxResult all(CgInfo cgInfo)
|
|
|
+ {
|
|
|
+ QueryWrapper<CgInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.setEntity(cgInfo);
|
|
|
+ List<CgInfo> cgInfoList = cgInfoService.list(queryWrapper);
|
|
|
+ return success(cgInfoList);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询采购信息列表
|
|
|
*/
|
|
|
- @PreAuthorize("@ss.hasPermi('cg:info:list')")
|
|
|
@GetMapping("/list")
|
|
|
public TableDataInfo list(CgInfo cgInfo)
|
|
|
{
|
|
|
@@ -56,7 +88,6 @@ public class CgInfoController extends BaseController
|
|
|
/**
|
|
|
* 导出采购信息列表
|
|
|
*/
|
|
|
- @PreAuthorize("@ss.hasPermi('cg:info:export')")
|
|
|
@Log(title = "采购信息", businessType = BusinessType.EXPORT)
|
|
|
@PostMapping("/export")
|
|
|
public void export(HttpServletResponse response, CgInfo cgInfo)
|
|
|
@@ -71,45 +102,70 @@ public class CgInfoController extends BaseController
|
|
|
/**
|
|
|
* 获取采购信息详细信息
|
|
|
*/
|
|
|
- @PreAuthorize("@ss.hasPermi('cg:info:query')")
|
|
|
@GetMapping(value = "/{id}")
|
|
|
public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
|
{
|
|
|
- return success(cgInfoService.getById(id));
|
|
|
+ CgInfo cgInfo = cgInfoService.getById(id);
|
|
|
+ QueryWrapper<CgYmq> cyQW = new QueryWrapper<>();
|
|
|
+ cyQW.lambda().eq(CgYmq::getFid,cgInfo.getId());
|
|
|
+ cgInfo.setCgYmq(cgYmqService.getOne(cyQW));
|
|
|
+ return success(cgInfo);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新增采购信息
|
|
|
*/
|
|
|
- @PreAuthorize("@ss.hasPermi('cg:info:add')")
|
|
|
@Log(title = "采购信息", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
|
public AjaxResult add(@RequestBody CgInfo cgInfo)
|
|
|
{
|
|
|
cgInfoService.save(cgInfo);
|
|
|
+
|
|
|
+ CgYmq cgYmq = cgInfo.getCgYmq();
|
|
|
+ if (Objects.nonNull(cgYmq)) {
|
|
|
+ cgYmq.setFid(cgInfo.getId());
|
|
|
+ cgYmqService.save(cgYmq);
|
|
|
+ }
|
|
|
return success(cgInfo);
|
|
|
}
|
|
|
|
|
|
+ private String genCgpc(String splx){
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ DecimalFormat splxFormat = new DecimalFormat("00");
|
|
|
+ DecimalFormat xhFormat = new DecimalFormat("0000");
|
|
|
+ QueryWrapper<CgInfo> qw = new QueryWrapper<>();
|
|
|
+ qw.lambda().select(CgInfo::getCgpc).orderByDesc(CgInfo::getCgpc);
|
|
|
+ List<CgInfo> list = cgInfoService.list(qw);
|
|
|
+ String cgpc = list.get(0).getCgpc();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 修改采购信息
|
|
|
*/
|
|
|
- @PreAuthorize("@ss.hasPermi('cg:info:edit')")
|
|
|
@Log(title = "采购信息", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
|
public AjaxResult edit(@RequestBody CgInfo cgInfo)
|
|
|
{
|
|
|
cgInfoService.updateById(cgInfo);
|
|
|
+ CgYmq cgYmq = cgInfo.getCgYmq();
|
|
|
+ if(Objects.nonNull(cgYmq)) {
|
|
|
+ cgYmq.setFid(cgInfo.getId());
|
|
|
+ cgYmqService.saveOrUpdate(cgYmq);
|
|
|
+ }
|
|
|
return success(cgInfo);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除采购信息
|
|
|
*/
|
|
|
- @PreAuthorize("@ss.hasPermi('cg:info:remove')")
|
|
|
@Log(title = "采购信息", businessType = BusinessType.DELETE)
|
|
|
@DeleteMapping("/{ids}")
|
|
|
public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
{
|
|
|
+ QueryWrapper<CgYmq> cyQW = new QueryWrapper<>();
|
|
|
+ cyQW.lambda().in(CgYmq::getFid,Arrays.asList(ids));
|
|
|
+ cgYmqService.remove(cyQW);
|
|
|
return toAjax(cgInfoService.removeByIds(Arrays.asList(ids)));
|
|
|
}
|
|
|
}
|