rk
2025-09-22 be643d854741ac1869ee77cdba3df51de39ffe3d
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
package com.doumee.api.business;
 
import com.alibaba.fastjson.JSONObject;
import com.doumee.api.BaseController;
import com.doumee.core.annotation.excel.ExcelExporter;
import com.doumee.core.annotation.pr.PreventRepeat;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.model.ApiResponse;
import com.doumee.core.model.LoginUserInfo;
import com.doumee.core.model.PageWrap;
import com.doumee.core.model.PageData;
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.DateUtil;
import com.doumee.dao.business.model.*;
import com.doumee.dao.system.dto.ExpertReportDTO;
import com.doumee.dao.system.vo.CompanyDeclaresVo;
import com.doumee.service.business.CompanyEconomicsService;
import com.doumee.service.business.DeclaresService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
 
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
 
/**
 * @author 江蹄蹄
 * @date 2023/02/15 08:55
 */
@Api(tags = "企业项目报名信息表")
@RestController
@RequestMapping("/business/declares")
public class DeclaresController extends BaseController {
 
    @Autowired
    private DeclaresService declaresService;
    @Autowired
    private CompanyEconomicsService companyEconomicsService;
 
    @PreventRepeat
    @ApiOperation("企业报名保存提交")
    @PostMapping("/create")
    @RequiresPermissions("business:declares:create")
    public ApiResponse create(@RequestBody Declares declares) {
            declaresService.create(declares);
        return ApiResponse.success(null);
    }
    @PreventRepeat
    @ApiOperation("更改报名记录诊断类型")
    @PostMapping("/updateDiagnoseType")
    @RequiresPermissions("business:declares:update")
    public ApiResponse updateDiagnoseType(@RequestBody Declares declares) {
            declaresService.updateDiagnoseType(declares);
        return ApiResponse.success(null);
    }
 
    @ApiOperation("根据ID删除")
    @GetMapping("/delete/{id}")
    @RequiresPermissions("business:declares:delete")
    public ApiResponse deleteById(@PathVariable Integer id) {
        declaresService.deleteById(id);
        return ApiResponse.success(null);
    }
 
    @ApiOperation("批量删除")
    @GetMapping("/delete/batch")
    @RequiresPermissions("business:declares:delete")
    public ApiResponse deleteByIdInBatch(@RequestParam String ids) {
        String [] idArray = ids.split(",");
        List<Integer> idList = new ArrayList<>();
        for (String id : idArray) {
            idList.add(Integer.valueOf(id));
        }
        declaresService.deleteByIdInBatch(idList);
        return ApiResponse.success(null);
    }
 
    @ApiOperation("根据ID修改")
    @PostMapping("/updateById")
    @RequiresPermissions("business:declares:update")
    public ApiResponse updateById(@RequestBody Declares declares) {
        declaresService.updateById(declares);
        return ApiResponse.success(null);
    }
 
    @ApiOperation("分页查询")
    @PostMapping("/page")
    @RequiresPermissions("business:declares:query")
    public ApiResponse<PageData<Declares>> findPage (@RequestBody PageWrap<Declares> pageWrap) {
        return ApiResponse.success(declaresService.findPage(pageWrap));
    }
 
    @ApiOperation("导出Excel")
    @PostMapping("/exportExcel")
    @RequiresPermissions("business:declares:exportExcel")
    public void exportExcel (@RequestBody PageWrap<Declares> pageWrap, HttpServletResponse response) throws Exception {
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        String exportName="企业列表"+DateUtil.getNowLongTime();
 
        List<Declares> list=declaresService.exportExcel(pageWrap);
 
        List<DeclaresArea> arealist=new ArrayList<>();
        List<DeclaresSJ> declaresSJList=new ArrayList<>();
        List<DeclaresFW> declaresFWList=new ArrayList<>();
        List<DeclaresSystem> declaresSystemList=new ArrayList<>();
        if(Constants.equalsInteger(user.getType(),Constants.UserType.AREA.getKey())){
            //县区用户
            if(list.size()>0){
                for(int i=0;i<list.size();i++){
                    Declares declares=list.get(i);
                    DeclaresArea declaresArea=new DeclaresArea();
                    BeanUtils.copyProperties(declares, declaresArea);
                    declaresArea.setCreateDate( DateUtil.getPlusTime(declares.getCreateDate()));
                    declaresArea.setDeclareStatus(Constants.DeclareStatus.getInfo(declares.getStatus()));
                    arealist.add(declaresArea);
                }
            }
            ExcelExporter.build(DeclaresArea.class).export(arealist, exportName, response);
        }else  if(Constants.equalsInteger(user.getType(),Constants.UserType.SJ.getKey())){
            //市经信局
            if(list.size()>0){
                for(int i=0;i<list.size();i++){
                    Declares declares=list.get(i);
                    DeclaresSJ declaresSJ=new DeclaresSJ();
                    BeanUtils.copyProperties(declares, declaresSJ);
                    declaresSJ.setDeclareStatus(Constants.DeclareStatus.getInfo(declares.getStatus()));
                    declaresSJList.add(declaresSJ);
                }
            }
            ExcelExporter.build(DeclaresSJ.class).export(declaresSJList, exportName, response);
        }else if(Constants.equalsInteger(user.getType(),Constants.UserType.SD_ADMIN.getKey())||
                Constants.equalsInteger(user.getType(),Constants.UserType.SD_CHILD.getKey())){
            //综合服务单位
            List<DeclaresAdmin> declaresAdminList=new ArrayList<>();
            if(list.size()>0){
                if(list.size()>0){
                    for(int i=0;i<list.size();i++){
                        Declares declares=list.get(i);
                        DeclaresAdmin declaresAdmin=new DeclaresAdmin();
                        BeanUtils.copyProperties(declares, declaresAdmin);
                        declaresAdmin.setDeclareStatus(Constants.DeclareStatus.getInfo(declares.getStatus()));
                        declaresAdminList.add(declaresAdmin);
                    }
                }
            }
            ExcelExporter.build(DeclaresAdmin.class).export(declaresAdminList, exportName, response);
 
        }else if(Constants.equalsInteger(user.getType(),Constants.UserType.SO_ADMIN.getKey())||
                Constants.equalsInteger(user.getType(),Constants.UserType.SO_CHILD.getKey())){
            //服务机构
            if(list.size()>0){
                if(list.size()>0){
                    for(int i=0;i<list.size();i++){
                        Declares declares=list.get(i);
                        DeclaresFW declaresFW=new DeclaresFW();
                        BeanUtils.copyProperties(declares, declaresFW);
                        declaresFW.setDeclareStatus(Constants.DeclareStatus.getInfo(declares.getStatus()));
                        declaresFWList.add(declaresFW);
                    }
                }
            }
            ExcelExporter.build(DeclaresFW.class).export(declaresFWList, exportName  , response);
 
        }else if(Constants.equalsInteger(user.getType(),Constants.UserType.SYSTEM.getKey())){
            //system
            if(list.size()>0){
                if(list.size()>0){
                    for(int i=0;i<list.size();i++){
                        Declares declares=list.get(i);
                        DeclaresSystem declaresSystem = new DeclaresSystem();
                        BeanUtils.copyProperties(declares, declaresSystem);
 
                        declaresSystem.setDeclareStatus(Constants.DeclareStatus.getInfo(declares.getStatus()));
                        declaresSystemList.add(declaresSystem);
                    }
                }
            }
            ExcelExporter.build(DeclaresSystem.class).export(declaresSystemList, exportName, response);
        }else if(Constants.equalsInteger(user.getType(),Constants.UserType.EXPERT.getKey())){
            //专家
            if(list.size()>0){
                if(list.size()>0){
                    for(int i=0;i<list.size();i++){
                        Declares declares=list.get(i);
                        DeclaresFW declaresFW=new DeclaresFW();
                        BeanUtils.copyProperties(declares, declaresFW);
                        declaresFW.setDeclareStatus(Constants.DeclareStatus.getInfo(declares.getStatus()));
                        declaresFWList.add(declaresFW);
                    }
                }
            }
            ExcelExporter.build(DeclaresFW.class).export(declaresFWList, exportName, response);
 
        }
    }
 
    @ApiOperation("导出Excel,针对某个项目")
    @PostMapping("/exportExcelForProject")
    @RequiresPermissions("business:declares:exportExcel")
    public void exportExcelForProject (@RequestBody PageWrap<Declares> pageWrap, HttpServletResponse response) throws Exception {
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
 
        List<DeclaresAdminForProject> arealist=new ArrayList<>();
        List<DeclaresFWForProjet> declaresFWList=new ArrayList<>();
        if(Constants.equalsInteger(user.getType(),Constants.UserType.SO_ADMIN.getKey())||
                Constants.equalsInteger(user.getType(),Constants.UserType.SO_CHILD.getKey())){
            //服务机构
            pageWrap.getModel().setQueryFlag(Constants.ZERO);
            List<Declares> list=declaresService.exportExcelForProject(pageWrap);
            if(list.size()>0){
                if(list.size()>0){
                    for(int i=0;i<list.size();i++){
                        Declares declares=list.get(i);
                        DeclaresFWForProjet declaresFW=new DeclaresFWForProjet();
                        BeanUtils.copyProperties(declares, declaresFW);
                        declaresFW.setIndex(i+1);
                        declaresFW.setRemark("");
//                        declaresFW.setLevelName(declares.getDiagnoseType());
                        declaresFW.setScore(declares.getRoleScore());
                        declaresFW.setPrice(declares.getServicePrice2());
                        declaresFW.setDeclareStatus(Constants.DeclareStatus.getInfo(declares.getStatus()));
                        declaresFWList.add(declaresFW);
                    }
                }
            }
            ExcelExporter.build(DeclaresFWForProjet.class).exportWithFirstAndEnd(declaresFWList, pageWrap.getModel().getProjectName()+"-诊断汇总表"+DateUtil.getNowLongTime(),null,pageWrap.getModel().getProjectName()+"-诊断汇总表",null, response);
 
        }else{
            //system
            pageWrap.getModel().setQueryFlag(Constants.ONE);
            List<Declares> list=declaresService.exportExcelForProject(pageWrap);
            if(list.size()>0){
                if(list.size()>0){
                    for(int i=0;i<list.size();i++){
                        Declares declares=list.get(i);
                        DeclaresAdminForProject declaresSystem = new DeclaresAdminForProject();
                        BeanUtils.copyProperties(declares, declaresSystem);
                        String ec = declares.getEconomics();
                        declaresSystem.setIndex(i+1);
                        declaresSystem.setLastYearIncome("-");
                        declaresSystem.setTotalProfit("-");
                        declaresSystem.setRemark("");
//                        declaresSystem.setLevelName(declares.getDiagnoseType());
                        declaresSystem.setScore(Constants.formatBigdecimal(declares.getRoleScore()).setScale(2, BigDecimal.ROUND_HALF_UP));
                        declaresSystem.setPrice(Constants.formatBigdecimal(declares.getServicePrice2()).setScale(2,BigDecimal.ROUND_HALF_UP));
                        if(StringUtils.isNotBlank(ec)){
                            String[] ess = ec.split("&&");
                            if(ess.length==2){
                                declaresSystem.setLastYearIncome(ess[0]);
                                declaresSystem.setTotalProfit(ess[1]);
                            }
                        }
                        declaresSystem.setDeclareStatus(Constants.DeclareStatus.getInfo(declares.getStatus()));
                        arealist.add(declaresSystem);
                    }
                }
            }
            ExcelExporter.build(DeclaresAdminForProject.class).exportWithFirstAndEnd(arealist, pageWrap.getModel().getProjectName()+"-诊断汇总表"+DateUtil.getNowLongTime(),null,pageWrap.getModel().getProjectName()+"-诊断汇总表",null, response);
        }
 
    }
 
    @ApiOperation("根据ID查询")
    @GetMapping("/{id}")
    @RequiresPermissions("business:declares:query")
    public ApiResponse<Declares>  findById(@PathVariable Integer id) {
        return ApiResponse.success(declaresService.findById(id));
    }
 
    @ApiOperation("根据项目projectId查询报名详情")
    @GetMapping("/findByProjectId")
    @RequiresPermissions("business:declares:query")
    public ApiResponse<Declares> findByProjectId( Integer projectId) {
        return ApiResponse.success(declaresService.findByProjectId(projectId));
    }
 
    @ApiOperation("企业报名详情选择服务机构保存")
    @PostMapping("/chooseService")
    @RequiresPermissions("business:declares:chooseService")
    public ApiResponse chooseService(@RequestBody Declares declares) {
        declaresService.chooseService(declares);
        return ApiResponse.success(null);
    }
 
    @ApiOperation("根据项目id分页查询企业报名数据")
    @PostMapping("/getPageByProjectId")
    @RequiresPermissions("business:declares:getPageByProjectId")
    public ApiResponse<PageData<Declares>> getPageByProjectId (@RequestBody PageWrap<Declares> pageWrap) {
        return ApiResponse.success(declaresService.getPageByProjectId(pageWrap));
    }
 
    @ApiOperation("县区企业审核")
    @PostMapping("/areaToExamine")
    @RequiresPermissions("business:declares:areaToExamine")
    public ApiResponse areaToExamine (@RequestBody Declares declares) {
          declaresService.areaToExamine(declares);
        return ApiResponse.success(null);
    }
 
 
    @ApiOperation("分配服务机构保存")
    @PostMapping("/distributionServiceSave")
    @RequiresPermissions("business:declares:distributionServiceSave")
    public ApiResponse distributionServiceSave (@RequestBody Declares declares) {
            declaresService.distributionServiceSave(declares);
        return ApiResponse.success(null);
    }
 
 
    @ApiOperation("综合服务单位分配给子账号")
    @PostMapping("/distributionChildAccount")
    @RequiresPermissions("business:declares:distributionChildAccount")
    public ApiResponse  distributionChildAccount(@RequestBody Declares declares){
        declaresService.distributionChildAccount(declares);
        return ApiResponse.success(null);
    }
 
/*
    @ApiOperation("综合服务单位分配给子账号")
    @PostMapping("/distriZHChildAccount")
    @RequiresPermissions("business:declares:distriZHChildAccount")
    public ApiResponse distriZHChildAccount (@RequestBody Declares declares) {
        try{
            declaresService.distriZHChildAccount(declares);
        }catch (BusinessException e){
            return ApiResponse.failed(e.getMessage());
        }
        return ApiResponse.success(null);
    }
 
    @ApiOperation("服务机构分配给子账号")
    @PostMapping("/distriServiceChildAccount")
    @RequiresPermissions("business:declares:distriServiceChildAccount")
    public ApiResponse distriServiceChildAccount (@RequestBody Declares declares) {
        try{
            declaresService.distriServiceChildAccount(declares);
        }catch (BusinessException e){
            return ApiResponse.failed(e.getMessage());
        }
        return ApiResponse.success(null);
    }     */
 
 
    @ApiOperation("服务机构确认/拒绝服务")
    @PostMapping("/confirmService")
    @RequiresPermissions("business:declares:confirmService")
    public ApiResponse confirmService (@RequestBody Declares declares) {
            declaresService.confirmService(declares);
        return ApiResponse.success(null);
    }
 
 
    @ApiOperation("查询项目报名企业")
    @PostMapping("/findCompanyDeclaresVoPage")
    @RequiresPermissions("business:declares:findCompanyDeclaresVoPage")
    public ApiResponse<PageData<CompanyDeclaresVo>> findCompanyDeclaresVoPage(PageWrap<Declares> pageWrap){
        PageData<CompanyDeclaresVo> companyDeclaresVoPage = declaresService.findCompanyDeclaresVoPage(pageWrap);
        return ApiResponse.success(companyDeclaresVoPage);
    }
 
 
    @ApiOperation("专家打分")
    @PostMapping("/checkExpertDeclares")
    @RequiresPermissions("business:declares:checkExpertDeclares")
    public ApiResponse checkExpertDeclares(@RequestBody ExpertReportDTO expertReportDTO){
        declaresService.checkExpertDeclares(expertReportDTO);
        return ApiResponse.success(null);
    }
}