| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.highdatas.mdm.entity.Character; |
| | | import com.highdatas.mdm.entity.*; |
| | | import com.highdatas.mdm.mapper.TableInfoMapper; |
| | | import com.highdatas.mdm.pojo.CodeMsg; |
| | |
| | | import com.highdatas.mdm.service.*; |
| | | import com.highdatas.mdm.util.Constant; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | | import com.highdatas.mdm.util.NoticeClient; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | */ |
| | | |
| | | @RestController |
| | | @Slf4j |
| | | @RequestMapping("/master") |
| | | public class MasterDataController { |
| | | @Autowired |
| | |
| | | IMasterModifiedService masterModifiedService; |
| | | @Autowired |
| | | IMasterAuthorService masterAuthorService; |
| | | @Autowired |
| | | ISysMenuService menuService; |
| | | @Autowired |
| | | NoticeClient noticeClient; |
| | | |
| | | @RequestMapping(value = "{tableName}/uploaded", method = RequestMethod.GET) |
| | | public Result get(@PathVariable String tableName, HttpServletRequest request) { |
| | |
| | | SysAssembleUpdateType uploadType; |
| | | if (StringUtils.isEmpty(uploadTypeStr)) { |
| | | uploadType = SysAssembleUpdateType.Increment; |
| | | }else { |
| | | uploadType = SysAssembleUpdateType.valueOf(uploadTypeStr); |
| | | } |
| | | uploadType = SysAssembleUpdateType.valueOf(uploadTypeStr); |
| | | TUser user = (TUser) request.getSession().getAttribute(Constant.USER); |
| | | |
| | | TUser user = DbUtils.getUser(request); |
| | | Maintain maintain = masterDataService.uploadedData(tableName, uploadType, user.getUserId()); |
| | | // 处理关联人 |
| | | masterModifiedService.dealAssemble(maintain.getId(), user.getUserId(), true); |
| | | //masterModifiedService.dealAssemble(maintain.getId(), user.getUserId(), true); |
| | | //添加 std_id 索引 |
| | | String recordTableName = tableName + Constant.RECORD; |
| | | |
| | | masterDataService.createIdx(recordTableName); |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("maintainId",maintain.getId()); |
| | | object.fluentPut("version",maintain.getVersion()); |
| | |
| | | |
| | | @RequestMapping(value = "{tableName}/all/{pageNo}", method = RequestMethod.GET) |
| | | public Result getByPage(@PathVariable String tableName, @PathVariable Integer pageNo, HttpServletRequest request) throws UnsupportedEncodingException { |
| | | TUser user = DbUtils.getUser(request); |
| | | String uuid = DbUtils.getUUID(); |
| | | Date start = new Date(); |
| | | Character character = DbUtils.getCharacter(request); |
| | | Date end = new Date(); |
| | | log.info(MessageFormat.format("master tag:{0} MASTER-- form userID selct user:{1} ms",uuid, (end.getTime() - start.getTime()))); |
| | | |
| | | String pageSizeStr = request.getParameter("pageSize"); |
| | | String whereSegment = request.getParameter(Constant.WHERE_SEGMENT); |
| | | String fields = request.getParameter(Constant.FIELDS); |
| | |
| | | return null; |
| | | } |
| | | //ADD Filter |
| | | String filter = masterAuthorService.getFilter(user.getUserId(), maintainFromVersion.getId()); |
| | | whereSegment = DbUtils.StrJoin(whereSegment, Constant.AND, filter); |
| | | start = new Date(); |
| | | log.info(MessageFormat.format("master tag:{0} MASTER-- select maintain:{1} ms",uuid, (start.getTime() - end.getTime()))); |
| | | |
| | | String filter = masterAuthorService.getFilter(character, maintainFromVersion.getId(), uuid); |
| | | if (!StringUtils.isEmpty(filter)) { |
| | | whereSegment = DbUtils.StrJoin(whereSegment, Constant.AND, filter); |
| | | } |
| | | end = new Date(); |
| | | log.info(MessageFormat.format("master tag:{0} MASTER-- select filter:{1} ms",uuid, (end.getTime() - start.getTime()))); |
| | | |
| | | if (StringUtils.isEmpty(fields)) { |
| | | if (StringUtils.isEmpty(pageSizeStr)) { |
| | | return masterDataService.selectListByPageByVersion(user, tableName, whereSegment,pageNo,version, findMax); |
| | | return masterDataService.selectListByPageByVersion(character, tableName, whereSegment,pageNo,version, findMax,uuid); |
| | | } |
| | | return masterDataService.selectListByPageByVersion(user, tableName, null, whereSegment,pageNo, Integer.valueOf(pageSizeStr),version,findMax); |
| | | return masterDataService.selectListByPageByVersion(character, tableName, null, whereSegment,pageNo, Integer.valueOf(pageSizeStr),version,findMax, uuid); |
| | | }else { |
| | | String[] split = fields.split(Constant.COMMA_TRIM); |
| | | List<String> fieldList = Arrays.stream(split).collect(Collectors.toList()); |
| | | if (StringUtils.isEmpty(pageSizeStr)) { |
| | | return masterDataService.selectListByPageByVersion(user, tableName, fieldList, whereSegment,pageNo, null,version, findMax); |
| | | return masterDataService.selectListByPageByVersion(character, tableName, fieldList, whereSegment,pageNo, null,version, findMax, uuid); |
| | | } |
| | | return masterDataService.selectListByPageByVersion(user, tableName, fieldList, whereSegment,pageNo, Integer.valueOf(pageSizeStr), findMax); |
| | | return masterDataService.selectListByPageByVersion(character, tableName, fieldList, whereSegment,pageNo, Integer.valueOf(pageSizeStr), findMax, uuid); |
| | | |
| | | } |
| | | } |
| | |
| | | String[] split = modify.split(Constant.SEMICOLON); |
| | | modifyFields = Arrays.stream(split).collect(Collectors.toList()); |
| | | } |
| | | TUser user = (TUser) request.getSession().getAttribute("user"); |
| | | TUser user = DbUtils.getUser(request); |
| | | |
| | | switch (operate) { |
| | | case delete: |
| | |
| | | |
| | | |
| | | @RequestMapping(value = "{tableName}/{operateStr}", method = RequestMethod.POST) |
| | | @Transactional(rollbackFor = {RuntimeException.class, Error.class}) |
| | | public Result insert(@PathVariable String tableName,@PathVariable String operateStr, @RequestParam String datas, @RequestParam String modify, HttpServletRequest request) { |
| | | String fields = request.getParameter("fields"); |
| | | Operate operate = Operate.parse(operateStr); |
| | | TUser user = (TUser) request.getSession().getAttribute("user"); |
| | | TUser user = DbUtils.getUser(request); |
| | | String userId = user.getUserId(); |
| | | Maintain maintain = maintainService.getMaxVersion(tableName); |
| | | Maintain nowMaintain = maintainService.getNextMaintain(tableName, userId); |
| | |
| | | List<String> ids = (List<String>) result.getData(); |
| | | |
| | | nowMaintain.insertOrUpdate(); |
| | | |
| | | for (String id : ids) { |
| | | MaintainDetail maintainDetail = new MaintainDetail(); |
| | | maintainDetail.setId(DbUtils.getUUID()); |
| | |
| | | Maintain firstVersionMaintain = maintainService.getMaintainFromVersion(tableName, Constant.VERSION_Default); |
| | | |
| | | MenuMapping menuMapping = menuMappingService.selectOne(new EntityWrapper<MenuMapping>().eq("table_name", firstVersionMaintain.getTableName())); |
| | | String menuId = menuMapping.getMenuId(); |
| | | SysMenu menu = menuService.selectById(menuId); |
| | | if (menu != null) { |
| | | LinkedHashSet<String> parentIdSet = new LinkedHashSet<>(); |
| | | parentIdSet.add(menuId); |
| | | LinkedHashSet<String> byParentId = menuService.getByParentId(parentIdSet); |
| | | if (byParentId == null) { |
| | | noticeClient.EditMasterData(menu, null, user.getUserId(), operate); |
| | | } else { |
| | | if (!byParentId.isEmpty()) { |
| | | List<SysMenu> sysMenus = menuService.selectBatchIds(byParentId); |
| | | SysMenu parentMenu = sysMenus.get(0); |
| | | noticeClient.EditMasterData(menu, parentMenu, user.getUserId(),operate); |
| | | } |
| | | |
| | | } |
| | | } |
| | | SysOperateLog operateLog = new SysOperateLog(); |
| | | operateLog.setChargeId(user.getUserId()).setId(DbUtils.getUUID()) |
| | | .setMaintainId(nowMaintain.getId()) |