| | |
| | | import com.highdatas.mdm.pojo.CodeMsg; |
| | | import com.highdatas.mdm.pojo.Operate; |
| | | import com.highdatas.mdm.pojo.Result; |
| | | import com.highdatas.mdm.pojo.SysAssembleUpdateType; |
| | | import com.highdatas.mdm.service.IMaintainDetailService; |
| | | import com.highdatas.mdm.service.IMaintainService; |
| | | import com.highdatas.mdm.service.IMenuMappingService; |
| | |
| | | |
| | | @RequestMapping(value = "{tableName}/uploaded", method = RequestMethod.GET) |
| | | public Result get(@PathVariable String tableName, HttpServletRequest request) { |
| | | String uploadType = request.getParameter("uploadType"); |
| | | if (StringUtils.isEmpty(uploadType)) { |
| | | uploadType = Constant.All; |
| | | String uploadTypeStr = request.getParameter("uploadType"); |
| | | SysAssembleUpdateType uploadType; |
| | | if (StringUtils.isEmpty(uploadTypeStr)) { |
| | | uploadType = SysAssembleUpdateType.Increment; |
| | | } |
| | | MenuMapping menuMapping = menuMappingService.selectOne(new EntityWrapper<MenuMapping>().eq("table_name",tableName)); |
| | | SysOperateLog operateLog = new SysOperateLog(); |
| | | |
| | | Maintain maxVersion = maintainService.getMaxVersion(tableName); |
| | | Maintain maintain = new Maintain(); |
| | | String biggerVersion = null; |
| | | if (maxVersion == null) { |
| | | biggerVersion = Constant.VERSION_Default; |
| | | maintain.setOrderNo(0); |
| | | operateLog.setOperate("初始化主题数据"); |
| | | } else { |
| | | operateLog.setOperate("更新主题"); |
| | | String flowId = maxVersion.getFlowId(); |
| | | String mVersion = maxVersion.getVersion(); |
| | | if (StringUtils.isEmpty(flowId)) { |
| | | biggerVersion = mVersion; |
| | | maintain.setOrderNo(maxVersion.getOrderNo()); |
| | | String tempName = maxVersion.getTableName() + Constant.RECORD; |
| | | |
| | | tableInfoMapper.deleteTempByMaintainId(tempName, DbUtils.quotedStr(maxVersion.getId())); |
| | | maintainDetailService.delete(new EntityWrapper<MaintainDetail>().eq("parent_id", maxVersion.getId())); |
| | | |
| | | maxVersion.deleteById(); |
| | | }else { |
| | | biggerVersion = DbUtils.versionAddBig(mVersion); |
| | | maintain.setOrderNo(DbUtils.getOrderNoAdd(maxVersion.getOrderNo())); |
| | | } |
| | | } |
| | | |
| | | String uuid = DbUtils.getUUID(); |
| | | maintain.setId(uuid); |
| | | uploadType = SysAssembleUpdateType.valueOf(uploadTypeStr); |
| | | TUser user = (TUser) request.getSession().getAttribute(Constant.USER); |
| | | if (user == null) { |
| | | return Result.error(CodeMsg.ERROR_PARAMS_NOT_MATHED); |
| | | } |
| | | maintain.setVersion(biggerVersion); |
| | | maintain.setChargeId(user.getUserId()); |
| | | maintain.setTableName(tableName); |
| | | maintain.setCreateTime(new Date()); |
| | | |
| | | |
| | | tableInfoMapper.insertMatintainDetailFromTemp(DbUtils.quotedStr(maintain.getId()), maintain.getTableName() + Constant.RECORD); |
| | | |
| | | tableInfoMapper.updateStdId( maintain.getTableName() + Constant.RECORD); |
| | | |
| | | Long aLong = tableInfoMapper.tempDeal(maintain.getTableName() + Constant.RECORD, DbUtils.quotedStr(maintain.getId())); |
| | | |
| | | maintain.setDesp(MessageFormat.format("上传数据{0}条", aLong)); |
| | | |
| | | operateLog.setCreateTime(new Date()) |
| | | .setMaintainId(maintain.getId()) |
| | | .setId(DbUtils.getUUID()) |
| | | .setMaintainId(menuMapping.getId()) |
| | | .setOperate("open") |
| | | .setDesp(MessageFormat.format("上传数据{0}条", aLong)); |
| | | |
| | | maintain.insert(); |
| | | Maintain maintain = masterDataService.uploadedData(tableName, uploadType, user.getUserId()); |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("maintainId",maintain.getId()); |
| | | object.fluentPut("version",maintain.getVersion()); |
| | |
| | | case delete: |
| | | //datas is id; |
| | | Integer deleteCount = tableInfoMapper.deleteRecordByMaintainId(maintain.getTableName() + Constant.RECORD, DbUtils.quotedStr(datas), DbUtils.quotedStr(maintainId)); |
| | | |
| | | result = Result.success(deleteCount); |
| | | |
| | | |
| | | break; |
| | | case update: |
| | | JSONObject jsonObject = JSONObject.parseObject(datas); |
| | |
| | | String nowMaintainId = nowMaintain.getId(); |
| | | String tempId = tableInfoMapper.getTempIdByStdId(tableName + Constant.RECORD,DbUtils.quotedStr(datas), DbUtils.quotedStr(nowMaintainId)); |
| | | if (!StringUtils.isEmpty(tempId)){ |
| | | maintainDetailService.delete(new EntityWrapper<MaintainDetail>().eq("parent_id", maintain.getId()).eq("operate",Operate.delete.name()).eq("pre_merge_id",tempId)); |
| | | return masterDataService.deleteById(tableName + Constant.RECORD, tempId); |
| | | maintainDetailService.delete(new EntityWrapper<MaintainDetail>().eq("parent_id", maintain.getId()).eq("pre_merge_id",tempId)); |
| | | result = masterDataService.deleteById(tableName + Constant.RECORD, tempId); |
| | | return result; |
| | | }else { |
| | | result = masterDataService.selectById(tableName, datas); |
| | | Object data = result.getData(); |