diff --git a/src/main/java/com/zcloud/controller/specialoperation/PersonnelManagementController.java b/src/main/java/com/zcloud/controller/specialoperation/PersonnelManagementController.java index 3c835df..e719484 100644 --- a/src/main/java/com/zcloud/controller/specialoperation/PersonnelManagementController.java +++ b/src/main/java/com/zcloud/controller/specialoperation/PersonnelManagementController.java @@ -14,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; +import java.time.LocalDate; +import java.time.temporal.ChronoUnit; import java.util.*; /** @@ -332,4 +334,47 @@ public class PersonnelManagementController extends BaseController { return mv; } + /**临期预警 + * @throws Exception + */ + @RequestMapping(value="/warnAmount") + // @RequiresPermissions("personnelmanagement:list") + @ResponseBody + @LogAnno(menuType= "综合管理",menuServer= "特种作业",instructionsOperate = "特种作业人员管理",instructionsType = "临期预警") + public Object warnAmount() throws Exception{ + Map map = new HashMap(); + String errInfo = "success"; + StringBuffer stringBuffer = new StringBuffer(); + PageData pd = new PageData(); + pd = this.getPageData(); + String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件 + if(Tools.notEmpty(KEYWORDS))pd.put("KEYWORDS", KEYWORDS.trim()); + pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业ID + List varList = personnelmanagementService.listAll(pd); //列出PersonnelManagement列表 + int cnt = 1; + boolean firstflag = true; + for (int i = 0; i < varList.size(); i++) { + String validDateEnd = varList.get(i).getString("VALID_ETIME"); + LocalDate date1 = LocalDate.now(); // 第一个时间点 + LocalDate date2 = LocalDate.parse(validDateEnd); // 当前时间点 + long daysBetween = ChronoUnit.DAYS.between(date1, date2); // 计算两个时间之间相隔的天数 + // 临期界限45天 + if (daysBetween <= 45 && daysBetween > 0) { + if (firstflag) { + stringBuffer.append("

以下持证人员证件临近有效期,请及时处置!
"); + stringBuffer.append("****************************************

"); + firstflag = false; + } + stringBuffer.append("

").append(cnt).append(". ") + .append(varList.get(i).get("NAME")) + .append(",距到期还有" + daysBetween + "天") + .append("

"); + cnt++; + } + } + map.put("result", errInfo); + map.put("message", stringBuffer.toString()); + return map; + } + } diff --git a/src/main/resources/mybatis/datasource/specialoperation/PersonnelManagementMapper.xml b/src/main/resources/mybatis/datasource/specialoperation/PersonnelManagementMapper.xml index 32a6bb6..41ada3d 100644 --- a/src/main/resources/mybatis/datasource/specialoperation/PersonnelManagementMapper.xml +++ b/src/main/resources/mybatis/datasource/specialoperation/PersonnelManagementMapper.xml @@ -220,6 +220,9 @@ from f where f.ISDELETE ='0' + + and f.CORPINFO_ID = #{CORPINFO_ID} + and f.UNITS_ID = #{UNITS_ID}