刘光辉
14 小时以前 34981c30a78e8bbd7791131059a9210f9928b62c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package jnpf.limsController;
 
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jnpf.limsEntity.ZhiliangBiaozhunGuanliEntity;
import jnpf.limsService.ZhiliangBiaozhunGuanliService;
import jnpf.util.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.Map;
 
@Slf4j
@Tag(name = "lims后台基础配置接口", description = "质量标准等基础配置查询入口")
@RestController
@RequestMapping("/lims/biz/config")
public class LimsBizConfigController {
 
    @Autowired
    private ZhiliangBiaozhunGuanliService zhiliangBiaozhunGuanliService;
 
    // ======================== 质量标准 ========================
 
    /**
     * 通过样品 ID 查询质量标准(单条)
     */
    @Operation(summary = "通过样品ID查询质量标准")
    @GetMapping("/zhiliang-biaozhun/get-by-yangpin-id")
    public R<ZhiliangBiaozhunGuanliEntity> getZhiliangBiaozhunByYangpinId(
            @RequestParam("yangpinId") String yangpinId) {
        if (yangpinId == null || yangpinId.isEmpty()) {
            return R.error("样品ID不能为空");
        }
        ZhiliangBiaozhunGuanliEntity entity = zhiliangBiaozhunGuanliService.findByYangpinId(yangpinId);
        if (entity == null) {
            return R.error("未找到对应的质量标准数据");
        }
        return R.success(entity);
    }
 
    /**
     * 质量标准版本升级:把传入的 formData(主表 + 动态 tableFieldXxxxxx 子表)整体复制为新一份,
     * 新主表 biz_enabled=disabled,新子表 f_foreign_id 关联新主表 f_id,历史数据不动。
     */
    @Operation(summary = "质量标准版本升级")
    @PostMapping("/zhiliang-biaozhun/version-upgrade")
    public R<String> versionUpgradeZhiliangBiaozhun(@RequestBody Map<String, Object> formData) {
        String newId = zhiliangBiaozhunGuanliService.versionUpgrade(formData);
        if (newId == null) {
            return R.success();
        }
        return R.success("升级成功", newId);
    }
}