| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.highdatas.mdm.entity.Flows; |
| | | import com.highdatas.mdm.entity.Maintain; |
| | | import com.highdatas.mdm.entity.MaintainField; |
| | | import com.highdatas.mdm.entity.SysField; |
| | | import com.highdatas.mdm.entity.*; |
| | | import com.highdatas.mdm.mapper.MaintainFieldMapper; |
| | | import com.highdatas.mdm.pojo.ActivitiStatus; |
| | | import com.highdatas.mdm.pojo.Operate; |
| | | import com.highdatas.mdm.service.IFlowsService; |
| | | import com.highdatas.mdm.service.IMaintainFieldService; |
| | | import com.highdatas.mdm.service.IMaintainService; |
| | | import com.highdatas.mdm.service.ISysFieldService; |
| | | import com.highdatas.mdm.service.*; |
| | | import com.highdatas.mdm.util.Constant; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | | import com.highdatas.mdm.util.RedisClient; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | IFlowsService flowsService; |
| | | @Autowired |
| | | ISysFieldService fieldService; |
| | | |
| | | @Autowired |
| | | MaintainFieldMapper maintainFieldMapper; |
| | | @Autowired |
| | | IMasterAuthorService masterAuthorService; |
| | | @Autowired |
| | | IMasterAuthorDetailService masterAuthorDetailService; |
| | | @Autowired |
| | | RedisClient redisClient; |
| | | |
| | | @Override |
| | | public MaintainField getNextMaintain(String tableName, String userId) { |
| | |
| | | HashMap<String, List<Maintain>> resultMap = getMaintainFieldMapByTable(tableName); |
| | | if (resultMap == null) { |
| | | return null; |
| | | } |
| | | if (maintainFieldId == null) { |
| | | return null; |
| | | } |
| | | if (maintainFieldId.equalsIgnoreCase(Constant.All)) { |
| | | Collection<List<Maintain>> values = resultMap.values(); |
| | | HashSet<Maintain> maintains = new HashSet<>(); |
| | | for (List<Maintain> value : values) { |
| | | maintains.addAll(value); |
| | | } |
| | | |
| | | return new ArrayList<>(maintains); |
| | | } |
| | | return resultMap.get(maintainFieldId); |
| | | } |
| | |
| | | maintainField.deleteById(); |
| | | } |
| | | else if (status.equals(ActivitiStatus.open)) { |
| | | |
| | | Integer orderNo = maintainField.getOrderNo(); |
| | | int preNo = orderNo - 1; |
| | | MaintainField preMaintainField; |
| | | if (preNo < 0 ) { |
| | | preMaintainField = new MaintainField().setId(Constant.Default); |
| | | }else { |
| | | preMaintainField = selectOne(new EntityWrapper<MaintainField>() |
| | | .eq("table_name", maintainField.getTableName()) |
| | | .eq("order_no", preNo)); |
| | | } |
| | | |
| | | if (preMaintainField == null){ |
| | | return; |
| | | } |
| | | List<MasterAuthor> masterAuthors = masterAuthorService.selectList( |
| | | new EntityWrapper<MasterAuthor>() |
| | | .eq("maintain_auto", true) |
| | | .eq("table_name", maintainField.getTableName()) |
| | | .eq("maintain_field_id", preMaintainField.getId())); |
| | | |
| | | List<SysField> fieldList = fieldService.selectList(new EntityWrapper<SysField>().eq("maintain_field_id", maintainField.getId())); |
| | | |
| | | List<SysField> collect = fieldList.stream().filter(sysField -> Operate.delete.equals(sysField.getOperate())).collect(Collectors.toList()); |
| | | //delete |
| | | for (SysField field : collect) { |
| | | List<SysField> deleteList = fieldList.stream().filter(sysField -> Operate.delete.equals(sysField.getOperate())).collect(Collectors.toList()); |
| | | List<SysField> updateList = fieldList.stream().filter(sysField -> (Operate.update.equals(sysField.getOperate()))).collect(Collectors.toList()); |
| | | List<SysField> createList = fieldList.stream().filter(sysField -> (Operate.create.equals(sysField.getOperate()))).collect(Collectors.toList()); |
| | | |
| | | List<String> createFieldList = createList.stream().map(sysField -> sysField.getField()).collect(Collectors.toList()); |
| | | |
| | | |
| | | for (MasterAuthor masterAuthor : masterAuthors) { |
| | | Boolean fieldAuto = masterAuthor.getFieldAuto(); |
| | | |
| | | List<MasterAuthorDetail> masterAuthorDetails = masterAuthorDetailService.selectList(new EntityWrapper<MasterAuthorDetail>().eq(Constant.PARENT_ID, masterAuthor.getId())); |
| | | |
| | | masterAuthor.setMaintainFieldId(maintainField.getId()) |
| | | .setCreateTime(new Date()) |
| | | .setUpdateTime(null) |
| | | .setId(DbUtils.getUUID()) |
| | | .insert(); |
| | | |
| | | for (MasterAuthorDetail masterAuthorDetail : masterAuthorDetails) { |
| | | long count = deleteList.stream().filter(sysField -> sysField.getField().equalsIgnoreCase(masterAuthorDetail.getField())).count(); |
| | | if (count > 0) { |
| | | continue; |
| | | } |
| | | masterAuthorDetail.setParentId(masterAuthor.getId()).setId(DbUtils.getUUID()).insert(); |
| | | } |
| | | |
| | | if (fieldAuto) { |
| | | for (String s : createFieldList) { |
| | | new MasterAuthorDetail().setField(s).setVal(Constant.z_AllVal).setAll(true).setParentId(masterAuthor.getId()).setId(DbUtils.getUUID()).insert(); |
| | | } |
| | | } |
| | | } |
| | | // |
| | | |
| | | |
| | | //delete |
| | | for (SysField field : deleteList) { |
| | | field.deleteById(); |
| | | } |
| | | //update |
| | | List<SysField> updateList = fieldList.stream().filter(sysField -> (Operate.update.equals(sysField.getOperate()))).collect(Collectors.toList()); |
| | | for (SysField field : updateList) { |
| | | field.setOperate(null).updateById(); |
| | | } |
| | | List<SysField> createList = fieldList.stream().filter(sysField -> (Operate.create.equals(sysField.getOperate()))).collect(Collectors.toList()); |
| | | for (SysField field : createList) { |
| | | for (SysField field : createList) { |
| | | String fieldType = field.getFieldType(); |
| | | if (StringUtils.isEmpty(fieldType)) { |
| | | fieldType = Constant.varchar; |
| | |
| | | maintainFieldMapper.addCloumn(tableName, field.getField(), fieldTypeStr); |
| | | |
| | | field.setOperate(null).updateById(); |
| | | |
| | | redisClient.delByField(); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public int getUnFlowCount(String tableName, String userId) { |
| | |
| | | public List<Maintain> getMaintainListByMaintainField(String id, String tableName) { |
| | | MaintainField maintainField = selectById(id); |
| | | if (maintainField == null) { |
| | | if (!id.equalsIgnoreCase(Constant.Default)){ |
| | | if (!id.equalsIgnoreCase(Constant.Default) && !id.equalsIgnoreCase(Constant.All)){ |
| | | return null; |
| | | }else { |
| | | maintainField = new MaintainField().setId(Constant.Default).setTableName(tableName); |
| | | maintainField = new MaintainField().setId(id).setTableName(tableName); |
| | | } |
| | | |
| | | } |
| | |
| | | HashMap<String, List<Maintain>> resultMap = new HashMap<>(); |
| | | for (Maintain maintain : maintainList) { |
| | | ActivitiStatus status = flowsService.getStatusByBusinessId(maintain.getId()); |
| | | if (!status.equals(ActivitiStatus.open)) { |
| | | if (!ActivitiStatus.open.equals(status)) { |
| | | continue; |
| | | } |
| | | MaintainField maintainFieldByMaintain = fieldService.getMaintainFieldByMaintain(maintain.getId()); |