瑞利声电固定资产管理系统
ycq
2026-10-16 dbbadb021c2fc171466cc82bd9a7a82cc47165f5
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
61
62
63
64
65
66
67
68
69
70
71
72
73
package zbooksoft.fams.controller;
 
import com.ruili.wcp.web.model.AjaxResponse;
import com.ruili.wcp.web.model.ErrorInfo;
import org.apache.shiro.authz.annotation.RequiresUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import zbooksoft.fams.service.AssetApplyService;
import zbooksoft.fams.service.AssetApplyService.BillType;
 
/**
 * 资产使用流程单据的选择资产弹窗
 * @author ycq
 * @date 2026-10-16
 */
@Controller
@RequestMapping("/fams/apply")
public class AssetApplyController {
 
    @Autowired
    private AssetApplyService assetApplyService;
 
    /**
     * 选择资产弹窗页面
     * @param billType 单据类型枚举名,如 BORROW
     * @return 弹窗视图
     */
    @RequestMapping(value = "/pickAssets", method = RequestMethod.GET)
    @RequiresUser
    public ModelAndView pickAssets(@RequestParam String billType) {
        BillType type = parseType(billType);
        ModelAndView mv = new ModelAndView("fams/apply/pickAssets");
        mv.addObject("billType", type == null ? "" : type.name());
        mv.addObject("billTitle", type == null ? "" : type.getTitle());
        mv.addObject("maxAssets", AssetApplyService.MAX_ASSETS_PER_BILL);
        mv.addObject("maxCandidates", AssetApplyService.MAX_CANDIDATES);
        return mv;
    }
 
    /**
     * 查可选资产
     * @param billType 单据类型枚举名
     * @param sealType 封存解封单的办理类型
     * @param keyword 关键字
     * @param billNo 当前单据编号
     * @return 候选资产
     */
    @RequestMapping(value = "/candidates", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    @ResponseBody
    @RequiresUser
    public Object candidates(@RequestParam String billType, @RequestParam(required = false) String sealType,
                             @RequestParam(required = false) String keyword, @RequestParam(required = false) String billNo) {
        BillType type = parseType(billType);
        if (type == null) {
            return new AjaxResponse(new ErrorInfo("单据类型不正确"), false);
        }
        return new AjaxResponse(assetApplyService.listCandidates(type, sealType, keyword, billNo));
    }
 
    private static BillType parseType(String billType) {
        for (BillType type : BillType.values()) {
            if (type.name().equals(billType)) {
                return type;
            }
        }
        return null;
    }
}