Browse Source

共享审核追加两种状态

hujie 1 year ago
parent
commit
9ef4b2d6a4

+ 22 - 0
cn.com.taiji.myapp/src/main/java/cn/com/taiji/quartz/common/job/ShareApplyExpireJob.java

@@ -0,0 +1,22 @@
+package cn.com.taiji.quartz.common.job;
+
+import cn.com.taiji.util.SpringUtil;
+import cn.com.taiji.zhongxiao.service.TshareApplyService;
+import org.quartz.DisallowConcurrentExecution;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@DisallowConcurrentExecution
+public class ShareApplyExpireJob implements Job {
+	 private static final Logger logger = LoggerFactory.getLogger(ShareApplyExpireJob.class);
+	@Override
+	public void execute(JobExecutionContext context) throws JobExecutionException {
+		logger.info("JobName: {}", context.getJobDetail().getKey().getName());
+		TshareApplyService service = SpringUtil.getBean(TshareApplyService.class);
+		service.expireShareApply();
+		logger.info("ShareApplyExpireJob执行完毕");
+	}
+}

+ 5 - 0
cn.com.taiji.system/pom.xml

@@ -364,6 +364,11 @@
 		    <artifactId>fastjson</artifactId>
 		    <version>1.2.56</version>
 		</dependency>
+		<dependency>
+			<groupId>cn.hutool</groupId>
+			<artifactId>hutool-all</artifactId>
+			<version>5.8.16</version>
+		</dependency>
 		  
 	</dependencies>
 	<build>

+ 1 - 1
cn.com.taiji.system/src/main/java/cn/com/taiji/zhongxiao/dto/TshareApplyDto.java

@@ -52,7 +52,7 @@ public class TshareApplyDto implements Serializable {
 	private String requireid;//需求单id
 	private String isconditions;//需求单id
 	private  VtasklistDto task;
-	private String actualize; //是否已实施 -1 未派单 0未实施   1已实施
+	private String actualize; // 是否已实施 -1未派单 0未实施 1已实施 2过期待停用 3过期已停用
 	private String actualizetime; //实施时间
 	private String distributetime; //派发时间
 	private String isrevoke; //是否撤销

+ 53 - 10
cn.com.taiji.system/src/main/java/cn/com/taiji/zhongxiao/service/TshareApplyService.java

@@ -2,12 +2,7 @@ package cn.com.taiji.zhongxiao.service;
 
 import java.sql.ResultSet;
 import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 
 import javax.inject.Inject;
 import javax.persistence.criteria.CriteriaBuilder;
@@ -16,7 +11,11 @@ import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Join;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
+import javax.servlet.http.HttpServletRequest;
 
+import cn.hutool.core.date.DateField;
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
 import org.activiti.engine.HistoryService;
 import org.activiti.engine.TaskService;
 import org.activiti.engine.history.HistoricTaskInstance;
@@ -24,6 +23,7 @@ import org.activiti.engine.task.Attachment;
 import org.activiti.engine.task.Comment;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.domain.Example;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Sort;
@@ -33,6 +33,7 @@ import org.springframework.data.jpa.domain.Specification;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.core.RowMapper;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
 import cn.com.taiji.sys.domain.Dept;
@@ -57,6 +58,8 @@ import cn.com.taiji.zhongxiao.dto.TshareApplyDtoForWord;
 import cn.com.taiji.zhongxiao.dto.VtasklistDto;
 import cn.com.taiji.zhongxiao.web.BaseAction;
 
+import static cn.com.taiji.zhongxiao.web.TshareApplyController.modelType;
+
 @Service
 @Transactional
 public class TshareApplyService {
@@ -147,6 +150,48 @@ public class TshareApplyService {
 		tshareApplyRepository.saveAndFlush(tshareApply);
 	}
 
+	@Inject
+	LoginfoService loginfoService;
+	// 老代码很多都没有事务控制???
+	@Transactional(propagation = Propagation.REQUIRED)
+	public void disableShareApply(HttpServletRequest request, User userInfo, String busId) {
+		Map<String, Object> map = new HashMap();
+		for(String id :busId.split(";")) {
+			TshareApplyDto tshareApply =  this.byone(id);
+			// 改成过期已撤销
+			tshareApply.setActualize("3");
+			this.TshareApplysave(tshareApply);
+			//记录模块操作日志
+			loginfoService.logDealInfo("2", modelType, "共享申请派单", "t_shareapply", id,ToolUtil.getIpAddr(request), request.getRequestURI(), userInfo);
+		}
+	}
+
+	@Transactional(propagation = Propagation.REQUIRED)
+	public void expireShareApply() {
+		List<TshareApply> list = tshareApplyRepository.findAll(new Specification<TshareApply>() {
+			@Override
+			public Predicate toPredicate(Root<TshareApply> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
+				List<Predicate> pl = new ArrayList<Predicate>();
+				pl.add(cb.equal(root.<String>get("state"), "2"));
+				pl.add(cb.equal(root.<String>get("actualize"), "1"));
+				pl.add(cb.isNull(root.get("isrevoke")));
+				return cb.and(pl.toArray(new Predicate[0]));
+			}
+		});
+		Date now = new Date();
+		list.forEach(apply -> {
+			DateTime time = DateUtil.parse(apply.getActualizetime(), "yyyy-MM-dd HH:mm:ss");
+			time = time.offset(DateField.YEAR, Integer.valueOf(apply.getSharingcycle().trim()));
+			if (time.isBeforeOrEquals(now)) {
+				TshareApplyDto dto =  this.byone(apply.getId());
+				// 改成过期已撤销
+				dto.setActualize("2");
+				this.TshareApplysave(dto);
+			}
+		});
+	}
+
+
 	// 获取资源共享申请列表
 	public Pagination findtshareApplysave(final TshareApplyDto dto, Pagination pag, final User userInfo,
 			final String type, Map<String, Object> searchParameters) {
@@ -265,9 +310,8 @@ public class TshareApplyService {
 				}
 				else {
 				
-					if (!"3".equals(type)) {//详情
+					if (!"3".equals(type) && !"1".equals(type)) {//详情
 						pl.add(cb.isNull(root.get("isrevoke")));
-
 					}
 				}
 				if (dto.getTaskname() != null && !"".equals(dto.getTaskname())) {
@@ -321,8 +365,7 @@ public class TshareApplyService {
 					if (dto.getHitchStatus() == 1) {
 						pl.add((cb.equal(root.get("hitchStatus"), dto.getHitchStatus())));
 					} else {
-						pl.add(cb.or(cb.equal(join.get("hitchStatus"), dto.getHitchStatus()),
-								cb.isNull(join.get("hitchStatus"))));
+						pl.add(cb.or(cb.equal(join.get("hitchStatus"), dto.getHitchStatus()), cb.isNull(join.get("hitchStatus"))));
 					}
 				}
 				if (dto.getActualize() != null && !"".equals(dto.getActualize())) {

+ 21 - 3
cn.com.taiji.system/src/main/java/cn/com/taiji/zhongxiao/web/TshareApplyController.java

@@ -462,7 +462,6 @@ public class TshareApplyController extends BaseAction{
 			  			if("已实施".equals(dto.getState())) {
 			  				dto.setActualize("1");
 			  				dto.setState("2");
-			  				
 			  			}
 			  			else if("未实施".equals(dto.getState())) {
 			  				dto.setActualize("0");
@@ -476,16 +475,24 @@ public class TshareApplyController extends BaseAction{
 			  				dto.setIsrevoke("0");
 				  			dto.setState("2");
 				  		}
+						else if("过期待停用".equals(dto.getState())) {
+							dto.setActualize("2");
+							dto.setState("2");
+						}
+						else if("过期已停用".equals(dto.getState())) {
+							dto.setActualize("3");
+							dto.setState("2");
+						}
 			  			else {
 			  				dto.setTaskname(dto.getState());
-			  				dto.setState("");
+			  				dto.setState("2");
 			  			}
 			  			
 			  		}
 			  		
 			  	}
 			  	else {
-			  		dto.setActualize("-1");
+			  		dto.setActualize(null);
 	  				dto.setState("2");
 			  	}
 			  	dto.setTinfoClass(tinfoClass);
@@ -701,6 +708,17 @@ public class TshareApplyController extends BaseAction{
     	    map.put("remark", "success");
     	   return map;
 	}
+
+	@RequestMapping(value="/endShareApply")
+	public @ResponseBody Map endShareApply(String busId, HttpServletRequest request, HttpServletResponse response) {
+		//获取session
+		HttpSession session = request.getSession();
+		User userInfo =  (User) session.getAttribute("user");
+		tshareApplyService.disableShareApply(request, userInfo, busId);
+		Map<String, Object> map = new HashMap<>();
+		map.put("remark", "success");
+		return map;
+	}
 	
 	 @RequestMapping("/revokeinfo")
 	    @ResponseBody

+ 47 - 2
cn.com.taiji.system/src/main/resources/static/theme/tshareapply/tshareapply_balist.js

@@ -61,8 +61,13 @@
         		}
         		else if(res.actualize=='1'){
         			return '审核通过(已实施)'+know;
-        			
         		}
+				else if(res.actualize=='2'){
+					return '审核通过(过期待停用)'+know;
+				}
+				else if(res.actualize=='3'){
+					return '审核通过(过期已停用)'+know;
+				}
         		else{
         			return '审核通过(待派发)'+know;
         		}
@@ -156,9 +161,12 @@
         case 'outputData'://导出
         	opendgviewoutputData(checkStatus.data);
         	break;
-        case 'distributeTask'://导出
+        case 'distributeTask':
         	distributeTask(checkStatus.data);
         	break;
+	  	case 'endShareApply':
+			endShareApply(checkStatus.data);
+			  break;
         case 'table_export':
 			exportFile(obj.config.id);
 			break;
@@ -221,6 +229,43 @@
 			sheet1: bodysArr
 		}, (new Date()).valueOf() + '.xlsx', 'xlsx');
 	}
+	  function endShareApply(data){
+		  var chk_value="";
+		  for(var i=0; i<data.length; i++){
+			  if(data[i].actualize == '2')
+				  chk_value=chk_value+data[i].id+";"
+		  }
+		  if(chk_value!=""){
+			  chk_value=chk_value.substr(0,chk_value.length-1);
+			  if(confirm("确定要设置为过期已停用状态?")){
+				  var data1={"busId":chk_value};
+				  $.ajax({
+					  async:false,
+					  type:"post",
+					  url:"/tshareApply/endShareApply",
+					  contentType: "application/x-www-form-urlencoded;charset=utf-8",
+					  dataType: 'json',
+					  data:data1,
+					  success:function(result){
+						  if(result.remark == "success"){
+							  layer.msg('提交成功', {icon: 6});
+							  window.location.reload();
+						  }
+						  else {
+							  layer.msg('提交失败', {icon: 6});
+						  }
+					  },
+					  error:function(){
+						  layer.msg('服务器异常', {icon: 6});
+					  }
+				  });
+			  }
+		  }
+		  else{
+			  layer.msg('请选择需要设置为过期已停用的共享清单', {icon: 6});
+		  }
+
+	  }
     function distributeTask(data){
     	var chk_value="";
     	for(var i=0; i<data.length; i++){

+ 11 - 7
cn.com.taiji.system/src/main/resources/templates/thymeleaf/tshareapply/tshareapply_balist.html

@@ -99,13 +99,13 @@
             <label class="layui-form-label">数据状态</label>
             <div class="layui-input-inline">
               <select name="state" id="state">
-                
+				  <option value="">全部</option>
            		<option value="待派单">待派单</option>
                 <option value="已实施">已实施</option>
                 <option value="未实施">未实施</option>
+				  <option value="过期待停用">过期待停用</option>
+				  <option value="过期已停用">过期已停用</option>
                 <option value="isrevoke">已撤销</option>
-                 
-               
               </select>
             </div>
           </div>
@@ -123,15 +123,14 @@
            <script type="text/html" id="Layui-table-toolbar-toolbarDemo">
             
 <div class="layui-row">
-        <div class="layui-col-md2 layui-col-sm3 layui-col-xs6" style="text-align: left;padding-left: 10px;">
+        <div class="layui-col-md6 layui-col-sm3 layui-col-xs6" style="text-align: left;padding-left: 10px;">
             <div class="layui-input-inline yutons-btn-margin-right">
                <button  class="layui-btn layui-btn-sm" lay-event="outputData"><i class="layui-icon iconfont icon-yunduanxiazai"></i>导出Word</button>
 				<button th:if="${zgbmgl==true}"  class="layui-btn layui-btn-sm" lay-event="distributeTask"><i class="layui-icon iconfont icon-yunduanxiazai"></i>派发任务</button>
-              
+				<button th:if="${zgbmgl==true}"  class="layui-btn layui-btn-sm" lay-event="endShareApply"><i class="layui-icon iconfont icon-yunduanxiazai"></i>停止共享</button>
             </div>
         </div>
-        <div class="layui-col-md10 layui-col-sm9 layui-col-xs6" style="text-align: right;">
-         
+        <div class="layui-col-md6 layui-col-sm9 layui-col-xs6" style="text-align: right;">
             <div class="layui-input-inline yutons-btn-margin-right" style="margin-right: 0px;">
 				<span class="layui-inline yutons-header-tool" title="筛选列" lay-event="LAYTABLE_COLS">
 							<i class="layui-icon layui-icon-cols"></i></span>
@@ -155,6 +154,11 @@
       </div>
     </div>
   </div>
+  <style type="text/css">
+	  layui-table-tool .layui-table-tool-temp {
+		  padding-right: 0px;
+	  }
+  </style>
 <script th:inline="javascript" type="text/javascript">
 /*<![CDATA[*/  
 //don't move this