Jelajahi Sumber

Merge remote-tracking branch 'origin/matser' into matser

ZhuJiaHao 8 bulan lalu
induk
melakukan
db04cc2dd2

+ 4 - 2
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/sqlzdy/Service/SwdlServiceImpl.java

@@ -804,7 +804,8 @@ public class SwdlServiceImpl extends GenericProvider implements SwdlService {
                     if (shiftDuration != null && !shiftDuration.isEmpty()) {
                         try {
                             //double duration = Double.parseDouble(shiftDuration)/60;
-                            double duration = Math.round(Double.parseDouble(shiftDuration)/60);
+                            //double duration = Math.round(Double.parseDouble(shiftDuration)/60);
+                            double duration = Math.round(Double.parseDouble(shiftDuration) / 60.0 * 100.0) / 100.0;
                             addTo(userStats, "ban_ci_shi_chang", duration);
                         } catch (NumberFormatException e) {
                             // 忽略格式错误
@@ -815,7 +816,8 @@ public class SwdlServiceImpl extends GenericProvider implements SwdlService {
                     if (workDuration != null && !workDuration.isEmpty()) {
                         try {
                            // double duration = Double.parseDouble(workDuration)/60;
-                            double duration = Math.round(Double.parseDouble(shiftDuration)/60);
+                            //double duration = Math.round(Double.parseDouble(workDuration)/60);
+                            double duration = Math.round(Double.parseDouble(workDuration) / 60.0 * 100.0) / 100.0;
                             addTo(userStats, "gong_zuo_shi_chang", duration);
                         } catch (NumberFormatException e) {
                             // 忽略格式错误

+ 38 - 10
ibps-provider-root/modules/provider-platform/src/main/java/com/lc/ibps/platform/plan/job/EquipmentMaintenancePlanJob.java

@@ -186,7 +186,7 @@ public class EquipmentMaintenancePlanJob  extends AbstractJob {
         List<Map<String, Object>> list = (List<Map<String, Object>>) commonDao.query(sql);
         if (BeanUtils.isNotEmpty(list)){
             for (Map<String, Object> map : list) {
-                String sql2 = " select id_,she_bei_ming_cheng_,yuan_she_bei_bian,guan_li_ren_,he_cha_xiao_zhun_,chu_chang_ri_qi_ from t_sbdj  " +
+                String sql2 = " select id_,she_bei_ming_cheng_,yuan_she_bei_bian,guan_li_ren_,he_cha_xiao_zhun_,chu_chang_ri_qi_,bian_zhi_bu_men_ from t_sbdj  " +
                         " where guan_li_ren_='"+map.get("guan_li_ren_")+"' and he_cha_xiao_zhun_!='' and he_cha_xiao_zhun_ is not null and chu_chang_ri_qi_!='' and chu_chang_ri_qi_ is not null ";
                 List<Map<String, Object>> equipList = (List<Map<String, Object>>) commonDao.query(sql2);
                 if (BeanUtils.isNotEmpty(equipList)){
@@ -221,18 +221,20 @@ public class EquipmentMaintenancePlanJob  extends AbstractJob {
             LocalDate currDate = LocalDate.now();
 
             String guanLiRen = StringUtil.defaultString(eqMap.get("guan_li_ren_").toString(),"");
-            changeMessagePushUser(guanLiRen,pushuser);
-            if(pushuser.isEmpty()){
-                //当保管人所在的所有组都没有专业组组长的时候推送给保管者
-                pushuser.add(guanLiRen);
-                //过滤掉重复数据
-                pushuser.stream()
-                        .distinct()
-                        .collect(Collectors.toList());
-            }
+            String bianZhiBuMeng = StringUtil.defaultString(eqMap.get("bian_zhi_bu_men_").toString(),"");
+            //changeMessagePushUser(guanLiRen,pushuser);
 
             // 比较 出厂日期 加上N年后是否小于等于 当前日期
             if (futureDate.isBefore(currDate) || futureDate.isEqual(currDate)) {
+                changeMessagePushUser2(bianZhiBuMeng,pushuser);
+                if(pushuser.isEmpty()){
+                    //当保管人所在的所有组都没有专业组组长的时候推送给保管者
+                    pushuser.add(guanLiRen);
+                    //过滤掉重复数据
+                    pushuser.stream()
+                            .distinct()
+                            .collect(Collectors.toList());
+                }
                 for(String zhanghao : pushuser){
                     Map<String, Object> rili = commonDao.queryOne("select id_ from ibps_party_user_calendar where type_='EQUIP_OVERDUE' and data_info_='t_sbdj' and data_source_id_='"+sourceId+"' and user_id_ = '"+zhanghao+"' limit 1");
                     // 已经 添加过的日程不再提醒
@@ -261,6 +263,32 @@ public class EquipmentMaintenancePlanJob  extends AbstractJob {
         }
     }
 
+    private void changeMessagePushUser2(String bianZhiBuMeng, ArrayList<String> pushuser) {
+            String groupSql = "select id_,name_,depth_ from ibps_party_entity where id_ = '"+bianZhiBuMeng+"'";//DEPTH_为4以上的是组
+            List<Map<String, Object>> entity = (List<Map<String, Object>>) commonDao.query(groupSql);
+            if(BeanUtils.isEmpty(entity) || entity.size()<1){
+                logger.warn("设备编制建档部门:"+bianZhiBuMeng+"查询不到信息......");
+                return;
+            }
+            for(Map groupInfo :entity){//应该只有一条记录
+                String roleIdSql = "select id_ from ibps_party_entity where PARTY_ALIAS_='zhsfzr' limit 1";//专业组组长角色
+                List<Map<String, Object>> role = (List<Map<String, Object>>) commonDao.query(roleIdSql);
+                String roleId = role.get(0).get("id_").toString().trim();
+                String group = (String) groupInfo.get("id_");
+                //获取和设备保管人一个组并且是专业组组长的用户
+                String teamLeaderSql = "SELECT id_,name_,status_,positions_,job_ FROM IBPS_PARTY_EMPLOYEE WHERE STATUS_='actived' and POSITIONS_ LIKE '%"+group.trim()+"%' AND JOB_ LIKE '%"+roleId+"%';";
+                List<Map<String, Object>> userList = (List<Map<String, Object>>) commonDao.query(teamLeaderSql);
+                if(BeanUtils.isEmpty(userList) || userList.size()<1){
+                    logger.warn("设备编制建档部门:"+bianZhiBuMeng+"不存在专业组组长");
+                    continue;
+                }
+                for(Map user :userList){
+                    pushuser.add(user.get("id_").toString());
+                }
+            }
+
+    }
+
     private void changeMessagePushUser(String guanLiRen,List<String> pushuser) {
         String sql = "select id_,positions_ from IBPS_PARTY_EMPLOYEE WHERE ID_='"+guanLiRen+"' limit 1";
         List<Map<String, Object>> positions = (List<Map<String, Object>>) commonDao.query(sql);

+ 94 - 0
ibps-provider-root/modules/provider-platform/src/main/java/com/lc/ibps/platform/plan/job/ThirdPartyWorkflowJob.java

@@ -0,0 +1,94 @@
+package com.lc.ibps.platform.plan.job;
+
+import com.lc.ibps.base.core.util.AppUtil;
+import com.lc.ibps.base.core.util.BeanUtils;
+import com.lc.ibps.base.core.util.JacksonUtil;
+import com.lc.ibps.base.saas.token.ITenantTokenService;
+import com.lc.ibps.base.web.context.ContextUtil;
+import com.lc.ibps.bpmn.api.IBpmInstService;
+import com.lc.ibps.cloud.entity.APIResult;
+import org.apache.commons.lang3.StringUtils;
+import org.quartz.JobDataMap;
+import org.quartz.JobExecutionContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.Map;
+
+public class ThirdPartyWorkflowJob extends AbstractJob{
+
+    public static final String TABLE_NAME = "TABLE_NAME";
+    public static final String FORM_KEY = "FORM_KEY";
+    public static final String DEF_KEY = "DEF_KEY";
+    public static final String NODE_NUM = "NODE_NUM";
+
+    private static final Logger logger = LoggerFactory.getLogger(QualityIndicatorJob.class);
+    @Override
+    public void executeJob(JobExecutionContext context) throws Exception {
+        JobDataMap dataMap = context.getMergedJobDataMap();
+        logger.warn("group={} job={} trigger={} is running.",
+                context.getJobDetail().getKey().getGroup(),
+                context.getJobDetail().getKey().getName(),
+                context.getTrigger().getKey().getName());
+        logger.warn("jobDataMap=is {}.", JacksonUtil.toJsonString(dataMap.getWrappedMap()));
+        String[] tableNameAry  = dataMap.getString(TABLE_NAME).split(";");
+        String[] formKeyAry = dataMap.getString(FORM_KEY).split(";");
+        String[] defKeyAry = dataMap.getString(DEF_KEY).split(";");
+        String[] nodeNumAry = dataMap.getString(NODE_NUM).split(";");
+        splitAry(tableNameAry,formKeyAry, defKeyAry,nodeNumAry);
+
+    }
+
+    /**
+     * 获取第三方数据后存入表中,再根据定时任务启动流程
+     * 其中定时任务配置参数如果有多个按照";"分隔,每个参数一一对应,如
+     * TABLE_NAME:t_dlxmsnzkyfx;t_fjbbjlb
+     * FORM_KEY:dlxmsnzkyfxzjbg;fjbbjlb
+     * DEF_KEY:Process_1cauof8;Process_0mg6v16
+     *
+     * @param tableNameAry
+     * @param formKeyAry
+     * @param defKeyAry
+     */
+    private void splitAry(String[] tableNameAry, String[] formKeyAry, String[] defKeyAry, String[] nodeNumAry) {
+        for (int i = 0; i < tableNameAry.length; i++) {
+            String tableName = tableNameAry[i];
+            String formKey = formKeyAry[i];
+            String defKey = defKeyAry[i];
+            String nodeNum = nodeNumAry[i];
+            if(tableName != null && !tableName.isEmpty() &&
+                    formKey != null && !formKey.isEmpty() &&
+                    defKey != null && !defKey.isEmpty()&&
+                    nodeNum != null && !nodeNum.isEmpty()) {
+                logger.warn("Ready Start Workflow:tableName={},formKey={},defKey={},nodeNum={}", tableName, formKey, defKey, nodeNum);
+                startWorkflow(tableName,formKey,defKey, Integer.parseInt(nodeNum));
+            }
+        }
+
+    }
+
+    protected void startWorkflow(String tableName, String formKey, String defKey, Integer nodeNum) {
+        String fetchSql = "SELECT id_ FROM %s WHERE shi_fou_guo_shen_='待推送'";
+        fetchSql = String.format(fetchSql,tableName);
+        List<Map<String, Object>> list = (List<Map<String, Object>>) commonDao.query(fetchSql);
+        if (BeanUtils.isEmpty(list)) return;
+        IBpmInstService bpmInstService = AppUtil.getBean(IBpmInstService.class);
+        if (StringUtils.isBlank(ContextUtil.getCurrentAccessToken())) {
+            ITenantTokenService tenantTokenService = AppUtil.getBean(ITenantTokenService.class);
+            String accessToken = tenantTokenService.getAccessToken();
+            ContextUtil.setCurrentAccessToken(accessToken);
+        }
+        for (Map<String, Object> objectMap : list) {
+            APIResult<String> result = bpmInstService.startFlowFromList(new String[]{(String) objectMap.get("id_")}, formKey, defKey);
+            result.getState();
+            if (nodeNum >1) {
+                //流程节点大于1的要改变状态避免被下次定时任务查到
+                String updateSql = "update "+tableName+" set shi_fou_guo_shen_='待编制' where id_='"+objectMap.get("id_")+"'";
+                commonDao.execute(updateSql);
+            }
+        }
+
+    }
+
+}