|  |  |  | 
|---|
|  |  |  | import com.doumee.dao.business.InsuranceMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.WorktypeMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Insurance; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Solutions; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Worktype; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemUser; | 
|---|
|  |  |  | import com.doumee.service.business.InsuranceService; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  | import org.springframework.util.CollectionUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.UUID; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 保险公司信息表Service实现 | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LoginUserInfo user= (LoginUserInfo)SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | initCreateParam(insurance);//工种数据有效性检验,去除空白行数据 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(insuranceMapper.selectCount(new QueryWrapper<Insurance>().lambda().eq(Insurance::getName,insurance.getName()) | 
|---|
|  |  |  | .eq(Insurance::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Insurance::getDataType,Constants.ZERO) | 
|---|
|  |  |  | )>Constants.ZERO){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"保险公司名称已存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | insurance.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | insurance.setCreator(user.getId()); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | private void dealWorkTypeData(Insurance insurance, Insurance newModel, List<Worktype> worktypeList,boolean isNew) { | 
|---|
|  |  |  | int num=0; | 
|---|
|  |  |  | List<String> workTypeName = worktypeList.stream().map(m->m.getName()).collect(Collectors.toList()); | 
|---|
|  |  |  | Set<String> set = new HashSet<>(workTypeName); | 
|---|
|  |  |  | if(workTypeName.size() != set.size()){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"对不起,工种录入数据存在相同数据!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for(Worktype w : worktypeList) { | 
|---|
|  |  |  | if(!isNew){ | 
|---|
|  |  |  | //查询保险公司下是否已存在该工种 | 
|---|
|  |  |  | if(worktypeMapper.selectCount(new QueryWrapper<Worktype>().lambda().eq(Worktype::getInsuranceId,insurance.getId()) | 
|---|
|  |  |  | .eq(Worktype::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Worktype::getDataType,Constants.ZERO) | 
|---|
|  |  |  | .eq(Worktype::getName,w.getName()) | 
|---|
|  |  |  | )>Constants.ZERO){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"当前保险公司下存在【"+w.getName()+"】该工种信息"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //基础版本 | 
|---|
|  |  |  | w.setInsuranceId(insurance.getId()); | 
|---|
|  |  |  | w.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | 
|---|
|  |  |  | w.setVersion(insurance.getVersion()); | 
|---|
|  |  |  | w.setSortnum(num++); | 
|---|
|  |  |  | worktypeMapper.insert(w); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //历史版本的工种信息 | 
|---|
|  |  |  | Worktype newType = new Worktype(); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //数据有效性校验 | 
|---|
|  |  |  | initCreateParam(insurance); | 
|---|
|  |  |  | if(insuranceMapper.selectCount(new QueryWrapper<Insurance>().lambda().eq(Insurance::getName,insurance.getName()) | 
|---|
|  |  |  | .eq(Insurance::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Insurance::getDataType,Constants.ZERO) | 
|---|
|  |  |  | .ne(Insurance::getId,insurance.getId()) | 
|---|
|  |  |  | )>Constants.ZERO){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"保险公司名称已存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LoginUserInfo user= (LoginUserInfo)SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | Insurance updateModel = new Insurance(); | 
|---|
|  |  |  | updateModel.setEditor(user.getId()); | 
|---|