doum
2025-09-08 863ec3280a6376c39a51144e1731c548300539ca
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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
package com.doumee.service.business.impl;
 
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.model.LoginUserInfo;
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.Utils;
import com.doumee.dao.business.CompanyChangeJoinMapper;
import com.doumee.dao.business.CompanyChangeMapper;
import com.doumee.dao.business.CompanyMapper;
import com.doumee.dao.business.MultifileMapper;
import com.doumee.dao.business.model.*;
import com.doumee.dao.system.SystemUserMapper;
import com.doumee.dao.system.model.SystemUser;
import com.doumee.service.business.AreasService;
import com.doumee.service.business.CompanyChangeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.doumee.service.business.CompanyService;
import com.doumee.service.business.MultifileService;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
 
import javax.validation.constraints.NotNull;
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * 企业变更信息记录表Service实现
 * @author 江蹄蹄
 * @date 2023/02/15 08:55
 */
@Service
public class CompanyChangeServiceImpl implements CompanyChangeService {
 
    @Autowired
    private CompanyChangeMapper companyChangeMapper;
 
    @Autowired
    CompanyChangeJoinMapper companyChangeJoinMapper;
 
    @Autowired
    CompanyMapper companyMapper;
 
    @Lazy
    @Autowired
    CompanyService companyService;
 
    @Autowired
    AreasService areasService;
 
 
    @Autowired
    private MultifileService multifileService;
 
    @Autowired
    private MultifileMapper multifileMapper;
 
    @Autowired
    SystemUserMapper systemUserMapper;
 
    @Autowired
    SystemDictDataBiz systemDictDataBiz;
 
    @Override
    public Integer create(CompanyChange companyChange) {
        if(
              StringUtils.isBlank(companyChange.getName())||
                      companyChange.getAreaId()==null||
                      companyChange.getCityId()==null||
                      StringUtils.isBlank(companyChange.getCreditCode())||
                      StringUtils.isBlank(companyChange.getLegalPerson())||
                      CollectionUtils.isEmpty(companyChange.getFileList()) ||
                      CollectionUtils.isEmpty(companyChange.getChangeFileList())
        ){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "请按要求填写变更信息");
        }
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        Company company = companyMapper.selectById(user.getCompanyId());
 
        deleteOldChanceByCompanyId(companyChange.getCompanyId());
 
        if (Objects.isNull(company)){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,企业信息不存在!");
        }
        companyChange.setStatus(Constants.ZERO);//待审核
        companyChange.setIsdeleted(Constants.ZERO);
        companyChange.setCreateDate(new Date());
        companyChange.setCreator(user.getId());
        companyChange.setCompanyId(user.getCompanyId());
        companyChangeMapper.insert(companyChange);
 
        //更新文件表
        //添加营业执照
        if (!CollectionUtils.isEmpty(companyChange.getFileList())){
            companyChange.getFileList().stream().forEach(s->{
 
                if(StringUtils.isEmpty(s.getFileurl())){
                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "请上传营业执照!");
                }
                Multifile multifile = new Multifile();
                multifile.setIsdeleted(Constants.ZERO);
                multifile.setCreateDate(new Date());
                multifile.setObjId(companyChange.getId());
                multifile.setType(Constants.ZERO);
                multifile.setObjType(Constants.MultiFile.COMPANY_CHANGE_LICENSE.getKey());
                multifile.setName(s.getName());
                multifile.setFileurl(s.getFileurl());
                multifile.setType(s.getType());
                multifileService.create(multifile);
            });
        }
 
        //添加工商变更登记图
        if(org.apache.commons.collections.CollectionUtils.isNotEmpty(companyChange.getChangeFileList())){
            companyChange.getChangeFileList().stream().forEach(s -> {
                if(StringUtils.isEmpty(s.getFileurl())){
                   return;
                }
                s.setIsdeleted(Constants.ZERO);
                s.setCreateDate(new Date());
                s.setObjId(companyChange.getId());
                s.setType(Constants.ZERO);
                s.setObjType(Constants.MultiFile.COMPANY_CHANGE_CHANGE.getKey());
                multifileService.create(s);
            });
 
        }
 
        return companyChange.getId();
    }
 
 
    private void deleteOldChanceByCompanyId(Integer companyId){
        CompanyChange companyChange = new CompanyChange();
        companyChange.setCompanyId(companyId);
        companyChange.setStatus(Constants.ZERO);
        UpdateWrapper<CompanyChange> deleteWrapper = new UpdateWrapper<>(companyChange);
        companyChangeMapper.delete(deleteWrapper);
 
    }
    @Override
    public void deleteById(Integer id) {
        companyChangeMapper.deleteById(id);
    }
 
    @Override
    public void delete(CompanyChange companyChange) {
        UpdateWrapper<CompanyChange> deleteWrapper = new UpdateWrapper<>(companyChange);
        companyChangeMapper.delete(deleteWrapper);
    }
 
    @Override
    public void deleteByIdInBatch(List<Integer> ids) {
        if (CollectionUtils.isEmpty(ids)) {
            return;
        }
        companyChangeMapper.deleteBatchIds(ids);
    }
 
    @Override
    public void updateById(CompanyChange companyChange) {
        companyChangeMapper.updateById(companyChange);
    }
 
    @Override
    public void updateByIdInBatch(List<CompanyChange> companyChanges) {
        if (CollectionUtils.isEmpty(companyChanges)) {
            return;
        }
        for (CompanyChange companyChange: companyChanges) {
            this.updateById(companyChange);
        }
    }
 
    @Override
    public CompanyChange findById(Integer id) {
        return companyChangeMapper.selectById(id);
    }
 
    @Override
    public CompanyChange findOne(CompanyChange companyChange) {
        QueryWrapper<CompanyChange> wrapper = new QueryWrapper<>(companyChange);
        return companyChangeMapper.selectOne(wrapper);
    }
 
    @Override
    public List<CompanyChange> findList(CompanyChange companyChange) {
        QueryWrapper<CompanyChange> wrapper = new QueryWrapper<>(companyChange);
        return companyChangeMapper.selectList(wrapper);
    }
  
    @Override
    public PageData<CompanyChange> findPage(PageWrap<CompanyChange> pageWrap) {
        IPage<CompanyChange> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
        QueryWrapper<CompanyChange> queryWrapper = new QueryWrapper<>();
        Utils.MP.blankToNull(pageWrap.getModel());
        if (pageWrap.getModel().getId() != null) {
            queryWrapper.lambda().eq(CompanyChange::getId, pageWrap.getModel().getId());
        }
 
        if (pageWrap.getModel().getCreator() != null) {
            queryWrapper.lambda().eq(CompanyChange::getCreator, pageWrap.getModel().getCreator());
        }
        if (pageWrap.getModel().getCreateDate() != null) {
            queryWrapper.lambda().ge(CompanyChange::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate()));
            queryWrapper.lambda().le(CompanyChange::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate()));
        }
        if (pageWrap.getModel().getEditor() != null) {
            queryWrapper.lambda().eq(CompanyChange::getEditor, pageWrap.getModel().getEditor());
        }
        if (pageWrap.getModel().getEditDate() != null) {
            queryWrapper.lambda().ge(CompanyChange::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate()));
            queryWrapper.lambda().le(CompanyChange::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate()));
        }
        if (pageWrap.getModel().getIsdeleted() != null) {
            queryWrapper.lambda().eq(CompanyChange::getIsdeleted, pageWrap.getModel().getIsdeleted());
        }
        if (pageWrap.getModel().getCompanyId() != null) {
            queryWrapper.lambda().eq(CompanyChange::getCompanyId, pageWrap.getModel().getCompanyId());
        }
        if (pageWrap.getModel().getName() != null) {
            queryWrapper.lambda().eq(CompanyChange::getName, pageWrap.getModel().getName());
        }
        if (pageWrap.getModel().getRemark() != null) {
            queryWrapper.lambda().eq(CompanyChange::getRemark, pageWrap.getModel().getRemark());
        }
        if (pageWrap.getModel().getLegalPerson() != null) {
            queryWrapper.lambda().eq(CompanyChange::getLegalPerson, pageWrap.getModel().getLegalPerson());
        }
        if (pageWrap.getModel().getAreaId() != null) {
            queryWrapper.lambda().eq(CompanyChange::getAreaId, pageWrap.getModel().getAreaId());
        }
        if (pageWrap.getModel().getCityId() != null) {
            queryWrapper.lambda().eq(CompanyChange::getCityId, pageWrap.getModel().getCityId());
        }
        if (pageWrap.getModel().getCreditCode() != null) {
            queryWrapper.lambda().eq(CompanyChange::getCreditCode, pageWrap.getModel().getCreditCode());
        }
        if (pageWrap.getModel().getStatus() != null) {
            queryWrapper.lambda().eq(CompanyChange::getStatus, pageWrap.getModel().getStatus());
        }
        if (pageWrap.getModel().getCheckor() != null) {
            queryWrapper.lambda().eq(CompanyChange::getCheckor, pageWrap.getModel().getCheckor());
        }
        if (pageWrap.getModel().getCheckDate() != null) {
            queryWrapper.lambda().ge(CompanyChange::getCheckDate, Utils.Date.getStart(pageWrap.getModel().getCheckDate()));
            queryWrapper.lambda().le(CompanyChange::getCheckDate, Utils.Date.getEnd(pageWrap.getModel().getCheckDate()));
        }
        if (pageWrap.getModel().getCheckInfo() != null) {
            queryWrapper.lambda().eq(CompanyChange::getCheckInfo, pageWrap.getModel().getCheckInfo());
        }
        for(PageWrap.SortData sortData: pageWrap.getSorts()) {
            if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) {
                queryWrapper.orderByDesc(sortData.getProperty());
            } else {
                queryWrapper.orderByAsc(sortData.getProperty());
            }
        }
        return PageData.from((companyChangeMapper.selectPage(page,queryWrapper)));
    }
 
    @Override
    public PageData<CompanyChange> findCompanyChangePage(PageWrap<CompanyChange> pageWrap) {
 
        IPage<CompanyChange> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
 
        MPJLambdaWrapper<CompanyChange> mpjWrapper = new MPJLambdaWrapper<>();
        mpjWrapper.leftJoin(Company.class,Company::getId,CompanyChange::getCompanyId)
                .in(Company::getType,Arrays.asList(Constants.CompanyType.BUSINESS_COMPANYTYPE.getValue(),
                        Constants.CompanyType.SERVICE_COMPANYTYPE.getValue(),Constants.CompanyType.ZF_SERVICE_COMPANY.getValue()))
                .like(StringUtils.isNotEmpty(pageWrap.getModel().getName()),Company::getName,pageWrap.getModel().getCompanyName())
                .eq(Objects.nonNull(pageWrap.getModel().getStatus()),CompanyChange::getStatus,pageWrap.getModel().getStatus())
                .selectAll(CompanyChange.class)
                .selectAs(Company::getName,CompanyChange::getCompanyName)
                .selectAs(Company::getType,CompanyChange::getCompanyType)
                .selectAs(Company::getCityId,CompanyChange::getCompanyCityId)
                .selectAs(Company::getAreaId,CompanyChange::getCompanyAreaId)
                .selectAs(Company::getRegisterDate,CompanyChange::getCompanyRegisterDate)
                .selectAs(Company::getAddress,CompanyChange::getCompanyAddress)
                .orderByDesc(CompanyChange::getCreateDate);
 
        IPage<CompanyChange> companyChangeIPage = companyChangeJoinMapper.selectPage(page, mpjWrapper);
//        companyChangeIPage.getRecords().stream().forEach(s->s.setCompanyAddress(getAddress(s.getCompanyCityId(),s.getCompanyAreaId())));
        return PageData.from(companyChangeIPage);
    }
 
    @Override
    public long count(CompanyChange companyChange) {
        QueryWrapper<CompanyChange> wrapper = new QueryWrapper<>(companyChange);
        return companyChangeMapper.selectCount(wrapper);
    }
 
 
    @Override
    public CompanyChange getCompanyChance(@NotNull Integer companyId) {
 
        CompanyChange companyChange = this.findLastOneByCompanyId(companyId);
        if (Objects.isNull(companyChange)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "该企业不存在变更申请数据");
        }
 
        String path = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()+ systemDictDataBiz.queryByCode(Constants.OSS,Constants.COMPANY_FILE).getCode();
 
 
        String address = getAddress(companyChange.getCityId(), companyChange.getAreaId());
        Areas city = areasService.findById(companyChange.getCityId(), Constants.ONE);
        CompanyChange company = new CompanyChange();
        company.setName(companyChange.getName());
        company.setCreditCode(companyChange.getCreditCode());
        company.setCityId(companyChange.getCityId());
        company.setAreaId(companyChange.getAreaId());
        company.setProvinceId(city.getProvinceId());
        company.setCompanyAddress(address);
        company.setLegalPerson(companyChange.getLegalPerson());
        company.setStatus(companyChange.getStatus());
        company.setCheckInfo(companyChange.getCheckInfo());
        Multifile multifile =new Multifile();
        multifile.setObjId(companyChange.getId());
        List<Multifile> list = multifileService.findList(multifile);
        if (!CollectionUtils.isEmpty(list)){
            List<Multifile> multifiles = list.stream()
                    .filter(s -> Constants.MultiFile.COMPANY_CHANGE_LICENSE.getKey() == s.getObjType())
                    .map(s->{
                        s.setFileurlfull(path+s.getFileurl());
                        return s;
                    })
                    .collect(Collectors.toList());
            company.setFileList(multifiles);
            List<String> fileUrls = list.stream()
                    .filter(s -> Constants.MultiFile.COMPANY_CHANGE_LICENSE.getKey() == s.getObjType())
                    .map(s->path+s.getFileurl()).collect(Collectors.toList());
            company.setFileurls(fileUrls);
 
            List<String> changeFileUrls = list.stream()
                    .filter(s -> Constants.MultiFile.COMPANY_CHANGE_CHANGE.getKey() == s.getObjType())
                    .map(s-> path + s.getFileurl()).collect(Collectors.toList());
            company.setFileChangeUrls(changeFileUrls);
            List<Multifile> changeMultifiles = list.stream()
                    .filter(s -> Constants.MultiFile.COMPANY_CHANGE_CHANGE.getKey() == s.getObjType())
                    .map(s->{
                        s.setFileurlfull(path+s.getFileurl());
                        return s;
                    })
                    .collect(Collectors.toList());
 
            company.setChangeFileList(changeMultifiles);
        }
        return company;
    }
 
 
    /**
     * 获取最新的公司变更
     * @param companyId
     * @return
     */
    private CompanyChange findLastOneByCompanyId(Integer companyId){
        QueryWrapper<CompanyChange> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(CompanyChange::getCompanyId,companyId)
                .orderByDesc(CompanyChange::getCreateDate).last("limit 1");
        CompanyChange companyChange = companyChangeMapper.selectOne(wrapper);
        return companyChange;
    }
 
    @Transactional(rollbackFor = {BusinessException.class, Exception.class})
    @Override
    public void checkCompanyChang(CompanyChange companyChange) {
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        CompanyChange realCompanyChance = findById(companyChange.getId());
        if (Constants.ZERO != Constants.formatIntegerNum(realCompanyChance.getStatus())){
            throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"当前审批已完成");
        }
 
        if (Constants.ONE == Constants.formatIntegerNum(companyChange.getStatus())){
            //如果审核通过
//            CompanyChange lastCompanyChange = this.findLastOneByCompanyId(realCompanyChance.getCompanyId());
            QueryWrapper<Company> companyWrapper = new QueryWrapper<>();
            companyWrapper.lambda().and(wrapper->wrapper
                    .eq(Company::getName,realCompanyChance.getName())
                    .or()
                    .eq(Company::getCreditCode,realCompanyChance.getCreditCode())
            );
            companyWrapper
                    .lambda().eq(Company::getIsdeleted,Constants.ZERO);
            companyWrapper
                    .lambda().ne(Company::getId,realCompanyChance.getCompanyId());
 
            if (companyMapper.selectCount(companyWrapper)> Constants.ZERO){
                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"公司名称或者统一信用代码用重复,请联系相关工作人员");
            }
            Company chanceCompany = new Company();
            chanceCompany.setId(realCompanyChance.getCompanyId());
            chanceCompany.setName(realCompanyChance.getName());
            chanceCompany.setCreditCode(realCompanyChance.getCreditCode());
            chanceCompany.setLegalPerson(realCompanyChance.getLegalPerson());
            chanceCompany.setCityId(realCompanyChance.getCityId());
            chanceCompany.setAreaId(realCompanyChance.getAreaId());
            chanceCompany.setEditDate(new Date());
            chanceCompany.setEditor(user.getId());
            companyMapper.updateById(chanceCompany);
 
            //跟新用户名称
        if (!StringUtils.isEmpty(realCompanyChance.getName())){
            QueryWrapper<SystemUser> wrapper = new QueryWrapper<>();
            wrapper.lambda()
                    .eq(SystemUser::getCompanyId,realCompanyChance.getCompanyId())
                    .in(SystemUser::getType, Constants.UserType.getHasCompanyType())
                    .last("limit 1");
            SystemUser systemUser1 = systemUserMapper.selectOne(wrapper);
            if (Objects.nonNull(systemUser1)){
                SystemUser systemUser = new SystemUser();
                systemUser.setId(systemUser1.getId());
                systemUser.setCityId(realCompanyChance.getCityId());
                systemUser.setAreaId(realCompanyChance.getAreaId());
                systemUser.setUsername(realCompanyChance.getName());
                systemUser.setRealname(realCompanyChance.getName());
                systemUserMapper.updateById(systemUser);
            }
        }
 
            QueryWrapper<Multifile> wrapper = new QueryWrapper();
            wrapper.lambda()
                    .eq(Multifile::getObjId,realCompanyChance.getId()).eq(Multifile::getObjType,Constants.MultiFile.COMPANY_CHANGE_LICENSE.getKey());
            //变更附件数据,营业执照,工商变更登记
            dealMultifiles(realCompanyChance,user);
            companyChange.setStatus(Constants.ONE);
        }
        companyChange.setCheckDate(new Date());
        companyChange.setCheckor(user.getId());
        companyChange.setCheckInfo(companyChange.getRemark());
        companyChangeMapper.updateById(companyChange);
    }
 
    /**
     *  变更附件数据,营业执照,工商变更登记
     * @param realCompanyChance
     * @param user
     */
    private void dealMultifiles(CompanyChange realCompanyChance, LoginUserInfo user) {
        Multifile f = new Multifile();
        f.setIsdeleted(Constants.ZERO);
        f.setObjId(realCompanyChance.getId());
        List<Multifile> fileList = multifileMapper.selectList(new QueryWrapper<>(f));
        List<Multifile> fileListYyzz = getMultiFileListByObjtype(fileList,Constants.MultiFile.COMPANY_CHANGE_LICENSE.getKey());
        List<Multifile> fileListGsdj = getMultiFileListByObjtype(fileList,Constants.MultiFile.COMPANY_CHANGE_CHANGE.getKey());
        deleteAndSaveNewFile(fileListYyzz,realCompanyChance.getCompanyId(),Constants.MultiFile.BUSINESS_LICENSE.getKey(),user);
        deleteAndSaveNewFile(fileListGsdj,realCompanyChance.getCompanyId(),Constants.MultiFile.BUSINESS_CHANGE.getKey(),user);
    }
 
    private void deleteAndSaveNewFile(List<Multifile> list,Integer comId, int key,LoginUserInfo user) {
        if(list == null || list.size() ==0){
            return;
        }
            //如果营业执照有变更,删除旧数据,新增新数据
            Multifile tf = new Multifile();
            tf.setObjId(comId);
            tf.setObjType(key);
            multifileService.delete(tf);
            list.forEach(file->{
                tf.setIsdeleted(Constants.ZERO);
                tf.setFileurl(file.getFileurl());
                tf.setName(file.getName());
                tf.setType(Constants.MultiFile.multifileType(file.getName()));
                tf.setCreateDate(new Date());
                tf.setCreator(user.getId());
                multifileMapper.insert(tf);
            });
    }
 
    private List<Multifile> getMultiFileListByObjtype(List<Multifile> fileList, int key) {
        if(fileList==null || fileList.size()==0){
            return null;
        }
        List<Multifile> list = null;
        for(Multifile item :fileList){
            if(Constants.equalsInteger(key,item.getObjType())){
                if(list == null){
                    list = new ArrayList<>();
                }
                list.add(item);
            }
        }
        return list;
    }
 
    /**
     * 更新企业附件
     * @param multifile
     * @param companyId
     * @param currentSubject
     */
    private void updateMultifile(Multifile multifile,Integer companyId, LoginUserInfo currentSubject){
 
 
        Multifile item = new Multifile();
        item.setIsdeleted(Constants.ZERO);
        item.setName(multifile.getName());
        item.setInfo(multifile.getInfo());
        item.setObjId(companyId);
        item.setType(multifile.getType());
        item.setObjType(Constants.formatIntegerNum(multifile.getObjType()) == Constants.MultiFile.COMPANY_CHANGE_LICENSE.getKey()
                ? Constants.MultiFile.BUSINESS_LICENSE.getKey() : Constants.MultiFile.BUSINESS_CHANGE.getKey());
        item.setFileurl(multifile.getFileurl());
        item.setCreateDate(new Date());
        item.setCreator(currentSubject.getId());
        item.setEditor(currentSubject.getId());
        item.setEditDate(new Date());
        multifileService.create(item);
 
    }
 
    private String getAddress(Integer cityId,Integer areaId){
        Areas cityAreas = areasService.findById(cityId, Constants.ONE);
        Areas areas = areasService.findById(areaId, Constants.TWO);
 
        String cityName = Optional.ofNullable(cityAreas)
                .map(s -> s.getProvinceName() + s.getName())
                .orElseThrow(() -> new BusinessException(ResponseStatus.BAD_REQUEST));
        String areaName = Optional.ofNullable(areas).map(s -> s.getName()).orElse("");
 
        return cityName+areaName;
    }
 
}