zhuguifei
2025-04-28 442928123f63ee497d766f9a7a14f0a6ee067e25
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package org.jeecg.modules.bonus.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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.bonus.entity.BonusAllocation;
import org.jeecg.modules.bonus.entity.BonusPayment;
import org.jeecg.modules.bonus.entity.BonusPaymentItem;
import org.jeecg.modules.bonus.service.IBonusAllocationService;
import org.jeecg.modules.bonus.service.IBonusPaymentItemService;
import org.jeecg.modules.bonus.service.IBonusPaymentService;
import org.jeecg.modules.project.entity.ProProject;
import org.jeecg.modules.project.service.IProProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
 
@Slf4j
@Api(tags = "奖金分配表")
@RestController
@RequestMapping("/bon/alloca")
public class BonusAllocationController extends JeecgController<BonusAllocation, IBonusAllocationService> {
    @Autowired
    private IBonusPaymentService bonusPaymentService;
 
    @Autowired
    private IProProjectService projectService;
 
    @Autowired
    private IBonusPaymentItemService paymentItemService;
 
    @Autowired
    private IBonusAllocationService allocationService;
 
 
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public Result<IPage<BonusAllocation>> queryPageList(BonusAllocation allocation, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                       @RequestParam(name = "pageSize", defaultValue = "100") Integer pageSize, HttpServletRequest req) {
        Result<IPage<BonusAllocation>> result = new Result<IPage<BonusAllocation>>();
        //没有分配明细id(bonus_payment_item)不查询
        if (allocation.getPid() == null) return result;
        QueryWrapper<BonusAllocation> queryWrapper = QueryGenerator.initQueryWrapper(allocation, req.getParameterMap());
        Page<BonusAllocation> page = new Page<BonusAllocation>(pageNo, pageSize);
        IPage<BonusAllocation> pageList = allocationService.page(page, queryWrapper);
        result.setSuccess(true);
        result.setResult(pageList);
        return result;
    }
 
 
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @AutoLog(value = "添加里程碑分配明细")
    @Transactional
    public Result<BonusPaymentItem> add(@RequestBody BonusPaymentItem paymentItem, HttpServletRequest request) {
        Result<BonusPaymentItem> result = new Result<BonusPaymentItem>();
        //主要更新项目成员,以及分配总额以及总配总比例
        paymentItemService.updateById(paymentItem);
        //新增明细前删除历史明细
        String id = paymentItem.getId();
        Map<String,Object> map  = new HashMap<>();
        map.put("pid",id);
        allocationService.removeByMap(map);
 
        List<BonusAllocation> allocationList = paymentItem.getAllocationList();
        String userNames = "";
        //保存分配明细
        for (int i = 0; i < allocationList.size(); i++) {
            BonusAllocation bonusAllocation = allocationList.get(i);
            bonusAllocation.setPid(paymentItem.getId());
            bonusAllocation.setPpid(paymentItem.getPid());
            bonusAllocation.setPro(paymentItem.getPro());
            allocationService.save(bonusAllocation);
        }
 
        result.success("添加成功!");
        result.setResult(paymentItem);
        return result;
    }
 
 
 
 
/*
    @RequestMapping(value = "/edit", method = RequestMethod.PUT)
    public Result<ProProject> edit(@RequestBody ProProject project) {
        Result<ProProject> result = new Result<ProProject>();
        proProjectService.updateProject(project);
        result.success("修改成功!");
        result.setResult(project);
        return result;
    }
*/
 
 
 
 
}