feat(purchase): 实现采购PDF解析与验收确认功能
- 新增采购验收确认表及附件系统生成标识字段 - 实现采购PDF多页明细解析合并与数据校验逻辑 - 支持报价与实际金额一致的自动赋值指令处理 - 添加移动端到货照片补充上传及重试机制测试 - 补充后端PDF解析路由分发及事务处理单元测试
This commit is contained in:
parent
b39fc01865
commit
91f473b7c7
@ -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<String,Object> matrix(List<Map<String,Object>> projects){var result=new LinkedHashMap<String,Object>();if(projects.isEmpty())return result;
|
||||
|
||||
@ -30,8 +30,8 @@ public class KpiService {
|
||||
private void requireManager(){if(!manager())throw new ServiceException("考核管理由KPI管理员协助办理",403);}
|
||||
public Map<String,Object> capabilities(){return Map.of("manage",manager(),"categories",CATEGORIES,"templateVersion","v1","maxItems",200);}
|
||||
public List<Map<String,Object>> 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<String,Object> create(PeriodInput input){
|
||||
|
||||
@ -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<Map<String,Object>> 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);
|
||||
|
||||
@ -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));
|
||||
}
|
||||
}
|
||||
@ -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]);
|
||||
}
|
||||
|
||||
@ -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)"));
|
||||
|
||||
@ -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')
|
||||
</if>
|
||||
</where>
|
||||
order by create_time desc, table_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult">
|
||||
|
||||
@ -44,7 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and date_format(create_time,'%Y%m%d') <= date_format(#{params.endTime},'%Y%m%d')
|
||||
</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
order by create_time desc, job_log_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectJobLogAll" resultMap="SysJobLogResult">
|
||||
|
||||
@ -41,6 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
AND invoke_target like concat('%', #{invokeTarget}, '%')
|
||||
</if>
|
||||
</where>
|
||||
order by case when status='0' then 0 else 1 end, create_time desc, job_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectJobAll" resultMap="SysJobResult">
|
||||
|
||||
@ -38,7 +38,7 @@ public class ProductAttachmentService {
|
||||
return new PurchaseDocumentService.Validated(bytes,"application/octet-stream");
|
||||
}catch(ServiceException error){throw error;}catch(Exception error){throw new ServiceException("附件读取失败或格式无效,请重新上传");}
|
||||
}
|
||||
@Transactional(readOnly=true) public List<Map<String,Object>> list(Long productId){authorize(productId,false);return db.queryForList("select id,original_name name,content_type contentType,byte_size size,create_by uploadedBy,create_time uploadedAt from production_product_attachment where product_id=? and deleted=0 order by create_time desc,id",productId);}
|
||||
@Transactional(readOnly=true) public List<Map<String,Object>> list(Long productId){authorize(productId,false);return db.queryForList("select id,original_name name,content_type contentType,byte_size size,create_by uploadedBy,create_time uploadedAt from production_product_attachment where product_id=? and deleted=0 order by create_time desc,id desc",productId);}
|
||||
|
||||
@Transactional public Map<String,Object> upload(Long productId,String id,MultipartFile file){
|
||||
authorize(productId,true);requireId(id);requireStorage();
|
||||
|
||||
@ -32,7 +32,7 @@ public class ProductionService {
|
||||
private static final String TASK_SELECT="select t.*,case when t.status='OPEN' and not exists(select 1 from production_action x where x.task_id=t.id) and not exists(select 1 from production_task x where x.parent_task_id=t.id) and not exists(select 1 from purchase_request x where x.production_task_id=t.id) and not exists(select 1 from in_record x where x.production_task_id=t.id) and not exists(select 1 from production_settlement x where x.task_id=t.id) then 1 else 0 end editable_identity,p.project_name,i.product_name item_name,i.product_code,i.brand,i.spec,i.unit,b.version_tag,case when not exists(select 1 from bom_line bl where bl.bom_id=t.bom_id and bl.del_flag='0') or exists(select 1 from production_action pa where pa.task_id=t.id and pa.active=1 and pa.kind='ISSUE') then 1 else 0 end material_recorded,coalesce((select sum(quantity) from production_action where task_id=t.id and active=1 and kind='COMPLETE'),0) good_quantity,coalesce((select sum(quantity) from production_action where task_id=t.id and active=1 and kind='SCRAP_ASSEMBLY'),0) scrap_quantity from production_task t join project_info p on p.id=t.project_id join product_info i on i.id=t.item_id left join bom_version b on b.id=t.bom_id";
|
||||
private static final String ACTION_SELECT="select a.*,p.project_name,i.product_name item_name,i.brand,i.spec,i.unit,w.area_name,e.original_cost,e.effective_cost,t.task_no,coalesce((select sum(r.quantity) from production_action r where r.source_id=a.id and r.active=1 and r.kind in ('RETURN','DELIVERY_RETURN','SCRAP_ISSUED')),0) handled_quantity from production_action a join project_info p on p.id=a.project_id join product_info i on i.id=a.item_id left join warehouse_area w on w.id=a.area_id left join inventory_cost_event e on e.id=a.cost_event_id left join production_task t on t.id=a.task_id";
|
||||
|
||||
public List<Map<String,Object>> tasks(Long projectId,Long itemId){return costViews(db.queryForList(TASK_SELECT+" where t.status<>'CANCELLED' and (? is null or t.project_id=?) and (? is null or t.item_id=?) order by t.id desc",projectId,projectId,itemId,itemId));}
|
||||
public List<Map<String,Object>> tasks(Long projectId,Long itemId){return costViews(db.queryForList(TASK_SELECT+" where t.status<>'CANCELLED' and (? is null or t.project_id=?) and (? is null or t.item_id=?) order by case when t.status='OPEN' then 0 else 1 end,t.business_date desc,t.create_time desc,t.id desc",projectId,projectId,itemId,itemId));}
|
||||
private List<Map<String,Object>> costViews(List<Map<String,Object>> rows){return rows.stream().map(ProductionCostView::of).toList();}
|
||||
private List<Map<String,Object>> settlementCostViews(List<Map<String,Object>> rows){
|
||||
return rows.stream().map(source->{
|
||||
@ -53,7 +53,7 @@ public class ProductionService {
|
||||
result.sort(Comparator.comparing((Map<String,Object> r)->Objects.toString(r.get("settled_time"),"")).reversed());return result;
|
||||
}
|
||||
public Map<String,Object> task(Long id){var rows=db.queryForList(TASK_SELECT+" where t.id=?",id);if(rows.isEmpty())throw fail("生产任务不存在");projects.requireProjectAccess(l(rows.get(0),"project_id"));return rows.get(0);}
|
||||
public List<Map<String,Object>> actions(Long projectId,Long taskId){return db.queryForList(ACTION_SELECT+" where (? is null or a.project_id=?) and (? is null or a.task_id=?) order by a.id desc",projectId,projectId,taskId,taskId);}
|
||||
public List<Map<String,Object>> actions(Long projectId,Long taskId){return db.queryForList(ACTION_SELECT+" where (? is null or a.project_id=?) and (? is null or a.task_id=?) order by a.business_date desc,a.create_time desc,a.id desc",projectId,projectId,taskId,taskId);}
|
||||
private record QueryFilter(String sql,List<Object> args) {}
|
||||
private QueryFilter actionFilter(Long projectId,Long taskId,String kind,Boolean active,String keyword,String beginDate,String endDate){
|
||||
var where=new StringBuilder(" where 1=1");var args=new ArrayList<Object>();
|
||||
@ -65,13 +65,13 @@ public class ProductionService {
|
||||
}
|
||||
public List<Map<String,Object>> filteredActions(Long projectId,Long taskId,String kind,Boolean active,String keyword,String beginDate,String endDate){
|
||||
var filter=actionFilter(projectId,taskId,kind,active,keyword,beginDate,endDate);
|
||||
return db.queryForList(ACTION_SELECT+filter.sql()+" order by a.id desc",filter.args().toArray());
|
||||
return db.queryForList(ACTION_SELECT+filter.sql()+" order by a.business_date desc,a.create_time desc,a.id desc",filter.args().toArray());
|
||||
}
|
||||
public Map<String,Object> actionPage(Long projectId,Long taskId,String kind,Boolean active,String keyword,String beginDate,String endDate,int page,int size){
|
||||
var filter=actionFilter(projectId,taskId,kind,active,keyword,beginDate,endDate);
|
||||
String sql=ACTION_SELECT+filter.sql();var args=new ArrayList<Object>(filter.args());
|
||||
long total=db.queryForObject("select count(*) from ("+sql+") counted",Long.class,args.toArray());size=Math.max(1,Math.min(100,size));args.add(size);args.add((long)(Math.max(1,page)-1)*size);
|
||||
return Map.of("rows",db.queryForList(sql+" order by a.id desc limit ? offset ?",args.toArray()),"total",total);
|
||||
return Map.of("rows",db.queryForList(sql+" order by a.business_date desc,a.create_time desc,a.id desc limit ? offset ?",args.toArray()),"total",total);
|
||||
}
|
||||
private Map<String,Object> action(Long id){var rows=db.queryForList(ACTION_SELECT+" where a.id=?",id);if(rows.isEmpty())throw fail("业务记录不存在");return rows.get(0);}
|
||||
public Map<String,Object> detail(Long id){var result=ProductionCostView.of(task(id));result.put("children",costViews(db.queryForList(TASK_SELECT+" where t.parent_task_id=? order by t.id",id)));result.put("openChildCount",db.queryForObject("select count(*) from production_task where parent_task_id=? and status='OPEN'",Long.class,id));result.put("pendingReceiptCount",db.queryForObject("select count(*) from in_record where production_task_id=? and in_status=0",Long.class,id));result.put("current_material_cost",material(id,null));result.put("actions",actions(null,id));result.put("needs",needs(id));result.put("settlements",settlementCostViews(db.queryForList("select s.*,'SETTLED' status,case when not exists(select 1 from bom_line bl where bl.bom_id=t.bom_id and bl.del_flag='0') or exists(select 1 from production_action a where a.task_id=s.task_id and a.kind='ISSUE' and a.create_time<s.create_time and (a.active=1 or a.void_time>s.create_time)) then 1 else 0 end material_recorded from production_settlement s join production_task t on t.id=s.task_id where s.task_id=? order by s.version desc",id)));return result;}
|
||||
@ -107,7 +107,7 @@ public class ProductionService {
|
||||
}
|
||||
public List<Map<String,Object>> filteredTasks(Long projectId,Long itemId,String status,String keyword){
|
||||
var filter=taskFilter(projectId,itemId,status,keyword,null);
|
||||
return costViews(db.queryForList(TASK_SELECT+filter.sql()+" order by t.id desc",filter.args().toArray()));
|
||||
return costViews(db.queryForList(TASK_SELECT+filter.sql()+" order by case when t.status='OPEN' then 0 else 1 end,t.business_date desc,t.create_time desc,t.id desc",filter.args().toArray()));
|
||||
}
|
||||
public Map<String,Object> page(Long projectId,Long itemId,String status,String keyword,int page,int size) {
|
||||
return operationPage(projectId,itemId,status,keyword,null,page,size);
|
||||
@ -117,7 +117,7 @@ public class ProductionService {
|
||||
var filter=taskFilter(projectId,itemId,status,keyword,operation);
|
||||
Long total=db.queryForObject("select count(*) from ("+TASK_SELECT+filter.sql()+") counted",Long.class,filter.args().toArray());
|
||||
var values=new ArrayList<Object>(filter.args());values.add(size);values.add((long)(page-1)*size);
|
||||
return Map.of("rows",costViews(db.queryForList(TASK_SELECT+filter.sql()+" order by t.id desc limit ? offset ?",values.toArray())),"total",total);
|
||||
return Map.of("rows",costViews(db.queryForList(TASK_SELECT+filter.sql()+" order by case when t.status='OPEN' then 0 else 1 end,t.business_date desc,t.create_time desc,t.id desc limit ? offset ?",values.toArray())),"total",total);
|
||||
}
|
||||
/** Read-only aggregation: amounts use the identical per-area rounding as stock list. */
|
||||
public Map<String,Object> projectSummary(Long projectId){
|
||||
|
||||
@ -43,7 +43,7 @@ public class ProjectAchievementService {
|
||||
String q=text(keyword,100,"关键字");if(!q.isEmpty()){where.append(" and a.title like ?");args.add("%"+q+"%");}
|
||||
String from=" from project_achievement a join project_info p on p.id=a.project_id join sys_user u on u.user_id=a.owner_id";
|
||||
long total=db.queryForObject("select count(*)"+from+where,Long.class,args.toArray());args.add(size);args.add((long)(page-1)*size);
|
||||
var rows=db.queryForList("select a.id,a.project_id projectId,p.project_name projectName,a.kind,a.title,a.owner_id ownerId,u.nick_name ownerName,a.progress,a.archived,a.version,a.update_time updateTime,a.content_json content"+from+where+" order by a.id desc limit ? offset ?",args.toArray());
|
||||
var rows=db.queryForList("select a.id,a.project_id projectId,p.project_name projectName,a.kind,a.title,a.owner_id ownerId,u.nick_name ownerName,a.progress,a.archived,a.version,a.update_time updateTime,a.content_json content"+from+where+" order by a.archived asc,case when a.progress='TERMINATED' then 1 else 0 end,a.create_time desc,a.id desc limit ? offset ?",args.toArray());
|
||||
boolean writable=SecurityUtils.isAdmin()||SecurityUtils.hasPermi("project:achievement:edit")||SecurityUtils.hasPermi("project:project:manage");
|
||||
boolean administrator=SecurityUtils.isAdmin(actor);
|
||||
Set<Long> managed=new HashSet<>();if(writable&&!administrator&&!rows.isEmpty())for(var membership:db.queryForList("select project_id from pm_collab_project_member where user_id=? and member_role='MANAGER'",actor))managed.add(((Number)membership.get("project_id")).longValue());
|
||||
|
||||
@ -111,7 +111,7 @@ public class ItemCategoryApplicationService {
|
||||
if(!keyword.isBlank()){where+=" and (a.category_name like ? escape '!' or a.example_name like ? escape '!')";String pattern="%"+keyword.replace("!","!!").replace("%","!%").replace("_","!_")+"%";args.add(pattern);args.add(pattern);}
|
||||
Long total=jdbc.queryForObject("select count(*) from item_category_application a"+where,Long.class,args.toArray());
|
||||
size=Math.min(100,Math.max(1,size));page=Math.max(1,page);args.add(size);args.add((long)(page-1)*size);
|
||||
var rows=jdbc.queryForList("select a.id,a.category_type as type,a.category_name as name,a.parent_code as parentCode,coalesce(g.dict_code,concat('pending-group-',pg.id)) as parentId,coalesce(g.dict_label,pg.effective_name,pg.category_name) as parentLabel,a.parent_application_id as parentApplicationId,case when g.dict_code is null and pg.status='PENDING' then 'PENDING' else 'CONFIRMED' end as parentReviewStatus,a.description,a.example_name as exampleName,a.example_spec as exampleSpec,a.status,a.resolved_dict_code as resolvedDictCode,coalesce(a.effective_name,a.category_name) as effectiveName,a.product_count as productCount,a.purchase_count as purchaseCount,(select count(*) from item_category_usage u join item_category_application ca on ca.id=u.application_id where ca.id=a.id or ca.parent_application_id=a.id and ca.status='PENDING') as usageCount,(select count(*) from item_category_usage u join purchase_request r on r.id=u.entity_id and r.del_flag='0' where (u.application_id=a.id or u.application_id in(select ca.id from item_category_application ca where ca.parent_application_id=a.id and ca.status='PENDING')) and u.entity_type='PURCHASE' and r.category=(select coalesce(ca.effective_name,ca.category_name) from item_category_application ca where ca.id=u.application_id) collate utf8mb4_unicode_ci) as pendingPurchaseCount,(select count(*) from item_category_usage u join product_info p on p.id=u.entity_id where (u.application_id=a.id or u.application_id in(select ca.id from item_category_application ca where ca.parent_application_id=a.id and ca.status='PENDING')) and u.entity_type='PRODUCT' and p.category=(select coalesce(ca.effective_name,ca.category_name) from item_category_application ca where ca.id=u.application_id) collate utf8mb4_unicode_ci) as pendingProductCount,a.applicant_name as applicantName,a.reviewer_name as reviewerName,a.review_note as reviewNote,a.create_time as createTime,a.review_time as reviewTime from item_category_application a left join item_category_application pg on pg.id=a.parent_application_id left join sys_dict_data g on g.dict_code=coalesce(a.parent_code,pg.resolved_dict_code)"+where+" order by a.id desc limit ? offset ?",args.toArray());
|
||||
var rows=jdbc.queryForList("select a.id,a.category_type as type,a.category_name as name,a.parent_code as parentCode,coalesce(g.dict_code,concat('pending-group-',pg.id)) as parentId,coalesce(g.dict_label,pg.effective_name,pg.category_name) as parentLabel,a.parent_application_id as parentApplicationId,case when g.dict_code is null and pg.status='PENDING' then 'PENDING' else 'CONFIRMED' end as parentReviewStatus,a.description,a.example_name as exampleName,a.example_spec as exampleSpec,a.status,a.resolved_dict_code as resolvedDictCode,coalesce(a.effective_name,a.category_name) as effectiveName,a.product_count as productCount,a.purchase_count as purchaseCount,(select count(*) from item_category_usage u join item_category_application ca on ca.id=u.application_id where ca.id=a.id or ca.parent_application_id=a.id and ca.status='PENDING') as usageCount,(select count(*) from item_category_usage u join purchase_request r on r.id=u.entity_id and r.del_flag='0' where (u.application_id=a.id or u.application_id in(select ca.id from item_category_application ca where ca.parent_application_id=a.id and ca.status='PENDING')) and u.entity_type='PURCHASE' and r.category=(select coalesce(ca.effective_name,ca.category_name) from item_category_application ca where ca.id=u.application_id) collate utf8mb4_unicode_ci) as pendingPurchaseCount,(select count(*) from item_category_usage u join product_info p on p.id=u.entity_id where (u.application_id=a.id or u.application_id in(select ca.id from item_category_application ca where ca.parent_application_id=a.id and ca.status='PENDING')) and u.entity_type='PRODUCT' and p.category=(select coalesce(ca.effective_name,ca.category_name) from item_category_application ca where ca.id=u.application_id) collate utf8mb4_unicode_ci) as pendingProductCount,a.applicant_name as applicantName,a.reviewer_name as reviewerName,a.review_note as reviewNote,a.create_time as createTime,a.review_time as reviewTime from item_category_application a left join item_category_application pg on pg.id=a.parent_application_id left join sys_dict_data g on g.dict_code=coalesce(a.parent_code,pg.resolved_dict_code)"+where+" order by case when a.status='PENDING' then 0 else 1 end,a.create_time desc,a.id desc limit ? offset ?",args.toArray());
|
||||
return Map.of("rows",rows,"total",total,"canReview",canReview());
|
||||
}
|
||||
private List<Map<String,Object>> linked(long id) {
|
||||
|
||||
@ -23,9 +23,9 @@ import com.ruoyi.warehouse.mapper.InRecordMapper;
|
||||
if(q.getAreaId()!=null){where.append(" and ir.area_id=?");args.add(q.getAreaId());}
|
||||
if("PURCHASE".equals(q.getSourceKind()))where.append(" and ir.purchase_request_id is not null");if("PRODUCTION".equals(q.getSourceKind()))where.append(" and ir.production_task_id is not null");if("OTHER".equals(q.getSourceKind()))where.append(" and ir.purchase_request_id is null and ir.production_task_id is null");
|
||||
String key="case when pr.purchase_batch_id is not null then concat('B:',pr.purchase_batch_id) when ir.production_task_id is not null then concat('P:',ir.production_task_id) else concat('O:',ir.id) end";
|
||||
String sql="select "+key+" `key`,coalesce(max(pr.purchase_batch_no),max(ir.source_no),max(ir.in_no)) title,group_concat(distinct p.project_name separator '、') projects,max(s.name) supplierName,count(*) recordCount from in_record ir left join purchase_request pr on pr.id=ir.purchase_request_id left join purchase_batch pb on pb.id=pr.purchase_batch_id left join supplier_info s on s.id=pb.supplier_id left join project_info p on p.id=ir.source_project_id left join product_info i on i.id=ir.product_id"+where+" group by "+key;
|
||||
String sql="select "+key+" `key`,coalesce(max(pr.purchase_batch_no),max(ir.source_no),max(ir.in_no)) title,group_concat(distinct p.project_name separator '、') projects,max(s.name) supplierName,count(*) recordCount,min(ir.create_time) queueTime,min(ir.id) queueId from in_record ir left join purchase_request pr on pr.id=ir.purchase_request_id left join purchase_batch pb on pb.id=pr.purchase_batch_id left join supplier_info s on s.id=pb.supplier_id left join project_info p on p.id=ir.source_project_id left join product_info i on i.id=ir.product_id"+where+" group by "+key;
|
||||
long total=db.queryForObject("select count(*) from ("+sql+") grouped",Long.class,args.toArray());var values=new ArrayList<>(args);values.add(Math.max(1,Math.min(100,size)));values.add((Math.max(1,page)-1)*Math.max(1,Math.min(100,size)));
|
||||
long itemTotal=db.queryForObject("select coalesce(sum(recordCount),0) from ("+sql+") grouped",Long.class,args.toArray());return Map.of("rows",db.queryForList(sql+" order by title limit ? offset ?",values.toArray()),"total",total,"itemTotal",itemTotal);
|
||||
long itemTotal=db.queryForObject("select coalesce(sum(recordCount),0) from ("+sql+") grouped",Long.class,args.toArray());return Map.of("rows",db.queryForList(sql+" order by queueTime asc,queueId asc limit ? offset ?",values.toArray()),"total",total,"itemTotal",itemTotal);
|
||||
}
|
||||
public List<InRecord> group(String key,InRecord q){
|
||||
com.ruoyi.warehouse.util.PendingReceiptScope.bind(q);
|
||||
|
||||
@ -62,7 +62,7 @@ public class PurchaseDocumentService {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private List<Attachment> files(Object group){return db.query("select id,original_name,content_type,byte_size,create_by,create_time,server_generated from purchase_document_attachment where group_id=? and deleted=0 order by create_time desc,id",(r,n)->new Attachment(r.getString(1),r.getString(2),r.getString(3),r.getInt(4),r.getString(5),r.getString(6),r.getBoolean(7)),group);}
|
||||
private List<Attachment> files(Object group){return db.query("select id,original_name,content_type,byte_size,create_by,create_time,server_generated from purchase_document_attachment where group_id=? and deleted=0 order by create_time desc,id desc",(r,n)->new Attachment(r.getString(1),r.getString(2),r.getString(3),r.getInt(4),r.getString(5),r.getString(6),r.getBoolean(7)),group);}
|
||||
|
||||
@Transactional
|
||||
public void saveNumber(String type, Long targetId, String kind, String number, Integer version) {
|
||||
|
||||
@ -18,7 +18,7 @@ public class SupplierService {
|
||||
public record Supplier(Long id,String name,String contact,String phone,String remark,Integer version,String email,String businessLicenseId){
|
||||
public Supplier(Long id,String name,String contact,String phone,String remark,Integer version){this(id,name,contact,phone,remark,version,null,null);}
|
||||
}
|
||||
public List<Map<String,Object>> list(String keyword){return db.queryForList("select s.*,s.business_license_id as businessLicenseId,a.original_name as businessLicenseName,a.content_type as businessLicenseContentType from supplier_info s left join supplier_license_attachment a on a.id=s.business_license_id where s.active=1 and (? is null or s.name like concat('%',?,'%')) order by s.name",keyword,keyword);}
|
||||
public List<Map<String,Object>> list(String keyword){return db.queryForList("select s.*,s.business_license_id as businessLicenseId,a.original_name as businessLicenseName,a.content_type as businessLicenseContentType from supplier_info s left join supplier_license_attachment a on a.id=s.business_license_id where s.active=1 and (? is null or s.name like concat('%',?,'%')) order by s.create_time desc,s.id desc",keyword,keyword);}
|
||||
@Transactional public void save(Supplier r){
|
||||
if(r==null)throw new ServiceException("请填写供应商资料");
|
||||
String name=r.name()==null?"":r.name().trim();if(name.isEmpty()||name.length()>200)throw new ServiceException("供应商名称必填,最多200字");
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
<include refid="VersionVo"/> where b.del_flag='0' and b.scope_type='PUBLIC'
|
||||
<if test="itemId != null">and b.item_id=#{itemId}</if>
|
||||
<if test="keyword != null and keyword != ''">and convert(concat_ws(' ',i.product_code,i.product_name,i.brand,i.spec,b.version_tag) using utf8mb4) collate utf8mb4_general_ci like concat('%',#{keyword},'%')</if>
|
||||
order by b.item_id,b.is_default desc,b.id desc
|
||||
order by b.item_id,b.is_default desc,b.create_time desc,b.id desc
|
||||
</select>
|
||||
<select id="selectVersion" resultMap="Version"><include refid="VersionVo"/> where b.id=#{id} and b.del_flag='0'</select>
|
||||
<select id="selectDefault" resultMap="Version"><include refid="VersionVo"/> where b.item_id=#{itemId} and b.is_default=1 and b.scope_type='PUBLIC' and b.del_flag='0'</select>
|
||||
@ -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</sql>
|
||||
<select id="selectProducts" resultMap="Product"><include refid="ProductVo"/> where p.del_flag='0'<if test="keyword != null and keyword != ''">and convert(concat_ws(' ',i.product_code,i.product_name,i.brand,i.spec,s.series_name,e.edition_tag) using utf8mb4) collate utf8mb4_general_ci like concat('%',#{keyword},'%')</if> order by p.id desc</select>
|
||||
<select id="selectProducts" resultMap="Product"><include refid="ProductVo"/> where p.del_flag='0'<if test="keyword != null and keyword != ''">and convert(concat_ws(' ',i.product_code,i.product_name,i.brand,i.spec,s.series_name,e.edition_tag) using utf8mb4) collate utf8mb4_general_ci like concat('%',#{keyword},'%')</if> order by p.create_time desc,p.id desc</select>
|
||||
<select id="selectProduct" resultMap="Product" flushCache="true" useCache="false"><include refid="ProductVo"/> where p.id=#{id} and p.del_flag='0'</select>
|
||||
<select id="selectProductByItem" resultMap="Product"><include refid="ProductVo"/> where p.item_id=#{itemId}</select>
|
||||
<insert id="insertProduct" useGeneratedKeys="true" keyProperty="id">insert into production_product(item_id,remark,create_by) values(#{itemId},#{remark},#{createBy})</insert>
|
||||
@ -80,7 +80,7 @@
|
||||
<update id="deleteProduct">update production_product set del_flag='2',version=version+1,update_time=sysdate() where id=#{id} and del_flag='0'</update>
|
||||
<update id="restoreProduct">update production_product set del_flag='0',version=version+1,update_time=sysdate() where id=#{id} and del_flag='2'</update>
|
||||
<sql id="ProjectProductVo">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</sql>
|
||||
<select id="selectProjectProducts" resultMap="ProjectProduct"><include refid="ProjectProductVo"/> where p.project_id=#{projectId} and p.del_flag='0' order by p.id</select>
|
||||
<select id="selectProjectProducts" resultMap="ProjectProduct"><include refid="ProjectProductVo"/> where p.project_id=#{projectId} and p.del_flag='0' order by p.create_time desc,p.id desc</select>
|
||||
<select id="selectProjectProduct" resultMap="ProjectProduct"><include refid="ProjectProductVo"/> where p.id=#{id} and p.del_flag='0'</select>
|
||||
<select id="selectProjectProductByItem" resultMap="ProjectProduct"><include refid="ProjectProductVo"/> where p.project_id=#{projectId} and p.item_id=#{itemId} and p.del_flag='0'</select>
|
||||
<insert id="insertProjectProduct" useGeneratedKeys="true" keyProperty="id">insert into project_product(project_id,item_id,bom_id,remark,create_by) values(#{projectId},#{itemId},#{bomId},#{remark},#{createBy})</insert>
|
||||
|
||||
@ -85,7 +85,8 @@
|
||||
<if test="project.projectStatus != null">and p.project_status = #{project.projectStatus}</if>
|
||||
<if test="project.projectType != null and project.projectType != ''">and p.project_type = #{project.projectType}</if>
|
||||
</where>
|
||||
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
|
||||
</sql>
|
||||
|
||||
<select id="selectProjectInfoById" resultMap="ProjectInfoResult">
|
||||
@ -105,7 +106,8 @@
|
||||
and (p.project_code like concat('%', #{keyword}, '%') or p.project_name like concat('%', #{keyword}, '%'))
|
||||
</if>
|
||||
</where>
|
||||
order by p.project_status, p.project_name limit 100
|
||||
order by case when p.project_status in (0,1) then 0 else 1 end,
|
||||
p.create_time desc, p.id desc limit 100
|
||||
</select>
|
||||
|
||||
<insert id="insertProjectInfo" parameterType="com.ruoyi.project.domain.ProjectInfo" useGeneratedKeys="true" keyProperty="id">
|
||||
|
||||
@ -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')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
order by create_time desc, config_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectConfigById" parameterType="Long" resultMap="SysConfigResult">
|
||||
<include refid="selectConfigVo"/>
|
||||
|
||||
@ -39,6 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and date_format(create_time,'%Y%m%d') <= date_format(#{params.endTime},'%Y%m%d')
|
||||
</if>
|
||||
</where>
|
||||
order by create_time desc, dict_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectDictTypeAll" resultMap="SysDictTypeResult">
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
and (title like concat('%', #{keyword}, '%') or description like concat('%', #{keyword}, '%'))
|
||||
</if>
|
||||
</where>
|
||||
order by create_time desc, id desc
|
||||
order by case when status in ('PENDING','PROCESSING') then 0 else 1 end, create_time desc, id desc
|
||||
</select>
|
||||
<select id="selectFeedback" resultMap="FeedbackResult">
|
||||
select id, feedback_type, title, description, page_path, page_title, status, reply,
|
||||
|
||||
@ -40,7 +40,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
AND login_time <= #{params.endTime}
|
||||
</if>
|
||||
</where>
|
||||
order by info_id desc
|
||||
order by login_time desc, info_id desc
|
||||
</select>
|
||||
|
||||
<delete id="deleteLogininforByIds" parameterType="Long">
|
||||
|
||||
@ -47,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
OR cu.nick_name like concat('%', #{createBy}, '%'))
|
||||
</if>
|
||||
</where>
|
||||
order by sn.notice_id desc
|
||||
order by sn.create_time desc, sn.notice_id desc
|
||||
</select>
|
||||
|
||||
<insert id="insertNotice" parameterType="SysNotice" useGeneratedKeys="true" keyProperty="noticeId">
|
||||
|
||||
@ -69,7 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
AND sol.oper_time <= #{params.endTime}
|
||||
</if>
|
||||
</where>
|
||||
order by sol.oper_id desc
|
||||
order by sol.oper_time desc, sol.oper_id desc
|
||||
</select>
|
||||
|
||||
<delete id="deleteOperLogByIds" parameterType="Long">
|
||||
|
||||
@ -35,10 +35,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
AND post_name like concat('%', #{postName}, '%')
|
||||
</if>
|
||||
</where>
|
||||
order by post_sort asc, create_time desc, post_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectPostAll" resultMap="SysPostResult">
|
||||
<include refid="selectPostVo"/>
|
||||
order by post_sort asc, create_time desc, post_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectPostById" parameterType="Long" resultMap="SysPostResult">
|
||||
|
||||
@ -53,7 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
order by r.role_sort
|
||||
order by r.role_sort, r.create_time desc, r.role_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectRolePermissionByUserId" parameterType="Long" resultMap="SysRoleResult">
|
||||
|
||||
@ -101,7 +101,10 @@
|
||||
or in_user.nick_name like concat('%', #{inOperator}, '%'))
|
||||
</if>
|
||||
</where>
|
||||
order by ir.id desc
|
||||
order by case when ir.in_status=0 then 0 else 1 end,
|
||||
case when ir.in_status=0 then ir.create_time end asc,
|
||||
case when ir.in_status=0 then ir.id end asc,
|
||||
coalesce(ir.business_date,ir.confirm_time,ir.create_time) desc, ir.create_time desc, ir.id desc
|
||||
</select>
|
||||
|
||||
<select id="selectInRecordById" parameterType="Long" resultMap="InRecordResult">
|
||||
|
||||
@ -83,7 +83,7 @@
|
||||
</if>
|
||||
<if test="sourceNo != null and sourceNo != ''">and orr.source_no like concat('%', #{sourceNo}, '%')</if>
|
||||
</where>
|
||||
order by orr.id desc
|
||||
order by coalesce(orr.out_time,orr.create_time) desc, orr.create_time desc, orr.id desc
|
||||
</select>
|
||||
|
||||
<select id="selectOutRecordById" parameterType="Long" resultMap="OutRecordResult">
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
</if>
|
||||
<if test="spec != null and spec != ''">and spec like concat('%', #{spec}, '%')</if>
|
||||
</where>
|
||||
order by id desc
|
||||
order by create_time desc, id desc
|
||||
</select>
|
||||
|
||||
<select id="selectProductInfoAll" resultMap="ProductInfoResult">
|
||||
|
||||
@ -70,7 +70,11 @@
|
||||
<select id="selectPurchaseArrivalList" parameterType="Long" resultMap="PurchaseArrivalResult">
|
||||
<include refid="selectPurchaseArrivalVo"/>
|
||||
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
|
||||
</select>
|
||||
|
||||
<select id="selectPurchaseArrivalById" parameterType="Long" resultMap="PurchaseArrivalResult">
|
||||
|
||||
@ -66,7 +66,8 @@
|
||||
<if test='progress == "confirm"'>having unpriced_count=0 and unlocked_count>0</if>
|
||||
<if test='progress == "open"'>having open_count>0</if>
|
||||
<if test='progress == "completed"'>having open_count=0</if>
|
||||
order by pb.id desc
|
||||
order by case when pending_count>0 then 0 when open_count>0 or request_count=0 then 1 else 2 end,
|
||||
pb.business_date desc, pb.create_time desc, pb.id desc
|
||||
</sql>
|
||||
<select id="selectPurchaseBatchList" parameterType="PurchaseBatch" resultMap="PurchaseBatchResult"><include refid="batchListQuery"/></select>
|
||||
<select id="selectPurchaseBatchTotals" parameterType="PurchaseBatch" resultType="map">select sum(actual_total_amount) as actualTotalAmount, sum(total_amount) as totalAmount, sum(unpriced_count) as unpricedCount from (<include refid="batchListQuery"/>) totals</select>
|
||||
@ -80,7 +81,7 @@
|
||||
<if test="keyword != null and keyword != ''">
|
||||
and (pb.batch_no like concat('%', #{keyword}, '%') or pb.batch_name like concat('%', #{keyword}, '%'))
|
||||
</if>
|
||||
order by pb.id desc
|
||||
order by pb.business_date desc, pb.create_time desc, pb.id desc
|
||||
limit 100
|
||||
</select>
|
||||
|
||||
@ -94,7 +95,7 @@
|
||||
and (pb.batch_no like concat('%', #{keyword}, '%') or pb.batch_name like concat('%', #{keyword}, '%'))
|
||||
</if>
|
||||
</where>
|
||||
order by pb.id desc
|
||||
order by pb.business_date desc, pb.create_time desc, pb.id desc
|
||||
limit 100
|
||||
</select>
|
||||
|
||||
|
||||
@ -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
|
||||
</select>
|
||||
|
||||
<insert id="insertPurchaseOperationLog" parameterType="PurchaseOperationLog" useGeneratedKeys="true" keyProperty="id">
|
||||
|
||||
@ -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 @@
|
||||
<if test="pendingAcceptance != null and pendingAcceptance">and coalesce(pa.pending_quantity, 0) > 0</if>
|
||||
<if test="purchaseBatchNo != null and purchaseBatchNo != ''">and pr.purchase_batch_no like concat('%', #{purchaseBatchNo}, '%')</if>
|
||||
</where>
|
||||
order by pr.id desc
|
||||
<choose>
|
||||
<when test="pendingAcceptance == true">
|
||||
order by coalesce(pa.first_pending_time,pr.create_time) asc,
|
||||
coalesce(pa.first_pending_created_time,pr.create_time) asc, pr.id asc
|
||||
</when>
|
||||
<when test="pendingRegistration == true or arrivalReady == true or notArrived == true or notReceived == true">
|
||||
order by pr.create_time asc, pr.id asc
|
||||
</when>
|
||||
<otherwise>
|
||||
order by case when pr.purchase_status in (4,5) then 1 else 0 end,
|
||||
pr.create_time desc, pr.id desc
|
||||
</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
<select id="selectPurchaseTaskSummary" resultMap="PurchaseTaskSummaryResult">
|
||||
|
||||
@ -58,7 +58,8 @@
|
||||
<if test="spec != null and spec != ''">and pi.spec like concat('%', #{spec}, '%')</if>
|
||||
<if test="checkStatus != null">and scr.check_status = #{checkStatus}</if>
|
||||
</where>
|
||||
order by scr.id desc
|
||||
order by case when scr.check_status=0 then 0 else 1 end,
|
||||
coalesce(scr.business_date,scr.create_time) desc, scr.create_time desc, scr.id desc
|
||||
</select>
|
||||
|
||||
<select id="selectStockCheckRecordById" parameterType="Long" resultMap="StockCheckRecordResult">
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<if test="areaCode != null and areaCode != ''">and area_code like concat('%', #{areaCode}, '%')</if>
|
||||
<if test="areaName != null and areaName != ''">and area_name like concat('%', #{areaName}, '%')</if>
|
||||
</where>
|
||||
order by id desc
|
||||
order by create_time desc, id desc
|
||||
</select>
|
||||
|
||||
<select id="selectWarehouseAreaAll" resultMap="WarehouseAreaResult">
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
<if test="status != null">and status = #{status}</if>
|
||||
<if test="createBy != null and createBy != ''">and create_by = #{createBy}</if>
|
||||
</where>
|
||||
order by id desc
|
||||
order by create_time desc, id desc
|
||||
</select>
|
||||
|
||||
<select id="selectWmsBatchJobById" parameterType="Long" resultMap="WmsBatchJobResult">
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
import request from '@/utils/request'
|
||||
import {sortPeopleResponse} from '@/utils/person-order'
|
||||
import {uploadFileResumable} from '@/api/common/file-transfers'
|
||||
const base='/project/workspace'
|
||||
export const workspaceCapabilities=()=>request({url:`${base}/capabilities`,workspaceCapabilityProbe:true})
|
||||
export const memberProjects=keyword=>request({url:`${base}/projects`,params:{keyword}})
|
||||
export const workspaceSummary=id=>request({url:`${base}/${id}`})
|
||||
export const projectMembers=id=>request({url:`${base}/${id}/members`})
|
||||
export const projectUserCandidates=(id,keyword)=>request({url:`${base}/${id}/users`,params:{keyword}})
|
||||
export const achievementUserCandidates=(id,keyword)=>request({url:`${base}/${id}/achievement-users`,params:{keyword}})
|
||||
export const projectMembers=id=>request({url:`${base}/${id}/members`}).then(sortPeopleResponse)
|
||||
export const projectUserCandidates=(id,keyword)=>request({url:`${base}/${id}/users`,params:{keyword}}).then(sortPeopleResponse)
|
||||
export const achievementUserCandidates=(id,keyword)=>request({url:`${base}/${id}/achievement-users`,params:{keyword}}).then(sortPeopleResponse)
|
||||
export const changeProjectMember=(id,data,remove=false)=>request({url:`${base}/${id}/members`,method:remove?'delete':'post',data})
|
||||
export const addProjectMembers=(id,data)=>request({url:`${base}/${id}/members/batch`,method:'post',data})
|
||||
export const transferProjectManager=(id,data)=>request({url:`${base}/${id}/manager`,method:'post',data})
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import request from '@/utils/request'
|
||||
import {sortPeopleResponse} from '@/utils/person-order'
|
||||
|
||||
export function optionselectUser() {
|
||||
return request({ url: '/warehouse/user/optionselect', method: 'get' })
|
||||
return request({ url: '/warehouse/user/optionselect', method: 'get' }).then(sortPeopleResponse)
|
||||
}
|
||||
|
||||
@ -194,6 +194,18 @@ body.mobile-workspace {
|
||||
}
|
||||
.el-table { font-size: var(--cmvr-table-font); }
|
||||
.el-table .cell { line-height: var(--cmvr-table-line); }
|
||||
/* Borderless tables share one alignment, including legacy left/right columns.
|
||||
Keep the cell's existing display mode so headers, fixed columns and editors
|
||||
retain their layout; flex cells also center their controls as a group. */
|
||||
.el-table :is(th,td).el-table__cell,
|
||||
.el-table :is(th,td).el-table__cell > .cell {
|
||||
text-align: center !important;
|
||||
}
|
||||
.el-table :is(th,td).el-table__cell > .cell { justify-content: center !important; }
|
||||
.el-table .cell :is(.el-button,.el-link) { text-align: center !important; }
|
||||
.el-table .item-summary__name { justify-content: center; }
|
||||
.el-table .item-summary__name > .table-text { flex: 0 1 auto; }
|
||||
.el-table .product-meta { justify-content: center; }
|
||||
.el-table .cell>.el-link,.el-table .cell .el-link__inner{max-width:100%;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.el-table .cell .el-link__inner{display:block}
|
||||
.el-table th .cell{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
<el-dialog v-model="peopleOpen" :title="peopleAction==='ADD'?'添加项目成员':hasManager?'转交项目经理':'设置项目经理'" :width="peopleAction==='ADD'?'min(820px,96vw)':'min(480px,94vw)'" append-to-body :close-on-click-modal="false" :close-on-press-escape="!busy" :show-close="!busy">
|
||||
<template v-if="peopleAction==='ADD'">
|
||||
<el-input v-model="memberKeyword" class="member-search" clearable :disabled="busy" placeholder="搜索姓名或账号" aria-label="搜索可选项目成员" @input="scheduleMemberSearch"/>
|
||||
<fieldset class="member-picker" :disabled="busy" :aria-busy="busy"><el-transfer v-model="selectedMembers" class="member-transfer" v-loading="searching" :data="transferData" :titles="['可选人员','待添加成员']" :button-texts="['移回','选入']" target-order="push" @change="rememberSelection"><template #default="{option}"><span :title="option.label">{{ option.label }}</span></template></el-transfer></fieldset>
|
||||
<fieldset class="member-picker" :disabled="busy" :aria-busy="busy"><el-transfer v-model="selectedMembers" class="member-transfer" v-loading="searching" :data="transferData" :titles="['可选人员','待添加成员']" :button-texts="['移回','选入']" target-order="original" @change="rememberSelection"><template #default="{option}"><span :title="option.label">{{ option.label }}</span></template></el-transfer></fieldset>
|
||||
<div class="member-picker-caption"><span>已选 {{ selectedMembers.length }} 人</span><span v-if="candidates.length>=50">当前显示前50人,可搜索查找其他人员</span></div>
|
||||
</template>
|
||||
<template v-else><el-alert :title="hasManager?'原项目经理保留为成员,新经理取得项目管理权限;不会自动将操作人加入项目。':'选择新经理即可恢复项目的日常管理;不会自动将操作人加入项目。'" type="warning" :closable="false"/><el-form label-position="top" :disabled="busy"><el-form-item label="选择人员"><el-select v-model="chosen" filterable remote :remote-method="search" :loading="searching" placeholder="搜索姓名或账号" style="width:100%"><el-option v-for="u in candidates" :key="u.userId" :value="u.userId" :label="`${u.name||u.userName} / ${u.userName}`"/></el-select></el-form-item><el-form-item :label="hasManager?'转交说明':'设置说明'"><el-input v-model="reason" type="textarea" maxlength="500"/></el-form-item></el-form></template>
|
||||
@ -18,6 +18,7 @@
|
||||
<script setup>
|
||||
import { formatDateTime } from '@/utils/display-format'
|
||||
import {computed,onBeforeUnmount,ref,watch} from 'vue'
|
||||
import {sortPeople} from '@/utils/person-order'
|
||||
import {ElMessageBox,ElMessage} from 'element-plus'
|
||||
import {addProjectMembers,changeProjectMember,projectUserCandidates,transferProjectManager,changeProjectState} from '@/api/project/workspace'
|
||||
const props=defineProps({project:{type:Object,required:true},summary:{type:Object,required:true},canEdit:Boolean})
|
||||
@ -29,7 +30,7 @@ const transferData=computed(()=>{
|
||||
const existing=new Set((props.summary.members||[]).map(person=>Number(person.userId))),people=new Map()
|
||||
for(const user of candidates.value)if(!existing.has(Number(user.userId)))people.set(Number(user.userId),user)
|
||||
for(const id of selectedMembers.value)if(selectedPeople.value[id]&&!existing.has(Number(id)))people.set(Number(id),selectedPeople.value[id])
|
||||
return [...people].map(([key,user])=>({key,label:`${user.name||user.userName} / ${user.userName}`,disabled:busy.value}))
|
||||
return sortPeople([...people.values()]).map(user=>({key:Number(user.userId),label:`${user.name||user.userName} / ${user.userName}`,disabled:busy.value}))
|
||||
})
|
||||
const stateNames={START:'内部项目启动',FINISH:'项目结题',TERMINATE:'终止项目'}
|
||||
let searchGeneration=0,memberSearchTimer
|
||||
|
||||
@ -69,7 +69,7 @@ watch(()=>props.active,active=>{if(active&&props.column.field==='materialName')p
|
||||
<style scoped>
|
||||
.live-cell-label{position:absolute;right:2px;bottom:0;max-width:110px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#fff;font-size:10px;line-height:14px;padding:0 3px;border-radius:3px 0 0 0;pointer-events:none;z-index:2}.sheet-cell:has(.live-cell-label){position:relative;padding-bottom:14px}
|
||||
|
||||
.sheet-pending-category{display:flex;align-items:center;gap:5px;width:100%;min-width:0}.sheet-pending-category>.sheet-value{flex:1;min-width:0}.sheet-pending-category>.el-tag{flex:none;font-size:11px;padding:0 3px}
|
||||
.sheet-pending-category{display:flex;align-items:center;justify-content:center;gap:5px;width:100%;min-width:0}.sheet-pending-category>.sheet-value{flex:0 1 auto;min-width:0}.sheet-pending-category>.el-tag{flex:none;font-size:11px;padding:0 3px}
|
||||
.cell-numeric{font-variant-numeric:tabular-nums}
|
||||
.sheet-keyboard-input{position:absolute;width:1px;height:1px;opacity:0;pointer-events:none;padding:0;border:0}
|
||||
</style>
|
||||
|
||||
@ -767,7 +767,9 @@ unpriced(){return this.sheet.rows.filter(r=>!r.historical&&!this.hasPrice(r)&&Nu
|
||||
.sheet-grid :deep(.el-input__wrapper){ padding:1px 8px; }
|
||||
.sheet-grid :deep(.el-select__wrapper){ min-height:var(--cmvr-grid-height); padding:2px 8px; font-size:var(--cmvr-grid-font); }
|
||||
.sheet-grid :deep(.el-select__input), .sheet-grid :deep(.el-input__inner){ padding:0; font-size:var(--cmvr-grid-font); }
|
||||
.sheet-grid :deep(.sheet-cell),.sheet-grid :deep(.sheet-cell .sheet-value),.sheet-grid :deep(.sheet-cell .el-input__inner),.sheet-grid :deep(.sheet-cell .el-select__wrapper){text-align:left}
|
||||
.sheet-grid :deep(.sheet-cell),.sheet-grid :deep(.sheet-cell .sheet-value){text-align:center}
|
||||
.sheet-grid :deep(.sheet-pending-category>.sheet-value){width:auto}
|
||||
.sheet-grid :deep(.sheet-cell .el-input__inner),.sheet-grid :deep(.sheet-cell .el-select__wrapper){text-align:left}
|
||||
.sheet-grid :deep(td.el-table__cell){ padding:var(--cmvr-grid-padding) 0 !important; }
|
||||
.sheet-footer { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; flex:none; padding:12px 0; font-size:var(--cmvr-grid-font); }
|
||||
.secondary { display:block; color:var(--el-text-color-secondary); font-size:12px; }
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
const pinyin=new Intl.Collator('zh-Hans-CN-u-co-pinyin',{sensitivity:'base',numeric:true})
|
||||
const name=p=>String(p.name||p.nickName||p.nick_name||p.userName||p.account||p.user_name||'').trim()
|
||||
const name=p=>String(p.name||p.nickName||p.nick_name||p.employeeName||p.userName||p.account||p.user_name||'').trim()
|
||||
export const sortPeople=people=>[...people].sort((a,b)=>pinyin.compare(name(a),name(b))||pinyin.compare(String(a.account||a.userName||a.user_name||''),String(b.account||b.userName||b.user_name||''))||String(a.id??a.userId??'').localeCompare(String(b.id??b.userId??''),undefined,{numeric:true}))
|
||||
// Only use for unpaged candidate arrays. Paged lists must be ordered by SQL.
|
||||
export const sortPeopleResponse=response=>({...response,data:sortPeople(response.data||[])})
|
||||
|
||||
@ -13,6 +13,7 @@ import {saveAs} from 'file-saver'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import AchievementLedger from './components/AchievementLedger.vue'
|
||||
import AchievementEditor from './components/AchievementEditor.vue'
|
||||
import {sortPeople} from '@/utils/person-order'
|
||||
import {kinds,kindTones,progressLabel,progressTone,progressNames} from './components/achievement-ui'
|
||||
import {listAchievements,memberProjects,projectMembers,achievementDetail,achievementUserCandidates,saveAchievement,changeAchievementProgress,archiveAchievement,exportAchievements} from '@/api/project/workspace'
|
||||
const props=defineProps({projectId:Number,embedded:Boolean}),user=useUserStore()
|
||||
@ -29,9 +30,9 @@ function search(){query.value.page=1;load()}
|
||||
function reset(){query.value={projectId:props.projectId,kind:undefined,keyword:'',page:1,pageSize:50};load()}
|
||||
async function searchProjects(keyword=''){const g=++projectGeneration;const r=await memberProjects(keyword);if(!disposed&&g===projectGeneration){const selected=new Set([form.value.projectId,query.value.projectId,props.projectId]),options=new Map(projects.value.filter(p=>selected.has(p.id)).map(p=>[p.id,p]));for(const p of r.data||[])options.set(p.id,p);projects.value=[...options.values()]}}
|
||||
async function loadMembers(){const project=form.value.projectId;members.value=[];if(!project){participantGeneration++;participantOptions.value=[];participantLoading.value=false;form.value.ownerId=undefined;return}const r=await projectMembers(project);if(!disposed&&form.value.projectId===project){members.value=r.data||[];if(!form.value.id&&!members.value.some(m=>Number(m.userId)===Number(form.value.ownerId)))form.value.ownerId=members.value.some(m=>Number(m.userId)===Number(user.id))?Number(user.id):undefined;if(editable.value)await searchParticipants('')}}
|
||||
function mergeParticipantOptions(candidates){const selected=new Set(form.value.participantIds||[]),merged=new Map();for(const person of [...(form.value.participants||[]),...participantOptions.value])if(selected.has(person.userId))merged.set(person.userId,person);for(const person of candidates)merged.set(person.userId,person);participantOptions.value=[...merged.values()]}
|
||||
function mergeParticipantOptions(candidates){const selected=new Set(form.value.participantIds||[]),merged=new Map();for(const person of [...(form.value.participants||[]),...participantOptions.value])if(selected.has(person.userId))merged.set(person.userId,person);for(const person of candidates)merged.set(person.userId,person);participantOptions.value=sortPeople([...merged.values()])}
|
||||
async function searchParticipants(keyword=''){const stamp=++participantGeneration,project=form.value.projectId;if(!editable.value){participantLoading.value=false;return}if(!project){participantOptions.value=[];return}participantLoading.value=true;try{const r=await achievementUserCandidates(project,keyword);if(!disposed&&stamp===participantGeneration&&project===form.value.projectId)mergeParticipantOptions(r.data||[])}catch{if(!disposed&&stamp===participantGeneration)mergeParticipantOptions([])}finally{if(stamp===participantGeneration)participantLoading.value=false}}
|
||||
function acceptDetail(data){form.value={...data,participantIds:data.participantIds||[],details:{...data.details}};form.value.legacyParticipants=data.legacyParticipants||form.value.details.participants||'';delete form.value.details.participants;participantGeneration++;participantOptions.value=[...(data.participants||[])];participantLoading.value=false}
|
||||
function acceptDetail(data){form.value={...data,participantIds:data.participantIds||[],details:{...data.details}};form.value.legacyParticipants=data.legacyParticipants||form.value.details.participants||'';delete form.value.details.participants;participantGeneration++;participantOptions.value=sortPeople(data.participants||[]);participantLoading.value=false}
|
||||
function kindChanged(){form.value.details={};form.value.progress='PREPARING'}
|
||||
async function create(){if(busy.value||materialBusy.value)return;busy.value=true;participantGeneration++;participantOptions.value=[];form.value={id:null,projectId:props.projectId||query.value.projectId,kind:query.value.kind||'PATENT',title:'',ownerId:undefined,progress:'PREPARING',archived:0,details:{},participantIds:[],canEdit:true};members.value=[];try{await loadMembers();if(disposed)return;baseline.value=JSON.stringify(payload());drawer.value=true}catch{}finally{busy.value=false}await nextTick();editor.value?.showTab('basic')}
|
||||
async function open(id,target='basic'){if(busy.value||materialBusy.value)return;const g=++detailGeneration;busy.value=true;try{const r=await achievementDetail(id);if(disposed||g!==detailGeneration)return;acceptDetail(r.data);const listed=rows.value.find(row=>row.id===id);if(listed?.projectName&&!projects.value.some(p=>p.id===r.data.projectId))projects.value.push({id:r.data.projectId,name:listed.projectName});await loadMembers();if(disposed||g!==detailGeneration)return;baseline.value=JSON.stringify(payload());drawer.value=true}catch{return}finally{busy.value=false}await nextTick();if(!disposed&&g===detailGeneration)editor.value?.showTab(target)}
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
import { request } from './client'
|
||||
import type { Member } from '../types'
|
||||
import { sortPeople } from '@/utils/person-order'
|
||||
|
||||
export const memberApi = {
|
||||
/** 查询负责人可选成员,所有者自动作为经理展示。 */
|
||||
members: (id: number) => request<Member[]>('get', `/projects/${id}/members`),
|
||||
members: (id: number) => request<Member[]>('get', `/projects/${id}/members`).then(sortPeople),
|
||||
/** 经理检索新成员,只返回昵称与 ID。 */
|
||||
candidates: (id: number, keyword: string) => request<Member[]>('get', `/projects/${id}/member-candidates?keyword=${encodeURIComponent(keyword)}`),
|
||||
candidates: (id: number, keyword: string) => request<Member[]>('get', `/projects/${id}/member-candidates?keyword=${encodeURIComponent(keyword)}`).then(sortPeople),
|
||||
/** 项目经理添加成员或调整角色。 */
|
||||
member: (id: number, userId: number, role: string) => request<void>('post', `/projects/${id}/members`, { userId, role }),
|
||||
/** 移除成员后旧对象和附件访问会立即重新鉴权。 */
|
||||
|
||||
@ -22,14 +22,14 @@
|
||||
<el-table-column v-if="canQuote" label="报价合计(元)" width="145" align="right"><template #default="{row}">{{ money(row.quoteAmount) }}<div v-if="row.unpricedCount" class="unpriced">{{ row.unpricedCount }} 项未报价</div></template></el-table-column>
|
||||
<el-table-column label="资料进度" min-width="410" class-name="business-control-cell"><template #default="{row}"><div class="document-steps"><el-tooltip v-for="(step,index) in row.stages" :key="step.kind" :content="stageHint(step)" placement="top"><button class="document-step" :class="{'is-complete':step.complete,'has-files':step.files>0}" :aria-label="`${row.batchName||row.batchNo} ${labels[step.kind]}资料 ${step.complete?'齐全':'待补充'}`" @click="openDocuments(row,step.kind)"><span class="step-dot">{{ step.complete?'✓':index+1 }}</span><span class="step-label">{{ labels[step.kind] }}</span><span class="step-count">{{ step.complete?'已齐全':step.files?step.files+' 份附件':'待补充' }}</span></button></el-tooltip></div></template></el-table-column>
|
||||
</el-table>
|
||||
<el-table v-else-if="view==='ledger'" :data="rows" height="100%" row-key="id" size="small" border>
|
||||
<el-table-column label="采购批次" min-width="185" fixed><template #default="{row}"><el-link type="primary" underline="never" @click="goRequest(row)">{{ row.batchName||row.batchNo }}</el-link></template></el-table-column>
|
||||
<el-table-column label="采购人" prop="purchasers" min-width="100" show-overflow-tooltip/>
|
||||
<el-table-column label="费用类别" min-width="170" class-name="business-operation-cell"><template #default="{row}"><el-button v-if="canManage&&row.editable!==false" link type="primary" class="category-link" @click="editCategory(row)">{{ row.expenseCategoryName }}</el-button><span v-else>{{ row.expenseCategoryName }}</span></template></el-table-column>
|
||||
<el-table-column v-if="canQuote" label="合同/直接采购金额(元)" width="185" align="right"><template #default="{row}">{{ money(row.quoteAmount) }}<span v-if="row.unpricedCount" class="unpriced"> · 含未报价</span></template></el-table-column>
|
||||
<el-table-column label="供应商全称" prop="supplierName" min-width="220" show-overflow-tooltip/>
|
||||
<el-table-column label="备注" prop="remark" min-width="220" show-overflow-tooltip/>
|
||||
<el-table-column v-for="kind in ['REQUEST','CONTRACT','PAYMENT']" :key="kind" :label="numberLabels[kind]" min-width="170" class-name="business-operation-cell"><template #default="{row}"><el-link type="primary" underline="never" @click="openDocuments(row,kind)">{{ stage(row,kind)?.number||'填写编号 / 上传资料' }}</el-link></template></el-table-column>
|
||||
<el-table v-else-if="view==='ledger'" class="purchase-ledger-table" :data="rows" height="100%" row-key="id" size="small" border>
|
||||
<el-table-column label="采购批次" min-width="185" fixed align="center" header-align="center"><template #default="{row}"><el-link type="primary" underline="never" @click="goRequest(row)">{{ row.batchName||row.batchNo }}</el-link></template></el-table-column>
|
||||
<el-table-column label="采购人" prop="purchasers" min-width="100" align="center" header-align="center" show-overflow-tooltip/>
|
||||
<el-table-column label="费用类别" min-width="170" align="center" header-align="center" class-name="business-operation-cell"><template #default="{row}"><el-button v-if="canManage&&row.editable!==false" link type="primary" class="category-link" @click="editCategory(row)">{{ row.expenseCategoryName }}</el-button><span v-else>{{ row.expenseCategoryName }}</span></template></el-table-column>
|
||||
<el-table-column v-if="canQuote" label="合同/直接采购金额(元)" width="185" align="center" header-align="center"><template #default="{row}">{{ money(row.quoteAmount) }}<span v-if="row.unpricedCount" class="unpriced"> · 含未报价</span></template></el-table-column>
|
||||
<el-table-column label="供应商全称" prop="supplierName" min-width="220" align="center" header-align="center" show-overflow-tooltip/>
|
||||
<el-table-column label="备注" prop="remark" min-width="220" align="center" header-align="center" show-overflow-tooltip/>
|
||||
<el-table-column v-for="kind in ['REQUEST','CONTRACT','PAYMENT']" :key="kind" :label="numberLabels[kind]" min-width="170" align="center" header-align="center" class-name="business-operation-cell"><template #default="{row}"><el-link type="primary" underline="never" @click="openDocuments(row,kind)">{{ stage(row,kind)?.number||'填写编号 / 上传资料' }}</el-link></template></el-table-column>
|
||||
</el-table>
|
||||
<el-table v-else-if="canQuote" :data="costRows" height="100%" :span-method="mergeProject" size="small" border>
|
||||
<el-table-column label="项目编号" prop="projectCode" width="180"/>
|
||||
@ -79,5 +79,6 @@ onMounted(async()=>{const results=await Promise.allSettled([projectOptions('',tr
|
||||
onActivated(()=>{if(mounted)load()});onBeforeUnmount(()=>{serial++;controller?.abort()})
|
||||
</script>
|
||||
<style scoped>
|
||||
.purchase-ledger-table .category-link{text-align:center;justify-content:center}
|
||||
.purchase-board{display:flex;flex-direction:column;gap:12px;height:calc(100dvh - 88px);min-height:420px;padding:16px 20px}.board-toolbar{display:flex;align-items:center;gap:16px;flex-wrap:wrap}.board-toolbar>.el-button{margin-left:auto}.board-guide,.muted{color:var(--el-text-color-secondary);font-size:12px;line-height:1.7}.board-filters{background:var(--el-fill-color-light);border-radius:8px;padding:14px 14px 2px}.board-filters .el-form-item{margin-right:18px;margin-bottom:12px}.board-filters .el-select{width:190px}.board-filters :deep(.el-date-editor){width:250px}.board-table{flex:1;min-height:180px;overflow:hidden;border:1px solid var(--el-border-color-lighter);border-radius:6px}.board-footer{display:flex;align-items:center;justify-content:space-between;gap:16px;flex-wrap:wrap;font-size:13px}.board-footer strong{font-size:17px;font-variant-numeric:tabular-nums;color:var(--el-text-color-primary)}.batch-title{font-weight:600;max-width:100%;justify-content:flex-start}.category-link{white-space:normal;text-align:left;height:auto;line-height:1.6}.unpriced{color:var(--el-color-warning);font-size:12px}.document-steps{display:flex;padding:4px 0;min-width:380px}.document-step{position:relative;display:flex;flex:1;flex-direction:column;align-items:center;gap:1px;border:0;background:none;color:var(--el-text-color-regular);cursor:pointer;padding:0 8px;font:inherit}.document-step:not(:last-child)::after{content:'';height:2px;background:var(--el-border-color-lighter);position:absolute;top:12px;left:calc(50% + 18px);width:calc(100% - 36px)}.step-dot{position:relative;z-index:1;display:grid;place-items:center;width:24px;height:24px;border-radius:50%;border:1px solid var(--el-border-color);color:var(--el-text-color-secondary);background:var(--el-bg-color);font-size:13px}.step-label{font-size:13px;line-height:1.4;font-weight:500}.step-count{font-size:11px;line-height:1.4;color:var(--el-text-color-secondary)}.is-complete .step-dot{background:var(--el-color-success-light-9);border-color:var(--el-color-success);color:var(--el-color-success);font-weight:700}.is-complete:not(:last-child)::after{background:var(--el-color-success-light-5)}.has-files:not(.is-complete) .step-dot{color:var(--el-color-warning);border-color:var(--el-color-warning);background:var(--el-color-warning-light-9)}.document-step:hover .step-label{color:var(--el-color-primary)}.document-step:focus-visible{outline:2px solid var(--el-color-primary);outline-offset:4px;border-radius:4px}.category-context{margin-top:0;font-weight:600}.category-note{margin-top:14px}@media(max-width:1000px){.board-guide{display:none}.purchase-board{padding:12px}.board-footer :deep(.el-pagination){max-width:100%;overflow:auto}}
|
||||
</style>
|
||||
|
||||
@ -152,7 +152,7 @@ it('member transfer adds several selected people in one request and excludes exi
|
||||
api.projectUserCandidates.mockResolvedValue({data:[{userId:2,userName:'manager',name:'现有经理'},{userId:3,userName:'alice',name:'甲'},{userId:4,userName:'bob',name:'乙'}]});api.addProjectMembers.mockResolvedValue({data:{addedCount:2}})
|
||||
const w=render(Governance,{project:{id:71},summary:{version:7,canManage:true,members:[{userId:2,role:'MANAGER'}]},canEdit:true})
|
||||
await button(w,'添加成员').trigger('click');await flushPromises();const transfer=w.findComponent({name:'ElTransfer'})
|
||||
expect(transfer.props('titles')).toEqual(['可选人员','待添加成员']);expect(transfer.props('data').map(p=>p.key)).toEqual([3,4])
|
||||
expect(transfer.props('titles')).toEqual(['可选人员','待添加成员']);expect(transfer.props('targetOrder')).toBe('original');expect(transfer.props('data').map(p=>p.key)).toEqual([3,4])
|
||||
transfer.vm.$emit('update:modelValue',[3,4]);transfer.vm.$emit('change',[3,4],'right',[3,4]);await flushPromises()
|
||||
const submit=document.body.querySelector('.el-dialog__footer .el-button--primary');submit.click();await flushPromises()
|
||||
expect(api.addProjectMembers).toHaveBeenCalledWith(71,{version:7,userIds:[3,4]});expect(api.addProjectMembers).toHaveBeenCalledTimes(1);expect(api.changeProjectMember).not.toHaveBeenCalled();expect(w.emitted('changed')).toHaveLength(1)
|
||||
@ -211,7 +211,7 @@ it('participant searches preserve selected names and ignore a slower previous re
|
||||
const select=w.findAllComponents({name:'ElSelect'}).find(c=>c.props('placeholder')==='搜索系统用户姓名或账号,可多选')
|
||||
let old,newer;api.achievementUserCandidates.mockImplementationOnce(()=>new Promise(done=>{old=done})).mockImplementationOnce(()=>new Promise(done=>{newer=done}))
|
||||
const search=select.props('remoteMethod'),a=search('旧搜索'),b=search('新搜索');newer({data:[{userId:5,userName:'new-user',name:'新结果'}]});await b;old({data:[{userId:6,userName:'stale',name:'过期结果'}]});await a;await flushPromises()
|
||||
expect(select.props('modelValue')).toEqual([4]);expect(select.findAllComponents({name:'ElOption'}).map(c=>c.props('label'))).toEqual(['已选人员 / old-user','新结果 / new-user'])
|
||||
expect(select.props('modelValue')).toEqual([4]);expect(select.findAllComponents({name:'ElOption'}).map(c=>c.props('label'))).toEqual(['新结果 / new-user','已选人员 / old-user'])
|
||||
expect(api.saveAchievement).not.toHaveBeenCalled()
|
||||
})
|
||||
it('read-only achievement viewing displays selected users without requesting the edit-only directory',async()=>{
|
||||
|
||||
@ -1,2 +1,9 @@
|
||||
import test from 'node:test';import assert from 'node:assert/strict';import {sortPeople} from '../../src/utils/person-order.js';
|
||||
import test from 'node:test';import assert from 'node:assert/strict';import {sortPeople,sortPeopleResponse} from '../../src/utils/person-order.js';
|
||||
test('selected and newly queried people merge in pinyin order, with stable account/id ties and no source mutation',()=>{const rows=[{id:5,name:'张三'},{id:4,name:'王五'},{id:3,name:'李四'},{id:2,name:'陈六'},{id:1,name:'阿明'},{id:7,name:'王五',account:'b'},{id:6,name:'王五',account:'a'}];const before=structuredClone(rows);assert.deepEqual(sortPeople(rows).map(p=>p.id),[1,2,3,4,6,7,5]);assert.deepEqual(rows,before);assert.deepEqual(sortPeople([{userId:2,nickName:'张三'},{userId:1,nickName:'李四'}]).map(p=>p.userId),[1,2]);});
|
||||
test('all candidate response formats use the displayed name, preserve metadata and selected identities',()=>{
|
||||
const response=Object.freeze({code:200,msg:'ok',data:Object.freeze([{userId:9,nickName:'张三',userName:'a'},{userId:7,name:'陈六',userName:'z'},{userId:5,employeeName:'李四',account:'b'},{userId:3,nick_name:'王五',user_name:'c'}])})
|
||||
const sorted=sortPeopleResponse(response)
|
||||
assert.deepEqual(sorted.data.map(p=>p.userId),[7,5,3,9]);assert.equal(sorted.code,200);assert.equal(sorted.msg,'ok')
|
||||
assert.equal(sorted.data[0],response.data[1]);assert.equal(response.data[0].userId,9)
|
||||
assert.deepEqual(sortPeopleResponse({code:200,data:null}),{code:200,data:[]})
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user