Commit 03614a3c by lijingjing

定时任务时间调整 每3分钟执行一次更改为5分钟;

优化原始记录关联查询;
parent c9bca976
...@@ -298,7 +298,7 @@ public class EntrustSampleItemController extends ServiceController { ...@@ -298,7 +298,7 @@ public class EntrustSampleItemController extends ServiceController {
@ApiOperation("手工分配") @ApiOperation("手工分配")
@PostMapping("/allot_item") @PostMapping("/allot_item")
public RestResult<Boolean> allotItem(@RequestParam("ids") Long[] ids, @RequestParam("tester") String tester, @RequestParam("testerId") Long testerId, @RequestParam("type") Integer type) { public RestResult<Boolean> allotItem(@RequestParam("ids") Long[] ids, @RequestParam("tester") String tester, @RequestParam("testerId") Long testerId, Integer type) {
return success(entrustSampleItemService.allotItem(ids, tester, testerId, type, getAccount())); return success(entrustSampleItemService.allotItem(ids, tester, testerId, type, getAccount()));
} }
......
...@@ -10,12 +10,11 @@ import javax.annotation.Resource; ...@@ -10,12 +10,11 @@ import javax.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
/** /**
*
* @author: meazty * @author: meazty
* @since: 2022/2/21 19:44 * @since: 2022/2/21 19:44
**/ **/
@Component @Component
@Configuration //1.主要用于标记配置类,兼备Component的效果。 @Configuration
@EnableScheduling @EnableScheduling
public class UserStatsTask { public class UserStatsTask {
...@@ -23,9 +22,9 @@ public class UserStatsTask { ...@@ -23,9 +22,9 @@ public class UserStatsTask {
private IUserTestStatisticsService userTestStatisticsService; private IUserTestStatisticsService userTestStatisticsService;
/** /**
* 每3分钟执行一次 * 每5分钟执行一次
*/ */
@Scheduled(cron = "0 */3 * * * ?") @Scheduled(cron = "0 */5 * * * ?")
private void configureTasks() { private void configureTasks() {
System.err.println("执行同步用户检测量定时任务时间: " + LocalDateTime.now()); System.err.println("执行同步用户检测量定时任务时间: " + LocalDateTime.now());
userTestStatisticsService.updateUserStatisticsInfo(); userTestStatisticsService.updateUserStatisticsInfo();
......
...@@ -822,24 +822,21 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe ...@@ -822,24 +822,21 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
@Override @Override
public Page<EntrustSampleVO> pageSampleByItem(Page<EntrustSampleVO> page, EntrustSampleVO entrustSample) { public Page<EntrustSampleVO> pageSampleByItem(Page<EntrustSampleVO> page, EntrustSampleVO entrustSample) {
if (null == entrustSample.getEntrustId()) { if (null == entrustSample.getEntrustId() || null == entrustSample.getItemStatus()) {
return page;
}
if (null == entrustSample.getItemStatus()) {
return page; return page;
} }
/* 移除冗余代码
List<EntrustSampleItem> itemList = entrustSampleItemService.list(Condition.create().eq("status", entrustSample.getItemStatus())); List<EntrustSampleItem> itemList = entrustSampleItemService.list(Condition.create().eq("status", entrustSample.getItemStatus()));
if (CollectionUtils.isEmpty(itemList)) { if (CollectionUtils.isEmpty(itemList)) {
return page; return page;
} }
List<Long> sampleIdsList = itemList.stream().map( i -> {
List<Long> sampleIdsList = itemList.stream().map(i -> {
return i.getEntrustSampleId(); return i.getEntrustSampleId();
}).collect(Collectors.toList()); }).collect(Collectors.toList());
entrustSample.setIds(sampleIdsList); entrustSample.setIds(sampleIdsList);
*/
// 此处逻辑 用到了样品检测项目状态,样品编号,委托编号
return page.setRecords(baseMapper.selectVOList(page, entrustSample)); return page.setRecords(baseMapper.selectVOList(page, entrustSample));
} }
......
...@@ -16,9 +16,7 @@ import org.apache.commons.collections4.ListUtils; ...@@ -16,9 +16,7 @@ import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Collections; import java.util.*;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -77,6 +75,10 @@ public class OriginalTemplateItemServiceImpl extends BaseServiceImpl<OriginalTem ...@@ -77,6 +75,10 @@ public class OriginalTemplateItemServiceImpl extends BaseServiceImpl<OriginalTem
if (CollectionUtils.isEmpty(sampleItemList)) { if (CollectionUtils.isEmpty(sampleItemList)) {
return Collections.emptyList(); return Collections.emptyList();
} }
Set<Long> templateIdSet = new HashSet<>();
for (SampleItemDTO dto : sampleItemList) {
}
return baseMapper.listIdsByItems(sampleItemList); return baseMapper.listIdsByItems(sampleItemList);
} }
} }
...@@ -3,21 +3,32 @@ ...@@ -3,21 +3,32 @@
<mapper namespace="com.patzn.cloud.service.lims.hmhj.mapper.OriginalTemplateItemMapper"> <mapper namespace="com.patzn.cloud.service.lims.hmhj.mapper.OriginalTemplateItemMapper">
<select id="listIdsByItems" resultType="java.lang.Long"> <select id="listIdsByItems" resultType="java.lang.Long">
select ot.id from original_template ot select
distinct ot.id
from original_template ot
left join (
select st.company_id,st.template_id,string_agg(st.name,'~~') || '~~' "sname"
from original_template_item st where st.deleted = 0 and st.type = 'sample'
group by st.company_id,st.template_id
) st ON st.template_id = ot.id
left join (
select it.company_id,it.template_id,string_agg(it.name,'~~') || '~~' "iname"
from original_template_item it where it.deleted = 0 and it.type = 'item'
group by it.company_id,it.template_id
) it ON it.template_id = ot.id
where ot.deleted = 0 and ( where ot.deleted = 0 and (
<foreach collection="sampleItemList" index="index" item="sampleItem" separator="or" open="(" close=")"> <foreach collection="sampleItemList" index="index" item="sampleItem" separator="or" open="(" close=")">
exists ( 1 != 2
select 1 from original_template_item oti where oti.deleted = 0 and oti.template_id = ot.id <if test="null != sampleItem.name">
and oti.type = 'sample' and(oti.name is null or oti.name = #{sampleItem.name}) and strpos(st.sname,concat(#{sampleItem.name},'~~')) > 0
) </if>
and exists ( <if test="null != sampleItem.itemList">
select 1 from original_template_item oi where oi.deleted = 0 and oi.template_id = ot.id and (
and oi.type = 'item' and ( oi.name is null or oi.name in <foreach collection="sampleItem.itemList" index="ix" item="item" separator="or" open="(" close=")">
<foreach collection="sampleItem.itemList" index="ix" item="item" separator="," open="(" close=")"> strpos(it.iname,concat(#{item},'~~')) > 0
#{item}
</foreach> </foreach>
) )
) </if>
</foreach> </foreach>
) )
</select> </select>
......
/** created by meazty on 2022/2/17 23:13 **/ /** created by meazty on 2022/2/17 23:13 **/
/** created by meazty on 2022/2/17 23:13 **/ /** created by meazty on 2022/2/17 23:13 **/
-- ----------------------------
-- Table structure for user_test_statistics
-- ----------------------------
DROP TABLE IF EXISTS "public"."user_test_statistics";
CREATE TABLE "public"."user_test_statistics" (
"user_id" int8 NOT NULL,
"user_name" varchar(64) COLLATE "pg_catalog"."default",
"real_name" varchar(64) COLLATE "pg_catalog"."default",
"group_ids" varchar(512) COLLATE "pg_catalog"."default",
"untested" int4,
"testing" int4,
"tested" int4,
"total" int4,
"company_id" int8 DEFAULT '1356149618195193858'::bigint
)
;
COMMENT ON COLUMN "public"."user_test_statistics"."user_id" IS '用户ID';
COMMENT ON COLUMN "public"."user_test_statistics"."user_name" IS '用户名';
COMMENT ON COLUMN "public"."user_test_statistics"."real_name" IS '真实名称';
COMMENT ON COLUMN "public"."user_test_statistics"."group_ids" IS '分组(科室)ids';
COMMENT ON COLUMN "public"."user_test_statistics"."untested" IS '未检测数量';
COMMENT ON COLUMN "public"."user_test_statistics"."testing" IS '正在检测数量';
COMMENT ON COLUMN "public"."user_test_statistics"."tested" IS '已检测数量';
COMMENT ON COLUMN "public"."user_test_statistics"."total" IS '总数';
COMMENT ON COLUMN "public"."user_test_statistics"."company_id" IS '企业ID';
-- ----------------------------
-- Uniques structure for table user_test_statistics
-- ----------------------------
ALTER TABLE "public"."user_test_statistics" ADD CONSTRAINT "ueq_user_id" UNIQUE ("user_id");
COMMENT ON CONSTRAINT "ueq_user_id" ON "public"."user_test_statistics" IS '用户id';
-- ----------------------------
-- Primary Key structure for table user_test_statistics
-- ----------------------------
ALTER TABLE "public"."user_test_statistics" ADD CONSTRAINT "user_test_stats_pkey" PRIMARY KEY ("user_id");
-- ----------------------------
-- Table structure for original_template_item
-- ----------------------------
DROP TABLE IF EXISTS "public"."original_template_item";
CREATE TABLE "public"."original_template_item" (
"id" int8 NOT NULL,
"template_id" int8,
"name" varchar(64) COLLATE "pg_catalog"."default",
"type" varchar(32) COLLATE "pg_catalog"."default",
"remark" varchar(255) COLLATE "pg_catalog"."default",
"company_id" int8,
"deleted" int2 DEFAULT 0,
"uid" int8,
"ctime" timestamp(6) DEFAULT NULL::timestamp without time zone,
"lid" int8,
"ltime" timestamp(6) DEFAULT NULL::timestamp without time zone
)
;
COMMENT ON COLUMN "public"."original_template_item"."id" IS 'ID';
COMMENT ON COLUMN "public"."original_template_item"."template_id" IS '原始记录模板ID';
COMMENT ON COLUMN "public"."original_template_item"."name" IS '名称';
COMMENT ON COLUMN "public"."original_template_item"."type" IS '类型';
COMMENT ON COLUMN "public"."original_template_item"."remark" IS '备注';
COMMENT ON COLUMN "public"."original_template_item"."company_id" IS '企业ID';
COMMENT ON COLUMN "public"."original_template_item"."deleted" IS '是否删除0否1是';
COMMENT ON COLUMN "public"."original_template_item"."uid" IS '创建人ID';
COMMENT ON COLUMN "public"."original_template_item"."ctime" IS '创建时间';
COMMENT ON COLUMN "public"."original_template_item"."lid" IS '最后修改人ID';
COMMENT ON COLUMN "public"."original_template_item"."ltime" IS '最后修改时间';
COMMENT ON TABLE "public"."original_template_item" IS '原始记录配置项(配置的字段,样品、项目等)';
-- ----------------------------
-- Primary Key structure for table original_template_item
-- ----------------------------
ALTER TABLE "public"."original_template_item" ADD CONSTRAINT "original_template_item_pkey" PRIMARY KEY ("id");
-- 委托样品 -- -- 委托样品 --
ALTER TABLE "public"."entrust_sample_item" ALTER TABLE "public"."entrust_sample_item"
ADD COLUMN "period" varchar(32); ADD COLUMN "period" varchar(32);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment