FlowBussinessDescManageServiceImpl.java 7.7 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\r\n" + 
							"	equipment_repair a\r\n" + 
							"LEFT JOIN equipment_info b ON a.info_id = b.id\r\n" + 
							"WHERE\r\n" + 
							"	a.id in ("+inSqlPart+")";
					//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("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\r\n" +
							"	problem_report_plan a\r\n" +
							"WHERE\r\n" +
							"	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\r\n" +
							"	equipment_defect_management a\r\n" +
							"WHERE\r\n" +
							"	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\r\n" +
							"	emergency_risk_event a\r\n" +

							"WHERE\r\n" +
							"	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\r\n" +
							"	ajh_rectification_info a\r\n" +

							"WHERE\r\n" +
							"	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\r\n" +
                            "	alarm_record_history a\r\n" +
                            "WHERE\r\n" +
                            "	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\r\n" +
							"	productive_task a\r\n" +

							"WHERE\r\n" +
							"	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;
	}

}