diff --git a/src/main/java/com/zhgd/xmgl/task/SlippageTask.java b/src/main/java/com/zhgd/xmgl/task/SlippageTask.java index bcb96da..4da18a8 100644 --- a/src/main/java/com/zhgd/xmgl/task/SlippageTask.java +++ b/src/main/java/com/zhgd/xmgl/task/SlippageTask.java @@ -2,10 +2,14 @@ package com.zhgd.xmgl.task; import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.zhgd.xmgl.modules.basicdata.entity.Engineering; import com.zhgd.xmgl.modules.basicdata.entity.EngineeringMain; import com.zhgd.xmgl.modules.basicdata.entity.SystemUser; import com.zhgd.xmgl.modules.basicdata.service.IEngineeringMainService; +import com.zhgd.xmgl.modules.basicdata.service.IEngineeringService; import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService; import com.zhgd.xmgl.modules.safety.entity.InspectRecord; import com.zhgd.xmgl.modules.safety.entity.ProjectSubItem; @@ -13,6 +17,7 @@ import com.zhgd.xmgl.modules.safety.entity.Remind; import com.zhgd.xmgl.modules.safety.service.IInspectRecordService; import com.zhgd.xmgl.modules.safety.service.IProjectSubItemService; import com.zhgd.xmgl.modules.safety.service.IRemindService; +import com.zhgd.xmgl.util.SMS; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; @@ -42,13 +47,16 @@ public class SlippageTask { @Autowired private IEngineeringMainService engineeringMainService; + @Autowired + private IEngineeringService engineeringService; + @Autowired private ISystemUserService systemUserService; /** * 每天凌晨计算项目进度是否逾期、临期 */ - @Scheduled(cron = "0 0 0 * * ?") + @Scheduled(cron = "0 0 1 * * ?") private void projectSubItem() { List states = Arrays.asList(3, 6, 7); List change = new ArrayList<>(); @@ -73,8 +81,9 @@ public class SlippageTask { private void saveRemind(Integer type, String desc, String engineeringSn) { Remind remind = new Remind(); EngineeringMain jsUser = engineeringMainService.getOne(Wrappers.lambdaQuery() - .eq(EngineeringMain::getEnterpriseSn, engineeringSn).eq(EngineeringMain::getType, 1)); + .eq(EngineeringMain::getEngineeringSn, engineeringSn).eq(EngineeringMain::getType, 1)); if (jsUser != null) { + Engineering engineering = engineeringService.getOne(Wrappers.lambdaQuery().eq(Engineering::getEngineeringSn, jsUser.getEngineeringSn())); SystemUser manager = systemUserService.getOne(Wrappers.lambdaQuery().eq(SystemUser::getSn, jsUser.getEnterpriseSn()).eq(SystemUser::getIsManager, true)); remind.setType(type); remind.setRemindDesc(desc); @@ -82,6 +91,13 @@ public class SlippageTask { remind.setUserId(manager.getUserId()); remind.setUserPhone(manager.getUserTel()); remindService.save(remind); + if (StringUtils.isNotBlank(manager.getUserTel())) { + JSONObject params = new JSONObject(); + params.put("phone", manager.getUserTel()); + params.put("project", engineering.getEngineeringName()); + params.put("alarmInfo", desc); + SMS.sendToPhone(params); + } } } diff --git a/src/main/java/com/zhgd/xmgl/util/SMS.java b/src/main/java/com/zhgd/xmgl/util/SMS.java new file mode 100644 index 0000000..c2bbe50 --- /dev/null +++ b/src/main/java/com/zhgd/xmgl/util/SMS.java @@ -0,0 +1,167 @@ +package com.zhgd.xmgl.util; + +import com.alibaba.fastjson.JSONObject; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; + +/** + * 短信发送工具类 + */ +public class SMS { + + private static String session_value; + + private static String host = "47.106.214.54:8080"; + + public static void main(String[] args) { + //updateRoadCheckData("20221026"); + //AutoSync("2022-10-29"); + + //发送短信 + JSONObject params = new JSONObject(); + params.put("phone", "17373303529"); + params.put("project", "sms测试项目1"); + params.put("alarmInfo", "预警类型1"); + SMS.sendToPhone(params); + + //发送验证码 +// JSONObject params = new JSONObject(); +// params.put("phone", "17373303529"); +// params.put("code", "123321"); +// SMS.sendToPhone_YZM(params); + + } + + /** + * 发送短信信息 + * @param params + */ + public static void sendToPhone(JSONObject params) { + JSONObject jo = new JSONObject(); + jo.put("user", "smsUser"); + jo.put("passwd", "sjhA86JDFH$2356_sdfAj123"); + String ret = SMS.login("http://"+host+"/SmsServer/UI/login", jo.toJSONString()); + System.out.println(ret); + + + ret = SMS.post("http://"+host+"/SmsServer/api/sendSms", params); + System.out.println(ret); + } + + public static void sendToPhone_YZM(JSONObject params) { + JSONObject jo = new JSONObject(); + jo.put("user", "smsUser"); + jo.put("passwd", "sjhA86JDFH$2356_sdfAj123"); + String ret = SMS.login("http://"+host+"/SmsServer/UI/login", jo.toJSONString()); + System.out.println(ret); + + + ret = SMS.post("http://"+host+"/SmsServer/api/sendSms_YZM", params); + System.out.println(ret); + } + + private static String login(String urlPath, String sendStr) { + String result = ""; + String line = ""; + BufferedReader reader = null; + try { + URL url = new URL(urlPath); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + + conn.setRequestMethod("POST"); + conn.setDoOutput(true); + conn.setDoInput(true); + conn.setUseCaches(false); + conn.setRequestProperty("Connection", "Keep-Alive"); + conn.setRequestProperty("Charset", "UTF-8"); + conn.setRequestProperty("Content-Type", "text/plain;charset=UTF-8"); + conn.setRequestProperty("Accept", "*/*"); + if (sendStr != null && sendStr.trim().length() > 0) { + byte[] writebytes = sendStr.getBytes(); + conn.setRequestProperty("Content-Length", String.valueOf(writebytes.length)); + OutputStream outwritestream = conn.getOutputStream(); + outwritestream.write(sendStr.getBytes()); + outwritestream.flush(); + outwritestream.close(); + conn.getResponseCode(); + } + if (conn.getResponseCode() == 200) { + reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8")); + while ((line = reader.readLine()) != null) { + result += line; + } + } + + session_value=conn.getHeaderField("Set-Cookie"); + + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (reader != null) { + try { + reader.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return result; + } + + private static String post(String urlPath, JSONObject param) { + if(param==null) { + param=new JSONObject(); + } + String Json = param.toJSONString(); + String result = ""; + String line = ""; + BufferedReader reader = null; + try { + URL url = new URL(urlPath); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + + conn.setRequestMethod("POST"); + conn.setDoOutput(true); + conn.setDoInput(true); + conn.setUseCaches(false); + conn.setRequestProperty("Connection", "Keep-Alive"); + conn.setRequestProperty("Charset", "UTF-8"); + conn.setRequestProperty("Content-Type", "text/plain;charset=UTF-8"); + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("Cookie", session_value); + if (Json != null && Json.trim().length() > 0) { + byte[] writebytes = Json.getBytes(); + conn.setRequestProperty("Content-Length", String.valueOf(writebytes.length)); + OutputStream outwritestream = conn.getOutputStream(); + outwritestream.write(Json.getBytes()); + outwritestream.flush(); + outwritestream.close(); + conn.getResponseCode(); + } + if (conn.getResponseCode() == 200) { + + reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8")); + while ((line = reader.readLine()) != null) { + result += line; + } + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (reader != null) { + try { + reader.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return result; + } + +} diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 493a631..6acd831 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -3,13 +3,13 @@ http.port=6023 server.port=6688 # 数据库配置 #182.90.224.147 -spring.datasource.url=jdbc:mysql://localhost:3306/wisdomsitezw_hzxmgl?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&useSSL=false +spring.datasource.url=jdbc:mysql://139.9.66.234:3306/wisdomsitezw_hzxmgl?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&useSSL=false # 数据库加密配置 #spring.datasource.username=ENC(XR4C/hvTYCUqudS49Wh/jA==) #spring.datasource.password=ENC(hHkiHEc6vSWjqfOtg2/2Uiihs0vX3l7V) spring.datasource.username=root -#spring.datasource.password=JXJ@admin -spring.datasource.password=root +spring.datasource.password=JXJ@admin +#spring.datasource.password=root # 文件存储路径 basePath=D:/itbgpImage/ # 文件访问路径 diff --git a/src/main/resources/magic/api/惠州项目管理企业版/安全质量管理.ms b/src/main/resources/magic/api/惠州项目管理企业版/安全质量管理.ms index a866124..cec804d 100644 --- a/src/main/resources/magic/api/惠州项目管理企业版/安全质量管理.ms +++ b/src/main/resources/magic/api/惠州项目管理企业版/安全质量管理.ms @@ -5,7 +5,7 @@ "groupId" : "b76810fe6da84d138b6bc227dd26b198", "name" : "安全质量管理", "createTime" : null, - "updateTime" : 1689834677900, + "updateTime" : 1691140491912, "lock" : null, "createBy" : null, "updateBy" : "admin", @@ -22,8 +22,8 @@ "responseBodyDefinition" : null } ================================ -Map qualityMap = db.selectOne("SELECT COUNT(q.id) qualityTotal, IFNULL(SUM(IF(q.state = 3, 1, 0)), 0) qualityCompleted, IFNULL(SUM(IF(q.state != 3, 1, 0)), 0) qualityUnCompleted FROM inspect_record a LEFT JOIN inspect_question q ON a.id = q.record_id WHERE a.type = 2 AND a.engineering_sn = #{body.engineeringSn}") +Map qualityMap = db.selectOne("SELECT COUNT(q.id) qualityTotal, IFNULL(SUM(IF(q.state = 3 AND q.level = 2, 1, 0)), 0) qualityCompleted, IFNULL(SUM(IF(q.state != 3 or q.level != 2, 1, 0)), 0) qualityUnCompleted FROM inspect_record a LEFT JOIN inspect_question q ON a.id = q.record_id WHERE a.type = 2 AND a.engineering_sn = #{body.engineeringSn}") -Map safetyMap = db.selectOne("SELECT COUNT(q.id) safetyTotal, IFNULL(SUM(IF(q.state = 3, 1, 0)), 0) safetyCompleted, IFNULL(SUM(IF(q.state != 3, 1, 0)), 0) safetyUnCompleted FROM inspect_record a LEFT JOIN inspect_question q ON a.id = q.record_id WHERE a.type = 1 AND a.engineering_sn = #{body.engineeringSn}") +Map safetyMap = db.selectOne("SELECT COUNT(q.id) safetyTotal, IFNULL(SUM(IF(q.state = 3 AND q.level = 2, 1, 0)), 0) safetyCompleted, IFNULL(SUM(IF(q.state != 3 or q.level != 2, 1, 0)), 0) safetyUnCompleted FROM inspect_record a LEFT JOIN inspect_question q ON a.id = q.record_id WHERE a.type = 1 AND a.engineering_sn = #{body.engineeringSn}") qualityMap.putAll(safetyMap) return qualityMap \ No newline at end of file diff --git a/src/main/resources/magic/api/惠州项目管理企业版/项目信息.ms b/src/main/resources/magic/api/惠州项目管理企业版/项目信息.ms index 17de392..c8c26ca 100644 --- a/src/main/resources/magic/api/惠州项目管理企业版/项目信息.ms +++ b/src/main/resources/magic/api/惠州项目管理企业版/项目信息.ms @@ -5,7 +5,7 @@ "groupId" : "b76810fe6da84d138b6bc227dd26b198", "name" : "项目信息", "createTime" : null, - "updateTime" : 1689838729932, + "updateTime" : 1690966720669, "lock" : null, "createBy" : null, "updateBy" : "admin", diff --git a/src/main/resources/magic/api/惠州项目管理政务版/进度管理.ms b/src/main/resources/magic/api/惠州项目管理政务版/进度管理.ms index 292913e..7646303 100644 --- a/src/main/resources/magic/api/惠州项目管理政务版/进度管理.ms +++ b/src/main/resources/magic/api/惠州项目管理政务版/进度管理.ms @@ -5,7 +5,7 @@ "groupId" : "1f3d3e5b9fe340bab84de67b0de08f44", "name" : "进度管理", "createTime" : null, - "updateTime" : 1690368857741, + "updateTime" : 1691140680204, "lock" : null, "createBy" : null, "updateBy" : "admin", @@ -31,7 +31,7 @@ BigDecimal totalNum = new BigDecimal(total); scheduleMap.put("scheduleRatio", completedNum == 0 ? 0 : completedNum.divide(totalNum, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).doubleValue()) -Map qualityMap = db.selectOne("SELECT COUNT( * ) qualityTotal, IFNULL(SUM(IF(question_num = 0, 1, 0)), 0) qualityQuestion, IFNULL(SUM(IF(state = 4 AND question_num != 0, 1, 0)), 0) qualityCompleted, IFNULL(SUM(IF(state != 4, 1, 0)), 0) qualityUnCompleted FROM inspect_record WHERE type = 2 AND #project ") +Map qualityMap = db.selectOne("SELECT COUNT( * ) qualityTotal, IFNULL(SUM(IF(question_num = 0, 1, 0)), 0) qualityQuestion, IFNULL(SUM(IF(state = 4 AND level = 2 AND question_num != 0, 1, 0)), 0) qualityCompleted, IFNULL(SUM(IF(question_num != 0 AND (state != 4 or level != 2), 1, 0)), 0) qualityUnCompleted FROM inspect_record WHERE type = 2 AND #project ") var completed1 = qualityMap.get("qualityCompleted")::int var total1 = qualityMap.get("qualityTotal")::int BigDecimal completedNum1 = new BigDecimal(completed1); @@ -39,7 +39,7 @@ BigDecimal totalNum1 = new BigDecimal(total1); qualityMap.put("qualityRatio", completedNum1 == 0 ? 0 : completedNum1.divide(totalNum1, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).doubleValue()) scheduleMap.putAll(qualityMap) -Map safetyMap = db.selectOne("SELECT COUNT( * ) safetyTotal, IFNULL(SUM(IF(question_num = 0, 1, 0)), 0) safetyQuestion, IFNULL(SUM(IF(state = 4 AND question_num != 0, 1, 0)), 0) safetyCompleted, IFNULL(SUM(IF(state != 4, 1, 0)), 0) safetyUnCompleted FROM inspect_record WHERE type = 1 AND #project ") +Map safetyMap = db.selectOne("SELECT COUNT( * ) safetyTotal, IFNULL(SUM(IF(question_num = 0, 1, 0)), 0) safetyQuestion, IFNULL(SUM(IF(state = 4 AND level = 2 AND question_num != 0, 1, 0)), 0) safetyCompleted, IFNULL(SUM(IF(question_num != 0 AND (state != 4 OR level != 2), 1, 0)), 0) safetyUnCompleted FROM inspect_record WHERE type = 1 AND #project ") var completed2 = safetyMap.get("safetyCompleted")::int var total2 = safetyMap.get("safetyTotal")::int BigDecimal completedNum2 = new BigDecimal(completed2);