Index: ssts-web/src/main/resources/spring/test/applicationContext-test.xml
===================================================================
diff -u -r20806 -r20835
--- ssts-web/src/main/resources/spring/test/applicationContext-test.xml (.../applicationContext-test.xml) (revision 20806)
+++ ssts-web/src/main/resources/spring/test/applicationContext-test.xml (.../applicationContext-test.xml) (revision 20835)
@@ -36,5 +36,12 @@
+
+
+
+
+
+
+
\ No newline at end of file
Index: ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/model/RuntimeInfo.java
===================================================================
diff -u
--- ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/model/RuntimeInfo.java (revision 0)
+++ ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/model/RuntimeInfo.java (revision 20835)
@@ -0,0 +1,36 @@
+package test.forgon.disinfectsystem.synthetic.allrecycle.model;
+
+public class RuntimeInfo {
+ /**
+ * 测试用例退出标志
+ */
+ public boolean exit = false;
+ /**
+ * 等待超时时间。在结束前,等待一个线程结束的最长时间.单位秒
+ */
+ public long timeout = 10*60;
+ /**
+ * 持续运行时间,单位为分钟
+ */
+ public int testDuration = 5*60;
+ /**
+ * 最大执行的循环次数
+ */
+ public int maxCycleCount = Integer.MAX_VALUE;
+ /**
+ * 一次审核器械包数量
+ */
+ public int tousseAmountPerReview = 50;
+ /**
+ * 一次灭菌器械包数量
+ */
+ public int tousseAmountPerSterile = 50;
+ /**
+ * 一次发送包实例数量
+ */
+ public int tousseAmountPerInvoice = 50;
+ /**
+ * 是否以多线程方式运行。如果为否,则一个模块一个模块地运行。如果为是,则多个模块同时运行
+ */
+ public boolean multiThread = true;
+}
Index: ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/PackingModule.java
===================================================================
diff -u
--- ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/PackingModule.java (revision 0)
+++ ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/PackingModule.java (revision 20835)
@@ -0,0 +1,138 @@
+package test.forgon.disinfectsystem.synthetic.allrecycle.service;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import net.sf.json.JSONObject;
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import test.forgon.disinfectsystem.synthetic.allrecycle.model.RuntimeInfo;
+
+import com.forgon.directory.acegi.tools.AcegiHelper;
+import com.forgon.disinfectsystem.basedatamanager.taskGroup.service.TaskGroupManager;
+import com.forgon.disinfectsystem.entity.basedatamanager.taskGroup.TaskGroup;
+import com.forgon.disinfectsystem.entity.packing.PackingTask;
+import com.forgon.disinfectsystem.packing.service.PackingManager;
+import com.forgon.disinfectsystem.packing.vo.WaitPackingTaskItemVo;
+import com.forgon.disinfectsystem.packing.vo.WaitPackingTaskVo;
+import com.forgon.runwithtrans.model.RunWithTransNewTask;
+
+public class PackingModule extends ModuleBase {
+
+ private PackingManager packingManager;
+ private TaskGroupManager taskGroupManager;
+ private List packingParams = new ArrayList<>();
+ private List allProcessedPackingTaskIds = new ArrayList<>();
+
+ @Override
+ protected void initBean() {
+ super.initBean();
+ packingManager = getBean("packingManager");
+ taskGroupManager = getBean("taskGroupManager");
+ }
+
+
+ public PackingModule(RuntimeInfo runtimeInfo) {
+ super(runtimeInfo);
+ moduleName = "装配";
+ }
+
+
+ @Override
+ protected boolean canExit() {
+ return requestStop && packingParams.size() <=0;
+ }
+
+
+ @Override
+ protected void prepare() {
+ timeoutTransNewManager.runWith_TRANS_NEW(new RunWithTransNewTask() {
+ @Override
+ public void runTask() {
+ List taskGroups = taskGroupManager.getAll();
+ if(CollectionUtils.isNotEmpty(taskGroups)){
+ List taskIds = new ArrayList<>();
+ for(TaskGroup tg : taskGroups){
+ List vos = packingManager.getWaitPackingTaskTaskVoList(tg.getTaskGroupName(), null);
+ if(CollectionUtils.isNotEmpty(vos)){
+ for(WaitPackingTaskVo taskVo : vos){
+ if(CollectionUtils.isNotEmpty(taskVo.getChildren())){
+ for(WaitPackingTaskItemVo vo : taskVo.getChildren()){
+ taskIds.add(vo.getTaskId());
+ }
+ }
+ }
+ }
+ }
+ List tasks = packingManager.getCollection(taskIds);
+ packingParams.clear();
+ for(PackingTask t : tasks){
+ String params = packingParam(t);
+ packingParams.add(params);
+ allProcessedPackingTaskIds.add(t.getId());
+ }
+ }
+ }
+ });
+ }
+
+
+ @Override
+ protected void doWork() {
+ for(String params : packingParams){
+ timeoutTransNewManager.runWith_TRANS_NEW(new RunWithTransNewTask() {
+ @Override
+ public void runTask() {
+ Date startTime = new Date();
+ try{
+ packingManager.packingTousse_TRANS_REQUIRED(params, null);
+ }finally{
+ runInfoLogManager.logDuration(moduleName, "packingManager.packingTousse_TRANS_REQUIRED", params + ",null", startTime);
+ }
+
+ }
+ });
+ }
+ }
+
+ private String packingParam(PackingTask packingTask){
+ String basketBarcode = packingTask.getBasketBarcode();
+ if(StringUtils.isBlank(basketBarcode)){
+ basketBarcode = "";
+ }
+ String[] barcodes = basketBarcode.split(";");
+ JSONObject packingParams = new JSONObject();
+ packingParams.put("taskIds", packingTask.getId());
+ packingParams.put("inspector", AcegiHelper.getLoginUser().getUserName());
+ packingParams.put("inspectorCode", AcegiHelper.getLoginUser().getUserName());
+ packingParams.put("operator", AcegiHelper.getLoginUser().getUserName());
+ packingParams.put("operatorCode", AcegiHelper.getLoginUser().getUserName());
+ packingParams.put("reviewer", AcegiHelper.getLoginUser().getUserName());
+ packingParams.put("reviewerCode", AcegiHelper.getLoginUser().getUserName());
+ packingParams.put("wrapper", AcegiHelper.getLoginUser().getUserName());
+ packingParams.put("wrapperCode", AcegiHelper.getLoginUser().getUserName());
+ packingParams.put("packageType", packingTask.getTousseDefinition().getPackageType());
+ packingParams.put("sterilingType", "无");
+ packingParams.put("sterileDate", String.valueOf(System.currentTimeMillis()));
+ packingParams.put("packAmount", packingTask.getUnPackAmount());
+ packingParams.put("taskGroup", "");
+ packingParams.put("splitPackage", null);
+ packingParams.put("basketBarcode", barcodes[0]);
+ packingParams.put("scannedBasketBarcodes", String.join(",", barcodes));
+ packingParams.put("idCardInstanceID", null);
+ packingParams.put("sterilizer", null);
+ packingParams.put("frequency", null);
+ packingParams.put("confirmContinue", "true");
+ packingParams.put("urgentAmount", null);
+ packingParams.put("tousseWeight", "");
+ return packingParams.toString();
+ }
+
+ public List getAllProcessedPackingTaskIds() {
+ return allProcessedPackingTaskIds;
+ }
+
+}
Index: ssts-web/src/test/java/com/forgon/disinfectsystem/entity/test/RunInfoLog.java
===================================================================
diff -u
--- ssts-web/src/test/java/com/forgon/disinfectsystem/entity/test/RunInfoLog.java (revision 0)
+++ ssts-web/src/test/java/com/forgon/disinfectsystem/entity/test/RunInfoLog.java (revision 20835)
@@ -0,0 +1,89 @@
+package com.forgon.disinfectsystem.entity.test;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+/**
+ * 测试用例中运行日志。主要记录方法运行的时间,捕获的异常及运行时主要的参数
+ * @author kzh
+ *
+ */
+@Entity
+public class RunInfoLog {
+ private Long id;
+ private String module;
+ private String Method;
+ private String params;
+ private Date startTime;
+ private Date LogTime;
+ private Long duration;
+ private String message;
+ private String exception;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ public Long getId() {
+ return id;
+ }
+ public void setId(Long id) {
+ this.id = id;
+ }
+ public String getModule() {
+ return module;
+ }
+ public void setModule(String module) {
+ this.module = module;
+ }
+ public String getMethod() {
+ return Method;
+ }
+ public void setMethod(String method) {
+ Method = method;
+ }
+ @Column(length=8000)
+ public String getParams() {
+ return params;
+ }
+ public void setParams(String params) {
+ this.params = params;
+ }
+ public Date getStartTime() {
+ return startTime;
+ }
+ public void setStartTime(Date startTime) {
+ this.startTime = startTime;
+ }
+ public Date getLogTime() {
+ return LogTime;
+ }
+ public void setLogTime(Date logTime) {
+ LogTime = logTime;
+ }
+ public Long getDuration() {
+ return duration;
+ }
+ public void setDuration(Long duration) {
+ this.duration = duration;
+ }
+ @Column(length=8000)
+ public String getMessage() {
+ return message;
+ }
+ public void setMessage(String message) {
+ this.message = message;
+ }
+ @Column(length=8000)
+ public String getException() {
+ return exception;
+ }
+ public void setException(String exception) {
+ this.exception = exception;
+ }
+
+
+}
Index: ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/ModuleBase.java
===================================================================
diff -u
--- ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/ModuleBase.java (revision 0)
+++ ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/ModuleBase.java (revision 20835)
@@ -0,0 +1,177 @@
+package test.forgon.disinfectsystem.synthetic.allrecycle.service;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.core.userdetails.UserDetailsService;
+
+import test.forgon.disinfectsystem.ThreadBase;
+import test.forgon.disinfectsystem.synthetic.allrecycle.model.RuntimeInfo;
+
+import com.forgon.directory.vo.LoginUserData;
+import com.forgon.runwithtrans.service.RunWithTransNewManager;
+import com.forgon.security.userdetails.UserContainsSessionUser;
+import com.forgon.tools.SpringBeanManger;
+import com.forgon.tools.hibernate.ObjectDao;
+import com.forgon.tools.json.JSONUtil;
+
+public abstract class ModuleBase {
+ protected ObjectDao objectDao;
+ protected UserDetailsService daoUserDetail;
+ protected RunInfoLogManager runInfoLogManager;
+ protected RunWithTransNewManager timeoutTransNewManager;
+
+ /**
+ * 前一个模块
+ */
+ private ModuleBase preModule;
+ protected boolean requestStop = false;
+ private Thread thread;
+ protected RuntimeInfo runtimeInfo;
+ /**
+ * 模块名称
+ */
+ protected String moduleName;
+
+
+ public ModuleBase(RuntimeInfo runtimeInfo){
+ this.runtimeInfo = runtimeInfo;
+ }
+ @SuppressWarnings("unchecked")
+ public T getBean(String name){
+ return (T) SpringBeanManger.getBean(name);
+ }
+ public void setPreModule(ModuleBase preModule) {
+ this.preModule = preModule;
+ }
+ /**
+ * 初始化bean。从spring容器中获取模块需要的bean.因为是自己new的对象。所以不能用Autowired自动注入
+ */
+ protected void initBean(){
+ daoUserDetail = getBean("daoUserDetail");
+ objectDao = getBean("objectDao");
+ timeoutTransNewManager = getBean("timeoutTransNewManager");
+ runInfoLogManager = getBean("runInfoLogManager");
+ }
+ /**
+ * 准备工作
+ */
+ protected void prepare(){
+
+ }
+ /**
+ * 处理线程工作内容
+ */
+ protected void doWork(){
+
+ }
+ /**
+ * 准备结束,处理善后工作
+ */
+// protected void tryExit(){
+// waitPreModule();//等待申请结束
+// actOnce();//最后一次操作
+// }
+ /**
+ * 当前模块是否可以退出。
+ * @return
+ */
+ protected boolean canExit(){
+ return true;
+ }
+ /**
+ * 一次执行的操作
+ */
+ protected void actOnce(){
+ prepare();
+ doWork();
+ }
+ public void start(){
+ initBean();
+ thread = new ThreadBase(new Runnable() {
+ @Override
+ public void run() {
+ makeActiveUser("admin");
+ int maxCycleCount = runtimeInfo.maxCycleCount;
+ if(!runtimeInfo.multiThread){
+ if(preModule != null){
+ preModule.join();//以单线程方式运行,等前一个模块运行结束
+ }
+ }
+ do{
+ Date startTime = new Date();
+ try{
+ actOnce();
+ if(maxCycleCount > 0){
+ --maxCycleCount;
+ }
+ }catch(Exception e){
+ runInfoLogManager.logException(moduleName, "actOnce", null, startTime, e);
+ }
+ }while((!runtimeInfo.exit && maxCycleCount > 0) || !canExit());
+// timeoutTransNewManager.runWith_TRANS_NEW(new RunWithTransNewTask() {
+// @Override
+// public void runTask() {
+// tryExit();
+// }
+// });
+ }
+ });
+ thread.start();
+ }
+ /**
+ * 请求模块退出
+ */
+ public void stop(){
+ requestStop = true;
+ }
+ public void join(){
+ waitPreModule();
+
+ try {
+ thread.join();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ protected void waitPreModule() {
+ if(preModule != null && preModule != this){
+ preModule.join();
+ }
+ }
+
+ /**
+ * 按照用户名登录
+ * @param username 用户名
+ */
+ protected void makeActiveUser(String username) {
+ String password = "1";
+ Collection authorities = new ArrayList();
+ LoginUserData loginedUser = new LoginUserData();
+ loginedUser.setUserName(username);
+
+ if ("admin".equals(username)) {
+ authorities.add(new SimpleGrantedAuthority(
+ "ROLE_ADMINISTRATOR_0"));
+ }
+
+ UserContainsSessionUser user = (UserContainsSessionUser) daoUserDetail
+ .loadUserByUsername(username);
+
+ Authentication authRequest = new UsernamePasswordAuthenticationToken(
+ user, password, authorities);
+
+ SecurityContextHolder.getContext().setAuthentication(authRequest);
+ }
+
+ protected String toJson(Object obj){
+ return JSONUtil.toJSONString(obj, true);
+ }
+}
Index: ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/RecyclingModule.java
===================================================================
diff -u
--- ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/RecyclingModule.java (revision 0)
+++ ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/RecyclingModule.java (revision 20835)
@@ -0,0 +1,149 @@
+package test.forgon.disinfectsystem.synthetic.allrecycle.service;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import net.sf.json.JSONObject;
+
+import org.apache.commons.collections4.CollectionUtils;
+
+import test.forgon.disinfectsystem.synthetic.allrecycle.model.RuntimeInfo;
+
+import com.forgon.directory.acegi.tools.AcegiHelper;
+import com.forgon.disinfectsystem.basedatamanager.container.service.ContainerManager;
+import com.forgon.disinfectsystem.entity.basedatamanager.container.Container;
+import com.forgon.disinfectsystem.entity.invoicemanager.InvoicePlan;
+import com.forgon.disinfectsystem.entity.recyclingrecord.RecyclingRecord;
+import com.forgon.disinfectsystem.entity.tousseitem.TousseItem;
+import com.forgon.disinfectsystem.recyclingapplication.service.InvoicePlanManager;
+import com.forgon.disinfectsystem.recyclingrecord.service.RecyclingRecordManager;
+import com.forgon.disinfectsystem.recyclingrecord.vo.RecyclingBasketItemVo;
+import com.forgon.runwithtrans.model.RunWithTransNewTask;
+/**
+ * 回收模块
+ * @author kzh
+ *
+ */
+public class RecyclingModule extends ModuleBase {
+ private InvoicePlanManager invoicePlanManager;
+ private RecyclingRecordManager recyclingRecordManager;
+ private ContainerManager containerManager;
+ /**
+ * 待回收的申请单id
+ */
+ private List waitRecyclingApplicationIds = new ArrayList<>();
+ public RecyclingModule(RuntimeInfo runtimeInfo) {
+ super(runtimeInfo);
+ moduleName = "回收";
+ }
+
+ @Override
+ protected void initBean() {
+ super.initBean();
+ invoicePlanManager = getBean("invoicePlanManager");
+ recyclingRecordManager = getBean("recyclingRecordManager");
+ containerManager = getBean("containerManager");
+ }
+
+ /**
+ * 查找所有待回收的申请单,存入到waitRecyclingApplicationIds中
+ */
+ @Override
+ protected void prepare() {
+ timeoutTransNewManager.runWith_TRANS_NEW(new RunWithTransNewTask() {
+ @Override
+ public void runTask() {
+ List list = invoicePlanManager.getWaitingforRecyclingInvoicePlans(AcegiHelper.getCurrentOrgUnitCode(),
+ null, null, null, null, null);
+ waitRecyclingApplicationIds = list.stream().map(p->p.getId()).collect(Collectors.toList());
+ }
+ });
+
+ }
+
+ @Override
+ protected void doWork() {
+ for(Long invoicePlanId : waitRecyclingApplicationIds){
+ timeoutTransNewManager.runWith_TRANS_NEW(new RunWithTransNewTask() {
+ @Override
+ public void runTask() {
+ submitRecyclingRecord(invoicePlanId);
+ }
+ });
+ }
+ }
+
+// @Override
+// protected void tryExit() {
+// // TODO Auto-generated method stub
+// super.tryExit();
+// }
+
+ @Override
+ protected boolean canExit() {
+ return requestStop && CollectionUtils.isEmpty(waitRecyclingApplicationIds);
+ }
+
+ private void submitRecyclingRecord(Long invoicePlanId){
+ InvoicePlan invoicePlan = invoicePlanManager.get(invoicePlanId);
+ RecyclingRecord oldRecord1 = new RecyclingRecord();
+ oldRecord1.setDepart(invoicePlan.getDepart());
+ oldRecord1.setDepartCode(invoicePlan.getDepartCoding());
+ oldRecord1.setRecyclingApplication(invoicePlan);
+ oldRecord1.setRecyclingTime(new Date());
+ oldRecord1.setOrgUnitCoding(invoicePlan.getHandleDepartCoding());
+
+ Container c = getRecyclingBasket();
+ if(c == null){
+ return;//没有篮筐,下次再回收吧
+ }
+ List tousseItems = new ArrayList<>();
+ for(TousseItem item : invoicePlan.getApplicationItems()){
+ RecyclingBasketItemVo vo = new RecyclingBasketItemVo();
+ vo.setAmount(item.getAmount());
+ vo.setBasketBarcode(c.getBarcode());
+ vo.setBasketGroupBarcodes(c.getBarcode());
+ vo.setItemType(RecyclingBasketItemVo.ITEM_TYPE_TOUSSE);
+ vo.setTousseAmountForMaterial(item.getAmount());
+ vo.setTousseDefinitionID(item.getTousseDefinitionId());
+ vo.setTousseName(item.getTousseName());
+ vo.setTousseNameForMaterial(item.getTousseName());
+ tousseItems.add(vo);
+ }
+ JSONObject params = new JSONObject();
+ params.put("tousseJson", tousseItems);
+ Date startTime = new Date();
+ String param1 = toJson(oldRecord1);
+ String param2 = params.toString();
+ try{
+ recyclingRecordManager.save(oldRecord1, params);
+ }finally{
+ runInfoLogManager.logDuration(moduleName, "recyclingRecordManager.save",
+ String.join(",", param1,param2), startTime);
+ }
+
+ }
+ /**
+ * 获取回收使用的篮筐。必须是清洗筐,且状态为已装配、空闲
+ * @return
+ */
+ private Container getRecyclingBasket(){
+ String where = String.format("containerType='%s' and purpose='%s' and departCode='%s' and status in ('%s','%s','%s','%s')",
+ Container.CONTAINERTYPE_BASKET,Container.CONTAINER_PURPOSE_CLEAN_BASKET,AcegiHelper.getCurrentOrgUnitCode(),
+ Container.CONTAINER_STATUS_FREE,Container.CONTAINER_STATUS_PACKED,Container.CONTAINER_STATUS_WASHLOADING,Container.CONTAINER_STATUS_WASHED);
+ List list = containerManager.getByHql(where);
+ if(CollectionUtils.isNotEmpty(list)){
+ for(Container c :list){
+ if(containerManager.isEmpty(c.getBarcode())){
+ return c;
+ }
+ if(c.washloading()){
+ return c;
+ }
+ }
+ }
+ return null;
+ }
+}
Index: ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/InvoiceModule.java
===================================================================
diff -u
--- ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/InvoiceModule.java (revision 0)
+++ ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/InvoiceModule.java (revision 20835)
@@ -0,0 +1,143 @@
+package test.forgon.disinfectsystem.synthetic.allrecycle.service;
+
+import static org.testng.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import test.forgon.disinfectsystem.synthetic.allrecycle.model.RuntimeInfo;
+
+import com.forgon.directory.acegi.tools.AcegiHelper;
+import com.forgon.disinfectsystem.basedatamanager.warehouse.service.WareHouseManager;
+import com.forgon.disinfectsystem.entity.basedatamanager.toussedefinition.TousseInstance;
+import com.forgon.disinfectsystem.entity.basedatamanager.warehouse.WareHouse;
+import com.forgon.disinfectsystem.entity.invoicemanager.TimeQuantum;
+import com.forgon.disinfectsystem.invoicemanager.service.InvoiceManager;
+import com.forgon.disinfectsystem.recyclingapplication.service.InvoicePlanManager;
+import com.forgon.disinfectsystem.recyclingapplication.vo.ApplicationGoodsVo;
+import com.forgon.disinfectsystem.recyclingapplication.vo.InvoicePlanVo;
+import com.forgon.disinfectsystem.tousse.toussedefinition.service.TousseInstanceManager;
+import com.forgon.runwithtrans.model.RunWithTransNewTask;
+
+public class InvoiceModule extends ModuleBase {
+
+ private InvoiceManager invoiceManager;
+ private InvoicePlanManager invoicePlanManager;
+ private WareHouseManager wareHouseManager;
+ private TousseInstanceManager tousseInstanceManager;
+ private List invoiceParams;
+ public InvoiceModule(RuntimeInfo runtimeInfo) {
+ super(runtimeInfo);
+ moduleName = "发货";
+ }
+
+ @Override
+ protected void initBean() {
+ super.initBean();
+ invoiceManager = getBean("invoiceManager");
+ invoicePlanManager = getBean("invoicePlanManager");
+ wareHouseManager = getBean("wareHouseManager");
+ tousseInstanceManager = getBean("tousseInstanceManager");
+ }
+
+ @Override
+ protected void prepare() {
+ invoiceParams = new ArrayList<>();
+ timeoutTransNewManager.runWith_TRANS_NEW(new RunWithTransNewTask() {
+ @Override
+ public void runTask() {
+ Collection invoicePlanVos = invoicePlanManager.getDepartInvoicePlan(null,null ,null);
+ if(CollectionUtils.isNotEmpty(invoicePlanVos)){
+ WareHouse wareHouse_CSSD = wareHouseManager.getDefaultWareHouseByUnitCode(AcegiHelper.getCurrentOrgUnitCode());
+ assertNotNull(wareHouse_CSSD);
+
+ List tousseInstances = tousseInstanceManager.getByHql(String.format("status in ('%s','%s') and wareHouseId=%d",
+ TousseInstance.STATUS_STERILED,TousseInstance.STATUS_DISINFECTED,wareHouse_CSSD.getId()));
+ if(CollectionUtils.isEmpty(tousseInstances)){
+ return;
+ }
+ for(InvoicePlanVo invoicePlanVo : invoicePlanVos){
+ Collection goodsVos = invoiceManager.getWaitDeliverGoods(invoicePlanVo.getDepartCode(), TimeQuantum.All);
+ if(CollectionUtils.isNotEmpty(goodsVos)){
+ int tousseAmountPerInvoice = runtimeInfo.tousseAmountPerInvoice;
+ JSONArray invoiceItems = new JSONArray();
+ for(ApplicationGoodsVo goods : goodsVos){
+ if(goods.disposable()){
+ //一次性物品,不包含
+ continue;
+ }
+ if(tousseAmountPerInvoice <=0){
+ break;
+ }
+ Set sets = tousseInstances.stream().filter(p->StringUtils.equals(p.getTousseName(),goods.getName())
+ &&StringUtils.equals(p.getTousseDefinition().getTousseType(), goods.getGoodsType())).collect(Collectors.toSet());
+ int amount = goods.getCount();
+ for(TousseInstance ti : sets){
+ if(amount <= 0){
+ break;
+ }
+ if(tousseAmountPerInvoice <=0){
+ break;
+ }
+ JSONObject invoiceItem = new JSONObject();
+ invoiceItem.put("barcode", ti.getBarcode());
+ invoiceItem.put("sendAmount", 1);
+ invoiceItem.put("isRoutine", TousseInstance.ROUTINE_YES);
+ invoiceItems.add(invoiceItem);
+ amount--;
+ tousseAmountPerInvoice--;
+ tousseInstances.remove(ti);//避免下次再发送同一个包
+ }
+ }
+ JSONObject params = new JSONObject();
+
+ params.put("mode", "depart");
+ params.put("departCode", invoicePlanVo.getDepartCode());
+ params.put("assistantSender", AcegiHelper.getLoginUserFullName());
+ params.put("sender", AcegiHelper.getLoginUserFullName());
+ params.put("invoiceItems", invoiceItems);
+ params.put("sourceWarehouseId", wareHouse_CSSD.getId());
+ params.put("sourceWarehouseName", wareHouse_CSSD.getName());
+ invoiceParams.add(params);
+ }
+ }
+ }
+ }
+ });
+
+ }
+
+ @Override
+ protected void doWork() {
+ for(JSONObject param : invoiceParams){
+ timeoutTransNewManager.runWith_TRANS_NEW(new RunWithTransNewTask() {
+ @Override
+ public void runTask() {
+ Date startTime = new Date();
+ try{
+ invoiceManager.submitInvoice(param);
+ }finally{
+ runInfoLogManager.logDuration(moduleName, "invoiceManager.submitInvoice", param.toString(), startTime);
+ }
+
+ }
+ });
+ }
+ }
+
+ @Override
+ protected boolean canExit() {
+ return requestStop && CollectionUtils.isEmpty(invoiceParams);
+ }
+
+}
Index: ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/ApplyModule.java
===================================================================
diff -u
--- ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/ApplyModule.java (revision 0)
+++ ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/ApplyModule.java (revision 20835)
@@ -0,0 +1,114 @@
+package test.forgon.disinfectsystem.synthetic.allrecycle.service;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+import test.forgon.constant.Constants;
+import test.forgon.disinfectsystem.synthetic.allrecycle.model.RuntimeInfo;
+
+import com.forgon.disinfectsystem.entity.basedatamanager.toussedefinition.TousseDefinition;
+import com.forgon.disinfectsystem.entity.invoicemanager.InvoicePlan;
+import com.forgon.disinfectsystem.entity.recyclingapplication.RecyclingApplication;
+import com.forgon.disinfectsystem.recyclingapplication.service.InvoicePlanManager;
+import com.forgon.disinfectsystem.recyclingapplication.service.RecyclingApplicationManager;
+import com.forgon.disinfectsystem.tousse.toussedefinition.service.TousseDefinitionManager;
+import com.forgon.disinfectsystem.vo.TousseItemVo;
+import com.forgon.runwithtrans.model.RunWithTransNewTask;
+
+/**
+ * 创建申请单模块
+ * @author kzh
+ *
+ */
+public class ApplyModule extends ModuleBase {
+ private InvoicePlanManager invoicePlanManager;
+ private RecyclingApplicationManager recyclingApplicationManager;
+ private TousseDefinitionManager tousseDefinitionManager;
+
+ public ApplyModule(RuntimeInfo runtimeInfo){
+ super(runtimeInfo);
+ moduleName = "申请";
+ }
+ private int tousseAmountPerTd = 10;
+
+ @Override
+ protected void prepare() {
+ prepareInvoicePlan();
+ }
+
+ @Override
+ protected void initBean() {
+ super.initBean();
+ invoicePlanManager = getBean("invoicePlanManager");
+ recyclingApplicationManager = getBean("recyclingApplicationManager");
+ tousseDefinitionManager = getBean("tousseDefinitionManager");
+ }
+
+ /**
+ * 初始化发货计划
+ */
+ private void prepareInvoicePlan(){
+ //以下都是10个
+ for(String tousseName : Arrays.asList("Test穿刺包","TestOR胆加仪","Test缝合包","Test清创包")){
+ createInvoicePlan(tousseName,tousseAmountPerTd);
+ }
+
+ //以下都是20个
+ for(String tousseName : Arrays.asList("Test开胸包","Test开颅包","Test开口包",
+ "TestOR甲加仪(半年期)","Test治疗巾","Test宫碘包","Test雾化器","止血带[100条/扎]","呼吸机","test止血带")){
+ createInvoicePlan(tousseName,2*tousseAmountPerTd);
+ }
+ }
+
+ private void createInvoicePlan(String tousseName,int tousseItemAmount) {
+ timeoutTransNewManager.runWith_TRANS_NEW(new RunWithTransNewTask() {
+ @Override
+ public void runTask() {
+ RecyclingApplication invoicePlan = new RecyclingApplication();
+ invoicePlan.setDeliverStatus(InvoicePlan.DELIVERSTATUS_AWAITDELIVER);
+ invoicePlan.setRecyclingStatus(InvoicePlan.RECYCLINGSTATUS_AWAITRECYCLE);
+ invoicePlan.setCommittedStatus(true);
+ invoicePlan.setDepartCoding(Constants.ORG_UNIT_CODE_OR);
+ invoicePlan.setDepart(Constants.ORG_UNIT_NAME_OR);
+ invoicePlan.setSettleAccountsDepartCoding(Constants.ORG_UNIT_CODE_OR);
+ invoicePlan.setSettleAccountsDepart(Constants.ORG_UNIT_NAME_OR);
+ invoicePlan.setHandleDepartCoding(Constants.ORG_UNIT_CODE_CSSD);
+ invoicePlan.setHandleDepart(Constants.ORG_UNIT_NAME_OR);
+ invoicePlan.setType(InvoicePlan.TYPE_COMBO_FORM);
+
+ List items = new ArrayList();
+ TousseItemVo tousseItem = createTousseItem(tousseName,tousseItemAmount);
+ items.add(tousseItem);
+ String param1 = toJson(invoicePlan);
+ String param2 = toJson(items);
+ String param3 = "true";
+ Date startTime = new Date();
+ try{
+ recyclingApplicationManager.saveRecyclingApplication(invoicePlan, items, true);
+ }finally{
+ runInfoLogManager.logDuration(moduleName, "recyclingApplicationManager.saveRecyclingApplication",
+ String.join(",", param1,param2,param3), startTime);
+ }
+
+ }
+ });
+ }
+
+ private TousseItemVo createTousseItem(String tousseName,int amount) {
+ TousseDefinition tousseDefinition = tousseDefinitionManager.getTousseDefinitionByName(tousseName);
+ TousseItemVo tousseItem = new TousseItemVo();
+ tousseItem.setAmount(amount);
+ tousseItem.setSendOutAmount(0);
+ tousseItem.setTousseName(tousseName);
+ tousseItem.setDiposable(com.forgon.Constants.STR_NO);
+ tousseItem.setIsApplyEntireTousse(tousseDefinition.getIsCleanedEntirely());
+ tousseItem.setIsRecycling(tousseDefinition.getIsRecycling());
+ tousseItem.setPrice(tousseDefinition.getPrice());
+ tousseItem.setTousseDefinitionId(tousseDefinition.getId());
+ tousseItem.setTousseDefinitionID(tousseDefinition.getId());
+ tousseItem.setTousseType(tousseDefinition.getTousseType());
+ return tousseItem;
+ }
+}
Index: ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/RunInfoLogManager.java
===================================================================
diff -u
--- ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/RunInfoLogManager.java (revision 0)
+++ ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/RunInfoLogManager.java (revision 20835)
@@ -0,0 +1,23 @@
+package test.forgon.disinfectsystem.synthetic.allrecycle.service;
+
+import java.util.Date;
+
+import com.forgon.disinfectsystem.entity.test.RunInfoLog;
+import com.forgon.tools.hibernate.BasePoManager;
+
+public interface RunInfoLogManager extends BasePoManager {
+ /**
+ * 记录异常
+ * @param moduleName
+ * @param method
+ */
+ public void logException(String moduleName, String method,String params,Date startTime,Exception e);
+ /**
+ * 记录运行时间
+ * @param moduleName
+ * @param method
+ * @param params
+ * @param startTime
+ */
+ public void logDuration(String moduleName, String method,String params,Date startTime);
+}
Index: ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/ReviewModule.java
===================================================================
diff -u
--- ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/ReviewModule.java (revision 0)
+++ ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/ReviewModule.java (revision 20835)
@@ -0,0 +1,92 @@
+package test.forgon.disinfectsystem.synthetic.allrecycle.service;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import org.apache.commons.collections4.CollectionUtils;
+
+import test.forgon.disinfectsystem.synthetic.allrecycle.model.RuntimeInfo;
+
+import com.forgon.directory.acegi.tools.AcegiHelper;
+import com.forgon.disinfectsystem.entity.basedatamanager.toussedefinition.TousseInstance;
+import com.forgon.disinfectsystem.packing.service.PackingManager;
+import com.forgon.disinfectsystem.tousse.toussedefinition.service.TousseInstanceManager;
+import com.forgon.runwithtrans.model.RunWithTransNewTask;
+import com.forgon.tools.MyCollectionUtils;
+
+public class ReviewModule extends ModuleBase {
+ private Map> taskGroupTousseInstanceIds = new HashMap<>();
+ private TousseInstanceManager tousseInstanceManager;
+ private PackingManager packingManager;
+ public ReviewModule(RuntimeInfo runtimeInfo) {
+ super(runtimeInfo);
+ moduleName = "审核";
+ }
+
+ @Override
+ protected void initBean() {
+ super.initBean();
+ tousseInstanceManager = getBean("tousseInstanceManager");
+ packingManager = getBean("packingManager");
+ }
+
+ @Override
+ protected void prepare() {
+ timeoutTransNewManager.runWith_TRANS_NEW(new RunWithTransNewTask() {
+
+ @Override
+ public void runTask() {
+ List tousseInstances = tousseInstanceManager.getByHql(String.format("po.status='%s' and po.orgUnitCoding = '%s'",
+ TousseInstance.STATUS_PACKED,AcegiHelper.getCurrentOrgUnitCode()));
+ taskGroupTousseInstanceIds.clear();
+ if(CollectionUtils.isNotEmpty(tousseInstances)){
+ for(TousseInstance ti : tousseInstances){
+ List ids = taskGroupTousseInstanceIds.get(ti.getTaskGroup());
+ if(ids == null){
+ ids = new ArrayList<>();
+ taskGroupTousseInstanceIds.put(ti.getTaskGroup(), ids);
+ }
+ ids.add(ti.getId());
+ }
+ }
+ }
+ });
+ }
+
+ @Override
+ protected void doWork() {
+ String reviewerCode = AcegiHelper.getLoginUser().getUserName();
+ String reviewer = AcegiHelper.getLoginUser().getUserFullName();
+ Date sterileDate = new Date();
+ for(String taskGroup : taskGroupTousseInstanceIds.keySet()){
+ Date startTime = new Date();
+ List allIds = taskGroupTousseInstanceIds.get(taskGroup).stream().map(p->p.toString()).collect(Collectors.toList());
+ List> splitIds = MyCollectionUtils.split(allIds,runtimeInfo.tousseAmountPerReview);
+ for(List idList : splitIds){
+ timeoutTransNewManager.runWith_TRANS_NEW(new RunWithTransNewTask() {
+ @Override
+ public void runTask() {
+ String ids = String.join(";", idList);
+ try{
+ packingManager.reviewTousseInstance(ids, null,
+ taskGroup, reviewer,reviewerCode, sterileDate);
+ }finally{
+ runInfoLogManager.logDuration(moduleName, "packingManager.reviewTousseInstance",
+ String.join(",", ids,"null",taskGroup,reviewer,reviewerCode,sterileDate.toString()), startTime);
+ }
+ }
+ });
+ }
+ }
+ }
+
+ @Override
+ protected boolean canExit() {
+ return requestStop && taskGroupTousseInstanceIds.isEmpty();
+ }
+
+}
Index: ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/SterileModule.java
===================================================================
diff -u
--- ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/SterileModule.java (revision 0)
+++ ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/SterileModule.java (revision 20835)
@@ -0,0 +1,114 @@
+package test.forgon.disinfectsystem.synthetic.allrecycle.service;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.apache.commons.collections4.CollectionUtils;
+
+import test.forgon.constant.Constants;
+import test.forgon.disinfectsystem.synthetic.allrecycle.model.RuntimeInfo;
+
+import com.forgon.directory.acegi.tools.AcegiHelper;
+import com.forgon.disinfectsystem.basedatamanager.sterilizer.service.SterilizerManager;
+import com.forgon.disinfectsystem.entity.basedatamanager.sterilizer.Sterilizer;
+import com.forgon.disinfectsystem.entity.basedatamanager.toussedefinition.TousseInstance;
+import com.forgon.disinfectsystem.entity.sterilizationmanager.sterilizationrecord.SterilizationRecord;
+import com.forgon.disinfectsystem.sterilizationmanager.sterilizationrecord.service.SterilizationRecordManager;
+import com.forgon.disinfectsystem.tousse.toussedefinition.service.TousseInstanceManager;
+import com.forgon.runwithtrans.model.RunWithTransNewTask;
+import com.forgon.tools.MyCollectionUtils;
+
+public class SterileModule extends ModuleBase {
+
+ private TousseInstanceManager tousseInstanceManager;
+ private SterilizerManager sterilizerManager;
+ private SterilizationRecordManager sterilizationRecordManager;
+ private List> barcodes;
+ private Long sterilizationRecordId = null;
+ public SterileModule(RuntimeInfo runtimeInfo) {
+ super(runtimeInfo);
+ moduleName = "灭菌";
+ }
+
+ @Override
+ protected void initBean() {
+ super.initBean();
+ tousseInstanceManager = getBean("tousseInstanceManager");
+ sterilizerManager = getBean("sterilizerManager");
+ sterilizationRecordManager = getBean("sterilizationRecordManager");
+ }
+
+ @Override
+ protected void prepare() {
+ barcodes =null;
+ timeoutTransNewManager.runWith_TRANS_NEW(new RunWithTransNewTask() {
+ @Override
+ public void runTask() {
+ List list = tousseInstanceManager.getAllReviewedTousseInstanceWithOutBasket(AcegiHelper.getCurrentOrgUnitCode(),null,null,null,null,null,null);
+ if(CollectionUtils.isNotEmpty(list)){
+ barcodes = MyCollectionUtils.split(list.stream().map(p->p.getBarcode()).collect(Collectors.toSet()),runtimeInfo.tousseAmountPerSterile);
+ }
+ }
+ });
+
+ }
+
+ @Override
+ protected void doWork() {
+ if(CollectionUtils.isNotEmpty(barcodes)){
+ for(List barcodeList : barcodes){
+ timeoutTransNewManager.runWith_TRANS_NEW(new RunWithTransNewTask() {
+ @Override
+ public void runTask() {
+ if(CollectionUtils.isNotEmpty(barcodeList)){
+ Sterilizer s = sterilizerManager.getSterilizerByName(Constants.Sterilizer.STERILIZER1);
+ SterilizationRecord sterilizationRecord = new SterilizationRecord();
+ sterilizationRecord.setSterilizer(s);
+ sterilizationRecord.setOrgUnitCoding(AcegiHelper.getCurrentOrgUnitCode());
+ sterilizationRecord.setSterilizerName(s.getName());
+ //只能按灭菌炉的实际炉次传参,否则将通不过
+ sterilizationRecord.setFrequency(sterilizationRecordManager.getMaxFrequency(s, 0L));
+ sterilizationRecord.setStartDate(new Date());
+ Date startTime = new Date();
+ try{
+ sterilizationRecordManager.saveOrUpdateSterilizationRecord(sterilizationRecord, barcodeList, null, null);
+ }finally{
+ runInfoLogManager.logDuration(moduleName, "sterilizationRecordManager.saveOrUpdateSterilizationRecord",
+ String.join(",", toJson(sterilizationRecord),toJson(barcodeList),"null","null"), startTime);
+ }
+ sterilizationRecordId = sterilizationRecord.getId();
+ }
+ }
+ });
+ //完成灭菌,不需要灭菌完成确认
+ timeoutTransNewManager.runWith_TRANS_NEW(new RunWithTransNewTask() {
+ @Override
+ public void runTask() {
+ List ids = new ArrayList<>();
+ ids.add(sterilizationRecordId);
+ Date startTime = new Date();
+ try{
+ sterilizationRecordManager.completeSterilization(ids, AcegiHelper.getCurrentOrgUnitCode(),
+ AcegiHelper.getLoginUserFullName());
+ }finally{
+ runInfoLogManager.logDuration(moduleName, "sterilizationRecordManager.completeSterilization",
+ String.join(",", ids.toString(),AcegiHelper.getCurrentOrgUnitCode(),
+ AcegiHelper.getLoginUserFullName()), startTime);
+ }
+
+
+ }
+ });
+ }
+ }
+ }
+
+ @Override
+ protected boolean canExit() {
+ return requestStop&&CollectionUtils.isEmpty(barcodes);
+ }
+
+
+}
Index: ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/RunInfoLogManagerImpl.java
===================================================================
diff -u
--- ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/RunInfoLogManagerImpl.java (revision 0)
+++ ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/RunInfoLogManagerImpl.java (revision 20835)
@@ -0,0 +1,99 @@
+package test.forgon.disinfectsystem.synthetic.allrecycle.service;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Date;
+
+import com.forgon.disinfectsystem.entity.test.RunInfoLog;
+import com.forgon.runwithtrans.model.RunWithTransNewTask;
+import com.forgon.runwithtrans.service.RunWithTransNewManager;
+import com.forgon.tools.hibernate.BasePoManagerImpl;
+
+public class RunInfoLogManagerImpl extends BasePoManagerImpl implements RunInfoLogManager {
+ private RunWithTransNewManager runWithTransNewManager;
+
+ public void setRunWithTransNewManager(
+ RunWithTransNewManager runWithTransNewManager) {
+ this.runWithTransNewManager = runWithTransNewManager;
+ }
+
+ @Override
+ public void logException(String moduleName, String method,String params,Date startTime,Exception e) {
+
+ StringWriter sw = null;
+ PrintWriter pw = null;
+ String ex = null;
+ try{
+ sw = new StringWriter();
+ pw = new PrintWriter(sw);
+ e.printStackTrace(pw);
+ pw.flush();
+ ex = sw.toString();
+ ex = adjustStrLen(ex);
+ }finally{
+ try {
+ if(pw != null){
+ pw.close();
+ }
+ if(sw != null){
+ sw.close();
+ }
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
+ }
+
+ RunInfoLog log = new RunInfoLog();
+ log.setException(ex);
+ log.setLogTime(new Date());
+ log.setMessage(adjustStrLen(e.getLocalizedMessage()));
+ log.setMethod(method);
+ log.setModule(moduleName);
+ log.setParams(adjustStrLen(params));
+ log.setStartTime(startTime);
+ calculateDuration(log);
+ save(log);
+ }
+
+ private void calculateDuration(RunInfoLog log){
+ Date startTime = log.getStartTime();
+ Date logTime = log.getLogTime();
+ long timespan = logTime.getTime() - startTime.getTime();
+ log.setDuration(timespan);
+ }
+
+ @Override
+ public void logDuration(String moduleName, String method, String params,
+ Date startTime) {
+ RunInfoLog log = new RunInfoLog();
+ log.setLogTime(new Date());
+ log.setMethod(method);
+ log.setModule(moduleName);
+ log.setParams(adjustStrLen(params));
+ log.setStartTime(startTime);
+ calculateDuration(log);
+ save(log);
+ }
+
+ @Override
+ public void save(RunInfoLog object) throws RuntimeException {
+ runWithTransNewManager.runWith_TRANS_NEW(new RunWithTransNewTask() {
+ @Override
+ public void runTask() {
+ objectDao.save(object);
+ }
+ });
+ }
+ /**
+ * 调整字符串长度.数据库中最大支持4k长度
+ * @param str
+ * @return
+ */
+ private String adjustStrLen(String str){
+ if(str != null && str.length() >= 8000){
+ str = str.substring(0,4000);
+ }
+ return str;
+ }
+}
Index: ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/WashModule.java
===================================================================
diff -u
--- ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/WashModule.java (revision 0)
+++ ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/WashModule.java (revision 20835)
@@ -0,0 +1,124 @@
+package test.forgon.disinfectsystem.synthetic.allrecycle.service;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
+import org.apache.commons.lang3.StringUtils;
+
+import test.forgon.constant.Constants;
+import test.forgon.disinfectsystem.synthetic.allrecycle.model.RuntimeInfo;
+
+import com.forgon.directory.acegi.tools.AcegiHelper;
+import com.forgon.disinfectsystem.basedata.becleanitem.service.ClassifyBasketManager;
+import com.forgon.disinfectsystem.basedatamanager.rinser.service.RinserManager;
+import com.forgon.disinfectsystem.entity.basedatamanager.rinser.Rinser;
+import com.forgon.disinfectsystem.entity.becleanitem.ClassifyBasket;
+import com.forgon.disinfectsystem.entity.washanddisinfectmanager.washanddisinfectrecord.WashAndDisinfectRecord;
+import com.forgon.disinfectsystem.washanddisinfectmanager.washanddisinfectrecord.service.WashAndDisinfectRecordManager;
+import com.forgon.runwithtrans.model.RunWithTransNewTask;
+import com.forgon.tools.db.DatabaseUtil;
+import com.forgon.tools.util.ForgonDateUtils;
+/**
+ * 清洗模块
+ * @author kzh
+ *
+ */
+public class WashModule extends ModuleBase {
+ private ClassifyBasketManager classifyBasketManager;
+ private WashAndDisinfectRecordManager washAndDisinfectRecordManager;
+ private RinserManager rinserManager;
+ private Map paramMap;
+ private Long washAndDisinfectRecordId;
+ public WashModule(RuntimeInfo runtimeInfo) {
+ super(runtimeInfo);
+ moduleName = "清洗";
+ }
+
+ @Override
+ protected void initBean() {
+ super.initBean();
+ classifyBasketManager = getBean("classifyBasketManager");
+ washAndDisinfectRecordManager = getBean("washAndDisinfectRecordManager");
+ rinserManager = getBean("rinserManager");
+ }
+
+ @Override
+ protected void prepare() {
+ timeoutTransNewManager.runWith_TRANS_NEW(new RunWithTransNewTask() {
+ @Override
+ public void runTask() {
+ List baskets = classifyBasketManager.loadPendingWashBaskets();
+ JSONArray array = new JSONArray();
+ for(ClassifyBasket basket : baskets){
+ JSONObject json = new JSONObject();
+ json.put("classifyBasketID", basket.getId());
+ json.put("personInChargeCode", AcegiHelper.getLoginUser().getUserName());
+ array.add(json);
+ }
+ paramMap = new HashMap();
+ paramMap.put("classifyBasketInfo", array.toString());
+ }
+ });
+
+ }
+
+ @Override
+ protected boolean canExit() {
+ if(!requestStop){
+ return false;
+ }
+ if(paramMap !=null){
+ String classifyBasketInfo = paramMap.get("classifyBasketInfo");
+ if(StringUtils.isNotBlank(classifyBasketInfo)){
+ JSONArray array = JSONArray.fromObject(classifyBasketInfo);
+ return array.size() <= 0;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ protected void doWork() {
+ timeoutTransNewManager.runWith_TRANS_NEW(new RunWithTransNewTask() {
+ @Override
+ public void runTask() {
+ WashAndDisinfectRecord washRecord = new WashAndDisinfectRecord();
+ washRecord.setStartDateStr(ForgonDateUtils.safelyFormatDate(new Date(), com.forgon.Constants.SIMPLEDATEFORMAT_YYYYMMDDHHMM, ""));
+ washRecord.setEndDateStr(ForgonDateUtils.safelyFormatDate(new Date(), com.forgon.Constants.SIMPLEDATEFORMAT_YYYYMMDDHHMM, ""));
+ washRecord.setDisinfectIdentification(Constants.RinserName.RINSER_1);
+ washRecord.setDisinfectProgram(Constants.CleanMethodName.CLEAN_METHOD_NAME_P1);
+ washAndDisinfectRecordManager.setRecycleCountIfNeed(washRecord);
+ Date startTime = new Date();
+ try{
+ washAndDisinfectRecordManager.saveOrUpdateWashAndDisinfectRecord(washRecord, paramMap);
+ }finally{
+ runInfoLogManager.logDuration(moduleName, "washAndDisinfectRecordManager.saveOrUpdateWashAndDisinfectRecord",
+ String.join(",", toJson(washRecord),toJson(paramMap)), startTime);
+ }
+
+ }
+ });
+
+ }
+
+ @Override
+ protected void actOnce() {
+ super.actOnce();
+ //如果清洗机是需要完成确认的,则保存以后还需要完成确认
+ timeoutTransNewManager.runWith_TRANS_NEW(new RunWithTransNewTask() {
+ @Override
+ public void runTask() {
+ Rinser rinser = rinserManager.getRinserByName(Constants.RinserName.RINSER_1);
+ if(rinser.sterilizerIsWashConfirm() && DatabaseUtil.isPoIdValid(washAndDisinfectRecordId)){
+ washAndDisinfectRecordManager.washConfirm(washAndDisinfectRecordId.toString(), WashAndDisinfectRecord.STATUS_WASHED);
+ }
+ }
+ });
+ }
+
+}
Index: ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/AllRecycleTests.java
===================================================================
diff -u
--- ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/AllRecycleTests.java (revision 0)
+++ ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/AllRecycleTests.java (revision 20835)
@@ -0,0 +1,77 @@
+package test.forgon.disinfectsystem.synthetic.allrecycle;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+import org.testng.annotations.Test;
+
+import test.forgon.disinfectsystem.AbstractCSSDTest;
+import test.forgon.disinfectsystem.synthetic.allrecycle.model.RuntimeInfo;
+import test.forgon.disinfectsystem.synthetic.allrecycle.service.ApplyModule;
+import test.forgon.disinfectsystem.synthetic.allrecycle.service.InvoiceModule;
+import test.forgon.disinfectsystem.synthetic.allrecycle.service.PackingModule;
+import test.forgon.disinfectsystem.synthetic.allrecycle.service.RecyclingModule;
+import test.forgon.disinfectsystem.synthetic.allrecycle.service.ReviewModule;
+import test.forgon.disinfectsystem.synthetic.allrecycle.service.SterileModule;
+import test.forgon.disinfectsystem.synthetic.allrecycle.service.UseRecordModule;
+import test.forgon.disinfectsystem.synthetic.allrecycle.service.WashModule;
+
+/**
+ * 主要流程模块的测试用例.每个模块单独在自己的线程中执行
+ */
+public class AllRecycleTests extends AbstractCSSDTest {
+
+ @Test
+ public void testCssdRecyle(){
+ RuntimeInfo runtimeInfo = new RuntimeInfo();
+ ApplyModule apply = new ApplyModule(runtimeInfo);
+ RecyclingModule recycling = new RecyclingModule(runtimeInfo);
+ recycling.setPreModule(apply);
+ WashModule wash = new WashModule(runtimeInfo);
+ wash.setPreModule(recycling);
+ PackingModule packing = new PackingModule(runtimeInfo);
+ packing.setPreModule(wash);
+ ReviewModule review = new ReviewModule(runtimeInfo);
+ review.setPreModule(packing);
+ SterileModule sterile = new SterileModule(runtimeInfo);
+ sterile.setPreModule(review);
+ InvoiceModule invoice = new InvoiceModule(runtimeInfo);
+ invoice.setPreModule(sterile);
+ UseRecordModule useRecord = new UseRecordModule(runtimeInfo);
+ useRecord.setPreModule(invoice);
+
+ apply.start();
+ recycling.start();
+ wash.start();
+ packing.start();
+ review.start();
+ sterile.start();
+ invoice.start();
+ useRecord.start();
+
+ ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
+ service.schedule(new Runnable(){
+ @Override
+ public void run() {
+ runtimeInfo.exit = true;
+ }}, runtimeInfo.testDuration, TimeUnit.MINUTES);
+ apply.join();
+ recycling.stop();
+ recycling.join();
+ wash.stop();
+ wash.join();
+ packing.stop();
+ packing.join();
+ review.stop();
+ review.join();
+ sterile.stop();
+ sterile.join();
+ invoice.stop();
+ invoice.join();
+ useRecord.stop();
+ useRecord.join();
+ System.out.println(String.join("','", packing.getAllProcessedPackingTaskIds().stream().map(p->p.toString()).collect(Collectors.toList())));
+ }
+}
Index: ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/UseRecordModule.java
===================================================================
diff -u
--- ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/UseRecordModule.java (revision 0)
+++ ssts-web/src/test/java/test/forgon/disinfectsystem/synthetic/allrecycle/service/UseRecordModule.java (revision 20835)
@@ -0,0 +1,12 @@
+package test.forgon.disinfectsystem.synthetic.allrecycle.service;
+
+import test.forgon.disinfectsystem.synthetic.allrecycle.model.RuntimeInfo;
+
+public class UseRecordModule extends ModuleBase {
+
+ public UseRecordModule(RuntimeInfo runtimeInfo) {
+ super(runtimeInfo);
+ moduleName = "使用记录";
+ }
+
+}