FlowBussinessDescManageServiceImpl.java 9.0 KB
package com.skua.modules.flow;

import com.skua.core.context.SpringContextUtils;
import com.skua.core.util.ConvertUtils;
import com.skua.modules.flow.custombiz.handle.IFlowBusinessDescService;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import java.util.*;
import java.util.stream.Collectors;

/**
 * 镜检照片管理
 */
@Service("flowBusinessDescService")
public class FlowBussinessDescManageServiceImpl implements IFlowBusinessDescService {
	@Override
	public Map<String, String> getFlowBusinessDesc(List<Map<String, String>> businessList) {
		JdbcTemplate masterDB = (JdbcTemplate)SpringContextUtils.getBean("master");
		Map<String,String> resultMap = new HashMap<String,String>();
		if(businessList!=null&&businessList.size()>0) {
			Map<String,String> tableMap = new HashMap<String,String>();
			for(Map<String, String> map : businessList) {
				String tablename = map.get("businessTable");
				String id = map.get("businessId");
				tableMap.put(tablename, ConvertUtils.getString(tableMap.get(tablename),"")+","+id);
			}
			Set<String> tableSet = tableMap.keySet();
			for(String tableName : tableSet) {
				if(tableName.equals("check_microscopic_manage")) {
					//镜检业务流程
					String ids = tableMap.get(tableName).substring(1);
					List<String> avgIndexCodeArray = Arrays.asList(ids.split(","));
					String inSqlPart = avgIndexCodeArray.stream().map(s -> "'"+s.trim()+"'").collect(Collectors.joining(","));
					String sql = "select id,create_by,'-镜检申请' as title from check_microscopic_manage where id in("+inSqlPart+")";
					List<Map<String, Object>> dataList = masterDB.queryForList(sql);
					for(Map<String, Object> dataMap : dataList) {
						resultMap.put(ConvertUtils.getString(dataMap.get("id")), ConvertUtils.getString(dataMap.get("create_by"))+""+ConvertUtils.getString(dataMap.get("title")));
					}
				}else if(tableName.equals("equipment_repair")) {
					//设备维修流程
					String ids = tableMap.get(tableName).substring(1);
					List<String> avgIndexCodeArray = Arrays.asList(ids.split(","));
					String inSqlPart = avgIndexCodeArray.stream().map(s -> "'"+s.trim()+"'").collect(Collectors.joining(","));
					String sql = "SELECT a.id," +
							"	CONCAT(b.equipment_name,'-维修申请') as title " +
							"FROM " +
							"	equipment_repair a " +
							"LEFT JOIN equipment_info b ON a.info_id = b.id " +
							"WHERE " +
							"	a.id in ("+inSqlPart+")";
					List<Map<String, Object>> dataList = masterDB.queryForList(sql);
					for(Map<String, Object> dataMap : dataList) {
						resultMap.put(ConvertUtils.getString(dataMap.get("id")), ConvertUtils.getString(dataMap.get("title")));
					}
				}else if ("problem_report_plan".equals(tableName)) {
					// 报警
					String ids = tableMap.get(tableName).substring(1);
					List<String> avgIndexCodeArray = Arrays.asList(ids.split(","));
					String inSqlPart = avgIndexCodeArray.stream().map(s -> "'" + s.trim() + "'").collect(Collectors.joining(","));
					String sql = "SELECT a.id," +
							"	CONCAT(problem_name,'-问题上报') as title " +
							"FROM " +
							"	problem_report_plan a " +
							"WHERE " +
							"	a.id in (" + inSqlPart + ")";
					List<Map<String, Object>> dataList = masterDB.queryForList(sql);
					for (Map<String, Object> dataMap : dataList) {
						resultMap.put(ConvertUtils.getString(dataMap.get("id")), ConvertUtils.getString(dataMap.get("title")));
					}
				}else if ("equipment_defect_management".equals(tableName)) {
					// 缺陷上报
					String ids = tableMap.get(tableName).substring(1);
					List<String> avgIndexCodeArray = Arrays.asList(ids.split(","));
					String inSqlPart = avgIndexCodeArray.stream().map(s -> "'" + s.trim() + "'").collect(Collectors.joining(","));
					String sql = "SELECT a.id," +
							"	CONCAT(equipment_name,'-缺陷上报') as title " +
							"FROM " +
							"	equipment_defect_management a " +
							"WHERE " +
							"	a.id in (" + inSqlPart + ")";
					List<Map<String, Object>> dataList = masterDB.queryForList(sql);
					for (Map<String, Object> dataMap : dataList) {
						resultMap.put(ConvertUtils.getString(dataMap.get("id")), ConvertUtils.getString(dataMap.get("title")));
					}
				} else if (tableName.equals("emergency_risk_event")) {
					//应急风险事件
					String ids = tableMap.get(tableName).substring(1);
					List<String> avgIndexCodeArray = Arrays.asList(ids.split(","));
					String inSqlPart = avgIndexCodeArray.stream().map(s -> "'" + s.trim() + "'").collect(Collectors.joining(","));
					String sql = "SELECT a.id," +
							"	CONCAT(a.risk_name,'-应急风险事件') as title " +
							"FROM " +
							"	emergency_risk_event a " +
							"WHERE " +
							"	a.id in (" + inSqlPart + ")";
					List<Map<String, Object>> dataList = masterDB.queryForList(sql);
					for (Map<String, Object> dataMap : dataList) {
						resultMap.put(ConvertUtils.getString(dataMap.get("id")), ConvertUtils.getString(dataMap.get("title")));
					}
				}
				else if (tableName.equals("ajh_rectification_info")) {
					//安全隐患
					String ids = tableMap.get(tableName).substring(1);
					List<String> avgIndexCodeArray = Arrays.asList(ids.split(","));
					String inSqlPart = avgIndexCodeArray.stream().map(s -> "'" + s.trim() + "'").collect(Collectors.joining(","));
					String sql = "SELECT a.id," +
							"	CONCAT((select struct_name from sys_struct_dict where id = a.rec_ord_body),'-安全隐患流程') as title " +
							"FROM " +
							"	ajh_rectification_info a " +
							"WHERE " +
							"	a.id in (" + inSqlPart + ")";
					List<Map<String, Object>> dataList = masterDB.queryForList(sql);
					for (Map<String, Object> dataMap : dataList) {
						resultMap.put(ConvertUtils.getString(dataMap.get("id")), ConvertUtils.getString(dataMap.get("title")));
					}
				}else if ("alarm_record_history".equals(tableName)) {
                    // 报警
                    String ids = tableMap.get(tableName).substring(1);
                    List<String> avgIndexCodeArray = Arrays.asList(ids.split(","));
                    String inSqlPart = avgIndexCodeArray.stream().map(s -> "'" + s.trim() + "'").collect(Collectors.joining(","));
                    String sql = "SELECT a.id," +
                            "	CONCAT(alarm_param_name,'-报警申请') as title " +
                            "FROM " +
                            "	alarm_record_history a " +
                            "WHERE " +
                            "	a.id in (" + inSqlPart + ")";
                    List<Map<String, Object>> dataList = masterDB.queryForList(sql);
                    for (Map<String, Object> dataMap : dataList) {
                        resultMap.put(ConvertUtils.getString(dataMap.get("id")), ConvertUtils.getString(dataMap.get("title")));
                    }
                }else if (tableName.equals("productive_task")) {
					//生产任务
					String ids = tableMap.get(tableName).substring(1);
					List<String> avgIndexCodeArray = Arrays.asList(ids.split(","));
					String inSqlPart = avgIndexCodeArray.stream().map(s -> "'" + s.trim() + "'").collect(Collectors.joining(","));
					String sql = "SELECT a.id," +
							"	CONCAT(a.task_name,'-生产任务流程') as title " +
							"FROM " +
							"	productive_task a " +
							"WHERE " +
							"	a.id in (" + inSqlPart + ")";
					List<Map<String, Object>> dataList = masterDB.queryForList(sql);
					for (Map<String, Object> dataMap : dataList) {
						resultMap.put(ConvertUtils.getString(dataMap.get("id")), ConvertUtils.getString(dataMap.get("title")));
					}
				}else if (tableName.equals("data_assessment_socre_master")) {
					//生产任务
					String ids = tableMap.get(tableName).substring(1);
					List<String> avgIndexCodeArray = Arrays.asList(ids.split(","));
					String inSqlPart = avgIndexCodeArray.stream().map(s -> "'" + s.trim() + "'").collect(Collectors.joining(","));
					String sql = "SELECT a.id," +
							"	CONCAT(a.create_by,'-考核评价审批') as title " +
							"FROM " +
							"	data_assessment_socre_master a " +
							"WHERE " +
							"	a.id in (" + inSqlPart + ")";
					List<Map<String, Object>> dataList = masterDB.queryForList(sql);
					for (Map<String, Object> dataMap : dataList) {
						resultMap.put(ConvertUtils.getString(dataMap.get("id")), ConvertUtils.getString(dataMap.get("title")));
					}
				}else if (tableName.equals("dangerous_operation_manage")) {
					//危险作业
					String ids = tableMap.get(tableName).substring(1);
					List<String> avgIndexCodeArray = Arrays.asList(ids.split(","));
					String inSqlPart = avgIndexCodeArray.stream().map(s -> "'" + s.trim() + "'").collect(Collectors.joining(","));
					String sql = "SELECT a.id," +
							"	CONCAT(a.operation_name,'-危险作业审批') as title " +
							"FROM " +
							"	dangerous_operation_manage a " +
							"WHERE " +
							"	a.id in (" + inSqlPart + ")";
					List<Map<String, Object>> dataList = masterDB.queryForList(sql);
					for (Map<String, Object> dataMap : dataList) {
						resultMap.put(ConvertUtils.getString(dataMap.get("id")), ConvertUtils.getString(dataMap.get("title")));
					}
				}
			}
		}
		return resultMap;
	}

}