diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/service/archive/ArchiveService.java b/ruoyi-admin/src/main/java/com/ruoyi/web/service/archive/ArchiveService.java index 26b2c60..d1802dd 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/service/archive/ArchiveService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/service/archive/ArchiveService.java @@ -66,7 +66,7 @@ public class ArchiveService { page=(int)Math.min(page,total==0?1:(total-1)/size+1); var paged=new ArrayList<>(args);paged.add(size);paged.add((page-1)*size); String reviewColumns="(select count(*) from project_archive_item i where i.project_id=p.id and i.required=0 and i.applicable=1) optional_total,(select count(*) from project_archive_item i where i.project_id=p.id and i.required=0 and i.applicable=1 and i.state='DONE') optional_done,(select max(h.create_time) from project_archive_history h where h.project_id=p.id and h.event_type='STATE_REVIEW') submitted_at,"; - var rows=db.queryForList("select p.*,u.nick_name manager_name,"+reviewColumns+"(select count(*) from project_archive_item i where i.project_id=p.id and i.item_key='costAnalysis') has_cost,(select count(*) from project_archive_item i where i.project_id=p.id) item_total,(select count(*) from project_archive_item i where i.project_id=p.id and (i.applicable=0 or i.state='DONE')) item_resolved,(select count(*) from project_archive_item i where i.project_id=p.id and i.required=1 and i.applicable=1) required_total,(select count(*) from project_archive_item i where i.project_id=p.id and i.required=1 and i.applicable=1 and i.state='DONE') required_done,(select count(*) from project_archive_document d join project_archive_item i on i.id=d.item_id where i.project_id=p.id and d.deleted=0 and d.current_file_id is not null) document_count"+from+" order by p.update_time desc,p.id desc limit ? offset ?",paged.toArray()); + var rows=db.queryForList("select p.*,u.nick_name manager_name,"+reviewColumns+"(select count(*) from project_archive_item i where i.project_id=p.id and i.item_key='costAnalysis') has_cost,(select count(*) from project_archive_item i where i.project_id=p.id) item_total,(select count(*) from project_archive_item i where i.project_id=p.id and (i.applicable=0 or i.state='DONE')) item_resolved,(select count(*) from project_archive_item i where i.project_id=p.id and i.required=1 and i.applicable=1) required_total,(select count(*) from project_archive_item i where i.project_id=p.id and i.required=1 and i.applicable=1 and i.state='DONE') required_done,(select count(*) from project_archive_document d join project_archive_item i on i.id=d.item_id where i.project_id=p.id and d.deleted=0 and d.current_file_id is not null) document_count"+from+" order by case p.archive_state when '"+(access.all()?"REVIEW":"EDITING")+"' then 0 when 'ARCHIVED' then 2 else 1 end,p.create_time desc,p.id desc limit ? offset ?",paged.toArray()); boolean editable=access.has("edit");for(var row:rows)row.put("canEdit",editable&&"EDITING".equals(row.get("archive_state"))&&(((Number)row.get("manager_id")).longValue()==access.actor()||access.administrator())); return Map.of("rows",rows,"total",total,"page",page,"size",size,"overview",overview,"matrix",comparison?matrix(rows):Map.of());} private Map matrix(List> projects){var result=new LinkedHashMap();if(projects.isEmpty())return result; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/service/kpi/KpiService.java b/ruoyi-admin/src/main/java/com/ruoyi/web/service/kpi/KpiService.java index 60fe6ca..1424c26 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/service/kpi/KpiService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/service/kpi/KpiService.java @@ -30,8 +30,8 @@ public class KpiService { private void requireManager(){if(!manager())throw new ServiceException("考核管理由KPI管理员协助办理",403);} public Map capabilities(){return Map.of("manage",manager(),"categories",CATEGORIES,"templateVersion","v1","maxItems",200);} public List> periods(boolean manage){ - if(manage){requireManager();return db.queryForList(PERIOD.replace(" from kpi_period",",(select count(*) from kpi_assessment a where a.period_id=p.id) as assignedCount,(select count(*) from kpi_assessment a where a.period_id=p.id and (case when p.phase='REVIEW' then a.review_status else a.status end) in ('SUBMITTED','SCORING','SCORED')) as submittedCount from kpi_period p")+" order by assessment_year desc,quarter desc,id desc");} - return db.queryForList("select p.id,p.name,p.assessment_year as year,p.quarter,p.closed,p.phase,p.workflow_state as workflowState,a.id as assessmentId,case when p.phase='REVIEW' then a.review_status else a.status end as status,a.version,date_format(a.update_time,'%Y-%m-%d %H:%i:%s') as updateTime from kpi_assessment a join kpi_period p on p.id=a.period_id where a.user_id=? order by p.assessment_year desc,p.quarter desc,p.id desc",SecurityUtils.getUserId()); + if(manage){requireManager();return db.queryForList(PERIOD.replace(" from kpi_period",",(select count(*) from kpi_assessment a where a.period_id=p.id) as assignedCount,(select count(*) from kpi_assessment a where a.period_id=p.id and (case when p.phase='REVIEW' then a.review_status else a.status end) in ('SUBMITTED','SCORING','SCORED')) as submittedCount from kpi_period p")+" order by p.closed asc,assessment_year desc,quarter desc,p.create_time desc,p.id desc");} + return db.queryForList("select p.id,p.name,p.assessment_year as year,p.quarter,p.closed,p.phase,p.workflow_state as workflowState,a.id as assessmentId,case when p.phase='REVIEW' then a.review_status else a.status end as status,a.version,date_format(a.update_time,'%Y-%m-%d %H:%i:%s') as updateTime from kpi_assessment a join kpi_period p on p.id=a.period_id where a.user_id=? order by p.closed asc,p.assessment_year desc,p.quarter desc,p.create_time desc,p.id desc",SecurityUtils.getUserId()); } @Transactional public Map create(PeriodInput input){ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/service/warehouse/PurchaseBoardService.java b/ruoyi-admin/src/main/java/com/ruoyi/web/service/warehouse/PurchaseBoardService.java index 5de8b03..042a3b5 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/service/warehouse/PurchaseBoardService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/service/warehouse/PurchaseBoardService.java @@ -45,7 +45,7 @@ public class PurchaseBoardService { long total=db.queryForObject("select count(*)"+FROM+f.sql(),Long.class,f.args().toArray()); String aggregate=" left join (select r.purchase_batch_id,count(*) itemCount,group_concat(distinct p.project_name order by p.id separator '、') projectNames,group_concat(distinct coalesce(nullif(u.nick_name,''),r.create_by) order by r.create_by separator '、') purchasers,sum(case when r.purchase_status<>5 then round(r.quantity*r.final_unit_price,6) end) quoteAmount,sum(case when r.purchase_status<>5 and r.final_unit_price is null then 1 else 0 end) unpricedCount from purchase_request r left join project_info p on p.id=r.project_id left join sys_user u on u.user_id=r.applicant_id where r.del_flag='0' group by r.purchase_batch_id) a on a.purchase_batch_id=b.id "; var args=new ArrayList<>(f.args());args.add(size);args.add(offset); - var rows=db.queryForList("select b.create_by createBy,b.id,b.batch_no batchNo,b.batch_name batchName,b.expense_category_id expenseCategoryId,coalesce(e.category_name,'待统一') expenseCategoryName,b.progress_remark remark,b.business_date businessDate,s.name supplierName,a.projectNames,a.purchasers,coalesce(a.itemCount,0) itemCount,a.quoteAmount,coalesce(a.unpricedCount,0) unpricedCount"+FROM+aggregate+" left join expense_category e on e.id=b.expense_category_id "+f.sql()+" order by b.id desc limit ? offset ?",args.toArray()); + var rows=db.queryForList("select b.create_by createBy,b.id,b.batch_no batchNo,b.batch_name batchName,b.expense_category_id expenseCategoryId,coalesce(e.category_name,'待统一') expenseCategoryName,b.progress_remark remark,b.business_date businessDate,s.name supplierName,a.projectNames,a.purchasers,coalesce(a.itemCount,0) itemCount,a.quoteAmount,coalesce(a.unpricedCount,0) unpricedCount"+FROM+aggregate+" left join expense_category e on e.id=b.expense_category_id "+f.sql()+" order by b.business_date desc,b.create_time desc,b.id desc limit ? offset ?",args.toArray()); if(!rows.isEmpty()){ var ids=rows.stream().map(r->r.get("id")).toList();String marks=String.join(",",Collections.nCopies(ids.size(),"?")); var docs=db.queryForList("select g.target_id batchId,g.document_kind kind,g.document_no number,count(a.id) files from purchase_document_group g left join purchase_document_attachment a on a.group_id=g.id and a.deleted=0 and a.content_type='application/pdf' where g.target_type='batch' and g.target_id in ("+marks+") group by g.id,g.target_id,g.document_kind,g.document_no",ids.toArray()); @@ -71,11 +71,11 @@ public class PurchaseBoardService { String where=f.sql()+(q.getProjectId()==null?"":" and r.project_id=?");var params=new ArrayList<>(f.args());if(q.getProjectId()!=null)params.add(q.getProjectId()); long total=db.queryForObject("select count(distinct p.id)"+joins+where,Long.class,params.toArray()); var pageArgs=new ArrayList<>(params);pageArgs.add(size);pageArgs.add(offset); - var projects=db.queryForList("select distinct p.id"+joins+where+" order by p.id desc limit ? offset ?",Long.class,pageArgs.toArray()); + var projects=db.queryForList("select p.id"+joins+where+" group by p.id,p.create_time order by p.create_time desc,p.id desc limit ? offset ?",Long.class,pageArgs.toArray()); List> rows=List.of(); if(!projects.isEmpty()){ String marks=String.join(",",Collections.nCopies(projects.size(),"?"));var rowArgs=new ArrayList<>(params);rowArgs.addAll(projects); - rows=db.queryForList("select p.id projectId,p.project_code projectCode,p.project_name projectName,b.expense_category_id expenseCategoryId,coalesce(e.category_name,'待统一') expenseCategoryName,sum(round(r.quantity*r.final_unit_price,6)) quoteAmount,sum(case when r.final_unit_price is null then 1 else 0 end) unpricedCount"+joins+" left join expense_category e on e.id=b.expense_category_id "+where+" and p.id in ("+marks+") group by p.id,p.project_code,p.project_name,b.expense_category_id,e.category_name order by p.id desc,coalesce(min(e.sort_order),99999),b.expense_category_id",rowArgs.toArray()); + rows=db.queryForList("select p.id projectId,p.project_code projectCode,p.project_name projectName,b.expense_category_id expenseCategoryId,coalesce(e.category_name,'待统一') expenseCategoryName,sum(round(r.quantity*r.final_unit_price,6)) quoteAmount,sum(case when r.final_unit_price is null then 1 else 0 end) unpricedCount"+joins+" left join expense_category e on e.id=b.expense_category_id "+where+" and p.id in ("+marks+") group by p.id,p.create_time,p.project_code,p.project_name,b.expense_category_id,e.category_name order by p.create_time desc,p.id desc,coalesce(min(e.sort_order),99999),b.expense_category_id",rowArgs.toArray()); } var summary=db.queryForMap("select sum(round(r.quantity*r.final_unit_price,6)) quoteAmount,sum(case when r.final_unit_price is null then 1 else 0 end) unpricedCount"+joins+where,params.toArray()); return Map.of("rows",rows,"total",total,"summary",summary); diff --git a/ruoyi-admin/src/test/java/com/ruoyi/projectdev/DefaultListOrderTest.java b/ruoyi-admin/src/test/java/com/ruoyi/projectdev/DefaultListOrderTest.java new file mode 100644 index 0000000..867f0f6 --- /dev/null +++ b/ruoyi-admin/src/test/java/com/ruoyi/projectdev/DefaultListOrderTest.java @@ -0,0 +1,69 @@ +package com.ruoyi.projectdev; + +import java.util.*; +import org.junit.jupiter.api.Test; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import com.ruoyi.warehouse.domain.*; +import static org.junit.jupiter.api.Assertions.*; + +/** Run the actual mapper ordering against isolated data, including paging ties. */ +class DefaultListOrderTest { + private JdbcTemplate db(){return new JdbcTemplate(new DriverManagerDataSource("jdbc:h2:mem:"+UUID.randomUUID()+";MODE=MySQL;DB_CLOSE_DELAY=-1","sa",""));} + private String order(String mapper,String method,Object query)throws Exception { + String sql=AuthorizedDatabaseTestSupport.configuration("mapper/warehouse/"+mapper+"Mapper.xml") + .getMappedStatement("com.ruoyi.warehouse.mapper."+mapper+"Mapper."+method) + .getBoundSql(query).getSql().replaceAll("\\s+"," ").trim(); + return sql.substring(sql.lastIndexOf("order by")); + } + @Test void unfinishedPurchasesPrecedeCompletedAndEqualTimesStayStableAcrossPages()throws Exception { + var db=db();db.execute("create table purchase_request(id bigint,purchase_status int,create_time timestamp)"); + db.execute("insert into purchase_request values(99,4,'2026-12-01'),(8,2,'2026-11-01'),(7,0,'2026-11-01'),(6,2,'2026-10-01'),(100,5,'2026-12-02')"); + String sql="select pr.id from purchase_request pr "+order("PurchaseRequest","selectPurchaseRequestList",new PurchaseRequest()); + assertEquals(List.of(8L,7L),db.queryForList(sql+" limit 2 offset 0",Long.class)); + assertEquals(List.of(6L,100L,99L),db.queryForList(sql+" limit 3 offset 2",Long.class)); + } + @Test void inboundUsesBusinessDateAndFallbackWithoutChangingCreationTime()throws Exception { + var db=db();db.execute("create table in_record(id bigint,in_status int,business_date date,confirm_time timestamp,create_time timestamp)"); + db.execute("insert into in_record values(1,1,'2026-12-01',null,'2026-12-01'),(2,0,'2026-01-01',null,'2026-11-01'),(3,1,'2026-12-02',null,'2026-10-01'),(4,1,null,'2026-12-03','2026-09-01')"); + assertEquals(List.of(2L,4L,3L,1L),db.queryForList("select ir.id from in_record ir "+order("InRecord","selectInRecordList",new InRecord()),Long.class)); + assertEquals("2026-09-01",db.queryForObject("select cast(create_time as date) from in_record where id=4",java.sql.Date.class).toString()); + } + @Test void batchQueuesPrioritizePendingAcceptanceThenOpenBatchesAndUseDatesWithinEachGroup()throws Exception { + var db=db();db.execute("create table purchase_batch(id bigint,pending_count int,open_count int,request_count int,business_date date,create_time timestamp)"); + db.execute("insert into purchase_batch values(1,0,0,2,'2026-12-01','2026-12-01'),(2,1,1,1,'2026-10-01','2026-10-01'),(3,0,1,1,'2026-11-01','2026-11-01'),(4,0,0,0,'2026-11-02','2026-11-02')"); + assertEquals(List.of(2L,4L,3L,1L),db.queryForList("select pb.id from purchase_batch pb "+order("PurchaseBatch","selectPurchaseBatchList",new PurchaseBatch()),Long.class)); + } + @Test void pendingAcceptanceWinsOverNewerFinishedRecordsAndOutboundUsesItsBusinessDate()throws Exception { + var db=db();db.execute("create table purchase_arrival(id bigint,acceptance_status int,arrival_date date,create_time timestamp)"); + db.execute("insert into purchase_arrival values(1,1,'2026-12-01','2026-12-01'),(2,0,'2026-10-01','2026-10-01'),(3,0,'2026-11-01','2026-11-01')"); + assertEquals(List.of(2L,3L,1L),db.queryForList("select pa.id from purchase_arrival pa "+order("PurchaseArrival","selectPurchaseArrivalList",1L),Long.class)); + db.execute("create table out_record(id bigint,out_time timestamp,create_time timestamp)"); + db.execute("insert into out_record values(1,'2026-12-01','2026-10-01'),(2,'2026-11-01','2026-12-01'),(3,'2026-12-02','2026-09-01')"); + assertEquals(List.of(3L,1L,2L),db.queryForList("select orr.id from out_record orr "+order("OutRecord","selectOutRecordList",new OutRecord()),Long.class)); + } + @Test void pendingInboundAndArrivalQueuesUseFifoBeforePagingWithStableTimeTies()throws Exception { + var db=db();db.execute("create table in_record(id bigint,in_status int,business_date date,confirm_time timestamp,create_time timestamp)"); + db.execute("insert into in_record values(1,0,'2026-12-01',null,'2026-10-01'),(2,0,'2026-01-01',null,'2026-11-01'),(3,0,'2026-01-01',null,'2026-10-01'),(4,1,'2026-12-02',null,'2026-09-01')"); + String inbound="select ir.id from in_record ir "+order("InRecord","selectInRecordList",new InRecord()); + assertEquals(List.of(1L,3L),db.queryForList(inbound+" limit 2 offset 0",Long.class)); + assertEquals(List.of(2L,4L),db.queryForList(inbound+" limit 2 offset 2",Long.class)); + db.execute("create table purchase_request(id bigint,purchase_status int,create_time timestamp)"); + db.execute("insert into purchase_request values(9,2,'2026-10-01'),(2,3,'2026-11-01'),(7,2,'2026-10-01')"); + for(int mode=0;mode<3;mode++){ + var query=new PurchaseRequest();if(mode==0)query.setPendingRegistration(true);else if(mode==1)query.setArrivalReady(true);else query.setNotReceived(true); + String arrivals="select pr.id from purchase_request pr "+order("PurchaseRequest","selectPurchaseRequestList",query); + assertEquals(List.of(7L,9L),db.queryForList(arrivals+" limit 2 offset 0",Long.class)); + assertEquals(List.of(2L),db.queryForList(arrivals+" limit 2 offset 2",Long.class)); + } + } + @Test void acceptanceQueueFollowsEarliestPendingArrivalRatherThanPurchaseCreation()throws Exception { + var db=db();db.execute("create table purchase_request(id bigint,create_time timestamp)"); + db.execute("insert into purchase_request values(1,'2026-01-01'),(2,'2026-02-01'),(3,'2026-02-01')"); + db.execute("create table pending(purchase_request_id bigint,first_pending_time timestamp,first_pending_created_time timestamp)"); + db.execute("insert into pending values(1,'2026-12-01','2026-12-01'),(2,'2026-11-01','2026-11-02'),(3,'2026-11-01','2026-11-01')"); + var query=new PurchaseRequest();query.setPendingAcceptance(true);query.setArrivalReady(true); + String sql="select pr.id from purchase_request pr join pending pa on pa.purchase_request_id=pr.id "+order("PurchaseRequest","selectPurchaseRequestList",query); + assertEquals(List.of(3L,2L,1L),db.queryForList(sql,Long.class)); + } +} diff --git a/ruoyi-admin/src/test/java/com/ruoyi/projectdev/ProductionQueryUsabilityTest.java b/ruoyi-admin/src/test/java/com/ruoyi/projectdev/ProductionQueryUsabilityTest.java index 03c0192..36ad55a 100644 --- a/ruoyi-admin/src/test/java/com/ruoyi/projectdev/ProductionQueryUsabilityTest.java +++ b/ruoyi-admin/src/test/java/com/ruoyi/projectdev/ProductionQueryUsabilityTest.java @@ -25,7 +25,7 @@ class ProductionQueryUsabilityTest { var db=mock(JdbcTemplate.class);var service=service(db); service.page(2L,3L,"READY"," robot ",2,20);service.filteredTasks(2L,3L,"READY"," robot "); var calls=lists(db);assertEquals(2,calls.size());String page=calls.get(0).getArgument(0),export=calls.get(1).getArgument(0); - assertEquals(page.substring(0,page.indexOf(" order by t.id desc")),export.substring(0,export.indexOf(" order by t.id desc"))); + assertEquals(page.substring(0,page.lastIndexOf(" order by ")),export.substring(0,export.lastIndexOf(" order by "))); assertTrue(page.endsWith("limit ? offset ?"));assertFalse(export.contains("limit ?")); assertArrayEquals(new Object[]{2L,3L,"%robot%"},Arrays.copyOfRange(calls.get(1).getArguments(),1,4)); } @@ -34,7 +34,7 @@ class ProductionQueryUsabilityTest { service.actionPage(2L,3L,"SCRAP_STOCK",false," screw ","2026-10-01","2026-10-13",2,20); service.filteredActions(2L,3L,"SCRAP_STOCK",false," screw ","2026-10-01","2026-10-13"); var calls=lists(db);String page=calls.get(0).getArgument(0),export=calls.get(1).getArgument(0); - assertEquals(page.substring(0,page.indexOf(" order by a.id desc")),export.substring(0,export.indexOf(" order by a.id desc"))); + assertEquals(page.substring(0,page.lastIndexOf(" order by ")),export.substring(0,export.lastIndexOf(" order by "))); assertFalse(export.contains("limit ?"));var args=calls.get(1).getArguments(); assertEquals(false,args[4]);assertEquals("%screw%",args[5]);assertEquals(java.time.LocalDate.of(2026,10,1),args[6]); } diff --git a/ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/SysFeedbackMapperTest.java b/ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/SysFeedbackMapperTest.java index 33a93d7..56e89bb 100644 --- a/ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/SysFeedbackMapperTest.java +++ b/ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/SysFeedbackMapperTest.java @@ -105,7 +105,7 @@ class SysFeedbackMapperTest .contains("inner join sys_feedback f on f.id = i.feedback_id and f.user_id = i.owner_id")); mine.put("ownerId", null); assertFalse(sql("selectFeedbackList", mine).contains("user_id = ?")); - assertTrue(sql("selectFeedbackList", mine).endsWith("order by create_time desc, id desc")); + assertTrue(sql("selectFeedbackList", mine).endsWith("order by case when status in ('PENDING','PROCESSING') then 0 else 1 end, create_time desc, id desc")); String contentSql = sql("selectImage", Map.of("id", "a".repeat(32), "viewerId", 201L, "admin", false)); assertTrue(contentSql.contains("i.feedback_id is null and i.owner_id = ?")); assertTrue(contentSql.contains("f.id is not null and (f.user_id = ? or ? = true)")); diff --git a/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml b/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml index c27b71b..bd9b60f 100644 --- a/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml +++ b/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml @@ -75,6 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND date_format(create_time,'%Y%m%d') <= date_format(#{params.endTime},'%Y%m%d') + order by create_time desc, table_id desc @@ -71,7 +71,7 @@ e.series_id,s.series_name,s.version series_version,e.edition_tag,e.source_product_id,e.source_bom_id from production_product p join product_info i on i.id=p.item_id left join bom_version b on b.item_id=p.item_id and b.scope_type='PUBLIC' and b.is_default=1 and b.del_flag='0' left join production_product_edition e on e.product_id=p.id left join production_product_series s on s.id=e.series_id - + insert into production_product(item_id,remark,create_by) values(#{itemId},#{remark},#{createBy}) @@ -80,7 +80,7 @@ update production_product set del_flag='2',version=version+1,update_time=sysdate() where id=#{id} and del_flag='0' update production_product set del_flag='0',version=version+1,update_time=sysdate() where id=#{id} and del_flag='2' select p.*,i.product_code item_code,i.product_name item_name,i.brand,i.spec,i.unit,b.version_tag from project_product p join product_info i on i.id=p.item_id left join bom_version b on b.id=p.bom_id - + insert into project_product(project_id,item_id,bom_id,remark,create_by) values(#{projectId},#{itemId},#{bomId},#{remark},#{createBy}) diff --git a/ruoyi-system/src/main/resources/mapper/project/ProjectInfoMapper.xml b/ruoyi-system/src/main/resources/mapper/project/ProjectInfoMapper.xml index 46be625..1771933 100644 --- a/ruoyi-system/src/main/resources/mapper/project/ProjectInfoMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/project/ProjectInfoMapper.xml @@ -85,7 +85,8 @@ and p.project_status = #{project.projectStatus} and p.project_type = #{project.projectType} - order by p.id desc + order by case when p.project_status in (0,1) then 0 else 1 end, + p.create_time desc, p.id desc diff --git a/ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml index a5ff114..0b7e541 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml @@ -57,7 +57,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and date_format(create_time,'%Y%m%d') <= date_format(#{params.endTime},'%Y%m%d') - + order by create_time desc, config_id desc + diff --git a/ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml index b009c85..0ec0dba 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml @@ -47,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" OR cu.nick_name like concat('%', #{createBy}, '%')) - order by sn.notice_id desc + order by sn.create_time desc, sn.notice_id desc diff --git a/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml index d32f2ac..9c98c86 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml @@ -69,7 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND sol.oper_time <= #{params.endTime} - order by sol.oper_id desc + order by sol.oper_time desc, sol.oper_id desc diff --git a/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml index 227c459..17a8e99 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml @@ -35,10 +35,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND post_name like concat('%', #{postName}, '%') + order by post_sort asc, create_time desc, post_id desc where pa.purchase_request_id = #{purchaseRequestId} - order by pa.id desc + order by case when pa.acceptance_status=0 then 0 else 1 end, + case when pa.acceptance_status=0 then coalesce(pa.arrival_date,pa.create_time) end asc, + case when pa.acceptance_status=0 then pa.create_time end asc, + case when pa.acceptance_status=0 then pa.id end asc, + pa.arrival_date desc, pa.create_time desc, pa.id desc @@ -80,7 +81,7 @@ and (pb.batch_no like concat('%', #{keyword}, '%') or pb.batch_name like concat('%', #{keyword}, '%')) - order by pb.id desc + order by pb.business_date desc, pb.create_time desc, pb.id desc limit 100 @@ -94,7 +95,7 @@ and (pb.batch_no like concat('%', #{keyword}, '%') or pb.batch_name like concat('%', #{keyword}, '%')) - order by pb.id desc + order by pb.business_date desc, pb.create_time desc, pb.id desc limit 100 diff --git a/ruoyi-system/src/main/resources/mapper/warehouse/PurchaseOperationLogMapper.xml b/ruoyi-system/src/main/resources/mapper/warehouse/PurchaseOperationLogMapper.xml index 0bdd5ff..8cc180f 100644 --- a/ruoyi-system/src/main/resources/mapper/warehouse/PurchaseOperationLogMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/warehouse/PurchaseOperationLogMapper.xml @@ -20,7 +20,7 @@ from purchase_operation_log pol left join sys_user su on su.user_id = pol.operator_id where pol.purchase_request_id = #{purchaseRequestId} - order by pol.id desc + order by pol.create_time desc, pol.id desc diff --git a/ruoyi-system/src/main/resources/mapper/warehouse/PurchaseRequestMapper.xml b/ruoyi-system/src/main/resources/mapper/warehouse/PurchaseRequestMapper.xml index d47a8b7..f709278 100644 --- a/ruoyi-system/src/main/resources/mapper/warehouse/PurchaseRequestMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/warehouse/PurchaseRequestMapper.xml @@ -101,7 +101,9 @@ left join ( select purchase_request_id, sum(case when acceptance_status = 1 then arrival_quantity-defective_quantity-returned_quantity else 0 end) as accepted_quantity, - sum(case when acceptance_status = 0 then arrival_quantity else 0 end) as pending_quantity + sum(case when acceptance_status = 0 then arrival_quantity else 0 end) as pending_quantity, + min(case when acceptance_status = 0 then coalesce(arrival_date,create_time) end) as first_pending_time, + min(case when acceptance_status = 0 then create_time end) as first_pending_created_time from purchase_arrival where acceptance_status in (0, 1) group by purchase_request_id @@ -148,7 +150,19 @@ and coalesce(pa.pending_quantity, 0) > 0 and pr.purchase_batch_no like concat('%', #{purchaseBatchNo}, '%') - order by pr.id desc + + + order by coalesce(pa.first_pending_time,pr.create_time) asc, + coalesce(pa.first_pending_created_time,pr.create_time) asc, pr.id asc + + + order by pr.create_time asc, pr.id asc + + + order by case when pr.purchase_status in (4,5) then 1 else 0 end, + pr.create_time desc, pr.id desc + +