| | |
| | | import com.highdatas.mdm.entity.Flows; |
| | | import com.highdatas.mdm.entity.Maintain; |
| | | import com.highdatas.mdm.entity.MaintainDetail; |
| | | import com.highdatas.mdm.entity.TUser; |
| | | import com.highdatas.mdm.mapper.MaintainMapper; |
| | | import com.highdatas.mdm.mapper.TableInfoMapper; |
| | | import com.highdatas.mdm.pojo.*; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | maintain.deleteById(); |
| | | return; |
| | | } |
| | | String fields = masterDataService.getTempFields(tableName); |
| | | String fields = masterDataService.getTempFields(null, tableName); |
| | | String tempFields = masterDataService.getFields(tableName + Constant.RECORD); |
| | | |
| | | String tableTempName = tableName + Constant.RECORD; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Result getUnSubmitData(String tableName, Integer pageNo, String pageSize, String whereSegment) { |
| | | public Result getUnSubmitData(TUser user, String tableName, Integer pageNo, String pageSize, String whereSegment) { |
| | | Wrapper<Maintain> versionWrapper = new EntityWrapper<Maintain>().eq("table_name", tableName).isNull("flow_id").orderBy("order_no desc"); |
| | | Maintain maintain = selectOne(versionWrapper); |
| | | if (maintain == null) { |
| | |
| | | if (!StringUtils.isEmpty(pageSize)) { |
| | | page.setPageSize(Integer.valueOf(pageSize)); |
| | | } |
| | | String tempFields = masterDataService.getTempFields(tableName); |
| | | String tempFields = masterDataService.getTempFields(user, tableName); |
| | | List<Map<String, Object>> maps = maintainMapper.selectUnSubmitData(tempName, tempFields, whereSegment, DbUtils.quotedStr(maintainId), page.getLimitSQL()); |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("records", maps); |
| | |
| | | object.fluentPut("pages", page.getPageCount()); |
| | | object.fluentPut("current", page.getPageNo()); |
| | | return Result.success(object); |
| | | } |
| | | |
| | | @Override |
| | | public Maintain getNextMaintain(String tableName, String userId) { |
| | | Maintain maintain = this.getMaxVersion(tableName); |
| | | Maintain unFlowMaxVersion = this.getUnFlowMaxVersion(tableName); |
| | | if (unFlowMaxVersion == null) { |
| | | unFlowMaxVersion = new Maintain(); |
| | | if (maintain != null) { |
| | | unFlowMaxVersion.setVersion(DbUtils.versionAddSub(maintain.getVersion())); |
| | | int orderNo = maintain.getOrderNo(); |
| | | orderNo++; |
| | | unFlowMaxVersion.setOrderNo(orderNo); |
| | | } else { |
| | | unFlowMaxVersion.setVersion(Constant.VERSION_Default); |
| | | unFlowMaxVersion.setOrderNo(0); |
| | | } |
| | | |
| | | unFlowMaxVersion.setId(DbUtils.getUUID()); |
| | | unFlowMaxVersion.setChargeId(userId); |
| | | unFlowMaxVersion.setCreateTime(new Date()); |
| | | unFlowMaxVersion.setTableName(tableName); |
| | | } |
| | | |
| | | Maintain nowMaintain = unFlowMaxVersion; |
| | | if (DbUtils.compareVersion(maintain, unFlowMaxVersion) != 0) { |
| | | nowMaintain = new Maintain(); |
| | | String maintanId = DbUtils.getUUID(); |
| | | nowMaintain.setId(maintanId); |
| | | nowMaintain.setCreateTime(new Date()); |
| | | int orderNo = maintain.getOrderNo(); |
| | | orderNo++; |
| | | nowMaintain.setVersion(DbUtils.versionAddSub(maintain.getVersion())); |
| | | nowMaintain.setOrderNo(orderNo); |
| | | nowMaintain.setTableName(tableName); |
| | | } |
| | | |
| | | nowMaintain.setChargeId(userId); |
| | | String maintainId = nowMaintain.getId(); |
| | | if(StringUtils.isEmpty(maintainId)) { |
| | | nowMaintain.setId(DbUtils.getUUID()); |
| | | } |
| | | return nowMaintain; |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Result getInvalidVerionData(String tableName, String where, Integer pageNo, Integer pageSize) { |
| | | public Result getInvalidVerionData(TUser user, String tableName, String where, Integer pageNo, Integer pageSize) { |
| | | Maintain invalidVersion = getInvalidMaxVersion(tableName); |
| | | if (invalidVersion == null) { |
| | | return Result.success(null); |
| | | } |
| | | String tableTempName = tableName + Constant.RECORD; |
| | | String tempFields = masterDataService.getTempFields(tableName); |
| | | String tempFields = masterDataService.getTempFields(user, tableName); |
| | | Long count = maintainMapper.countInvalidVersionData(tableTempName, where, invalidVersion.getOrderNo()); |
| | | Page page = new Page(count); |
| | | page.setPageNo(pageNo); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Result tempDataByVersionByFlow(String flowId, String whereSegment, Integer pageNo, Integer pageSize) { |
| | | public Result tempDataByVersionByFlow(TUser user, String flowId, String whereSegment, Integer pageNo, Integer pageSize) { |
| | | Flows flows = flowsService.selectById(flowId); |
| | | if (flows == null) { |
| | | return Result.error(CodeMsg.SELECT_ERROR_NOTFOUND); |
| | |
| | | if (maintain == null) { |
| | | return Result.error(CodeMsg.SELECT_ERROR_NOTFOUND); |
| | | } |
| | | String fields = masterDataService.getTempFields(maintain.getTableName()); |
| | | String fields = masterDataService.getTempFields(user, maintain.getTableName()); |
| | | String tableTempName = maintain.getTableName() + Constant.RECORD; |
| | | long total = maintainMapper.countTempDataByVersionByFlow(tableTempName, flowId, whereSegment); |
| | | |