| | |
| | | return insurance.getId(); |
| | | } |
| | | private void dealWorkTypeData(Insurance insurance, Insurance newModel, List<Worktype> worktypeList,boolean isNew) { |
| | | int num=0; |
| | | for(Worktype w : worktypeList) { |
| | | //基础版本 |
| | | w.setInsuranceId(insurance.getId()); |
| | |
| | | w.setDataType(insurance.getDataType()); |
| | | w.setStatus(Constants.ZERO); |
| | | w.setVersion(insurance.getVersion()); |
| | | w.setSortnum(num++); |
| | | worktypeMapper.insert(w); |
| | | |
| | | //历史版本的工种信息 |
| | |
| | | BeanUtils.copyProperties(w, newType); |
| | | newType.setInsuranceId(newModel.getId()); |
| | | newType.setBaseId(w.getId()); |
| | | newType.setDataType(Constants.ONE); |
| | | newType.setDataType(Constants.TWO); |
| | | newType.setVersion(newModel.getVersion()); |
| | | w.setSortnum(num++); |
| | | worktypeMapper.insert(newType); |
| | | } |
| | | } |
| | |
| | | |
| | | @Override |
| | | public void updateById(Insurance insurance) { |
| | | LoginUserInfo user= (LoginUserInfo)SecurityUtils.getSubject().getPrincipal(); |
| | | Insurance model = findById(insurance.getId()); |
| | | if(model == null || !Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO) |
| | | || !Constants.equalsInteger(model.getDataType(),Constants.ZERO)){ |
| | |
| | | } |
| | | //数据有效性校验 |
| | | initCreateParam(insurance); |
| | | |
| | | LoginUserInfo user= (LoginUserInfo)SecurityUtils.getSubject().getPrincipal(); |
| | | Insurance updateModel = new Insurance(); |
| | | updateModel.setEditor(user.getId()); |
| | | updateModel.setName(insurance.getName()); |
| | |
| | | newModel.setId(null); |
| | | newModel.setVersion(updateModel.getVersion()); |
| | | newModel.setCreateDate(new Date()); |
| | | newModel.setName(updateModel.getName()); |
| | | newModel.setBaseId(insurance.getId()); |
| | | newModel.setDataType(Constants.TWO); |
| | | insuranceMapper.insert(newModel); |
| | |
| | | .lambda() |
| | | .eq(Insurance::getBaseId,insurance.getId()) |
| | | .eq(Insurance::getDataType,Constants.TWO) |
| | | .ne(Insurance::getId,newModel.getId()) |
| | | .set(Insurance::getDataType,Constants.ONE) |
| | | ); |
| | | worktypeMapper.update(null,new UpdateWrapper<Worktype>() |
| | | .lambda() |
| | | .eq(Worktype::getBaseId,insurance.getId()) |
| | | .eq(Worktype::getDataType,Constants.TWO) |
| | | .set(Worktype::getDataType,Constants.ONE) |
| | | ); |
| | | |
| | | //处理工作信息,新增最新的,同时产生历史版本 |
| | | dealWorkTypeData(updateModel,newModel,insurance.getWorktypeList(),false); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public Insurance findById(Integer id) { |
| | | return insuranceMapper.selectById(id); |
| | | Insurance model = insuranceMapper.selectById(id); |
| | | if(model == null || !Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY ); |
| | | } |
| | | List<Worktype> worktypeList = worktypeMapper.selectList(new QueryWrapper<Worktype>().lambda() |
| | | .eq(Worktype::getInsuranceId,id) |
| | | .eq(Worktype::getIsdeleted,Constants.ZERO) |
| | | .orderByAsc(Worktype::getSortnum)); |
| | | model.setWorktypeList(worktypeList); |
| | | return model; |
| | | } |
| | | |
| | | @Override |
| | |
| | | queryWrapper.lambda().eq(Insurance::getIsdeleted, pageWrap.getModel().getIsdeleted()); |
| | | } |
| | | if (pageWrap.getModel().getName() != null) { |
| | | queryWrapper.lambda().eq(Insurance::getName, pageWrap.getModel().getName()); |
| | | queryWrapper.lambda().like(Insurance::getName, pageWrap.getModel().getName()); |
| | | } |
| | | if (pageWrap.getModel().getRemark() != null) { |
| | | queryWrapper.lambda().eq(Insurance::getRemark, pageWrap.getModel().getRemark()); |