first commit
This commit is contained in:
11
src/main/java/com/sipai/activiti/Test.java
Normal file
11
src/main/java/com/sipai/activiti/Test.java
Normal file
@ -0,0 +1,11 @@
|
||||
package com.sipai.activiti;
|
||||
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
int a = 3;
|
||||
int b = 3;
|
||||
System.out.println(a % b);
|
||||
}
|
||||
}
|
||||
39
src/main/java/com/sipai/activiti/cmd/JumpActivityCmd.java
Normal file
39
src/main/java/com/sipai/activiti/cmd/JumpActivityCmd.java
Normal file
@ -0,0 +1,39 @@
|
||||
package com.sipai.activiti.cmd;
|
||||
|
||||
/**
|
||||
* @author: Henry Yan
|
||||
*/
|
||||
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.interceptor.CommandContext;
|
||||
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
|
||||
import org.activiti.engine.impl.pvm.process.ActivityImpl;
|
||||
import org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl;
|
||||
|
||||
public class JumpActivityCmd implements Command<Object> {
|
||||
private String activityId;
|
||||
private String processInstanceId;
|
||||
private String jumpOrigin;
|
||||
|
||||
public JumpActivityCmd(String processInstanceId, String activityId) {
|
||||
this(processInstanceId, activityId, "jump");
|
||||
}
|
||||
|
||||
public JumpActivityCmd(String processInstanceId, String activityId, String jumpOrigin) {
|
||||
this.activityId = activityId;
|
||||
this.processInstanceId = processInstanceId;
|
||||
this.jumpOrigin = jumpOrigin;
|
||||
}
|
||||
|
||||
public Object execute(CommandContext commandContext) {
|
||||
|
||||
ExecutionEntity executionEntity = commandContext.getExecutionEntityManager().findExecutionById(processInstanceId);
|
||||
|
||||
executionEntity.destroyScope(jumpOrigin);
|
||||
|
||||
ProcessDefinitionImpl processDefinition = executionEntity.getProcessDefinition();
|
||||
ActivityImpl activity = processDefinition.findActivity(activityId);
|
||||
executionEntity.executeActivity(activity);
|
||||
return executionEntity;
|
||||
}
|
||||
}
|
||||
32
src/main/java/com/sipai/activiti/form/UsersFormType.java
Normal file
32
src/main/java/com/sipai/activiti/form/UsersFormType.java
Normal file
@ -0,0 +1,32 @@
|
||||
package com.sipai.activiti.form;
|
||||
|
||||
import org.activiti.engine.form.AbstractFormType;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 用户表单字段类型
|
||||
*
|
||||
* @author henryyan
|
||||
*/
|
||||
public class UsersFormType extends AbstractFormType {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "users";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object convertFormValueToModelValue(String propertyValue) {
|
||||
String[] split = StringUtils.split(propertyValue, ",");
|
||||
return Arrays.asList(split);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertModelValueToFormValue(Object modelValue) {
|
||||
return ObjectUtils.toString(modelValue);
|
||||
}
|
||||
|
||||
}
|
||||
95
src/main/java/com/sipai/activiti/util/DateConverter.java
Normal file
95
src/main/java/com/sipai/activiti/util/DateConverter.java
Normal file
@ -0,0 +1,95 @@
|
||||
package com.sipai.activiti.util;
|
||||
|
||||
import org.apache.commons.beanutils.Converter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class DateConverter implements Converter {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(DateConverter.class);
|
||||
|
||||
private static final String DATETIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
private static final String DATETIME_PATTERN_NO_SECOND = "yyyy-MM-dd HH:mm";
|
||||
|
||||
private static final String DATE_PATTERN = "yyyy-MM-dd";
|
||||
|
||||
private static final String MONTH_PATTERN = "yyyy-MM";
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Object convert(Class type, Object value) {
|
||||
Object result = null;
|
||||
if (type == Date.class) {
|
||||
try {
|
||||
result = doConvertToDate(value);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (type == String.class) {
|
||||
result = doConvertToString(value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert String to Date
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
* @throws ParseException
|
||||
*/
|
||||
private Date doConvertToDate(Object value) throws ParseException {
|
||||
Date result = null;
|
||||
|
||||
if (value instanceof String) {
|
||||
result = DateUtils.parseDate((String) value, new String[]{DATE_PATTERN, DATETIME_PATTERN,
|
||||
DATETIME_PATTERN_NO_SECOND, MONTH_PATTERN});
|
||||
|
||||
// all patterns failed, try a milliseconds constructor
|
||||
if (result == null && StringUtils.isNotEmpty((String) value)) {
|
||||
|
||||
try {
|
||||
result = new Date(new Long((String) value).longValue());
|
||||
} catch (Exception e) {
|
||||
logger.error("Converting from milliseconds to Date fails!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if (value instanceof Object[]) {
|
||||
// let's try to convert the first element only
|
||||
Object[] array = (Object[]) value;
|
||||
|
||||
if (array.length >= 1) {
|
||||
value = array[0];
|
||||
result = doConvertToDate(value);
|
||||
}
|
||||
|
||||
} else if (Date.class.isAssignableFrom(value.getClass())) {
|
||||
result = (Date) value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert Date to String
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
private String doConvertToString(Object value) {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATETIME_PATTERN);
|
||||
String result = null;
|
||||
if (value instanceof Date) {
|
||||
result = simpleDateFormat.format(value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
93
src/main/java/com/sipai/activiti/util/LinkedProperties.java
Normal file
93
src/main/java/com/sipai/activiti/util/LinkedProperties.java
Normal file
@ -0,0 +1,93 @@
|
||||
package com.sipai.activiti.util;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 有序Properties
|
||||
*/
|
||||
public class LinkedProperties extends Properties {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Map<Object, Object> linkMap = new LinkedHashMap<Object, Object>();
|
||||
|
||||
public void clear() {
|
||||
linkMap.clear();
|
||||
}
|
||||
|
||||
public boolean contains(Object value) {
|
||||
return linkMap.containsValue(value);
|
||||
}
|
||||
|
||||
public boolean containsKey(Object key) {
|
||||
return linkMap.containsKey(key);
|
||||
}
|
||||
|
||||
public boolean containsValue(Object value) {
|
||||
return linkMap.containsValue(value);
|
||||
}
|
||||
|
||||
public Enumeration elements() {
|
||||
throw new RuntimeException("Method elements is not supported in LinkedProperties class");
|
||||
}
|
||||
|
||||
public Set entrySet() {
|
||||
return linkMap.entrySet();
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
return linkMap.equals(o);
|
||||
}
|
||||
|
||||
public Object get(Object key) {
|
||||
return linkMap.get(key);
|
||||
}
|
||||
|
||||
public String getProperty(String key) {
|
||||
Object oval = get(key); //here the class Properties uses super.get()
|
||||
if (oval == null) return null;
|
||||
return (oval instanceof String) ? (String) oval : null; //behavior of standard properties
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return linkMap.isEmpty();
|
||||
}
|
||||
|
||||
public Enumeration keys() {
|
||||
Set keys = linkMap.keySet();
|
||||
return Collections.enumeration(keys);
|
||||
}
|
||||
|
||||
public Set keySet() {
|
||||
return linkMap.keySet();
|
||||
}
|
||||
|
||||
public void list(PrintStream out) {
|
||||
this.list(new PrintWriter(out, true));
|
||||
}
|
||||
|
||||
public void list(PrintWriter out) {
|
||||
out.println("-- listing properties --");
|
||||
for (Map.Entry e : (Set<Map.Entry>) this.entrySet()) {
|
||||
String key = (String) e.getKey();
|
||||
String val = (String) e.getValue();
|
||||
if (val.length() > 40) {
|
||||
val = val.substring(0, 37) + "...";
|
||||
}
|
||||
out.println(key + "=" + val);
|
||||
}
|
||||
}
|
||||
|
||||
public Object put(Object key, Object value) {
|
||||
return linkMap.put(key, value);
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return linkMap.size();
|
||||
}
|
||||
|
||||
public Collection values() {
|
||||
return linkMap.values();
|
||||
}
|
||||
|
||||
}
|
||||
258
src/main/java/com/sipai/activiti/util/Page.java
Normal file
258
src/main/java/com/sipai/activiti/util/Page.java
Normal file
@ -0,0 +1,258 @@
|
||||
package com.sipai.activiti.util;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author HenryYan
|
||||
*/
|
||||
public class Page<T> {
|
||||
|
||||
// -- 公共变量 --//
|
||||
public static final String ASC = "asc";
|
||||
public static final String DESC = "desc";
|
||||
|
||||
// -- 分页参数 --//
|
||||
protected int pageNo = 1;
|
||||
protected int pageSize = -1;
|
||||
protected String orderBy = null;
|
||||
protected String order = null;
|
||||
protected boolean autoCount = true;
|
||||
|
||||
// -- 返回结果 --//
|
||||
protected List<T> result = Lists.newArrayList();
|
||||
protected long totalCount = -1;
|
||||
|
||||
// -- 构造函数 --//
|
||||
public Page() {
|
||||
}
|
||||
|
||||
public Page(int pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
// -- 分页参数访问函数 --//
|
||||
|
||||
/**
|
||||
* 获得当前页的页号,序号从1开始,默认为1.
|
||||
*/
|
||||
public int getPageNo() {
|
||||
return pageNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前页的页号,序号从1开始,低于1时自动调整为1.
|
||||
*/
|
||||
public void setPageNo(final int pageNo) {
|
||||
this.pageNo = pageNo;
|
||||
|
||||
if (pageNo < 1) {
|
||||
this.pageNo = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回Page对象自身的setPageNo函数,可用于连续设置。
|
||||
*/
|
||||
public Page<T> pageNo(final int thePageNo) {
|
||||
setPageNo(thePageNo);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得每页的记录数量, 默认为-1.
|
||||
*/
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置每页的记录数量.
|
||||
*/
|
||||
public void setPageSize(final int pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回Page对象自身的setPageSize函数,可用于连续设置。
|
||||
*/
|
||||
public Page<T> pageSize(final int thePageSize) {
|
||||
setPageSize(thePageSize);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据pageNo和pageSize计算当前页第一条记录在总结果集中的位置,序号从1开始.
|
||||
*/
|
||||
public int getFirst() {
|
||||
return ((pageNo - 1) * pageSize) + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得排序字段,无默认值. 多个排序字段时用','分隔.
|
||||
*/
|
||||
public String getOrderBy() {
|
||||
return orderBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置排序字段,多个排序字段时用','分隔.
|
||||
*/
|
||||
public void setOrderBy(final String orderBy) {
|
||||
this.orderBy = orderBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回Page对象自身的setOrderBy函数,可用于连续设置。
|
||||
*/
|
||||
public Page<T> orderBy(final String theOrderBy) {
|
||||
setOrderBy(theOrderBy);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得排序方向, 无默认值.
|
||||
*/
|
||||
public String getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置排序方式向.
|
||||
*
|
||||
* @param order 可选值为desc或asc,多个排序字段时用','分隔.
|
||||
*/
|
||||
public void setOrder(final String order) {
|
||||
String lowcaseOrder = StringUtils.lowerCase(order);
|
||||
|
||||
// 检查order字符串的合法值
|
||||
String[] orders = StringUtils.split(lowcaseOrder, ',');
|
||||
for (String orderStr : orders) {
|
||||
if (!StringUtils.equals(DESC, orderStr) && !StringUtils.equals(ASC, orderStr)) {
|
||||
throw new IllegalArgumentException("排序方向" + orderStr + "不是合法值");
|
||||
}
|
||||
}
|
||||
|
||||
this.order = lowcaseOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回Page对象自身的setOrder函数,可用于连续设置。
|
||||
*/
|
||||
public Page<T> order(final String theOrder) {
|
||||
setOrder(theOrder);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否已设置排序字段,无默认值.
|
||||
*/
|
||||
public boolean isOrderBySetted() {
|
||||
return (StringUtils.isNotBlank(orderBy) && StringUtils.isNotBlank(order));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得查询对象时是否先自动执行count查询获取总记录数, 默认为false.
|
||||
*/
|
||||
public boolean isAutoCount() {
|
||||
return autoCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置查询对象时是否自动先执行count查询获取总记录数.
|
||||
*/
|
||||
public void setAutoCount(final boolean autoCount) {
|
||||
this.autoCount = autoCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回Page对象自身的setAutoCount函数,可用于连续设置。
|
||||
*/
|
||||
public Page<T> autoCount(final boolean theAutoCount) {
|
||||
setAutoCount(theAutoCount);
|
||||
return this;
|
||||
}
|
||||
|
||||
// -- 访问查询结果函数 --//
|
||||
|
||||
/**
|
||||
* 获得页内的记录列表.
|
||||
*/
|
||||
public List<T> getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置页内的记录列表.
|
||||
*/
|
||||
public void setResult(final List<T> result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得总记录数, 默认值为-1.
|
||||
*/
|
||||
public long getTotalCount() {
|
||||
return totalCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置总记录数.
|
||||
*/
|
||||
public void setTotalCount(final long totalCount) {
|
||||
this.totalCount = totalCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据pageSize与totalCount计算总页数, 默认值为-1.
|
||||
*/
|
||||
public long getTotalPages() {
|
||||
if (totalCount < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
long count = totalCount / pageSize;
|
||||
if (totalCount % pageSize > 0) {
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否还有下一页.
|
||||
*/
|
||||
public boolean isHasNext() {
|
||||
return (pageNo + 1 <= getTotalPages());
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得下页的页号, 序号从1开始. 当前页为尾页时仍返回尾页序号.
|
||||
*/
|
||||
public int getNextPage() {
|
||||
if (isHasNext()) {
|
||||
return pageNo + 1;
|
||||
} else {
|
||||
return pageNo;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否还有上一页.
|
||||
*/
|
||||
public boolean isHasPre() {
|
||||
return (pageNo - 1 >= 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得上页的页号, 序号从1开始. 当前页为首页时返回首页序号.
|
||||
*/
|
||||
public int getPrePage() {
|
||||
if (isHasPre()) {
|
||||
return pageNo - 1;
|
||||
} else {
|
||||
return pageNo;
|
||||
}
|
||||
}
|
||||
}
|
||||
26
src/main/java/com/sipai/activiti/util/PageUtil.java
Normal file
26
src/main/java/com/sipai/activiti/util/PageUtil.java
Normal file
@ -0,0 +1,26 @@
|
||||
package com.sipai.activiti.util;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 分页工具
|
||||
*
|
||||
* @author henryyan
|
||||
*/
|
||||
public class PageUtil {
|
||||
|
||||
public static int PAGE_SIZE = 50;
|
||||
|
||||
public static int[] init(Page<?> page, HttpServletRequest request) {
|
||||
int pageNumber = Integer.parseInt(StringUtils.defaultIfBlank(request.getParameter("p"), "1"));
|
||||
page.setPageNo(pageNumber);
|
||||
int pageSize = Integer.parseInt(StringUtils.defaultIfBlank(request.getParameter("ps"), String.valueOf(PAGE_SIZE)));
|
||||
page.setPageSize(pageSize);
|
||||
int firstResult = page.getFirst() - 1;
|
||||
int maxResults = page.getPageSize();
|
||||
return new int[]{firstResult, maxResults};
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,72 @@
|
||||
package com.sipai.activiti.util;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import org.activiti.engine.RepositoryService;
|
||||
import org.activiti.engine.impl.RepositoryServiceImpl;
|
||||
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
|
||||
import org.activiti.engine.impl.pvm.process.ActivityImpl;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 流程定义缓存
|
||||
*
|
||||
* @author henryyan
|
||||
*/
|
||||
public class ProcessDefinitionCache {
|
||||
|
||||
private static Map<String, ProcessDefinition> map = Maps.newHashMap();
|
||||
|
||||
private static Map<String, List<ActivityImpl>> activities = Maps.newHashMap();
|
||||
|
||||
private static Map<String, ActivityImpl> singleActivity = Maps.newHashMap();
|
||||
|
||||
private static RepositoryService repositoryService;
|
||||
|
||||
public static ProcessDefinition get(String processDefinitionId) {
|
||||
ProcessDefinition processDefinition = map.get(processDefinitionId);
|
||||
if (processDefinition == null) {
|
||||
processDefinition = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processDefinitionId);
|
||||
if (processDefinition != null) {
|
||||
put(processDefinitionId, processDefinition);
|
||||
}
|
||||
}
|
||||
return processDefinition;
|
||||
}
|
||||
|
||||
public static void put(String processDefinitionId, ProcessDefinition processDefinition) {
|
||||
map.put(processDefinitionId, processDefinition);
|
||||
ProcessDefinitionEntity pde = (ProcessDefinitionEntity) processDefinition;
|
||||
activities.put(processDefinitionId, pde.getActivities());
|
||||
for (ActivityImpl activityImpl : pde.getActivities()) {
|
||||
singleActivity.put(processDefinitionId + "_" + activityImpl.getId(), activityImpl);
|
||||
}
|
||||
}
|
||||
|
||||
public static ActivityImpl getActivity(String processDefinitionId, String activityId) {
|
||||
ProcessDefinition processDefinition = get(processDefinitionId);
|
||||
if (processDefinition != null) {
|
||||
ActivityImpl activityImpl = singleActivity.get(processDefinitionId + "_" + activityId);
|
||||
if (activityImpl != null) {
|
||||
return activityImpl;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getActivityName(String processDefinitionId, String activityId) {
|
||||
ActivityImpl activity = getActivity(processDefinitionId, activityId);
|
||||
if (activity != null) {
|
||||
return ObjectUtils.toString(activity.getProperty("name"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void setRepositoryService(RepositoryService repositoryService) {
|
||||
ProcessDefinitionCache.repositoryService = repositoryService;
|
||||
}
|
||||
|
||||
}
|
||||
208
src/main/java/com/sipai/activiti/util/PropertyFileUtil.java
Normal file
208
src/main/java/com/sipai/activiti/util/PropertyFileUtil.java
Normal file
@ -0,0 +1,208 @@
|
||||
package com.sipai.activiti.util;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.util.DefaultPropertiesPersister;
|
||||
import org.springframework.util.PropertiesPersister;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 系统属性工具类
|
||||
*
|
||||
* @author HenryYan
|
||||
*/
|
||||
public class PropertyFileUtil {
|
||||
|
||||
|
||||
private static final String DEFAULT_ENCODING = "UTF-8";
|
||||
private static Logger logger = LoggerFactory.getLogger(PropertyFileUtil.class);
|
||||
private static Properties properties;
|
||||
private static PropertiesPersister propertiesPersister = new DefaultPropertiesPersister();
|
||||
private static ResourceLoader resourceLoader = new DefaultResourceLoader();
|
||||
private static Properties activePropertyFiles = null;
|
||||
private static String PROFILE_ID = StringUtils.EMPTY;
|
||||
public static boolean INITIALIZED = false; // 是否已初始化
|
||||
|
||||
/**
|
||||
* 初始化读取配置文件,读取的文件列表位于classpath下面的application-files.properties<br/>
|
||||
* <p/>
|
||||
* 多个配置文件会用最后面的覆盖相同属性值
|
||||
*
|
||||
* @throws IOException 读取属性文件时
|
||||
*/
|
||||
public static void init() throws IOException {
|
||||
String fileNames = "application-files.properties";
|
||||
PROFILE_ID = StringUtils.EMPTY;
|
||||
innerInit(fileNames);
|
||||
activePropertyFiles(fileNames);
|
||||
INITIALIZED = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化读取配置文件,读取的文件列表位于classpath下面的application-[type]-files.properties<br/>
|
||||
* <p/>
|
||||
* 多个配置文件会用最后面的覆盖相同属性值
|
||||
*
|
||||
* @param profile 配置文件类型,application-[profile]-files.properties
|
||||
* @throws IOException 读取属性文件时
|
||||
*/
|
||||
public static void init(String profile) throws IOException {
|
||||
if (StringUtils.isBlank(profile)) {
|
||||
init();
|
||||
} else {
|
||||
PROFILE_ID = profile;
|
||||
String fileNames = "application-" + profile + "-files.properties";
|
||||
innerInit(fileNames);
|
||||
}
|
||||
INITIALIZED = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 内部处理
|
||||
*
|
||||
* @param fileName
|
||||
* @throws IOException
|
||||
*/
|
||||
private static void innerInit(String fileName) throws IOException {
|
||||
String[] propFiles = activePropertyFiles(fileName);
|
||||
logger.debug("读取属性文件:{}", ArrayUtils.toString(propFiles));
|
||||
properties = loadProperties(propFiles);
|
||||
Set<Object> keySet = properties.keySet();
|
||||
for (Object key : keySet) {
|
||||
logger.debug("property: {}, value: {}", key, properties.getProperty(key.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取读取的资源文件列表
|
||||
*
|
||||
* @param fileName
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
private static String[] activePropertyFiles(String fileName) throws IOException {
|
||||
logger.info("读取" + fileName);
|
||||
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||
InputStream resourceAsStream = loader.getResourceAsStream(fileName);
|
||||
// 默认的Properties实现使用HashMap算法,为了保持原有顺序使用有序Map
|
||||
activePropertyFiles = new LinkedProperties();
|
||||
activePropertyFiles.load(resourceAsStream);
|
||||
|
||||
Set<Object> fileKeySet = activePropertyFiles.keySet();
|
||||
String[] propFiles = new String[fileKeySet.size()];
|
||||
List<Object> fileList = new ArrayList<Object>();
|
||||
|
||||
fileList.addAll(activePropertyFiles.keySet());
|
||||
for (int i = 0; i < propFiles.length; i++) {
|
||||
String fileKey = fileList.get(i).toString();
|
||||
propFiles[i] = activePropertyFiles.getProperty(fileKey);
|
||||
}
|
||||
return propFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* 载入多个properties文件, 相同的属性在最后载入的文件中的值将会覆盖之前的载入.
|
||||
* 文件路径使用Spring Resource格式, 文件编码使用UTF-8.
|
||||
*
|
||||
* @see org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
|
||||
*/
|
||||
public static Properties loadProperties(String... resourcesPaths) throws IOException {
|
||||
Properties props = new Properties();
|
||||
|
||||
for (String location : resourcesPaths) {
|
||||
|
||||
logger.debug("Loading properties file from:" + location);
|
||||
|
||||
InputStream is = null;
|
||||
try {
|
||||
Resource resource = resourceLoader.getResource(location);
|
||||
is = resource.getInputStream();
|
||||
propertiesPersister.load(props, new InputStreamReader(is, DEFAULT_ENCODING));
|
||||
} catch (IOException ex) {
|
||||
logger.info("Could not load properties from classpath:" + location + ": " + ex.getMessage());
|
||||
} finally {
|
||||
if (is != null) {
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有的key
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Set<String> getKeys() {
|
||||
return properties.stringPropertyNames();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取键值对Map
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Map<String, String> getKeyValueMap() {
|
||||
Set<String> keys = getKeys();
|
||||
Map<String, String> values = new HashMap<String, String>();
|
||||
for (String key : keys) {
|
||||
values.put(key, get(key));
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取属性值
|
||||
*
|
||||
* @param key 键
|
||||
* @return 值
|
||||
*/
|
||||
public static String get(String key) {
|
||||
String propertyValue = properties.getProperty(key);
|
||||
logger.debug("获取属性:{},值:{}", key, propertyValue);
|
||||
return propertyValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取属性值
|
||||
*
|
||||
* @param key 键
|
||||
* @param defaultValue 默认值
|
||||
* @return 值
|
||||
*/
|
||||
public static String get(String key, String defaultValue) {
|
||||
String propertyValue = properties.getProperty(key);
|
||||
String value = StringUtils.defaultString(propertyValue, defaultValue);
|
||||
logger.debug("获取属性:{},值:{}", key, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向内存添加属性
|
||||
*
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
*/
|
||||
public static void add(String key, String value) {
|
||||
properties.put(key, value);
|
||||
logger.debug("通过方法添加属性到内存:{},值:{}", key, value);
|
||||
}
|
||||
|
||||
public static Properties getActivePropertyFiles() {
|
||||
return activePropertyFiles;
|
||||
}
|
||||
|
||||
public static String getProfile() {
|
||||
return PROFILE_ID;
|
||||
}
|
||||
}
|
||||
24
src/main/java/com/sipai/activiti/util/PropertyType.java
Normal file
24
src/main/java/com/sipai/activiti/util/PropertyType.java
Normal file
@ -0,0 +1,24 @@
|
||||
package com.sipai.activiti.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 属性数据类型
|
||||
*
|
||||
* @author HenryYan
|
||||
*/
|
||||
public enum PropertyType {
|
||||
S(String.class), I(Integer.class), L(Long.class), F(Float.class), N(Double.class), D(Date.class), SD(java.sql.Date.class), B(
|
||||
Boolean.class);
|
||||
|
||||
private Class<?> clazz;
|
||||
|
||||
private PropertyType(Class<?> clazz) {
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
public Class<?> getValue() {
|
||||
return clazz;
|
||||
}
|
||||
}
|
||||
37
src/main/java/com/sipai/activiti/util/UserUtil.java
Normal file
37
src/main/java/com/sipai/activiti/util/UserUtil.java
Normal file
@ -0,0 +1,37 @@
|
||||
package com.sipai.activiti.util;
|
||||
|
||||
import org.activiti.engine.identity.User;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
* 用户工具类
|
||||
*
|
||||
* @author HenryYan
|
||||
*/
|
||||
public class UserUtil {
|
||||
|
||||
public static final String USER = "user";
|
||||
|
||||
/**
|
||||
* 设置用户到session
|
||||
*
|
||||
* @param session
|
||||
* @param user
|
||||
*/
|
||||
public static void saveUserToSession(HttpSession session, User user) {
|
||||
session.setAttribute(USER, user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从Session获取当前用户信息
|
||||
*
|
||||
* @param session
|
||||
* @return
|
||||
*/
|
||||
public static User getUserFromSession(HttpSession session) {
|
||||
Object attribute = session.getAttribute(USER);
|
||||
return attribute == null ? null : (User) attribute;
|
||||
}
|
||||
|
||||
}
|
||||
77
src/main/java/com/sipai/activiti/util/Variable.java
Normal file
77
src/main/java/com/sipai/activiti/util/Variable.java
Normal file
@ -0,0 +1,77 @@
|
||||
package com.sipai.activiti.util;
|
||||
|
||||
import jodd.util.StringUtil;
|
||||
|
||||
import org.apache.commons.beanutils.ConvertUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Variable {
|
||||
|
||||
private String keys;
|
||||
private String values;
|
||||
private String types;
|
||||
|
||||
public String getKeys() {
|
||||
return keys;
|
||||
}
|
||||
|
||||
public void setKeys(String keys) {
|
||||
this.keys = keys;
|
||||
}
|
||||
|
||||
public String getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public void setValues(String values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
public String getTypes() {
|
||||
return types;
|
||||
}
|
||||
|
||||
public void setTypes(String types) {
|
||||
this.types = types;
|
||||
}
|
||||
|
||||
public Map<String, Object> getVariableMap() {
|
||||
Map<String, Object> vars = new HashMap<String, Object>();
|
||||
|
||||
ConvertUtils.register(new DateConverter(), java.util.Date.class);
|
||||
|
||||
if (StringUtil.isBlank(keys)) {
|
||||
return vars;
|
||||
}
|
||||
|
||||
String[] arrayKey = keys.split(",");
|
||||
String[] arrayValue = values.split(",");
|
||||
String[] arrayType = types.split(",");
|
||||
for (int i = 0; i < arrayKey.length; i++) {
|
||||
if ("".equals(arrayKey[i]) || "".equals(arrayValue[i]) || "".equals(arrayType[i])) {
|
||||
continue;
|
||||
}
|
||||
String key = arrayKey[i];
|
||||
String value = arrayValue[i];
|
||||
String type = arrayType[i];
|
||||
Object objectValue=null;
|
||||
if(!type.equals("A")){
|
||||
Class<?> targetType = Enum.valueOf(PropertyType.class, type).getValue();
|
||||
objectValue = ConvertUtils.convert(value, targetType);
|
||||
}else{
|
||||
//如果变量为ArrayList需特别处理
|
||||
String[] list =value.split("-");
|
||||
objectValue=new ArrayList<String>();
|
||||
for (String str : list) {
|
||||
((ArrayList)objectValue).add(str);
|
||||
}
|
||||
}
|
||||
vars.put(key, objectValue);
|
||||
}
|
||||
return vars;
|
||||
}
|
||||
|
||||
}
|
||||
83
src/main/java/com/sipai/activiti/util/WorkflowUtils.java
Normal file
83
src/main/java/com/sipai/activiti/util/WorkflowUtils.java
Normal file
@ -0,0 +1,83 @@
|
||||
package com.sipai.activiti.util;
|
||||
|
||||
import org.activiti.engine.RepositoryService;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author HenryYan
|
||||
*/
|
||||
public class WorkflowUtils {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(WorkflowUtils.class);
|
||||
|
||||
/**
|
||||
* 转换流程节点类型为中文说明
|
||||
*
|
||||
* @param type 英文名称
|
||||
* @return 翻译后的中文名称
|
||||
*/
|
||||
public static String parseToZhType(String type) {
|
||||
Map<String, String> types = new HashMap<String, String>();
|
||||
types.put("userTask", "用户任务");
|
||||
types.put("serviceTask", "系统任务");
|
||||
types.put("startEvent", "开始节点");
|
||||
types.put("endEvent", "结束节点");
|
||||
types.put("exclusiveGateway", "条件判断节点(系统自动根据条件处理)");
|
||||
types.put("inclusiveGateway", "并行处理任务");
|
||||
types.put("callActivity", "子流程");
|
||||
return types.get(type) == null ? type : types.get(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出图片文件到硬盘
|
||||
*
|
||||
* @return 文件的全路径
|
||||
*/
|
||||
public static String exportDiagramToFile(RepositoryService repositoryService, ProcessDefinition processDefinition, String exportDir) throws IOException {
|
||||
String diagramResourceName = processDefinition.getDiagramResourceName();
|
||||
String key = processDefinition.getKey();
|
||||
int version = processDefinition.getVersion();
|
||||
String diagramPath = "";
|
||||
|
||||
InputStream resourceAsStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), diagramResourceName);
|
||||
byte[] b = new byte[resourceAsStream.available()];
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
int len = -1;
|
||||
resourceAsStream.read(b, 0, b.length);
|
||||
|
||||
// create file if not exist
|
||||
String diagramDir = exportDir + "/" + key + "/" + version;
|
||||
File diagramDirFile = new File(diagramDir);
|
||||
if (!diagramDirFile.exists()) {
|
||||
diagramDirFile.mkdirs();
|
||||
}
|
||||
diagramPath = diagramDir + "/" + diagramResourceName;
|
||||
File file = new File(diagramPath);
|
||||
|
||||
// 文件存在退出
|
||||
if (file.exists()) {
|
||||
// 文件大小相同时直接返回否则重新创建文件(可能损坏)
|
||||
logger.debug("diagram exist, ignore... : {}", diagramPath);
|
||||
return diagramPath;
|
||||
} else {
|
||||
file.createNewFile();
|
||||
}
|
||||
|
||||
logger.debug("export diagram to : {}", diagramPath);
|
||||
|
||||
// wirte bytes to file
|
||||
FileUtils.writeByteArrayToFile(file, b);
|
||||
return diagramPath;
|
||||
}
|
||||
|
||||
}
|
||||
92
src/main/java/com/sipai/config/RedissonConfig.java
Normal file
92
src/main/java/com/sipai/config/RedissonConfig.java
Normal file
@ -0,0 +1,92 @@
|
||||
package com.sipai.config;
|
||||
|
||||
import org.redisson.Redisson;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.redisson.client.codec.Codec;
|
||||
import org.redisson.codec.JsonJacksonCodec;
|
||||
import org.redisson.config.Config;
|
||||
import org.redisson.config.SingleServerConfig;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @Author : YYJ
|
||||
* @CreateTime : 2021/9/14
|
||||
* @Description :
|
||||
**/
|
||||
@Configuration
|
||||
public class RedissonConfig {
|
||||
private static String MODE_SINGLE = "single";
|
||||
private static String MODE_CLUSTER = "cluster";
|
||||
@Value("${redis.mode}")
|
||||
public String mode;
|
||||
@Value("${redis.host}")
|
||||
public String host;
|
||||
|
||||
@Value("${redis.port}")
|
||||
public String port;
|
||||
|
||||
// @Value("${redis.database}")
|
||||
// public String database;
|
||||
|
||||
@Value("${redis.password}")
|
||||
public String password;
|
||||
|
||||
@Value("${cluster1.host.port:}")
|
||||
public String cluster1;
|
||||
@Value("${cluster2.host.port:}")
|
||||
public String cluster2;
|
||||
@Value("${cluster3.host.port:}")
|
||||
public String cluster3;
|
||||
@Value("${cluster4.host.port:}")
|
||||
public String cluster4;
|
||||
@Value("${cluster5.host.port:}")
|
||||
public String cluster5;
|
||||
@Value("${cluster6.host.port:}")
|
||||
public String cluster6;
|
||||
|
||||
@Bean
|
||||
public RedissonClient redissonClient(){
|
||||
RedissonClient redisson = null;
|
||||
Config conf = new Config();
|
||||
|
||||
if(MODE_SINGLE.equals(mode)) {//单机
|
||||
//单节点模式
|
||||
SingleServerConfig singleServerConfig = conf.useSingleServer();
|
||||
//设置连接地址:redis://127.0.0.1:6379
|
||||
singleServerConfig.setAddress("redis://" + host + ":" + port);
|
||||
//设置连接密码
|
||||
singleServerConfig.setPassword(password);
|
||||
// singleServerConfig.setDatabase(Integer.valueOf(database));
|
||||
}else if(MODE_CLUSTER.equals(mode)){//集群
|
||||
conf.useClusterServers()
|
||||
.setScanInterval(2000);
|
||||
if(cluster1!=null && !cluster1.isEmpty()){
|
||||
conf.useClusterServers().addNodeAddress("redis://" + cluster1);
|
||||
}
|
||||
if(cluster2!=null && !cluster2.isEmpty()){
|
||||
conf.useClusterServers().addNodeAddress("redis://" + cluster2);
|
||||
}
|
||||
if(cluster3!=null && !cluster3.isEmpty()){
|
||||
conf.useClusterServers().addNodeAddress("redis://" + cluster3);
|
||||
}
|
||||
if(cluster4!=null && !cluster4.isEmpty()){
|
||||
conf.useClusterServers().addNodeAddress("redis://" + cluster4);
|
||||
}
|
||||
if(cluster5!=null && !cluster5.isEmpty()){
|
||||
conf.useClusterServers().addNodeAddress("redis://" + cluster5);
|
||||
}
|
||||
if(cluster6!=null && !cluster6.isEmpty()){
|
||||
conf.useClusterServers().addNodeAddress("redis://" + cluster6);
|
||||
}
|
||||
// .setPassword(password);
|
||||
}
|
||||
|
||||
//使用json序列化方式
|
||||
Codec codec = new JsonJacksonCodec();
|
||||
conf.setCodec(codec);
|
||||
redisson = Redisson.create(conf);
|
||||
return redisson;
|
||||
}
|
||||
}
|
||||
37
src/main/java/com/sipai/controller/DBController.java
Normal file
37
src/main/java/com/sipai/controller/DBController.java
Normal file
@ -0,0 +1,37 @@
|
||||
package com.sipai.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.tools.CommUtil;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/data/db")
|
||||
public class DBController {
|
||||
|
||||
@RequestMapping(value = "/handle.do", method = RequestMethod.POST)
|
||||
// @RequestMapping(value = "/handle.do")
|
||||
public ModelAndView handle(HttpServletRequest request, Model model) {
|
||||
String json = request.getParameter("json");
|
||||
System.out.println(CommUtil.nowDate() + "------" + json);
|
||||
if (json != null && !json.trim().equals("")) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("code", "100");
|
||||
jsonObject.put("message", "");
|
||||
model.addAttribute("result", jsonObject);
|
||||
} else {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("code", "400");
|
||||
jsonObject.put("message", "json为空,请重新请求");
|
||||
model.addAttribute("result", jsonObject);
|
||||
}
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
package com.sipai.controller.Listener;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.Listener.ListenerMessage;
|
||||
import com.sipai.entity.equipment.EquipmentCard;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.entity.workorder.Overhaul;
|
||||
import com.sipai.service.Listener.ListenerMessageService;
|
||||
import com.sipai.service.equipment.EquipmentCardService;
|
||||
import com.sipai.service.workorder.OverhaulService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
import net.sf.json.JSONArray;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Auther: 你的名字
|
||||
* @Date: 2021/11/21/16:59
|
||||
* @Description:
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/listener/listenerMessage")
|
||||
public class ListenerMessageController {
|
||||
@Resource
|
||||
private ListenerMessageService listenerMessageService;
|
||||
@Resource
|
||||
private EquipmentCardService equipmentCardService;
|
||||
|
||||
@RequestMapping("/getList.do")
|
||||
public ModelAndView getList(HttpServletRequest request, Model model) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String orderstr = " order by insdt desc";
|
||||
|
||||
String wherestr = " where 1=1 and Cmdtype='web' and Action = 'layer' and DateDiff(dd,insdt,getdate())=0";
|
||||
if (request.getParameter("unitId") != null && !request.getParameter("unitId").isEmpty()) {
|
||||
wherestr += " and unit_id = '" + request.getParameter("unitId") + "' ";
|
||||
}
|
||||
List<ListenerMessage> list = this.listenerMessageService.selectListByWhere(wherestr + orderstr);
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
|
||||
System.out.println(json);
|
||||
model.addAttribute("result", json);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/getList4Equ.do")
|
||||
public ModelAndView getList4Equ(HttpServletRequest request, Model model) {
|
||||
String equipmentcardId = request.getParameter("equipmentcardId");
|
||||
String orderstr = " order by insdt desc";
|
||||
|
||||
String wherestr = " where 1=1 and Cmdtype='web' and Action = 'layer' and DateDiff(dd,insdt,getdate())=0";
|
||||
if (request.getParameter("unitId") != null && !request.getParameter("unitId").isEmpty()) {
|
||||
wherestr += " and unit_id = '" + request.getParameter("unitId") + "' ";
|
||||
}
|
||||
String equipmentId = "";
|
||||
if(equipmentcardId!=null && !equipmentcardId.equals("")){
|
||||
EquipmentCard equipmentCard = equipmentCardService.selectByEquipmentCardId(equipmentcardId);
|
||||
if(equipmentCard!=null){
|
||||
equipmentId = equipmentCard.getId();
|
||||
}
|
||||
}
|
||||
List<ListenerMessage> list = this.listenerMessageService.selectListByWhere4Equ(wherestr + orderstr,equipmentId);
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
|
||||
System.out.println(json);
|
||||
model.addAttribute("result", json);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,191 @@
|
||||
package com.sipai.controller.accident;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.accident.Accident;
|
||||
import com.sipai.entity.accident.AccidentType;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.maintenance.Abnormity;
|
||||
import com.sipai.entity.user.Unit;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.accident.AccidentService;
|
||||
import com.sipai.service.accident.AccidentTypeService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/accident/accident")
|
||||
public class AccidentController {
|
||||
@Resource
|
||||
private AccidentService accidentService;
|
||||
@Resource
|
||||
private AccidentTypeService accidentTypeService;
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
|
||||
@RequestMapping("/showlist.do")
|
||||
public String showlist(HttpServletRequest request,Model model){
|
||||
return "/accident/accidentList";
|
||||
}
|
||||
|
||||
@RequestMapping("/browseList.do")
|
||||
public String browseList(HttpServletRequest request,Model model){
|
||||
return "/accident/accidentBrowse";
|
||||
}
|
||||
|
||||
@RequestMapping("/getList.do")
|
||||
public ModelAndView getList(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required=false) String sort,
|
||||
@RequestParam(value = "order", required=false) String order) {
|
||||
User cu=(User)request.getSession().getAttribute("cu");
|
||||
String companyId =request.getParameter("unitId");
|
||||
if(sort==null){
|
||||
sort = " insdt ";
|
||||
}
|
||||
if(order==null){
|
||||
order = " desc ";
|
||||
}
|
||||
String orderstr=" order by "+sort+" "+order;
|
||||
|
||||
String wherestr=" where 1=1";
|
||||
if(companyId!=null && !companyId.isEmpty()){
|
||||
//获取公司下所有子节点
|
||||
List<Unit> units = unitService.getUnitChildrenById(companyId);
|
||||
String companyids="";
|
||||
for(Unit unit : units){
|
||||
companyids += "'"+unit.getId()+"',";
|
||||
}
|
||||
if(companyids!=""){
|
||||
companyids = companyids.substring(0, companyids.length()-1);
|
||||
wherestr += " and unit_id in ("+companyids+") ";
|
||||
}
|
||||
}
|
||||
if(request.getParameter("search_name")!=null && !request.getParameter("search_name").isEmpty()){
|
||||
wherestr += " and name like '%"+request.getParameter("search_name")+"%' ";
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<Accident> list = this.accidentService.selectListByWhere(wherestr+orderstr);
|
||||
PageInfo<Accident> pi = new PageInfo<Accident>(list);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
|
||||
String result="{\"total\":"+pi.getTotal()+",\"rows\":"+json+"}";
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/doadd.do")
|
||||
public String doadd(HttpServletRequest request,Model model){
|
||||
return "/accident/accidentAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/showAccidentType4Select.do")
|
||||
public String showAccidentType4Select(HttpServletRequest request,Model model){
|
||||
return "/accident/accidentType4select4Use";
|
||||
}
|
||||
|
||||
@RequestMapping("/dosave.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute Accident accident){
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String userId = cu.getId();
|
||||
accident.setId(CommUtil.getUUID());
|
||||
accident.setInsdt(CommUtil.nowDate());
|
||||
accident.setInsuser(userId);
|
||||
int code = this.accidentService.save(accident);
|
||||
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("新增失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doedit.do")
|
||||
public String doedit(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
Accident accident = this.accidentService.selectById(id);
|
||||
model.addAttribute("accident", accident);
|
||||
return "/accident/accidentEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/doview.do")
|
||||
public String doview(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
Accident accident = this.accidentService.selectById(id);
|
||||
model.addAttribute("accident", accident);
|
||||
return "/accident/accidentView";
|
||||
}
|
||||
|
||||
@RequestMapping("/doupdate.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute Accident accident){
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String userId = cu.getId();
|
||||
|
||||
int code = this.accidentService.update(accident);
|
||||
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("更新失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodelete.do")
|
||||
public String dodelete(HttpServletRequest request,Model model,
|
||||
@ModelAttribute AccidentType accidentType){
|
||||
Result result = new Result();
|
||||
int code = this.accidentService.deleteById(accidentType.getId());
|
||||
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("删除失败");
|
||||
}
|
||||
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodeletes.do")
|
||||
public String dodeletes(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="ids") String ids){
|
||||
String[] idArray = ids.split(",");
|
||||
try {
|
||||
for (int i = 0; i < idArray.length; i++) {
|
||||
this.accidentService.deleteById(idArray[i]);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Result result = Result.failed("删除失败");
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
Result result = Result.success(1);
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,143 @@
|
||||
package com.sipai.controller.accident;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.sipai.entity.accident.AccidentType;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.accident.AccidentTypeService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/accident/accidentType")
|
||||
public class AccidentTypeController {
|
||||
@Resource
|
||||
private AccidentTypeService accidentTypeService;
|
||||
|
||||
@RequestMapping("/showAccidentTypeTree.do")
|
||||
public String showAccidentTypeTree(HttpServletRequest request,Model model){
|
||||
return "/accident/accidentTypeTree";
|
||||
}
|
||||
|
||||
@RequestMapping("/getAccidentTypeTree.do")
|
||||
public ModelAndView getAccidentTypeTree(HttpServletRequest request,Model model) {
|
||||
List<AccidentType> list = this.accidentTypeService.selectListByWhere(" where 1=1 order by morder");
|
||||
String treeList = this.accidentTypeService.getTreeList(null, list);
|
||||
model.addAttribute("result", treeList);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/getAccidentTypeTree4Use.do")
|
||||
public ModelAndView getAccidentTypeTree4Use(HttpServletRequest request,Model model) {
|
||||
List<AccidentType> list = this.accidentTypeService.selectListByWhere(" where 1=1 and active ='启用' order by morder");
|
||||
String treeList = this.accidentTypeService.getTreeList(null, list);
|
||||
model.addAttribute("result", treeList);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/doadd.do")
|
||||
public String doadd(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="pid") String pid){
|
||||
if(pid!=null && !pid.equals("")){
|
||||
AccidentType accidentType = this.accidentTypeService.selectById(pid);
|
||||
model.addAttribute("pname",accidentType.getName());
|
||||
}
|
||||
return "/accident/accidentTypeAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/showAccidentType4Select.do")
|
||||
public String showAccidentType4Select(HttpServletRequest request,Model model){
|
||||
return "/accident/accidentType4select";
|
||||
}
|
||||
|
||||
@RequestMapping("/showAccidentType4Select4Use.do")
|
||||
public String showAccidentType4Select4Use(HttpServletRequest request,Model model){
|
||||
return "/accident/accidentType4select4Use";
|
||||
}
|
||||
|
||||
@RequestMapping("/dosave.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute AccidentType accidentType){
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String userId = cu.getId();
|
||||
accidentType.setId(CommUtil.getUUID());
|
||||
if (accidentType.getPid()==null || accidentType.getPid().isEmpty()) {
|
||||
accidentType.setPid("-1");
|
||||
}
|
||||
int code = this.accidentTypeService.save(accidentType);
|
||||
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("新增失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doedit.do")
|
||||
public String doedit(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
AccidentType accidentType = this.accidentTypeService.selectById(id);
|
||||
AccidentType pAccidentType = this.accidentTypeService.selectById(accidentType.getPid());
|
||||
if(pAccidentType!=null){
|
||||
model.addAttribute("pname", pAccidentType.getName());
|
||||
}
|
||||
model.addAttribute("accidentType", accidentType);
|
||||
return "/accident/accidentTypeEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/doupdate.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute AccidentType accidentType){
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String userId = cu.getId();
|
||||
if (accidentType.getPid()==null || accidentType.getPid().isEmpty()) {
|
||||
accidentType.setPid("-1");
|
||||
}
|
||||
|
||||
int code = this.accidentTypeService.update(accidentType);
|
||||
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("更新失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodelete.do")
|
||||
public String dodelete(HttpServletRequest request,Model model,
|
||||
@ModelAttribute AccidentType accidentType){
|
||||
List<AccidentType> list = this.accidentTypeService.selectListByWhere(" where pid = '"+accidentType.getId()+"'");
|
||||
Result result = new Result();
|
||||
if(list!=null&&list.size()>0){
|
||||
result = Result.failed("请先删除子菜单");
|
||||
}else{
|
||||
int code = this.accidentTypeService.deleteById(accidentType.getId());
|
||||
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,610 @@
|
||||
package com.sipai.controller.accident;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
|
||||
import org.activiti.engine.RuntimeService;
|
||||
import org.activiti.engine.TaskService;
|
||||
import org.activiti.engine.history.HistoricTaskInstance;
|
||||
import org.activiti.engine.impl.pvm.process.ActivityImpl;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.accident.ReasonableAdvice;
|
||||
import com.sipai.entity.activiti.WorkTask;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.business.BusinessUnit;
|
||||
import com.sipai.entity.business.BusinessUnitAudit;
|
||||
import com.sipai.entity.business.BusinessUnitHandle;
|
||||
import com.sipai.entity.business.BusinessUnitRecord;
|
||||
import com.sipai.entity.user.Unit;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.accident.ReasonableAdviceService;
|
||||
import com.sipai.service.activiti.WorkflowProcessDefinitionService;
|
||||
import com.sipai.service.activiti.WorkflowService;
|
||||
import com.sipai.service.business.BusinessUnitAuditService;
|
||||
import com.sipai.service.business.BusinessUnitHandleService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.service.user.UserService;
|
||||
import com.sipai.tools.ActivitiUtil;
|
||||
import com.sipai.tools.CommString;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/accident/reasonableAdvice")
|
||||
public class ReasonableAdviceController {
|
||||
@Resource
|
||||
private ReasonableAdviceService reasonableAdviceService;
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private WorkflowProcessDefinitionService workflowProcessDefinitionService;
|
||||
@Resource
|
||||
private BusinessUnitHandleService businessUnitHandleService;
|
||||
@Resource
|
||||
private BusinessUnitAuditService businessUnitAuditService;
|
||||
@Resource
|
||||
private WorkflowService workflowService;
|
||||
@Resource
|
||||
private RuntimeService runtimeService;
|
||||
@Resource
|
||||
private TaskService taskService;
|
||||
|
||||
@RequestMapping("/showlist.do")
|
||||
public String showlist(HttpServletRequest request,Model model){
|
||||
return "/accident/reasonableAdviceList";
|
||||
}
|
||||
|
||||
@RequestMapping("/getlist.do")
|
||||
public ModelAndView getList(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required=false) String sort,
|
||||
@RequestParam(value = "order", required=false) String order) {
|
||||
User cu=(User)request.getSession().getAttribute("cu");
|
||||
String companyId =request.getParameter("unitId");
|
||||
if(sort==null){
|
||||
sort = " insdt ";
|
||||
}
|
||||
if(order==null){
|
||||
order = " desc ";
|
||||
}
|
||||
String orderstr=" order by "+sort+" "+order;
|
||||
|
||||
String wherestr=" where 1=1";
|
||||
if(companyId!=null && !companyId.isEmpty()){
|
||||
//获取公司下所有子节点
|
||||
List<Unit> units = unitService.getUnitChildrenById(companyId);
|
||||
String companyids="";
|
||||
for(Unit unit : units){
|
||||
companyids += "'"+unit.getId()+"',";
|
||||
}
|
||||
if(companyids!=""){
|
||||
companyids = companyids.substring(0, companyids.length()-1);
|
||||
wherestr += " and unit_id in ("+companyids+") ";
|
||||
}
|
||||
}
|
||||
if(request.getParameter("search_name")!=null && !request.getParameter("search_name").isEmpty()){
|
||||
wherestr += " and name like '%"+request.getParameter("search_name")+"%' ";
|
||||
}
|
||||
if(request.getParameter("takeFlag")!=null && !request.getParameter("takeFlag").isEmpty()){
|
||||
wherestr += " and take_flag = '"+request.getParameter("takeFlag")+"' ";
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<ReasonableAdvice> list = this.reasonableAdviceService.selectListByWhere(wherestr+orderstr);
|
||||
PageInfo<ReasonableAdvice> pi = new PageInfo<ReasonableAdvice>(list);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
|
||||
String result="{\"total\":"+pi.getTotal()+",\"rows\":"+json+"}";
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/doadd.do")
|
||||
public String doadd(HttpServletRequest request,Model model){
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
model.addAttribute("userId", cu.getId());
|
||||
model.addAttribute("userName", cu.getCaption());
|
||||
return "/accident/reasonableAdviceAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/dosave.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute ReasonableAdvice reasonableAdvice){
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String userId = cu.getId();
|
||||
reasonableAdvice.setId(CommUtil.getUUID());
|
||||
reasonableAdvice.setInsdt(CommUtil.nowDate());
|
||||
int code = this.reasonableAdviceService.save(reasonableAdvice);
|
||||
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("新增失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doedit.do")
|
||||
public String doedit(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
ReasonableAdvice reasonableAdvice = this.reasonableAdviceService.selectById(id);
|
||||
model.addAttribute("reasonableAdvice", reasonableAdvice);
|
||||
|
||||
String[] userleadid = reasonableAdvice.getUserLead().split(",");
|
||||
String[] usershelpid = reasonableAdvice.getUsersHelp().split(",");
|
||||
String solvername="";
|
||||
String solvername1="";
|
||||
for (String lid : userleadid) {
|
||||
User user = this.userService.getUserById(lid);
|
||||
if (user!=null) {
|
||||
solvername+=user.getCaption()+",";
|
||||
}
|
||||
}
|
||||
for (String hid : usershelpid) {
|
||||
User user = this.userService.getUserById(hid);
|
||||
if (user!=null) {
|
||||
solvername1+=user.getCaption()+",";
|
||||
}
|
||||
}
|
||||
model.addAttribute("solvername", solvername);
|
||||
model.addAttribute("solvername1", solvername1);
|
||||
return "/accident/reasonableAdviceEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/doupdate.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute ReasonableAdvice reasonableAdvice){
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String userId = cu.getId();
|
||||
|
||||
int code = this.reasonableAdviceService.update(reasonableAdvice);
|
||||
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("更新失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodelete.do")
|
||||
public String dodelete(HttpServletRequest request,Model model,
|
||||
@ModelAttribute ReasonableAdvice reasonableAdvice){
|
||||
Result result = new Result();
|
||||
int code = this.reasonableAdviceService.deleteById(reasonableAdvice.getId());
|
||||
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("删除失败");
|
||||
}
|
||||
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodeletes.do")
|
||||
public String dodeletes(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="ids") String ids){
|
||||
String[] idArray = ids.split(",");
|
||||
try {
|
||||
for (int i = 0; i < idArray.length; i++) {
|
||||
this.reasonableAdviceService.deleteById(idArray[i]);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Result result = Result.failed("删除失败");
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
Result result = Result.success(1);
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
@RequestMapping("/view.do")
|
||||
public String doview(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
ReasonableAdvice reasonableAdvice = this.reasonableAdviceService.selectById(id);
|
||||
model.addAttribute("reasonableAdvice", reasonableAdvice);
|
||||
|
||||
String[] userleadid = reasonableAdvice.getUserLead().split(",");
|
||||
String[] usershelpid = reasonableAdvice.getUsersHelp().split(",");
|
||||
String solvername="";
|
||||
String solvername1="";
|
||||
for (String lid : userleadid) {
|
||||
User user = this.userService.getUserById(lid);
|
||||
if (user!=null) {
|
||||
solvername+=user.getCaption()+",";
|
||||
}
|
||||
}
|
||||
for (String hid : usershelpid) {
|
||||
User user = this.userService.getUserById(hid);
|
||||
if (user!=null) {
|
||||
solvername1+=user.getCaption()+",";
|
||||
}
|
||||
}
|
||||
model.addAttribute("solvername", solvername);
|
||||
model.addAttribute("solvername1", solvername1);
|
||||
return "/accident/reasonableAdviceView";
|
||||
}
|
||||
@RequestMapping("/showlisttake.do")
|
||||
public String showlisttake(HttpServletRequest request,Model model){
|
||||
return "/accident/reasonableAdviceListtake";
|
||||
}
|
||||
|
||||
@RequestMapping("/doedittake.do")
|
||||
public String doedittake(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
ReasonableAdvice reasonableAdvice = this.reasonableAdviceService.selectById(id);
|
||||
model.addAttribute("reasonableAdvice", reasonableAdvice);
|
||||
|
||||
String[] userleadid = reasonableAdvice.getUserLead().split(",");
|
||||
String[] usershelpid = reasonableAdvice.getUsersHelp().split(",");
|
||||
String solvername="";
|
||||
String solvername1="";
|
||||
for (String lid : userleadid) {
|
||||
User user = this.userService.getUserById(lid);
|
||||
if (user!=null) {
|
||||
solvername+=user.getCaption()+",";
|
||||
}
|
||||
}
|
||||
for (String hid : usershelpid) {
|
||||
User user = this.userService.getUserById(hid);
|
||||
if (user!=null) {
|
||||
solvername1+=user.getCaption()+",";
|
||||
}
|
||||
}
|
||||
model.addAttribute("solvername", solvername);
|
||||
model.addAttribute("solvername1", solvername1);
|
||||
return "/accident/reasonableAdviceEdittake";
|
||||
}
|
||||
|
||||
@RequestMapping("/downloadExcel.do")
|
||||
public String downloadExcel(HttpServletRequest request, HttpServletResponse response, Model model) {
|
||||
String orderstr=" order by insdt desc";
|
||||
String companyId =request.getParameter("unitId");
|
||||
String wherestr=" where 1=1";
|
||||
if(companyId!=null && !companyId.isEmpty()){
|
||||
//获取公司下所有子节点
|
||||
List<Unit> units = unitService.getUnitChildrenById(companyId);
|
||||
String companyids="";
|
||||
for(Unit unit : units){
|
||||
companyids += "'"+unit.getId()+"',";
|
||||
}
|
||||
if(companyids!=""){
|
||||
companyids = companyids.substring(0, companyids.length()-1);
|
||||
wherestr += " and unit_id in ("+companyids+") ";
|
||||
}
|
||||
}
|
||||
if(request.getParameter("search_name")!=null && !request.getParameter("search_name").isEmpty()){
|
||||
wherestr += " and name like '%"+request.getParameter("search_name")+"%' ";
|
||||
}
|
||||
if(request.getParameter("takeFlag")!=null && !request.getParameter("takeFlag").isEmpty()&&!"null".equals(request.getParameter("takeFlag"))){
|
||||
wherestr += " and take_flag = '"+request.getParameter("takeFlag")+"' ";
|
||||
}
|
||||
List<ReasonableAdvice> list = this.reasonableAdviceService.selectListByWhere(wherestr+orderstr);
|
||||
try {
|
||||
this.reasonableAdviceService.downloadExcel(response,list);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* 更新,启动合理化建议审核流程
|
||||
* */
|
||||
@RequestMapping("/startProcess.do")
|
||||
public String dostartProcess(HttpServletRequest request,Model model,
|
||||
@ModelAttribute ReasonableAdvice reasonableAdvice){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
if(reasonableAdvice.getId()==null || reasonableAdvice.getId().isEmpty()){
|
||||
reasonableAdvice.setId(CommUtil.getUUID());
|
||||
this.reasonableAdviceService.save(reasonableAdvice);
|
||||
}
|
||||
reasonableAdvice.setInsdt(CommUtil.nowDate());
|
||||
int result=0;
|
||||
try {
|
||||
result =this.reasonableAdviceService.startProcess(reasonableAdvice);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
}
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+reasonableAdvice.getId()+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
/**
|
||||
* 查看合理化建议处理流程详情
|
||||
* @param request
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/showProcessReasonableAdviceView.do")
|
||||
public String showProcessReasonableAdviceView(HttpServletRequest request,Model model){
|
||||
String reasonableAdviceId = request.getParameter("id");
|
||||
ReasonableAdvice reasonableAdvice = this.reasonableAdviceService.selectById(reasonableAdviceId);
|
||||
request.setAttribute("business", reasonableAdvice);
|
||||
List<BusinessUnitRecord> businessUnitRecords = new ArrayList<>();
|
||||
BusinessUnitRecord businessUnitRecord = new BusinessUnitRecord(reasonableAdvice);
|
||||
businessUnitRecords.add(businessUnitRecord);
|
||||
|
||||
List<WorkTask> workTasks=workflowProcessDefinitionService.getAllPDTask(reasonableAdvice.getProcessdefid(), "desc");
|
||||
List<String> keys=new ArrayList<>();
|
||||
for (WorkTask workTask : workTasks) {
|
||||
keys.add(workTask.getTaskKey());
|
||||
}
|
||||
Set set = new HashSet();
|
||||
set.addAll(keys);
|
||||
keys=new ArrayList<>();
|
||||
keys.addAll(set);
|
||||
for (String item : keys) {
|
||||
switch (item) {
|
||||
case BusinessUnit.UNIT_REASONABLE_ADVICE_HANDLE:
|
||||
List<BusinessUnitHandle> list = businessUnitHandleService.selectListByWhere("where businessid='"+reasonableAdviceId+"' ");
|
||||
for (BusinessUnitHandle businessUnitHandle : list) {
|
||||
businessUnitRecord = new BusinessUnitRecord(businessUnitHandle);
|
||||
businessUnitRecords.add(businessUnitRecord);
|
||||
}
|
||||
break;
|
||||
case BusinessUnit.UNIT_REASONABLE_ADVICE_AUDIT:
|
||||
List<BusinessUnitAudit> list_audit = businessUnitAuditService.selectListByWhere("where businessid='"+reasonableAdviceId+"' ");
|
||||
for (BusinessUnitAudit businessUnitAudit : list_audit) {
|
||||
businessUnitRecord = new BusinessUnitRecord(businessUnitAudit);
|
||||
businessUnitRecords.add(businessUnitRecord);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
//展示最新任务是否签收
|
||||
String processId = reasonableAdvice.getProcessid();
|
||||
List<HistoricTaskInstance> list=this.workflowService.getHistoryService() // 历史相关Service
|
||||
.createHistoricTaskInstanceQuery() // 创建历史任务实例查询
|
||||
.processInstanceId(processId) // 用流程实例id查询
|
||||
.list();
|
||||
for (HistoricTaskInstance task : list) {
|
||||
if (task.getAssignee()==null || task.getClaimTime()==null) {
|
||||
continue;
|
||||
}
|
||||
businessUnitRecord = new BusinessUnitRecord(task);
|
||||
businessUnitRecords.add(businessUnitRecord);
|
||||
}
|
||||
Collections.sort(businessUnitRecords, new Comparator<BusinessUnitRecord>() {
|
||||
public int compare(BusinessUnitRecord o1, BusinessUnitRecord o2) {
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
||||
try{
|
||||
Date dt1 = df.parse(o1.getInsdt());
|
||||
Date dt2 = df.parse(o2.getInsdt());
|
||||
if (dt1.getTime() > dt2.getTime()) {
|
||||
return 1;
|
||||
} else if (dt1.getTime() < dt2.getTime()) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
JSONArray jsonArray =JSONArray.fromObject(businessUnitRecords);
|
||||
model.addAttribute("businessUnitRecords",jsonArray);
|
||||
//检测流程实例是否结束,结束则历史记录最后节点变化
|
||||
long num =runtimeService.createProcessInstanceQuery().processInstanceId(reasonableAdvice.getProcessid()).count();
|
||||
if(num>0){
|
||||
model.addAttribute("finishFlag", false);
|
||||
}else{
|
||||
model.addAttribute("finishFlag", true);
|
||||
}
|
||||
|
||||
if(request.getParameter("inModal")!=null){
|
||||
//判断显示在流程处理模态框右侧
|
||||
return "accident/reasonableAdviceExecuteViewInModal";
|
||||
}else{
|
||||
return "accident/reasonableAdviceExecuteView";
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 显示合理化建议审核
|
||||
* */
|
||||
@RequestMapping("/showAuditReasonableAdvice.do")
|
||||
public String showAuditReasonableAdvice(HttpServletRequest request,Model model){
|
||||
String taskId = request.getParameter("taskId");
|
||||
String processInstanceId = request.getParameter("processInstanceId");
|
||||
BusinessUnitAudit businessUnitAudit=new BusinessUnitAudit();
|
||||
|
||||
Task task = this.taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||
model.addAttribute("taskName", task.getName());
|
||||
|
||||
businessUnitAudit.setId(CommUtil.getUUID());
|
||||
businessUnitAudit.setProcessid(processInstanceId);
|
||||
businessUnitAudit.setTaskid(taskId);
|
||||
ProcessInstance pInstance=runtimeService.createProcessInstanceQuery()
|
||||
.processInstanceId(processInstanceId)
|
||||
.singleResult();
|
||||
businessUnitAudit.setBusinessid(pInstance.getBusinessKey());
|
||||
businessUnitAudit.setTaskdefinitionkey(task.getTaskDefinitionKey());
|
||||
model.addAttribute("businessUnitAudit", businessUnitAudit);
|
||||
String reasonableAdviceId= pInstance.getBusinessKey();
|
||||
ReasonableAdvice reasonableAdvice = this.reasonableAdviceService.selectById(reasonableAdviceId);
|
||||
model.addAttribute("reasonableAdvice", reasonableAdvice);
|
||||
String[] userleadid = reasonableAdvice.getUserLead().split(",");
|
||||
String[] usershelpid = reasonableAdvice.getUsersHelp().split(",");
|
||||
String solvername="";
|
||||
String solvername1="";
|
||||
for (String lid : userleadid) {
|
||||
User user = this.userService.getUserById(lid);
|
||||
if (user!=null) {
|
||||
solvername+=user.getCaption()+",";
|
||||
}
|
||||
}
|
||||
for (String hid : usershelpid) {
|
||||
User user = this.userService.getUserById(hid);
|
||||
if (user!=null) {
|
||||
solvername1+=user.getCaption()+",";
|
||||
}
|
||||
}
|
||||
model.addAttribute("solvername", solvername);
|
||||
model.addAttribute("solvername1", solvername1);
|
||||
|
||||
//获取任务下一节点,若为任务节点,则显示目标用户div,否则不显示
|
||||
List<ActivityImpl> activityImpls=workflowProcessDefinitionService.getNEXTActivities(task.getProcessDefinitionId(), task.getTaskDefinitionKey());
|
||||
if (activityImpls.size()>0) {
|
||||
model.addAttribute("showTargetUsersFlag", true);
|
||||
}else{
|
||||
model.addAttribute("showTargetUsersFlag", false);
|
||||
}
|
||||
|
||||
return "accident/reasonableAdviceAudit";
|
||||
}
|
||||
/**
|
||||
* 流程流转
|
||||
* */
|
||||
@RequestMapping("/AuditReasonableAdvice.do")
|
||||
public String doAuditReasonableAdvice(HttpServletRequest request,Model model,
|
||||
@ModelAttribute BusinessUnitAudit businessUnitAudit){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
String acceptanceResults = request.getParameter("acceptanceResults");
|
||||
String sampling = request.getParameter("sampling");
|
||||
String reasonableAdviceId = businessUnitAudit.getBusinessid();
|
||||
ReasonableAdvice reasonableAdvice = this.reasonableAdviceService.selectById(reasonableAdviceId);
|
||||
int result = this.reasonableAdviceService.update(reasonableAdvice);
|
||||
businessUnitAudit.setInsuser(cu.getId());
|
||||
businessUnitAudit.setInsdt(CommUtil.nowDate());
|
||||
result =this.reasonableAdviceService.doAudit(businessUnitAudit);
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+businessUnitAudit.getId()+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
/**
|
||||
* 显示合理化建议业务处理
|
||||
* */
|
||||
@RequestMapping("/showReasonableAdviceHandle.do")
|
||||
public String showReasonableAdviceHandle(HttpServletRequest request,Model model){
|
||||
String taskId = request.getParameter("taskId");
|
||||
String processInstanceId = request.getParameter("processInstanceId");
|
||||
String unitId = request.getParameter("unitId");
|
||||
ProcessInstance pInstance=runtimeService.createProcessInstanceQuery()
|
||||
.processInstanceId(processInstanceId)
|
||||
.singleResult();
|
||||
BusinessUnitHandle businessUnitHandle = new BusinessUnitHandle();
|
||||
Task task = this.taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||
model.addAttribute("taskName", task.getName());
|
||||
List<BusinessUnitHandle> businessUnitHandles = this.businessUnitHandleService.selectListByWhere("where processid='"+processInstanceId+"' and taskId='"+taskId+"'");
|
||||
if(businessUnitHandles!= null && businessUnitHandles.size()>0){
|
||||
businessUnitHandle = businessUnitHandles.get(0);
|
||||
//若任务退回后,需更新新的任务id
|
||||
businessUnitHandle.setTaskid(taskId);
|
||||
}else{
|
||||
businessUnitHandle.setId(CommUtil.getUUID());
|
||||
businessUnitHandle.setProcessid(processInstanceId);
|
||||
businessUnitHandle.setTaskid(taskId);
|
||||
businessUnitHandle.setBusinessid(pInstance.getBusinessKey());
|
||||
businessUnitHandle.setTaskdefinitionkey(task.getTaskDefinitionKey());
|
||||
businessUnitHandle.setUnitid(unitId);
|
||||
}
|
||||
String userIds = businessUnitHandle.getTargetusers();
|
||||
if(userIds!= null && !userIds.isEmpty()){
|
||||
List<User> users = userService.selectListByWhere("where id in('"+userIds.replace(",", "','")+"')");
|
||||
String targetUsersName ="";
|
||||
for (User user : users) {
|
||||
if(!targetUsersName.isEmpty()){
|
||||
targetUsersName+=",";
|
||||
}
|
||||
targetUsersName+=user.getCaption();
|
||||
}
|
||||
model.addAttribute("targetUsersName", targetUsersName);
|
||||
}
|
||||
|
||||
model.addAttribute("businessUnitHandle", businessUnitHandle);
|
||||
model.addAttribute("nowDate", CommUtil.nowDate());
|
||||
String reasonableAdviceId = pInstance.getBusinessKey();
|
||||
ReasonableAdvice reasonableAdvice = this.reasonableAdviceService.selectById(reasonableAdviceId);
|
||||
List<BusinessUnitAudit> list = this.businessUnitAuditService.selectListByWhere("where businessId = '"+reasonableAdviceId+"' order by insdt desc ");
|
||||
if(list!=null && list.size()>0){
|
||||
model.addAttribute("businessUnitAudit", list.get(0));
|
||||
}
|
||||
model.addAttribute("reasonableAdvice", reasonableAdvice);
|
||||
return "accident/reasonableAdviceHandle";
|
||||
}
|
||||
/**
|
||||
* 流程流程,合理化建议业务处理提交
|
||||
* */
|
||||
@RequestMapping("/submitReasonableAdviceHandle.do")
|
||||
public String dosubmitReasonableAdviceHandle(HttpServletRequest request,Model model,
|
||||
@ModelAttribute BusinessUnitHandle businessUnitHandle){
|
||||
String routeNumStr=request.getParameter("routeNum");
|
||||
String passstatusStr=request.getParameter("passstatus");
|
||||
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
int result=0;
|
||||
if(!this.businessUnitHandleService.checkExit(businessUnitHandle)) {
|
||||
businessUnitHandle.setInsuser(cu.getId());
|
||||
businessUnitHandle.setInsdt(CommUtil.nowDate());
|
||||
result =this.businessUnitHandleService.save(businessUnitHandle);
|
||||
}else {
|
||||
result =this.businessUnitHandleService.update(businessUnitHandle);
|
||||
}
|
||||
|
||||
try {
|
||||
boolean passstatus = true;
|
||||
if(passstatusStr!=null && !"".equals(passstatusStr)){
|
||||
passstatus = Boolean.getBoolean(passstatusStr);
|
||||
}
|
||||
Map<String, Object> variables = new HashMap<String, Object>();
|
||||
variables =ActivitiUtil.fixVariableWithRoute(variables, passstatus, routeNumStr);
|
||||
variables.put(CommString.ACTI_KEK_Candidate_Users, businessUnitHandle.getTargetusers());
|
||||
variables.put(CommString.ACTI_KEK_Assignee, null);
|
||||
taskService.complete(businessUnitHandle.getTaskid(), variables);
|
||||
//发送消息
|
||||
if(businessUnitHandle.getTargetusers()!=null && !businessUnitHandle.getTargetusers().isEmpty()){
|
||||
//补全所有字段信息
|
||||
businessUnitHandle = businessUnitHandleService.selectById(businessUnitHandle.getId());
|
||||
BusinessUnitRecord businessUnitRecord = new BusinessUnitRecord(businessUnitHandle);
|
||||
businessUnitRecord.sendMessage(businessUnitHandle.getTargetusers(),"");
|
||||
}
|
||||
this.reasonableAdviceService.updateStatus(businessUnitHandle.getBusinessid(),passstatus);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
result=0;
|
||||
}
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+businessUnitHandle.getId()+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
}
|
||||
647
src/main/java/com/sipai/controller/accident/RoastController.java
Normal file
647
src/main/java/com/sipai/controller/accident/RoastController.java
Normal file
@ -0,0 +1,647 @@
|
||||
package com.sipai.controller.accident;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.accident.Roast;
|
||||
import com.sipai.entity.activiti.WorkTask;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.business.BusinessUnit;
|
||||
import com.sipai.entity.business.BusinessUnitAudit;
|
||||
import com.sipai.entity.business.BusinessUnitHandle;
|
||||
import com.sipai.entity.business.BusinessUnitRecord;
|
||||
import com.sipai.entity.user.Unit;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.accident.RoastService;
|
||||
import com.sipai.service.activiti.WorkflowProcessDefinitionService;
|
||||
import com.sipai.service.activiti.WorkflowService;
|
||||
import com.sipai.service.business.BusinessUnitAuditService;
|
||||
import com.sipai.service.business.BusinessUnitHandleService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.service.user.UserService;
|
||||
import com.sipai.tools.ActivitiUtil;
|
||||
import com.sipai.tools.CommString;
|
||||
import com.sipai.tools.CommUtil;
|
||||
import net.sf.json.JSONArray;
|
||||
import org.activiti.engine.RuntimeService;
|
||||
import org.activiti.engine.TaskService;
|
||||
import org.activiti.engine.history.HistoricTaskInstance;
|
||||
import org.activiti.engine.impl.pvm.process.ActivityImpl;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/accident/roast")
|
||||
public class RoastController {
|
||||
@Resource
|
||||
private RoastService roastService;
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private WorkflowProcessDefinitionService workflowProcessDefinitionService;
|
||||
@Resource
|
||||
private BusinessUnitHandleService businessUnitHandleService;
|
||||
@Resource
|
||||
private BusinessUnitAuditService businessUnitAuditService;
|
||||
@Resource
|
||||
private WorkflowService workflowService;
|
||||
@Resource
|
||||
private RuntimeService runtimeService;
|
||||
@Resource
|
||||
private TaskService taskService;
|
||||
|
||||
@RequestMapping("/showlist.do")
|
||||
public String showlist(HttpServletRequest request, Model model) {
|
||||
return "/accident/roastListApp";
|
||||
}
|
||||
|
||||
@RequestMapping("/showlistWeb.do")
|
||||
public String showlistWeb(HttpServletRequest request, Model model) {
|
||||
return "/accident/roastListWeb";
|
||||
}
|
||||
|
||||
@RequestMapping("/getlist.do")
|
||||
public ModelAndView getList(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required = false) String sort,
|
||||
@RequestParam(value = "order", required = false) String order) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String companyId = request.getParameter("unitId");
|
||||
if (sort == null) {
|
||||
sort = " insdt ";
|
||||
}
|
||||
if (order == null) {
|
||||
order = " desc ";
|
||||
}
|
||||
String orderstr = " order by " + sort + " " + order;
|
||||
|
||||
String wherestr = " where 1=1";
|
||||
if (companyId != null && !companyId.isEmpty()) {
|
||||
//获取公司下所有子节点
|
||||
List<Unit> units = unitService.getUnitChildrenById(companyId);
|
||||
String companyids = "";
|
||||
for (Unit unit : units) {
|
||||
companyids += "'" + unit.getId() + "',";
|
||||
}
|
||||
if (companyids != "") {
|
||||
companyids = companyids.substring(0, companyids.length() - 1);
|
||||
wherestr += " and unit_id in (" + companyids + ") ";
|
||||
}
|
||||
}
|
||||
if (request.getParameter("search_name") != null && !request.getParameter("search_name").isEmpty()) {
|
||||
wherestr += " and name like '%" + request.getParameter("search_name") + "%' ";
|
||||
}
|
||||
if (request.getParameter("takeFlag") != null && !request.getParameter("takeFlag").isEmpty()) {
|
||||
wherestr += " and take_flag = '" + request.getParameter("takeFlag") + "' ";
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<Roast> list = this.roastService.selectListByWhere(wherestr + orderstr);
|
||||
PageInfo<Roast> pi = new PageInfo<Roast>(list);
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
|
||||
String result = "{\"total\":" + pi.getTotal() + ",\"rows\":" + json + "}";
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/getlistApp.do")
|
||||
public ModelAndView getlistApp(HttpServletRequest request, Model model) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String companyId = request.getParameter("unitId");
|
||||
String orderstr = " order by insdt desc";
|
||||
String wherestr = " where 1=1";
|
||||
if (companyId != null && !companyId.isEmpty()) {
|
||||
//获取公司下所有子节点
|
||||
List<Unit> units = unitService.getUnitChildrenById(companyId);
|
||||
String companyids = "";
|
||||
for (Unit unit : units) {
|
||||
companyids += "'" + unit.getId() + "',";
|
||||
}
|
||||
if (companyids != "") {
|
||||
companyids = companyids.substring(0, companyids.length() - 1);
|
||||
wherestr += " and unit_id in (" + companyids + ") ";
|
||||
}
|
||||
}
|
||||
if (request.getParameter("search_name") != null && !request.getParameter("search_name").isEmpty()) {
|
||||
wherestr += " and name like '%" + request.getParameter("search_name") + "%' ";
|
||||
}
|
||||
if (request.getParameter("takeFlag") != null && !request.getParameter("takeFlag").isEmpty()) {
|
||||
wherestr += " and take_flag = '" + request.getParameter("takeFlag") + "' ";
|
||||
}
|
||||
List<Roast> list = this.roastService.selectListByWhere(wherestr + orderstr);
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
|
||||
// String result = "{\"total\":" + null + ",\"rows\":" + json + "}";
|
||||
model.addAttribute("result", json);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/doadd.do")
|
||||
public String doadd(HttpServletRequest request, Model model) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
model.addAttribute("userId", cu.getId());
|
||||
model.addAttribute("userName", cu.getCaption());
|
||||
return "/accident/roastAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/dosave.do")
|
||||
public String dosave(HttpServletRequest request, Model model,
|
||||
@ModelAttribute Roast roast) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String userId = cu.getId();
|
||||
roast.setId(CommUtil.getUUID());
|
||||
roast.setInsdt(CommUtil.nowDate());
|
||||
roast.setInsuser(userId);
|
||||
int code = this.roastService.save(roast);
|
||||
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("新增失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doedit.do")
|
||||
public String doedit(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
Roast roast = this.roastService.selectById(id);
|
||||
model.addAttribute("roast", roast);
|
||||
|
||||
String[] userleadid = roast.getUserLead().split(",");
|
||||
// String[] usershelpid = roast.getUsersHelp().split(",");
|
||||
String solvername = "";
|
||||
String solvername1 = "";
|
||||
for (String lid : userleadid) {
|
||||
User user = this.userService.getUserById(lid);
|
||||
if (user != null) {
|
||||
solvername += user.getCaption() + ",";
|
||||
}
|
||||
}
|
||||
/*for (String hid : usershelpid) {
|
||||
User user = this.userService.getUserById(hid);
|
||||
if (user != null) {
|
||||
solvername1 += user.getCaption() + ",";
|
||||
}
|
||||
}*/
|
||||
model.addAttribute("solvername", solvername);
|
||||
// model.addAttribute("solvername1", solvername1);
|
||||
return "/accident/roastEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/doupdate.do")
|
||||
public String doupdate(HttpServletRequest request, Model model,
|
||||
@ModelAttribute Roast roast) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String userId = cu.getId();
|
||||
|
||||
int code = this.roastService.update(roast);
|
||||
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("更新失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodelete.do")
|
||||
public String dodelete(HttpServletRequest request, Model model,
|
||||
@ModelAttribute Roast roast) {
|
||||
Result result = new Result();
|
||||
int code = this.roastService.deleteById(roast.getId());
|
||||
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("删除失败");
|
||||
}
|
||||
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodeletes.do")
|
||||
public String dodeletes(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "ids") String ids) {
|
||||
String[] idArray = ids.split(",");
|
||||
try {
|
||||
for (int i = 0; i < idArray.length; i++) {
|
||||
this.roastService.deleteById(idArray[i]);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Result result = Result.failed("删除失败");
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
Result result = Result.success(1);
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/view.do")
|
||||
public String doview(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
Roast roast = this.roastService.selectById(id);
|
||||
model.addAttribute("roast", roast);
|
||||
|
||||
String[] userleadid = roast.getUserLead().split(",");
|
||||
// String[] usershelpid = roast.getUsersHelp().split(",");
|
||||
String solvername = "";
|
||||
String solvername1 = "";
|
||||
for (String lid : userleadid) {
|
||||
User user = this.userService.getUserById(lid);
|
||||
if (user != null) {
|
||||
solvername += user.getCaption() + ",";
|
||||
}
|
||||
}
|
||||
/*for (String hid : usershelpid) {
|
||||
User user = this.userService.getUserById(hid);
|
||||
if (user != null) {
|
||||
solvername1 += user.getCaption() + ",";
|
||||
}
|
||||
}*/
|
||||
model.addAttribute("solvername", solvername);
|
||||
// model.addAttribute("solvername1", solvername1);
|
||||
return "/accident/roastView";
|
||||
}
|
||||
|
||||
@RequestMapping("/showlisttake.do")
|
||||
public String showlisttake(HttpServletRequest request, Model model) {
|
||||
return "/accident/roastListtake";
|
||||
}
|
||||
|
||||
@RequestMapping("/doedittake.do")
|
||||
public String doedittake(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
Roast roast = this.roastService.selectById(id);
|
||||
model.addAttribute("roast", roast);
|
||||
|
||||
String[] userleadid = roast.getUserLead().split(",");
|
||||
String[] usershelpid = roast.getUsersHelp().split(",");
|
||||
String solvername = "";
|
||||
String solvername1 = "";
|
||||
for (String lid : userleadid) {
|
||||
User user = this.userService.getUserById(lid);
|
||||
if (user != null) {
|
||||
solvername += user.getCaption() + ",";
|
||||
}
|
||||
}
|
||||
for (String hid : usershelpid) {
|
||||
User user = this.userService.getUserById(hid);
|
||||
if (user != null) {
|
||||
solvername1 += user.getCaption() + ",";
|
||||
}
|
||||
}
|
||||
model.addAttribute("solvername", solvername);
|
||||
model.addAttribute("solvername1", solvername1);
|
||||
return "/accident/roastEdittake";
|
||||
}
|
||||
|
||||
@RequestMapping("/downloadExcel.do")
|
||||
public String downloadExcel(HttpServletRequest request, HttpServletResponse response, Model model) {
|
||||
String orderstr = " order by insdt desc";
|
||||
String companyId = request.getParameter("unitId");
|
||||
String wherestr = " where 1=1";
|
||||
if (companyId != null && !companyId.isEmpty()) {
|
||||
//获取公司下所有子节点
|
||||
List<Unit> units = unitService.getUnitChildrenById(companyId);
|
||||
String companyids = "";
|
||||
for (Unit unit : units) {
|
||||
companyids += "'" + unit.getId() + "',";
|
||||
}
|
||||
if (companyids != "") {
|
||||
companyids = companyids.substring(0, companyids.length() - 1);
|
||||
wherestr += " and unit_id in (" + companyids + ") ";
|
||||
}
|
||||
}
|
||||
if (request.getParameter("search_name") != null && !request.getParameter("search_name").isEmpty()) {
|
||||
wherestr += " and name like '%" + request.getParameter("search_name") + "%' ";
|
||||
}
|
||||
if (request.getParameter("takeFlag") != null && !request.getParameter("takeFlag").isEmpty() && !"null".equals(request.getParameter("takeFlag"))) {
|
||||
wherestr += " and take_flag = '" + request.getParameter("takeFlag") + "' ";
|
||||
}
|
||||
List<Roast> list = this.roastService.selectListByWhere(wherestr + orderstr);
|
||||
try {
|
||||
this.roastService.downloadExcel(response, list);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新,启动合理化建议审核流程
|
||||
*/
|
||||
@RequestMapping("/startProcess.do")
|
||||
public String dostartProcess(HttpServletRequest request, Model model,
|
||||
@ModelAttribute Roast roast) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
if (roast.getId() == null || roast.getId().isEmpty()) {
|
||||
roast.setId(CommUtil.getUUID());
|
||||
this.roastService.save(roast);
|
||||
}
|
||||
roast.setInsuser(cu.getId());
|
||||
roast.setInsdt(CommUtil.nowDate());
|
||||
int result = 0;
|
||||
try {
|
||||
result = this.roastService.startProcess(roast);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
}
|
||||
String resstr = "{\"res\":\"" + result + "\",\"id\":\"" + roast.getId() + "\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看合理化建议处理流程详情
|
||||
*
|
||||
* @param request
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/showProcessRoastView.do")
|
||||
public String showProcessRoastView(HttpServletRequest request, Model model) {
|
||||
String roastId = request.getParameter("id");
|
||||
Roast roast = this.roastService.selectById(roastId);
|
||||
request.setAttribute("business", roast);
|
||||
List<BusinessUnitRecord> businessUnitRecords = new ArrayList<>();
|
||||
BusinessUnitRecord businessUnitRecord = new BusinessUnitRecord(roast);
|
||||
businessUnitRecords.add(businessUnitRecord);
|
||||
|
||||
List<WorkTask> workTasks = workflowProcessDefinitionService.getAllPDTask(roast.getProcessdefid(), "desc");
|
||||
List<String> keys = new ArrayList<>();
|
||||
for (WorkTask workTask : workTasks) {
|
||||
keys.add(workTask.getTaskKey());
|
||||
}
|
||||
Set set = new HashSet();
|
||||
set.addAll(keys);
|
||||
keys = new ArrayList<>();
|
||||
keys.addAll(set);
|
||||
for (String item : keys) {
|
||||
switch (item) {
|
||||
case BusinessUnit.UNIT_ROAST_HANDLE:
|
||||
List<BusinessUnitHandle> list = businessUnitHandleService.selectListByWhere("where businessid='" + roastId + "' ");
|
||||
for (BusinessUnitHandle businessUnitHandle : list) {
|
||||
businessUnitRecord = new BusinessUnitRecord(businessUnitHandle);
|
||||
businessUnitRecords.add(businessUnitRecord);
|
||||
}
|
||||
break;
|
||||
case BusinessUnit.UNIT_ROAST_AUDIT:
|
||||
List<BusinessUnitAudit> list_audit = businessUnitAuditService.selectListByWhere("where businessid='" + roastId + "' ");
|
||||
for (BusinessUnitAudit businessUnitAudit : list_audit) {
|
||||
businessUnitRecord = new BusinessUnitRecord(businessUnitAudit);
|
||||
businessUnitRecords.add(businessUnitRecord);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
//展示最新任务是否签收
|
||||
String processId = roast.getProcessid();
|
||||
List<HistoricTaskInstance> list = this.workflowService.getHistoryService() // 历史相关Service
|
||||
.createHistoricTaskInstanceQuery() // 创建历史任务实例查询
|
||||
.processInstanceId(processId) // 用流程实例id查询
|
||||
.list();
|
||||
for (HistoricTaskInstance task : list) {
|
||||
if (task.getAssignee() == null || task.getClaimTime() == null) {
|
||||
continue;
|
||||
}
|
||||
businessUnitRecord = new BusinessUnitRecord(task);
|
||||
businessUnitRecords.add(businessUnitRecord);
|
||||
}
|
||||
Collections.sort(businessUnitRecords, new Comparator<BusinessUnitRecord>() {
|
||||
public int compare(BusinessUnitRecord o1, BusinessUnitRecord o2) {
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
||||
try {
|
||||
Date dt1 = df.parse(o1.getInsdt());
|
||||
Date dt2 = df.parse(o2.getInsdt());
|
||||
if (dt1.getTime() > dt2.getTime()) {
|
||||
return 1;
|
||||
} else if (dt1.getTime() < dt2.getTime()) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
JSONArray jsonArray = JSONArray.fromObject(businessUnitRecords);
|
||||
model.addAttribute("businessUnitRecords", jsonArray);
|
||||
//检测流程实例是否结束,结束则历史记录最后节点变化
|
||||
long num = runtimeService.createProcessInstanceQuery().processInstanceId(roast.getProcessid()).count();
|
||||
if (num > 0) {
|
||||
model.addAttribute("finishFlag", false);
|
||||
} else {
|
||||
model.addAttribute("finishFlag", true);
|
||||
}
|
||||
|
||||
if (request.getParameter("inModal") != null) {
|
||||
//判断显示在流程处理模态框右侧
|
||||
return "accident/roastExecuteViewInModal";
|
||||
} else {
|
||||
return "accident/roastExecuteView";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示合理化建议审核
|
||||
*/
|
||||
@RequestMapping("/showAuditRoast.do")
|
||||
public String showAuditRoast(HttpServletRequest request, Model model) {
|
||||
String taskId = request.getParameter("taskId");
|
||||
String processInstanceId = request.getParameter("processInstanceId");
|
||||
BusinessUnitAudit businessUnitAudit = new BusinessUnitAudit();
|
||||
|
||||
Task task = this.taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||
model.addAttribute("taskName", task.getName());
|
||||
|
||||
businessUnitAudit.setId(CommUtil.getUUID());
|
||||
businessUnitAudit.setProcessid(processInstanceId);
|
||||
businessUnitAudit.setTaskid(taskId);
|
||||
ProcessInstance pInstance = runtimeService.createProcessInstanceQuery()
|
||||
.processInstanceId(processInstanceId)
|
||||
.singleResult();
|
||||
businessUnitAudit.setBusinessid(pInstance.getBusinessKey());
|
||||
businessUnitAudit.setTaskdefinitionkey(task.getTaskDefinitionKey());
|
||||
model.addAttribute("businessUnitAudit", businessUnitAudit);
|
||||
String roastId = pInstance.getBusinessKey();
|
||||
Roast roast = this.roastService.selectById(roastId);
|
||||
model.addAttribute("roast", roast);
|
||||
String[] userleadid = roast.getUserLead().split(",");
|
||||
// String[] usershelpid = roast.getUsersHelp().split(",");
|
||||
String solvername = "";
|
||||
String solvername1 = "";
|
||||
for (String lid : userleadid) {
|
||||
User user = this.userService.getUserById(lid);
|
||||
if (user != null) {
|
||||
solvername += user.getCaption() + ",";
|
||||
}
|
||||
}
|
||||
/*for (String hid : usershelpid) {
|
||||
User user = this.userService.getUserById(hid);
|
||||
if (user != null) {
|
||||
solvername1 += user.getCaption() + ",";
|
||||
}
|
||||
}*/
|
||||
model.addAttribute("solvername", solvername);
|
||||
// model.addAttribute("solvername1", solvername1);
|
||||
|
||||
//获取任务下一节点,若为任务节点,则显示目标用户div,否则不显示
|
||||
List<ActivityImpl> activityImpls = workflowProcessDefinitionService.getNEXTActivities(task.getProcessDefinitionId(), task.getTaskDefinitionKey());
|
||||
if (activityImpls.size() > 0) {
|
||||
model.addAttribute("showTargetUsersFlag", true);
|
||||
} else {
|
||||
model.addAttribute("showTargetUsersFlag", false);
|
||||
}
|
||||
|
||||
return "accident/roastAudit";
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程流转
|
||||
*/
|
||||
@RequestMapping("/AuditRoast.do")
|
||||
public String doAuditRoast(HttpServletRequest request, Model model,
|
||||
@ModelAttribute BusinessUnitAudit businessUnitAudit) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String acceptanceResults = request.getParameter("acceptanceResults");
|
||||
String sampling = request.getParameter("sampling");
|
||||
String roastId = businessUnitAudit.getBusinessid();
|
||||
Roast roast = this.roastService.selectById(roastId);
|
||||
int result = this.roastService.update(roast);
|
||||
businessUnitAudit.setInsuser(cu.getId());
|
||||
businessUnitAudit.setInsdt(CommUtil.nowDate());
|
||||
result = this.roastService.doAudit(businessUnitAudit);
|
||||
String resstr = "{\"res\":\"" + result + "\",\"id\":\"" + businessUnitAudit.getId() + "\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示合理化建议业务处理
|
||||
*/
|
||||
@RequestMapping("/showRoastHandle.do")
|
||||
public String showRoastHandle(HttpServletRequest request, Model model) {
|
||||
String taskId = request.getParameter("taskId");
|
||||
String processInstanceId = request.getParameter("processInstanceId");
|
||||
String unitId = request.getParameter("unitId");
|
||||
ProcessInstance pInstance = runtimeService.createProcessInstanceQuery()
|
||||
.processInstanceId(processInstanceId)
|
||||
.singleResult();
|
||||
BusinessUnitHandle businessUnitHandle = new BusinessUnitHandle();
|
||||
Task task = this.taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||
model.addAttribute("taskName", task.getName());
|
||||
List<BusinessUnitHandle> businessUnitHandles = this.businessUnitHandleService.selectListByWhere("where processid='" + processInstanceId + "' and taskId='" + taskId + "'");
|
||||
if (businessUnitHandles != null && businessUnitHandles.size() > 0) {
|
||||
businessUnitHandle = businessUnitHandles.get(0);
|
||||
//若任务退回后,需更新新的任务id
|
||||
businessUnitHandle.setTaskid(taskId);
|
||||
} else {
|
||||
businessUnitHandle.setId(CommUtil.getUUID());
|
||||
businessUnitHandle.setProcessid(processInstanceId);
|
||||
businessUnitHandle.setTaskid(taskId);
|
||||
businessUnitHandle.setBusinessid(pInstance.getBusinessKey());
|
||||
businessUnitHandle.setTaskdefinitionkey(task.getTaskDefinitionKey());
|
||||
businessUnitHandle.setUnitid(unitId);
|
||||
}
|
||||
String userIds = businessUnitHandle.getTargetusers();
|
||||
if (userIds != null && !userIds.isEmpty()) {
|
||||
List<User> users = userService.selectListByWhere("where id in('" + userIds.replace(",", "','") + "')");
|
||||
String targetUsersName = "";
|
||||
for (User user : users) {
|
||||
if (!targetUsersName.isEmpty()) {
|
||||
targetUsersName += ",";
|
||||
}
|
||||
targetUsersName += user.getCaption();
|
||||
}
|
||||
model.addAttribute("targetUsersName", targetUsersName);
|
||||
}
|
||||
|
||||
model.addAttribute("businessUnitHandle", businessUnitHandle);
|
||||
model.addAttribute("nowDate", CommUtil.nowDate());
|
||||
String roastId = pInstance.getBusinessKey();
|
||||
Roast roast = this.roastService.selectById(roastId);
|
||||
List<BusinessUnitAudit> list = this.businessUnitAuditService.selectListByWhere("where businessId = '" + roastId + "' order by insdt desc ");
|
||||
if (list != null && list.size() > 0) {
|
||||
model.addAttribute("businessUnitAudit", list.get(0));
|
||||
}
|
||||
model.addAttribute("roast", roast);
|
||||
return "accident/roastHandle";
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程流程,合理化建议业务处理提交
|
||||
*/
|
||||
@RequestMapping("/submitRoastHandle.do")
|
||||
public String dosubmitRoastHandle(HttpServletRequest request, Model model,
|
||||
@ModelAttribute BusinessUnitHandle businessUnitHandle) {
|
||||
String routeNumStr = request.getParameter("routeNum");
|
||||
String passstatusStr = request.getParameter("passstatus");
|
||||
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
int result = 0;
|
||||
if (!this.businessUnitHandleService.checkExit(businessUnitHandle)) {
|
||||
businessUnitHandle.setInsuser(cu.getId());
|
||||
businessUnitHandle.setInsdt(CommUtil.nowDate());
|
||||
result = this.businessUnitHandleService.save(businessUnitHandle);
|
||||
} else {
|
||||
result = this.businessUnitHandleService.update(businessUnitHandle);
|
||||
}
|
||||
|
||||
try {
|
||||
boolean passstatus = true;
|
||||
if (passstatusStr != null && !"".equals(passstatusStr)) {
|
||||
passstatus = Boolean.getBoolean(passstatusStr);
|
||||
}
|
||||
Map<String, Object> variables = new HashMap<String, Object>();
|
||||
variables = ActivitiUtil.fixVariableWithRoute(variables, passstatus, routeNumStr);
|
||||
variables.put(CommString.ACTI_KEK_Candidate_Users, businessUnitHandle.getTargetusers());
|
||||
variables.put(CommString.ACTI_KEK_Assignee, null);
|
||||
taskService.complete(businessUnitHandle.getTaskid(), variables);
|
||||
//发送消息
|
||||
if (businessUnitHandle.getTargetusers() != null && !businessUnitHandle.getTargetusers().isEmpty()) {
|
||||
//补全所有字段信息
|
||||
businessUnitHandle = businessUnitHandleService.selectById(businessUnitHandle.getId());
|
||||
BusinessUnitRecord businessUnitRecord = new BusinessUnitRecord(businessUnitHandle);
|
||||
businessUnitRecord.sendMessage(businessUnitHandle.getTargetusers(), "");
|
||||
}
|
||||
this.roastService.updateStatus(businessUnitHandle.getBusinessid(), passstatus);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
result = 0;
|
||||
}
|
||||
String resstr = "{\"res\":\"" + result + "\",\"id\":\"" + businessUnitHandle.getId() + "\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,504 @@
|
||||
package com.sipai.controller.accident;
|
||||
|
||||
import com.sipai.entity.equipment.EquipmentCard;
|
||||
import com.sipai.entity.maintenance.Abnormity;
|
||||
import com.sipai.entity.scada.MPoint;
|
||||
import com.sipai.entity.scada.MPointHistory;
|
||||
import com.sipai.entity.user.Company;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.entity.workorder.WorkorderDetail;
|
||||
import com.sipai.service.company.CompanyService;
|
||||
import com.sipai.service.equipment.EquipmentCardService;
|
||||
import com.sipai.service.maintenance.AbnormityService;
|
||||
import com.sipai.service.scada.MPointHistoryService;
|
||||
import com.sipai.service.scada.MPointService;
|
||||
import com.sipai.service.workorder.WorkorderDetailService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
import com.sipai.tools.SpringContextUtil;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 手动计算故障率使用
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/gzy/handle")
|
||||
public class TestKpiController {
|
||||
|
||||
@Resource
|
||||
private EquipmentCardService equipmentCardService ;
|
||||
@Resource
|
||||
private CompanyService companyService ;
|
||||
@Resource
|
||||
private WorkorderDetailService workorderDetailService ;
|
||||
@Resource
|
||||
private AbnormityService abnormityService ;
|
||||
@Resource
|
||||
private MPointService mPointService ;
|
||||
@Resource
|
||||
private MPointHistoryService mPointHistoryService ;
|
||||
|
||||
|
||||
//http://202.105.18.155:9101/FSHB_CC/gzy/handle/update.do?st=2023-09-01
|
||||
@RequestMapping("/update.do")
|
||||
public String update(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "st", required = true) String st) {
|
||||
String sdt = st;
|
||||
List<Company> list = companyService.selectListByWhere("where 1=1 and type = 'B'");
|
||||
for (Company company : list) {
|
||||
String ids = "";//符合条件的设备ids
|
||||
double num = 100;//任务完成率
|
||||
long time = 0;//故障时间
|
||||
|
||||
/**
|
||||
* 通用设备
|
||||
*/
|
||||
ids = "";//清空
|
||||
num = 100;//还原成100
|
||||
time = 0;
|
||||
List<EquipmentCard> list1 = equipmentCardService.selectSimpleListByWhere("where bizid = '" + company.getId() + "' and (remark = '通用设备')");
|
||||
if (list1 != null && list1.size() > 0) {
|
||||
for (int i = 0; i < list1.size(); i++) {
|
||||
ids += "'" + list1.get(i).getId() + "',";
|
||||
}
|
||||
if (ids != null && !ids.equals("")) {
|
||||
ids = ids.substring(0, ids.length() - 1);
|
||||
}
|
||||
//完成设备工单数
|
||||
List<WorkorderDetail> list1_f = workorderDetailService.selectSimpleListByWhere("where type='repair' and datediff(month,[insdt],'" + sdt + "')=0 and unit_id = '" + company.getId() + "' and equipment_id in (" + ids + ") and (status = '" + WorkorderDetail.Status_Compete + "' or status='" + WorkorderDetail.Status_Finish + "')");
|
||||
//所有设备工单数
|
||||
List<WorkorderDetail> list1_all = workorderDetailService.selectSimpleListByWhere("where type='repair' and datediff(month,[insdt],'" + sdt + "')=0 and unit_id = '" + company.getId() + "' and equipment_id in (" + ids + ") ");
|
||||
if (list1_all != null && list1_all.size() > 0) {
|
||||
num = (Double.valueOf(list1_f.size())) / (Double.valueOf(list1_all.size())) * 100;
|
||||
} else {
|
||||
// 百分之百
|
||||
num = 100;
|
||||
}
|
||||
|
||||
//计算当月最大数
|
||||
int maxday = CommUtil.getDaysByYearMonth(Integer.parseInt(sdt.substring(0, 4)), Integer.parseInt(sdt.substring(5, 7)));
|
||||
//开始时间
|
||||
String sdtTime = sdt.substring(0, 7) + "-01 00:00:00";
|
||||
//结束时间
|
||||
String edtTime = sdt.substring(0, 7) + "-" + maxday + " 23:59:59";
|
||||
|
||||
//计算故障时间
|
||||
for (WorkorderDetail workorderDetail : list1_all) {
|
||||
String s_dt = workorderDetail.getInsdt();//开始时间 有异常单按异常单的上报时间,没有异常单按维修单下发时间
|
||||
String e_dt = workorderDetail.getCompleteDate();//结束时间 按验收通过时间
|
||||
|
||||
if (workorderDetail.getAbnormityId() != null) {
|
||||
Abnormity abnormity = abnormityService.selectSimpleById(workorderDetail.getAbnormityId());
|
||||
if (abnormity != null) {
|
||||
s_dt = abnormity.getInsdt();//异常上报时间
|
||||
}
|
||||
}
|
||||
|
||||
//当月下发,当月完成---故障时间=验收时间减去下发时间
|
||||
if (CommUtil.compare_time(sdtTime, s_dt) == -1 && e_dt != null && ((e_dt.substring(0, 7)).equals(edtTime.substring(0, 7)))) {
|
||||
time += CommUtil.getDays2(e_dt, s_dt, "second");
|
||||
}
|
||||
//当月下发,当月以后完成---故障时间=下发时间到月底
|
||||
if (CommUtil.compare_time(sdtTime, s_dt) == -1 && e_dt != null && CommUtil.compare_time(edtTime, e_dt) == -1) {
|
||||
time += CommUtil.getDays2(edtTime, s_dt, "second");
|
||||
}
|
||||
//以前下发,当月完成---故障时间=月初到验收时间
|
||||
if (CommUtil.compare_time(s_dt, sdtTime) == -1 && e_dt != null && ((e_dt.substring(0, 7)).equals(edtTime.substring(0, 7)))) {
|
||||
time += CommUtil.getDays2(e_dt, sdtTime, "second");
|
||||
}
|
||||
//以前下发,当月以后完成---故障时间=当月总时间
|
||||
if (CommUtil.compare_time(s_dt, sdtTime) == -1 && e_dt != null && CommUtil.compare_time(edtTime, e_dt) == -1) {
|
||||
time += CommUtil.getDays2(edtTime, sdtTime, "second");
|
||||
}
|
||||
if (CommUtil.compare_time(sdtTime, s_dt) == -1 && e_dt == null) {
|
||||
time += CommUtil.getDays2(CommUtil.nowDate(), s_dt, "second");
|
||||
}
|
||||
//以前下发,未完成---故障时间=月初到当前时间
|
||||
if (CommUtil.compare_time(s_dt, sdtTime) == -1 && e_dt == null) {
|
||||
time += CommUtil.getDays2(CommUtil.nowDate(), sdtTime, "second");
|
||||
}
|
||||
}
|
||||
|
||||
long all_second = CommUtil.getDays2(edtTime, sdtTime, "second");
|
||||
//总设备数
|
||||
long all_size = list1.size();
|
||||
//所有设备总时间
|
||||
long all_time = all_second * all_size;
|
||||
|
||||
//计算完好率(到秒)
|
||||
double rateD = ((all_time - time) * 1.0 / all_time * 100);
|
||||
|
||||
// System.out.println("通用设备_任务合格率:" + num);
|
||||
// System.out.println("通用设备_故障率:" + (100 - rateD));
|
||||
|
||||
save("FSCCSK_KPI_TYSBYXDF1A", num, company.getId(), sdtTime);
|
||||
save("FSCCSK_KPI_TYSBYXDF2A", (100 - rateD), company.getId(), sdtTime);
|
||||
save_his("FSCCSK_KPI_TYSBYXDF1A", num, company.getId(), sdtTime);
|
||||
save_his("FSCCSK_KPI_TYSBYXDF2A", (100 - rateD), company.getId(), sdtTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 气动阀、液控阀
|
||||
*/
|
||||
ids = "";//清空
|
||||
num = 100;//还原成100
|
||||
time = 0;
|
||||
List<EquipmentCard> list2 = equipmentCardService.selectSimpleListByWhere("where bizid = '" + company.getId() + "' and (remark = '气动阀' or remark = '液控阀')");
|
||||
if (list2 != null && list2.size() > 0) {
|
||||
for (int i = 0; i < list2.size(); i++) {
|
||||
ids += "'" + list2.get(i).getId() + "',";
|
||||
}
|
||||
if (ids != null && !ids.equals("")) {
|
||||
ids = ids.substring(0, ids.length() - 1);
|
||||
}
|
||||
//完成设备工单数
|
||||
List<WorkorderDetail> list1_f = workorderDetailService.selectSimpleListByWhere("where type='repair' and datediff(month,[insdt],'" + sdt + "')=0 and unit_id = '" + company.getId() + "' and equipment_id in (" + ids + ") and (status = '" + WorkorderDetail.Status_Compete + "' or status='" + WorkorderDetail.Status_Finish + "')");
|
||||
//所有设备工单数
|
||||
List<WorkorderDetail> list1_all = workorderDetailService.selectSimpleListByWhere("where type='repair' and datediff(month,[insdt],'" + sdt + "')=0 and unit_id = '" + company.getId() + "' and equipment_id in (" + ids + ") ");
|
||||
if (list1_all != null && list1_all.size() > 0) {
|
||||
num = (Double.valueOf(list1_f.size())) / (Double.valueOf(list1_all.size())) * 100;
|
||||
} else {
|
||||
// 百分之百
|
||||
num = 100;
|
||||
}
|
||||
|
||||
//计算当月最大数
|
||||
int maxday = CommUtil.getDaysByYearMonth(Integer.parseInt(sdt.substring(0, 4)), Integer.parseInt(sdt.substring(5, 7)));
|
||||
//开始时间
|
||||
String sdtTime = sdt.substring(0, 7) + "-01 00:00:00";
|
||||
//结束时间
|
||||
String edtTime = sdt.substring(0, 7) + "-" + maxday + " 23:59:59";
|
||||
|
||||
//计算故障时间
|
||||
for (WorkorderDetail workorderDetail : list1_all) {
|
||||
String s_dt = workorderDetail.getInsdt();//开始时间 有异常单按异常单的上报时间,没有异常单按维修单下发时间
|
||||
String e_dt = workorderDetail.getCompleteDate();//结束时间 按验收通过时间
|
||||
|
||||
if (workorderDetail.getAbnormityId() != null) {
|
||||
Abnormity abnormity = abnormityService.selectSimpleById(workorderDetail.getAbnormityId());
|
||||
if (abnormity != null) {
|
||||
s_dt = abnormity.getInsdt();//异常上报时间
|
||||
}
|
||||
}
|
||||
|
||||
//当月下发,当月完成---故障时间=验收时间减去下发时间
|
||||
if (CommUtil.compare_time(sdtTime, s_dt) == -1 && e_dt != null && ((e_dt.substring(0, 7)).equals(edtTime.substring(0, 7)))) {
|
||||
time += CommUtil.getDays2(e_dt, s_dt, "second");
|
||||
}
|
||||
//当月下发,当月以后完成---故障时间=下发时间到月底
|
||||
if (CommUtil.compare_time(sdtTime, s_dt) == -1 && e_dt != null && CommUtil.compare_time(edtTime, e_dt) == -1) {
|
||||
time += CommUtil.getDays2(edtTime, s_dt, "second");
|
||||
}
|
||||
//以前下发,当月完成---故障时间=月初到验收时间
|
||||
if (CommUtil.compare_time(s_dt, sdtTime) == -1 && e_dt != null && ((e_dt.substring(0, 7)).equals(edtTime.substring(0, 7)))) {
|
||||
time += CommUtil.getDays2(e_dt, sdtTime, "second");
|
||||
}
|
||||
//以前下发,当月以后完成---故障时间=当月总时间
|
||||
if (CommUtil.compare_time(s_dt, sdtTime) == -1 && e_dt != null && CommUtil.compare_time(edtTime, e_dt) == -1) {
|
||||
time += CommUtil.getDays2(edtTime, sdtTime, "second");
|
||||
}
|
||||
if (CommUtil.compare_time(sdtTime, s_dt) == -1 && e_dt == null) {
|
||||
time += CommUtil.getDays2(CommUtil.nowDate(), s_dt, "second");
|
||||
}
|
||||
//以前下发,未完成---故障时间=月初到当前时间
|
||||
if (CommUtil.compare_time(s_dt, sdtTime) == -1 && e_dt == null) {
|
||||
time += CommUtil.getDays2(CommUtil.nowDate(), sdtTime, "second");
|
||||
}
|
||||
}
|
||||
|
||||
long all_second = CommUtil.getDays2(edtTime, sdtTime, "second");
|
||||
//总设备数
|
||||
long all_size = list1.size();
|
||||
//所有设备总时间
|
||||
long all_time = all_second * all_size;
|
||||
|
||||
//计算完好率(到秒)
|
||||
double rateD = ((all_time - time) * 1.0 / all_time * 100);
|
||||
|
||||
// System.out.println("气动阀、液控阀_任务合格率:" + num);
|
||||
// System.out.println("气动阀、液控阀_故障率:" + (100 - rateD));
|
||||
|
||||
save("FSCCSK_KPI_LCQDFZBFYXDF1A", num, company.getId(), sdtTime);
|
||||
save("FSCCSK_KPI_LCQDFZBFYXDF2A", (100 - rateD), company.getId(), sdtTime);
|
||||
save_his("FSCCSK_KPI_LCQDFZBFYXDF1A", num, company.getId(), sdtTime);
|
||||
save_his("FSCCSK_KPI_LCQDFZBFYXDF2A", (100 - rateD), company.getId(), sdtTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 滤阀
|
||||
*/
|
||||
ids = "";//清空
|
||||
num = 100;//还原成100
|
||||
time = 0;
|
||||
List<EquipmentCard> list3 = equipmentCardService.selectSimpleListByWhere("where bizid = '" + company.getId() + "' and (remark = '滤阀')");
|
||||
if (list3 != null && list3.size() > 0) {
|
||||
for (int i = 0; i < list3.size(); i++) {
|
||||
ids += "'" + list3.get(i).getId() + "',";
|
||||
}
|
||||
if (ids != null && !ids.equals("")) {
|
||||
ids = ids.substring(0, ids.length() - 1);
|
||||
}
|
||||
//完成设备工单数
|
||||
List<WorkorderDetail> list1_f = workorderDetailService.selectSimpleListByWhere("where type='repair' and datediff(month,[insdt],'" + sdt + "')=0 and unit_id = '" + company.getId() + "' and equipment_id in (" + ids + ") and (status = '" + WorkorderDetail.Status_Compete + "' or status='" + WorkorderDetail.Status_Finish + "')");
|
||||
//所有设备工单数
|
||||
List<WorkorderDetail> list1_all = workorderDetailService.selectSimpleListByWhere("where type='repair' and datediff(month,[insdt],'" + sdt + "')=0 and unit_id = '" + company.getId() + "' and equipment_id in (" + ids + ") ");
|
||||
if (list1_all != null && list1_all.size() > 0) {
|
||||
num = (Double.valueOf(list1_f.size())) / (Double.valueOf(list1_all.size())) * 100;
|
||||
} else {
|
||||
// 百分之百
|
||||
num = 100;
|
||||
}
|
||||
|
||||
//计算当月最大数
|
||||
int maxday = CommUtil.getDaysByYearMonth(Integer.parseInt(sdt.substring(0, 4)), Integer.parseInt(sdt.substring(5, 7)));
|
||||
//开始时间
|
||||
String sdtTime = sdt.substring(0, 7) + "-01 00:00:00";
|
||||
//结束时间
|
||||
String edtTime = sdt.substring(0, 7) + "-" + maxday + " 23:59:59";
|
||||
|
||||
//计算故障时间
|
||||
for (WorkorderDetail workorderDetail : list1_all) {
|
||||
String s_dt = workorderDetail.getInsdt();//开始时间 有异常单按异常单的上报时间,没有异常单按维修单下发时间
|
||||
String e_dt = workorderDetail.getCompleteDate();//结束时间 按验收通过时间
|
||||
|
||||
if (workorderDetail.getAbnormityId() != null) {
|
||||
Abnormity abnormity = abnormityService.selectSimpleById(workorderDetail.getAbnormityId());
|
||||
if (abnormity != null) {
|
||||
s_dt = abnormity.getInsdt();//异常上报时间
|
||||
}
|
||||
}
|
||||
|
||||
//当月下发,当月完成---故障时间=验收时间减去下发时间
|
||||
if (CommUtil.compare_time(sdtTime, s_dt) == -1 && e_dt != null && ((e_dt.substring(0, 7)).equals(edtTime.substring(0, 7)))) {
|
||||
time += CommUtil.getDays2(e_dt, s_dt, "second");
|
||||
}
|
||||
//当月下发,当月以后完成---故障时间=下发时间到月底
|
||||
if (CommUtil.compare_time(sdtTime, s_dt) == -1 && e_dt != null && CommUtil.compare_time(edtTime, e_dt) == -1) {
|
||||
time += CommUtil.getDays2(edtTime, s_dt, "second");
|
||||
}
|
||||
//以前下发,当月完成---故障时间=月初到验收时间
|
||||
if (CommUtil.compare_time(s_dt, sdtTime) == -1 && e_dt != null && ((e_dt.substring(0, 7)).equals(edtTime.substring(0, 7)))) {
|
||||
time += CommUtil.getDays2(e_dt, sdtTime, "second");
|
||||
}
|
||||
//以前下发,当月以后完成---故障时间=当月总时间
|
||||
if (CommUtil.compare_time(s_dt, sdtTime) == -1 && e_dt != null && CommUtil.compare_time(edtTime, e_dt) == -1) {
|
||||
time += CommUtil.getDays2(edtTime, sdtTime, "second");
|
||||
}
|
||||
if (CommUtil.compare_time(sdtTime, s_dt) == -1 && e_dt == null) {
|
||||
time += CommUtil.getDays2(CommUtil.nowDate(), s_dt, "second");
|
||||
}
|
||||
//以前下发,未完成---故障时间=月初到当前时间
|
||||
if (CommUtil.compare_time(s_dt, sdtTime) == -1 && e_dt == null) {
|
||||
time += CommUtil.getDays2(CommUtil.nowDate(), sdtTime, "second");
|
||||
}
|
||||
}
|
||||
|
||||
long all_second = CommUtil.getDays2(edtTime, sdtTime, "second");
|
||||
//总设备数
|
||||
long all_size = list1.size();
|
||||
//所有设备总时间
|
||||
long all_time = all_second * all_size;
|
||||
|
||||
//计算完好率(到秒)
|
||||
double rateD = ((all_time - time) * 1.0 / all_time * 100);
|
||||
|
||||
// System.out.println("滤阀_任务合格率:" + num);
|
||||
// System.out.println("滤阀_故障率:" + (100 - rateD));
|
||||
|
||||
save("FSCCSK_KPI_TJFYXDF1A", num, company.getId(), sdtTime);
|
||||
save("FSCCSK_KPI_TJFYXDF2A", (100 - rateD), company.getId(), sdtTime);
|
||||
save_his("FSCCSK_KPI_TJFYXDF1A", num, company.getId(), sdtTime);
|
||||
save_his("FSCCSK_KPI_TJFYXDF2A", (100 - rateD), company.getId(), sdtTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 水质仪表
|
||||
*/
|
||||
ids = "";//清空
|
||||
num = 100;//还原成100
|
||||
time = 0;
|
||||
List<EquipmentCard> list4 = equipmentCardService.selectSimpleListByWhere("where bizid = '" + company.getId() + "' and (remark = '水质仪表')");
|
||||
if (list4 != null && list4.size() > 0) {
|
||||
for (int i = 0; i < list4.size(); i++) {
|
||||
ids += "'" + list4.get(i).getId() + "',";
|
||||
}
|
||||
if (ids != null && !ids.equals("")) {
|
||||
ids = ids.substring(0, ids.length() - 1);
|
||||
}
|
||||
List<WorkorderDetail> list1_f = workorderDetailService.selectSimpleListByWhere("where type='repair' and datediff(month,[insdt],'" + sdt + "')=0 and unit_id = '" + company.getId() + "' and equipment_id in (" + ids + ") and (status = '" + WorkorderDetail.Status_Compete + "' or status='" + WorkorderDetail.Status_Finish + "')");
|
||||
List<WorkorderDetail> list1_all = workorderDetailService.selectSimpleListByWhere("where type='repair' and datediff(month,[insdt],'" + sdt + "')=0 and unit_id = '" + company.getId() + "' and equipment_id in (" + ids + ") ");
|
||||
if (list1_all != null && list1_all.size() > 0) {
|
||||
num = (Double.valueOf(list1_f.size())) / (Double.valueOf(list1_all.size())) * 100;
|
||||
} else {
|
||||
// 百分之百
|
||||
num = 100;
|
||||
}
|
||||
// System.out.println("水质仪表_任务合格率:" + num);
|
||||
|
||||
save("FSCCSK_KPI_SZYBYXDF1A", num, company.getId(), sdt.substring(0, 7) + "-01 00:00:00");
|
||||
save_his("FSCCSK_KPI_SZYBYXDF1A", num, company.getId(), sdt.substring(0, 7) + "-01 00:00:00");
|
||||
}
|
||||
|
||||
/**
|
||||
* 一二泵机组
|
||||
*/
|
||||
ids = "";//清空
|
||||
num = 100;//还原成100
|
||||
time = 0;
|
||||
List<EquipmentCard> list5 = equipmentCardService.selectSimpleListByWhere("where bizid = '" + company.getId() + "' and (remark = '一二泵机组')");
|
||||
if (list5 != null && list5.size() > 0) {
|
||||
for (int i = 0; i < list5.size(); i++) {
|
||||
ids += "'" + list5.get(i).getId() + "',";
|
||||
}
|
||||
if (ids != null && !ids.equals("")) {
|
||||
ids = ids.substring(0, ids.length() - 1);
|
||||
}
|
||||
//完成设备工单数
|
||||
List<WorkorderDetail> list1_f = workorderDetailService.selectSimpleListByWhere("where type='repair' and datediff(month,[insdt],'" + sdt + "')=0 and unit_id = '" + company.getId() + "' and equipment_id in (" + ids + ") and (status = '" + WorkorderDetail.Status_Compete + "' or status='" + WorkorderDetail.Status_Finish + "')");
|
||||
//所有设备工单数
|
||||
List<WorkorderDetail> list1_all = workorderDetailService.selectSimpleListByWhere("where type='repair' and datediff(month,[insdt],'" + sdt + "')=0 and unit_id = '" + company.getId() + "' and equipment_id in (" + ids + ") ");
|
||||
if (list1_all != null && list1_all.size() > 0) {
|
||||
num = (Double.valueOf(list1_f.size())) / (Double.valueOf(list1_all.size())) * 100;
|
||||
} else {
|
||||
// 百分之百
|
||||
num = 100;
|
||||
}
|
||||
|
||||
//计算当月最大数
|
||||
int maxday = CommUtil.getDaysByYearMonth(Integer.parseInt(sdt.substring(0, 4)), Integer.parseInt(sdt.substring(5, 7)));
|
||||
//开始时间
|
||||
String sdtTime = sdt.substring(0, 7) + "-01 00:00:00";
|
||||
//结束时间
|
||||
String edtTime = sdt.substring(0, 7) + "-" + maxday + " 23:59:59";
|
||||
|
||||
//计算故障时间
|
||||
for (WorkorderDetail workorderDetail : list1_all) {
|
||||
String s_dt = workorderDetail.getInsdt();//开始时间 有异常单按异常单的上报时间,没有异常单按维修单下发时间
|
||||
String e_dt = workorderDetail.getCompleteDate();//结束时间 按验收通过时间
|
||||
|
||||
if (workorderDetail.getAbnormityId() != null) {
|
||||
Abnormity abnormity = abnormityService.selectSimpleById(workorderDetail.getAbnormityId());
|
||||
if (abnormity != null) {
|
||||
s_dt = abnormity.getInsdt();//异常上报时间
|
||||
}
|
||||
}
|
||||
|
||||
//当月下发,当月完成---故障时间=验收时间减去下发时间
|
||||
if (CommUtil.compare_time(sdtTime, s_dt) == -1 && e_dt != null && ((e_dt.substring(0, 7)).equals(edtTime.substring(0, 7)))) {
|
||||
time += CommUtil.getDays2(e_dt, s_dt, "second");
|
||||
}
|
||||
//当月下发,当月以后完成---故障时间=下发时间到月底
|
||||
if (CommUtil.compare_time(sdtTime, s_dt) == -1 && e_dt != null && CommUtil.compare_time(edtTime, e_dt) == -1) {
|
||||
time += CommUtil.getDays2(edtTime, s_dt, "second");
|
||||
}
|
||||
//以前下发,当月完成---故障时间=月初到验收时间
|
||||
if (CommUtil.compare_time(s_dt, sdtTime) == -1 && e_dt != null && ((e_dt.substring(0, 7)).equals(edtTime.substring(0, 7)))) {
|
||||
time += CommUtil.getDays2(e_dt, sdtTime, "second");
|
||||
}
|
||||
//以前下发,当月以后完成---故障时间=当月总时间
|
||||
if (CommUtil.compare_time(s_dt, sdtTime) == -1 && e_dt != null && CommUtil.compare_time(edtTime, e_dt) == -1) {
|
||||
time += CommUtil.getDays2(edtTime, sdtTime, "second");
|
||||
}
|
||||
if (CommUtil.compare_time(sdtTime, s_dt) == -1 && e_dt == null) {
|
||||
time += CommUtil.getDays2(CommUtil.nowDate(), s_dt, "second");
|
||||
}
|
||||
//以前下发,未完成---故障时间=月初到当前时间
|
||||
if (CommUtil.compare_time(s_dt, sdtTime) == -1 && e_dt == null) {
|
||||
time += CommUtil.getDays2(CommUtil.nowDate(), sdtTime, "second");
|
||||
}
|
||||
}
|
||||
|
||||
long all_second = CommUtil.getDays2(edtTime, sdtTime, "second");
|
||||
//总设备数
|
||||
long all_size = list1.size();
|
||||
//所有设备总时间
|
||||
long all_time = all_second * all_size;
|
||||
|
||||
//计算完好率(到秒)
|
||||
double rateD = ((all_time - time) * 1.0 / all_time * 100);
|
||||
|
||||
// System.out.println("一二泵机组_任务合格率:" + num);
|
||||
// System.out.println("一二泵机组_故障率:" + (100 - rateD));
|
||||
|
||||
save("FSCCSK_KPI_JBFJYXDF1A", num, company.getId(), sdtTime);
|
||||
save("FSCCSK_KPI_JBFJYXDF2A", (100 - rateD), company.getId(), sdtTime);
|
||||
save_his("FSCCSK_KPI_JBFJYXDF1A", num, company.getId(), sdtTime);
|
||||
save_his("FSCCSK_KPI_JBFJYXDF2A", (100 - rateD), company.getId(), sdtTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 供配电柜、变压器
|
||||
*/
|
||||
ids = "";//清空
|
||||
num = 100;//还原成100
|
||||
time = 0;
|
||||
List<EquipmentCard> list6 = equipmentCardService.selectSimpleListByWhere("where bizid = '" + company.getId() + "' and (remark = '供配电柜、变压器')");
|
||||
if (list6 != null && list6.size() > 0) {
|
||||
for (int i = 0; i < list6.size(); i++) {
|
||||
ids += "'" + list6.get(i).getId() + "',";
|
||||
}
|
||||
if (ids != null && !ids.equals("")) {
|
||||
ids = ids.substring(0, ids.length() - 1);
|
||||
}
|
||||
List<WorkorderDetail> list1_f = workorderDetailService.selectSimpleListByWhere("where unit_id = '" + company.getId() + "' and equipment_id in (" + ids + ") and (status = '" + WorkorderDetail.Status_Compete + "' or status='" + WorkorderDetail.Status_Finish + "')");
|
||||
List<WorkorderDetail> list1_all = workorderDetailService.selectSimpleListByWhere("where unit_id = '" + company.getId() + "' and equipment_id in (" + ids + ") ");
|
||||
if (list1_all != null && list1_all.size() > 0) {
|
||||
num = (Double.valueOf(list1_f.size())) / (Double.valueOf(list1_all.size())) * 100;
|
||||
} else {
|
||||
// 百分之百
|
||||
num = 100;
|
||||
}
|
||||
// System.out.println("供配电柜、变压器_任务合格率:" + num);
|
||||
|
||||
save("FSCCSK_KPI_GPDGBYQYXDF1A", num, company.getId(), sdt.substring(0, 7) + "-01 00:00:00");
|
||||
save_his("FSCCSK_KPI_GPDGBYQYXDF1A", num, company.getId(), sdt.substring(0, 7) + "-01 00:00:00");
|
||||
}
|
||||
|
||||
}
|
||||
return "suc";
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新总表
|
||||
*/
|
||||
public void save(String mpId, double val, String unitId, String dt) {
|
||||
try {
|
||||
MPoint mPoint = mPointService.selectById(unitId, mpId);
|
||||
mPoint.setParmvalue(new BigDecimal(val + ""));
|
||||
mPoint.setMeasuredt(dt);
|
||||
mPointService.update2(unitId, mPoint);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存子表
|
||||
*/
|
||||
public void save_his(String mpId, double val, String unitId, String dt) {
|
||||
try {
|
||||
MPointHistory mPointHistory = new MPointHistory();
|
||||
mPointHistory.setParmvalue(new BigDecimal(val + ""));
|
||||
mPointHistory.setMeasuredt(dt);
|
||||
mPointHistory.setTbName("[tb_mp_" + mpId + "]");
|
||||
|
||||
List<MPointHistory> list = mPointHistoryService.selectTopNumListByTableAWhere(unitId, "1", "[tb_mp_" + mpId + "]", "where MeasureDT = '" + dt + "'");
|
||||
if (list != null && list.size() > 0) {
|
||||
mPointHistoryService.updateByWhere(unitId, "[tb_mp_" + mpId + "]", " ParmValue = '" + val + "' ", "where MeasureDT = '" + dt + "'");
|
||||
} else {
|
||||
mPointHistoryService.save(unitId, mPointHistory);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,317 @@
|
||||
package com.sipai.controller.achievement;
|
||||
|
||||
import java.awt.Robot;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.jacob.activeX.ActiveXComponent;
|
||||
import com.jacob.com.ComThread;
|
||||
import com.jacob.com.Dispatch;
|
||||
import com.jacob.com.Variant;
|
||||
import com.sipai.entity.achievement.AcceptanceModel;
|
||||
import com.sipai.entity.achievement.AcceptanceModelMPoint;
|
||||
import com.sipai.entity.base.CommonFile;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.data.CurveMpoint;
|
||||
import com.sipai.entity.data.DataCurve;
|
||||
import com.sipai.entity.scada.MPoint;
|
||||
import com.sipai.entity.scada.MPointHistory;
|
||||
import com.sipai.entity.user.Company;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.achievement.AcceptanceModelMPointService;
|
||||
import com.sipai.service.achievement.AcceptanceModelService;
|
||||
import com.sipai.service.base.CommonFileService;
|
||||
import com.sipai.service.company.CompanyService;
|
||||
import com.sipai.service.user.UserService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/achievement/acceptanceModel")
|
||||
public class AcceptanceModelController {
|
||||
@Resource
|
||||
private AcceptanceModelService acceptanceModelService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private CompanyService companyService;
|
||||
@Resource
|
||||
private CommonFileService commonFileService;
|
||||
@Resource
|
||||
private AcceptanceModelMPointService acceptanceModelMPointService;
|
||||
|
||||
|
||||
@RequestMapping("/showAcceptanceModelManage.do")
|
||||
public String showPatrolPointEquipmentTree(HttpServletRequest request, Model model){
|
||||
return "achievement/acceptanceModelManage";
|
||||
}
|
||||
|
||||
@RequestMapping("/getAcceptanceModelJson.do")
|
||||
public String getAcceptanceModelJson(HttpServletRequest request, Model model){
|
||||
String unitId = request.getParameter("unitId");
|
||||
List<AcceptanceModel> list = this.acceptanceModelService.selectListByWhere(" where 1=1 and unit_id='"+unitId+"' order by morder");
|
||||
String json = this.acceptanceModelService.getTreeList(null, list);
|
||||
model.addAttribute("result", json);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/showAcceptanceModel4Select.do")
|
||||
public String showMenu4Select(HttpServletRequest request,Model model){
|
||||
return "achievement/acceptanceModel4Select";
|
||||
}
|
||||
|
||||
@RequestMapping("/doadd.do")
|
||||
public String doadd(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="unitId") String unitId,
|
||||
@RequestParam(value="pid") String pid){
|
||||
if(pid!=null && !pid.equals("")&& !pid.equals("-1")){
|
||||
AcceptanceModel acceptanceModel = this.acceptanceModelService.selectById(pid);
|
||||
model.addAttribute("pname",acceptanceModel.getName());
|
||||
}
|
||||
if(unitId!=null && !unitId.equals("")&& !unitId.equals("-1")){
|
||||
Company company = this.companyService.selectByPrimaryKey(unitId);
|
||||
model.addAttribute("_bizname",company.getName());
|
||||
}
|
||||
model.addAttribute("id",CommUtil.getUUID());
|
||||
return "achievement/acceptanceModelAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/dosave.do")
|
||||
public String dosave(HttpServletRequest request, Model model,
|
||||
@ModelAttribute(value="acceptanceModel") AcceptanceModel acceptanceModel){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
// acceptanceModel.setId(CommUtil.getUUID());
|
||||
acceptanceModel.setInsuser(cu.getId());
|
||||
acceptanceModel.setInsdt(CommUtil.nowDate());
|
||||
|
||||
int code = this.acceptanceModelService.save(acceptanceModel);
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("新增失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doedit.do")
|
||||
public String doedit(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id){
|
||||
AcceptanceModel acceptanceModel = this.acceptanceModelService.selectById(id);
|
||||
String _auditMan="";
|
||||
String userids = acceptanceModel.getUserid();
|
||||
if(userids!=null && !("").equals(userids)){
|
||||
userids=userids.replace(",","','");
|
||||
List<User> list = this.userService.selectListByWhere("where id in ('"+userids+"')");
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
_auditMan+=list.get(i).getCaption();
|
||||
if(i!=(list.size()-1)){
|
||||
_auditMan+=",";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String unitId = acceptanceModel.getUnitId();
|
||||
if(unitId!=null && !unitId.equals("")&& !unitId.equals("-1")){
|
||||
Company company = this.companyService.selectByPrimaryKey(unitId);
|
||||
model.addAttribute("_bizname",company.getName());
|
||||
}
|
||||
AcceptanceModel pModel = this.acceptanceModelService.selectById(acceptanceModel.getPid());
|
||||
if(pModel!=null){
|
||||
model.addAttribute("pname",pModel.getName() );
|
||||
}
|
||||
model.addAttribute("acceptanceModel",acceptanceModel);
|
||||
model.addAttribute("_auditMan",_auditMan );
|
||||
return "achievement/acceptanceModelEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/doupdate.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute(value="acceptanceModel") AcceptanceModel acceptanceModel){
|
||||
int code = this.acceptanceModelService.update(acceptanceModel);
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("更新失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodel.do")
|
||||
public String dodel(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id){
|
||||
int code = this.acceptanceModelService.deleteById(id);
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("删除失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示上传页面-bootstrap-fileinput
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @param masterid
|
||||
* @param mappernamespace
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/fileinput.do")
|
||||
public String fileinput(HttpServletRequest request,
|
||||
HttpServletResponse response,Model model,@RequestParam(value="masterId") String masterId,
|
||||
@RequestParam(value="tbName") String tbName,@RequestParam(value="nameSpace") String nameSpace) {
|
||||
model.addAttribute("tbName",tbName);
|
||||
model.addAttribute("masterId",masterId);
|
||||
model.addAttribute("nameSpace",nameSpace);
|
||||
return "base/fileinputForAcceptanceModel";
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件通用接口
|
||||
*
|
||||
* @param request 请求体
|
||||
* @param dstFileName html上传组件中(input中name属性),上传文件体名称,通过此名称获取所有上传的文件map
|
||||
* @param reportGroupId (特殊)上传报告所述报告组id
|
||||
* */
|
||||
@RequestMapping("/inputFile.do")
|
||||
public ModelAndView inputFile(HttpServletRequest request,HttpServletResponse response,Model model) {
|
||||
Map<String, Object> ret = new HashMap<String, Object>();
|
||||
String masterId = request.getParameter("masterId");
|
||||
String tbName = request.getParameter("tbName");
|
||||
String nameSpace = request.getParameter("nameSpace");
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
//判断保存文件的路径是否存在
|
||||
String contextPath=request.getContextPath().replace("/", "");
|
||||
String filepathSever=request.getSession().getServletContext().getRealPath("");
|
||||
String filepath=filepathSever.replaceAll(contextPath, "UploadFile"+"/"+nameSpace+"/");
|
||||
File fileUploadPath = new File(filepath);
|
||||
if (!fileUploadPath.exists()) {
|
||||
//解决上传文件目录无法自动创建
|
||||
fileUploadPath.mkdirs();
|
||||
}
|
||||
|
||||
if (ServletFileUpload.isMultipartContent(request)) {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
List<MultipartFile> fileList = multipartRequest.getFiles("filelist"); //控件id
|
||||
//for循环只执行一次
|
||||
for (MultipartFile item : fileList) {
|
||||
String fileName = ""; //当前上传文件全名称
|
||||
String fileType = ""; //当前上传文件类型
|
||||
String saveFileName = ""; //保存到服务器目录的文件名称
|
||||
String reportAddr = ""; //保存到服务器目录的文件全路径
|
||||
try {
|
||||
fileName = item.getOriginalFilename();
|
||||
fileType = item.getContentType();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
|
||||
saveFileName = dateFormat.format(new Date())+fileName;
|
||||
reportAddr = fileUploadPath + "/" + saveFileName;
|
||||
reportAddr = reportAddr.replace("/", File.separator).replace("\\", File.separator);
|
||||
|
||||
File savedFile = new File(fileUploadPath, saveFileName);
|
||||
item.transferTo(savedFile);
|
||||
|
||||
//上传文件成功,保存文件信息到表reportDetail
|
||||
CommonFile commonFile = new CommonFile();
|
||||
commonFile.setId(CommUtil.getUUID());
|
||||
commonFile.setMasterid(masterId);
|
||||
commonFile.setFilename(fileName);
|
||||
commonFile.setType(fileType);
|
||||
commonFile.setAbspath(reportAddr);
|
||||
commonFile.setInsdt(CommUtil.nowDate());
|
||||
commonFile.setInsuser(cu.getId());
|
||||
commonFile.setSize((int)item.getSize());
|
||||
int res =commonFileService.insertByTable(tbName, commonFile);
|
||||
|
||||
if (res==1) {
|
||||
ret.put("suc", true);
|
||||
ret.put("msg", commonFile.getId());
|
||||
|
||||
List<CommonFile> commfiles = this.commonFileService.selectListByTableAWhere(tbName, "where id='"+commonFile.getId()+"'");
|
||||
if(commfiles!=null && commfiles.size()>0){
|
||||
String excelpath=commfiles.get(0).getAbspath();
|
||||
String filename=commfiles.get(0).getFilename();
|
||||
|
||||
//生成HTM文件
|
||||
//设置文件的文件夹
|
||||
String RealPath=request.getRealPath("");
|
||||
if(RealPath.substring(RealPath.length()-1, RealPath.length()).equals("\\")||RealPath.substring(RealPath.length()-1, RealPath.length()).equals("/")){
|
||||
RealPath=RealPath.substring(0, RealPath.length()-1);
|
||||
}
|
||||
String fileforder=RealPath+"_tohtm/"+nameSpace;
|
||||
// System.out.println(fileforder);
|
||||
try {
|
||||
File file=new File(fileforder);
|
||||
if(!file.exists()){
|
||||
file.mkdir();
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//开始生成
|
||||
ComThread.InitSTA();
|
||||
ActiveXComponent xl = new ActiveXComponent("Excel.Application");
|
||||
xl.setProperty("DisplayAlerts", new Variant(false));
|
||||
Object workbooks = xl.getProperty("Workbooks").toDispatch();
|
||||
Object workbook = Dispatch.call((Dispatch) workbooks, "Open",
|
||||
excelpath).toDispatch();
|
||||
Dispatch.invoke((Dispatch) workbook, "SaveAs", Dispatch.Method,
|
||||
new Object[]{
|
||||
fileforder+"\\"+filename+".htm",
|
||||
new Variant(44),
|
||||
new Variant(""),
|
||||
new Variant(""),
|
||||
new Variant(false),
|
||||
new Variant(false),
|
||||
new Variant(1),
|
||||
new Variant(2)}, new int[1]);
|
||||
Dispatch.call((Dispatch) workbooks, "Close");
|
||||
xl.invoke("Quit", new Variant[] {});
|
||||
ComThread.Release();
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
ret.put("suc", false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
ret.put("suc", false);
|
||||
ret.put("msg", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
String result =JSONObject.fromObject(ret).toString();
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,185 @@
|
||||
package com.sipai.controller.achievement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.jws.soap.SOAPBinding.Use;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.achievement.AcceptanceModel;
|
||||
import com.sipai.entity.achievement.AcceptanceModelMPoint;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.report.RptCollectMode;
|
||||
import com.sipai.entity.scada.MPoint;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.achievement.AcceptanceModelMPointService;
|
||||
import com.sipai.service.report.RptCollectModeService;
|
||||
import com.sipai.service.scada.MPointService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/achievement/acceptanceModelMPoint")
|
||||
public class AcceptanceModelMPointController {
|
||||
@Resource
|
||||
private AcceptanceModelMPointService acceptanceModelMPointService;
|
||||
@Resource
|
||||
private MPointService mPointService;
|
||||
@Resource
|
||||
private RptCollectModeService rptCollectModeService;
|
||||
|
||||
@RequestMapping("/getlist.do")
|
||||
public String getAcceptanceModelJson(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required=false) String sort,
|
||||
@RequestParam(value = "order", required=false) String order){
|
||||
String unitId = request.getParameter("unitId");
|
||||
String acceptanceModelId = request.getParameter("id");
|
||||
PageHelper.startPage(page, rows);
|
||||
|
||||
List<AcceptanceModelMPoint> list = this.acceptanceModelMPointService.selectListByWhere(unitId, " where 1=1 and acceptance_model_id='"+acceptanceModelId+"' order by morder");
|
||||
|
||||
PageInfo<AcceptanceModelMPoint> pi = new PageInfo<AcceptanceModelMPoint>(list);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
String result="{\"total\":"+pi.getTotal()+",\"rows\":"+json+"}";
|
||||
model.addAttribute("result",result);
|
||||
return ("result");
|
||||
}
|
||||
@RequestMapping("/doadd.do")
|
||||
public String doadd(HttpServletRequest request,Model model){
|
||||
return "achievement/acceptanceModel_MPointAdd";
|
||||
}
|
||||
@RequestMapping("/showlistForSelect.do")
|
||||
public String showlistForSelect(HttpServletRequest request,Model model) {
|
||||
request.setAttribute("pid", request.getParameter("pid"));
|
||||
request.setAttribute("mpid", request.getParameter("mpid"));
|
||||
return "/achievement/MPoint4Select4Single";
|
||||
}
|
||||
@RequestMapping("/dosave.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute(value="acceptanceModelMPoint") AcceptanceModelMPoint acceptanceModelMPoint){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
acceptanceModelMPoint.setId(CommUtil.getUUID());
|
||||
acceptanceModelMPoint.setInsuser(cu.getId());
|
||||
acceptanceModelMPoint.setInsdt(CommUtil.nowDate());
|
||||
int code = this.acceptanceModelMPointService.save(acceptanceModelMPoint);
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("新增失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
@RequestMapping("/doedit.do")
|
||||
public String doedit(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
String unitId = request.getParameter("unitId");
|
||||
AcceptanceModelMPoint acceptanceModelMPoint = this.acceptanceModelMPointService.selectById(unitId,id);
|
||||
model.addAttribute("acceptanceModelMPoint", acceptanceModelMPoint);
|
||||
return "achievement/acceptanceModel_MPointEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/doupdate.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute(value="acceptanceModelMPoint") AcceptanceModelMPoint acceptanceModelMPoint){
|
||||
int code = this.acceptanceModelMPointService.update(acceptanceModelMPoint);
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("更新失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/showMPoint4Select.do")
|
||||
public String showMPoint4Select(HttpServletRequest request,Model model){
|
||||
String mPointIds=request.getParameter("mPointIds");
|
||||
String unitId = request.getParameter("unitId");
|
||||
String whereStr= "where MPointID in ('"+mPointIds.replace(",", "','")+"') ";
|
||||
List<MPoint> list = this.mPointService.selectListByWhere(unitId, whereStr);
|
||||
model.addAttribute("mPoints",JSONArray.fromObject(list));
|
||||
return "achievement/MPoint4Select";
|
||||
}
|
||||
|
||||
@RequestMapping("/doimport.do")
|
||||
public String doimport(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "acceptanceModelId") String acceptanceModelId,
|
||||
@RequestParam(value = "mPointIds") String mPointIds){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
String userId= cu.getId();
|
||||
String[] mpidArr = mPointIds.split(",");
|
||||
this.acceptanceModelMPointService.deleteByWhere("where acceptance_model_id = '"+acceptanceModelId+"'");
|
||||
|
||||
int num = 0;
|
||||
for (int i = 0; i < mpidArr.length; i++) {
|
||||
AcceptanceModelMPoint acceptanceModelMPoint = new AcceptanceModelMPoint();
|
||||
acceptanceModelMPoint.setId(CommUtil.getUUID());
|
||||
acceptanceModelMPoint.setAcceptanceModelId(acceptanceModelId);
|
||||
acceptanceModelMPoint.setMpointId(mpidArr[i]);
|
||||
acceptanceModelMPoint.setInsuser(userId);
|
||||
acceptanceModelMPoint.setInsdt(CommUtil.nowDate());
|
||||
acceptanceModelMPoint.setMorder(i);
|
||||
|
||||
int code = this.acceptanceModelMPointService.save(acceptanceModelMPoint);
|
||||
if(code==1){
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
Result result = new Result();
|
||||
if (num == mpidArr.length) {
|
||||
result = Result.success(num);
|
||||
} else {
|
||||
result = Result.failed("导入失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodel.do")
|
||||
public String dodel(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id){
|
||||
int code = this.acceptanceModelMPointService.deleteById(id);
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("删除失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/getValueTypeJson.do")
|
||||
public String getValueTypeJson(HttpServletRequest request,Model model){
|
||||
List<RptCollectMode> list = this.rptCollectModeService.selectListByWhere
|
||||
("where 1=1 order by morder");
|
||||
JSONArray json = new JSONArray();
|
||||
if(list!=null && list.size()>0){
|
||||
for(int i=0;i<list.size();i++){
|
||||
JSONObject jsonObject =new JSONObject();
|
||||
jsonObject.put("id", list.get(i).getId());
|
||||
jsonObject.put("text", list.get(i).getContent());
|
||||
json.add(jsonObject);
|
||||
}
|
||||
}
|
||||
model.addAttribute("result", json.toString());
|
||||
return "result";
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,211 @@
|
||||
package com.sipai.controller.achievement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.achievement.AcceptanceModelMPoint;
|
||||
import com.sipai.entity.achievement.AcceptanceModelOutput;
|
||||
import com.sipai.entity.achievement.ModelLibrary;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.report.RptCollectMode;
|
||||
import com.sipai.entity.scada.MPoint;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.achievement.AcceptanceModelMPointService;
|
||||
import com.sipai.service.achievement.AcceptanceModelOutputService;
|
||||
import com.sipai.service.achievement.ModelLibraryService;
|
||||
import com.sipai.service.report.RptCollectModeService;
|
||||
import com.sipai.service.scada.MPointService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/achievement/acceptanceModelOutput")
|
||||
public class AcceptanceModelOutputController {
|
||||
@Resource
|
||||
private AcceptanceModelOutputService acceptanceModelOutputService;
|
||||
@Resource
|
||||
private MPointService mPointService;
|
||||
@Resource
|
||||
private RptCollectModeService rptCollectModeService;
|
||||
@Resource
|
||||
private ModelLibraryService modelLibraryService;
|
||||
|
||||
@RequestMapping("/getlist.do")
|
||||
public String getAcceptanceModelJson(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required=false) String sort,
|
||||
@RequestParam(value = "order", required=false) String order){
|
||||
String unitId = request.getParameter("unitId");
|
||||
String acceptanceModelId = request.getParameter("id");
|
||||
PageHelper.startPage(page, rows);
|
||||
|
||||
List<AcceptanceModelOutput> list = this.acceptanceModelOutputService.selectListByWhere(unitId, " where 1=1 and acceptance_model_id='"+acceptanceModelId+"' order by morder");
|
||||
|
||||
PageInfo<AcceptanceModelOutput> pi = new PageInfo<AcceptanceModelOutput>(list);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
String result="{\"total\":"+pi.getTotal()+",\"rows\":"+json+"}";
|
||||
model.addAttribute("result",result);
|
||||
return ("result");
|
||||
}
|
||||
@RequestMapping("/doadd.do")
|
||||
public String doadd(HttpServletRequest request,Model model){
|
||||
return "achievement/acceptanceModel_OutputAdd";
|
||||
}
|
||||
@RequestMapping("/showlistForSelect.do")
|
||||
public String showlistForSelect(HttpServletRequest request,Model model) {
|
||||
request.setAttribute("pid", request.getParameter("pid"));
|
||||
request.setAttribute("mpid", request.getParameter("mpid"));
|
||||
return "/achievement/MPoint4Select4Single";
|
||||
}
|
||||
@RequestMapping("/dosave.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute(value="acceptanceModelOutput") AcceptanceModelOutput acceptanceModelOutput){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
acceptanceModelOutput.setId(CommUtil.getUUID());
|
||||
acceptanceModelOutput.setInsuser(cu.getId());
|
||||
acceptanceModelOutput.setInsdt(CommUtil.nowDate());
|
||||
int code = this.acceptanceModelOutputService.save(acceptanceModelOutput);
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("新增失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/check.do")
|
||||
public String check(HttpServletRequest request,Model model,
|
||||
@ModelAttribute(value="acceptanceModelOutput") AcceptanceModelOutput acceptanceModelOutput){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
String unitId = request.getParameter("unitId");
|
||||
List<AcceptanceModelOutput> list = this.acceptanceModelOutputService.selectListByWhere(unitId, "where acceptance_model_id='"+acceptanceModelOutput.getAcceptanceModelId()+"' and base_id = '"+acceptanceModelOutput.getBaseId()+"'");
|
||||
Result result;
|
||||
if (list.size()>0) {
|
||||
result = Result.failed("重复");
|
||||
} else {
|
||||
result = Result.success(1);
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
@RequestMapping("/doedit.do")
|
||||
public String doedit(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
String unitId = request.getParameter("unitId");
|
||||
AcceptanceModelOutput acceptanceModelOutput = this.acceptanceModelOutputService.selectById(unitId,id);
|
||||
model.addAttribute("acceptanceModelOutput", acceptanceModelOutput);
|
||||
return "achievement/acceptanceModel_OutputEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/doupdate.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute(value="acceptanceModelOutput") AcceptanceModelOutput acceptanceModelOutput){
|
||||
int code = this.acceptanceModelOutputService.update(acceptanceModelOutput);
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("更新失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/showOutput4Select.do")
|
||||
public String showMPoint4Select(HttpServletRequest request,Model model){
|
||||
String baseIds=request.getParameter("mPointIds");
|
||||
String unitId = request.getParameter("unitId");
|
||||
baseIds=baseIds.replace(",","','");
|
||||
List<ModelLibrary> list = this.modelLibraryService.selectListByWhere("where id in ('"+baseIds+"')");
|
||||
model.addAttribute("modelLibrarys",JSONArray.fromObject(list));
|
||||
return "achievement/modelLibrary4selects";
|
||||
}
|
||||
|
||||
@RequestMapping("/doimport.do")
|
||||
public String doimport(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "acceptanceModelId") String acceptanceModelId,
|
||||
@RequestParam(value = "baseIds") String baseIds){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
String userId= cu.getId();
|
||||
String[] baseIdsArr = baseIds.split(",");
|
||||
this.acceptanceModelOutputService.deleteByWhere("where acceptance_model_id = '"+acceptanceModelId+"'");
|
||||
|
||||
int num = 0;
|
||||
for (int i = 0; i < baseIdsArr.length; i++) {
|
||||
ModelLibrary modelLibrary = this.modelLibraryService.selectById(baseIdsArr[i]);
|
||||
if(!"3".equals(modelLibrary.getType())){
|
||||
continue;
|
||||
}
|
||||
AcceptanceModelOutput acceptanceModelOutput = new AcceptanceModelOutput();
|
||||
acceptanceModelOutput.setId(CommUtil.getUUID());
|
||||
acceptanceModelOutput.setAcceptanceModelId(acceptanceModelId);
|
||||
acceptanceModelOutput.setBaseId(baseIdsArr[i]);
|
||||
|
||||
acceptanceModelOutput.setName(this.modelLibraryService.selectById(baseIdsArr[i]).getParamName());
|
||||
acceptanceModelOutput.setInsuser(userId);
|
||||
acceptanceModelOutput.setInsdt(CommUtil.nowDate());
|
||||
acceptanceModelOutput.setMorder(i);
|
||||
|
||||
int code = this.acceptanceModelOutputService.save(acceptanceModelOutput);
|
||||
if(code==1){
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
Result result = new Result();
|
||||
if (num == baseIdsArr.length) {
|
||||
result = Result.success(num);
|
||||
} else {
|
||||
result = Result.failed("导入失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodel.do")
|
||||
public String dodel(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id){
|
||||
int code = this.acceptanceModelOutputService.deleteById(id);
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("删除失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
//
|
||||
//
|
||||
// @RequestMapping("/getValueTypeJson.do")
|
||||
// public String getValueTypeJson(HttpServletRequest request,Model model){
|
||||
// List<RptCollectMode> list = this.rptCollectModeService.selectListByWhere
|
||||
// ("where 1=1 order by morder");
|
||||
// JSONArray json = new JSONArray();
|
||||
// if(list!=null && list.size()>0){
|
||||
// for(int i=0;i<list.size();i++){
|
||||
// JSONObject jsonObject =new JSONObject();
|
||||
// jsonObject.put("id", list.get(i).getId());
|
||||
// jsonObject.put("text", list.get(i).getContent());
|
||||
// json.add(jsonObject);
|
||||
// }
|
||||
// }
|
||||
// model.addAttribute("result", json.toString());
|
||||
// return "result";
|
||||
// }
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
package com.sipai.controller.achievement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.achievement.AcceptanceModelOutput;
|
||||
import com.sipai.entity.achievement.AcceptanceModelOutputData;
|
||||
import com.sipai.entity.achievement.AcceptanceModelRecord;
|
||||
import com.sipai.service.achievement.AcceptanceModelOutputDataService;
|
||||
import com.sipai.service.achievement.AcceptanceModelOutputService;
|
||||
import com.sipai.service.achievement.AcceptanceModelRecordService;
|
||||
import com.sipai.service.achievement.ModelLibraryService;
|
||||
import com.sipai.service.report.RptCollectModeService;
|
||||
import com.sipai.service.scada.MPointService;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/achievement/acceptanceModelOutputData")
|
||||
public class AcceptanceModelOutputDataController {
|
||||
@Resource
|
||||
private AcceptanceModelOutputService acceptanceModelOutputService;
|
||||
@Resource
|
||||
private AcceptanceModelRecordService acceptanceModelRecordService;
|
||||
@Resource
|
||||
private AcceptanceModelOutputDataService acceptanceModelOutputDataService;
|
||||
@Resource
|
||||
private MPointService mPointService;
|
||||
@Resource
|
||||
private RptCollectModeService rptCollectModeService;
|
||||
@Resource
|
||||
private ModelLibraryService modelLibraryService;
|
||||
|
||||
@RequestMapping("/getlist.do")
|
||||
public String getlist(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required=false) String sort,
|
||||
@RequestParam(value = "order", required=false) String order){
|
||||
String id = request.getParameter("pid");
|
||||
AcceptanceModelRecord acceptanceModelRecord = this.acceptanceModelRecordService.selectById(id);
|
||||
PageHelper.startPage(page, rows);
|
||||
List<AcceptanceModelOutputData> list = this.acceptanceModelOutputDataService.selectListByWhere(" where 1=1 and pid='"+acceptanceModelRecord.getPid()+"' order by td.id");
|
||||
PageInfo<AcceptanceModelOutputData> pi = new PageInfo<AcceptanceModelOutputData>(list);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
String result="{\"total\":"+pi.getTotal()+",\"rows\":"+json+"}";
|
||||
model.addAttribute("result",result);
|
||||
return ("result");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,112 @@
|
||||
package com.sipai.controller.achievement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.achievement.AcceptanceModelText;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.achievement.AcceptanceModelTextService;
|
||||
import com.sipai.service.report.RptCollectModeService;
|
||||
import com.sipai.service.scada.MPointService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/achievement/acceptanceModelText")
|
||||
public class AcceptanceModelTextController {
|
||||
@Resource
|
||||
private AcceptanceModelTextService acceptanceModelTextService;
|
||||
@Resource
|
||||
private MPointService mPointService;
|
||||
@Resource
|
||||
private RptCollectModeService rptCollectModeService;
|
||||
|
||||
@RequestMapping("/getlist.do")
|
||||
public String getAcceptanceModelJson(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required=false) String sort,
|
||||
@RequestParam(value = "order", required=false) String order){
|
||||
String unitId = request.getParameter("unitId");
|
||||
String acceptanceModelId = request.getParameter("id");
|
||||
PageHelper.startPage(page, rows);
|
||||
|
||||
List<AcceptanceModelText> list = this.acceptanceModelTextService.selectListByWhere(" where 1=1 and acceptance_model_id='"+acceptanceModelId+"' order by morder");
|
||||
|
||||
PageInfo<AcceptanceModelText> pi = new PageInfo<AcceptanceModelText>(list);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
String result="{\"total\":"+pi.getTotal()+",\"rows\":"+json+"}";
|
||||
model.addAttribute("result",result);
|
||||
return ("result");
|
||||
}
|
||||
@RequestMapping("/doadd.do")
|
||||
public String doadd(HttpServletRequest request,Model model){
|
||||
return "achievement/acceptanceModel_TextAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/dosave.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute(value="acceptanceModelText") AcceptanceModelText acceptanceModelText){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
acceptanceModelText.setId(CommUtil.getUUID());
|
||||
acceptanceModelText.setInsuser(cu.getId());
|
||||
acceptanceModelText.setInsdt(CommUtil.nowDate());
|
||||
int code = this.acceptanceModelTextService.save(acceptanceModelText);
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("新增失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
@RequestMapping("/doedit.do")
|
||||
public String doedit(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
AcceptanceModelText acceptanceModelText = this.acceptanceModelTextService.selectById(id);
|
||||
model.addAttribute("acceptanceModelText", acceptanceModelText);
|
||||
return "achievement/acceptanceModel_TextEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/doupdate.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute(value="acceptanceModelText") AcceptanceModelText acceptanceModelText){
|
||||
int code = this.acceptanceModelTextService.update(acceptanceModelText);
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("更新失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodel.do")
|
||||
public String dodel(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id){
|
||||
int code = this.acceptanceModelTextService.deleteById(id);
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("删除失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,120 @@
|
||||
package com.sipai.controller.achievement;
|
||||
|
||||
import com.sipai.entity.achievement.ModelLibrary;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.equipment.AssetClass;
|
||||
import com.sipai.entity.equipment.EquipmentClass;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.achievement.ModelLibraryService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/achievement/modelLibrary")
|
||||
public class ModelLibraryController {
|
||||
@Resource
|
||||
private ModelLibraryService modelLibraryService;
|
||||
|
||||
@RequestMapping("/showTree.do")
|
||||
public String showTree(HttpServletRequest request, Model model) {
|
||||
return "/achievement/modelLibrary4Tree";
|
||||
}
|
||||
|
||||
@RequestMapping("/showTree4Select.do")
|
||||
public String showMenu4Select(HttpServletRequest request,Model model){
|
||||
return "/achievement/modelLibrary4select";
|
||||
}
|
||||
@RequestMapping("/getTree.do")
|
||||
public String getTree(HttpServletRequest request, Model model) {
|
||||
String wherestr = "where 1=1 ";
|
||||
List<ModelLibrary> list = this.modelLibraryService.selectListByWhere("where 1=1 order by morder");
|
||||
String json = modelLibraryService.getTree(null, list);
|
||||
Result result = Result.success(json);
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/add.do")
|
||||
public String add(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "pid") String pid) {
|
||||
if (pid != null && !pid.equals("")) {
|
||||
ModelLibrary entity = modelLibraryService.selectById(pid);
|
||||
model.addAttribute("pname", entity.getParamName());
|
||||
}
|
||||
model.addAttribute("id", CommUtil.getUUID());
|
||||
return "achievement/modelLibraryAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/edit.do")
|
||||
public String edit(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
ModelLibrary entity = modelLibraryService.selectById(id);
|
||||
if (entity != null) {
|
||||
ModelLibrary entity2 = modelLibraryService.selectById(entity.getPid());
|
||||
if (entity2 != null) {
|
||||
model.addAttribute("pname", entity2.getParamName());
|
||||
}
|
||||
/*if (equipmentClass.getAssetClassId() != null) {
|
||||
String AssetClass = "";
|
||||
String AssetClassname = "";
|
||||
List<com.sipai.entity.equipment.AssetClass> list = this.assetClassService.selectListByWhere("where class_id = '" + equipmentClass.getId() + "' ");
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
AssetClass += list.get(i).getId();
|
||||
AssetClassname += list.get(i).getAssetclassname();
|
||||
if (i < list.size() - 1) {
|
||||
AssetClass += ",";
|
||||
AssetClassname += ",";
|
||||
}
|
||||
}
|
||||
equipmentClass.set_assetClassname(AssetClassname);
|
||||
equipmentClass.setAssetClassId(AssetClass);
|
||||
}*/
|
||||
model.addAttribute("entity", entity);
|
||||
}
|
||||
return "achievement/modelLibraryEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/save.do")
|
||||
public String save(HttpServletRequest request, Model model,
|
||||
@ModelAttribute("modelLibrary") ModelLibrary modelLibrary) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
modelLibrary.setInsuser(cu.getId());
|
||||
modelLibrary.setInsdt(CommUtil.nowDate());
|
||||
int res = this.modelLibraryService.save(modelLibrary);
|
||||
Result result = Result.success(res);
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/update.do")
|
||||
public String update(HttpServletRequest request, Model model,
|
||||
@ModelAttribute("modelLibrary") ModelLibrary modelLibrary) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
modelLibrary.setInsuser(cu.getId());
|
||||
modelLibrary.setInsdt(CommUtil.nowDate());
|
||||
int res = this.modelLibraryService.update(modelLibrary);
|
||||
Result result = Result.success(res);
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/delete.do")
|
||||
public String delete(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
int res = this.modelLibraryService.deleteById(id);
|
||||
Result result = Result.success(res);
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
1900
src/main/java/com/sipai/controller/activiti/ActivitiController.java
Normal file
1900
src/main/java/com/sipai/controller/activiti/ActivitiController.java
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,863 @@
|
||||
package com.sipai.controller.activiti;
|
||||
|
||||
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
|
||||
import org.activiti.bpmn.BpmnAutoLayout;
|
||||
import org.activiti.bpmn.converter.BpmnXMLConverter;
|
||||
import org.activiti.bpmn.model.BpmnModel;
|
||||
import org.activiti.bpmn.model.EndEvent;
|
||||
import org.activiti.bpmn.model.ExclusiveGateway;
|
||||
import org.activiti.bpmn.model.Process;
|
||||
import org.activiti.bpmn.model.SequenceFlow;
|
||||
import org.activiti.bpmn.model.StartEvent;
|
||||
import org.activiti.bpmn.model.UserTask;
|
||||
import org.activiti.editor.constants.ModelDataJsonConstants;
|
||||
import org.activiti.editor.language.json.converter.BpmnJsonConverter;
|
||||
import org.activiti.engine.ManagementService;
|
||||
import org.activiti.engine.ProcessEngineConfiguration;
|
||||
import org.activiti.engine.RepositoryService;
|
||||
import org.activiti.engine.RuntimeService;
|
||||
import org.activiti.engine.TaskService;
|
||||
import org.activiti.engine.impl.Condition;
|
||||
import org.activiti.engine.impl.RepositoryServiceImpl;
|
||||
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
||||
import org.activiti.engine.impl.context.Context;
|
||||
import org.activiti.engine.impl.interceptor.Command;
|
||||
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
|
||||
import org.activiti.engine.impl.pvm.PvmActivity;
|
||||
import org.activiti.engine.impl.pvm.PvmTransition;
|
||||
import org.activiti.engine.impl.pvm.process.ActivityImpl;
|
||||
import org.activiti.engine.repository.Deployment;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.activiti.engine.repository.ProcessDefinitionQuery;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.activiti.image.ProcessDiagramGenerator;
|
||||
import org.activiti.spring.ProcessEngineFactoryBean;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.codehaus.jackson.node.ObjectNode;
|
||||
import org.junit.Assert;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.activiti.cmd.JumpActivityCmd;
|
||||
import com.sipai.activiti.util.Page;
|
||||
import com.sipai.activiti.util.PageUtil;
|
||||
import com.sipai.activiti.util.WorkflowUtils;
|
||||
import com.sipai.entity.activiti.TaskModel;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.activiti.WorkflowProcessDefinitionService;
|
||||
import com.sipai.service.activiti.WorkflowTraceService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
import com.sipai.tools.FileUtil;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
/**
|
||||
* 流程管理控制器
|
||||
*
|
||||
* @author wxp
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping(value = "/activiti/auto")
|
||||
public class AutoActivitiController {
|
||||
|
||||
protected Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
protected WorkflowProcessDefinitionService workflowProcessDefinitionService;
|
||||
|
||||
protected RepositoryService repositoryService;
|
||||
|
||||
protected RuntimeService runtimeService;
|
||||
|
||||
protected TaskService taskService;
|
||||
|
||||
protected WorkflowTraceService traceService;
|
||||
|
||||
@Autowired
|
||||
ManagementService managementService;
|
||||
|
||||
protected static Map<String, ProcessDefinition> PROCESS_DEFINITION_CACHE = new HashMap<String, ProcessDefinition>();
|
||||
|
||||
@Autowired
|
||||
ProcessEngineFactoryBean processEngine;
|
||||
|
||||
@Autowired
|
||||
ProcessEngineConfiguration processEngineConfiguration;
|
||||
|
||||
@RequestMapping("/doimport.do")
|
||||
public String doimport(HttpServletRequest request,Model model){
|
||||
return "/activiti/importAutoActiviti";
|
||||
}
|
||||
@RequestMapping(value = "saveImportActiviti.do")
|
||||
public ModelAndView saveImportActiviti(@RequestParam MultipartFile[] file, HttpServletRequest request,
|
||||
HttpServletResponse response,Model model) throws IOException {
|
||||
User cu = (User)request.getSession().getAttribute("cu");
|
||||
//要存入的实际地址
|
||||
String realPath = request.getSession().getServletContext().getRealPath("/");
|
||||
String pjName = request.getContextPath().substring(1, request.getContextPath().length());
|
||||
realPath = realPath.replace(pjName,"Temp");
|
||||
|
||||
List<TaskModel> data= importByExcel(realPath,file,cu);
|
||||
int result =autoImport(data);
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
public int autoImport(List<TaskModel> data) {
|
||||
int result=0;
|
||||
if(data==null || data.size()<3)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
// 1. Build up the model from scratch
|
||||
BpmnModel bModel = new BpmnModel();
|
||||
Process process=new Process();
|
||||
bModel.addProcess(process);
|
||||
final String PROCESSID =data.get(0).getId();
|
||||
final String PROCESSNAME =data.get(0).getName();
|
||||
if(PROCESSID==null || PROCESSNAME==null){
|
||||
return result;
|
||||
}
|
||||
process.setId(PROCESSID);
|
||||
process.setName(PROCESSNAME);
|
||||
|
||||
for (int i = 1; i < data.size(); i++) {
|
||||
TaskModel taskModel = data.get(i);
|
||||
switch (taskModel.getType()) {
|
||||
case "startEvent":
|
||||
String taskId = taskModel.getId();
|
||||
String target_true = taskModel.getTarget_true();
|
||||
process.addFlowElement(createStartEvent()); //创建节点
|
||||
process.addFlowElement(createSequenceFlow(taskId, target_true, "", ""));//创建连线
|
||||
break;
|
||||
case "endEvent":
|
||||
process.addFlowElement(createEndEvent());
|
||||
break;
|
||||
case "task":
|
||||
taskId = taskModel.getId();
|
||||
String taskName = taskModel.getName();
|
||||
target_true = taskModel.getTarget_true();
|
||||
process.addFlowElement(createUserTask(taskId, taskName, "candidateGroup"+i));
|
||||
process.addFlowElement(createSequenceFlow(taskId, target_true, "", ""));
|
||||
break;
|
||||
case "gateway":
|
||||
taskId = taskModel.getId();
|
||||
taskName = taskModel.getName();
|
||||
target_true = taskModel.getTarget_true();
|
||||
String target_false = taskModel.getTarget_false();
|
||||
process.addFlowElement(createExclusiveGateway(taskId));
|
||||
process.addFlowElement(createSequenceFlow(taskId, target_true, "通过", "${pass=='Y'}"));
|
||||
process.addFlowElement(createSequenceFlow(taskId, target_false, "不通过", "${pass=='N'}"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Generate graphical information
|
||||
new BpmnAutoLayout(bModel).execute();
|
||||
|
||||
// 3. Deploy the process to the engine
|
||||
Deployment deployment = repositoryService.createDeployment().addBpmnModel(PROCESSID+".bpmn", bModel).name(PROCESSID+"_deployment").deploy();
|
||||
|
||||
// 4. Start a process instance
|
||||
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(PROCESSID);
|
||||
|
||||
// 5. Check if task is available
|
||||
List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
|
||||
Assert.assertEquals(1, tasks.size());
|
||||
try{
|
||||
// 6. Save process diagram to a file
|
||||
InputStream processDiagram = repositoryService.getProcessDiagram(processInstance.getProcessDefinitionId());
|
||||
FileUtils.copyInputStreamToFile(processDiagram, new File("/deployments/"+PROCESSID+".png"));
|
||||
|
||||
// 7. Save resulting BPMN xml to a file
|
||||
InputStream processBpmn = repositoryService.getResourceAsStream(deployment.getId(), PROCESSID+".bpmn");
|
||||
FileUtils.copyInputStreamToFile(processBpmn,new File("/deployments/"+PROCESSID+".bpmn"));
|
||||
result=1;
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println(".........end...");
|
||||
|
||||
return result;
|
||||
}
|
||||
public List<TaskModel> importByExcel(String realPath, MultipartFile[] file,User operator) throws IOException {
|
||||
List<TaskModel> result = new ArrayList<>() ;
|
||||
//上传文件的原名(即上传前的文件名字)
|
||||
String originalFilename = null;
|
||||
//服务器路径
|
||||
String serverPath = null;
|
||||
for(MultipartFile myfile:file){
|
||||
if(myfile.isEmpty()){
|
||||
return null;
|
||||
}else{
|
||||
originalFilename = myfile.getOriginalFilename();
|
||||
//兼容linux路径
|
||||
serverPath = realPath+System.getProperty("file.separator")+CommUtil.getUUID()+originalFilename;
|
||||
FileUtil.saveFile(myfile.getInputStream(), serverPath);
|
||||
System.out.println("-->>临时文件上传完成!");
|
||||
|
||||
FileInputStream is = new FileInputStream(serverPath);
|
||||
try {
|
||||
POIFSFileSystem fs = new POIFSFileSystem(is);
|
||||
HSSFWorkbook wb = new HSSFWorkbook(fs);
|
||||
HSSFSheet sheet = wb.getSheetAt(0);
|
||||
// 得到总行数
|
||||
int rowNum = sheet.getPhysicalNumberOfRows();
|
||||
HSSFRow row = sheet.getRow(0);
|
||||
//以导入时列名长度为需要导入数据的长度,超过部分程序将忽略
|
||||
int colNum = row.getPhysicalNumberOfCells();
|
||||
// 正文内容应该从第3行开始,第一行为表头的标题
|
||||
for (int i = 1; i < rowNum; i++) {
|
||||
//Excel行数据
|
||||
row = sheet.getRow(i);
|
||||
TaskModel taskModel=new TaskModel();
|
||||
taskModel.setId(row.getCell(0)==null?null:row.getCell(0).toString());
|
||||
taskModel.setName(row.getCell(1)==null?null:row.getCell(1).toString());
|
||||
taskModel.setTarget_true(row.getCell(2)==null?null:row.getCell(2).toString());
|
||||
taskModel.setTarget_false(row.getCell(3)==null?null:row.getCell(3).toString());
|
||||
taskModel.setType(row.getCell(4)==null?null:row.getCell(4).toString());
|
||||
|
||||
result.add(taskModel);
|
||||
|
||||
}
|
||||
//导入动作完成后,删除导入文件的临时文件
|
||||
FileUtil.deleteFile(serverPath);
|
||||
System.out.println("<<--临时文件已删除!");
|
||||
//关闭流文件
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/showProcessList.do")
|
||||
public String showProcessList(HttpServletRequest request,Model model) {
|
||||
return "/activiti/processList";
|
||||
}
|
||||
/**
|
||||
* 流程定义列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/getProcessList.do")
|
||||
public ModelAndView getProcessList(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required=false) String sort,
|
||||
@RequestParam(value = "order", required=false) String order) {
|
||||
User cu=(User)request.getSession().getAttribute("cu");
|
||||
if(order==null){
|
||||
order = " asc ";
|
||||
}
|
||||
String orderstr=" order by "+sort+" "+order;
|
||||
String wherestr="";
|
||||
if(request.getParameter("querytype")!=null&&request.getParameter("querytype").equals("select")){
|
||||
wherestr = " where 1=1 ";
|
||||
}
|
||||
if(request.getParameter("search_name")!=null && !request.getParameter("search_name").isEmpty()){
|
||||
wherestr += " and name like '%"+request.getParameter("search_name")+"%' ";
|
||||
}
|
||||
|
||||
PageHelper.startPage(page, rows);
|
||||
Page<Object[]> page1 = new Page<Object[]>(PageUtil.PAGE_SIZE);
|
||||
int[] pageParams = PageUtil.init(page1, request);
|
||||
|
||||
List<Object[]> list = new ArrayList<Object[]>();
|
||||
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery().orderByDeploymentId().desc();
|
||||
List<ProcessDefinition> processDefinitionList = processDefinitionQuery.listPage(pageParams[0], pageParams[1]);
|
||||
for (ProcessDefinition processDefinition : processDefinitionList) {
|
||||
/*BpmnModel model_bpmn = repositoryService.getBpmnModel(processDefinition.getId());
|
||||
if(model != null) {
|
||||
Collection<FlowElement> flowElements = model_bpmn.getMainProcess().getFlowElements();
|
||||
for(FlowElement e : flowElements) {
|
||||
if(e.getClass().toString().contains("userTask"))
|
||||
System.out.println("flowelement id:" + e.getId() + " name:" + e.getName() + " class:" + e.getClass().toString());
|
||||
}
|
||||
} */
|
||||
String deploymentId = processDefinition.getDeploymentId();
|
||||
Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
|
||||
list.add(new Object[]{processDefinition, deployment});
|
||||
}
|
||||
PageInfo<Object[]> pi = new PageInfo<Object[]>(list);
|
||||
|
||||
JSONArray json= listToJsonArray(list);
|
||||
|
||||
String result="{\"total\":"+pi.getTotal()+",\"rows\":"+json+"}";
|
||||
// System.out.println(result);
|
||||
model.addAttribute("result",result);
|
||||
|
||||
return new ModelAndView("result");
|
||||
|
||||
|
||||
|
||||
// page.setTotalCount(processDefinitionQuery.count());
|
||||
// page.setResult(objects);
|
||||
// mav.addObject("page", page);
|
||||
//
|
||||
// return mav;
|
||||
}
|
||||
/**
|
||||
* 根据流程定义,获取流程下一个任务
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public void getNextPDNode(String processDefinitionId, String activitiId, boolean flag) {
|
||||
ProcessDefinitionEntity def = (ProcessDefinitionEntity) ((RepositoryServiceImpl)repositoryService).getDeployedProcessDefinition(processDefinitionId);
|
||||
//根据流程定义获得所有的节点:
|
||||
List<ActivityImpl> activitiList = def.getActivities();
|
||||
// List<PvmTransition> outTransitions = activityImpl.getOutgoingTransitions();
|
||||
|
||||
for(ActivityImpl activityImpl:activitiList){
|
||||
String id = activityImpl.getId();
|
||||
if(activitiId.equals(id)){
|
||||
System.out.println("当前执行的任务:"+activityImpl.getProperty("name"));
|
||||
//ActivityBehavior behavior=activityImpl.getActivityBehavior();
|
||||
//获取从某个节点出来的所有子节点-网关
|
||||
List<PvmTransition> outTransitions_gw = activityImpl.getOutgoingTransitions();
|
||||
for(PvmTransition tr_gw:outTransitions_gw){
|
||||
//获取线路的终点节点-网关
|
||||
PvmActivity ac_gw = tr_gw.getDestination();
|
||||
List<PvmTransition> outTransitions = ac_gw.getOutgoingTransitions();
|
||||
for(PvmTransition tr:outTransitions){
|
||||
Condition condition=(Condition)tr.getProperty("condition");
|
||||
// condition.
|
||||
PvmActivity ac = tr.getDestination();
|
||||
System.out.println("下一步任务任务:"+ac.getProperty("name"));
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 流程定义列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/getProcessListForSelect.do")
|
||||
public ModelAndView getProcessListForSelect(HttpServletRequest request,Model model) {
|
||||
Page<Object[]> page1 = new Page<Object[]>(PageUtil.PAGE_SIZE);
|
||||
int[] pageParams = PageUtil.init(page1, request);
|
||||
|
||||
List<ProcessDefinition> list = new ArrayList<ProcessDefinition>();
|
||||
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery().active().orderByDeploymentId().desc();
|
||||
List<ProcessDefinition> processDefinitionList = processDefinitionQuery.listPage(pageParams[0], pageParams[1]);
|
||||
for (ProcessDefinition processDefinition : processDefinitionList) {
|
||||
String deploymentId = processDefinition.getDeploymentId();
|
||||
// Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
|
||||
list.add(processDefinition);//(new Object[]{processDefinition, deployment});
|
||||
}
|
||||
PageInfo<ProcessDefinition> pi = new PageInfo<ProcessDefinition>(list);
|
||||
|
||||
JSONArray json= listToJsonArray_ProcessDefinition(list);
|
||||
|
||||
|
||||
model.addAttribute("result",json);
|
||||
|
||||
return new ModelAndView("result");
|
||||
|
||||
|
||||
|
||||
// page.setTotalCount(processDefinitionQuery.count());
|
||||
// page.setResult(objects);
|
||||
// mav.addObject("page", page);
|
||||
//
|
||||
// return mav;
|
||||
}
|
||||
private JSONArray listToJsonArray( List list){
|
||||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
JSONArray json= new JSONArray();
|
||||
if (list!=null) {
|
||||
for(int i=0;i<list.size();i++){
|
||||
JSONObject item= new JSONObject();
|
||||
Object[] object =(Object[])list.get(i);
|
||||
//leave的activiti属性
|
||||
ProcessDefinitionEntity pInstance=(ProcessDefinitionEntity)object[0];
|
||||
if(pInstance!=null){
|
||||
JSONObject jbpInstance= new JSONObject();
|
||||
jbpInstance.put("deploymentId", pInstance.getDeploymentId());
|
||||
jbpInstance.put("description", pInstance.getDescription());
|
||||
jbpInstance.put("diagramResourceName", pInstance.getDiagramResourceName());
|
||||
jbpInstance.put("id", pInstance.getId());
|
||||
jbpInstance.put("name", pInstance.getName());
|
||||
jbpInstance.put("key", pInstance.getKey());
|
||||
jbpInstance.put("resourceName", pInstance.getResourceName());
|
||||
jbpInstance.put("revision", pInstance.getVersion());
|
||||
jbpInstance.put("suspended", pInstance.getSuspensionState());
|
||||
item.put("processDefinition", jbpInstance);
|
||||
}
|
||||
|
||||
Deployment pd=(Deployment)object[1];
|
||||
if(pd!=null){
|
||||
JSONObject jbpDefinition= new JSONObject();
|
||||
jbpDefinition.put("deploymentTime", sdf.format(pd.getDeploymentTime()));
|
||||
jbpDefinition.put("id", pd.getId());
|
||||
jbpDefinition.put("name", pd.getName());
|
||||
item.put("deployment", jbpDefinition);
|
||||
}
|
||||
json.add(item);
|
||||
}
|
||||
}
|
||||
sdf=null;
|
||||
return json;
|
||||
}
|
||||
private JSONArray listToJsonArray_ProcessDefinition( List list){
|
||||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
JSONArray json= new JSONArray();
|
||||
if (list!=null) {
|
||||
for(int i=0;i<list.size();i++){
|
||||
JSONObject item= new JSONObject();
|
||||
//leave的activiti属性
|
||||
ProcessDefinitionEntity pInstance=(ProcessDefinitionEntity)list.get(i);
|
||||
if(pInstance!=null){
|
||||
item.put("deploymentId", pInstance.getDeploymentId());
|
||||
item.put("description", pInstance.getDescription());
|
||||
item.put("diagramResourceName", pInstance.getDiagramResourceName());
|
||||
item.put("id", pInstance.getId());
|
||||
item.put("name", pInstance.getName());
|
||||
item.put("key", pInstance.getKey());
|
||||
item.put("resourceName", pInstance.getResourceName());
|
||||
item.put("revision", pInstance.getVersion());
|
||||
item.put("suspended", pInstance.getSuspensionState());
|
||||
}
|
||||
|
||||
json.add(item);
|
||||
}
|
||||
}
|
||||
sdf=null;
|
||||
return json;
|
||||
}
|
||||
/**
|
||||
* 部署全部流程
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "/redeploy/all")
|
||||
public String redeployAll(@Value("#{APP_PROPERTIES['export.diagram.path']}") String exportDir) throws Exception {
|
||||
workflowProcessDefinitionService.deployAllFromClasspath(exportDir);
|
||||
return "redirect:/workflow/process-list";
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取资源,通过部署ID
|
||||
*
|
||||
* @param processDefinitionId 流程定义
|
||||
* @param resourceType 资源类型(xml|image)
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "/resource/read")
|
||||
public void loadByDeployment(@RequestParam("processDefinitionId") String processDefinitionId, @RequestParam("resourceType") String resourceType,
|
||||
HttpServletResponse response) throws Exception {
|
||||
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
|
||||
String resourceName = "";
|
||||
if (resourceType.equals("image")) {
|
||||
resourceName = processDefinition.getDiagramResourceName();
|
||||
} else if (resourceType.equals("xml")) {
|
||||
resourceName = processDefinition.getResourceName();
|
||||
}
|
||||
InputStream resourceAsStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), resourceName);
|
||||
byte[] b = new byte[1024];
|
||||
int len = -1;
|
||||
while ((len = resourceAsStream.read(b, 0, 1024)) != -1) {
|
||||
response.getOutputStream().write(b, 0, len);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取资源,通过流程ID
|
||||
*
|
||||
* @param resourceType 资源类型(xml|image)
|
||||
* @param processInstanceId 流程实例ID
|
||||
* @param response
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "/resource/process-instance")
|
||||
public void loadByProcessInstance(@RequestParam("type") String resourceType, @RequestParam("pid") String processInstanceId, HttpServletResponse response)
|
||||
throws Exception {
|
||||
InputStream resourceAsStream = null;
|
||||
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
|
||||
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processInstance.getProcessDefinitionId())
|
||||
.singleResult();
|
||||
|
||||
String resourceName = "";
|
||||
if (resourceType.equals("image")) {
|
||||
resourceName = processDefinition.getDiagramResourceName();
|
||||
} else if (resourceType.equals("xml")) {
|
||||
resourceName = processDefinition.getResourceName();
|
||||
}
|
||||
resourceAsStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), resourceName);
|
||||
byte[] b = new byte[1024];
|
||||
int len = -1;
|
||||
while ((len = resourceAsStream.read(b, 0, 1024)) != -1) {
|
||||
response.getOutputStream().write(b, 0, len);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除部署的流程,级联删除流程实例
|
||||
*
|
||||
* @param deploymentId 流程部署ID
|
||||
*/
|
||||
@RequestMapping(value = "/process/delete")
|
||||
public String delete(HttpServletRequest request,Model model,
|
||||
@RequestParam("deploymentId") String deploymentId) {
|
||||
int result =0;
|
||||
try {
|
||||
repositoryService.deleteDeployment(deploymentId, true);
|
||||
result=1;
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
result =0;
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出跟踪流程信息
|
||||
*
|
||||
* @param processInstanceId
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "process/trace")
|
||||
@ResponseBody
|
||||
public List<Map<String, Object>> traceProcess(@RequestParam("pid") String processInstanceId) throws Exception {
|
||||
List<Map<String, Object>> activityInfos = traceService.traceProcess(processInstanceId,null);
|
||||
return activityInfos;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取带跟踪的图片
|
||||
*/
|
||||
@RequestMapping(value = "process/trace/auto/{executionId}")
|
||||
public void readResource(@PathVariable("executionId") String executionId, HttpServletResponse response)
|
||||
throws Exception {
|
||||
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(executionId).singleResult();
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId());
|
||||
List<String> activeActivityIds = runtimeService.getActiveActivityIds(executionId);
|
||||
// 不使用spring请使用下面的两行代码
|
||||
// ProcessEngineImpl defaultProcessEngine = (ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine();
|
||||
// Context.setProcessEngineConfiguration(defaultProcessEngine.getProcessEngineConfiguration());
|
||||
|
||||
// 使用spring注入引擎请使用下面的这行代码
|
||||
processEngineConfiguration = processEngine.getProcessEngineConfiguration();
|
||||
Context.setProcessEngineConfiguration((ProcessEngineConfigurationImpl) processEngineConfiguration);
|
||||
|
||||
ProcessDiagramGenerator diagramGenerator = processEngineConfiguration.getProcessDiagramGenerator();
|
||||
InputStream imageStream = diagramGenerator.generateDiagram(bpmnModel, "png", activeActivityIds);
|
||||
|
||||
// 输出资源内容到相应对象
|
||||
byte[] b = new byte[1024];
|
||||
int len;
|
||||
while ((len = imageStream.read(b, 0, 1024)) != -1) {
|
||||
response.getOutputStream().write(b, 0, len);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/deploy")
|
||||
public String deploy(@Value("#{APP_PROPERTIES['export.diagram.path']}") String exportDir, @RequestParam(value = "file", required = false) MultipartFile file) {
|
||||
|
||||
String fileName = file.getOriginalFilename();
|
||||
|
||||
try {
|
||||
InputStream fileInputStream = file.getInputStream();
|
||||
Deployment deployment = null;
|
||||
|
||||
String extension = FilenameUtils.getExtension(fileName);
|
||||
if (extension.equals("zip") || extension.equals("bar")) {
|
||||
ZipInputStream zip = new ZipInputStream(fileInputStream);
|
||||
deployment = repositoryService.createDeployment().addZipInputStream(zip).deploy();
|
||||
} else {
|
||||
deployment = repositoryService.createDeployment().addInputStream(fileName, fileInputStream).deploy();
|
||||
}
|
||||
|
||||
List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).list();
|
||||
|
||||
for (ProcessDefinition processDefinition : list) {
|
||||
WorkflowUtils.exportDiagramToFile(repositoryService, processDefinition, exportDir);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("error on deploy process, because of file input stream", e);
|
||||
}
|
||||
|
||||
return "redirect:/workflow/process-list";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/process/convert-to-model/{processDefinitionId}")
|
||||
public String convertToModel(@PathVariable("processDefinitionId") String processDefinitionId)
|
||||
throws UnsupportedEncodingException, XMLStreamException {
|
||||
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
|
||||
.processDefinitionId(processDefinitionId).singleResult();
|
||||
InputStream bpmnStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(),
|
||||
processDefinition.getResourceName());
|
||||
XMLInputFactory xif = XMLInputFactory.newInstance();
|
||||
InputStreamReader in = new InputStreamReader(bpmnStream, "UTF-8");
|
||||
XMLStreamReader xtr = xif.createXMLStreamReader(in);
|
||||
BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr);
|
||||
|
||||
BpmnJsonConverter converter = new BpmnJsonConverter();
|
||||
com.fasterxml.jackson.databind.node.ObjectNode modelNode = converter.convertToJson(bpmnModel);
|
||||
org.activiti.engine.repository.Model modelData = repositoryService.newModel();
|
||||
modelData.setKey(processDefinition.getKey());
|
||||
modelData.setName(processDefinition.getResourceName());
|
||||
modelData.setCategory(processDefinition.getDeploymentId());
|
||||
|
||||
ObjectNode modelObjectNode = new ObjectMapper().createObjectNode();
|
||||
modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME, processDefinition.getName());
|
||||
modelObjectNode.put(ModelDataJsonConstants.MODEL_REVISION, 1);
|
||||
modelObjectNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, processDefinition.getDescription());
|
||||
modelData.setMetaInfo(modelObjectNode.toString());
|
||||
|
||||
repositoryService.saveModel(modelData);
|
||||
|
||||
repositoryService.addModelEditorSource(modelData.getId(), modelNode.toString().getBytes("utf-8"));
|
||||
|
||||
return "redirect:/workflow/model/list";
|
||||
}
|
||||
|
||||
/**
|
||||
* 待办任务--Portlet
|
||||
*/
|
||||
/* @RequestMapping(value = "/task/todo/list")
|
||||
@ResponseBody
|
||||
public List<Map<String, Object>> todoList(HttpSession session) throws Exception {
|
||||
User user=(User)request.getSession().getAttribute("cu");
|
||||
List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm");
|
||||
|
||||
// 已经签收的任务
|
||||
List<Task> todoList = taskService.createTaskQuery().taskAssignee(user.getId()).active().list();
|
||||
for (Task task : todoList) {
|
||||
String processDefinitionId = task.getProcessDefinitionId();
|
||||
ProcessDefinition processDefinition = getProcessDefinition(processDefinitionId);
|
||||
|
||||
Map<String, Object> singleTask = packageTaskInfo(sdf, task, processDefinition);
|
||||
singleTask.put("status", "todo");
|
||||
result.add(singleTask);
|
||||
}
|
||||
|
||||
// 等待签收的任务
|
||||
List<Task> toClaimList = taskService.createTaskQuery().taskCandidateUser(user.getId()).active().list();
|
||||
for (Task task : toClaimList) {
|
||||
String processDefinitionId = task.getProcessDefinitionId();
|
||||
ProcessDefinition processDefinition = getProcessDefinition(processDefinitionId);
|
||||
|
||||
Map<String, Object> singleTask = packageTaskInfo(sdf, task, processDefinition);
|
||||
singleTask.put("status", "claim");
|
||||
result.add(singleTask);
|
||||
}
|
||||
|
||||
return result;
|
||||
}*/
|
||||
|
||||
private Map<String, Object> packageTaskInfo(SimpleDateFormat sdf, Task task, ProcessDefinition processDefinition) {
|
||||
Map<String, Object> singleTask = new HashMap<String, Object>();
|
||||
singleTask.put("id", task.getId());
|
||||
singleTask.put("name", task.getName());
|
||||
singleTask.put("createTime", sdf.format(task.getCreateTime()));
|
||||
singleTask.put("pdname", processDefinition.getName());
|
||||
singleTask.put("pdversion", processDefinition.getVersion());
|
||||
singleTask.put("pid", task.getProcessInstanceId());
|
||||
return singleTask;
|
||||
}
|
||||
|
||||
private ProcessDefinition getProcessDefinition(String processDefinitionId) {
|
||||
ProcessDefinition processDefinition = PROCESS_DEFINITION_CACHE.get(processDefinitionId);
|
||||
if (processDefinition == null) {
|
||||
processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
|
||||
PROCESS_DEFINITION_CACHE.put(processDefinitionId, processDefinition);
|
||||
}
|
||||
return processDefinition;
|
||||
}
|
||||
|
||||
/**
|
||||
* 挂起、激活流程定义
|
||||
*/
|
||||
@RequestMapping(value = "processdefinition/update.do")
|
||||
public String updateDefinitionState(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "state") String state,
|
||||
@RequestParam(value = "processDefinitionId") String processDefinitionId) {
|
||||
int result =0;
|
||||
if (state.equals("active")) {
|
||||
repositoryService.activateProcessDefinitionById(processDefinitionId, true, null);
|
||||
result=1;
|
||||
} else if (state.equals("suspend")) {
|
||||
repositoryService.suspendProcessDefinitionById(processDefinitionId, true, null);
|
||||
result=1;
|
||||
}
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
/**
|
||||
* 挂起、激活流程实例
|
||||
*/
|
||||
@RequestMapping(value = "processinstance/update.do")
|
||||
public String updateInstanceState(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "state") String state,
|
||||
@RequestParam(value = "processInstanceId") String processInstanceId) {
|
||||
int result =0;
|
||||
if (state.equals("active")) {
|
||||
runtimeService.activateProcessInstanceById(processInstanceId);
|
||||
result=1;
|
||||
} else if (state.equals("suspend")) {
|
||||
runtimeService.suspendProcessInstanceById(processInstanceId);
|
||||
result=1;
|
||||
}
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
/**
|
||||
* 导出图片文件到硬盘
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "export/diagrams")
|
||||
@ResponseBody
|
||||
public List<String> exportDiagrams(@Value("#{APP_PROPERTIES['export.diagram.path']}") String exportDir) throws IOException {
|
||||
List<String> files = new ArrayList<String>();
|
||||
List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery().list();
|
||||
|
||||
for (ProcessDefinition processDefinition : list) {
|
||||
files.add(WorkflowUtils.exportDiagramToFile(repositoryService, processDefinition, exportDir));
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "activity/jump")
|
||||
@ResponseBody
|
||||
public boolean jump(@RequestParam("executionId") String executionId,
|
||||
@RequestParam("activityId") String activityId) {
|
||||
Command<Object> cmd = new JumpActivityCmd(executionId, activityId);
|
||||
managementService.executeCommand(cmd);
|
||||
return true;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "bpmn/model/{processDefinitionId}")
|
||||
@ResponseBody
|
||||
public BpmnModel queryBpmnModel(@PathVariable("processDefinitionId") String processDefinitionId) {
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
|
||||
return bpmnModel;
|
||||
}
|
||||
/*任务节点*/
|
||||
protected static UserTask createUserTask(String id, String name, String candidateGroup) {
|
||||
List<String> candidateGroups=new ArrayList<String>();
|
||||
candidateGroups.add(candidateGroup);
|
||||
UserTask userTask = new UserTask();
|
||||
userTask.setName(name);
|
||||
userTask.setId(id);
|
||||
userTask.setCandidateGroups(candidateGroups);
|
||||
return userTask;
|
||||
}
|
||||
|
||||
/*连线*/
|
||||
protected static SequenceFlow createSequenceFlow(String from, String to,String name,String conditionExpression) {
|
||||
SequenceFlow flow = new SequenceFlow();
|
||||
flow.setSourceRef(from);
|
||||
flow.setTargetRef(to);
|
||||
flow.setName(name);
|
||||
if(StringUtils.isNotEmpty(conditionExpression)){
|
||||
flow.setConditionExpression(conditionExpression);
|
||||
}
|
||||
return flow;
|
||||
}
|
||||
|
||||
/*排他网关*/
|
||||
protected static ExclusiveGateway createExclusiveGateway(String id) {
|
||||
ExclusiveGateway exclusiveGateway = new ExclusiveGateway();
|
||||
exclusiveGateway.setId(id);
|
||||
return exclusiveGateway;
|
||||
}
|
||||
|
||||
/*开始节点*/
|
||||
protected static StartEvent createStartEvent() {
|
||||
StartEvent startEvent = new StartEvent();
|
||||
startEvent.setId("startEvent");
|
||||
return startEvent;
|
||||
}
|
||||
|
||||
/*结束节点*/
|
||||
protected static EndEvent createEndEvent() {
|
||||
EndEvent endEvent = new EndEvent();
|
||||
endEvent.setId("endEvent");
|
||||
return endEvent;
|
||||
}
|
||||
@Autowired
|
||||
public void setWorkflowProcessDefinitionService(WorkflowProcessDefinitionService workflowProcessDefinitionService) {
|
||||
this.workflowProcessDefinitionService = workflowProcessDefinitionService;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setRepositoryService(RepositoryService repositoryService) {
|
||||
this.repositoryService = repositoryService;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setRuntimeService(RuntimeService runtimeService) {
|
||||
this.runtimeService = runtimeService;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setTraceService(WorkflowTraceService traceService) {
|
||||
this.traceService = traceService;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setTaskService(TaskService taskService) {
|
||||
this.taskService = taskService;
|
||||
}
|
||||
|
||||
}
|
||||
1051
src/main/java/com/sipai/controller/activiti/ModelController.java
Normal file
1051
src/main/java/com/sipai/controller/activiti/ModelController.java
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,353 @@
|
||||
package com.sipai.controller.activiti;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.sipai.entity.activiti.ProcessType;
|
||||
import com.sipai.entity.activiti.TodoTask;
|
||||
import com.sipai.entity.equipment.EquipmentAcceptanceApply;
|
||||
import com.sipai.entity.equipment.EquipmentLoseApply;
|
||||
import com.sipai.entity.equipment.EquipmentSaleApply;
|
||||
import com.sipai.entity.equipment.EquipmentScrapApply;
|
||||
import com.sipai.entity.equipment.EquipmentStopRecord;
|
||||
import com.sipai.entity.equipment.EquipmentTransfersApply;
|
||||
import com.sipai.entity.equipment.MaintenancePlan;
|
||||
import com.sipai.entity.maintenance.Maintenance;
|
||||
import com.sipai.entity.maintenance.MaintenanceDetail;
|
||||
import com.sipai.entity.sparepart.Contract;
|
||||
import com.sipai.entity.sparepart.InStockRecord;
|
||||
import com.sipai.entity.sparepart.OutStockRecord;
|
||||
import com.sipai.entity.sparepart.StockCheck;
|
||||
import com.sipai.entity.sparepart.Subscribe;
|
||||
import com.sipai.entity.user.Company;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.entity.user.UserDetail;
|
||||
import com.sipai.entity.process.ProcessAdjustment;
|
||||
import com.sipai.service.activiti.WorkflowService;
|
||||
import com.sipai.service.base.LoginService;
|
||||
import com.sipai.service.equipment.EquipmentAcceptanceApplyService;
|
||||
import com.sipai.service.equipment.EquipmentLoseApplyService;
|
||||
import com.sipai.service.equipment.EquipmentSaleApplyService;
|
||||
import com.sipai.service.equipment.EquipmentScrapApplyService;
|
||||
import com.sipai.service.equipment.EquipmentStopRecordService;
|
||||
import com.sipai.service.equipment.EquipmentTransfersApplyService;
|
||||
import com.sipai.service.equipment.MaintenancePlanService;
|
||||
import com.sipai.service.maintenance.MaintenanceDetailService;
|
||||
import com.sipai.service.maintenance.MaintenanceService;
|
||||
import com.sipai.service.sparepart.ContractService;
|
||||
import com.sipai.service.sparepart.InStockRecordService;
|
||||
import com.sipai.service.sparepart.OutStockRecordService;
|
||||
import com.sipai.service.sparepart.StockCheckService;
|
||||
import com.sipai.service.sparepart.SubscribeService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.service.user.UserDetailService;
|
||||
import com.sipai.service.user.UserService;
|
||||
import com.sipai.service.process.ProcessAdjustmentService;
|
||||
import com.sipai.tools.CommString;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/oeProcess")
|
||||
public class OEProcessController {
|
||||
|
||||
@Resource
|
||||
private WorkflowService workflowService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
|
||||
@Resource
|
||||
private MaintenanceService maintenanceService;
|
||||
@Resource
|
||||
private MaintenanceDetailService maintenanceDetailService;
|
||||
@Resource
|
||||
private SubscribeService subscribeService;
|
||||
@Resource
|
||||
private ContractService contractService;
|
||||
@Resource
|
||||
private ProcessAdjustmentService processAdjustmentService;
|
||||
@Resource
|
||||
private InStockRecordService inStockRecordService;
|
||||
@Resource
|
||||
private OutStockRecordService outStockRecordService;
|
||||
@Resource
|
||||
private MaintenancePlanService maintenancePlanService;
|
||||
@Resource
|
||||
private StockCheckService stockCheckService;
|
||||
@Resource
|
||||
private EquipmentLoseApplyService equipmentLoseApplyService;
|
||||
@Resource
|
||||
private EquipmentScrapApplyService equipmentScrapApplyService;
|
||||
@Resource
|
||||
private EquipmentSaleApplyService equipmentSaleApplyService;
|
||||
@Resource
|
||||
private EquipmentTransfersApplyService equipmentTransfersApplyService;
|
||||
@Resource
|
||||
private EquipmentAcceptanceApplyService equipmentAcceptanceApplyService;
|
||||
|
||||
@Resource
|
||||
private EquipmentStopRecordService equipmentStopRecordService;
|
||||
@Resource
|
||||
private LoginService loginService;
|
||||
@Resource
|
||||
private UserDetailService userDetailService;
|
||||
|
||||
@RequestMapping("/nameLogin.do")
|
||||
public ModelAndView nameLogin(HttpServletRequest request,
|
||||
HttpServletResponse response,Model model) {
|
||||
|
||||
String username=request.getParameter("username");
|
||||
if(null==username || "".equals(username)){
|
||||
return new ModelAndView("login");
|
||||
}
|
||||
|
||||
List<User> userList=userService.selectListByWhere(" where name='"+username+"'");
|
||||
if(userList.size() >0 && null!=userList){
|
||||
String userId = userList.get(0).getId();
|
||||
User cu = userList.get(0);
|
||||
cu.setCurrentip(request.getRemoteAddr());
|
||||
cu.setLastlogintime(CommUtil.nowDate());
|
||||
UserDetail userDetail = this.userDetailService.selectByUserId(cu.getId());
|
||||
cu.setUserDetail(userDetail);
|
||||
if(cu.getThemeclass()==null || cu.getThemeclass().isEmpty()){
|
||||
cu.setThemeclass(CommString.Default_Theme);
|
||||
}
|
||||
Company company =unitService.getCompanyByUserId(cu.getId());
|
||||
String unitId = "";
|
||||
if (company!=null) {
|
||||
cu.set_pname(company.getSname());
|
||||
unitId = company.getId();
|
||||
}else{
|
||||
//cu.set_pname("平台");
|
||||
List<Company> companies = unitService.getCompaniesByWhere("where pid='-1' and type='C'");
|
||||
if(companies!=null){
|
||||
cu.set_pname(companies.get(0).getSname());
|
||||
unitId = companies.get(0).getId();
|
||||
}
|
||||
}
|
||||
//设置session
|
||||
HttpSession newSession = request.getSession(true);
|
||||
((HttpServletRequest) request).getSession().setAttribute(
|
||||
"cu", cu);
|
||||
newSession.setAttribute("cu", cu);
|
||||
newSession.setAttribute("unitId", unitId);
|
||||
request.setAttribute("unitId", unitId);
|
||||
model.addAttribute("cu", cu);
|
||||
return new ModelAndView("frameset");
|
||||
}else{
|
||||
return new ModelAndView("login");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping("/taskList.do")
|
||||
public String taskList(HttpServletRequest request,Model model){
|
||||
|
||||
String username=request.getParameter("username");
|
||||
String password=request.getParameter("password");
|
||||
|
||||
if(null==username || "".equals(username)){
|
||||
return "redirect:http://192.168.2.10:5001/SIPAIIS_WMS/";
|
||||
}
|
||||
if(null==password || "".equals(password)){
|
||||
return "redirect:http://192.168.2.10:5001/SIPAIIS_WMS/";
|
||||
}
|
||||
|
||||
List<User> userList=userService.selectListByWhere(" where name='"+username+"' and password='"+password+"'");
|
||||
if(userList.size() >0 && null!=userList){
|
||||
String userId = userList.get(0).getId();
|
||||
model.addAttribute("userId", userId);
|
||||
User cu = new User();
|
||||
cu = userList.get(0);
|
||||
//设置cu其他信息
|
||||
cu.setCurrentip(request.getRemoteAddr());
|
||||
cu.setLastlogintime(CommUtil.nowDate());
|
||||
|
||||
//设置session
|
||||
HttpSession newSession = request.getSession(true);
|
||||
newSession.setAttribute("cu", cu);
|
||||
//return "/activiti/taskList";
|
||||
return "/activiti/oeProcessTaskList";
|
||||
}else{
|
||||
return "redirect:http://192.168.2.10:5001/SIPAIIS_WMS/";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取生产总流程任务列表
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
@RequestMapping(value = "getTaskList.do")
|
||||
public ModelAndView getTaskList(HttpServletRequest request,Model model) {
|
||||
//User cu=(User)request.getSession().getAttribute("cu");
|
||||
//String userId = cu.getId();
|
||||
String userId=request.getParameter("userId");
|
||||
Map<String, Object> map=null;
|
||||
|
||||
/* Page<Task> page1 = new Page<Task>(PageUtil.PAGE_SIZE);
|
||||
int[] pageParams = PageUtil.init(page1, request);*/
|
||||
//筛选附件条件,用与variable筛选
|
||||
List<TodoTask> list=workflowService.findTodoTasks(userId,null,map);
|
||||
for (TodoTask todoTask : list) {
|
||||
try {
|
||||
String businessKey = todoTask.getVariables().get("businessKey").toString();
|
||||
Maintenance maintenance=null;
|
||||
if(todoTask.getType().contains(ProcessType.S_Maintenance.getId())){
|
||||
//系统默认主流程
|
||||
maintenance= this.maintenanceService.selectById(businessKey);
|
||||
todoTask.setBusiness(maintenance);
|
||||
}else if (todoTask.getType().contains(ProcessType.B_Purchase.getId())) {
|
||||
Subscribe subscribe = this.subscribeService.selectById(businessKey);
|
||||
if(subscribe!=null){
|
||||
maintenance=new Maintenance();
|
||||
Company company = unitService.getCompById(subscribe.getBizId());
|
||||
maintenance.setCompany(company);
|
||||
maintenance.setProblem("物资申购审核");
|
||||
maintenance.setStatus(todoTask.getTask().getDescription());
|
||||
todoTask.setBusiness(maintenance);
|
||||
}
|
||||
}else if (todoTask.getType().contains(ProcessType.B_Contract.getId())) {
|
||||
Contract contract = this.contractService.selectById(businessKey);
|
||||
if(contract!=null){
|
||||
maintenance=new Maintenance();
|
||||
Company company = unitService.getCompById(contract.getBizId());
|
||||
maintenance.setCompany(company);
|
||||
maintenance.setProblem("采购合同审核");
|
||||
maintenance.setStatus(todoTask.getTask().getDescription());
|
||||
todoTask.setBusiness(maintenance);
|
||||
}
|
||||
}else if(todoTask.getType().contains(ProcessType.Process_Adjustment.getId())){
|
||||
ProcessAdjustment processAdjustment = this.processAdjustmentService.selectById(businessKey);
|
||||
maintenance=new Maintenance();
|
||||
Company company = unitService.getCompById(processAdjustment.getUnitId());
|
||||
maintenance.setCompany(company);
|
||||
//将问题详情内容复制到中间变量
|
||||
maintenance.setProblem(processAdjustment.getContents());
|
||||
maintenance.setStatus(todoTask.getTask().getDescription());
|
||||
todoTask.setBusiness(maintenance);
|
||||
}else if(todoTask.getType().contains(ProcessType.B_Maintenance.getId())){
|
||||
MaintenanceDetail maintenanceDetail = this.maintenanceDetailService.selectById(businessKey);
|
||||
if (null!=maintenanceDetail.getMaintenanceid() && !maintenanceDetail.getMaintenanceid().isEmpty()) {
|
||||
maintenance= this.maintenanceService.selectById(maintenanceDetail.getMaintenanceid());
|
||||
}else{
|
||||
maintenance=new Maintenance();
|
||||
Company company = unitService.getCompById(maintenanceDetail.getCompanyid());
|
||||
maintenance.setCompany(company);
|
||||
}
|
||||
//将问题详情内容复制到中间变量
|
||||
maintenance.setProblem(maintenanceDetail.getProblemcontent());
|
||||
maintenance.setStatus(todoTask.getTask().getDescription());
|
||||
todoTask.setBusiness(maintenance);
|
||||
}else if(todoTask.getType().contains(ProcessType.I_Stock.getId())){
|
||||
InStockRecord inStockRecord = this.inStockRecordService.selectById(businessKey);
|
||||
maintenance=new Maintenance();
|
||||
Company company = unitService.getCompById(inStockRecord.getBizId());
|
||||
maintenance.setCompany(company);
|
||||
maintenance.setProblem("物资入库审核");
|
||||
maintenance.setStatus(todoTask.getTask().getDescription());
|
||||
todoTask.setBusiness(maintenance);
|
||||
}else if(todoTask.getType().contains(ProcessType.O_Stock.getId())){
|
||||
OutStockRecord outStockRecord = this.outStockRecordService.selectById(businessKey);
|
||||
maintenance=new Maintenance();
|
||||
Company company = unitService.getCompById(outStockRecord.getBizId());
|
||||
maintenance.setCompany(company);
|
||||
maintenance.setProblem("物资领用审核");
|
||||
maintenance.setStatus(todoTask.getTask().getDescription());
|
||||
todoTask.setBusiness(maintenance);
|
||||
}else if(todoTask.getType().contains(ProcessType.Stock_Check.getId())){
|
||||
StockCheck stockCheck = this.stockCheckService.selectById(businessKey);
|
||||
maintenance=new Maintenance();
|
||||
Company company = unitService.getCompById(stockCheck.getBizId());
|
||||
maintenance.setCompany(company);
|
||||
maintenance.setProblem("库存盘点审核");
|
||||
maintenance.setStatus(todoTask.getTask().getDescription());
|
||||
todoTask.setBusiness(maintenance);
|
||||
}else if(todoTask.getType().contains(ProcessType.Maintain_Plan.getId())){
|
||||
MaintenancePlan maintenancePlan = this.maintenancePlanService.selectById(businessKey);
|
||||
maintenance=new Maintenance();
|
||||
Company company = unitService.getCompById(maintenancePlan.getBizId());
|
||||
maintenance.setCompany(company);
|
||||
maintenance.setProblem(maintenancePlan.getContent());
|
||||
maintenance.setStatus(todoTask.getTask().getDescription());
|
||||
todoTask.setBusiness(maintenance);
|
||||
}else if(todoTask.getType().contains(ProcessType.Lose_Apply.getId())){
|
||||
EquipmentLoseApply loseApply = this.equipmentLoseApplyService.selectById(businessKey);
|
||||
maintenance=new Maintenance();
|
||||
Company company = unitService.getCompById(loseApply.getBizId());
|
||||
maintenance.setCompany(company);
|
||||
maintenance.setProblem("设备丢失申请");
|
||||
maintenance.setStatus(todoTask.getTask().getDescription());
|
||||
todoTask.setBusiness(maintenance);
|
||||
}else if(todoTask.getType().contains(ProcessType.Sale_Apply.getId())){
|
||||
EquipmentSaleApply saleApply = this.equipmentSaleApplyService.selectById(businessKey);
|
||||
maintenance=new Maintenance();
|
||||
Company company = unitService.getCompById(saleApply.getBizId());
|
||||
maintenance.setCompany(company);
|
||||
maintenance.setProblem("设备出售申请");
|
||||
maintenance.setStatus(todoTask.getTask().getDescription());
|
||||
todoTask.setBusiness(maintenance);
|
||||
}else if(todoTask.getType().contains(ProcessType.Scrap_Apply.getId())){
|
||||
EquipmentScrapApply scrapApply = this.equipmentScrapApplyService.selectById(businessKey);
|
||||
maintenance=new Maintenance();
|
||||
Company company = unitService.getCompById(scrapApply.getBizId());
|
||||
maintenance.setCompany(company);
|
||||
maintenance.setProblem("设备报废申请");
|
||||
maintenance.setStatus(todoTask.getTask().getDescription());
|
||||
todoTask.setBusiness(maintenance);
|
||||
}else if(todoTask.getType().contains(ProcessType.Transfers_Apply.getId())){
|
||||
EquipmentTransfersApply transfersApply = this.equipmentTransfersApplyService.selectById(businessKey);
|
||||
maintenance=new Maintenance();
|
||||
Company company = unitService.getCompById(transfersApply.getBizId());
|
||||
maintenance.setCompany(company);
|
||||
maintenance.setProblem("设备调拨申请");
|
||||
maintenance.setStatus(todoTask.getTask().getDescription());
|
||||
todoTask.setBusiness(maintenance);
|
||||
}else if(todoTask.getType().contains(ProcessType.Acceptance_Apply.getId())){
|
||||
EquipmentAcceptanceApply eaa = equipmentAcceptanceApplyService.selectById(businessKey);
|
||||
maintenance=new Maintenance();
|
||||
Company company = unitService.getCompById(eaa.getBizId());
|
||||
maintenance.setCompany(company);
|
||||
maintenance.setProblem("设备验收申请");
|
||||
maintenance.setStatus(todoTask.getTask().getDescription());
|
||||
todoTask.setBusiness(maintenance);
|
||||
}else if(todoTask.getType().contains(ProcessType.EquipmentStop_Apply.getId())){
|
||||
EquipmentStopRecord esr = equipmentStopRecordService.selectById(businessKey);
|
||||
maintenance=new Maintenance();
|
||||
Company company = unitService.getCompById(esr.getBizId());
|
||||
maintenance.setCompany(company);
|
||||
maintenance.setProblem("设备停用申请");
|
||||
maintenance.setStatus(todoTask.getTask().getDescription());
|
||||
todoTask.setBusiness(maintenance);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
JSONArray json= this.workflowService.todoTasklistToJsonArray(list);
|
||||
String result="{\"total\":"+list.size()+",\"rows\":"+json+"}";
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,164 @@
|
||||
package com.sipai.controller.administration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.administration.IndexClass;
|
||||
import com.sipai.entity.administration.IndexClass;
|
||||
import com.sipai.entity.user.Company;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.administration.IndexClassService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/administration/indexClass")
|
||||
public class IndexClassController {
|
||||
@Resource
|
||||
private IndexClassService indexClassService;
|
||||
|
||||
@RequestMapping("/showList.do")
|
||||
public String showList(HttpServletRequest request, Model model) {
|
||||
return "/administration/indexClassList";
|
||||
}
|
||||
|
||||
@RequestMapping("/getIndexClassJson.do")
|
||||
public String getIndexClassJson(HttpServletRequest request,Model model){
|
||||
List<IndexClass> list = this.indexClassService.selectListByWhere("where 1=1 order by morder");
|
||||
String json = this.indexClassService.getTreeList(null, list);
|
||||
model.addAttribute("result", json);
|
||||
return "result";
|
||||
}
|
||||
@RequestMapping("/getList.do")
|
||||
public ModelAndView getList(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required = false) String sort,
|
||||
@RequestParam(value = "order", required = false) String order) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
if (sort==null || sort.equals("id")) {
|
||||
sort = " insdt ";
|
||||
}
|
||||
if (order == null) {
|
||||
order = " desc ";
|
||||
}
|
||||
String orderstr = " order by "+sort+" "+order;
|
||||
String wherestr = " where 1=1 ";
|
||||
if (request.getParameter("search_code")!= null && !request.getParameter("search_code").isEmpty()) {
|
||||
wherestr += " and unit_id = '"+request.getParameter("search_code")+"'";
|
||||
}
|
||||
if (request.getParameter("search_name")!= null && !request.getParameter("search_name").isEmpty()) {
|
||||
wherestr += " and name like '%"+request.getParameter("search_name")+"%'";
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<IndexClass> list = this.indexClassService.selectListByWhere(wherestr+orderstr);
|
||||
PageInfo<IndexClass> pInfo = new PageInfo<IndexClass>(list);
|
||||
JSONArray jsonArray = JSONArray.fromObject(list);
|
||||
String result = "{\"total\":"+pInfo.getTotal()+",\"rows\":"+jsonArray+"}";
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/showList4Select.do")
|
||||
public String showList4Select(HttpServletRequest request,Model model){
|
||||
return "administration/indexClass4select";
|
||||
}
|
||||
|
||||
@RequestMapping("/add.do")
|
||||
public String doadd (HttpServletRequest request,Model model,
|
||||
@RequestParam(value="pid") String pid){
|
||||
if(pid!= null && !pid.equals("") && !pid.equals("-1")){
|
||||
IndexClass indexClass= this.indexClassService.selectById(pid);
|
||||
model.addAttribute("pname",indexClass.getName());
|
||||
}
|
||||
return "/administration/indexClassAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/save.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute IndexClass indexClass) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
indexClass.setId(CommUtil.getUUID());
|
||||
indexClass.setInsdt(CommUtil.nowDate());
|
||||
indexClass.setInsuser(cu.getId());
|
||||
int result = this.indexClassService.save(indexClass);
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/delete.do")
|
||||
public String dodelete(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
int result = this.indexClassService.deleteById(id);
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/deletes.do")
|
||||
public String dodeletes(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "ids") String ids){
|
||||
ids = ids.replace(",","','");
|
||||
int result = this.indexClassService.deleteByWhere("where id in ('"+ids+"')");
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/edit.do")
|
||||
public String doedit(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
IndexClass indexClass = this.indexClassService.selectById(id);
|
||||
model.addAttribute("indexClass", indexClass);
|
||||
return "/administration/indexClassEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/update.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute IndexClass indexClass) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
indexClass.setInsdt(CommUtil.nowDate());
|
||||
indexClass.setInsuser(cu.getId());
|
||||
int result = this.indexClassService.update(indexClass);
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/view.do")
|
||||
public String doview(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
IndexClass indexClass = this.indexClassService.selectById(id);
|
||||
model.addAttribute("indexClass", indexClass);
|
||||
return "/administration/indexClassView";
|
||||
}
|
||||
/**
|
||||
* 获取合同类型
|
||||
* */
|
||||
@RequestMapping("/getIndexClass4Select.do")
|
||||
public String getIndexClass4Select(HttpServletRequest request,Model model){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
JSONArray json=new JSONArray();
|
||||
List<IndexClass> list = this.indexClassService.selectListByWhere("where 1=1");
|
||||
if(list!=null && list.size()>0){
|
||||
for (IndexClass indexClass : list) {
|
||||
JSONObject jsonObject =new JSONObject();
|
||||
jsonObject.put("id", indexClass.getId());
|
||||
jsonObject.put("text", indexClass.getName());
|
||||
json.add(jsonObject);
|
||||
}
|
||||
}
|
||||
model.addAttribute("result", json.toString());
|
||||
return "result";
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,197 @@
|
||||
package com.sipai.controller.administration;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.apache.batik.ext.awt.geom.Cubic;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.administration.Index;
|
||||
import com.sipai.entity.administration.IndexCycle;
|
||||
import com.sipai.entity.base.CommonFile;
|
||||
import com.sipai.entity.sparepart.SubscribeDetail;
|
||||
import com.sipai.entity.user.Company;
|
||||
import com.sipai.entity.user.Unit;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.administration.IndexCycleService;
|
||||
import com.sipai.service.administration.IndexService;
|
||||
import com.sipai.service.base.CommonFileService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.service.user.UserService;
|
||||
import com.sipai.tools.CommString;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/administration/index")
|
||||
public class IndexController {
|
||||
@Resource
|
||||
private IndexService indexService;
|
||||
|
||||
@Resource
|
||||
private IndexCycleService indexCycleService;
|
||||
|
||||
@RequestMapping("/showList.do")
|
||||
public String showList(HttpServletRequest request, Model model) {
|
||||
return "/administration/indexList";
|
||||
}
|
||||
@RequestMapping("/getIndexJson.do")
|
||||
public String getIndexJson(HttpServletRequest request,Model model){
|
||||
List<Index> list = this.indexService.selectListByWhere("where 1=1 order by morder");
|
||||
String json = this.indexService.getTreeList(null, list);
|
||||
model.addAttribute("result", json);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/getList.do")
|
||||
public ModelAndView getList(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required = false) String sort,
|
||||
@RequestParam(value = "order", required = false) String order) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
if (sort==null || sort.equals("id")) {
|
||||
sort = " insdt ";
|
||||
}
|
||||
if (order == null) {
|
||||
order = " desc ";
|
||||
}
|
||||
String orderstr = " order by "+sort+" "+order;
|
||||
String wherestr = " where 1=1 ";
|
||||
if (request.getParameter("search_code")!= null && !request.getParameter("search_code").isEmpty()) {
|
||||
wherestr += " and unit_id = '"+request.getParameter("search_code")+"'";
|
||||
}
|
||||
if (request.getParameter("search_name")!= null && !request.getParameter("search_name").isEmpty()) {
|
||||
wherestr += " and name like '%"+request.getParameter("search_name")+"%'";
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<Index> list = this.indexService.selectListByWhere(wherestr+orderstr);
|
||||
PageInfo<Index> pInfo = new PageInfo<Index>(list);
|
||||
JSONArray jsonArray = JSONArray.fromObject(list);
|
||||
String result = "{\"total\":"+pInfo.getTotal()+",\"rows\":"+jsonArray+"}";
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/add.do")
|
||||
public String doadd(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="pid") String pid){
|
||||
if(pid!= null && !pid.equals("") && !pid.equals("-1")){
|
||||
Index index= this.indexService.selectById(pid);
|
||||
model.addAttribute("pname",index.getName());
|
||||
}
|
||||
return "/administration/indexAdd";
|
||||
}
|
||||
@RequestMapping("/save.do")
|
||||
public ModelAndView dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute Index index) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
index.setId(CommUtil.getUUID());
|
||||
index.setInsdt(CommUtil.nowDate());
|
||||
index.setInsuser(cu.getId());
|
||||
int result = this.indexService.save(index);
|
||||
if(result==1){
|
||||
//生成1-12月的附表数据
|
||||
BigDecimal money = new BigDecimal(0);
|
||||
IndexCycle indexCycle=null;
|
||||
for(int i=1;i<13;i++){
|
||||
indexCycle = new IndexCycle();
|
||||
indexCycle.setId(CommUtil.getUUID());
|
||||
indexCycle.setInsdt(CommUtil.nowDate());
|
||||
indexCycle.setInsuser(cu.getId());
|
||||
indexCycle.setPid(index.getId());
|
||||
indexCycle.setName(i+"月");
|
||||
indexCycle.setMorder(i);
|
||||
indexCycle.setActive("启用");
|
||||
indexCycle.setMoney(money);
|
||||
indexCycleService.save(indexCycle);
|
||||
}
|
||||
|
||||
}
|
||||
String resultstr = "{\"res\":\""+result+"\",\"id\":\""+index.getId()+"\"}";
|
||||
model.addAttribute("result",resultstr);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
@RequestMapping("/showList4Select.do")
|
||||
public String showList4Select(HttpServletRequest request,Model model){
|
||||
return "administration/index4select";
|
||||
}
|
||||
@RequestMapping("/delete.do")
|
||||
public ModelAndView dodelete(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id){
|
||||
int result = this.indexService.deleteById(id);
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
@RequestMapping("/deletes.do")
|
||||
public String dodeletes(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "ids") String ids){
|
||||
ids = ids.replace(",","','");
|
||||
int result = this.indexService.deleteByWhere("where id in ('"+ids+"')");
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/edit.do")
|
||||
public String doedit(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
Index index = this.indexService.selectById(id);
|
||||
model.addAttribute("index", index);
|
||||
return "/administration/indexEdit";
|
||||
}
|
||||
@RequestMapping("/update.do")
|
||||
public ModelAndView doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute Index index) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
index.setInsdt(CommUtil.nowDate());
|
||||
index.setInsuser(cu.getId());
|
||||
int result = this.indexService.update(index);
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
@RequestMapping("/view.do")
|
||||
public String doview(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
Index index = this.indexService.selectById(id);
|
||||
model.addAttribute("index", index);
|
||||
return "/administration/indexView";
|
||||
}
|
||||
|
||||
/**
|
||||
* 明细修改后更新金额
|
||||
* @param request
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/updateIndexCycle.do")
|
||||
public String doupdateIndexCycle(HttpServletRequest request,Model model) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String id = request.getParameter("id");
|
||||
String money = request.getParameter("money");//价格
|
||||
IndexCycle indexCycle = this.indexCycleService.selectById(id);
|
||||
if(null != money && !money.equals("")){
|
||||
BigDecimal moneyBD = new BigDecimal(money);
|
||||
indexCycle.setMoney(moneyBD);
|
||||
}
|
||||
int result = this.indexCycleService.update(indexCycle);
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+indexCycle.getId()+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,180 @@
|
||||
package com.sipai.controller.administration;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.administration.IndexCycle;
|
||||
import com.sipai.entity.administration.IndexCycle;
|
||||
import com.sipai.entity.user.Company;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.administration.IndexCycleService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/administration/indexCycle")
|
||||
public class IndexCycleController {
|
||||
@Resource
|
||||
private IndexCycleService indexCycleService;
|
||||
|
||||
@RequestMapping("/showList.do")
|
||||
public String showList(HttpServletRequest request, Model model) {
|
||||
return "/administration/indexCycleList";
|
||||
}
|
||||
|
||||
@RequestMapping("/getIndexCycleJson.do")
|
||||
public String getIndexCycleJson(HttpServletRequest request,Model model){
|
||||
|
||||
String wherestr="";
|
||||
if (request.getParameter("pid")!= null && !request.getParameter("pid").isEmpty()) {
|
||||
wherestr += " and pid = '"+request.getParameter("pid")+"'";
|
||||
}
|
||||
|
||||
List<IndexCycle> list = this.indexCycleService.selectListByWhere("where 1=1 "+wherestr+" order by morder");
|
||||
String json = this.indexCycleService.getTreeList(null, list);
|
||||
model.addAttribute("result", json);
|
||||
return "result";
|
||||
}
|
||||
@RequestMapping("/getList.do")
|
||||
public ModelAndView getList(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required = false) String sort,
|
||||
@RequestParam(value = "order", required = false) String order) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
if (sort==null || sort.equals("id")) {
|
||||
sort = " morder ";
|
||||
}
|
||||
if (order == null) {
|
||||
order = " asc ";
|
||||
}
|
||||
String orderstr = " order by "+sort+" "+order;
|
||||
String wherestr = " where 1=1 ";
|
||||
if (request.getParameter("search_code")!= null && !request.getParameter("search_code").isEmpty()) {
|
||||
wherestr += " and unit_id = '"+request.getParameter("search_code")+"'";
|
||||
}
|
||||
if (request.getParameter("search_name")!= null && !request.getParameter("search_name").isEmpty()) {
|
||||
wherestr += " and name like '%"+request.getParameter("search_name")+"%'";
|
||||
}
|
||||
if (request.getParameter("pid")!= null && !request.getParameter("pid").isEmpty()) {
|
||||
wherestr += " and pid = '"+request.getParameter("pid")+"'";
|
||||
}
|
||||
|
||||
PageHelper.startPage(page, rows);
|
||||
List<IndexCycle> list = this.indexCycleService.selectListByWhere(wherestr+orderstr);
|
||||
PageInfo<IndexCycle> pInfo = new PageInfo<IndexCycle>(list);
|
||||
JSONArray jsonArray = JSONArray.fromObject(list);
|
||||
String result = "{\"total\":"+pInfo.getTotal()+",\"rows\":"+jsonArray+"}";
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/showList4Select.do")
|
||||
public String showList4Select(HttpServletRequest request,Model model){
|
||||
return "administration/indexCycle4select";
|
||||
}
|
||||
|
||||
@RequestMapping("/add.do")
|
||||
public String doadd (HttpServletRequest request,Model model,
|
||||
@RequestParam(value="pid") String pid){
|
||||
if(pid!= null && !pid.equals("") && !pid.equals("-1")){
|
||||
IndexCycle indexCycle= this.indexCycleService.selectById(pid);
|
||||
model.addAttribute("pname",indexCycle.getName());
|
||||
}
|
||||
return "/administration/indexCycleAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/save.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute IndexCycle indexCycle) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
indexCycle.setId(CommUtil.getUUID());
|
||||
indexCycle.setInsdt(CommUtil.nowDate());
|
||||
indexCycle.setInsuser(cu.getId());
|
||||
int result = this.indexCycleService.save(indexCycle);
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/delete.do")
|
||||
public String dodelete(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
int result = this.indexCycleService.deleteById(id);
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/deletes.do")
|
||||
public String dodeletes(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "ids") String ids){
|
||||
ids = ids.replace(",","','");
|
||||
int result = this.indexCycleService.deleteByWhere("where id in ('"+ids+"')");
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/edit.do")
|
||||
public String doedit(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
IndexCycle indexCycle = this.indexCycleService.selectById(id);
|
||||
model.addAttribute("indexCycle", indexCycle);
|
||||
return "/administration/indexCycleEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/update.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute IndexCycle indexCycle) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
indexCycle.setInsdt(CommUtil.nowDate());
|
||||
indexCycle.setInsuser(cu.getId());
|
||||
int result = this.indexCycleService.update(indexCycle);
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/view.do")
|
||||
public String doview(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
IndexCycle indexCycle = this.indexCycleService.selectById(id);
|
||||
model.addAttribute("indexCycle", indexCycle);
|
||||
return "/administration/indexCycleView";
|
||||
}
|
||||
/**
|
||||
* 获取合同类型
|
||||
* */
|
||||
@RequestMapping("/getIndexCycle4Select.do")
|
||||
public String getIndexCycle4Select(HttpServletRequest request,Model model){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
String wherestr="";
|
||||
if (request.getParameter("pid")!= null && !request.getParameter("pid").isEmpty()) {
|
||||
wherestr += " and pid = '"+request.getParameter("pid")+"'";
|
||||
}
|
||||
JSONArray json=new JSONArray();
|
||||
List<IndexCycle> list = this.indexCycleService.selectListByWhere("where 1=1 "+wherestr+" order by morder");
|
||||
if(list!=null && list.size()>0){
|
||||
for (IndexCycle indexCycle : list) {
|
||||
JSONObject jsonObject =new JSONObject();
|
||||
jsonObject.put("id", indexCycle.getId());
|
||||
jsonObject.put("text", indexCycle.getName()+"("+indexCycle.getMoney().setScale(2, BigDecimal.ROUND_HALF_UP )+")");
|
||||
jsonObject.put("money", indexCycle.getMoney().setScale(2, BigDecimal.ROUND_HALF_UP ));
|
||||
json.add(jsonObject);
|
||||
}
|
||||
}
|
||||
model.addAttribute("result", json.toString());
|
||||
return "result";
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,429 @@
|
||||
package com.sipai.controller.administration;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
|
||||
import org.activiti.engine.RuntimeService;
|
||||
import org.activiti.engine.TaskService;
|
||||
import org.activiti.engine.history.HistoricTaskInstance;
|
||||
import org.activiti.engine.impl.pvm.process.ActivityImpl;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.activiti.WorkTask;
|
||||
import com.sipai.entity.administration.IndexWork;
|
||||
import com.sipai.entity.business.BusinessUnit;
|
||||
import com.sipai.entity.business.BusinessUnitAudit;
|
||||
import com.sipai.entity.business.BusinessUnitHandle;
|
||||
import com.sipai.entity.business.BusinessUnitRecord;
|
||||
import com.sipai.entity.user.Company;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.activiti.WorkflowProcessDefinitionService;
|
||||
import com.sipai.service.activiti.WorkflowService;
|
||||
import com.sipai.service.administration.IndexWorkService;
|
||||
import com.sipai.service.business.BusinessUnitAuditService;
|
||||
import com.sipai.service.business.BusinessUnitHandleService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.service.user.UserService;
|
||||
import com.sipai.tools.ActivitiUtil;
|
||||
import com.sipai.tools.CommString;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/administration/indexWork")
|
||||
public class IndexWorkController {
|
||||
@Resource
|
||||
private IndexWorkService indexWorkService;
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
@Resource
|
||||
private WorkflowProcessDefinitionService workflowProcessDefinitionService;
|
||||
@Resource
|
||||
private BusinessUnitHandleService businessUnitHandleService;
|
||||
@Resource
|
||||
private BusinessUnitAuditService businessUnitAuditService;
|
||||
@Resource
|
||||
private WorkflowService workflowService;
|
||||
@Resource
|
||||
private RuntimeService runtimeService;
|
||||
@Resource
|
||||
private TaskService taskService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@RequestMapping("/showList.do")
|
||||
public String showList(HttpServletRequest request, Model model) {
|
||||
return "/administration/indexWorkList";
|
||||
}
|
||||
|
||||
@RequestMapping("/getList.do")
|
||||
public ModelAndView getList(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required = false) String sort,
|
||||
@RequestParam(value = "order", required = false) String order) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
if (sort==null || sort.equals("id")) {
|
||||
sort = " insdt ";
|
||||
}
|
||||
if (order == null) {
|
||||
order = " desc ";
|
||||
}
|
||||
String orderstr = " order by "+sort+" "+order;
|
||||
String wherestr = " where 1=1 ";
|
||||
if (request.getParameter("search_code")!= null && !request.getParameter("search_code").isEmpty()) {
|
||||
wherestr += " and unit_id = '"+request.getParameter("search_code")+"'";
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<IndexWork> list = this.indexWorkService.selectListByWhere(wherestr+orderstr);
|
||||
PageInfo<IndexWork> pInfo = new PageInfo<IndexWork>(list);
|
||||
JSONArray jsonArray = JSONArray.fromObject(list);
|
||||
String result = "{\"total\":"+pInfo.getTotal()+",\"rows\":"+jsonArray+"}";
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/add.do")
|
||||
public String doadd (HttpServletRequest request,Model model) {
|
||||
String companyId = request.getParameter("companyId");
|
||||
Company company = this.unitService.getCompById(companyId);
|
||||
String id = company.getEname()+"-ZBKZ-"+CommUtil.nowDate().replaceAll("[[\\s-:punct:]]","");
|
||||
model.addAttribute("id",id);
|
||||
model.addAttribute("company",company);
|
||||
return "/administration/indexWorkAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/save.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute IndexWork indexWork) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
indexWork.setInsdt(CommUtil.nowDate());
|
||||
indexWork.setInsuser(cu.getId());
|
||||
int result = this.indexWorkService.save(indexWork);
|
||||
String resultstr = "{\"res\":\""+result+"\",\"id\":\""+indexWork.getId()+"\"}";
|
||||
model.addAttribute("result",resultstr);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/delete.do")
|
||||
public String dodelete(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
int result = this.indexWorkService.deleteById(id);
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/deletes.do")
|
||||
public String dodeletes(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "ids") String ids){
|
||||
ids = ids.replace(",","','");
|
||||
int result = this.indexWorkService.deleteByWhere("where id in ('"+ids+"')");
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/edit.do")
|
||||
public String doedit(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
IndexWork indexWork = this.indexWorkService.selectById(id);
|
||||
model.addAttribute("indexWork", indexWork);
|
||||
return "/administration/indexWorkEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/update.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute IndexWork indexWork) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
indexWork.setInsdt(CommUtil.nowDate());
|
||||
indexWork.setInsuser(cu.getId());
|
||||
int result = this.indexWorkService.update(indexWork);
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+indexWork.getId()+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/view.do")
|
||||
public String doview(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
IndexWork indexWork = this.indexWorkService.selectById(id);
|
||||
model.addAttribute("indexWork", indexWork);
|
||||
return "/administration/indexWorkView";
|
||||
}
|
||||
/**
|
||||
* 更新,启动指标审核流程
|
||||
* */
|
||||
@RequestMapping("/startProcess.do")
|
||||
public String dostartProcess(HttpServletRequest request,Model model,
|
||||
@ModelAttribute IndexWork indexWork){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
indexWork.setInsuser(cu.getId());
|
||||
indexWork.setInsdt(CommUtil.nowDate());
|
||||
indexWorkService.update(indexWork);
|
||||
indexWork = indexWorkService.selectById(indexWork.getId());
|
||||
int result=0;
|
||||
try {
|
||||
result =this.indexWorkService.startProcess(indexWork);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
}
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+indexWork.getId()+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
/**
|
||||
* 查看指标处理流程详情
|
||||
* @param request
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/showProcessIndexWorkView.do")
|
||||
public String showProcessIndexWorkView(HttpServletRequest request,Model model){
|
||||
String indexWorkId = request.getParameter("id");
|
||||
IndexWork indexWork = this.indexWorkService.selectById(indexWorkId);
|
||||
request.setAttribute("business", indexWork);
|
||||
List<BusinessUnitRecord> businessUnitRecords = new ArrayList<>();
|
||||
BusinessUnitRecord businessUnitRecord = new BusinessUnitRecord(indexWork);
|
||||
businessUnitRecords.add(businessUnitRecord);
|
||||
|
||||
List<WorkTask> workTasks=workflowProcessDefinitionService.getAllPDTask(indexWork.getProcessdefid(), "desc");
|
||||
List<String> keys=new ArrayList<>();
|
||||
for (WorkTask workTask : workTasks) {
|
||||
keys.add(workTask.getTaskKey());
|
||||
}
|
||||
Set set = new HashSet();
|
||||
set.addAll(keys);
|
||||
keys=new ArrayList<>();
|
||||
keys.addAll(set);
|
||||
for (String item : keys) {
|
||||
switch (item) {
|
||||
case BusinessUnit.UNIT_IndexWork_HANDLE:
|
||||
List<BusinessUnitHandle> list = businessUnitHandleService.selectListByWhere("where businessid='"+indexWorkId+"' ");
|
||||
for (BusinessUnitHandle businessUnitHandle : list) {
|
||||
businessUnitRecord = new BusinessUnitRecord(businessUnitHandle);
|
||||
businessUnitRecords.add(businessUnitRecord);
|
||||
}
|
||||
break;
|
||||
case BusinessUnit.UNIT_IndexWork_AUDIT:
|
||||
List<BusinessUnitAudit> list_audit = businessUnitAuditService.selectListByWhere("where businessid='"+indexWorkId+"' ");
|
||||
for (BusinessUnitAudit businessUnitAudit : list_audit) {
|
||||
businessUnitRecord = new BusinessUnitRecord(businessUnitAudit);
|
||||
businessUnitRecords.add(businessUnitRecord);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
//展示最新任务是否签收
|
||||
String processId = indexWork.getProcessid();
|
||||
List<HistoricTaskInstance> list=this.workflowService.getHistoryService() // 历史相关Service
|
||||
.createHistoricTaskInstanceQuery() // 创建历史任务实例查询
|
||||
.processInstanceId(processId) // 用流程实例id查询
|
||||
.list();
|
||||
for (HistoricTaskInstance task : list) {
|
||||
if (task.getAssignee()==null || task.getClaimTime()==null) {
|
||||
continue;
|
||||
}
|
||||
businessUnitRecord = new BusinessUnitRecord(task);
|
||||
businessUnitRecords.add(businessUnitRecord);
|
||||
}
|
||||
Collections.sort(businessUnitRecords, new Comparator<BusinessUnitRecord>() {
|
||||
public int compare(BusinessUnitRecord o1, BusinessUnitRecord o2) {
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
||||
try{
|
||||
Date dt1 = df.parse(o1.getInsdt());
|
||||
Date dt2 = df.parse(o2.getInsdt());
|
||||
if (dt1.getTime() > dt2.getTime()) {
|
||||
return 1;
|
||||
} else if (dt1.getTime() < dt2.getTime()) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
JSONArray jsonArray =JSONArray.fromObject(businessUnitRecords);
|
||||
model.addAttribute("businessUnitRecords",jsonArray);
|
||||
//检测流程实例是否结束,结束则历史记录最后节点变化
|
||||
long num =runtimeService.createProcessInstanceQuery().processInstanceId(indexWork.getProcessid()).count();
|
||||
if(num>0){
|
||||
model.addAttribute("finishFlag", false);
|
||||
}else{
|
||||
model.addAttribute("finishFlag", true);
|
||||
}
|
||||
|
||||
if(request.getParameter("inModal")!=null){
|
||||
//判断显示在流程处理模态框右侧
|
||||
return "administration/indexWorkExecuteViewInModal";
|
||||
}else{
|
||||
return "administration/indexWorkExecuteView";
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 显示指标审核
|
||||
* */
|
||||
@RequestMapping("/showAuditIndexWork.do")
|
||||
public String showAuditIndexWork(HttpServletRequest request,Model model){
|
||||
String taskId = request.getParameter("taskId");
|
||||
String processInstanceId = request.getParameter("processInstanceId");
|
||||
BusinessUnitAudit businessUnitAudit=new BusinessUnitAudit();
|
||||
|
||||
Task task = this.taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||
model.addAttribute("taskName", task.getName());
|
||||
|
||||
businessUnitAudit.setId(CommUtil.getUUID());
|
||||
businessUnitAudit.setProcessid(processInstanceId);
|
||||
businessUnitAudit.setTaskid(taskId);
|
||||
ProcessInstance pInstance=runtimeService.createProcessInstanceQuery()
|
||||
.processInstanceId(processInstanceId)
|
||||
.singleResult();
|
||||
businessUnitAudit.setBusinessid(pInstance.getBusinessKey());
|
||||
businessUnitAudit.setTaskdefinitionkey(task.getTaskDefinitionKey());
|
||||
model.addAttribute("businessUnitAudit", businessUnitAudit);
|
||||
String indexWorkId= pInstance.getBusinessKey();
|
||||
IndexWork indexWork = this.indexWorkService.selectById(indexWorkId);
|
||||
model.addAttribute("indexWork", indexWork);
|
||||
|
||||
//获取任务下一节点,若为任务节点,则显示目标用户div,否则不显示
|
||||
List<ActivityImpl> activityImpls=workflowProcessDefinitionService.getNEXTActivities(task.getProcessDefinitionId(), task.getTaskDefinitionKey());
|
||||
if (activityImpls.size()>0) {
|
||||
model.addAttribute("showTargetUsersFlag", true);
|
||||
}else{
|
||||
model.addAttribute("showTargetUsersFlag", false);
|
||||
}
|
||||
return "administration/indexWorkAudit";
|
||||
}
|
||||
/**
|
||||
* 流程流转
|
||||
* */
|
||||
@RequestMapping("/AuditIndexWork.do")
|
||||
public String doAuditIndexWork(HttpServletRequest request,Model model,
|
||||
@ModelAttribute BusinessUnitAudit businessUnitAudit){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
int result=0;
|
||||
businessUnitAudit.setInsuser(cu.getId());
|
||||
businessUnitAudit.setInsdt(CommUtil.nowDate());
|
||||
result =this.indexWorkService.doAudit(businessUnitAudit);
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+businessUnitAudit.getId()+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
/**
|
||||
* 显示指标业务处理
|
||||
* */
|
||||
@RequestMapping("/showIndexWorkHandle.do")
|
||||
public String showIndexWorkHandle(HttpServletRequest request,Model model){
|
||||
String taskId = request.getParameter("taskId");
|
||||
String processInstanceId = request.getParameter("processInstanceId");
|
||||
String unitId = request.getParameter("unitId");
|
||||
ProcessInstance pInstance=runtimeService.createProcessInstanceQuery()
|
||||
.processInstanceId(processInstanceId)
|
||||
.singleResult();
|
||||
BusinessUnitHandle businessUnitHandle = new BusinessUnitHandle();
|
||||
Task task = this.taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||
model.addAttribute("taskName", task.getName());
|
||||
List<BusinessUnitHandle> businessUnitHandles = this.businessUnitHandleService.selectListByWhere("where processid='"+processInstanceId+"' and taskId='"+taskId+"'");
|
||||
if(businessUnitHandles!= null && businessUnitHandles.size()>0){
|
||||
businessUnitHandle = businessUnitHandles.get(0);
|
||||
//若任务退回后,需更新新的任务id
|
||||
businessUnitHandle.setTaskid(taskId);
|
||||
}else{
|
||||
businessUnitHandle.setId(CommUtil.getUUID());
|
||||
businessUnitHandle.setProcessid(processInstanceId);
|
||||
businessUnitHandle.setTaskid(taskId);
|
||||
businessUnitHandle.setBusinessid(pInstance.getBusinessKey());
|
||||
businessUnitHandle.setTaskdefinitionkey(task.getTaskDefinitionKey());
|
||||
businessUnitHandle.setUnitid(unitId);
|
||||
}
|
||||
String userIds = businessUnitHandle.getTargetusers();
|
||||
if(userIds!= null && !userIds.isEmpty()){
|
||||
List<User> users = userService.selectListByWhere("where id in('"+userIds.replace(",", "','")+"')");
|
||||
String targetUsersName ="";
|
||||
for (User user : users) {
|
||||
if(!targetUsersName.isEmpty()){
|
||||
targetUsersName+=",";
|
||||
}
|
||||
targetUsersName+=user.getCaption();
|
||||
}
|
||||
model.addAttribute("targetUsersName", targetUsersName);
|
||||
}
|
||||
|
||||
model.addAttribute("businessUnitHandle", businessUnitHandle);
|
||||
model.addAttribute("nowDate", CommUtil.nowDate());
|
||||
String indexWorkId = pInstance.getBusinessKey();
|
||||
IndexWork indexWork = this.indexWorkService.selectById(indexWorkId);
|
||||
List<BusinessUnitAudit> list = this.businessUnitAuditService.selectListByWhere("where businessId = '"+indexWorkId+"' order by insdt desc ");
|
||||
if(list!=null && list.size()>0){
|
||||
model.addAttribute("businessUnitAudit", list.get(0));
|
||||
}
|
||||
model.addAttribute("indexWork", indexWork);
|
||||
return "administration/indexWorkHandle";
|
||||
}
|
||||
/**
|
||||
* 流程流程,指标业务处理提交
|
||||
* */
|
||||
@RequestMapping("/submitIndexWorkHandle.do")
|
||||
public String dosubmitIndexWorkHandle(HttpServletRequest request,Model model,
|
||||
@ModelAttribute BusinessUnitHandle businessUnitHandle){
|
||||
String routeNum=request.getParameter("routeNum");
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
int result=0;
|
||||
if(!this.businessUnitHandleService.checkExit(businessUnitHandle)) {
|
||||
businessUnitHandle.setInsuser(cu.getId());
|
||||
businessUnitHandle.setInsdt(CommUtil.nowDate());
|
||||
result =this.businessUnitHandleService.save(businessUnitHandle);
|
||||
}else {
|
||||
result =this.businessUnitHandleService.update(businessUnitHandle);
|
||||
}
|
||||
try {
|
||||
Map<String, Object> variables = new HashMap<String, Object>();
|
||||
variables =ActivitiUtil.fixVariableWithRoute(variables, true, routeNum);
|
||||
variables.put(CommString.ACTI_KEK_Candidate_Users, businessUnitHandle.getTargetusers());
|
||||
variables.put(CommString.ACTI_KEK_Assignee, null);
|
||||
taskService.complete(businessUnitHandle.getTaskid(), variables);
|
||||
//发送消息
|
||||
if(businessUnitHandle.getTargetusers()!=null && !businessUnitHandle.getTargetusers().isEmpty()){
|
||||
//补全所有字段信息
|
||||
businessUnitHandle = businessUnitHandleService.selectById(businessUnitHandle.getId());
|
||||
BusinessUnitRecord businessUnitRecord = new BusinessUnitRecord(businessUnitHandle);
|
||||
businessUnitRecord.sendMessage(businessUnitHandle.getTargetusers(),"");
|
||||
}
|
||||
this.indexWorkService.updateStatus(businessUnitHandle.getBusinessid());
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
result=0;
|
||||
}
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+businessUnitHandle.getId()+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,171 @@
|
||||
package com.sipai.controller.administration;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.administration.OrganizationClass;
|
||||
import com.sipai.entity.administration.OrganizationClass;
|
||||
import com.sipai.entity.user.Company;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.administration.OrganizationClassService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/administration/organizationClass")
|
||||
public class OrganizationClassController {
|
||||
@Resource
|
||||
private OrganizationClassService organizationClassService;
|
||||
|
||||
@RequestMapping("/showList.do")
|
||||
public String showList(HttpServletRequest request, Model model) {
|
||||
return "/administration/organizationClassList";
|
||||
}
|
||||
|
||||
@RequestMapping("/getOrganizationClassJson.do")
|
||||
public String getOrganizationClassJson(HttpServletRequest request,Model model){
|
||||
List<OrganizationClass> list = this.organizationClassService.selectListByWhere("where 1=1 order by morder");
|
||||
String json = this.organizationClassService.getTreeList(null, list);
|
||||
model.addAttribute("result", json);
|
||||
return "result";
|
||||
}
|
||||
@RequestMapping("/getList.do")
|
||||
public ModelAndView getList(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required = false) String sort,
|
||||
@RequestParam(value = "order", required = false) String order) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
if (sort==null || sort.equals("id")) {
|
||||
sort = " insdt ";
|
||||
}
|
||||
if (order == null) {
|
||||
order = " desc ";
|
||||
}
|
||||
String orderstr = " order by "+sort+" "+order;
|
||||
String wherestr = " where 1=1 ";
|
||||
if (request.getParameter("search_code")!= null && !request.getParameter("search_code").isEmpty()) {
|
||||
wherestr += " and unit_id = '"+request.getParameter("search_code")+"'";
|
||||
}
|
||||
if (request.getParameter("search_name")!= null && !request.getParameter("search_name").isEmpty()) {
|
||||
wherestr += " and name like '%"+request.getParameter("search_name")+"%'";
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<OrganizationClass> list = this.organizationClassService.selectListByWhere(wherestr+orderstr);
|
||||
PageInfo<OrganizationClass> pInfo = new PageInfo<OrganizationClass>(list);
|
||||
JSONArray jsonArray = JSONArray.fromObject(list);
|
||||
String result = "{\"total\":"+pInfo.getTotal()+",\"rows\":"+jsonArray+"}";
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/showList4Select.do")
|
||||
public String showList4Select(HttpServletRequest request,Model model){
|
||||
return "administration/organizationClass4select";
|
||||
}
|
||||
|
||||
@RequestMapping("/add.do")
|
||||
public String doadd (HttpServletRequest request,Model model,
|
||||
@RequestParam(value="pid") String pid){
|
||||
if(pid!= null && !pid.equals("") && !pid.equals("-1")){
|
||||
OrganizationClass organizationClass= this.organizationClassService.selectById(pid);
|
||||
if(organizationClass!=null){
|
||||
model.addAttribute("pname",organizationClass.getName());
|
||||
}else{
|
||||
|
||||
}
|
||||
}
|
||||
return "/administration/organizationClassAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/save.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute OrganizationClass organizationClass) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
organizationClass.setId(CommUtil.getUUID());
|
||||
organizationClass.setInsdt(CommUtil.nowDate());
|
||||
organizationClass.setInsuser(cu.getId());
|
||||
int result = this.organizationClassService.save(organizationClass);
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/delete.do")
|
||||
public String dodelete(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
int result = this.organizationClassService.deleteById(id);
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/deletes.do")
|
||||
public String dodeletes(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "ids") String ids){
|
||||
ids = ids.replace(",","','");
|
||||
int result = this.organizationClassService.deleteByWhere("where id in ('"+ids+"')");
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/edit.do")
|
||||
public String doedit(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
OrganizationClass organizationClass = this.organizationClassService.selectById(id);
|
||||
model.addAttribute("organizationClass", organizationClass);
|
||||
return "/administration/organizationClassEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/update.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute OrganizationClass organizationClass) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
organizationClass.setInsdt(CommUtil.nowDate());
|
||||
organizationClass.setInsuser(cu.getId());
|
||||
int result = this.organizationClassService.update(organizationClass);
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/view.do")
|
||||
public String doview(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
OrganizationClass organizationClass = this.organizationClassService.selectById(id);
|
||||
model.addAttribute("organizationClass", organizationClass);
|
||||
return "/administration/organizationClassView";
|
||||
}
|
||||
/**
|
||||
* 获取合同类型
|
||||
* */
|
||||
@RequestMapping("/getOrganizationClass4Select.do")
|
||||
public String getOrganizationClass4Select(HttpServletRequest request,Model model){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
JSONArray json=new JSONArray();
|
||||
List<OrganizationClass> list = this.organizationClassService.selectListByWhere("where 1=1");
|
||||
if(list!=null && list.size()>0){
|
||||
for (OrganizationClass organizationClass : list) {
|
||||
JSONObject jsonObject =new JSONObject();
|
||||
jsonObject.put("id", organizationClass.getId());
|
||||
jsonObject.put("text", organizationClass.getName());
|
||||
jsonObject.put("code", organizationClass.getCode());
|
||||
json.add(jsonObject);
|
||||
}
|
||||
}
|
||||
model.addAttribute("result", json.toString());
|
||||
return "result";
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,457 @@
|
||||
package com.sipai.controller.administration;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
|
||||
import org.activiti.engine.RuntimeService;
|
||||
import org.activiti.engine.TaskService;
|
||||
import org.activiti.engine.history.HistoricTaskInstance;
|
||||
import org.activiti.engine.impl.pvm.process.ActivityImpl;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.activiti.WorkTask;
|
||||
import com.sipai.entity.administration.Organization;
|
||||
import com.sipai.entity.administration.OrganizationCommStr;
|
||||
import com.sipai.entity.business.BusinessUnit;
|
||||
import com.sipai.entity.business.BusinessUnitAudit;
|
||||
import com.sipai.entity.business.BusinessUnitHandle;
|
||||
import com.sipai.entity.business.BusinessUnitRecord;
|
||||
import com.sipai.entity.user.Company;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.activiti.WorkflowProcessDefinitionService;
|
||||
import com.sipai.service.activiti.WorkflowService;
|
||||
import com.sipai.service.administration.OrganizationService;
|
||||
import com.sipai.service.business.BusinessUnitAuditService;
|
||||
import com.sipai.service.business.BusinessUnitHandleService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.service.user.UserService;
|
||||
import com.sipai.tools.ActivitiUtil;
|
||||
import com.sipai.tools.CommString;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/administration/organization")
|
||||
public class OrganizationController {
|
||||
@Resource
|
||||
private OrganizationService organizationService;
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
@Resource
|
||||
private WorkflowProcessDefinitionService workflowProcessDefinitionService;
|
||||
@Resource
|
||||
private BusinessUnitHandleService businessUnitHandleService;
|
||||
@Resource
|
||||
private BusinessUnitAuditService businessUnitAuditService;
|
||||
@Resource
|
||||
private WorkflowService workflowService;
|
||||
@Resource
|
||||
private RuntimeService runtimeService;
|
||||
@Resource
|
||||
private TaskService taskService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@RequestMapping("/showList.do")
|
||||
public String showList(HttpServletRequest request, Model model) {
|
||||
return "/administration/organizationList";
|
||||
}
|
||||
|
||||
@RequestMapping("/getList.do")
|
||||
public ModelAndView getList(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required = false) String sort,
|
||||
@RequestParam(value = "order", required = false) String order) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
if (sort==null || sort.equals("id")) {
|
||||
sort = " insdt ";
|
||||
}
|
||||
if (order == null) {
|
||||
order = " desc ";
|
||||
}
|
||||
String orderstr = " order by "+sort+" "+order;
|
||||
String wherestr = " where 1=1 ";
|
||||
if (request.getParameter("search_code")!= null && !request.getParameter("search_code").isEmpty()) {
|
||||
wherestr += " and unit_id = '"+request.getParameter("search_code")+"'";
|
||||
}
|
||||
if (request.getParameter("typeid")!= null && !request.getParameter("typeid").isEmpty()) {
|
||||
wherestr += " and typeid = '"+request.getParameter("typeid")+"'";
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<Organization> list = this.organizationService.selectListByWhere(wherestr+orderstr);
|
||||
PageInfo<Organization> pInfo = new PageInfo<Organization>(list);
|
||||
JSONArray jsonArray = JSONArray.fromObject(list);
|
||||
String result = "{\"total\":"+pInfo.getTotal()+",\"rows\":"+jsonArray+"}";
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/add.do")
|
||||
public String doadd (HttpServletRequest request,Model model) {
|
||||
String companyId = request.getParameter("companyId");
|
||||
Company company = this.unitService.getCompById(companyId);
|
||||
String id = company.getEname()+"-ZZYA-"+CommUtil.nowDate().replaceAll("[[\\s-:punct:]]","");
|
||||
model.addAttribute("id",id);
|
||||
model.addAttribute("company",company);
|
||||
return "/administration/organizationAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/save.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute Organization organization) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
organization.setInsdt(CommUtil.nowDate());
|
||||
organization.setInsuser(cu.getId());
|
||||
int result = this.organizationService.save(organization);
|
||||
String resultstr = "{\"res\":\""+result+"\",\"id\":\""+organization.getId()+"\"}";
|
||||
model.addAttribute("result",resultstr);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/delete.do")
|
||||
public String dodelete(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
int result = this.organizationService.deleteById(id);
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/deletes.do")
|
||||
public String dodeletes(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "ids") String ids){
|
||||
ids = ids.replace(",","','");
|
||||
int result = this.organizationService.deleteByWhere("where id in ('"+ids+"')");
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/edit.do")
|
||||
public String doedit(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
Organization organization = this.organizationService.selectById(id);
|
||||
model.addAttribute("organization", organization);
|
||||
return "/administration/organizationEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/update.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute Organization organization) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
organization.setInsdt(CommUtil.nowDate());
|
||||
organization.setInsuser(cu.getId());
|
||||
int result = this.organizationService.update(organization);
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+organization.getId()+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/view.do")
|
||||
public String doview(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
Organization organization = this.organizationService.selectById(id);
|
||||
model.addAttribute("organization", organization);
|
||||
return "/administration/organizationView";
|
||||
}
|
||||
/**
|
||||
* 更新,启动指标审核流程
|
||||
* */
|
||||
@RequestMapping("/startProcess.do")
|
||||
public String dostartProcess(HttpServletRequest request,Model model,
|
||||
@ModelAttribute Organization organization){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
organization.setInsuser(cu.getId());
|
||||
organization.setInsdt(CommUtil.nowDate());
|
||||
int result=0;
|
||||
try {
|
||||
result =this.organizationService.startProcess(organization);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
}
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+organization.getId()+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
/**
|
||||
* 查看指标处理流程详情
|
||||
* @param request
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/showProcessOrganizationView.do")
|
||||
public String showProcessOrganizationView(HttpServletRequest request,Model model){
|
||||
String organizationId = request.getParameter("id");
|
||||
Organization organization = this.organizationService.selectById(organizationId);
|
||||
request.setAttribute("business", organization);
|
||||
List<BusinessUnitRecord> businessUnitRecords = new ArrayList<>();
|
||||
BusinessUnitRecord businessUnitRecord = new BusinessUnitRecord(organization);
|
||||
businessUnitRecords.add(businessUnitRecord);
|
||||
|
||||
List<WorkTask> workTasks=workflowProcessDefinitionService.getAllPDTask(organization.getProcessdefid(), "desc");
|
||||
List<String> keys=new ArrayList<>();
|
||||
for (WorkTask workTask : workTasks) {
|
||||
keys.add(workTask.getTaskKey());
|
||||
}
|
||||
Set set = new HashSet();
|
||||
set.addAll(keys);
|
||||
keys=new ArrayList<>();
|
||||
keys.addAll(set);
|
||||
|
||||
String type=organization.getTypeid();
|
||||
if (OrganizationCommStr.Administration_Type_Organization.equals(type)) {
|
||||
for (String item : keys) {
|
||||
switch (item) {
|
||||
case BusinessUnit.UNIT_Organization_HANDLE:
|
||||
List<BusinessUnitHandle> list = businessUnitHandleService.selectListByWhere("where businessid='"+organizationId+"' ");
|
||||
for (BusinessUnitHandle businessUnitHandle : list) {
|
||||
businessUnitRecord = new BusinessUnitRecord(businessUnitHandle);
|
||||
businessUnitRecords.add(businessUnitRecord);
|
||||
}
|
||||
break;
|
||||
case BusinessUnit.UNIT_Organization_AUDIT:
|
||||
List<BusinessUnitAudit> list_audit = businessUnitAuditService.selectListByWhere("where businessid='"+organizationId+"' ");
|
||||
for (BusinessUnitAudit businessUnitAudit : list_audit) {
|
||||
businessUnitRecord = new BusinessUnitRecord(businessUnitAudit);
|
||||
businessUnitRecords.add(businessUnitRecord);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else if(OrganizationCommStr.Administration_Type_Reserve.equals(type)) {
|
||||
for (String item : keys) {
|
||||
switch (item) {
|
||||
case BusinessUnit.UNIT_Reserve_HANDLE:
|
||||
List<BusinessUnitHandle> list = businessUnitHandleService.selectListByWhere("where businessid='"+organizationId+"' ");
|
||||
for (BusinessUnitHandle businessUnitHandle : list) {
|
||||
businessUnitRecord = new BusinessUnitRecord(businessUnitHandle);
|
||||
businessUnitRecords.add(businessUnitRecord);
|
||||
}
|
||||
break;
|
||||
case BusinessUnit.UNIT_Reserve_AUDIT:
|
||||
List<BusinessUnitAudit> list_audit = businessUnitAuditService.selectListByWhere("where businessid='"+organizationId+"' ");
|
||||
for (BusinessUnitAudit businessUnitAudit : list_audit) {
|
||||
businessUnitRecord = new BusinessUnitRecord(businessUnitAudit);
|
||||
businessUnitRecords.add(businessUnitRecord);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//展示最新任务是否签收
|
||||
String processId = organization.getProcessid();
|
||||
List<HistoricTaskInstance> list=this.workflowService.getHistoryService() // 历史相关Service
|
||||
.createHistoricTaskInstanceQuery() // 创建历史任务实例查询
|
||||
.processInstanceId(processId) // 用流程实例id查询
|
||||
.list();
|
||||
for (HistoricTaskInstance task : list) {
|
||||
if (task.getAssignee()==null || task.getClaimTime()==null) {
|
||||
continue;
|
||||
}
|
||||
businessUnitRecord = new BusinessUnitRecord(task);
|
||||
businessUnitRecords.add(businessUnitRecord);
|
||||
}
|
||||
Collections.sort(businessUnitRecords, new Comparator<BusinessUnitRecord>() {
|
||||
public int compare(BusinessUnitRecord o1, BusinessUnitRecord o2) {
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
||||
try{
|
||||
Date dt1 = df.parse(o1.getInsdt());
|
||||
Date dt2 = df.parse(o2.getInsdt());
|
||||
if (dt1.getTime() > dt2.getTime()) {
|
||||
return 1;
|
||||
} else if (dt1.getTime() < dt2.getTime()) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
JSONArray jsonArray =JSONArray.fromObject(businessUnitRecords);
|
||||
model.addAttribute("businessUnitRecords",jsonArray);
|
||||
//检测流程实例是否结束,结束则历史记录最后节点变化
|
||||
long num =runtimeService.createProcessInstanceQuery().processInstanceId(organization.getProcessid()).count();
|
||||
if(num>0){
|
||||
model.addAttribute("finishFlag", false);
|
||||
}else{
|
||||
model.addAttribute("finishFlag", true);
|
||||
}
|
||||
|
||||
if(request.getParameter("inModal")!=null){
|
||||
//判断显示在流程处理模态框右侧
|
||||
return "administration/organizationExecuteViewInModal";
|
||||
}else{
|
||||
return "administration/organizationExecuteView";
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 显示指标审核
|
||||
* */
|
||||
@RequestMapping("/showAuditOrganization.do")
|
||||
public String showAuditOrganization(HttpServletRequest request,Model model){
|
||||
String taskId = request.getParameter("taskId");
|
||||
String processInstanceId = request.getParameter("processInstanceId");
|
||||
BusinessUnitAudit businessUnitAudit=new BusinessUnitAudit();
|
||||
|
||||
Task task = this.taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||
model.addAttribute("taskName", task.getName());
|
||||
|
||||
businessUnitAudit.setId(CommUtil.getUUID());
|
||||
businessUnitAudit.setProcessid(processInstanceId);
|
||||
businessUnitAudit.setTaskid(taskId);
|
||||
ProcessInstance pInstance=runtimeService.createProcessInstanceQuery()
|
||||
.processInstanceId(processInstanceId)
|
||||
.singleResult();
|
||||
businessUnitAudit.setBusinessid(pInstance.getBusinessKey());
|
||||
businessUnitAudit.setTaskdefinitionkey(task.getTaskDefinitionKey());
|
||||
model.addAttribute("businessUnitAudit", businessUnitAudit);
|
||||
String organizationId= pInstance.getBusinessKey();
|
||||
Organization organization = this.organizationService.selectById(organizationId);
|
||||
model.addAttribute("organization", organization);
|
||||
|
||||
//获取任务下一节点,若为任务节点,则显示目标用户div,否则不显示
|
||||
List<ActivityImpl> activityImpls=workflowProcessDefinitionService.getNEXTActivities(task.getProcessDefinitionId(), task.getTaskDefinitionKey());
|
||||
if (activityImpls.size()>0) {
|
||||
model.addAttribute("showTargetUsersFlag", true);
|
||||
}else{
|
||||
model.addAttribute("showTargetUsersFlag", false);
|
||||
}
|
||||
return "administration/organizationAudit";
|
||||
}
|
||||
/**
|
||||
* 流程流转
|
||||
* */
|
||||
@RequestMapping("/AuditOrganization.do")
|
||||
public String doAuditOrganization(HttpServletRequest request,Model model,
|
||||
@ModelAttribute BusinessUnitAudit businessUnitAudit){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
int result=0;
|
||||
businessUnitAudit.setInsuser(cu.getId());
|
||||
businessUnitAudit.setInsdt(CommUtil.nowDate());
|
||||
result =this.organizationService.doAudit(businessUnitAudit);
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+businessUnitAudit.getId()+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
/**
|
||||
* 显示指标业务处理
|
||||
* */
|
||||
@RequestMapping("/showOrganizationHandle.do")
|
||||
public String showOrganizationHandle(HttpServletRequest request,Model model){
|
||||
String taskId = request.getParameter("taskId");
|
||||
String processInstanceId = request.getParameter("processInstanceId");
|
||||
String unitId = request.getParameter("unitId");
|
||||
ProcessInstance pInstance=runtimeService.createProcessInstanceQuery()
|
||||
.processInstanceId(processInstanceId)
|
||||
.singleResult();
|
||||
BusinessUnitHandle businessUnitHandle = new BusinessUnitHandle();
|
||||
Task task = this.taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||
model.addAttribute("taskName", task.getName());
|
||||
List<BusinessUnitHandle> businessUnitHandles = this.businessUnitHandleService.selectListByWhere("where processid='"+processInstanceId+"' and taskId='"+taskId+"'");
|
||||
if(businessUnitHandles!= null && businessUnitHandles.size()>0){
|
||||
businessUnitHandle = businessUnitHandles.get(0);
|
||||
//若任务退回后,需更新新的任务id
|
||||
businessUnitHandle.setTaskid(taskId);
|
||||
}else{
|
||||
businessUnitHandle.setId(CommUtil.getUUID());
|
||||
businessUnitHandle.setProcessid(processInstanceId);
|
||||
businessUnitHandle.setTaskid(taskId);
|
||||
businessUnitHandle.setBusinessid(pInstance.getBusinessKey());
|
||||
businessUnitHandle.setTaskdefinitionkey(task.getTaskDefinitionKey());
|
||||
businessUnitHandle.setUnitid(unitId);
|
||||
}
|
||||
String userIds = businessUnitHandle.getTargetusers();
|
||||
if(userIds!= null && !userIds.isEmpty()){
|
||||
List<User> users = userService.selectListByWhere("where id in('"+userIds.replace(",", "','")+"')");
|
||||
String targetUsersName ="";
|
||||
for (User user : users) {
|
||||
if(!targetUsersName.isEmpty()){
|
||||
targetUsersName+=",";
|
||||
}
|
||||
targetUsersName+=user.getCaption();
|
||||
}
|
||||
model.addAttribute("targetUsersName", targetUsersName);
|
||||
}
|
||||
|
||||
model.addAttribute("businessUnitHandle", businessUnitHandle);
|
||||
model.addAttribute("nowDate", CommUtil.nowDate());
|
||||
String organizationId = pInstance.getBusinessKey();
|
||||
Organization organization = this.organizationService.selectById(organizationId);
|
||||
List<BusinessUnitAudit> list = this.businessUnitAuditService.selectListByWhere("where businessId = '"+organizationId+"' order by insdt desc ");
|
||||
|
||||
if(list!=null && list.size()>0){
|
||||
model.addAttribute("businessUnitAudit", list.get(0));
|
||||
}
|
||||
model.addAttribute("organization", organization);
|
||||
return "administration/organizationHandle";
|
||||
}
|
||||
/**
|
||||
* 流程流程,指标业务处理提交
|
||||
* */
|
||||
@RequestMapping("/submitOrganizationHandle.do")
|
||||
public String dosubmitOrganizationHandle(HttpServletRequest request,Model model,
|
||||
@ModelAttribute BusinessUnitHandle businessUnitHandle){
|
||||
String routeNum=request.getParameter("routeNum");
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
int result=0;
|
||||
if(!this.businessUnitHandleService.checkExit(businessUnitHandle)) {
|
||||
businessUnitHandle.setInsuser(cu.getId());
|
||||
businessUnitHandle.setInsdt(CommUtil.nowDate());
|
||||
result =this.businessUnitHandleService.save(businessUnitHandle);
|
||||
}else {
|
||||
result =this.businessUnitHandleService.update(businessUnitHandle);
|
||||
}
|
||||
try {
|
||||
Map<String, Object> variables = new HashMap<String, Object>();
|
||||
variables =ActivitiUtil.fixVariableWithRoute(variables, true, routeNum);
|
||||
variables.put(CommString.ACTI_KEK_Candidate_Users, businessUnitHandle.getTargetusers());
|
||||
variables.put(CommString.ACTI_KEK_Assignee, null);
|
||||
taskService.complete(businessUnitHandle.getTaskid(), variables);
|
||||
//发送消息
|
||||
if(businessUnitHandle.getTargetusers()!=null && !businessUnitHandle.getTargetusers().isEmpty()){
|
||||
//补全所有字段信息
|
||||
businessUnitHandle = businessUnitHandleService.selectById(businessUnitHandle.getId());
|
||||
BusinessUnitRecord businessUnitRecord = new BusinessUnitRecord(businessUnitHandle);
|
||||
businessUnitRecord.sendMessage(businessUnitHandle.getTargetusers(),"");
|
||||
}
|
||||
this.organizationService.updateStatus(businessUnitHandle.getBusinessid());
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
result=0;
|
||||
}
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+businessUnitHandle.getId()+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,429 @@
|
||||
package com.sipai.controller.administration;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
|
||||
import org.activiti.engine.RuntimeService;
|
||||
import org.activiti.engine.TaskService;
|
||||
import org.activiti.engine.history.HistoricTaskInstance;
|
||||
import org.activiti.engine.impl.pvm.process.ActivityImpl;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.activiti.WorkTask;
|
||||
import com.sipai.entity.administration.Temporary;
|
||||
import com.sipai.entity.business.BusinessUnit;
|
||||
import com.sipai.entity.business.BusinessUnitAudit;
|
||||
import com.sipai.entity.business.BusinessUnitHandle;
|
||||
import com.sipai.entity.business.BusinessUnitRecord;
|
||||
import com.sipai.entity.user.Company;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.activiti.WorkflowProcessDefinitionService;
|
||||
import com.sipai.service.activiti.WorkflowService;
|
||||
import com.sipai.service.administration.TemporaryService;
|
||||
import com.sipai.service.business.BusinessUnitAuditService;
|
||||
import com.sipai.service.business.BusinessUnitHandleService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.service.user.UserService;
|
||||
import com.sipai.tools.ActivitiUtil;
|
||||
import com.sipai.tools.CommString;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/administration/temporary")
|
||||
public class TemporaryController {
|
||||
@Resource
|
||||
private TemporaryService temporaryService;
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
@Resource
|
||||
private WorkflowProcessDefinitionService workflowProcessDefinitionService;
|
||||
@Resource
|
||||
private BusinessUnitHandleService businessUnitHandleService;
|
||||
@Resource
|
||||
private BusinessUnitAuditService businessUnitAuditService;
|
||||
@Resource
|
||||
private WorkflowService workflowService;
|
||||
@Resource
|
||||
private RuntimeService runtimeService;
|
||||
@Resource
|
||||
private TaskService taskService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@RequestMapping("/showList.do")
|
||||
public String showList(HttpServletRequest request, Model model) {
|
||||
return "/administration/temporaryList";
|
||||
}
|
||||
|
||||
@RequestMapping("/getList.do")
|
||||
public ModelAndView getList(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required = false) String sort,
|
||||
@RequestParam(value = "order", required = false) String order) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
if (sort==null || sort.equals("id")) {
|
||||
sort = " insdt ";
|
||||
}
|
||||
if (order == null) {
|
||||
order = " desc ";
|
||||
}
|
||||
String orderstr = " order by "+sort+" "+order;
|
||||
String wherestr = " where 1=1 ";
|
||||
if (request.getParameter("search_code")!= null && !request.getParameter("search_code").isEmpty()) {
|
||||
wherestr += " and unit_id = '"+request.getParameter("search_code")+"'";
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<Temporary> list = this.temporaryService.selectListByWhere(wherestr+orderstr);
|
||||
PageInfo<Temporary> pInfo = new PageInfo<Temporary>(list);
|
||||
JSONArray jsonArray = JSONArray.fromObject(list);
|
||||
String result = "{\"total\":"+pInfo.getTotal()+",\"rows\":"+jsonArray+"}";
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/add.do")
|
||||
public String doadd (HttpServletRequest request,Model model) {
|
||||
String companyId = request.getParameter("companyId");
|
||||
Company company = this.unitService.getCompById(companyId);
|
||||
String id = company.getEname()+"-ZZYA-"+CommUtil.nowDate().replaceAll("[[\\s-:punct:]]","");
|
||||
model.addAttribute("id",id);
|
||||
model.addAttribute("company",company);
|
||||
return "/administration/temporaryAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/save.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute Temporary temporary) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
temporary.setInsdt(CommUtil.nowDate());
|
||||
temporary.setInsuser(cu.getId());
|
||||
int result = this.temporaryService.save(temporary);
|
||||
String resultstr = "{\"res\":\""+result+"\",\"id\":\""+temporary.getId()+"\"}";
|
||||
model.addAttribute("result",resultstr);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/delete.do")
|
||||
public String dodelete(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
int result = this.temporaryService.deleteById(id);
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/deletes.do")
|
||||
public String dodeletes(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "ids") String ids){
|
||||
ids = ids.replace(",","','");
|
||||
int result = this.temporaryService.deleteByWhere("where id in ('"+ids+"')");
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/edit.do")
|
||||
public String doedit(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
Temporary temporary = this.temporaryService.selectById(id);
|
||||
model.addAttribute("temporary", temporary);
|
||||
return "/administration/temporaryEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/update.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute Temporary temporary) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
temporary.setInsdt(CommUtil.nowDate());
|
||||
temporary.setInsuser(cu.getId());
|
||||
int result = this.temporaryService.update(temporary);
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+temporary.getId()+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/view.do")
|
||||
public String doview(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
Temporary temporary = this.temporaryService.selectById(id);
|
||||
model.addAttribute("temporary", temporary);
|
||||
return "/administration/temporaryView";
|
||||
}
|
||||
/**
|
||||
* 更新,启动指标审核流程
|
||||
* */
|
||||
@RequestMapping("/startProcess.do")
|
||||
public String dostartProcess(HttpServletRequest request,Model model,
|
||||
@ModelAttribute Temporary temporary){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
temporary.setInsuser(cu.getId());
|
||||
temporary.setInsdt(CommUtil.nowDate());
|
||||
int result=0;
|
||||
try {
|
||||
result =this.temporaryService.startProcess(temporary);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
}
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+temporary.getId()+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
/**
|
||||
* 查看指标处理流程详情
|
||||
* @param request
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/showProcessTemporaryView.do")
|
||||
public String showProcessTemporaryView(HttpServletRequest request,Model model){
|
||||
String temporaryId = request.getParameter("id");
|
||||
Temporary temporary = this.temporaryService.selectById(temporaryId);
|
||||
request.setAttribute("business", temporary);
|
||||
List<BusinessUnitRecord> businessUnitRecords = new ArrayList<>();
|
||||
BusinessUnitRecord businessUnitRecord = new BusinessUnitRecord(temporary);
|
||||
businessUnitRecords.add(businessUnitRecord);
|
||||
|
||||
List<WorkTask> workTasks=workflowProcessDefinitionService.getAllPDTask(temporary.getProcessdefid(), "desc");
|
||||
List<String> keys=new ArrayList<>();
|
||||
for (WorkTask workTask : workTasks) {
|
||||
keys.add(workTask.getTaskKey());
|
||||
}
|
||||
Set set = new HashSet();
|
||||
set.addAll(keys);
|
||||
keys=new ArrayList<>();
|
||||
keys.addAll(set);
|
||||
|
||||
for (String item : keys) {
|
||||
switch (item) {
|
||||
case BusinessUnit.UNIT_Temporary_HANDLE:
|
||||
List<BusinessUnitHandle> list = businessUnitHandleService.selectListByWhere("where businessid='"+temporaryId+"' ");
|
||||
for (BusinessUnitHandle businessUnitHandle : list) {
|
||||
businessUnitRecord = new BusinessUnitRecord(businessUnitHandle);
|
||||
businessUnitRecords.add(businessUnitRecord);
|
||||
}
|
||||
break;
|
||||
case BusinessUnit.UNIT_Temporary_AUDIT:
|
||||
List<BusinessUnitAudit> list_audit = businessUnitAuditService.selectListByWhere("where businessid='"+temporaryId+"' ");
|
||||
for (BusinessUnitAudit businessUnitAudit : list_audit) {
|
||||
businessUnitRecord = new BusinessUnitRecord(businessUnitAudit);
|
||||
businessUnitRecords.add(businessUnitRecord);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
//展示最新任务是否签收
|
||||
String processId = temporary.getProcessid();
|
||||
List<HistoricTaskInstance> list=this.workflowService.getHistoryService() // 历史相关Service
|
||||
.createHistoricTaskInstanceQuery() // 创建历史任务实例查询
|
||||
.processInstanceId(processId) // 用流程实例id查询
|
||||
.list();
|
||||
for (HistoricTaskInstance task : list) {
|
||||
if (task.getAssignee()==null || task.getClaimTime()==null) {
|
||||
continue;
|
||||
}
|
||||
businessUnitRecord = new BusinessUnitRecord(task);
|
||||
businessUnitRecords.add(businessUnitRecord);
|
||||
}
|
||||
Collections.sort(businessUnitRecords, new Comparator<BusinessUnitRecord>() {
|
||||
public int compare(BusinessUnitRecord o1, BusinessUnitRecord o2) {
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
||||
try{
|
||||
Date dt1 = df.parse(o1.getInsdt());
|
||||
Date dt2 = df.parse(o2.getInsdt());
|
||||
if (dt1.getTime() > dt2.getTime()) {
|
||||
return 1;
|
||||
} else if (dt1.getTime() < dt2.getTime()) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
JSONArray jsonArray =JSONArray.fromObject(businessUnitRecords);
|
||||
model.addAttribute("businessUnitRecords",jsonArray);
|
||||
//检测流程实例是否结束,结束则历史记录最后节点变化
|
||||
long num =runtimeService.createProcessInstanceQuery().processInstanceId(temporary.getProcessid()).count();
|
||||
if(num>0){
|
||||
model.addAttribute("finishFlag", false);
|
||||
}else{
|
||||
model.addAttribute("finishFlag", true);
|
||||
}
|
||||
|
||||
if(request.getParameter("inModal")!=null){
|
||||
//判断显示在流程处理模态框右侧
|
||||
return "administration/temporaryExecuteViewInModal";
|
||||
}else{
|
||||
return "administration/temporaryExecuteView";
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 显示指标审核
|
||||
* */
|
||||
@RequestMapping("/showAuditTemporary.do")
|
||||
public String showAuditTemporary(HttpServletRequest request,Model model){
|
||||
String taskId = request.getParameter("taskId");
|
||||
String processInstanceId = request.getParameter("processInstanceId");
|
||||
BusinessUnitAudit businessUnitAudit=new BusinessUnitAudit();
|
||||
|
||||
Task task = this.taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||
model.addAttribute("taskName", task.getName());
|
||||
|
||||
businessUnitAudit.setId(CommUtil.getUUID());
|
||||
businessUnitAudit.setProcessid(processInstanceId);
|
||||
businessUnitAudit.setTaskid(taskId);
|
||||
ProcessInstance pInstance=runtimeService.createProcessInstanceQuery()
|
||||
.processInstanceId(processInstanceId)
|
||||
.singleResult();
|
||||
businessUnitAudit.setBusinessid(pInstance.getBusinessKey());
|
||||
businessUnitAudit.setTaskdefinitionkey(task.getTaskDefinitionKey());
|
||||
model.addAttribute("businessUnitAudit", businessUnitAudit);
|
||||
String temporaryId= pInstance.getBusinessKey();
|
||||
Temporary temporary = this.temporaryService.selectById(temporaryId);
|
||||
model.addAttribute("temporary", temporary);
|
||||
|
||||
//获取任务下一节点,若为任务节点,则显示目标用户div,否则不显示
|
||||
List<ActivityImpl> activityImpls=workflowProcessDefinitionService.getNEXTActivities(task.getProcessDefinitionId(), task.getTaskDefinitionKey());
|
||||
if (activityImpls.size()>0) {
|
||||
model.addAttribute("showTargetUsersFlag", true);
|
||||
}else{
|
||||
model.addAttribute("showTargetUsersFlag", false);
|
||||
}
|
||||
return "administration/temporaryAudit";
|
||||
}
|
||||
/**
|
||||
* 流程流转
|
||||
* */
|
||||
@RequestMapping("/AuditTemporary.do")
|
||||
public String doAuditTemporary(HttpServletRequest request,Model model,
|
||||
@ModelAttribute BusinessUnitAudit businessUnitAudit){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
int result=0;
|
||||
businessUnitAudit.setInsuser(cu.getId());
|
||||
businessUnitAudit.setInsdt(CommUtil.nowDate());
|
||||
result =this.temporaryService.doAudit(businessUnitAudit);
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+businessUnitAudit.getId()+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
/**
|
||||
* 显示指标业务处理
|
||||
* */
|
||||
@RequestMapping("/showTemporaryHandle.do")
|
||||
public String showTemporaryHandle(HttpServletRequest request,Model model){
|
||||
String taskId = request.getParameter("taskId");
|
||||
String processInstanceId = request.getParameter("processInstanceId");
|
||||
String unitId = request.getParameter("unitId");
|
||||
ProcessInstance pInstance=runtimeService.createProcessInstanceQuery()
|
||||
.processInstanceId(processInstanceId)
|
||||
.singleResult();
|
||||
BusinessUnitHandle businessUnitHandle = new BusinessUnitHandle();
|
||||
Task task = this.taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||
model.addAttribute("taskName", task.getName());
|
||||
List<BusinessUnitHandle> businessUnitHandles = this.businessUnitHandleService.selectListByWhere("where processid='"+processInstanceId+"' and taskId='"+taskId+"'");
|
||||
if(businessUnitHandles!= null && businessUnitHandles.size()>0){
|
||||
businessUnitHandle = businessUnitHandles.get(0);
|
||||
//若任务退回后,需更新新的任务id
|
||||
businessUnitHandle.setTaskid(taskId);
|
||||
}else{
|
||||
businessUnitHandle.setId(CommUtil.getUUID());
|
||||
businessUnitHandle.setProcessid(processInstanceId);
|
||||
businessUnitHandle.setTaskid(taskId);
|
||||
businessUnitHandle.setBusinessid(pInstance.getBusinessKey());
|
||||
businessUnitHandle.setTaskdefinitionkey(task.getTaskDefinitionKey());
|
||||
businessUnitHandle.setUnitid(unitId);
|
||||
}
|
||||
String userIds = businessUnitHandle.getTargetusers();
|
||||
if(userIds!= null && !userIds.isEmpty()){
|
||||
List<User> users = userService.selectListByWhere("where id in('"+userIds.replace(",", "','")+"')");
|
||||
String targetUsersName ="";
|
||||
for (User user : users) {
|
||||
if(!targetUsersName.isEmpty()){
|
||||
targetUsersName+=",";
|
||||
}
|
||||
targetUsersName+=user.getCaption();
|
||||
}
|
||||
model.addAttribute("targetUsersName", targetUsersName);
|
||||
}
|
||||
|
||||
model.addAttribute("businessUnitHandle", businessUnitHandle);
|
||||
model.addAttribute("nowDate", CommUtil.nowDate());
|
||||
String temporaryId = pInstance.getBusinessKey();
|
||||
Temporary temporary = this.temporaryService.selectById(temporaryId);
|
||||
List<BusinessUnitAudit> list = this.businessUnitAuditService.selectListByWhere("where businessId = '"+temporaryId+"' order by insdt desc ");
|
||||
|
||||
if(list!=null && list.size()>0){
|
||||
model.addAttribute("businessUnitAudit", list.get(0));
|
||||
}
|
||||
model.addAttribute("temporary", temporary);
|
||||
return "administration/temporaryHandle";
|
||||
}
|
||||
/**
|
||||
* 流程流程,指标业务处理提交
|
||||
* */
|
||||
@RequestMapping("/submitTemporaryHandle.do")
|
||||
public String dosubmitTemporaryHandle(HttpServletRequest request,Model model,
|
||||
@ModelAttribute BusinessUnitHandle businessUnitHandle){
|
||||
String routeNum=request.getParameter("routeNum");
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
int result=0;
|
||||
if(!this.businessUnitHandleService.checkExit(businessUnitHandle)) {
|
||||
businessUnitHandle.setInsuser(cu.getId());
|
||||
businessUnitHandle.setInsdt(CommUtil.nowDate());
|
||||
result =this.businessUnitHandleService.save(businessUnitHandle);
|
||||
}else {
|
||||
result =this.businessUnitHandleService.update(businessUnitHandle);
|
||||
}
|
||||
try {
|
||||
Map<String, Object> variables = new HashMap<String, Object>();
|
||||
variables =ActivitiUtil.fixVariableWithRoute(variables, true, routeNum);
|
||||
variables.put(CommString.ACTI_KEK_Candidate_Users, businessUnitHandle.getTargetusers());
|
||||
variables.put(CommString.ACTI_KEK_Assignee, null);
|
||||
taskService.complete(businessUnitHandle.getTaskid(), variables);
|
||||
//发送消息
|
||||
if(businessUnitHandle.getTargetusers()!=null && !businessUnitHandle.getTargetusers().isEmpty()){
|
||||
//补全所有字段信息
|
||||
businessUnitHandle = businessUnitHandleService.selectById(businessUnitHandle.getId());
|
||||
BusinessUnitRecord businessUnitRecord = new BusinessUnitRecord(businessUnitHandle);
|
||||
businessUnitRecord.sendMessage(businessUnitHandle.getTargetusers(),"");
|
||||
}
|
||||
this.temporaryService.updateStatus(businessUnitHandle.getBusinessid());
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
result=0;
|
||||
}
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+businessUnitHandle.getId()+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,142 @@
|
||||
package com.sipai.controller.alarm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.alarm.AlarmCondition;
|
||||
import com.sipai.service.alarm.AlarmConditionService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/alarm/alarmCondition")
|
||||
public class AlarmConditionController {
|
||||
@Resource
|
||||
private AlarmConditionService alarmConditionService;
|
||||
|
||||
@RequestMapping("/getList.do")
|
||||
public String getList(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required=false) String sort,
|
||||
@RequestParam(value = "order", required=false) String order){
|
||||
if(sort==null){
|
||||
sort = " insdt ";
|
||||
}
|
||||
if(order==null){
|
||||
order = " desc ";
|
||||
}
|
||||
String orderstr=" order by "+sort+" "+order;
|
||||
String wherestr="where 1=1";
|
||||
if(request.getParameter("alarmtypeid") != null &&
|
||||
request.getParameter("alarmtypeid").trim().length()>0){
|
||||
wherestr += " and alarmtypeid = '"+request.getParameter("alarmtypeid")+"'";
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<AlarmCondition> list = this.alarmConditionService.selectListByWhere
|
||||
(wherestr+orderstr);
|
||||
PageInfo<AlarmCondition> pi = new PageInfo<AlarmCondition>(list);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
|
||||
String result="{\"total\":"+pi.getTotal()+",\"rows\":"+json+"}";
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/showAdd.do")
|
||||
public String showAdd(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "alarmtypeid") String alarmtypeid){
|
||||
model.addAttribute("alarmtypeid", alarmtypeid);
|
||||
return "alarm/alarmConditionAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/dosave.do")
|
||||
public String dosave(HttpServletRequest request,Model model){
|
||||
List<AlarmCondition> list = this.alarmConditionService.
|
||||
selectListByWhere("where mpointid = '"+request.getParameter("mpointid")+"' "
|
||||
+ "order by id");
|
||||
if(list != null && list.size()>0){
|
||||
model.addAttribute("result","已存在该测量点的报警!");
|
||||
}else{
|
||||
AlarmCondition alarmCondition = new AlarmCondition();
|
||||
alarmCondition.setId(CommUtil.getUUID());
|
||||
alarmCondition.setInsdt(CommUtil.nowDate());
|
||||
alarmCondition.setAlarmtypeid(request.getParameter("alarmtypeid"));
|
||||
alarmCondition.setCompare(request.getParameter("compare"));
|
||||
if(request.getParameter("lowerlimit")!=null && request.getParameter("lowerlimit").trim().length()>0){
|
||||
alarmCondition.setLowerlimit(Double.parseDouble(request.getParameter("lowerlimit")));
|
||||
}
|
||||
if(request.getParameter("val")!=null && request.getParameter("val").trim().length()>0){
|
||||
alarmCondition.setVal(Double.parseDouble(request.getParameter("val")));
|
||||
}
|
||||
if(request.getParameter("upperlimit")!=null && request.getParameter("upperlimit").trim().length()>0){
|
||||
alarmCondition.setUpperlimit(Double.parseDouble(request.getParameter("upperlimit")));
|
||||
}
|
||||
alarmCondition.setMpointid(request.getParameter("mpointid"));
|
||||
int result = this.alarmConditionService.save(alarmCondition);
|
||||
model.addAttribute("result",result);
|
||||
}
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/showEdit.do")
|
||||
public String showEdit(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
AlarmCondition alarmCondition = this.alarmConditionService.selectById(id);
|
||||
model.addAttribute("alarmCondition", alarmCondition);
|
||||
return "alarm/alarmConditionEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/update.do")
|
||||
public String update(HttpServletRequest request,Model model){
|
||||
AlarmCondition alarmCondition = this.alarmConditionService.selectById(request.getParameter("id"));
|
||||
List<AlarmCondition> list = this.alarmConditionService.
|
||||
selectListByWhere("where mpointid = '"+request.getParameter("mpointid")+"' "
|
||||
+ "order by id");
|
||||
if(list != null && list.size()>0 && !request.getParameter("mpointid").
|
||||
equals(alarmCondition.getMpointid())){
|
||||
model.addAttribute("result","已存在该测量点的报警!");
|
||||
}else{
|
||||
AlarmCondition alarmCondition2 = new AlarmCondition();
|
||||
alarmCondition2.setId(CommUtil.getUUID());
|
||||
alarmCondition2.setInsdt(CommUtil.nowDate());
|
||||
alarmCondition2.setAlarmtypeid(request.getParameter("alarmtypeid"));
|
||||
alarmCondition2.setCompare(request.getParameter("compare"));
|
||||
if(request.getParameter("lowerlimit")!=null && request.getParameter("lowerlimit").trim().length()>0){
|
||||
alarmCondition2.setLowerlimit(Double.parseDouble(request.getParameter("lowerlimit")));
|
||||
}
|
||||
if(request.getParameter("val")!=null && request.getParameter("val").trim().length()>0){
|
||||
alarmCondition2.setVal(Double.parseDouble(request.getParameter("val")));
|
||||
}
|
||||
if(request.getParameter("upperlimit")!=null && request.getParameter("upperlimit").trim().length()>0){
|
||||
alarmCondition2.setUpperlimit(Double.parseDouble(request.getParameter("upperlimit")));
|
||||
}
|
||||
alarmCondition2.setMpointid(request.getParameter("mpointid"));
|
||||
int result = this.alarmConditionService.save(alarmCondition2);
|
||||
this.alarmConditionService.deleteById(request.getParameter("id"));
|
||||
model.addAttribute("result",result);
|
||||
}
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodel.do")
|
||||
public String dodel(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
int result = this.alarmConditionService.deleteById(id);
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,357 @@
|
||||
package com.sipai.controller.alarm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.sipai.entity.alarm.*;
|
||||
import com.sipai.service.alarm.*;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/alarm/alarmInformation")
|
||||
public class AlarmInformationController {
|
||||
@Resource
|
||||
private AlarmInformationService alarmInformationService;
|
||||
@Resource
|
||||
private AlarmSubscribeService alarmSubscribeService;
|
||||
@Resource
|
||||
private AlarmLevelsService alarmLevelsService;
|
||||
@Resource
|
||||
private AlarmMoldService alarmMoldService;
|
||||
@Resource
|
||||
private AlarmPointService alarmPointService;
|
||||
|
||||
@RequestMapping("/showist.do")
|
||||
public String showAlarmInformationlist(HttpServletRequest request,Model model) {
|
||||
return "/alarm/alarmInformationList";
|
||||
}
|
||||
@RequestMapping("/getlist.do")
|
||||
public ModelAndView getlist(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required=false) String sort,
|
||||
@RequestParam(value = "order", required=false) String order) {
|
||||
//User cu=(User)request.getSession().getAttribute("cu");
|
||||
if(sort==null){
|
||||
sort = " code ";
|
||||
}
|
||||
if(order==null){
|
||||
order = " asc ";
|
||||
}
|
||||
String orderstr=" order by "+sort+" "+order;
|
||||
|
||||
String wherestr="where 1=1 and unit_id='"+request.getParameter("unitId")+"' ";
|
||||
|
||||
PageHelper.startPage(page, rows);
|
||||
List<AlarmInformation> list = this.alarmInformationService.selectListByWhere(wherestr+orderstr);
|
||||
|
||||
PageInfo<AlarmInformation> pi = new PageInfo<AlarmInformation>(list);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
|
||||
String result="{\"total\":"+pi.getTotal()+",\"rows\":"+json+"}";
|
||||
// System.out.println(result);
|
||||
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/getJson.do")
|
||||
public ModelAndView getJson(HttpServletRequest request,Model model) {
|
||||
List<AlarmInformation> list = this.alarmInformationService.selectListByWhere(" where unit_id='"+request.getParameter("unitId")+"' order by code");
|
||||
JSONArray jsondata=new JSONArray();
|
||||
for(AlarmInformation aInformation:list){
|
||||
JSONObject jsonObject=new JSONObject();
|
||||
jsonObject.put("id",aInformation.getCode());
|
||||
jsonObject.put("text",aInformation.getName());
|
||||
jsondata.add(jsonObject);
|
||||
}
|
||||
String str = JSON.toJSONString(jsondata);
|
||||
model.addAttribute("result",str);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/getJsonForConfigure.do")
|
||||
public ModelAndView getJsonForConfigure(HttpServletRequest request,Model model) {
|
||||
JSONArray jsondata=new JSONArray();
|
||||
List<AlarmInformation> alarmMoldList = this.alarmInformationService.getDistinctMold(" where unit_id='"+request.getParameter("unitId")+"' ");
|
||||
for(AlarmInformation alarmMold:alarmMoldList){
|
||||
JSONObject jsonObject=new JSONObject();
|
||||
jsonObject.put("id",alarmMold.getMoldCode());
|
||||
jsonObject.put("text",AlarmMoldCodeEnum.getName(alarmMold.getMoldCode()));
|
||||
jsonObject.put("type","mold");
|
||||
jsonObject.put("moldCode",alarmMold.getMoldCode());
|
||||
List<AlarmInformation> levelList = this.alarmInformationService.selectListByWhere(" " +
|
||||
"where unit_id='"+request.getParameter("unitId")+"' and mold_code='"+alarmMold.getMoldCode()+"' " +
|
||||
"order by code");
|
||||
JSONArray djsondata=new JSONArray();
|
||||
for(AlarmInformation aInformation:levelList){
|
||||
JSONObject djsonObject=new JSONObject();
|
||||
djsonObject.put("id",aInformation.getLevelCode());
|
||||
djsonObject.put("text",AlarmLevelsCodeEnum.getName(aInformation.getLevelCode()));
|
||||
djsonObject.put("type","level");
|
||||
djsonObject.put("hiddenId",aInformation.getId());
|
||||
djsonObject.put("moldCode",alarmMold.getMoldCode());
|
||||
djsondata.add(djsonObject);
|
||||
}
|
||||
jsonObject.put("nodes",djsondata);
|
||||
jsondata.add(jsonObject);
|
||||
}
|
||||
|
||||
String str = JSON.toJSONString(jsondata);
|
||||
model.addAttribute("result",str);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/getJsonForSysSubscribe.do")
|
||||
public ModelAndView getJsonForSysSubscribe(HttpServletRequest request,Model model) {
|
||||
User cu=(User)request.getSession().getAttribute("cu");
|
||||
|
||||
JSONArray jsondata=new JSONArray();
|
||||
List<AlarmInformation> alarmMoldList = this.alarmInformationService.getDistinctMold(" where unit_id='"+request.getParameter("unitId")+"' and alarm_receivers like '%"+cu.getId()+"%' ");
|
||||
for(AlarmInformation alarmMold:alarmMoldList){
|
||||
JSONObject jsonObject=new JSONObject();
|
||||
jsonObject.put("id",alarmMold.getMoldCode());
|
||||
jsonObject.put("text",AlarmMoldCodeEnum.getName(alarmMold.getMoldCode()));
|
||||
jsonObject.put("type","mold");
|
||||
jsonObject.put("moldCode",alarmMold.getMoldCode());
|
||||
|
||||
List<AlarmInformation> levelList = this.alarmInformationService.selectListByWhere(" " +
|
||||
"where unit_id='"+request.getParameter("unitId")+"' and mold_code='"+alarmMold.getMoldCode()+"' and alarm_receivers like '%"+cu.getId()+"%' " +
|
||||
"order by code");
|
||||
JSONArray djsondata=new JSONArray();
|
||||
for(AlarmInformation aInformation:levelList){
|
||||
JSONObject djsonObject=new JSONObject();
|
||||
djsonObject.put("id",aInformation.getLevelCode());
|
||||
djsonObject.put("text",AlarmLevelsCodeEnum.getName(aInformation.getLevelCode()));
|
||||
djsonObject.put("type","level");
|
||||
djsonObject.put("code",aInformation.getCode());
|
||||
djsondata.add(djsonObject);
|
||||
}
|
||||
jsonObject.put("nodes",djsondata);
|
||||
jsondata.add(jsonObject);
|
||||
}
|
||||
|
||||
String str = JSON.toJSONString(jsondata);
|
||||
model.addAttribute("result",str);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/getJsonForPersonalSubscribe.do")
|
||||
public ModelAndView getJsonForPersonalSubscribe(HttpServletRequest request,Model model) {
|
||||
User cu=(User)request.getSession().getAttribute("cu");
|
||||
|
||||
List<AlarmSubscribe> moldList = this.alarmSubscribeService.selectMoldCountByWhere(" where s.unit_id='"+request.getParameter("unitId")+"' and userid='"+cu.getId()+"' ");
|
||||
|
||||
JSONArray jsondata=new JSONArray();
|
||||
for(AlarmSubscribe mold:moldList){
|
||||
JSONObject jsonObject=new JSONObject();
|
||||
jsonObject.put("id",mold.getMoldCode());
|
||||
jsonObject.put("text",AlarmMoldCodeEnum.getName(mold.getMoldCode()));
|
||||
jsonObject.put("type","mold");
|
||||
|
||||
List<AlarmSubscribe> levelList = this.alarmSubscribeService.selectlevelCountByWhere(" where s.unit_id='"+request.getParameter("unitId")+"' and userid='"+cu.getId()+"' and mold_code='"+mold.getMoldCode()+"' ");
|
||||
|
||||
JSONArray djsondata=new JSONArray();
|
||||
for(AlarmSubscribe level:levelList){
|
||||
JSONObject djsonObject=new JSONObject();
|
||||
djsonObject.put("id",level.getLevelCode());
|
||||
djsonObject.put("text",AlarmLevelsCodeEnum.getName(level.getLevelCode()));
|
||||
djsonObject.put("type","level");
|
||||
djsonObject.put("moldCode",mold.getMoldCode());
|
||||
djsonObject.put("levelCode",level.getLevelCode());
|
||||
djsondata.add(djsonObject);
|
||||
}
|
||||
jsonObject.put("nodes",djsondata);
|
||||
jsondata.add(jsonObject);
|
||||
}
|
||||
|
||||
String str = JSON.toJSONString(jsondata);
|
||||
model.addAttribute("result",str);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/doadd.do")
|
||||
public String doadd(HttpServletRequest request,Model model){
|
||||
List<AlarmLevels> alarmLevels = this.alarmLevelsService.selectListByWhere(" order by morder");
|
||||
JSONArray jsondata=new JSONArray();
|
||||
for (AlarmLevels alarmLevels2 : alarmLevels) {
|
||||
JSONObject jsonObject=new JSONObject();
|
||||
jsonObject.put("id",alarmLevels2.getCode());
|
||||
jsonObject.put("text",alarmLevels2.getName());
|
||||
jsondata.add(jsonObject);
|
||||
}
|
||||
List<AlarmMold> alarmMolds = this.alarmMoldService.selectListByWhere(" order by morder");
|
||||
JSONArray jsondata2=new JSONArray();
|
||||
for (AlarmMold alarmMolds2 : alarmMolds) {
|
||||
JSONObject jsonObject=new JSONObject();
|
||||
jsonObject.put("id",alarmMolds2.getCode());
|
||||
jsonObject.put("text",alarmMolds2.getName());
|
||||
jsondata2.add(jsonObject);
|
||||
}
|
||||
|
||||
model.addAttribute("alarmLevelsCodeEnum",jsondata.toString());
|
||||
model.addAttribute("alarmMoldCodeEnum",jsondata2.toString());
|
||||
model.addAttribute("AlarmInformationAlarmModeEnum",AlarmInformationAlarmModeEnum.getJsonString());
|
||||
return "alarm/alarmInformationAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/doedit.do")
|
||||
public String doedit(HttpServletRequest request,Model model){
|
||||
String id = request.getParameter("id");
|
||||
AlarmInformation alarmInformation = this.alarmInformationService.selectById(id);
|
||||
model.addAttribute("alarmInformation", alarmInformation);
|
||||
|
||||
List<AlarmLevels> alarmLevels = this.alarmLevelsService.selectListByWhere(" order by morder");
|
||||
JSONArray jsondata=new JSONArray();
|
||||
for (AlarmLevels alarmLevels2 : alarmLevels) {
|
||||
JSONObject jsonObject=new JSONObject();
|
||||
jsonObject.put("id",alarmLevels2.getCode());
|
||||
jsonObject.put("text",alarmLevels2.getName());
|
||||
jsondata.add(jsonObject);
|
||||
}
|
||||
List<AlarmMold> alarmMolds = this.alarmMoldService.selectListByWhere(" order by morder");
|
||||
JSONArray jsondata2=new JSONArray();
|
||||
for (AlarmMold alarmMolds2 : alarmMolds) {
|
||||
JSONObject jsonObject=new JSONObject();
|
||||
jsonObject.put("id",alarmMolds2.getCode());
|
||||
jsonObject.put("text",alarmMolds2.getName());
|
||||
jsondata2.add(jsonObject);
|
||||
}
|
||||
model.addAttribute("alarmLevelsCodeEnum",jsondata.toString());
|
||||
model.addAttribute("alarmMoldCodeEnum",jsondata2.toString());
|
||||
model.addAttribute("AlarmInformationAlarmModeEnum",AlarmInformationAlarmModeEnum.getJsonString());
|
||||
return "alarm/alarmInformationEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/dosave.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute AlarmInformation alarmInformation){
|
||||
User cu=(User)request.getSession().getAttribute("cu");
|
||||
Result result = new Result();
|
||||
AlarmInformation AlarmInformationNum=this.alarmInformationService.selectCountByWhere(" where code='"+alarmInformation.getCode()+"' and unit_id='"+request.getParameter("unitId")+"' ");
|
||||
if(AlarmInformationNum.getNum()>0){
|
||||
result = Result.failed("不能添加重复数据!");
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
String id = CommUtil.getUUID();
|
||||
alarmInformation.setId(id);
|
||||
alarmInformation.setInsdt(CommUtil.nowDate());
|
||||
alarmInformation.setInsuser(cu.getId());
|
||||
alarmInformation.setUpdatetime(CommUtil.nowDate());
|
||||
alarmInformation.setUpdater(cu.getId());
|
||||
int code = this.alarmInformationService.save(alarmInformation);
|
||||
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("新增失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dofirstsave.do")
|
||||
public String dofirstsave(HttpServletRequest request,Model model){
|
||||
User cu=(User)request.getSession().getAttribute("cu");
|
||||
|
||||
String unitId=request.getParameter("unitId");
|
||||
this.alarmInformationService.deleteByWhere(" where unit_id='"+unitId+"' ");
|
||||
this.alarmPointService.deleteByWhere(" where unit_id='"+unitId+"' ");
|
||||
|
||||
List<AlarmLevels> alarmLevels = this.alarmLevelsService.selectListByWhere(" order by morder");
|
||||
List<AlarmMold> alarmMolds = this.alarmMoldService.selectListByWhere(" order by morder");
|
||||
int code=0;
|
||||
for (AlarmMold alarmMold : alarmMolds) {
|
||||
for (AlarmLevels alarmLevelss : alarmLevels) {
|
||||
AlarmInformation alarmInformation=new AlarmInformation();
|
||||
alarmInformation.setId(CommUtil.getUUID());
|
||||
alarmInformation.setInsdt(CommUtil.nowDate());
|
||||
alarmInformation.setInsuser(cu.getId());
|
||||
alarmInformation.setUpdatetime(CommUtil.nowDate());
|
||||
alarmInformation.setUpdater(cu.getId());
|
||||
alarmInformation.setName(alarmMold.getName()+"_"+alarmLevelss.getName());
|
||||
alarmInformation.setCode(alarmMold.getCode()+"_"+alarmLevelss.getCode());
|
||||
alarmInformation.setLevelCode(alarmLevelss.getCode());
|
||||
alarmInformation.setMoldCode(alarmMold.getCode());
|
||||
alarmInformation.setUnitId(unitId);
|
||||
code = this.alarmInformationService.save(alarmInformation);
|
||||
}
|
||||
}
|
||||
|
||||
Result result = new Result();
|
||||
if (code >= Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("新增失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doupdate.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute AlarmInformation alarmInformation){
|
||||
User cu=(User)request.getSession().getAttribute("cu");
|
||||
String oldCode=request.getParameter("oldCode");
|
||||
Result result = new Result();
|
||||
AlarmInformation AlarmInformationNum=this.alarmInformationService.selectCountByWhere(" where code='"+alarmInformation.getCode()+"' and unit_id='"+request.getParameter("unitId")+"' ");
|
||||
if(AlarmInformationNum.getNum()>0&&!oldCode.equals(alarmInformation.getCode())){
|
||||
result = Result.failed("不能添加重复数据!");
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
alarmInformation.setUpdatetime(CommUtil.nowDate());
|
||||
alarmInformation.setUpdater(cu.getId());
|
||||
int code = this.alarmInformationService.update(alarmInformation);
|
||||
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("更新失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
@RequestMapping("/dodelete.do")
|
||||
public String dodelete(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id){
|
||||
int code = this.alarmInformationService.deleteById(id);
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("删除失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodeletes.do")
|
||||
public String dodeletes(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="ids") String ids){
|
||||
ids=ids.replace(",","','");
|
||||
int result = this.alarmInformationService.deleteByWhere("where id in ('"+ids+"')");
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,171 @@
|
||||
package com.sipai.controller.alarm;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.alarm.AlarmLevelsConfig;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.hqconfig.RiskLevel;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.alarm.AlarmLevesConfigService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
import net.sf.json.JSONArray;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("alarm/config")
|
||||
public class AlarmLevelsConfigController {
|
||||
@Resource
|
||||
private AlarmLevesConfigService alarmLevesConfigService;
|
||||
|
||||
@RequestMapping("/showList.do")
|
||||
public String showList(HttpServletRequest request,Model model){
|
||||
return "alarm/alarmLevelsConfigList";
|
||||
}
|
||||
|
||||
@RequestMapping("/getList.do")
|
||||
public String getList(HttpServletRequest request,Model model){
|
||||
User cu=(User)request.getSession().getAttribute("cu");
|
||||
ArrayList<AlarmLevelsConfig> resultList = new ArrayList<>();
|
||||
List<AlarmLevelsConfig> list = this.alarmLevesConfigService.selectListByWhere("");
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
list.get(i).setLimit(list.get(i).getLowerLimit() + " - " + list.get(i).getUpperLimit());
|
||||
resultList.add(list.get(i));
|
||||
}
|
||||
JSONArray json= JSONArray.fromObject(resultList);
|
||||
String result="{\"rows\":"+json+"}";
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/getConfigList.do")
|
||||
public String getConfigList(HttpServletRequest request,Model model){
|
||||
String rvalue = request.getParameter("rvalue");
|
||||
List<AlarmLevelsConfig> list = this.alarmLevesConfigService.selectListByWhere("where upper_limit >= " + rvalue + " and lower_limit <= " + rvalue);
|
||||
JSONArray json= JSONArray.fromObject(list);
|
||||
String result="{\"rows\":"+json+"}";
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doAdd.do")
|
||||
public String doadd(HttpServletRequest request,Model model){
|
||||
return "alarm/alarmLevelsConfigAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/doSave.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute AlarmLevelsConfig alarmLevelsConfig){
|
||||
List<AlarmLevelsConfig> alarmLevelsConfigs = alarmLevesConfigService.selectListByWhere("where level = '" + alarmLevelsConfig.getLevel() + "'");
|
||||
if (alarmLevelsConfigs.size() > 0) {
|
||||
String resstr="{\"res\":\"0\",\"msg\":\"相同等级只可存在一条配置!\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
String id = CommUtil.getUUID();
|
||||
alarmLevelsConfig.setId(id);
|
||||
switch(alarmLevelsConfig.getLevel()) {
|
||||
case "A":
|
||||
alarmLevelsConfig.setCode(1);
|
||||
break;
|
||||
case "B":
|
||||
alarmLevelsConfig.setCode(2);
|
||||
break;
|
||||
case "C":
|
||||
alarmLevelsConfig.setCode(3);
|
||||
break;
|
||||
case "D":
|
||||
alarmLevelsConfig.setCode(4);
|
||||
break;
|
||||
}
|
||||
int result = this.alarmLevesConfigService.save(alarmLevelsConfig);
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+id+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doEdit.do")
|
||||
public String doedit(HttpServletRequest request,Model model,@RequestParam(value = "id") String id){
|
||||
AlarmLevelsConfig alarmLevelsConfig = this.alarmLevesConfigService.selectById(id);
|
||||
model.addAttribute("alarmLevelsConfig", alarmLevelsConfig);
|
||||
return "alarm/alarmLevelsConfigEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/doUpdate.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute("alarmLevelsConfig") AlarmLevelsConfig alarmLevelsConfig){
|
||||
List<AlarmLevelsConfig> alarmLevelsConfigs = alarmLevesConfigService.selectListByWhere("where level = '" + alarmLevelsConfig.getLevel() + "' and id != '" + alarmLevelsConfig.getId() + "'");
|
||||
if (alarmLevelsConfigs.size() > 0) {
|
||||
String resstr="{\"res\":\"0\",\"msg\":\"相同等级只可存在一条配置!\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
switch(alarmLevelsConfig.getLevel()) {
|
||||
case "A":
|
||||
alarmLevelsConfig.setCode(1);
|
||||
break;
|
||||
case "B":
|
||||
alarmLevelsConfig.setCode(2);
|
||||
break;
|
||||
case "C":
|
||||
alarmLevelsConfig.setCode(3);
|
||||
break;
|
||||
case "D":
|
||||
alarmLevelsConfig.setCode(4);
|
||||
break;
|
||||
}
|
||||
int code = this.alarmLevesConfigService.update(alarmLevelsConfig);
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("更新失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/deletes.do")
|
||||
public String dodels(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="ids") String ids){
|
||||
String[] idArray = ids.split(",");
|
||||
try {
|
||||
for (int i = 0; i < idArray.length; i++) {
|
||||
this.alarmLevesConfigService.deleteById(idArray[i]);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Result result = Result.failed("删除失败");
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
Result result = Result.success(1);
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodel.do")
|
||||
public String dodel(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id){
|
||||
Result result = new Result();
|
||||
int code = this.alarmLevesConfigService.deleteById(id);
|
||||
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("删除失败");
|
||||
}
|
||||
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,177 @@
|
||||
package com.sipai.controller.alarm;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.alarm.AlarmLevels;
|
||||
import com.sipai.entity.alarm.AlarmLevelsCodeEnum;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.alarm.AlarmLevelsService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/alarm/alarmLevels")
|
||||
public class AlarmLevelsController {
|
||||
|
||||
@Resource
|
||||
private AlarmLevelsService alarmLevelsService;
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
|
||||
@RequestMapping("/showist.do")
|
||||
public String showAlarmLevelslist(HttpServletRequest request,Model model) {
|
||||
return "/alarm/alarmLevelsList";
|
||||
}
|
||||
@RequestMapping("/getlist.do")
|
||||
public ModelAndView getlist(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required=false) String sort,
|
||||
@RequestParam(value = "order", required=false) String order) {
|
||||
//User cu=(User)request.getSession().getAttribute("cu");
|
||||
if(sort==null){
|
||||
sort = " code ";
|
||||
}
|
||||
if(order==null){
|
||||
order = " asc ";
|
||||
}
|
||||
String orderstr=" order by "+sort+" "+order;
|
||||
|
||||
String wherestr="where 1=1 ";
|
||||
|
||||
PageHelper.startPage(page, rows);
|
||||
List<AlarmLevels> list = this.alarmLevelsService.selectListByWhere(wherestr+orderstr);
|
||||
|
||||
PageInfo<AlarmLevels> pi = new PageInfo<AlarmLevels>(list);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
|
||||
String result="{\"total\":"+pi.getTotal()+",\"rows\":"+json+"}";
|
||||
// System.out.println(result);
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/doadd.do")
|
||||
public String doadd(HttpServletRequest request,Model model){
|
||||
model.addAttribute("alarmLevelsCodeEnum",AlarmLevelsCodeEnum.getJsonString());
|
||||
return "alarm/alarmLevelsAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/doedit.do")
|
||||
public String doedit(HttpServletRequest request,Model model){
|
||||
String id = request.getParameter("id");
|
||||
AlarmLevels alarmLevels = this.alarmLevelsService.selectById(id);
|
||||
model.addAttribute("alarmLevels", alarmLevels);
|
||||
model.addAttribute("alarmLevelsCodeEnum",AlarmLevelsCodeEnum.getJsonString());
|
||||
return "alarm/alarmLevelsEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/dosave.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute AlarmLevels alarmLevels){
|
||||
Result result = new Result();
|
||||
AlarmLevels AlarmLevelsNum=this.alarmLevelsService.selectCountByWhere(" where code='"+alarmLevels.getCode()+"' ");
|
||||
if(AlarmLevelsNum.getNum()>0){
|
||||
result = Result.failed("不能添加重复数据!");
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
String id = CommUtil.getUUID();
|
||||
alarmLevels.setId(id);
|
||||
alarmLevels.setName(AlarmLevelsCodeEnum.getName(request.getParameter("code")));
|
||||
int code = this.alarmLevelsService.save(alarmLevels);
|
||||
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("新增失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dofirstsave.do")
|
||||
public String donewsave(HttpServletRequest request,Model model){
|
||||
this.alarmLevelsService.deleteByWhere("");
|
||||
int code=0;
|
||||
List<AlarmLevels> list=AlarmLevelsCodeEnum.getList();
|
||||
for (AlarmLevels alarmLevels : list) {
|
||||
String id = CommUtil.getUUID();
|
||||
alarmLevels.setId(id);
|
||||
code += this.alarmLevelsService.save(alarmLevels);
|
||||
}
|
||||
|
||||
Result result = new Result();
|
||||
if (code >= Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("新增失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doupdate.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute AlarmLevels alarmLevels){
|
||||
String oldCode=request.getParameter("oldCode");
|
||||
Result result = new Result();
|
||||
AlarmLevels AlarmLevelsNum=this.alarmLevelsService.selectCountByWhere(" where code='"+alarmLevels.getCode()+"' ");
|
||||
if(AlarmLevelsNum.getNum()>0&&!oldCode.equals(alarmLevels.getCode())){
|
||||
result = Result.failed("不能添加重复数据!");
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
alarmLevels.setName(AlarmLevelsCodeEnum.getName(request.getParameter("code")));
|
||||
int code = this.alarmLevelsService.update(alarmLevels);
|
||||
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("更新失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
@RequestMapping("/dodelete.do")
|
||||
public String dodelete(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id){
|
||||
int code = this.alarmLevelsService.deleteById(id);
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("删除失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodeletes.do")
|
||||
public String dodeletes(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="ids") String ids){
|
||||
ids=ids.replace(",","','");
|
||||
int result = this.alarmLevelsService.deleteByWhere("where id in ('"+ids+"')");
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,210 @@
|
||||
package com.sipai.controller.alarm;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.alarm.AlarmMold;
|
||||
import com.sipai.entity.alarm.AlarmMoldCodeEnum;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.alarm.AlarmMoldService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/alarm/alarmMold")
|
||||
public class AlarmMoldController {
|
||||
@Resource
|
||||
private AlarmMoldService alarmMoldService;
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
|
||||
@RequestMapping("/showist.do")
|
||||
public String showAlarmMoldlist(HttpServletRequest request,Model model) {
|
||||
return "/alarm/alarmMoldList";
|
||||
}
|
||||
@RequestMapping("/getlist.do")
|
||||
public ModelAndView getlist(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required=false) String sort,
|
||||
@RequestParam(value = "order", required=false) String order) {
|
||||
//User cu=(User)request.getSession().getAttribute("cu");
|
||||
if(sort==null){
|
||||
sort = " code ";
|
||||
}
|
||||
if(order==null){
|
||||
order = " asc ";
|
||||
}
|
||||
String orderstr=" order by "+sort+" "+order;
|
||||
|
||||
String wherestr="where 1=1 ";
|
||||
|
||||
PageHelper.startPage(page, rows);
|
||||
List<AlarmMold> list = this.alarmMoldService.selectListByWhere(wherestr+orderstr);
|
||||
|
||||
PageInfo<AlarmMold> pi = new PageInfo<AlarmMold>(list);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
|
||||
String result="{\"total\":"+pi.getTotal()+",\"rows\":"+json+"}";
|
||||
// System.out.println(result);
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/doadd.do")
|
||||
public String doadd(HttpServletRequest request,Model model){
|
||||
model.addAttribute("alarmMoldCodeEnum",AlarmMoldCodeEnum.getJsonString());
|
||||
return "alarm/alarmMoldAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/doadds.do")
|
||||
public String doadds(HttpServletRequest request,Model model){
|
||||
return "alarm/alarmMoldAdds";
|
||||
}
|
||||
|
||||
@RequestMapping("/getAlarmMoldCodeEnumJson.do")
|
||||
public ModelAndView getAlarmMoldCodeEnumJson(HttpServletRequest request,Model model) {
|
||||
|
||||
model.addAttribute("result",AlarmMoldCodeEnum.getJsonString());
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/doedit.do")
|
||||
public String doedit(HttpServletRequest request,Model model){
|
||||
String id = request.getParameter("id");
|
||||
AlarmMold alarmMold = this.alarmMoldService.selectById(id);
|
||||
model.addAttribute("alarmMold", alarmMold);
|
||||
model.addAttribute("alarmMoldCodeEnum",AlarmMoldCodeEnum.getJsonString());
|
||||
return "alarm/alarmMoldEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/dosave.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute AlarmMold alarmMold){
|
||||
Result result = new Result();
|
||||
AlarmMold AlarmMoldNum=this.alarmMoldService.selectCountByWhere(" where code='"+alarmMold.getCode()+"' ");
|
||||
if(AlarmMoldNum.getNum()>0){
|
||||
result = Result.failed("不能添加重复数据!");
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
String id = CommUtil.getUUID();
|
||||
alarmMold.setId(id);
|
||||
alarmMold.setName(AlarmMoldCodeEnum.getName(request.getParameter("code")));
|
||||
int code = this.alarmMoldService.save(alarmMold);
|
||||
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("新增失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dosaves.do")
|
||||
public String dosaves(HttpServletRequest request,Model model,
|
||||
@ModelAttribute AlarmMold alarmMold){
|
||||
Result result = new Result();
|
||||
int code = 0;
|
||||
int sunCode = 0;
|
||||
int failCode = 0;
|
||||
|
||||
String[] ids=request.getParameter("ids").split(",");
|
||||
String[] names=request.getParameter("names").split(",");
|
||||
for (String id : ids) {
|
||||
AlarmMold AlarmMoldNum=this.alarmMoldService.selectCountByWhere(" where code='"+id+"' ");
|
||||
if(AlarmMoldNum.getNum()>0){
|
||||
failCode++;
|
||||
}else{
|
||||
alarmMold.setId(CommUtil.getUUID());
|
||||
alarmMold.setCode(id);
|
||||
alarmMold.setName(names[code]);
|
||||
alarmMold.setMorder(code);
|
||||
int scnum=this.alarmMoldService.save(alarmMold);
|
||||
if (scnum >= Result.SUCCESS) {
|
||||
sunCode++;
|
||||
} else {
|
||||
failCode++;
|
||||
}
|
||||
}
|
||||
|
||||
code++;
|
||||
}
|
||||
|
||||
if (sunCode >= Result.SUCCESS) {
|
||||
if(sunCode==code){
|
||||
result = Result.success(code);
|
||||
}else{
|
||||
result = Result.failed("共需增加"+code+"条记录。其中"+sunCode+"条成功,"+failCode+"条失败");
|
||||
}
|
||||
} else {
|
||||
result = Result.failed("共需增加"+code+"条记录。其中"+sunCode+"条成功,"+failCode+"条失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doupdate.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute AlarmMold alarmMold){
|
||||
String oldCode=request.getParameter("oldCode");
|
||||
Result result = new Result();
|
||||
AlarmMold AlarmMoldNum=this.alarmMoldService.selectCountByWhere(" where code='"+alarmMold.getCode()+"' ");
|
||||
if(AlarmMoldNum.getNum()>0&&!oldCode.equals(alarmMold.getCode())){
|
||||
result = Result.failed("不能添加重复数据!");
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
alarmMold.setName(AlarmMoldCodeEnum.getName(request.getParameter("code")));
|
||||
int code = this.alarmMoldService.update(alarmMold);
|
||||
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("更新失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
@RequestMapping("/dodelete.do")
|
||||
public String dodelete(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id){
|
||||
int code = this.alarmMoldService.deleteById(id);
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("删除失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodeletes.do")
|
||||
public String dodeletes(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="ids") String ids){
|
||||
ids=ids.replace(",","','");
|
||||
int result = this.alarmMoldService.deleteByWhere("where id in ('"+ids+"')");
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,524 @@
|
||||
package com.sipai.controller.alarm;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.sipai.entity.alarm.AlarmMoldCodeEnum;
|
||||
import com.sipai.entity.alarm.AlarmSubscribe;
|
||||
import com.sipai.entity.scada.MPoint;
|
||||
import com.sipai.entity.user.ProcessSection;
|
||||
import com.sipai.service.alarm.AlarmSubscribeService;
|
||||
import com.sipai.service.scada.MPointService;
|
||||
import com.sipai.service.scada.ProAlarmService;
|
||||
import com.sipai.service.user.ProcessSectionService;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.alarm.AlarmInformation;
|
||||
import com.sipai.entity.alarm.AlarmPoint;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.alarm.AlarmInformationService;
|
||||
import com.sipai.service.alarm.AlarmPointService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/alarm/alarmPoint")
|
||||
public class AlarmPointController {
|
||||
@Resource
|
||||
private AlarmPointService alarmPointService;
|
||||
@Resource
|
||||
private AlarmInformationService alarmInformationService;
|
||||
@Resource
|
||||
private MPointService mPointService;
|
||||
@Resource
|
||||
private AlarmSubscribeService alarmSubscribeService;
|
||||
@Resource
|
||||
private ProAlarmService proAlarmService;
|
||||
@Resource
|
||||
private ProcessSectionService processSectionService;
|
||||
|
||||
@RequestMapping("/showist.do")
|
||||
public String showAlarmPointlist(HttpServletRequest request, Model model) {
|
||||
|
||||
return "/alarm/alarmPointList";
|
||||
}
|
||||
|
||||
@RequestMapping("/showistForSubscribe.do")
|
||||
public String showistForSubscribe(HttpServletRequest request, Model model) {
|
||||
List<AlarmInformation> alarmInformations = this.alarmInformationService.selectListByWhere(" where unit_id='" + request.getParameter("unitId") + "' order by code");
|
||||
JSONArray jsondata = new JSONArray();
|
||||
for (AlarmInformation alarmInformations2 : alarmInformations) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("id", alarmInformations2.getCode());
|
||||
jsonObject.put("text", alarmInformations2.getName());
|
||||
jsondata.add(jsonObject);
|
||||
}
|
||||
model.addAttribute("alarmInformationJson", jsondata.toString());
|
||||
return "/alarm/alarmPointListForSubscribe";
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/getlist.do")
|
||||
public ModelAndView getlist(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required = false) String sort,
|
||||
@RequestParam(value = "order", required = false) String order) {
|
||||
//User cu=(User)request.getSession().getAttribute("cu");
|
||||
if (sort == null) {
|
||||
sort = " alarm_point ";
|
||||
}
|
||||
if (order == null) {
|
||||
order = " asc ";
|
||||
}
|
||||
String orderstr = " order by " + sort + " " + order;
|
||||
|
||||
String wherestr = "where 1=1 ";
|
||||
|
||||
if (request.getParameter("unitId") != null && request.getParameter("unitId").length() > 0) {
|
||||
wherestr += " and unit_id='" + request.getParameter("unitId") + "' ";
|
||||
}
|
||||
String searchName = request.getParameter("search_name");
|
||||
if (request.getParameter("informationCode") != null && request.getParameter("informationCode").length() > 0) {
|
||||
wherestr += " and information_code='" + request.getParameter("informationCode") + "' ";
|
||||
}
|
||||
|
||||
PageHelper.startPage(page, rows);
|
||||
List<AlarmPoint> list = new ArrayList<>();
|
||||
try {
|
||||
list = this.alarmPointService.selectListByWhere(wherestr + orderstr, searchName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
PageInfo<AlarmPoint> pi = new PageInfo<AlarmPoint>(list);
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
|
||||
String result = "{\"total\":" + pi.getTotal() + ",\"rows\":" + json + "}";
|
||||
// System.out.println(result);
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/getlistForSubscribePersonal.do")
|
||||
public ModelAndView getlistForSubscribePersonal(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required = false) String sort,
|
||||
@RequestParam(value = "order", required = false) String order) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
if (sort == null) {
|
||||
sort = " mold_code ";
|
||||
}
|
||||
if (order == null) {
|
||||
order = " asc ";
|
||||
}
|
||||
String orderstr = " order by " + sort + " " + order;
|
||||
|
||||
String wherestr = " where s.unit_id='" + request.getParameter("unitId") + "' and userid='" + cu.getId() + "' " +
|
||||
" and i.mold_code='" + request.getParameter("moldCode") + "' and i.level_code='" + request.getParameter("levelCode") + "' ";
|
||||
|
||||
PageHelper.startPage(page, rows);
|
||||
List<AlarmSubscribe> list = this.alarmSubscribeService.selectLeftOuterListByWhere(wherestr + orderstr);
|
||||
|
||||
PageInfo<AlarmSubscribe> pi = new PageInfo<AlarmSubscribe>(list);
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
|
||||
String result = "{\"total\":" + pi.getTotal() + ",\"rows\":" + json + "}";
|
||||
// System.out.println(result);
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/getlistForSubscribePersonalAdd.do")
|
||||
public ModelAndView getlistForSubscribePersonalAdd(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required = false) String sort,
|
||||
@RequestParam(value = "order", required = false) String order) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
if (sort == null) {
|
||||
sort = " alarm_point ";
|
||||
}
|
||||
if (order == null) {
|
||||
order = " asc ";
|
||||
}
|
||||
String orderstr = " order by " + sort + " " + order;
|
||||
|
||||
String wherestr = " where 1=1 and (alarm_receivers not like '%" + cu.getId() + "%' or alarm_receivers is null) ";
|
||||
|
||||
if (request.getParameter("unitId") != null && request.getParameter("unitId").length() > 0) {
|
||||
wherestr += " and p.unit_id='" + request.getParameter("unitId") + "' ";
|
||||
}
|
||||
String searchName = request.getParameter("search_name");
|
||||
if (request.getParameter("informationCode") != null && request.getParameter("informationCode").length() > 0) {
|
||||
wherestr += " and information_code='" + request.getParameter("informationCode") + "' ";
|
||||
}
|
||||
if (request.getParameter("alarmMoldCode") != null && request.getParameter("alarmMoldCode").length() > 0) {
|
||||
wherestr += " and information_code like '%" + request.getParameter("alarmMoldCode") + "%' ";
|
||||
}
|
||||
if (request.getParameter("alarmLevelsCode") != null && request.getParameter("alarmLevelsCode").length() > 0) {
|
||||
wherestr += " and information_code like '%" + request.getParameter("alarmLevelsCode") + "%' ";
|
||||
}
|
||||
|
||||
List<AlarmSubscribe> alarmSubscribeList = this.alarmSubscribeService.selectListByWhere(" where unit_id='" + request.getParameter("unitId") + "' and userid='" + cu.getId() + "' ");
|
||||
String alarmPointIds = "";
|
||||
if (alarmSubscribeList != null && alarmSubscribeList.size() > 0) {
|
||||
for (int i = 0; i < alarmSubscribeList.size(); i++) {
|
||||
alarmPointIds += alarmSubscribeList.get(i).getAlarmPointId() + ",";
|
||||
}
|
||||
}
|
||||
if (!alarmPointIds.equals("")) {
|
||||
alarmPointIds = alarmPointIds.replace(",", "','");
|
||||
wherestr += " and p.id not in ('" + alarmPointIds + "') ";
|
||||
}
|
||||
|
||||
PageHelper.startPage(page, rows);
|
||||
List<AlarmPoint> list = this.alarmPointService.selectListJoinInformationByWhere(wherestr + orderstr);
|
||||
|
||||
PageInfo<AlarmPoint> pi = new PageInfo<AlarmPoint>(list);
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
|
||||
String result = "{\"total\":" + pi.getTotal() + ",\"rows\":" + json + "}";
|
||||
// System.out.println(result);
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/getlistForSubscribeSys.do")
|
||||
public ModelAndView getlistForSubscribeSys(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required = false) String sort,
|
||||
@RequestParam(value = "order", required = false) String order) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
if (sort == null) {
|
||||
sort = " alarm_point ";
|
||||
}
|
||||
if (order == null) {
|
||||
order = " asc ";
|
||||
}
|
||||
String orderstr = " order by " + sort + " " + order;
|
||||
|
||||
String wherestr = " where 1=1 ";
|
||||
|
||||
if (request.getParameter("unitId") != null && request.getParameter("unitId").length() > 0) {
|
||||
wherestr += " and p.unit_id='" + request.getParameter("unitId") + "' ";
|
||||
}
|
||||
String searchName = request.getParameter("search_name");
|
||||
if (request.getParameter("informationCode") != null && request.getParameter("informationCode").length() > 0) {
|
||||
wherestr += " and information_code='" + request.getParameter("informationCode") + "' ";
|
||||
}
|
||||
|
||||
PageHelper.startPage(page, rows);
|
||||
List<AlarmPoint> list = this.alarmPointService.selectListJoinInformationByWhere(wherestr + orderstr);
|
||||
|
||||
PageInfo<AlarmPoint> pi = new PageInfo<AlarmPoint>(list);
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
|
||||
String result = "{\"total\":" + pi.getTotal() + ",\"rows\":" + json + "}";
|
||||
// System.out.println(result);
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/doMPointadd.do")
|
||||
public String doMPointadd(HttpServletRequest request, Model model) {
|
||||
List<AlarmInformation> alarmInformations = this.alarmInformationService.selectListByWhere(" where unit_id='" + request.getParameter("unitId") + "' order by code");
|
||||
JSONArray jsondata = new JSONArray();
|
||||
for (AlarmInformation alarmInformations2 : alarmInformations) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("id", alarmInformations2.getCode());
|
||||
jsonObject.put("text", alarmInformations2.getName());
|
||||
jsondata.add(jsonObject);
|
||||
}
|
||||
model.addAttribute("alarmInformationJson", jsondata.toString());
|
||||
|
||||
return "alarm/alarmPointAddForMPoint";
|
||||
}
|
||||
|
||||
@RequestMapping("/doMPointedit.do")
|
||||
public String doMPointedit(HttpServletRequest request, Model model) throws IOException {
|
||||
String id = request.getParameter("id");
|
||||
AlarmPoint alarmPoint = this.alarmPointService.selectById(id);
|
||||
model.addAttribute("alarmPoint", alarmPoint);
|
||||
|
||||
List<AlarmInformation> alarmInformations = this.alarmInformationService.selectListByWhere(" where unit_id='" + request.getParameter("unitId") + "' order by code");
|
||||
JSONArray jsondata = new JSONArray();
|
||||
for (AlarmInformation alarmInformations2 : alarmInformations) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("id", alarmInformations2.getCode());
|
||||
jsonObject.put("text", alarmInformations2.getName());
|
||||
jsondata.add(jsonObject);
|
||||
}
|
||||
model.addAttribute("alarmInformationJson", jsondata.toString());
|
||||
String alarmConfigType = new CommUtil().getProperties("mqtt.properties", "alarmConfigType");
|
||||
model.addAttribute("alarmConfigType", alarmConfigType);
|
||||
return "alarm/alarmPointEditForMPoint";
|
||||
}
|
||||
|
||||
@RequestMapping("/addOwnPoint.do")
|
||||
public String addOwnPoint(HttpServletRequest request, Model model) {
|
||||
List<AlarmInformation> alarmInformations = this.alarmInformationService.selectListByWhere(" where unit_id='" + request.getParameter("unitId") + "' order by code");
|
||||
JSONArray jsondata = new JSONArray();
|
||||
for (AlarmInformation alarmInformations2 : alarmInformations) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("id", alarmInformations2.getCode());
|
||||
jsonObject.put("text", alarmInformations2.getName());
|
||||
jsondata.add(jsonObject);
|
||||
}
|
||||
model.addAttribute("alarmInformationJson", jsondata.toString());
|
||||
return "alarm/alarmPointEditForOwnPoint";
|
||||
}
|
||||
|
||||
@RequestMapping("/dosave.do")
|
||||
public String dosave(HttpServletRequest request, Model model,
|
||||
@ModelAttribute AlarmPoint alarmPoint) {
|
||||
Result result = new Result();
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String id = CommUtil.getUUID();
|
||||
alarmPoint.setId(id);
|
||||
int code = this.alarmPointService.save(alarmPoint);
|
||||
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("新增失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doMPointSaves.do")
|
||||
public String doMPointSaves(HttpServletRequest request, Model model) {
|
||||
Result result = new Result();
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
int code = 0;
|
||||
|
||||
String unitId = request.getParameter("unitId");
|
||||
String[] idss = request.getParameter("ids").split(",");
|
||||
String informationCode = request.getParameter("informationCode");
|
||||
for (String ids : idss) {
|
||||
AlarmPoint alarmPoint = new AlarmPoint();
|
||||
alarmPoint.setId(CommUtil.getUUID());
|
||||
alarmPoint.setInsdt(CommUtil.nowDate());
|
||||
alarmPoint.setInsuser(cu.getId());
|
||||
alarmPoint.setUpdatetime(CommUtil.nowDate());
|
||||
alarmPoint.setUpdater(cu.getId());
|
||||
alarmPoint.setAlarmPoint(ids);
|
||||
alarmPoint.setInformationCode(informationCode);
|
||||
alarmPoint.setUnitId(unitId);
|
||||
alarmPoint.setType(request.getParameter("type"));
|
||||
code += this.alarmPointService.save(alarmPoint);
|
||||
}
|
||||
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("新增失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doupdate.do")
|
||||
public String doupdate(HttpServletRequest request, Model model,
|
||||
@ModelAttribute AlarmPoint alarmPoint) {
|
||||
Result result = new Result();
|
||||
|
||||
int code = this.alarmPointService.update(alarmPoint);
|
||||
if (alarmPoint.getInformationCode().contains(AlarmMoldCodeEnum.LimitValue_Pro.getKey())) {
|
||||
MPoint mPoint = this.mPointService.selectById(alarmPoint.getUnitId(), alarmPoint.getAlarmPoint());
|
||||
if (request.getParameter("lalarmmin") != null && !request.getParameter("alarmmax").equals("")) {
|
||||
mPoint.setAlarmmax(new BigDecimal(request.getParameter("alarmmax")));
|
||||
this.mPointService.update2(alarmPoint.getUnitId(), mPoint);
|
||||
} else {
|
||||
this.mPointService.updateAlarmmax(alarmPoint.getUnitId(), mPoint.getMpointcode());
|
||||
// mPoint.setAlarmmax(null);
|
||||
}
|
||||
if (request.getParameter("lalarmmin") != null && !request.getParameter("alarmmin").equals("")) {
|
||||
mPoint.setAlarmmin(new BigDecimal(request.getParameter("alarmmin")));
|
||||
this.mPointService.update2(alarmPoint.getUnitId(), mPoint);
|
||||
} else {
|
||||
this.mPointService.updateAlarmmin(alarmPoint.getUnitId(), mPoint.getMpointcode());
|
||||
// mPoint.setAlarmmin(null);
|
||||
}
|
||||
if (request.getParameter("lalarmmin") != null && !request.getParameter("halarmmax").equals("")) {
|
||||
mPoint.setHalarmmax(new BigDecimal(request.getParameter("halarmmax")));
|
||||
this.mPointService.update2(alarmPoint.getUnitId(), mPoint);
|
||||
} else {
|
||||
this.mPointService.updateHalarmmax(alarmPoint.getUnitId(), mPoint.getMpointcode());
|
||||
// mPoint.setHalarmmax(null);
|
||||
}
|
||||
if (request.getParameter("lalarmmin") != null && !request.getParameter("lalarmmin").equals("")) {
|
||||
mPoint.setLalarmmin(new BigDecimal(request.getParameter("lalarmmin")));
|
||||
this.mPointService.update2(alarmPoint.getUnitId(), mPoint);
|
||||
} else {
|
||||
this.mPointService.updateLalarmmin(alarmPoint.getUnitId(), mPoint.getMpointcode());
|
||||
// mPoint.setLalarmmin(null);
|
||||
}
|
||||
// this.mPointService.update2(alarmPoint.getUnitId(),mPoint);
|
||||
}
|
||||
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("更新失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodelete.do")
|
||||
public String dodelete(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
this.alarmSubscribeService.deleteByWhere("where alarm_point_id in ('" + id + "')");
|
||||
int code = this.alarmPointService.deleteById(id);
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("删除失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodeletes.do")
|
||||
public String dodeletes(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "ids") String ids) {
|
||||
ids = ids.replace(",", "','");
|
||||
this.alarmSubscribeService.deleteByWhere("where alarm_point_id in ('" + ids + "')");
|
||||
int result = this.alarmPointService.deleteByWhere("where id in ('" + ids + "')");
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/alarmRecover.do")
|
||||
public ModelAndView alarmRecover(HttpServletRequest request, Model model) {
|
||||
String bizid = request.getParameter("bizid");
|
||||
String pointId = request.getParameter("pointId");
|
||||
String alarmTime = request.getParameter("alarmTime");
|
||||
String recoverValue = request.getParameter("recoverValue");
|
||||
|
||||
int code = this.alarmPointService.alarmRecover(bizid, pointId, alarmTime, recoverValue);
|
||||
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("操作失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/insertAlarm.do")
|
||||
public String insertAlarm(HttpServletRequest request, Model model) {
|
||||
String alarmType = request.getParameter("alarmType");
|
||||
String pointId = request.getParameter("pointId");
|
||||
String pointName = request.getParameter("pointName");
|
||||
String unitId = request.getParameter("unitId");
|
||||
String levelType = request.getParameter("levelType");
|
||||
String describe = request.getParameter("describe");
|
||||
String nowValue = request.getParameter("nowValue");
|
||||
String prSectionCode = request.getParameter("prSectionCode");
|
||||
|
||||
String prSectionName = "";
|
||||
List<ProcessSection> prSection = this.processSectionService.selectListByWhere(" where code='" + prSectionCode + "' and unit_id='" + unitId + "' ");
|
||||
if (prSection != null && prSection.size() > 0) {
|
||||
prSectionName = prSection.get(0).getName();
|
||||
}
|
||||
|
||||
int result = this.alarmPointService.insertAlarm(unitId, request, alarmType, pointId, pointName, CommUtil.nowDate(), levelType, describe, nowValue, prSectionCode, prSectionName);
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/insertAlarmForApp.do")
|
||||
public String insertAlarmForApp(HttpServletRequest request, Model model) {
|
||||
String alarmType = request.getParameter("alarmType");
|
||||
String pointId = request.getParameter("pointId");
|
||||
String pointName = request.getParameter("pointName");
|
||||
String unitId = request.getParameter("unitId");
|
||||
String levelType = request.getParameter("levelType");
|
||||
String describe = request.getParameter("describe");
|
||||
String nowValue = request.getParameter("nowValue");
|
||||
String prSectionCode = request.getParameter("prSectionCode");
|
||||
|
||||
String prSectionName = "";
|
||||
List<ProcessSection> prSection = this.processSectionService.selectListByWhere(" where code='" + prSectionCode + "' and unit_id='" + unitId + "' ");
|
||||
if (prSection != null && prSection.size() > 0) {
|
||||
prSectionName = prSection.get(0).getName();
|
||||
}
|
||||
|
||||
String nowTime = CommUtil.nowDate();
|
||||
int result = this.alarmPointService.insertAlarm(unitId, request, alarmType, pointId, pointName, nowTime, levelType, describe, nowValue, prSectionCode, prSectionName);
|
||||
|
||||
JSONObject j = new JSONObject();
|
||||
j.put("result", result);
|
||||
j.put("pointId", pointId);
|
||||
j.put("nowTime", nowTime);
|
||||
|
||||
model.addAttribute("result", j);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/externalSysAlarm.do")
|
||||
public String externalSysAlarm(HttpServletRequest request, Model model) {
|
||||
String alarmType = request.getParameter("alarmType");
|
||||
String pointId = request.getParameter("pointId");
|
||||
String pointName = request.getParameter("pointName");
|
||||
String unitId = request.getParameter("unitId");
|
||||
String levelType = request.getParameter("levelType");
|
||||
String describe = request.getParameter("describe");
|
||||
String nowValue = request.getParameter("nowValue");
|
||||
String prSectionCode = request.getParameter("prSectionCode");
|
||||
|
||||
String prSectionName = "";
|
||||
if (prSectionCode != null && !prSectionCode.equals("")) {
|
||||
List<ProcessSection> prSection = this.processSectionService.selectListByWhere(" where code='" + prSectionCode + "' and unit_id='" + unitId + "' ");
|
||||
if (prSection != null && prSection.size() > 0) {
|
||||
prSectionName = prSection.get(0).getName();
|
||||
}
|
||||
}
|
||||
|
||||
int result = this.alarmPointService.insertAlarm(unitId, null, alarmType, pointId, pointName, CommUtil.nowDate(), levelType, describe, nowValue, prSectionCode, prSectionName);
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/externalSysAlarmRecover.do")
|
||||
public ModelAndView externalSysAlarmRecover(HttpServletRequest request, Model model) {
|
||||
String unitId = request.getParameter("unitId");
|
||||
String pointId = request.getParameter("pointId");
|
||||
String recoverValue = request.getParameter("recoverValue");
|
||||
|
||||
int code = this.alarmPointService.alarmRecover2(unitId, pointId, recoverValue);
|
||||
|
||||
model.addAttribute("result", code);
|
||||
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,150 @@
|
||||
package com.sipai.controller.alarm;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.alarm.AlarmLevelsConfig;
|
||||
import com.sipai.entity.alarm.AlarmPointRiskLevel;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.hqconfig.RiskLevel;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.alarm.AlarmLevesConfigService;
|
||||
import com.sipai.service.alarm.AlarmPointRiskLevelService;
|
||||
import com.sipai.service.hqconfig.RiskLevelService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
import net.sf.json.JSONArray;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("alarm/alarmPointRiskLevel")
|
||||
public class AlarmPointRiskLevelController {
|
||||
@Resource
|
||||
private AlarmPointRiskLevelService alarmPointRiskLevelService;
|
||||
@Resource
|
||||
private RiskLevelService riskLevelService;
|
||||
|
||||
// @RequestMapping("/getList.do")
|
||||
// public String getList(HttpServletRequest request, Model model) {
|
||||
// String pid = request.getParameter("pid");
|
||||
// List<AlarmPointRiskLevel> list = this.alarmPointRiskLevelService.selectListByWhere("where alarmPoint_id = '" + pid + "' order by morder ");
|
||||
// JSONArray json = JSONArray.fromObject(list);
|
||||
// String result = "{\"rows\":" + json + "}";
|
||||
// model.addAttribute("result", result);
|
||||
// return "result";
|
||||
// }
|
||||
|
||||
@RequestMapping("/getList.do")
|
||||
public ModelAndView getList(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required = false) String sort,
|
||||
@RequestParam(value = "order", required = false) String order) {
|
||||
//User cu=(User)request.getSession().getAttribute("cu");
|
||||
if (sort == null) {
|
||||
sort = " morder ";
|
||||
}
|
||||
if (order == null) {
|
||||
order = " asc ";
|
||||
}
|
||||
String orderstr = " order by " + sort + " " + order;
|
||||
|
||||
String pid = request.getParameter("pid");
|
||||
|
||||
String wherestr = "where alarmPoint_id = '" + pid + "' order by morder ";
|
||||
|
||||
PageHelper.startPage(page, rows);
|
||||
List<AlarmPointRiskLevel> list = this.alarmPointRiskLevelService.selectListByWhere(wherestr);
|
||||
|
||||
PageInfo<AlarmPointRiskLevel> pi = new PageInfo<AlarmPointRiskLevel>(list);
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
|
||||
String result = "{\"total\":" + pi.getTotal() + ",\"rows\":" + json + "}";
|
||||
// System.out.println(result);
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/add.do")
|
||||
public String add(HttpServletRequest request, Model model) {
|
||||
return "alarm/alarmPointRiskLevelAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/edit.do")
|
||||
public String edit(HttpServletRequest request, Model model) {
|
||||
String id = request.getParameter("id");
|
||||
AlarmPointRiskLevel alarmPointRiskLevel = alarmPointRiskLevelService.selectById(id);
|
||||
model.addAttribute("alarmPointRiskLevel", alarmPointRiskLevel);
|
||||
return "alarm/alarmPointRiskLevelEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/doSave.do")
|
||||
public String dosave(HttpServletRequest request, Model model,
|
||||
@ModelAttribute AlarmPointRiskLevel alarmPointRiskLevel) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String id = CommUtil.getUUID();
|
||||
alarmPointRiskLevel.setId(id);
|
||||
alarmPointRiskLevel.setInsdt(CommUtil.nowDate());
|
||||
alarmPointRiskLevel.setInsuser(cu.getId());
|
||||
alarmPointRiskLevel.setMorder(0);
|
||||
int result = this.alarmPointRiskLevelService.save(alarmPointRiskLevel);
|
||||
String resstr = "{\"res\":\"" + result + "\",\"id\":\"" + id + "\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doUpdate.do")
|
||||
public String doupdate(HttpServletRequest request, Model model,
|
||||
@ModelAttribute AlarmPointRiskLevel alarmPointRiskLevel) {
|
||||
int code = this.alarmPointRiskLevelService.update(alarmPointRiskLevel);
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("更新失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/dodel.do")
|
||||
public String dodel(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
Result result = new Result();
|
||||
int code = this.alarmPointRiskLevelService.deleteById(id);
|
||||
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("删除失败");
|
||||
}
|
||||
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodelByPid.do")
|
||||
public String dodelByPid(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "pid") String pid) {
|
||||
Result result = new Result();
|
||||
int code = this.alarmPointRiskLevelService.deleteByWhere(pid);
|
||||
if (code > 0) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("删除失败");
|
||||
}
|
||||
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,132 @@
|
||||
package com.sipai.controller.alarm;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.alarm.AlarmRecord;
|
||||
import com.sipai.entity.alarm.AlarmSolution;
|
||||
import com.sipai.entity.alarm.AlarmType;
|
||||
import com.sipai.entity.timeefficiency.PatrolRecord;
|
||||
import com.sipai.entity.timeefficiency.TimeEfficiencyCommStr;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.alarm.AlarmRecordService;
|
||||
import com.sipai.service.alarm.AlarmSolutionService;
|
||||
import com.sipai.service.timeefficiency.PatrolRecordService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/alarm/alarmRecord")
|
||||
public class AlarmRecordController {
|
||||
@Resource
|
||||
private AlarmRecordService alarmRecordService;
|
||||
@Resource
|
||||
private PatrolRecordService patrolRecordService;
|
||||
@Resource
|
||||
private AlarmSolutionService alarmSolutionService;
|
||||
|
||||
@RequestMapping("/showList.do")
|
||||
public String showList(HttpServletRequest request,Model model){
|
||||
return "alarm/alarmRecordList";
|
||||
}
|
||||
|
||||
@RequestMapping("/getList.do")
|
||||
public String getList(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required=false) String sort,
|
||||
@RequestParam(value = "order", required=false) String order){
|
||||
if(sort==null){
|
||||
sort = " insdt ";
|
||||
}
|
||||
if(order==null){
|
||||
order = " desc ";
|
||||
}
|
||||
String orderstr=" order by "+sort+" "+order;
|
||||
String wherestr="where 1=1";
|
||||
PageHelper.startPage(page, rows);
|
||||
List<AlarmRecord> list = this.alarmRecordService.selectListByWhere(wherestr+orderstr);
|
||||
PageInfo<AlarmRecord> pi = new PageInfo<AlarmRecord>(list);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
|
||||
String result="{\"total\":"+pi.getTotal()+",\"rows\":"+json+"}";
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doview.do")
|
||||
public String doview(HttpServletRequest request,Model model){
|
||||
String id = request.getParameter("id");
|
||||
AlarmRecord alarmRecord = this.alarmRecordService.selectById(id);
|
||||
model.addAttribute("alarmRecord", alarmRecord);
|
||||
return "alarm/alarmRecordView";
|
||||
}
|
||||
|
||||
/**
|
||||
* 下发
|
||||
* @param request
|
||||
* @param model
|
||||
* @return
|
||||
* @throws ParseException
|
||||
*/
|
||||
@RequestMapping("/issue.do")
|
||||
public String issue(HttpServletRequest request,Model model) throws ParseException{
|
||||
String id = request.getParameter("id");
|
||||
String unitId = request.getParameter("unitId");
|
||||
AlarmRecord alarmRecord = this.alarmRecordService.selectById(id);
|
||||
AlarmType alarmType = alarmRecord.getAlarmType();
|
||||
String solutionid = request.getParameter("solutionid");
|
||||
solutionid = "('"+solutionid.replaceAll(",", "','")+"')";
|
||||
List<AlarmSolution> list = this.alarmSolutionService.selectListByWhere
|
||||
("where id in "+solutionid +" order by id");
|
||||
PatrolRecord patrolRecord = new PatrolRecord();
|
||||
patrolRecord.setBizId(unitId);
|
||||
patrolRecord.setUnitId(unitId);
|
||||
patrolRecord.setInsuser(((User)request.getSession().getAttribute("cu")).getId());
|
||||
//patrolRecord.setPatrolAreaId(patrolPlan.getPatrolAreaId());
|
||||
patrolRecord.setName("预警临时任务");
|
||||
String content = "预警描述:"+alarmType.getDescribe()+".";
|
||||
if(list != null && list.size()>0){
|
||||
for(int i=0;i<list.size();i++){
|
||||
content += "\n解决措施"+i+":"+list.get(i).getSolution()+";";
|
||||
}
|
||||
}
|
||||
patrolRecord.setContent(alarmType.getDescribe());
|
||||
patrolRecord.setPatrolPlanId(alarmRecord.getId());
|
||||
patrolRecord.setType(TimeEfficiencyCommStr.PatrolType_Alarm);
|
||||
patrolRecord.setPatrolModelId(TimeEfficiencyCommStr.PatrolModel_TempTask);
|
||||
patrolRecord.setStatus(PatrolRecord.Status_Issue);
|
||||
patrolRecord.setDuration(0);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Calendar startCalendar =Calendar.getInstance();
|
||||
String startTime = CommUtil.nowDate().substring(0, 19);
|
||||
startCalendar.setTime(sdf.parse(startTime));
|
||||
Calendar endCalendar =Calendar.getInstance();
|
||||
endCalendar.setTime(startCalendar.getTime());
|
||||
endCalendar.add(Calendar.MINUTE, 60);
|
||||
String endTime = sdf.format(endCalendar.getTime());
|
||||
patrolRecord.setStartTime(startTime);
|
||||
patrolRecord.setEndTime(endTime);
|
||||
patrolRecord.setId(CommUtil.getUUID());
|
||||
patrolRecord.setInsdt(CommUtil.nowDate());
|
||||
int result=this.patrolRecordService.save(patrolRecord);
|
||||
alarmRecord.setState("1");
|
||||
this.alarmRecordService.update(alarmRecord);
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,131 @@
|
||||
package com.sipai.controller.alarm;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.alarm.AlarmCondition;
|
||||
import com.sipai.entity.alarm.AlarmSolution;
|
||||
import com.sipai.entity.alarm.OrderType;
|
||||
import com.sipai.service.alarm.AlarmSolutionService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/alarm/alarmSolution")
|
||||
public class AlarmSolutionController {
|
||||
@Resource
|
||||
private AlarmSolutionService alarmSolutionService;
|
||||
|
||||
@RequestMapping("/getList.do")
|
||||
public String getList(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required=false) String sort,
|
||||
@RequestParam(value = "order", required=false) String order){
|
||||
if(sort==null){
|
||||
sort = " insdt ";
|
||||
}
|
||||
if(order==null){
|
||||
order = " desc ";
|
||||
}
|
||||
String orderstr=" order by "+sort+" "+order;
|
||||
String wherestr="where 1=1";
|
||||
if(request.getParameter("alarmtypeid") != null &&
|
||||
request.getParameter("alarmtypeid").trim().length()>0){
|
||||
wherestr += " and alarmtypeid = '"+request.getParameter("alarmtypeid")+"'";
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<AlarmSolution> list = this.alarmSolutionService.selectListByWhere(wherestr + orderstr);
|
||||
PageInfo<AlarmSolution> pi = new PageInfo<AlarmSolution>(list);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
|
||||
String result="{\"total\":"+pi.getTotal()+",\"rows\":"+json+"}";
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/showAdd.do")
|
||||
public String showAdd(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "alarmtypeid") String alarmtypeid){
|
||||
model.addAttribute("alarmtypeid", alarmtypeid);
|
||||
return "alarm/alarmSolutionAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/getOrderJson.do")
|
||||
public String getOrderJson(HttpServletRequest request,Model model){
|
||||
List<OrderType> list = OrderType.getList();
|
||||
JSONArray json = new JSONArray();
|
||||
if(list!=null && list.size()>0){
|
||||
for(int i=0;i<list.size();i++){
|
||||
JSONObject jsonObject =new JSONObject();
|
||||
jsonObject.put("id", list.get(i).getId());
|
||||
jsonObject.put("text", list.get(i).getName());
|
||||
json.add(jsonObject);
|
||||
}
|
||||
}
|
||||
model.addAttribute("result", json.toString());
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dosave.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute("alarmSolution") AlarmSolution alarmSolution){
|
||||
alarmSolution.setId(CommUtil.getUUID());
|
||||
alarmSolution.setInsdt(CommUtil.nowDate());
|
||||
alarmSolution.setDeptids(request.getParameter(""));
|
||||
int result = this.alarmSolutionService.save(alarmSolution);
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodel.do")
|
||||
public String dodel(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
int result = this.alarmSolutionService.deleteById(id);
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/showEdit.do")
|
||||
public String showEdit(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
AlarmSolution alarmSolution = this.alarmSolutionService.selectById(id);
|
||||
model.addAttribute("alarmSolution", alarmSolution);
|
||||
String deptIds = alarmSolution.getDeptids();
|
||||
String[] depts = deptIds.split(",");
|
||||
List<String> list = Arrays.asList(depts);
|
||||
JSONArray json=new JSONArray();
|
||||
if(list != null && list.size()>0){
|
||||
for(String s:list){
|
||||
JSONObject jsonObject =new JSONObject();
|
||||
jsonObject.put("id", s);
|
||||
jsonObject.put("text", "");
|
||||
json.add(jsonObject);
|
||||
}
|
||||
}
|
||||
model.addAttribute("depts", json);
|
||||
return "alarm/alarmSolutionEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/doupdate.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute("alarmSolution") AlarmSolution alarmSolution){
|
||||
int result = this.alarmSolutionService.update(alarmSolution);
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,209 @@
|
||||
package com.sipai.controller.alarm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.sipai.entity.alarm.AlarmLevels;
|
||||
import com.sipai.entity.alarm.AlarmMold;
|
||||
import com.sipai.service.alarm.AlarmLevelsService;
|
||||
import com.sipai.service.alarm.AlarmMoldService;
|
||||
import net.sf.json.JSONArray;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.alarm.AlarmSubscribe;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.alarm.AlarmSubscribeService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/alarm/alarmSubscribe")
|
||||
public class AlarmSubscribeController {
|
||||
@Resource
|
||||
private AlarmSubscribeService alarmSubscribeService;
|
||||
@Resource
|
||||
private AlarmLevelsService alarmLevelsService;
|
||||
@Resource
|
||||
private AlarmMoldService alarmMoldService;
|
||||
|
||||
@RequestMapping("/showist.do")
|
||||
public String showAlarmSubscribelist(HttpServletRequest request,Model model) {
|
||||
return "/alarm/alarmSubscribeList";
|
||||
}
|
||||
@RequestMapping("/getlist.do")
|
||||
public ModelAndView getlist(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required=false) String sort,
|
||||
@RequestParam(value = "order", required=false) String order) {
|
||||
//User cu=(User)request.getSession().getAttribute("cu");
|
||||
if(sort==null){
|
||||
sort = " code ";
|
||||
}
|
||||
if(order==null){
|
||||
order = " asc ";
|
||||
}
|
||||
String orderstr=" order by "+sort+" "+order;
|
||||
|
||||
String wherestr="where 1=1 ";
|
||||
|
||||
PageHelper.startPage(page, rows);
|
||||
List<AlarmSubscribe> list = this.alarmSubscribeService.selectListByWhere(wherestr+orderstr);
|
||||
|
||||
PageInfo<AlarmSubscribe> pi = new PageInfo<AlarmSubscribe>(list);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
|
||||
String result="{\"total\":"+pi.getTotal()+",\"rows\":"+json+"}";
|
||||
// System.out.println(result);
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/getJsonForPersonalSubscribe.do")
|
||||
public ModelAndView getJsonForPersonalSubscribe(HttpServletRequest request,Model model) {
|
||||
User cu=(User)request.getSession().getAttribute("cu");
|
||||
// JSONArray jsondata=new JSONArray();
|
||||
// List<AlarmInformation> alarmMoldList = this.alarmInformationService.getDistinctMold(" where unit_id='"+request.getParameter("unitId")+"' and alarm_receivers like '%"+cu.getId()+"%' ");
|
||||
// for(AlarmInformation alarmMold:alarmMoldList){
|
||||
// JSONObject jsonObject=new JSONObject();
|
||||
// jsonObject.put("id",alarmMold.getMoldCode());
|
||||
// jsonObject.put("text",AlarmMoldCodeEnum.getName(alarmMold.getMoldCode()));
|
||||
// jsonObject.put("type","mold");
|
||||
// jsonObject.put("moldCode",alarmMold.getMoldCode());
|
||||
//
|
||||
// List<AlarmInformation> levelList = this.alarmInformationService.selectListByWhere(" " +
|
||||
// "where unit_id='"+request.getParameter("unitId")+"' and mold_code='"+alarmMold.getMoldCode()+"' and alarm_receivers like '%"+cu.getId()+"%' " +
|
||||
// "order by code");
|
||||
// JSONArray djsondata=new JSONArray();
|
||||
// for(AlarmInformation aInformation:levelList){
|
||||
// JSONObject djsonObject=new JSONObject();
|
||||
// djsonObject.put("id",aInformation.getLevelCode());
|
||||
// djsonObject.put("text",AlarmLevelsCodeEnum.getName(aInformation.getLevelCode()));
|
||||
// djsonObject.put("type","level");
|
||||
// djsonObject.put("hiddenId",aInformation.getId());
|
||||
// djsonObject.put("moldCode",alarmMold.getMoldCode());
|
||||
// djsondata.add(djsonObject);
|
||||
// }
|
||||
// jsonObject.put("nodes",djsondata);
|
||||
// jsondata.add(jsonObject);
|
||||
// }
|
||||
//
|
||||
// String str = JSON.toJSONString(jsondata);
|
||||
// model.addAttribute("result",str);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/doadd.do")
|
||||
public String doadd(HttpServletRequest request,Model model){
|
||||
List<AlarmLevels> alarmLevels = this.alarmLevelsService.selectListByWhere(" order by morder");
|
||||
JSONArray jsondata=new JSONArray();
|
||||
for (AlarmLevels alarmLevels2 : alarmLevels) {
|
||||
JSONObject jsonObject=new JSONObject();
|
||||
jsonObject.put("id",alarmLevels2.getCode());
|
||||
jsonObject.put("text",alarmLevels2.getName());
|
||||
jsondata.add(jsonObject);
|
||||
}
|
||||
List<AlarmMold> alarmMolds = this.alarmMoldService.selectListByWhere(" order by morder");
|
||||
JSONArray jsondata2=new JSONArray();
|
||||
for (AlarmMold alarmMolds2 : alarmMolds) {
|
||||
JSONObject jsonObject=new JSONObject();
|
||||
jsonObject.put("id",alarmMolds2.getCode());
|
||||
jsonObject.put("text",alarmMolds2.getName());
|
||||
jsondata2.add(jsonObject);
|
||||
}
|
||||
|
||||
model.addAttribute("alarmLevelsCodeEnum",jsondata.toString());
|
||||
model.addAttribute("alarmMoldCodeEnum",jsondata2.toString());
|
||||
return "alarm/alarmSubscribeAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/showSysPoint.do")
|
||||
public String showSysPoint(HttpServletRequest request,Model model){
|
||||
String id = request.getParameter("id");
|
||||
AlarmSubscribe alarmSubscribe = this.alarmSubscribeService.selectById(id);
|
||||
model.addAttribute("alarmSubscribe", alarmSubscribe);
|
||||
return "alarm/alarmSysSubscribePointList";
|
||||
}
|
||||
|
||||
@RequestMapping("/showPersonalPoint.do")
|
||||
public String showPersonalPoint(HttpServletRequest request,Model model){
|
||||
String id = request.getParameter("id");
|
||||
AlarmSubscribe alarmSubscribe = this.alarmSubscribeService.selectById(id);
|
||||
model.addAttribute("alarmSubscribe", alarmSubscribe);
|
||||
return "alarm/alarmPersonalSubscribePointList";
|
||||
}
|
||||
|
||||
@RequestMapping("/doPersonalSave.do")
|
||||
public String doPersonalSave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute AlarmSubscribe alarmSubscribe){
|
||||
Result result = new Result();
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
String[] ids=request.getParameter("ids").split(",");
|
||||
int code = 0;
|
||||
for (String alarmPointid: ids) {
|
||||
String id = CommUtil.getUUID();
|
||||
alarmSubscribe.setId(id);
|
||||
alarmSubscribe.setAlarmPointId(alarmPointid);
|
||||
alarmSubscribe.setUnitId(request.getParameter("unitId"));
|
||||
alarmSubscribe.setUserid(cu.getId());
|
||||
code += this.alarmSubscribeService.save(alarmSubscribe);
|
||||
}
|
||||
|
||||
if (code >= Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("新增失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doupdate.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute AlarmSubscribe alarmSubscribe){
|
||||
String oldCode=request.getParameter("oldCode");
|
||||
Result result = new Result();
|
||||
int code = this.alarmSubscribeService.update(alarmSubscribe);
|
||||
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("更新失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
@RequestMapping("/dodelete.do")
|
||||
public String dodelete(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id){
|
||||
int code = this.alarmSubscribeService.deleteById(id);
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("删除失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodeletes.do")
|
||||
public String dodeletes(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="ids") String ids){
|
||||
ids=ids.replace(",","','");
|
||||
int result = this.alarmSubscribeService.deleteByWhere("where id in ('"+ids+"')");
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,123 @@
|
||||
package com.sipai.controller.alarm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import com.sipai.entity.alarm.AlarmType;
|
||||
import com.sipai.entity.msg.MsgType;
|
||||
import com.sipai.entity.user.Menu;
|
||||
import com.sipai.service.alarm.AlarmTypeService;
|
||||
import com.sipai.service.msg.MsgTypeService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/alarm")
|
||||
public class AlarmTypeController {
|
||||
@Resource
|
||||
private AlarmTypeService alarmTypeService;
|
||||
@Resource
|
||||
private MsgTypeService msgTypeService;
|
||||
|
||||
@RequestMapping("/showAlarmTypeTree.do")
|
||||
public String showAlarmTypeTree(HttpServletRequest request,Model model){
|
||||
return "alarm/alarmTypeTree";
|
||||
}
|
||||
|
||||
@RequestMapping("/getAlarmTypesJson.do")
|
||||
public String getAlarmTypesJson(HttpServletRequest request,Model model){
|
||||
List<AlarmType> list = alarmTypeService.selectListByWhere
|
||||
("where 1=1 and unitid='"+request.getParameter("unitid")
|
||||
+"' order by id");
|
||||
String json = alarmTypeService.getTreeList(null, list);
|
||||
model.addAttribute("result", json);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/showAlarmTypeAdd.do")
|
||||
public String doadd(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="pid") String pid){
|
||||
if(pid!=null && !pid.equals("")){
|
||||
AlarmType alarmType= alarmTypeService.selectById(pid);
|
||||
model.addAttribute("pname",alarmType.getType());
|
||||
}
|
||||
return "alarm/alarmTypeAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/showAlarmType4Select.do")
|
||||
public String showAlarmType4Select(HttpServletRequest request,Model model){
|
||||
return "alarm/alarmType4Select";
|
||||
}
|
||||
|
||||
@RequestMapping("/saveAlarm.do")
|
||||
public String saveAlarm(HttpServletRequest request,Model model,
|
||||
@ModelAttribute("alarmType") AlarmType alarmType){
|
||||
alarmType.setId(CommUtil.getUUID());
|
||||
alarmType.setUnitid(request.getParameter("unitId"));
|
||||
if (alarmType.getPid()==null || alarmType.getPid().isEmpty()) {
|
||||
alarmType.setPid("-1");
|
||||
}
|
||||
int result = this.alarmTypeService.save(alarmType);
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/showAlarmTypeEdit.do")
|
||||
public String showAlarmTypeEdit(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id){
|
||||
AlarmType alarmType = alarmTypeService.selectById(id);
|
||||
if(alarmTypeService.selectById(alarmType.getPid())!=null)
|
||||
alarmType.set_pname(alarmTypeService.selectById(alarmType.getPid()).getType());
|
||||
model.addAttribute("alarmType",alarmType );
|
||||
if(alarmType.getOperaters() != null && alarmType.getOperaters().size()>0){
|
||||
String users = "";
|
||||
for(int i=0;i<alarmType.getOperaters().size();i++){
|
||||
users += alarmType.getOperaters().get(i).getCaption()+",";
|
||||
}
|
||||
model.addAttribute("operaters", users.substring(0, users.length()-1));
|
||||
}
|
||||
if(alarmType.getNoticeType() != null){
|
||||
MsgType msgType = msgTypeService.getMsgTypeById(alarmType.getNoticeType());
|
||||
if(msgType != null){
|
||||
model.addAttribute("msgType", msgType);
|
||||
}
|
||||
}
|
||||
return "alarm/alarmTypeEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/updatealarmType.do")
|
||||
public String updatealarmType(HttpServletRequest request,Model model,
|
||||
@ModelAttribute("alarmType") AlarmType alarmType){
|
||||
int result = this.alarmTypeService.update(alarmType);
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/deleteAlarmType.do")
|
||||
public String deleteAlarmType(HttpServletRequest request,Model model,
|
||||
@ModelAttribute("alarmType") AlarmType alarmType){
|
||||
String msg = "";
|
||||
int result = 0;
|
||||
List<AlarmType> list = alarmTypeService.selectListByWhere("where pid = '"
|
||||
+alarmType.getId()+"'");
|
||||
if(list != null && list.size()>0){
|
||||
msg = "请先删除子类型";
|
||||
}else{
|
||||
result = this.alarmTypeService.deleteById(alarmType.getId());
|
||||
if(result>0){
|
||||
|
||||
}else{
|
||||
msg="删除失败";
|
||||
}
|
||||
}
|
||||
model.addAttribute("result","{\"res\":\""+result+"\",\"msg\":\""+msg+"\"}");
|
||||
return "result";
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,333 @@
|
||||
package com.sipai.controller.alarm;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.process.DecisionExpertBase;
|
||||
import com.sipai.entity.scada.ProAlarmBaseText;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.process.DecisionExpertBaseService;
|
||||
import com.sipai.service.scada.ProAlarmBaseTextService;
|
||||
import com.sipai.service.scada.ProAlarmService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
import net.sf.json.JSONArray;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/alarm/proAlarmBaseText")
|
||||
public class ProAlarmBaseTextController {
|
||||
@Resource
|
||||
private ProAlarmBaseTextService proAlarmBaseTextService;
|
||||
@Resource
|
||||
private DecisionExpertBaseService decisionExpertBaseService;
|
||||
@Resource
|
||||
private ProAlarmService proAlarmService;
|
||||
|
||||
@RequestMapping("/showList.do")
|
||||
public String showProAlarmBaseTextEdit(HttpServletRequest request, Model model) {
|
||||
|
||||
return "alarm/proAlarmBaseTextList";
|
||||
}
|
||||
|
||||
@RequestMapping("/getList.do")
|
||||
public ModelAndView getList(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "unitId") String unitId,
|
||||
@RequestParam(value = "sort", required = false) String sort,
|
||||
@RequestParam(value = "order", required = false) String order) {
|
||||
//User cu=(User)request.getSession().getAttribute("cu");
|
||||
if (sort == null) {
|
||||
sort = " insdt ";
|
||||
}
|
||||
if (order == null) {
|
||||
order = " asc ";
|
||||
}
|
||||
String orderstr = " order by " + sort + " " + order;
|
||||
|
||||
String wherestr = "where 1=1 ";
|
||||
|
||||
if (!request.getParameter("sdt").equals("") && request.getParameter("sdt").length() > 0 && !request.getParameter("edt").equals("") && request.getParameter("edt").length() > 0) {
|
||||
wherestr += " and insdt>='" + request.getParameter("sdt") + "' and insdt<='" + request.getParameter("edt") + "' ";
|
||||
}
|
||||
if (!request.getParameter("zdType").equals("") && request.getParameter("zdType").length() > 0) {
|
||||
wherestr += " and decisionExpertBase_pid='" + request.getParameter("zdType") + "' ";
|
||||
}
|
||||
if (!request.getParameter("adoptSt").equals("") && request.getParameter("adoptSt").length() > 0) {
|
||||
String adoptSt = request.getParameter("adoptSt");
|
||||
if (ProAlarmBaseText.AdoptSt_True.equals(adoptSt)) {
|
||||
wherestr += " and adopt_st='" + adoptSt + "' ";
|
||||
} else {
|
||||
wherestr += " and adopt_st is null ";
|
||||
}
|
||||
}
|
||||
|
||||
PageHelper.startPage(page, rows);
|
||||
List<ProAlarmBaseText> list = this.proAlarmBaseTextService.selectListByWhere2(unitId, wherestr + orderstr);
|
||||
|
||||
PageInfo<ProAlarmBaseText> pi = new PageInfo<ProAlarmBaseText>(list);
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
|
||||
String result = "{\"total\":" + pi.getTotal() + ",\"rows\":" + json + "}";
|
||||
// System.out.println(result);
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/downOrder.do")
|
||||
public String downOrder(HttpServletRequest request, Model model) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
|
||||
String id = request.getParameter("id");
|
||||
String unitId = request.getParameter("unitId");
|
||||
|
||||
ProAlarmBaseText proAlarmBaseText = this.proAlarmBaseTextService.selectById(unitId, id);
|
||||
proAlarmBaseText.setAdoptSt(ProAlarmBaseText.AdoptSt_True);
|
||||
proAlarmBaseText.setAdopter(cu.getId());
|
||||
proAlarmBaseText.setAdoptionTime(CommUtil.nowDate());
|
||||
|
||||
int result = this.proAlarmBaseTextService.update(unitId, proAlarmBaseText);
|
||||
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/getStatisticalData.do")
|
||||
public String getStatisticalData(HttpServletRequest request, Model model) {
|
||||
String unitId = request.getParameter("unitId");
|
||||
String date = request.getParameter("statisticalDate");
|
||||
|
||||
List<DecisionExpertBase> dlist = this.decisionExpertBaseService.selectListByWhere(" where unitId='" + unitId + "' and pid='-1' ");
|
||||
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
if (dlist != null && dlist.size() > 0) {
|
||||
for (DecisionExpertBase decisionExpertBase :
|
||||
dlist) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
String name = decisionExpertBase.getName();
|
||||
List<ProAlarmBaseText> pTrueNumList = this.proAlarmBaseTextService.selectCountByWhere(unitId, " where decisionExpertBase_pid='" + decisionExpertBase.getId() + "' and adopt_st='" + ProAlarmBaseText.AdoptSt_True + "' and datediff(year,insdt,'" + date + "')=0 ");
|
||||
List<ProAlarmBaseText> pFalseNumList = this.proAlarmBaseTextService.selectCountByWhere(unitId, " where decisionExpertBase_pid='" + decisionExpertBase.getId() + "' and (adopt_st='" + ProAlarmBaseText.AdoptSt_False + "' or adopt_st is null) and datediff(year,insdt,'" + date + "')=0 ");
|
||||
|
||||
int trueNum = 0;
|
||||
int falseNum = 0;
|
||||
|
||||
if (pTrueNumList != null && pTrueNumList.size() > 0) {
|
||||
trueNum = pTrueNumList.get(0).getNum();
|
||||
}
|
||||
if (pFalseNumList != null && pFalseNumList.size() > 0) {
|
||||
falseNum = pFalseNumList.get(0).getNum();
|
||||
}
|
||||
|
||||
jsonObject.put("name", name);
|
||||
jsonObject.put("trueNum", trueNum);
|
||||
jsonObject.put("falseNum", falseNum);
|
||||
jsonObject.put("totalNum", trueNum + falseNum);
|
||||
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
model.addAttribute("result", jsonArray);
|
||||
return "result";
|
||||
}
|
||||
|
||||
//月数据 泰和模型用
|
||||
@RequestMapping("/getStatisticalDataForTH.do")
|
||||
public String getStatisticalDataForTH(HttpServletRequest request, Model model) {
|
||||
try {
|
||||
String unitId = request.getParameter("unitId");
|
||||
String date = request.getParameter("statisticalDate");
|
||||
String pid = request.getParameter("pid");
|
||||
|
||||
// String sdt = CommUtil.subplus(date, "-12", "month");
|
||||
// String edt = CommUtil.subplus(date, "1", "month");
|
||||
String sdt = date.substring(0, 4) + "-01-01";
|
||||
String edt = CommUtil.subplus(sdt, "1", "year");
|
||||
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
|
||||
//决策信息
|
||||
List<ProAlarmBaseText> pTrueNumList = this.proAlarmBaseTextService.selectCountByWhere(unitId, " where decisionExpertBase_pid='" + pid + "' and adopt_st='" + ProAlarmBaseText.AdoptSt_True + "' and datediff(month,insdt,'" + date + "')=0");
|
||||
List<ProAlarmBaseText> pFalseNumList = this.proAlarmBaseTextService.selectCountByWhere(unitId, " where decisionExpertBase_pid='" + pid + "' and (adopt_st='" + ProAlarmBaseText.AdoptSt_False + "' or adopt_st is null) and datediff(month,insdt,'" + date + "')=0");
|
||||
|
||||
List<ProAlarmBaseText> pTrueNumList2 = this.proAlarmBaseTextService.selectListByWhere(unitId, " where decisionExpertBase_pid='" + pid + "' and datediff(month,insdt,'" + date + "')=0 order by insdt desc");
|
||||
|
||||
int trueNum = 0;
|
||||
int falseNum = 0;
|
||||
|
||||
if (pTrueNumList != null && pTrueNumList.size() > 0) {
|
||||
trueNum = pTrueNumList.get(0).getNum();
|
||||
}
|
||||
|
||||
if (pTrueNumList2 != null && pTrueNumList2.size() > 0) {
|
||||
jsonObject.put("firstTrueContent", pTrueNumList2.get(0).getDecisionexpertbasetext());
|
||||
jsonObject.put("firstTrueTime", pTrueNumList2.get(0).getInsdt().substring(0, 16));
|
||||
jsonObject.put("firstTrueSt", pTrueNumList2.get(0).getAdoptSt());
|
||||
} else {
|
||||
jsonObject.put("firstTrueContent", "-");
|
||||
jsonObject.put("firstTrueTime", "-");
|
||||
jsonObject.put("firstTrueSt", "-");
|
||||
}
|
||||
|
||||
if (pFalseNumList != null && pFalseNumList.size() > 0) {
|
||||
falseNum = pFalseNumList.get(0).getNum();
|
||||
}
|
||||
|
||||
// jsonObject.put("name", name);
|
||||
jsonObject.put("trueNum", trueNum);
|
||||
jsonObject.put("falseNum", falseNum);
|
||||
jsonObject.put("totalNum", trueNum + falseNum);
|
||||
|
||||
//报警信息
|
||||
List<DecisionExpertBase> deList = this.decisionExpertBaseService.selectListByWhere(" where pid='" + pid + "' ");
|
||||
String mpids = "";
|
||||
if (deList != null && deList.size() > 0) {
|
||||
for (DecisionExpertBase decisionExpertBase :
|
||||
deList) {
|
||||
mpids += decisionExpertBase.getMpid() + ",";
|
||||
}
|
||||
}
|
||||
mpids = mpids.replace(",", "','");
|
||||
|
||||
String curveSdt = CommUtil.subplus(date,"-11","month");
|
||||
String curveEdt = CommUtil.subplus(date,"1","month");
|
||||
|
||||
String[] yearM = new String[12];
|
||||
for (int i = 0; i < 12; i++) {
|
||||
yearM[i] = CommUtil.subplus(curveSdt, String.valueOf(i), "month").substring(5, 7);
|
||||
}
|
||||
jsonObject.put("curve_xData", yearM);
|
||||
|
||||
List<ProAlarmBaseText> trueNumList = this.proAlarmBaseTextService.selectNumFromDateByWhere(unitId, " where decisionExpertBase_pid='" + pid + "' and adopt_st='" + ProAlarmBaseText.AdoptSt_True + "' and (insdt>='" + curveSdt + "' and insdt<'" + curveEdt + "') ", "7");
|
||||
List<ProAlarmBaseText> totalNumList = this.proAlarmBaseTextService.selectNumFromDateByWhere(unitId, " where decisionExpertBase_pid='" + pid + "' and (adopt_st='" + ProAlarmBaseText.AdoptSt_True + "' or adopt_st='" + ProAlarmBaseText.AdoptSt_False + "') and (insdt>='" + curveSdt + "' and insdt<'" + curveEdt + "') ", "7");
|
||||
|
||||
JSONArray trueNum_1_Json = new JSONArray();
|
||||
if (trueNumList != null && trueNumList.size() > 0) {
|
||||
for (ProAlarmBaseText proAlarmBaseText :
|
||||
trueNumList) {
|
||||
String[] dataValue = new String[2];
|
||||
dataValue[0] = proAlarmBaseText.get_date().substring(5, 7);
|
||||
dataValue[1] = proAlarmBaseText.getNum() + "";
|
||||
trueNum_1_Json.add(dataValue);
|
||||
}
|
||||
}
|
||||
jsonObject.put("trueNum_his", trueNum_1_Json);
|
||||
|
||||
JSONArray totalNum_1_Json = new JSONArray();
|
||||
if (totalNumList != null && totalNumList.size() > 0) {
|
||||
for (ProAlarmBaseText proAlarmBaseText :
|
||||
totalNumList) {
|
||||
String[] dataValue = new String[2];
|
||||
dataValue[0] = proAlarmBaseText.get_date().substring(5, 7);
|
||||
dataValue[1] = proAlarmBaseText.getNum() + "";
|
||||
totalNum_1_Json.add(dataValue);
|
||||
}
|
||||
}
|
||||
jsonObject.put("totalNum_his", totalNum_1_Json);
|
||||
|
||||
jsonArray.add(jsonObject);
|
||||
|
||||
model.addAttribute("result", jsonArray);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/getStatisticalDataForTH2.do")
|
||||
public String getStatisticalDataForTH2(HttpServletRequest request, Model model) {
|
||||
try {
|
||||
String unitId = request.getParameter("unitId");
|
||||
String date = request.getParameter("statisticalDate");
|
||||
String pid = request.getParameter("pid");
|
||||
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
|
||||
//决策信息
|
||||
List<ProAlarmBaseText> pTrueNumList = this.proAlarmBaseTextService.selectCountByWhere(unitId, " where decisionExpertBase_pid='" + pid + "' and adopt_st='" + ProAlarmBaseText.AdoptSt_True + "' and datediff(month,insdt,'" + date + "')=0");
|
||||
List<ProAlarmBaseText> pFalseNumList = this.proAlarmBaseTextService.selectCountByWhere(unitId, " where decisionExpertBase_pid='" + pid + "' and (adopt_st='" + ProAlarmBaseText.AdoptSt_False + "' or adopt_st is null) and datediff(month,insdt,'" + date + "')=0");
|
||||
|
||||
List<ProAlarmBaseText> pTrueNumList2 = this.proAlarmBaseTextService.selectListByWhere(unitId, " where decisionExpertBase_pid='" + pid + "' and adopt_st='" + ProAlarmBaseText.AdoptSt_True + "' and datediff(month,insdt,'" + date + "')=0 order by insdt desc");
|
||||
|
||||
int trueNum = 0;
|
||||
int falseNum = 0;
|
||||
|
||||
if (pTrueNumList != null && pTrueNumList.size() > 0) {
|
||||
trueNum = pTrueNumList.get(0).getNum();
|
||||
}
|
||||
|
||||
if (pTrueNumList2 != null && pTrueNumList2.size() > 0) {
|
||||
jsonObject.put("firstTrueContent", pTrueNumList2.get(0).getDecisionexpertbasetext());
|
||||
jsonObject.put("firstTrueTime", pTrueNumList2.get(0).getInsdt().substring(0, 16));
|
||||
} else {
|
||||
jsonObject.put("firstTrueContent", "-");
|
||||
jsonObject.put("firstTrueTime", "-");
|
||||
}
|
||||
|
||||
if (pFalseNumList != null && pFalseNumList.size() > 0) {
|
||||
falseNum = pFalseNumList.get(0).getNum();
|
||||
}
|
||||
|
||||
jsonObject.put("trueNum", trueNum);
|
||||
jsonObject.put("falseNum", falseNum);
|
||||
jsonObject.put("totalNum", trueNum + falseNum);
|
||||
|
||||
|
||||
jsonArray.add(jsonObject);
|
||||
|
||||
model.addAttribute("result", jsonArray);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/getBarData.do")
|
||||
public String getBarData(HttpServletRequest request, Model model) {
|
||||
String unitId = request.getParameter("unitId");
|
||||
String date = request.getParameter("statisticalDate");
|
||||
|
||||
List<ProAlarmBaseText> pTrueNumList = this.proAlarmBaseTextService.selectNumFromDateByWhere(unitId, " where adopt_st='" + ProAlarmBaseText.AdoptSt_True + "' and datediff(year,insdt,'" + date + "')=0 ", "7");
|
||||
List<ProAlarmBaseText> pTotalNumList = this.proAlarmBaseTextService.selectNumFromDateByWhere(unitId, " where datediff(year,insdt,'" + date + "')=0 ", "7");
|
||||
|
||||
JSONArray trueMainJsonArray = new JSONArray();
|
||||
for (ProAlarmBaseText pTrueNum :
|
||||
pTrueNumList) {
|
||||
JSONArray trueJsonArray = new JSONArray();
|
||||
trueJsonArray.add(pTrueNum.get_date().substring(5, 7));
|
||||
trueJsonArray.add(pTrueNum.getNum());
|
||||
trueMainJsonArray.add(trueJsonArray);
|
||||
}
|
||||
|
||||
JSONArray totalMainJsonArray = new JSONArray();
|
||||
for (ProAlarmBaseText pTotalNum :
|
||||
pTotalNumList) {
|
||||
JSONArray totalJsonArray = new JSONArray();
|
||||
totalJsonArray.add(pTotalNum.get_date().substring(5, 7));
|
||||
totalJsonArray.add(pTotalNum.getNum());
|
||||
totalMainJsonArray.add(totalJsonArray);
|
||||
}
|
||||
|
||||
JSONArray mainJsonArray = new JSONArray();
|
||||
|
||||
mainJsonArray.add(trueMainJsonArray);
|
||||
mainJsonArray.add(totalMainJsonArray);
|
||||
|
||||
model.addAttribute("result", mainJsonArray);
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
569
src/main/java/com/sipai/controller/alarm/ProAlarmController.java
Normal file
569
src/main/java/com/sipai/controller/alarm/ProAlarmController.java
Normal file
@ -0,0 +1,569 @@
|
||||
package com.sipai.controller.alarm;
|
||||
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.sipai.entity.alarm.*;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.data.XServer;
|
||||
import com.sipai.entity.scada.MPoint;
|
||||
import com.sipai.entity.user.Unit;
|
||||
import com.sipai.entity.work.CameraFile;
|
||||
import com.sipai.service.alarm.AlarmPointService;
|
||||
import com.sipai.service.alarm.AlarmSubscribeService;
|
||||
import com.sipai.service.data.XServerService;
|
||||
import com.sipai.service.scada.MPointService;
|
||||
import com.sipai.service.user.UserService;
|
||||
import com.sipai.service.work.CameraFileService;
|
||||
import com.sipai.tools.MinioProp;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.eclipse.paho.client.mqttv3.MqttClient;
|
||||
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.scada.ProAlarm;
|
||||
import com.sipai.entity.user.Company;
|
||||
import com.sipai.entity.user.ProcessSection;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.alarm.AlarmInformationService;
|
||||
import com.sipai.service.company.CompanyService;
|
||||
import com.sipai.service.msg.MsgService;
|
||||
import com.sipai.service.scada.ProAlarmService;
|
||||
import com.sipai.service.user.ProcessSectionService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
import com.sipai.tools.Mqtt;
|
||||
import com.sipai.tools.MqttUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/alarm/proAlarm")
|
||||
public class ProAlarmController {
|
||||
@Resource
|
||||
private ProAlarmService proAlarmService;
|
||||
@Resource
|
||||
private ProcessSectionService processSectionService;
|
||||
@Resource
|
||||
private CompanyService companyService;
|
||||
@Resource
|
||||
private MsgService msgService;
|
||||
@Resource
|
||||
private AlarmInformationService alarmInformationService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private XServerService xServerService;
|
||||
@Resource
|
||||
private AlarmSubscribeService alarmSubscribeService;
|
||||
@Resource
|
||||
private AlarmPointService alarmPointService;
|
||||
@Resource
|
||||
private CameraFileService cameraFileService;
|
||||
@Resource
|
||||
private MPointService mPointService;
|
||||
|
||||
@RequestMapping("/showlist.do")
|
||||
public String showlist(HttpServletRequest request, Model model) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
model.addAttribute("AlarmMoldCodeEnum", AlarmMoldCodeEnum.getJsonString2());
|
||||
model.addAttribute("AlarmLevelsCodeEnum", AlarmLevelsCodeEnum.getJsonString());
|
||||
model.addAttribute("userName", cu.getCaption());
|
||||
// proAlarmService.topAlarmNumC(request, "SK_FF_FT202_V_PV", ProAlarm.C_type_reduce);
|
||||
return "/alarm/proAlarmList";
|
||||
}
|
||||
|
||||
@RequestMapping("/doView.do")
|
||||
public String doView(HttpServletRequest request, Model model) {
|
||||
ProAlarm proAlarm = this.proAlarmService.selectById(request.getParameter("unitId"), request.getParameter("id"));
|
||||
if (proAlarm != null) {
|
||||
proAlarm.setAlarmTypeName(AlarmMoldCodeEnum.getName(proAlarm.getAlarmType()));
|
||||
proAlarm.setAlarmLevelName(AlarmLevelsCodeEnum.getName(proAlarm.getAlarmLevel()));
|
||||
User cuser = this.userService.getUserById(proAlarm.getConfirmerid());
|
||||
if (cuser != null) {
|
||||
proAlarm.setConfirmerName(cuser.getCaption());
|
||||
}
|
||||
|
||||
String diffTime = "";
|
||||
if (proAlarm.getAlarmTime() != null && proAlarm.getLastAlarmTime() != null) {
|
||||
String alarmTime = proAlarm.getAlarmTime();
|
||||
diffTime = CommUtil.getDiffTimeEndMin(proAlarm.getLastAlarmTime(), alarmTime);
|
||||
}
|
||||
proAlarm.setDuration(diffTime);
|
||||
|
||||
if (proAlarm.getAlarmTime() != null) {
|
||||
proAlarm.setAlarmTime(proAlarm.getAlarmTime().substring(0, 16));
|
||||
}
|
||||
if (proAlarm.getConfirmTime() != null) {
|
||||
proAlarm.setConfirmTime(proAlarm.getConfirmTime().substring(0, 16));
|
||||
}
|
||||
|
||||
MPoint mPoint = this.mPointService.selectById(request.getParameter("unitId"), proAlarm.getPointCode());
|
||||
if (mPoint != null) {
|
||||
proAlarm.setmPoint(mPoint);
|
||||
String describe = proAlarm.getDescribe();
|
||||
|
||||
String alarmLine = "";
|
||||
if (describe.indexOf("上限") > 0) {
|
||||
alarmLine = CommUtil.formatMPointValue(mPoint.getAlarmmax(), mPoint.getNumtail(), mPoint.getRate()).toPlainString();
|
||||
} else if (describe.indexOf("上极限") > 0) {
|
||||
alarmLine = CommUtil.formatMPointValue(mPoint.getHalarmmax(), mPoint.getNumtail(), mPoint.getRate()).toPlainString();
|
||||
} else if (describe.indexOf("下限") > 0) {
|
||||
alarmLine = CommUtil.formatMPointValue(mPoint.getAlarmmin(), mPoint.getNumtail(), mPoint.getRate()).toPlainString();
|
||||
} else if (describe.indexOf("下极限") > 0) {
|
||||
alarmLine = CommUtil.formatMPointValue(mPoint.getLalarmmin(), mPoint.getNumtail(), mPoint.getRate()).toPlainString();
|
||||
}
|
||||
|
||||
proAlarm.setAlarmLine(alarmLine);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
model.addAttribute("proAlarm", proAlarm);
|
||||
return "/alarm/proAlarmView";
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/getlist.do")
|
||||
public ModelAndView getlist(HttpServletRequest request, Model model) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String companyId = request.getParameter("companyId");
|
||||
String sort = " alarm_time ";
|
||||
String order = " desc ";
|
||||
String orderstr = " order by " + sort + " " + order;
|
||||
|
||||
String wherestr = " where 1=1 ";
|
||||
if (request.getParameter("sdt") != null && !request.getParameter("sdt").isEmpty()) {
|
||||
wherestr += " and alarm_time >= '" + request.getParameter("sdt") + "' ";
|
||||
}
|
||||
if (request.getParameter("edt") != null && !request.getParameter("edt").isEmpty()) {
|
||||
wherestr += " and alarm_time <= '" + request.getParameter("edt") + "' ";
|
||||
}
|
||||
if (request.getParameter("alarmlevel") != null && !request.getParameter("alarmlevel").isEmpty()) {
|
||||
wherestr += " and alarm_level = '" + request.getParameter("alarmlevel") + "' ";
|
||||
}
|
||||
if (request.getParameter("search_name") != null && !request.getParameter("search_name").isEmpty()) {
|
||||
wherestr += " and (describe like '%" + request.getParameter("search_name") + "%' or point_name like '%" + request.getParameter("search_name") + "%' or point_code like '%" + request.getParameter("search_name") + "%') ";
|
||||
}
|
||||
if (request.getParameter("point_code") != null && !request.getParameter("point_code").isEmpty()) {
|
||||
wherestr += " and point_code ='" + request.getParameter("point_code") + "' ";
|
||||
}
|
||||
if (request.getParameter("pSectionCode") != null && !request.getParameter("pSectionCode").isEmpty()) {
|
||||
wherestr += " and process_section_code = '" + request.getParameter("pSectionCode") + "' ";
|
||||
}
|
||||
if (request.getParameter("alarmType") != null && !request.getParameter("alarmType").isEmpty()) {
|
||||
wherestr += " and alarm_type = '" + request.getParameter("alarmType") + "' ";
|
||||
}
|
||||
if (request.getParameter("status") != null && !request.getParameter("status").isEmpty()) {
|
||||
wherestr += " and status = '" + request.getParameter("status") + "' ";
|
||||
}
|
||||
|
||||
//获取当前人所属点
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
//// String points = "";
|
||||
// List<AlarmSubscribe> slist = this.alarmSubscribeService.selectListByWhere(" where userid like '%" + cu.getId() + "%' ");
|
||||
// for (AlarmSubscribe alarmSubscribe :
|
||||
// slist) {
|
||||
// String alarm_point_id = alarmSubscribe.getAlarmPointId();
|
||||
// AlarmPoint alarmPoint = this.alarmPointService.selectById(alarm_point_id);
|
||||
// if (alarmPoint != null) {
|
||||
// if (alarmPoint.getAlarmPoint() != null) {
|
||||
// if (jsonObject.get(alarmPoint.getUnitId()) == null) {
|
||||
// jsonObject.put(alarmPoint.getUnitId(), alarmPoint.getAlarmPoint());
|
||||
// } else {
|
||||
// jsonObject.put(alarmPoint.getUnitId(), jsonObject.get(alarmPoint.getUnitId()) + "," + alarmPoint.getAlarmPoint());
|
||||
// }
|
||||
//// points += alarmPoint.getAlarmPoint() + ",";
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// List<AlarmInformation> ilist = this.alarmInformationService.selectListByWhere2(" where alarm_receivers like '%" + cu.getId() + "%' ");
|
||||
// for (AlarmInformation alarmInformation :
|
||||
// ilist) {
|
||||
// String code = alarmInformation.getCode();
|
||||
// List<AlarmPoint> plist = this.alarmPointService.selectListByWhere2(" where information_code='" + code + "' and unit_id='" + alarmInformation.getUnitId() + "' ");
|
||||
// if (plist != null && plist.size() > 0) {
|
||||
// for (AlarmPoint alarmPoint :
|
||||
// plist) {
|
||||
// if (alarmPoint.getAlarmPoint() != null) {
|
||||
// if (jsonObject.get(alarmPoint.getUnitId()) == null) {
|
||||
// jsonObject.put(alarmPoint.getUnitId(), alarmPoint.getAlarmPoint());
|
||||
// } else {
|
||||
// jsonObject.put(alarmPoint.getUnitId(), jsonObject.get(alarmPoint.getUnitId()) + "," + alarmPoint.getAlarmPoint());
|
||||
// }
|
||||
//// points += alarmPoint.getAlarmPoint() + ",";
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// Iterator<String> sIterator = jsonObject.keys();
|
||||
|
||||
JSONArray arr = new JSONArray();
|
||||
List<XServer> allxServerList = this.xServerService.selectListByWhere(" where 1=1 ");
|
||||
for (XServer xServer :
|
||||
allxServerList) {
|
||||
// if (jsonObject.get(xServer.getBizid()) != null) {
|
||||
// String code_value = jsonObject.get(xServer.getBizid()).toString();
|
||||
// code_value = code_value + ",data_stop_alarm";
|
||||
// code_value = code_value.replace(",", "','");
|
||||
// List<ProAlarm> list = this.proAlarmService.selectListByWhere(xServer.getBizid(), wherestr + " and point_code in ('" + code_value + "')"
|
||||
// + orderstr);
|
||||
List<ProAlarm> list = this.proAlarmService.selectListByWhere(xServer.getBizid(), wherestr + orderstr);
|
||||
// System.out.println(wherestr + " and point_code in ('" + code_value + "')");
|
||||
if (list != null && list.size() > 0) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
User cuser = this.userService.getUserById(list.get(i).getConfirmerid());
|
||||
if (cuser != null) {
|
||||
list.get(i).setConfirmerName(cuser.getCaption());
|
||||
}
|
||||
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("id", list.get(i).getId());
|
||||
obj.put("pointCode", list.get(i).getPointCode());
|
||||
obj.put("pointName", list.get(i).getPointName());
|
||||
obj.put("alarmTime", list.get(i).getAlarmTime());
|
||||
obj.put("describe", list.get(i).getDescribe());
|
||||
obj.put("confirmerName", list.get(i).getConfirmerName());
|
||||
obj.put("confirmTime", list.get(i).getConfirmTime());
|
||||
obj.put("alarmTypeName", list.get(i).getAlarmTypeName());
|
||||
obj.put("status", list.get(i).getStatus());
|
||||
obj.put("bizId", list.get(i).getBizId());
|
||||
obj.put("alarmType", list.get(i).getAlarmType());
|
||||
obj.put("processSectionCode", list.get(i).getProcessSectionCode());
|
||||
obj.put("confirmContent", list.get(i).getConfirmContent());
|
||||
obj.put("alarmLevel", list.get(i).getAlarmLevel());
|
||||
|
||||
List<CameraFile> cameraFilelist = this.cameraFileService.selectListByWhere(" where pointId='" + list.get(i).getId() + "' ");
|
||||
if (cameraFilelist != null && cameraFilelist.size() > 0) {
|
||||
obj.put("cameraFileSt", "true");
|
||||
String cameraIds = "";
|
||||
for (CameraFile cameraFile :
|
||||
cameraFilelist) {
|
||||
cameraIds += cameraFile.getMasterid() + ",";
|
||||
}
|
||||
obj.put("cameraIds", cameraIds);
|
||||
} else {
|
||||
obj.put("cameraFileSt", "false");
|
||||
}
|
||||
|
||||
arr.add(obj);
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
model.addAttribute("result", arr);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/getAlarmJson.do")
|
||||
public ModelAndView getAlarmJson(HttpServletRequest request, Model model) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String companyId = request.getParameter("companyId");
|
||||
|
||||
String orderstr = " order by alarm_time desc";
|
||||
|
||||
String wherestr = "where 1=1 and (status='" + ProAlarm.STATUS_ALARM + "' or status='" + ProAlarm.STATUS_ALARM_CONFIRM + "') ";
|
||||
|
||||
List<ProAlarm> list = this.proAlarmService.selectListByWhere(companyId, wherestr + orderstr);
|
||||
|
||||
JSONArray jsondata = new JSONArray();
|
||||
if (list != null && list.size() > 0) {
|
||||
for (ProAlarm proAlarm : list) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("mpcode", proAlarm.getPointCode());
|
||||
jsonObject.put("mpname", proAlarm.getPointName());
|
||||
jsonObject.put("alarmTime", proAlarm.getAlarmTime());
|
||||
jsonObject.put("describe", proAlarm.getDescribe());
|
||||
if (proAlarm.getAlarmType().equals(AlarmMoldCodeEnum.LimitValue_Pro.getKey())) {
|
||||
jsonObject.put("alarmTypeLv1", "超限报警");
|
||||
} else if (proAlarm.getAlarmType().equals(AlarmMoldCodeEnum.EquAbnormal_Pro.getKey())) {
|
||||
jsonObject.put("alarmTypeLv1", "设备故障");
|
||||
}
|
||||
if (proAlarm.getProcessSectionCode() != null && !proAlarm.getProcessSectionCode().equals("")) {
|
||||
ProcessSection processSection = this.processSectionService.selectById(proAlarm.getProcessSectionCode());
|
||||
if (processSection != null) {
|
||||
jsonObject.put("processSectionCode", processSection.getCode());
|
||||
} else {
|
||||
jsonObject.put("processSectionCode", "-");
|
||||
}
|
||||
} else {
|
||||
jsonObject.put("processSectionCode", "-");
|
||||
}
|
||||
|
||||
jsondata.add(jsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
model.addAttribute("result", jsondata);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/getUrgentButton.do")
|
||||
public ModelAndView getUrgentButton(HttpServletRequest request, Model model) {
|
||||
String status = request.getParameter("status");//0报警 2恢复
|
||||
// String alarmTime = request.getParameter("alarmTime");//报警时间 and恢复时间
|
||||
String alarmTime = CommUtil.nowDate();
|
||||
// String describe = request.getParameter("describe");//报警描述
|
||||
String pointName = request.getParameter("pointName");//报警名称
|
||||
String companyEname = request.getParameter("companyEname");//厂ename
|
||||
|
||||
String describe = pointName + "于" + alarmTime.substring(0, 16) + "发生紧急报警。";//报警描述
|
||||
|
||||
List<Company> companyList = this.companyService.selectListByWhere(" where ename='" + companyEname + "' ");
|
||||
if (companyList != null && companyList.size() > 0) {
|
||||
String unitId = companyList.get(0).getId();
|
||||
|
||||
ProAlarm proAlarm = new ProAlarm();
|
||||
if (status.equals("0")) {
|
||||
List<AlarmInformation> alarmInformationList = this.alarmInformationService.selectListByWhere(" where mold_code='Urgent_Button' and unit_id='" + unitId + "' ");
|
||||
if (alarmInformationList != null && alarmInformationList.size() > 0) {
|
||||
String alarmReceivers = alarmInformationList.get(0).getAlarmReceivers();
|
||||
proAlarm.setId(CommUtil.getUUID());
|
||||
proAlarm.setInsdt(alarmTime);
|
||||
proAlarm.setAlarmTime(alarmTime);
|
||||
proAlarm.setStatus(ProAlarm.STATUS_ALARM);
|
||||
proAlarm.setBizId(unitId);
|
||||
proAlarm.setPointName(pointName);
|
||||
proAlarm.setDescribe(describe);
|
||||
proAlarm.setAlarmLevel(alarmInformationList.get(0).getLevelCode());
|
||||
proAlarm.setAlarmType("Urgent_Button");
|
||||
int inCode = this.proAlarmService.save(unitId, proAlarm);
|
||||
if (inCode == 1) {
|
||||
if (alarmReceivers != null && !alarmReceivers.equals("")) {
|
||||
String result = this.msgService.sendNewsFromAlarm(AlarmInformationAlarmModeEnum.message.getKey(), "emp01", describe, "ALARM", alarmReceivers);
|
||||
com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
|
||||
jsonObject.put("title", "紧急报警");
|
||||
jsonObject.put("content", describe);
|
||||
|
||||
String[] alarmReceiver = alarmReceivers.split(",");
|
||||
for (String receiver : alarmReceiver) {
|
||||
//发布mqtt
|
||||
MqttUtil.publish(jsonObject, receiver);
|
||||
}
|
||||
}
|
||||
model.addAttribute("result", "执行成功");
|
||||
} else {
|
||||
model.addAttribute("result", "执行出错");
|
||||
}
|
||||
} else {
|
||||
model.addAttribute("result", "无配置项");
|
||||
}
|
||||
|
||||
} else if (status.equals("2")) {
|
||||
int inCode = this.proAlarmService.recoverAlarmByWhere(unitId, " where (status='" + ProAlarm.STATUS_ALARM + "' or status='" + ProAlarm.STATUS_ALARM_CONFIRM + "') and point_name='" + pointName + "' ", alarmTime, "2");
|
||||
if (inCode == 1) {
|
||||
model.addAttribute("result", "紧急报警恢复");
|
||||
} else {
|
||||
model.addAttribute("result", "执行出错");
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
model.addAttribute("result", "无所属厂");
|
||||
}
|
||||
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/alarmConfirm.do")
|
||||
public ModelAndView alarmConfirm(HttpServletRequest request, Model model) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
|
||||
String bizid = request.getParameter("bizid");
|
||||
String pointCode = request.getParameter("pointCode");
|
||||
String alarmTime = request.getParameter("alarmTime");
|
||||
String confirmContent = request.getParameter("confirmContent");
|
||||
|
||||
List<ProAlarm> list = this.proAlarmService.selectListByWhere(bizid, " where point_code='" + pointCode + "' and alarm_time='" + alarmTime + "' ");
|
||||
|
||||
Result result = new Result();
|
||||
if (list != null && list.size() > 0) {
|
||||
for (ProAlarm proAlarm :
|
||||
list) {
|
||||
// ProAlarm proAlarm = list.get(0);
|
||||
proAlarm.setConfirmerid(cu.getId());
|
||||
proAlarm.setConfirmTime(CommUtil.nowDate());
|
||||
proAlarm.setStatus(ProAlarm.STATUS_ALARM_CONFIRM);
|
||||
proAlarm.setConfirmContent(confirmContent);
|
||||
|
||||
int code = this.proAlarmService.update(bizid, proAlarm);
|
||||
|
||||
if (code == Result.SUCCESS) {
|
||||
//报警数量-1
|
||||
this.proAlarmService.topAlarmNumC(request, proAlarm.getPointCode(), ProAlarm.C_type_reduce);
|
||||
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("操作失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/getPersonalAlarmNum.do")
|
||||
public ModelAndView getPersonalAlarmNum(HttpServletRequest request, Model model) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String userId = cu.getId();
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
String edt = CommUtil.nowDate().substring(0, 10) + " 23:59";
|
||||
String sdt = CommUtil.subplus(edt, "-30", "day").substring(0, 10) + " 00:00";
|
||||
|
||||
// String points = "";
|
||||
List<AlarmSubscribe> slist = this.alarmSubscribeService.selectListByWhere(" where userid like '%" + userId + "%' ");
|
||||
for (AlarmSubscribe alarmSubscribe :
|
||||
slist) {
|
||||
String alarm_point_id = alarmSubscribe.getAlarmPointId();
|
||||
AlarmPoint alarmPoint = this.alarmPointService.selectById(alarm_point_id);
|
||||
if (alarmPoint != null) {
|
||||
if (alarmPoint.getAlarmPoint() != null) {
|
||||
if (jsonObject.get(alarmPoint.getUnitId()) == null) {
|
||||
jsonObject.put(alarmPoint.getUnitId(), alarmPoint.getAlarmPoint());
|
||||
} else {
|
||||
jsonObject.put(alarmPoint.getUnitId(), jsonObject.get(alarmPoint.getUnitId()) + "," + alarmPoint.getAlarmPoint());
|
||||
}
|
||||
// points += alarmPoint.getAlarmPoint() + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<AlarmInformation> ilist = this.alarmInformationService.selectListByWhere2(" where alarm_receivers like '%" + userId + "%' ");
|
||||
for (AlarmInformation alarmInformation :
|
||||
ilist) {
|
||||
String code = alarmInformation.getCode();
|
||||
List<AlarmPoint> plist = this.alarmPointService.selectListByWhere2(" where information_code='" + code + "' and unit_id='" + alarmInformation.getUnitId() + "' ");
|
||||
if (plist != null && plist.size() > 0) {
|
||||
for (AlarmPoint alarmPoint :
|
||||
plist) {
|
||||
if (alarmPoint.getAlarmPoint() != null) {
|
||||
if (jsonObject.get(alarmPoint.getUnitId()) == null) {
|
||||
jsonObject.put(alarmPoint.getUnitId(), alarmPoint.getAlarmPoint());
|
||||
} else {
|
||||
jsonObject.put(alarmPoint.getUnitId(), jsonObject.get(alarmPoint.getUnitId()) + "," + alarmPoint.getAlarmPoint());
|
||||
}
|
||||
// points += alarmPoint.getAlarmPoint() + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int totalAlarmNum = 0;
|
||||
|
||||
Iterator<String> sIterator = jsonObject.keys();
|
||||
while (sIterator.hasNext()) {
|
||||
String key = sIterator.next();
|
||||
String value = jsonObject.getString(key);
|
||||
value = value + ",data_stop_alarm";
|
||||
value = value.replace(",", "','");
|
||||
|
||||
List<ProAlarm> proAlarmList = this.proAlarmService.selectCountByWhere(key, " where point_code in ('" + value + "') and status='" + ProAlarm.STATUS_ALARM + "' and alarm_time >= '" + sdt + "' and alarm_time <= '" + edt + "' ");
|
||||
if (proAlarmList != null && proAlarmList.size() > 0) {
|
||||
totalAlarmNum += proAlarmList.get(0).getNum();
|
||||
}
|
||||
}
|
||||
|
||||
model.addAttribute("result", totalAlarmNum);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/getAlarmNum.do")
|
||||
public ModelAndView getAlarmNum(HttpServletRequest request, Model model) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
|
||||
String unitId = request.getParameter("unitId");
|
||||
String sdt = request.getParameter("sdt");
|
||||
String edt = request.getParameter("edt");
|
||||
|
||||
String wherestr = "where 1=1 and (status='" + ProAlarm.STATUS_ALARM + "' or status='" + ProAlarm.STATUS_ALARM_CONFIRM + "') and alarm_time >= '" + sdt + "' and alarm_time <= '" + edt + "' ";
|
||||
|
||||
List<ProAlarm> proAlarmNum = this.proAlarmService.selectCountByWhere(unitId, wherestr);
|
||||
|
||||
int totalAlarmNum = 0;
|
||||
if (proAlarmNum != null && proAlarmNum.size() > 0) {
|
||||
totalAlarmNum = proAlarmNum.get(0).getNum();
|
||||
}
|
||||
|
||||
model.addAttribute("result", totalAlarmNum);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/getAlarmYearHis.do")
|
||||
public ModelAndView getAlarmYearHis(HttpServletRequest request, Model model) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
|
||||
String unitId = request.getParameter("unitId");
|
||||
String sdt = CommUtil.nowDate().substring(0, 4) + "-01-01 00:00";
|
||||
String edt = CommUtil.nowDate().substring(0, 4) + "-12-31 23:59";
|
||||
|
||||
String wherestr = "where 1=1 and (status='" + ProAlarm.STATUS_ALARM + "' or status='" + ProAlarm.STATUS_ALARM_CONFIRM + "') and alarm_time >= '" + sdt + "' and alarm_time <= '" + edt + "' ";
|
||||
|
||||
List<ProAlarm> proAlarmNum = this.proAlarmService.selectNumFromDateByWhere(unitId, wherestr, "7");
|
||||
|
||||
if (proAlarmNum != null && proAlarmNum.size() > 0) {
|
||||
for (int i = 1; i < 13; i++) {
|
||||
String month = String.valueOf(i);
|
||||
if (month.length() == 1) {
|
||||
month = "0" + month;
|
||||
}
|
||||
|
||||
Boolean in = false;
|
||||
for (int j = 0; j < proAlarmNum.size(); j++) {
|
||||
if (month.equals(proAlarmNum.get(j).get_date().substring(5, 7))) {
|
||||
in = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(in){
|
||||
|
||||
}else{
|
||||
ProAlarm p = new ProAlarm();
|
||||
p.setNum(0);
|
||||
p.set_date(CommUtil.nowDate().substring(0, 4)+"-"+month);
|
||||
proAlarmNum.add(p);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
model.addAttribute("result", CommUtil.toJson(proAlarmNum));
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/getAlarmTopData.do")
|
||||
public ModelAndView getAlarmTopData(HttpServletRequest request, Model model) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
|
||||
String unitId = request.getParameter("unitId");
|
||||
String sdt = request.getParameter("sdt");
|
||||
String edt = request.getParameter("edt");
|
||||
String topNum = request.getParameter("topNum");
|
||||
|
||||
String wherestr = "where 1=1 and (status='" + ProAlarm.STATUS_ALARM + "' or status='" + ProAlarm.STATUS_ALARM_CONFIRM + "') and alarm_time >= '" + sdt + "' and alarm_time <= '" + edt + "' ";
|
||||
|
||||
List<ProAlarm> proAlarmNum = this.proAlarmService.selectTopNumListByWhere(unitId, wherestr, "4");
|
||||
|
||||
|
||||
model.addAttribute("result", CommUtil.toJson(proAlarmNum));
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
package com.sipai.controller.alarm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.scada.ProAlarmDataStopHisPoint;
|
||||
import com.sipai.service.scada.ProAlarmDataStopHisPointService;
|
||||
import net.sf.json.JSONArray;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/alarm/proAlarmDataStopHisPoint")
|
||||
public class ProAlarmDataStopHisPointController {
|
||||
@Resource
|
||||
private ProAlarmDataStopHisPointService proAlarmDataStopHisPointService;
|
||||
|
||||
@RequestMapping("/showList.do")
|
||||
public String showProAlarmDataStopHisPointEdit(HttpServletRequest request,Model model){
|
||||
|
||||
return "alarm/proAlarmDataStopHisPointList";
|
||||
}
|
||||
|
||||
@RequestMapping("/getList.do")
|
||||
public ModelAndView getList(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "unitId") String unitId,
|
||||
@RequestParam(value = "alarmId") String alarmId,
|
||||
@RequestParam(value = "sort", required=false) String sort,
|
||||
@RequestParam(value = "order", required=false) String order) {
|
||||
//User cu=(User)request.getSession().getAttribute("cu");
|
||||
if(sort==null){
|
||||
sort = " code ";
|
||||
}
|
||||
if(order==null){
|
||||
order = " asc ";
|
||||
}
|
||||
String orderstr=" order by "+sort+" "+order;
|
||||
|
||||
String wherestr="where 1=1 and alarm_id='"+alarmId+"' ";
|
||||
System.out.println(wherestr);
|
||||
|
||||
PageHelper.startPage(page, rows);
|
||||
List<ProAlarmDataStopHisPoint> list = this.proAlarmDataStopHisPointService.selectListByWhere(unitId,wherestr+orderstr);
|
||||
|
||||
PageInfo<ProAlarmDataStopHisPoint> pi = new PageInfo<ProAlarmDataStopHisPoint>(list);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
|
||||
String result="{\"total\":"+pi.getTotal()+",\"rows\":"+json+"}";
|
||||
// System.out.println(result);
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
}
|
||||
102
src/main/java/com/sipai/controller/alarm/RiskPController.java
Normal file
102
src/main/java/com/sipai/controller/alarm/RiskPController.java
Normal file
@ -0,0 +1,102 @@
|
||||
package com.sipai.controller.alarm;
|
||||
|
||||
import com.sipai.entity.alarm.AlarmLevelsConfig;
|
||||
import com.sipai.entity.alarm.RiskP;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.hqconfig.RiskLevel;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.alarm.AlarmLevesConfigService;
|
||||
import com.sipai.service.alarm.RiskPService;
|
||||
import com.sipai.service.hqconfig.RiskLevelService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
import net.sf.json.JSONArray;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("alarm/riskP")
|
||||
public class RiskPController {
|
||||
@Resource
|
||||
private RiskPService riskPService;
|
||||
@Resource
|
||||
private RiskLevelService riskLevelService;
|
||||
|
||||
@RequestMapping("/getList.do")
|
||||
public String getList(HttpServletRequest request,Model model){
|
||||
String pid = request.getParameter("pid");
|
||||
List<RiskP> list = this.riskPService.selectListByWhere("where pid = '" + pid + "'");
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
RiskLevel riskLevel = riskLevelService.selectById(list.get(i).getrId());
|
||||
list.get(i).setRiskLevel(riskLevel);
|
||||
}
|
||||
JSONArray json= JSONArray.fromObject(list);
|
||||
String result="{\"rows\":"+json+"}";
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doSave.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute RiskP riskP){
|
||||
String id = CommUtil.getUUID();
|
||||
int result = this.riskPService.save(riskP);
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+id+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doUpdate.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute RiskP riskP){
|
||||
int code = this.riskPService.update(riskP);
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("更新失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/dodel.do")
|
||||
public String dodel(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id){
|
||||
Result result = new Result();
|
||||
int code = this.riskPService.deleteById(id);
|
||||
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("删除失败");
|
||||
}
|
||||
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodelByPid.do")
|
||||
public String dodelByPid(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="pid") String pid){
|
||||
Result result = new Result();
|
||||
int code = this.riskPService.deleteByWhere(pid);
|
||||
if (code > 0) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("删除失败");
|
||||
}
|
||||
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
package com.sipai.controller.app;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import com.sipai.entity.app.AppDataConfigure;
|
||||
import com.sipai.entity.scada.MPoint;
|
||||
import com.sipai.entity.scada.MPointHistory;
|
||||
import com.sipai.entity.visual.CacheData;
|
||||
import com.sipai.service.app.AppDataConfigureService;
|
||||
import com.sipai.service.scada.MPointHistoryService;
|
||||
import com.sipai.service.scada.MPointService;
|
||||
import com.sipai.service.visual.CacheDataService;
|
||||
import com.sipai.webservice.server.work.getSSOldOPMDataServer;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/app/appEquipmentData")
|
||||
public class AppEquipmentDataController {
|
||||
@Resource
|
||||
private CacheDataService cacheDataService;
|
||||
@Resource
|
||||
private MPointHistoryService mPointHistoryService;
|
||||
@Resource
|
||||
private MPointService mPointService;
|
||||
@Resource
|
||||
private AppDataConfigureService appDataConfigureService;
|
||||
|
||||
@RequestMapping("getdataForSS.do")
|
||||
public String getdataForSS(HttpServletRequest request,Model model){
|
||||
String unitId=request.getParameter("bizid");
|
||||
String type=request.getParameter("type");
|
||||
|
||||
com.alibaba.fastjson.JSONObject jsonObject=new com.alibaba.fastjson.JSONObject();
|
||||
List<AppDataConfigure> cList=this.appDataConfigureService.selectListByCacheData(" where ac.unitId='"+unitId+"' and ac.type='"+type+"' and ac.datatype='"+AppDataConfigure.type_newData+"' order by ac.morder ");
|
||||
if(cList!=null&&cList.size()>0){
|
||||
for(int i=0;i<cList.size();i++){
|
||||
if(cList.get(i).getActive()!=null){
|
||||
if (cList.get(i).getActive().equals(CacheData.Active_true)) {
|
||||
if(cList.get(i).getValue()!=null&&!cList.get(i).getValue().equals("")){
|
||||
jsonObject.put(cList.get(i).getShowname(), new BigDecimal(Double.toString(cList.get(i).getValue())));
|
||||
}else{
|
||||
jsonObject.put(cList.get(i).getShowname(), "");
|
||||
}
|
||||
}else{
|
||||
if(cList.get(i).getInivalue()!=null&&!cList.get(i).getInivalue().equals("")){
|
||||
jsonObject.put(cList.get(i).getShowname(), new BigDecimal(Double.toString(cList.get(i).getInivalue())));
|
||||
}else{
|
||||
jsonObject.put(cList.get(i).getShowname(), "");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
jsonObject.put(cList.get(i).getShowname(), "");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
List<AppDataConfigure> hList=this.appDataConfigureService.selectListByCacheData(" where ac.unitId='"+unitId+"' and ac.type='"+type+"' and ac.datatype='"+AppDataConfigure.type_hisData+"' order by ac.morder ");
|
||||
if(hList!=null&&hList.size()>0){
|
||||
for(int i=0;i<hList.size();i++){
|
||||
String mpid=hList.get(i).getMpcode();
|
||||
List<MPointHistory> mList=this.mPointHistoryService.selectListByTableAWhere(unitId, "tb_mp_"+mpid, " order by MeasureDT ");
|
||||
|
||||
JSONArray mjsondata=new JSONArray();
|
||||
if(mList!=null&&mList.size()>0){
|
||||
for(int m=0;m<mList.size();m++){
|
||||
String[] dataValue=new String[2];
|
||||
dataValue[0]=mList.get(m).getMeasuredt().substring(0, 10);
|
||||
dataValue[1]=String.valueOf(mList.get(m).getParmvalue());
|
||||
mjsondata.add(dataValue);
|
||||
}
|
||||
}
|
||||
jsonObject.put(hList.get(i).getShowname(), mjsondata);
|
||||
}
|
||||
}
|
||||
|
||||
model.addAttribute("result", jsonObject);
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,271 @@
|
||||
package com.sipai.controller.app;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import com.sipai.entity.app.AppDataConfigure;
|
||||
import com.sipai.entity.app.AppHomePageData;
|
||||
import com.sipai.entity.data.CurveMpoint;
|
||||
import com.sipai.entity.scada.MPoint;
|
||||
import com.sipai.entity.scada.MPointHistory;
|
||||
import com.sipai.entity.user.Company;
|
||||
import com.sipai.entity.user.Unit;
|
||||
import com.sipai.entity.visual.CacheData;
|
||||
import com.sipai.service.app.AppDataConfigureService;
|
||||
import com.sipai.service.app.AppHomePageDataService;
|
||||
import com.sipai.service.scada.MPointHistoryService;
|
||||
import com.sipai.service.scada.MPointService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.service.visual.CacheDataService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
import com.sipai.webservice.server.work.getSSOldOPMDataServer;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/app/appHomePageData")
|
||||
public class AppHomePageDataController {
|
||||
@Resource
|
||||
private AppHomePageDataService appHomePageDataService;
|
||||
@Resource
|
||||
private CacheDataService cacheDataService;
|
||||
@Resource
|
||||
private MPointHistoryService mPointHistoryService;
|
||||
@Resource
|
||||
private AppDataConfigureService appDataConfigureService;
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
@Resource
|
||||
private MPointService mPointService;
|
||||
|
||||
@RequestMapping("getdata.do")
|
||||
public String getdata(HttpServletRequest request,Model model){
|
||||
com.alibaba.fastjson.JSONObject object=new com.alibaba.fastjson.JSONObject();
|
||||
List<AppHomePageData> list = this.appHomePageDataService.selectListByWhere(" where 1=1 ");
|
||||
if(list!=null&&list.size()>0){
|
||||
object.put("todayyearwater", list.get(0).getTodayyearwater());
|
||||
object.put("onlinewater", list.get(0).getOnlinewater());
|
||||
object.put("waterquantity", list.get(0).getWaterquantity());
|
||||
object.put("waterrate", list.get(0).getWaterrate());
|
||||
object.put("mudvolume", list.get(0).getMudvolume());
|
||||
object.put("mudrate", list.get(0).getMudrate());
|
||||
object.put("totaleqnum", list.get(0).getTotaleqnum());
|
||||
object.put("usingeqnum", list.get(0).getUsingeqnum());
|
||||
object.put("aeq", list.get(0).getAeq());
|
||||
object.put("beq", list.get(0).getBeq());
|
||||
object.put("ceq", list.get(0).getCeq());
|
||||
object.put("eqrate", list.get(0).getEqrate());
|
||||
object.put("overhaulrate", list.get(0).getOverhaulrate());
|
||||
object.put("maintainrate", list.get(0).getMaintainrate());
|
||||
object.put("abnormalnum", list.get(0).getAbnormalnum());
|
||||
object.put("abnormaladdnum", list.get(0).getAbnormaladdnum());
|
||||
object.put("workingabnormalnum", list.get(0).getWorkingabnormalnum());
|
||||
object.put("eqabnormalnum", list.get(0).getEqabnormalnum());
|
||||
object.put("insdt", list.get(0).getInsdt());
|
||||
}
|
||||
|
||||
model.addAttribute("result", object);
|
||||
return "result";
|
||||
}
|
||||
|
||||
// @RequestMapping("getdataForSS.do")
|
||||
// public String getdataForSS(HttpServletRequest request,Model model){
|
||||
// String unitId=request.getParameter("bizid");
|
||||
//
|
||||
// JSONArray jsondata=new JSONArray();
|
||||
// com.alibaba.fastjson.JSONObject jsonObject=new com.alibaba.fastjson.JSONObject();
|
||||
// List<CacheData> cList=this.cacheDataService.selectListByWhere(" where unitId='"+unitId+"' and type='"+CacheData.Type_App_1+"' order by morder ");
|
||||
// if(cList!=null&&cList.size()>0){
|
||||
// for(int i=0;i<cList.size();i++){
|
||||
//
|
||||
// if (cList.get(i).getActive().equals(CacheData.Active_true)) {
|
||||
// if(cList.get(i).getValue()!=null&&!cList.get(i).getValue().equals("")){
|
||||
// jsonObject.put(cList.get(i).getDataname(), new BigDecimal(Double.toString(cList.get(i).getValue())));
|
||||
// }else{
|
||||
// jsonObject.put(cList.get(i).getDataname(), "");
|
||||
// }
|
||||
// }else{
|
||||
// if(cList.get(i).getInivalue()!=null&&!cList.get(i).getInivalue().equals("")){
|
||||
// jsonObject.put(cList.get(i).getDataname(), new BigDecimal(Double.toString(cList.get(i).getInivalue())));
|
||||
// }else{
|
||||
// jsonObject.put(cList.get(i).getDataname(), "");
|
||||
// }
|
||||
// }
|
||||
//// jsonObject.put("text", cList.get(i).getDataname());
|
||||
//// jsondata.add(jsonObject);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// List<CacheData> hList=this.cacheDataService.selectListByWhere(" where unitId='"+unitId+"' and type='"+CacheData.Type_App_2+"' order by morder ");
|
||||
// if(hList!=null&&hList.size()>0){
|
||||
// for(int i=0;i<hList.size();i++){
|
||||
//// com.alibaba.fastjson.JSONObject jsonObject=new com.alibaba.fastjson.JSONObject();
|
||||
// String mpid=hList.get(i).getMpcode();
|
||||
// List<MPointHistory> mList=this.mPointHistoryService.selectListByTableAWhere(unitId, "tb_mp_"+mpid, " order by MeasureDT ");
|
||||
//
|
||||
// JSONArray mjsondata=new JSONArray();
|
||||
// if(mList!=null&&mList.size()>0){
|
||||
// for(int m=0;m<mList.size();m++){
|
||||
// String[] dataValue=new String[2];
|
||||
// dataValue[0]=mList.get(m).getMeasuredt().substring(0, 10);
|
||||
// dataValue[1]=String.valueOf(mList.get(m).getParmvalue().doubleValue());
|
||||
// mjsondata.add(dataValue);
|
||||
// }
|
||||
// }
|
||||
// jsonObject.put(hList.get(i).getDataname(), mjsondata);
|
||||
//// jsonObject.put("text", hList.get(i).getDataname());
|
||||
//
|
||||
//// jsondata.add(jsonObject);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// model.addAttribute("result", jsonObject);
|
||||
// return "result";
|
||||
// }
|
||||
|
||||
@RequestMapping("getdataForSS.do")
|
||||
public String getdataForSS(HttpServletRequest request,Model model){
|
||||
String unitId=request.getParameter("bizid");
|
||||
String type=request.getParameter("type");
|
||||
|
||||
com.alibaba.fastjson.JSONObject jsonObject=new com.alibaba.fastjson.JSONObject();
|
||||
List<AppDataConfigure> cList=this.appDataConfigureService.selectListByCacheData(" where ac.unitId='"+unitId+"' and ac.type='"+type+"' and ac.datatype='"+AppDataConfigure.type_newData+"' order by ac.morder ");
|
||||
if(cList!=null&&cList.size()>0){
|
||||
for(int i=0;i<cList.size();i++){
|
||||
if(cList.get(i).getActive()!=null){
|
||||
if (cList.get(i).getActive().equals(CacheData.Active_true)) {
|
||||
if(cList.get(i).getValue()!=null&&!cList.get(i).getValue().equals("")){
|
||||
jsonObject.put(cList.get(i).getShowname(), new BigDecimal(Double.toString(cList.get(i).getValue())).toPlainString());
|
||||
}else{
|
||||
jsonObject.put(cList.get(i).getShowname(), "");
|
||||
}
|
||||
}else{
|
||||
if(cList.get(i).getInivalue()!=null&&!cList.get(i).getInivalue().equals("")){
|
||||
jsonObject.put(cList.get(i).getShowname(), new BigDecimal(Double.toString(cList.get(i).getInivalue())).toPlainString());
|
||||
}else{
|
||||
jsonObject.put(cList.get(i).getShowname(), "");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
jsonObject.put(cList.get(i).getShowname(), "");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
List<AppDataConfigure> hList=this.appDataConfigureService.selectListByCacheData(" where ac.unitId='"+unitId+"' and ac.type='"+type+"' and ac.datatype='"+AppDataConfigure.type_hisData+"' order by ac.morder ");
|
||||
if(hList!=null&&hList.size()>0){
|
||||
for(int i=0;i<hList.size();i++){
|
||||
String mpid=hList.get(i).getMpcode();
|
||||
List<MPointHistory> mList=this.mPointHistoryService.selectListByTableAWhere(unitId, "tb_mp_"+mpid, " where datediff(year,Measuredt,'"+CommUtil.nowDate()+"')=0 order by MeasureDT ");
|
||||
|
||||
JSONArray mjsondata=new JSONArray();
|
||||
if(mList!=null&&mList.size()>0){
|
||||
for(int m=0;m<mList.size();m++){
|
||||
String[] dataValue=new String[2];
|
||||
dataValue[0]=mList.get(m).getMeasuredt().substring(0, 10);
|
||||
BigDecimal bd = new BigDecimal(mList.get(m).getParmvalue().doubleValue());
|
||||
double d=Double.valueOf(bd.toPlainString());
|
||||
DecimalFormat df = new DecimalFormat("#.00");
|
||||
dataValue[1]=String.valueOf(df.format(d));
|
||||
mjsondata.add(dataValue);
|
||||
}
|
||||
}
|
||||
jsonObject.put(hList.get(i).getShowname(), mjsondata);
|
||||
}
|
||||
}
|
||||
|
||||
model.addAttribute("result", jsonObject);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("getFillingInformationForSS.do")
|
||||
public String getFillingInformationForSS(HttpServletRequest request,Model model){
|
||||
String unitId=request.getParameter("bizid");
|
||||
String type=request.getParameter("type");
|
||||
String yestime=CommUtil.subplus(CommUtil.nowDate(), "-1", "day");
|
||||
|
||||
String bizids=this.unitService.getAllBizIdFromFather(unitId, "");
|
||||
|
||||
JSONArray mainjsonarr=new JSONArray();
|
||||
String[] cbizids=bizids.split(",");
|
||||
if(cbizids!=null&&cbizids.length>0){
|
||||
for (int m = 0; m < cbizids.length; m++) {
|
||||
com.alibaba.fastjson.JSONObject mainjsonObject=new com.alibaba.fastjson.JSONObject();
|
||||
JSONArray jsonarr=new JSONArray();
|
||||
|
||||
List<AppDataConfigure> cList=this.appDataConfigureService.selectListByCacheData(" where ac.unitId='"+cbizids[m]+"' and ac.type='"+type+"' and datediff(day,vc.insdt,'"+yestime+"')=0 and ac.datatype='"+AppDataConfigure.type_newData+"' order by ac.morder ");
|
||||
if(cList!=null&&cList.size()>0){
|
||||
for(int i=0;i<cList.size();i++){
|
||||
String mpcode=cList.get(i).getMpcode();
|
||||
MPoint mpoint=this.mPointService.selectById(cbizids[m], mpcode);
|
||||
String unit="";
|
||||
if(mpoint!=null){
|
||||
if(mpoint.getUnit()!=null){
|
||||
unit=mpoint.getUnit();
|
||||
}
|
||||
}
|
||||
|
||||
com.alibaba.fastjson.JSONObject jsonObject=new com.alibaba.fastjson.JSONObject();
|
||||
if(cList.get(i).getActive()!=null){
|
||||
if (cList.get(i).getActive().equals(CacheData.Active_true)) {
|
||||
if(cList.get(i).getValue()!=null&&!cList.get(i).getValue().equals("")){
|
||||
jsonObject.put("name",cList.get(i).getShowname());
|
||||
jsonObject.put("value",new BigDecimal(Double.toString(cList.get(i).getValue())).toPlainString());
|
||||
jsonObject.put("insdt",cList.get(i).getInsdt());
|
||||
jsonObject.put("unit",unit);
|
||||
}else{
|
||||
jsonObject.put("name",cList.get(i).getShowname());
|
||||
jsonObject.put("value","");
|
||||
jsonObject.put("insdt","");
|
||||
jsonObject.put("unit",unit);
|
||||
}
|
||||
}else{
|
||||
if(cList.get(i).getInivalue()!=null&&!cList.get(i).getInivalue().equals("")){
|
||||
jsonObject.put("name",cList.get(i).getShowname());
|
||||
jsonObject.put("value",new BigDecimal(Double.toString(cList.get(i).getInivalue())).toPlainString());
|
||||
jsonObject.put("insdt",cList.get(i).getInsdt());
|
||||
jsonObject.put("unit",unit);
|
||||
}else{
|
||||
jsonObject.put("name",cList.get(i).getShowname());
|
||||
jsonObject.put("value","");
|
||||
jsonObject.put("insdt","");
|
||||
jsonObject.put("unit",unit);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
jsonObject.put("name",cList.get(i).getShowname());
|
||||
jsonObject.put("value","");
|
||||
jsonObject.put("insdt","");
|
||||
jsonObject.put("unit",unit);
|
||||
}
|
||||
jsonarr.add(jsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
Company u=unitService.getCompById(cbizids[m]);
|
||||
|
||||
mainjsonObject.put("bizname",u.getSname());
|
||||
mainjsonObject.put("children",jsonarr);
|
||||
|
||||
mainjsonarr.add(mainjsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
model.addAttribute("result", mainjsonarr);
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,104 @@
|
||||
package com.sipai.controller.app;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import com.sipai.entity.app.AppDataConfigure;
|
||||
import com.sipai.entity.scada.MPoint;
|
||||
import com.sipai.entity.scada.MPointHistory;
|
||||
import com.sipai.entity.visual.CacheData;
|
||||
import com.sipai.service.app.AppDataConfigureService;
|
||||
import com.sipai.service.scada.MPointHistoryService;
|
||||
import com.sipai.service.scada.MPointService;
|
||||
import com.sipai.service.visual.CacheDataService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
import com.sipai.webservice.server.work.getSSOldOPMDataServer;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/app/appMPointData")
|
||||
public class AppMPointDataController {
|
||||
@Resource
|
||||
private MPointHistoryService mPointHistoryService;
|
||||
@Resource
|
||||
private MPointService mPointService;
|
||||
@Resource
|
||||
private AppDataConfigureService appDataConfigureService;
|
||||
|
||||
|
||||
@RequestMapping("/getHisDataForSS.do")
|
||||
public String getHisData(HttpServletRequest request,Model model){
|
||||
String unitId=request.getParameter("bizid");
|
||||
String name=request.getParameter("name");
|
||||
String year=request.getParameter("year");
|
||||
String month=request.getParameter("month");
|
||||
String type="app首页数据";
|
||||
|
||||
String date=year+"-"+month+"-01";
|
||||
|
||||
JSONArray mainjsondata=new JSONArray();
|
||||
com.alibaba.fastjson.JSONObject jsonObject2=new com.alibaba.fastjson.JSONObject();
|
||||
|
||||
String mpid="";
|
||||
List<AppDataConfigure> aList=this.appDataConfigureService.selectListByCacheData(" where ac.unitId='"+unitId+"' and ac.type='"+type+"' and ac.showName='"+name+"' and ac.datatype='"+AppDataConfigure.type_newData+"' order by ac.morder ");
|
||||
if(aList!=null&&aList.size()>0){
|
||||
if(aList.get(0).getMpcode()!=null||!aList.get(0).getMpcode().equals("")){
|
||||
mpid=aList.get(0).getMpcode();
|
||||
}
|
||||
}
|
||||
|
||||
List<MPoint> mPoints = mPointService.selectListByWhere(unitId, "where (id='"+mpid+"' or MPointCode='"+mpid+"')");
|
||||
List<MPointHistory> list = mPointHistoryService
|
||||
.selectListByTableAWhere(unitId, "[tb_mp_"+mpid+"]", " where datediff(month,MeasureDT,'"+date+"')=0 order by measuredt");
|
||||
|
||||
if(list!=null && list.size()>0){
|
||||
String mpname=mPoints.get(0).getParmname();
|
||||
String unit="-";
|
||||
if(mPoints.get(0).getUnit()!=null){
|
||||
unit=mPoints.get(0).getUnit();
|
||||
}
|
||||
|
||||
String numTail="2";
|
||||
if(mPoints.get(0).getNumtail()!=null){
|
||||
numTail=mPoints.get(0).getNumtail();
|
||||
}
|
||||
String changeDf="#0.";
|
||||
for(int n=0;n<Double.valueOf(numTail);n++){
|
||||
changeDf+="0";
|
||||
}
|
||||
if(changeDf.equals("#0.")){
|
||||
changeDf="#";
|
||||
}
|
||||
DecimalFormat df = new DecimalFormat(changeDf);
|
||||
|
||||
jsonObject2.put("name",mpname);
|
||||
jsonObject2.put("unit",unit);
|
||||
|
||||
JSONArray jsondata=new JSONArray();
|
||||
for(int j=0;j<list.size();j++){
|
||||
String[] dataValue=new String[2];
|
||||
String measuredt=list.get(j).getMeasuredt();
|
||||
|
||||
dataValue[0]=measuredt.substring(0, 16);
|
||||
dataValue[1]=df.format(list.get(j).getParmvalue());
|
||||
jsondata.add(dataValue);
|
||||
}
|
||||
jsonObject2.put("value",jsondata);
|
||||
mainjsondata.add(jsonObject2);
|
||||
|
||||
}
|
||||
|
||||
model.addAttribute("result",mainjsondata);
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,247 @@
|
||||
package com.sipai.controller.app;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.sipai.entity.app.AppRoleMenu;
|
||||
import com.sipai.entity.user.Role;
|
||||
import com.sipai.entity.user.Unit;
|
||||
import com.sipai.entity.user.UserRole;
|
||||
import com.sipai.service.app.AppRoleMenuService;
|
||||
import com.sipai.service.user.RoleService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.service.user.UserRoleService;
|
||||
import com.sipai.tools.CommString;
|
||||
import net.sf.json.JSONArray;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.app.AppMenuitem;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.scada.MPointHistory;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.scada.MPointHistoryService;
|
||||
import com.sipai.service.app.AppMenuitemService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/app/appMenuitem")
|
||||
public class AppMenuitemController {
|
||||
@Resource
|
||||
private AppMenuitemService appMenuitemService;
|
||||
@Resource
|
||||
private AppRoleMenuService appRoleMenuService;
|
||||
@Resource
|
||||
private RoleService roleService;
|
||||
@Resource
|
||||
private UserRoleService userRoleService;
|
||||
|
||||
@RequestMapping("/showMange.do")
|
||||
public String showMange(HttpServletRequest request, Model model) {
|
||||
return "app/appMenuitemMange";
|
||||
}
|
||||
|
||||
@RequestMapping("/showList.do")
|
||||
public String showList(HttpServletRequest request, Model model) {
|
||||
return "app/appMenuitemList";
|
||||
}
|
||||
|
||||
@RequestMapping("/getList.do")
|
||||
public ModelAndView getList(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required = false) String sort,
|
||||
@RequestParam(value = "order", required = false) String order) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
if (sort == null) {
|
||||
sort = " sdt ";
|
||||
}
|
||||
if (order == null) {
|
||||
order = " desc ";
|
||||
}
|
||||
String orderstr = " order by " + sort + " " + order;
|
||||
|
||||
String wherestr = " where 1=1 and pid='" + request.getParameter("pid") + "' ";
|
||||
PageHelper.startPage(page, rows);
|
||||
List<AppMenuitem> list = this.appMenuitemService.selectListByWhere(wherestr + orderstr);
|
||||
PageInfo<AppMenuitem> pi = new PageInfo<AppMenuitem>(list);
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
|
||||
String result = "{\"total\":" + pi.getTotal() + ",\"rows\":" + json + "}";
|
||||
// System.out.println(result);
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/getTreeJson.do")
|
||||
public String getTreeJson(HttpServletRequest request, Model model) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
|
||||
List<AppMenuitem> list = this.appMenuitemService.selectListByWhere("where 1=1 "
|
||||
+ " order by morder");
|
||||
|
||||
String json = this.appMenuitemService.getTreeList(null, list);
|
||||
model.addAttribute("result", json);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doadd.do")
|
||||
public String doadd(HttpServletRequest request, Model model) {
|
||||
return "app/appMenuitemAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/dosave.do")
|
||||
public String dosave(HttpServletRequest request, Model model,
|
||||
@ModelAttribute(value = "appMenuitem") AppMenuitem appMenuitem) throws ScriptException {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
appMenuitem.setId(CommUtil.getUUID());
|
||||
int code = this.appMenuitemService.save(appMenuitem);
|
||||
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("新增失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doedit.do")
|
||||
public String doedit(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
AppMenuitem appMenuitem = this.appMenuitemService.selectById(id);
|
||||
model.addAttribute("appMenuitem", appMenuitem);
|
||||
|
||||
return "app/appMenuitemEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/doupdate.do")
|
||||
public String doupdate(HttpServletRequest request, Model model,
|
||||
@ModelAttribute(value = "appMenuitem") AppMenuitem appMenuitem) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
|
||||
Result result = new Result();
|
||||
int code = this.appMenuitemService.update(appMenuitem);
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("更新失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodel.do")
|
||||
public String dodel(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
Result result = new Result();
|
||||
int code = this.appMenuitemService.deleteById(id);
|
||||
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("删除失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodeletes.do")
|
||||
public String dodels(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "ids") String ids) {
|
||||
ids = ids.replace(",", "','");
|
||||
int result = this.appMenuitemService.deleteByWhere("where id in ('" + ids + "')");
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/showRoleMenu.do")
|
||||
public String showRoleMenu(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "roleid") String roleid) {
|
||||
// List<AppRoleMenu> list = this.appRoleMenuService.getFinalMenuByRoleId(roleid);
|
||||
// JSONArray json = JSONArray.fromObject(list);
|
||||
List<AppRoleMenu> list = this.appRoleMenuService.selectListByWhere(" where roleID='" + roleid + "'");
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
model.addAttribute("json", json);
|
||||
List<Role> roles = roleService.getList("where id='" + roleid + "'");
|
||||
if (roles != null && roles.size() > 0) {
|
||||
model.addAttribute("rolename", roles.get(0).getName());
|
||||
}
|
||||
model.addAttribute("roleid", roleid);
|
||||
return "app/appRoleMenuSelect";
|
||||
}
|
||||
|
||||
@RequestMapping("/getMenusJson.do")
|
||||
public String getMenusJson(HttpServletRequest request, Model model,
|
||||
@RequestParam String roleid) {
|
||||
List<AppMenuitem> list = this.appMenuitemService.selectListByWhere("where 1=1 and active='" + CommString.Active_True + "' order by morder");
|
||||
|
||||
String result = this.appMenuitemService.getTreeList(null, list);
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/updateRoleMenu.do")
|
||||
public String updateRoleMenu(HttpServletRequest request, Model model,
|
||||
@RequestParam("menustr") String menustr, @RequestParam("roleid") String roleid) {
|
||||
int result = this.appRoleMenuService.updateRoleMenu(roleid, menustr);
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/sendToApp.do")
|
||||
public String sendToApp(HttpServletRequest request, Model model,
|
||||
@RequestParam("userId") String userId) {
|
||||
String roleIds = "";
|
||||
List<UserRole> userRolelist = this.userRoleService.selectListByWhere(" where EmpID='" + userId + "' ");
|
||||
if (userRolelist != null && userRolelist.size() > 0) {
|
||||
for (UserRole userRole :
|
||||
userRolelist) {
|
||||
roleIds += userRole.getRoleid() + ",";
|
||||
}
|
||||
}
|
||||
|
||||
String menuIds = "";
|
||||
if (!roleIds.equals("")) {
|
||||
roleIds = roleIds.replace(",", "','");
|
||||
List<AppRoleMenu> appRoleMenulist = this.appRoleMenuService.selectDistinctMenuIDListByWhere(" where roleID in ('" + roleIds + "') ");
|
||||
for (AppRoleMenu appRoleMenu :
|
||||
appRoleMenulist) {
|
||||
menuIds += appRoleMenu.getMenuid() + ",";
|
||||
}
|
||||
}
|
||||
|
||||
List<AppMenuitem> list = this.appMenuitemService.selectListByWhere("where 1=1 and active='" + CommString.Active_True + "' "
|
||||
+ " order by morder");
|
||||
if (list != null && list.size() > 0) {
|
||||
for (AppMenuitem appMenuitem :
|
||||
list) {
|
||||
boolean status = menuIds.contains(appMenuitem.getId());
|
||||
if (status) {
|
||||
appMenuitem.setStatus("true");
|
||||
} else {
|
||||
appMenuitem.setStatus("false");
|
||||
}
|
||||
}
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
model.addAttribute("result", json);
|
||||
}
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,217 @@
|
||||
package com.sipai.controller.app;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.sipai.entity.scada.MPoint;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.app.AppProductMonitor;
|
||||
import com.sipai.entity.app.AppProductMonitorMp;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.report.RptDayValSet;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.app.AppProductMonitorMpService;
|
||||
import com.sipai.service.app.AppProductMonitorService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/app/appProductMonitor")
|
||||
public class AppProductMonitorController {
|
||||
@Resource
|
||||
private AppProductMonitorService appProductMonitorService;
|
||||
@Resource
|
||||
private AppProductMonitorMpService appProductMonitorMpService;
|
||||
|
||||
@RequestMapping("/showTree1.do")
|
||||
public String showTree(HttpServletRequest request,Model model){
|
||||
return "/app/appProductMonitorTree";
|
||||
}
|
||||
|
||||
@RequestMapping("/getTree.do")
|
||||
public String getTree(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "unitId") String unitId){
|
||||
String orderstr=" order by morder asc";
|
||||
String wherestr=" where unit_id ='"+unitId+"'";
|
||||
List<AppProductMonitor> list = this.appProductMonitorService.selectListByWhere(wherestr+orderstr);
|
||||
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for (AppProductMonitor appProductMonitor : list) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("id", appProductMonitor.getId());
|
||||
jsonObject.put("text", appProductMonitor.getName());
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
|
||||
Result success = Result.success(jsonArray);
|
||||
model.addAttribute("result", CommUtil.toJson(success));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/getlist4APP.do")
|
||||
public String getlist4APP(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "unitId") String unitId){
|
||||
String orderstr=" order by morder asc";
|
||||
String wherestr=" where unit_id ='"+unitId+"'";
|
||||
List<AppProductMonitor> list = this.appProductMonitorService.selectListByWhere(wherestr+orderstr);
|
||||
|
||||
Result success = Result.success(list);
|
||||
model.addAttribute("result", CommUtil.toJson(success));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doadd.do")
|
||||
public String doadd(HttpServletRequest request,Model model){
|
||||
return "/app/appProductMonitorAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/dosave.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
AppProductMonitor appProductMonitor){
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
appProductMonitor.setId(CommUtil.getUUID());
|
||||
appProductMonitor.setInsdt(CommUtil.nowDate());
|
||||
appProductMonitor.setInsuser(cu.getId());
|
||||
int code = this.appProductMonitorService.save(appProductMonitor);
|
||||
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("新增失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doedit.do")
|
||||
public String doedit(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
AppProductMonitor appProductMonitor = this.appProductMonitorService.selectById(id);
|
||||
|
||||
model.addAttribute("appProductMonitor", appProductMonitor);
|
||||
return "/app/appProductMonitorEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/doupdate.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
AppProductMonitor appProductMonitor){
|
||||
int code = this.appProductMonitorService.update(appProductMonitor);
|
||||
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("修改失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodelete.do")
|
||||
public String dodelete(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id){
|
||||
int code = this.appProductMonitorService.deleteById(id);
|
||||
this.appProductMonitorMpService.deleteByWhere("where pid = '" + id + "'");
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("删除失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/getlistMp.do")
|
||||
public String getlistMp(HttpServletRequest request,Model model,
|
||||
// @RequestParam(value = "page") Integer page,
|
||||
// @RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required=false) String sort,
|
||||
@RequestParam(value = "order", required=false) String order,
|
||||
@RequestParam(value = "unitId") String unitId,
|
||||
@RequestParam(value = "pid") String pid) {
|
||||
// String userId= JwtUtil.getUserId(request.getHeader(CommString.TOKEN_HEADER));
|
||||
String orderstr=" order by morder asc";
|
||||
String wherestr=" where pid = '"+pid+"'";
|
||||
// PageHelper.startPage(page, rows);
|
||||
List<AppProductMonitorMp> list = this.appProductMonitorMpService.selectListByWhere(wherestr+orderstr);
|
||||
// PageInfo<AppProductMonitorMp> pi = new PageInfo<AppProductMonitorMp>(list);
|
||||
|
||||
// list = list.stream()
|
||||
// .sorted(Comparator.comparing(AppProductMonitorMp::getMorder))
|
||||
// .collect(Collectors.toList());
|
||||
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
// String result="{\"total\":"+pi.getTotal()+",\"rows\":"+json+"}";
|
||||
String result=""+json;
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doimportMp.do")
|
||||
public String doimportMp(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "pid") String pid,
|
||||
@RequestParam(value = "mpids") String mpids){
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String userId = cu.getId();
|
||||
String unitId = request.getParameter("unitId");
|
||||
this.appProductMonitorMpService.deleteByWhere("where pid = '"+pid+"'");
|
||||
|
||||
int num = 0;
|
||||
String[] mpidArr = mpids.split(",");
|
||||
if (mpids!=null&&!mpids.isEmpty()){
|
||||
for (int i = 0; i < mpidArr.length; i++) {
|
||||
AppProductMonitorMp appProductMonitorMp = new AppProductMonitorMp();
|
||||
appProductMonitorMp.setId(CommUtil.getUUID());
|
||||
appProductMonitorMp.setPid(pid);
|
||||
appProductMonitorMp.setMpid(mpidArr[i]);
|
||||
appProductMonitorMp.setUnitId(unitId);
|
||||
appProductMonitorMp.setInsuser(userId);
|
||||
appProductMonitorMp.setInsdt(CommUtil.nowDate());
|
||||
appProductMonitorMp.setMorder(i);
|
||||
int code = this.appProductMonitorMpService.save(appProductMonitorMp);
|
||||
if(code==1){
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Result result = new Result();
|
||||
// if (num == mpidArr.length) {
|
||||
result = Result.success(num);
|
||||
// }
|
||||
// else {
|
||||
// result = Result.failed("导入失败");
|
||||
// }
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodeleteMp.do")
|
||||
public String dodeleteMp(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id){
|
||||
int code = this.appProductMonitorMpService.deleteById(id);
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("删除失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
package com.sipai.controller.app;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import com.sipai.entity.user.Unit;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.service.visual.CacheDataService;
|
||||
import com.sipai.tools.CommString;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/app/appYesterdayMainData")
|
||||
public class AppYesterdayMainDataController {
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
@Resource
|
||||
private CacheDataService cacheDataService;
|
||||
|
||||
@RequestMapping("getdata.do")
|
||||
public String getdata(HttpServletRequest request,Model model){
|
||||
String type=request.getParameter("type");
|
||||
List<Unit> ulist =this.unitService.selectListByWhere(" where (type in ('"+CommString.UNIT_TYPE_COMPANY+"','"+CommString.UNIT_TYPE_BIZ+"')) order by type desc,morder");
|
||||
String json = cacheDataService.getAPPYesterdayMainDataTreeList(null, ulist,type);
|
||||
model.addAttribute("result", json);
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
390
src/main/java/com/sipai/controller/app/EquBIMController.java
Normal file
390
src/main/java/com/sipai/controller/app/EquBIMController.java
Normal file
@ -0,0 +1,390 @@
|
||||
package com.sipai.controller.app;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.sipai.entity.scada.MPoint;
|
||||
import com.sipai.service.scada.MPointService;
|
||||
import net.sf.json.JSONArray;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.itextpdf.text.pdf.PdfStructTreeController.returnType;
|
||||
import com.lowagie.tools.concat_pdf;
|
||||
import com.sipai.entity.command.EmergencyRecordsDetail;
|
||||
import com.sipai.entity.equipment.EquipmentCard;
|
||||
import com.sipai.entity.equipment.EquipmentCardProp;
|
||||
import com.sipai.entity.structure.StructureCardPicture;
|
||||
import com.sipai.entity.structure.StructureCardPictureRoute;
|
||||
import com.sipai.entity.timeefficiency.PatrolPoint;
|
||||
import com.sipai.service.command.EmergencyRecordsDetailService;
|
||||
import com.sipai.service.equipment.EquipmentCardPropService;
|
||||
import com.sipai.service.equipment.EquipmentCardService;
|
||||
import com.sipai.service.structure.StructureCardPictureRouteService;
|
||||
import com.sipai.service.structure.StructureCardPictureService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(value = "equBIM")
|
||||
public class EquBIMController {
|
||||
|
||||
@Resource
|
||||
private StructureCardPictureService structureCardPictureService;
|
||||
@Resource
|
||||
private StructureCardPictureRouteService structureCardPictureRouteService;
|
||||
@Resource
|
||||
private EquipmentCardService equipmentCardService;
|
||||
@Resource
|
||||
private EquipmentCardPropService equipmentCardPropService;
|
||||
@Resource
|
||||
private EmergencyRecordsDetailService emergencyRecordsDetailService;
|
||||
@Resource
|
||||
private MPointService mPointService;
|
||||
|
||||
/**
|
||||
* 获取相应构筑物下的巡检路线,给同济
|
||||
*
|
||||
* @param request
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("getStructureCardPictureRoute.do")
|
||||
public String getPatrolPoints(HttpServletRequest request, Model model) {
|
||||
//拿到构筑物id
|
||||
String structureId = request.getParameter("structureId");
|
||||
//拿到type
|
||||
String type = request.getParameter("type");
|
||||
Map<String, Object> InspectionDatas = new HashMap<>();
|
||||
//根据type=(line 或 area)查有多少个底图的list
|
||||
//查这个构筑物下有多少底图
|
||||
if (structureId != null && !structureId.equals("") && !structureId.equals("*")) {
|
||||
if (type != null && !type.equals("") && type.equals("line")) {
|
||||
//查询巡检路线
|
||||
List<StructureCardPicture> structureCardPictures = this.structureCardPictureService.selectListByWhere("where 1=1 and structure_id = '" + structureId + "' and type = '" + type + "' order by morder");
|
||||
if (structureCardPictures != null && structureCardPictures.size() > 0) {
|
||||
List<Map<String, Object>> structureCardPictureslist = new ArrayList<Map<String, Object>>();
|
||||
//循环底图
|
||||
for (int i = 0; i < structureCardPictures.size(); i++) {
|
||||
Map<String, Object> structureCardPictureMap = new HashMap<>();
|
||||
structureCardPictureMap.put("InspectionName", "Inspection_" + structureId + "_" + structureCardPictures.get(i).getFloor());
|
||||
structureCardPictureMap.put("ImageWidth", 2048);
|
||||
structureCardPictureMap.put("ImageHeight", 1080);
|
||||
//查询该底图下有多少巡检点
|
||||
List<StructureCardPictureRoute> structureCardPictureRoutes = this.structureCardPictureRouteService.selectListByWhere("where 1=1 and structure_card_picture_id = '" + structureCardPictures.get(i).getId() + "'");
|
||||
if (structureCardPictureRoutes != null && structureCardPictureRoutes.size() > 0) {
|
||||
//存每个底图下的巡检点
|
||||
List<Map<String, Object>> structureCardPictureRouteslist = new ArrayList<Map<String, Object>>();
|
||||
List<StructureCardPictureRoute> newstructureCardPictureRoutes = this.structureCardPictureRouteService.sort(structureCardPictureRoutes);
|
||||
if (newstructureCardPictureRoutes != null && newstructureCardPictureRoutes.size() > 0) {
|
||||
for (int j = 0; j < newstructureCardPictureRoutes.size(); j++) {
|
||||
Map<String, Object> structureCardPictureRouteMap = new HashMap<>();
|
||||
structureCardPictureRouteMap.put("x", newstructureCardPictureRoutes.get(j).getPosx());
|
||||
structureCardPictureRouteMap.put("y", newstructureCardPictureRoutes.get(j).getPosy());
|
||||
structureCardPictureRouteMap.put("index", j);
|
||||
structureCardPictureRouteslist.add(structureCardPictureRouteMap);
|
||||
}
|
||||
structureCardPictureMap.put("Points", structureCardPictureRouteslist);
|
||||
}
|
||||
}
|
||||
structureCardPictureslist.add(structureCardPictureMap);
|
||||
}
|
||||
InspectionDatas.put("InspectionDatas", structureCardPictureslist);
|
||||
model.addAttribute("result", JSONArray.fromObject(JSONArray.fromObject(structureCardPictureslist)));
|
||||
}
|
||||
} else if (type != null && !type.equals("") && type.equals("area")) {
|
||||
List<Map<String, Object>> structureCardPictureslist = new ArrayList<Map<String, Object>>();
|
||||
//查询有多少楼层
|
||||
List<StructureCardPicture> structureCardPictures = this.structureCardPictureService.selectListGroupByFloor("where 1=1 and structure_id = '" + structureId + "' and type = '" + type + "' ");
|
||||
|
||||
if (structureCardPictures != null && structureCardPictures.size() > 0) {
|
||||
//循环楼层,再查出有多少每个楼层有多少个安全区域
|
||||
for (int m = 0; m < structureCardPictures.size(); m++) {
|
||||
Map<String, Object> structureCardPictureMap = new HashMap<>();
|
||||
structureCardPictureMap.put("InspectionName", "Inspection_" + structureId + "_" + structureCardPictures.get(m).getFloor());
|
||||
structureCardPictureMap.put("ImageWidth", 2048);
|
||||
structureCardPictureMap.put("ImageHeight", 1080);
|
||||
List<Map<String, Object>> structureCardPictureRouteslist = new ArrayList<Map<String, Object>>();
|
||||
|
||||
List<StructureCardPicture> structureCardPicturesFloor = this.structureCardPictureService.selectListByWhere("where 1=1 and "
|
||||
+ " structure_id = '" + structureId + "' and type = '" + type + "' and floor = '" + structureCardPictures.get(m).getFloor() + "' order by morder");
|
||||
|
||||
if (structureCardPicturesFloor != null && structureCardPicturesFloor.size() > 0) {
|
||||
//循环每个楼层
|
||||
for (int n = 0; n < structureCardPicturesFloor.size(); n++) {
|
||||
|
||||
Map<String, Object> structureCardPictureRouteMap = new HashMap<>();
|
||||
//找到每个安全区域的两个点
|
||||
List<StructureCardPictureRoute> structureCardPictureRoutes = this.structureCardPictureRouteService.selectListByWhere(
|
||||
"where 1=1 and structure_card_picture_id = '" + structureCardPicturesFloor.get(n).getId() + "'");
|
||||
if (structureCardPictureRoutes != null && structureCardPictureRoutes.size() > 0) {
|
||||
List<StructureCardPictureRoute> newstructureCardPictureRoutes = this.structureCardPictureRouteService.sort(structureCardPictureRoutes);
|
||||
if (newstructureCardPictureRoutes != null && newstructureCardPictureRoutes.size() >= 2) {
|
||||
structureCardPictureRouteMap.put("point_Max", newstructureCardPictureRoutes.get(0).getPosx().toString() + "," + newstructureCardPictureRoutes.get(0).getPosy().toString());
|
||||
structureCardPictureRouteMap.put("point_Min", newstructureCardPictureRoutes.get(1).getPosx().toString() + "," + newstructureCardPictureRoutes.get(1).getPosy().toString());
|
||||
structureCardPictureRouteMap.put("areaType", structureCardPicturesFloor.get(n).getSafeLevel());
|
||||
structureCardPictureRouteMap.put("areaNote", structureCardPicturesFloor.get(n).getSafeContent());
|
||||
structureCardPictureRouteslist.add(structureCardPictureRouteMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
structureCardPictureMap.put("Points", structureCardPictureRouteslist);
|
||||
structureCardPictureslist.add(structureCardPictureMap);
|
||||
}
|
||||
model.addAttribute("result", JSONArray.fromObject(JSONArray.fromObject(structureCardPictureslist)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
if (type != null && !type.equals("") && type.equals("line")) {
|
||||
//查询巡检路线
|
||||
List<StructureCardPicture> structureCardPictures = this.structureCardPictureService.selectListByWhere("where 1=1 and type = '" + type + "' order by morder");
|
||||
if (structureCardPictures != null && structureCardPictures.size() > 0) {
|
||||
List<Map<String, Object>> structureCardPictureslist = new ArrayList<Map<String, Object>>();
|
||||
//循环底图
|
||||
for (int i = 0; i < structureCardPictures.size(); i++) {
|
||||
Map<String, Object> structureCardPictureMap = new HashMap<>();
|
||||
structureCardPictureMap.put("InspectionName", "Inspection_" + structureCardPictures.get(i).getStructureId() + "_" + structureCardPictures.get(i).getFloor());
|
||||
structureCardPictureMap.put("ImageWidth", 2048);
|
||||
structureCardPictureMap.put("ImageHeight", 1080);
|
||||
//查询该底图下有多少巡检点
|
||||
List<StructureCardPictureRoute> structureCardPictureRoutes = this.structureCardPictureRouteService.selectListByWhere("where 1=1 and structure_card_picture_id = '" + structureCardPictures.get(i).getId() + "'");
|
||||
if (structureCardPictureRoutes != null && structureCardPictureRoutes.size() > 0) {
|
||||
//存每个底图下的巡检点
|
||||
List<Map<String, Object>> structureCardPictureRouteslist = new ArrayList<Map<String, Object>>();
|
||||
List<StructureCardPictureRoute> newstructureCardPictureRoutes = this.structureCardPictureRouteService.sort(structureCardPictureRoutes);
|
||||
if (newstructureCardPictureRoutes != null && newstructureCardPictureRoutes.size() > 0) {
|
||||
for (int j = 0; j < newstructureCardPictureRoutes.size(); j++) {
|
||||
Map<String, Object> structureCardPictureRouteMap = new HashMap<>();
|
||||
structureCardPictureRouteMap.put("x", newstructureCardPictureRoutes.get(j).getPosx());
|
||||
structureCardPictureRouteMap.put("y", newstructureCardPictureRoutes.get(j).getPosy());
|
||||
structureCardPictureRouteMap.put("index", j);
|
||||
structureCardPictureRouteslist.add(structureCardPictureRouteMap);
|
||||
}
|
||||
structureCardPictureMap.put("Points", structureCardPictureRouteslist);
|
||||
}
|
||||
}
|
||||
structureCardPictureslist.add(structureCardPictureMap);
|
||||
}
|
||||
InspectionDatas.put("InspectionDatas", structureCardPictureslist);
|
||||
model.addAttribute("result", JSONArray.fromObject(JSONArray.fromObject(structureCardPictureslist)));
|
||||
}
|
||||
} else if (type != null && !type.equals("") && type.equals("area")) {
|
||||
List<Map<String, Object>> structureCardPictureslist = new ArrayList<Map<String, Object>>();
|
||||
|
||||
List<StructureCardPicture> structureCardPictureAll = this.structureCardPictureService.selectListGroupByStructureId("where 1=1 and type = '" + type + "' ");
|
||||
for (int a = 0; a < structureCardPictureAll.size(); a++) {
|
||||
//查询有多少楼层
|
||||
List<StructureCardPicture> structureCardPictures = this.structureCardPictureService.selectListGroupByFloor("where 1=1 and structure_id = '" + structureCardPictureAll.get(a).getStructureId() + "' and type = '" + type + "' ");
|
||||
|
||||
if (structureCardPictures != null && structureCardPictures.size() > 0) {
|
||||
//循环楼层,再查出有多少每个楼层有多少个安全区域
|
||||
for (int m = 0; m < structureCardPictures.size(); m++) {
|
||||
Map<String, Object> structureCardPictureMap = new HashMap<>();
|
||||
structureCardPictureMap.put("InspectionName", "Inspection_" + structureCardPictureAll.get(a).getStructureId() + "_" + structureCardPictures.get(m).getFloor());
|
||||
structureCardPictureMap.put("ImageWidth", 2048);
|
||||
structureCardPictureMap.put("ImageHeight", 1080);
|
||||
List<Map<String, Object>> structureCardPictureRouteslist = new ArrayList<Map<String, Object>>();
|
||||
|
||||
List<StructureCardPicture> structureCardPicturesFloor = this.structureCardPictureService.selectListByWhere("where 1=1 and "
|
||||
+ " structure_id = '" + structureCardPictureAll.get(a).getStructureId() + "' and type = '" + type + "' and floor = '" + structureCardPictures.get(m).getFloor() + "' order by morder");
|
||||
|
||||
if (structureCardPicturesFloor != null && structureCardPicturesFloor.size() > 0) {
|
||||
//循环每个楼层
|
||||
for (int n = 0; n < structureCardPicturesFloor.size(); n++) {
|
||||
|
||||
Map<String, Object> structureCardPictureRouteMap = new HashMap<>();
|
||||
//找到每个安全区域的两个点
|
||||
List<StructureCardPictureRoute> structureCardPictureRoutes = this.structureCardPictureRouteService.selectListByWhere(
|
||||
"where 1=1 and structure_card_picture_id = '" + structureCardPicturesFloor.get(n).getId() + "'");
|
||||
if (structureCardPictureRoutes != null && structureCardPictureRoutes.size() > 0) {
|
||||
List<StructureCardPictureRoute> newstructureCardPictureRoutes = this.structureCardPictureRouteService.sort(structureCardPictureRoutes);
|
||||
if (newstructureCardPictureRoutes != null && newstructureCardPictureRoutes.size() >= 2) {
|
||||
structureCardPictureRouteMap.put("point_Max", newstructureCardPictureRoutes.get(0).getPosx().toString() + "," + newstructureCardPictureRoutes.get(0).getPosy().toString());
|
||||
structureCardPictureRouteMap.put("point_Min", newstructureCardPictureRoutes.get(1).getPosx().toString() + "," + newstructureCardPictureRoutes.get(1).getPosy().toString());
|
||||
structureCardPictureRouteMap.put("areaType", structureCardPicturesFloor.get(n).getSafeLevel());
|
||||
structureCardPictureRouteMap.put("areaNote", structureCardPicturesFloor.get(n).getSafeContent());
|
||||
structureCardPictureRouteslist.add(structureCardPictureRouteMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
structureCardPictureMap.put("Points", structureCardPictureRouteslist);
|
||||
structureCardPictureslist.add(structureCardPictureMap);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
model.addAttribute("result", JSONArray.fromObject(JSONArray.fromObject(structureCardPictureslist)));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// model.addAttribute("result",JSONObject.toJSONString(InspectionDatas));
|
||||
return "result";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看设备
|
||||
*/
|
||||
@RequestMapping("/doviewForTongji.do")
|
||||
public String doviewForTongji(HttpServletRequest request, Model model) {
|
||||
String id = request.getParameter("id");
|
||||
if (id != null && !id.equals("") && !id.equals("*")) {
|
||||
EquipmentCard equipmentCard = this.equipmentCardService.selectById(id);
|
||||
model.addAttribute("equipmentCard", equipmentCard);
|
||||
if (equipmentCard != null) {
|
||||
EquipmentCardProp equipmentCardProp = this.equipmentCardPropService
|
||||
.selectByEquipmentId(equipmentCard.getId());
|
||||
model.addAttribute("equipmentCardProp", equipmentCardProp);
|
||||
}
|
||||
|
||||
// return "equipment/equipmentCardView";
|
||||
model.addAttribute("id", id);
|
||||
}
|
||||
|
||||
return "equipment/equipmentCardNewViewForTongji";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取应急预案步骤,For BIM
|
||||
*
|
||||
* @param request
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("getEmergencyRecordsDetailJson.do")
|
||||
@ResponseBody
|
||||
public Object getEmergencyRecordsDetailJson(HttpServletRequest request, Model model) {
|
||||
|
||||
com.alibaba.fastjson.JSONObject resultObject = new com.alibaba.fastjson.JSONObject();
|
||||
String pid = request.getParameter("pid"); //EmergencyConfigure中的pid
|
||||
if (pid != null && !"".equals(pid)) {
|
||||
List<EmergencyRecordsDetail> emergencyRecordsDetails = this.emergencyRecordsDetailService
|
||||
.selectListForJson("where b.pid = '" + pid + "' and a.status = '1' order by b.ord desc,a.rank desc");
|
||||
if (emergencyRecordsDetails != null && emergencyRecordsDetails.size() > 0) {
|
||||
resultObject.put("name", emergencyRecordsDetails.get(0).getContents());
|
||||
if (emergencyRecordsDetails.get(0).get_ord().equals("4") && emergencyRecordsDetails.get(0).getRank().toString().equals("1")) {
|
||||
resultObject.put("step", "1.0");
|
||||
} else {
|
||||
resultObject.put("step", emergencyRecordsDetails.get(0).get_ord() + "." + emergencyRecordsDetails.get(0).getRank().toString());
|
||||
}
|
||||
|
||||
} else {
|
||||
List<EmergencyRecordsDetail> emergencyRecordsDetails2 = this.emergencyRecordsDetailService
|
||||
.selectListForJson("where b.pid = '" + pid + "' and a.status = '2' order by b.ord desc,a.rank desc");
|
||||
if (emergencyRecordsDetails2 != null && emergencyRecordsDetails2.size() > 0) {
|
||||
resultObject.put("name", emergencyRecordsDetails2.get(0).getContents());
|
||||
if (emergencyRecordsDetails2.get(0).get_ord().equals("4") && emergencyRecordsDetails2.get(0).getRank().toString().equals("1")) {
|
||||
resultObject.put("step", "1.0");
|
||||
} else {
|
||||
resultObject.put("step", emergencyRecordsDetails2.get(0).get_ord() + "." + emergencyRecordsDetails2.get(0).getRank().toString());
|
||||
}
|
||||
} else {
|
||||
resultObject.put("name", "未开始应急预案");
|
||||
resultObject.put("step", "1.0");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取天气
|
||||
*
|
||||
* @param request
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("getWeather.do")
|
||||
@ResponseBody
|
||||
public Object getWeather(HttpServletRequest request, Model model) throws IOException {
|
||||
String city = "上海";
|
||||
com.alibaba.fastjson.JSONObject resultObject = com.alibaba.fastjson.JSONObject.parseObject(CommUtil.getWeather(city));
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
@RequestMapping("getEquipmentCard.do")
|
||||
public String getEquipmentCard(HttpServletRequest request, Model model) {
|
||||
String bizId = request.getParameter("bizId");
|
||||
String equId = request.getParameter("equId");
|
||||
EquipmentCard equipmentCard = this.equipmentCardService.selectSimpleByEquipmentCardId(equId);
|
||||
JSONArray upstreamAndDownstreamIdListArr = new JSONArray();
|
||||
JSONArray controlIdListArr = new JSONArray();
|
||||
JSONArray powerIdListArr = new JSONArray();
|
||||
JSONArray mpointListArr = new JSONArray();
|
||||
String controlIds = equipmentCard.getControlId();
|
||||
if (controlIds != null && controlIds.length() > 0) {
|
||||
String[] controlIdList = controlIds.split(",");
|
||||
if (controlIdList != null && controlIdList.length > 0) {
|
||||
for (int i = 0; i < controlIdList.length; i++) {
|
||||
net.sf.json.JSONObject obj = new net.sf.json.JSONObject();
|
||||
EquipmentCard equipmentCard2 = this.equipmentCardService.selectSimpleListById(controlIdList[i]);
|
||||
if (equipmentCard2 != null) {
|
||||
obj.put("equipmentID", equipmentCard2.getEquipmentcardid());
|
||||
obj.put("equipmentName", equipmentCard2.getEquipmentname());
|
||||
} else {
|
||||
obj.put("equipmentID", controlIdList[i]);
|
||||
obj.put("equipmentName", "未查到对应设备");
|
||||
}
|
||||
controlIdListArr.add(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
String powerIds = equipmentCard.getPowerId();
|
||||
if (powerIds != null && powerIds.length() > 0) {
|
||||
String[] powerIdList = powerIds.split(",");
|
||||
if (powerIdList != null && powerIdList.length > 0) {
|
||||
for (int i = 0; i < powerIdList.length; i++) {
|
||||
net.sf.json.JSONObject obj = new net.sf.json.JSONObject();
|
||||
EquipmentCard equipmentCard2 = this.equipmentCardService.selectSimpleListById(powerIdList[i]);
|
||||
if (equipmentCard2 != null) {
|
||||
obj.put("equipmentID", equipmentCard2.getEquipmentcardid());
|
||||
obj.put("equipmentName", equipmentCard2.getEquipmentname());
|
||||
} else {
|
||||
obj.put("equipmentID", powerIdList[i]);
|
||||
obj.put("equipmentName", "未查到对应设备");
|
||||
}
|
||||
powerIdListArr.add(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备的测量点
|
||||
*
|
||||
*/
|
||||
List<MPoint> mpoints = this.mPointService.selectListByWhere(bizId, " where equipmentId='" + equId + "'");
|
||||
if (mpoints != null && mpoints.size() > 0) {
|
||||
for (MPoint group : mpoints) {
|
||||
net.sf.json.JSONObject obj = new net.sf.json.JSONObject();
|
||||
obj.put("MpointID", group.getMpointid());
|
||||
obj.put("ParmName", group.getParmname());
|
||||
mpointListArr.add(obj);
|
||||
}
|
||||
}
|
||||
net.sf.json.JSONObject json = new net.sf.json.JSONObject();
|
||||
json = net.sf.json.JSONObject.fromObject(equipmentCard);
|
||||
json.put("upstreamAndDownstreamIdList", upstreamAndDownstreamIdListArr);
|
||||
json.put("controlIdList", controlIdListArr);
|
||||
json.put("powerIdList", powerIdListArr);
|
||||
json.put("mpoints", mpointListArr);
|
||||
|
||||
//System.out.println(json);
|
||||
model.addAttribute("result", json);
|
||||
return "result";
|
||||
}
|
||||
}
|
||||
365
src/main/java/com/sipai/controller/app/LoginController.java
Normal file
365
src/main/java/com/sipai/controller/app/LoginController.java
Normal file
@ -0,0 +1,365 @@
|
||||
package com.sipai.controller.app;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.sipai.entity.base.BasicComponents;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.base.BasicComponentsService;
|
||||
import com.sipai.service.base.LoginService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.service.user.UserDetailService;
|
||||
import com.sipai.service.user.UserService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
import com.sipai.tools.SpringContextUtil;
|
||||
import com.sipai.tools.VerifyCodeUtils;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(value = "app")
|
||||
public class LoginController {
|
||||
|
||||
@Resource
|
||||
private LoginService loginService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private UserDetailService userDetailService;
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
|
||||
@RequestMapping(value = "login.do", method = RequestMethod.POST)
|
||||
public ModelAndView login(HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
String j_username= request.getParameter("user");
|
||||
String j_password= request.getParameter("pwd");
|
||||
User cu = new User();
|
||||
if(j_username!=null && j_password!=null){
|
||||
cu= loginService.Login(j_username, j_password);
|
||||
}
|
||||
if (null != cu) {
|
||||
//设置cu其他信息
|
||||
cu.setCurrentip(request.getRemoteAddr());
|
||||
cu.setLastlogintime(CommUtil.nowDate());
|
||||
|
||||
HttpSession currentSession = request.getSession(false);
|
||||
if (null != currentSession){
|
||||
currentSession.invalidate();
|
||||
}
|
||||
//设置session
|
||||
HttpSession newSession = request.getSession(true);
|
||||
newSession.setAttribute("cu", cu);
|
||||
request.setAttribute("result", "{\"result\":\"pass\",\"re1\":" +
|
||||
JSONObject.toJSONString(cu) + "}");
|
||||
/*JSONObject jsob = JSONObject.fromObject(cu);
|
||||
request.setAttribute("result", "{\"result\":\"pass\",\"re1\":" +
|
||||
jsob.toString() + "}");
|
||||
jsob=null;*/
|
||||
} else {
|
||||
request.setAttribute("result", "{\"result\":\"no\"}");
|
||||
}
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping(value = "nameLogin.do")
|
||||
public ModelAndView nameLogin(HttpServletRequest request,
|
||||
HttpServletResponse response,Model model) {
|
||||
request.setAttribute("username", request.getParameter("username"));
|
||||
return new ModelAndView("namelogin");
|
||||
/*String j_username= request.getParameter("username");
|
||||
List<User> userList=userService.selectListByWhere(" where name='"+j_username+"'");
|
||||
if(userList.size() >0 && null!=userList){
|
||||
User cu = userService.getUserById(userList.get(0).getId());
|
||||
String unitId = "";
|
||||
if (null != cu) {
|
||||
//设置cu其他信息
|
||||
cu.setCurrentip(request.getRemoteAddr());
|
||||
cu.setLastlogintime(CommUtil.nowDate());
|
||||
|
||||
UserDetail userDetail = this.userDetailService.selectByUserId(cu.getId());
|
||||
cu.setUserDetail(userDetail);
|
||||
if(cu.getThemeclass()==null || cu.getThemeclass().isEmpty()){
|
||||
cu.setThemeclass(CommString.Default_Theme);
|
||||
}
|
||||
Company company =unitService.getCompanyByUserId(cu.getId());
|
||||
if (company!=null) {
|
||||
cu.set_pname(company.getSname());
|
||||
unitId = company.getId();
|
||||
}else{
|
||||
//cu.set_pname("平台");
|
||||
List<Company> companies = unitService.getCompaniesByWhere("where pid='-1' and type='C'");
|
||||
if(companies!=null){
|
||||
cu.set_pname(companies.get(0).getSname());
|
||||
unitId = companies.get(0).getId();
|
||||
}
|
||||
}
|
||||
//设置session
|
||||
HttpSession newSession = request.getSession(true);
|
||||
newSession.setAttribute("cu", cu);
|
||||
newSession.setAttribute("unitId", unitId);
|
||||
|
||||
|
||||
String result ="{\"status\":" + true +",\"res\":"+ JSONObject.toJSONString(cu) +"}";
|
||||
JSONObject jsonObject =JSONObject.parseObject(result);
|
||||
request.setAttribute("result", jsonObject);
|
||||
|
||||
JSONObject jsob = JSONObject.fromObject(cu);
|
||||
request.setAttribute("result", "{\"result\":\"pass\",\"re1\":" +
|
||||
jsob.toString() + "}");
|
||||
jsob=null;
|
||||
|
||||
HttpSession session = request.getSession(false);
|
||||
if (SessionManager.isOnline(session)){
|
||||
return new ModelAndView("frameset");
|
||||
}else{
|
||||
return new ModelAndView("login");
|
||||
}
|
||||
} else {
|
||||
return new ModelAndView("login");
|
||||
}
|
||||
}else{
|
||||
return new ModelAndView("login");
|
||||
}*/
|
||||
}
|
||||
|
||||
@RequestMapping(value = "loginscadato.do")
|
||||
public ModelAndView loginscadato(HttpServletRequest request,
|
||||
HttpServletResponse response,Model model) {
|
||||
String j_username= request.getParameter("user");
|
||||
User cu = new User();
|
||||
if(j_username!=null && !j_username.equals("")){
|
||||
cu= loginService.NameLogin(j_username);
|
||||
}
|
||||
if (null != cu){
|
||||
((HttpServletRequest) request).getSession().setAttribute("cu", cu);
|
||||
model.addAttribute("cu", cu);
|
||||
return new ModelAndView("main");
|
||||
}
|
||||
String result = "对不起,您暂时没有权限进入该系统";
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅获取app的名称,app调用的接口
|
||||
* @param request
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getApkName.do")
|
||||
public String getApkName(HttpServletRequest request,Model model){
|
||||
String contextPath=request.getContextPath().replace("/", "");
|
||||
String filepathSever=request.getSession().getServletContext().getRealPath("");
|
||||
String webName = request.getServletContext().getContextPath().replace("/", "");
|
||||
String filepath=filepathSever.replaceAll(contextPath, webName+"_APK");
|
||||
System.out.println("app下载路径::"+filepath);
|
||||
File file = new File(filepath);
|
||||
File[] tempList = file.listFiles();
|
||||
String vesionInfo = "";
|
||||
if(tempList!=null){
|
||||
if(tempList.length>0) {
|
||||
for (int i = 0; i < tempList.length; i++) {
|
||||
if (tempList[i].getName().toLowerCase().contains("apk")) {
|
||||
try {
|
||||
vesionInfo = tempList[i].getName();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// TODO: handle exception
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
System.out.println("app下载路径:文件夹为空");
|
||||
}
|
||||
}else{
|
||||
System.out.println("app下载路径:没有找到文件夹");
|
||||
}
|
||||
String result = "{\"ApkName\":\""+vesionInfo+"\"}";
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
/**
|
||||
* 获取apkurl地址
|
||||
* @param mapping
|
||||
* @param form
|
||||
* @param request
|
||||
* @param response
|
||||
* @return ActionForward
|
||||
*/
|
||||
@RequestMapping(value = "doScanApk.do")
|
||||
public ModelAndView doScanApk(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model){
|
||||
String type =request.getParameter("type");
|
||||
String contextPath=request.getContextPath().replace("/", "");
|
||||
String filepathSever=request.getSession().getServletContext().getRealPath("");
|
||||
|
||||
String webName = request.getServletContext().getContextPath().replace("/", "");
|
||||
|
||||
String filepath=filepathSever.replaceAll(contextPath, webName+"_APK/"+type);
|
||||
File file=new File(filepath);
|
||||
File[] tempList = file.listFiles();
|
||||
if(tempList==null || tempList.length==0){
|
||||
model.addAttribute("result","");
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
String fileName="";
|
||||
String veisioninfo="";
|
||||
int versionOne=0;
|
||||
int versionTwo=0;
|
||||
for (int i = 0; i < tempList.length; i++) {
|
||||
if (tempList[i].getName().toLowerCase().contains("apk")) {
|
||||
//版本号
|
||||
veisioninfo=tempList[i].getName().split("-")[1];
|
||||
String[] veision = veisioninfo.split("\\.");
|
||||
//判断版本号
|
||||
if(versionOne < Integer.parseInt(veision[0])){
|
||||
versionOne = Integer.parseInt(veision[0]);
|
||||
versionTwo = Integer.parseInt(veision[1]);
|
||||
fileName = tempList[i].getName();
|
||||
}else{
|
||||
if(versionTwo < Integer.parseInt(veision[1])){
|
||||
versionTwo = Integer.parseInt(veision[1]);
|
||||
fileName = tempList[i].getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
/*System.out.println(tempList[i].getName().toString());
|
||||
if (tempList[i].getName().toLowerCase().contains("apk")) {
|
||||
try {
|
||||
String code=tempList[i].getName().split("-")[1];
|
||||
String name=tempList[i].getName().split("-")[2];
|
||||
veisioninfo=tempList[i].getName();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
String urlstr=request.getRequestURL().substring(0, request.getRequestURL().indexOf(contextPath))+webName+"_APK/"+type+"/";
|
||||
veisioninfo=urlstr+fileName;
|
||||
String result = "{\"res\":\"" + veisioninfo + "\"}";
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("downLoadAPP.do")
|
||||
public void downLoadAPP(HttpServletRequest request,HttpServletResponse response,String path){
|
||||
File file = new File(path);
|
||||
if(file.exists()){
|
||||
File[] files=file.listFiles();
|
||||
if(files.length > 0 &&!files[0].isDirectory()){
|
||||
String fileName=files[0].getName();
|
||||
String abspath=files[0].getAbsolutePath();
|
||||
BufferedInputStream bis = null;
|
||||
BufferedOutputStream bos = null;
|
||||
try {
|
||||
response.reset();
|
||||
response.setContentType("applicatoin/octet-stream");
|
||||
response.setHeader("Content-disposition", "attachment; filename="
|
||||
+ URLEncoder.encode(fileName, "UTF-8"));
|
||||
bis = new BufferedInputStream(new FileInputStream(abspath));
|
||||
bos = new BufferedOutputStream(response.getOutputStream());
|
||||
byte[] buff = new byte[1024];
|
||||
int bytesRead;
|
||||
while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
|
||||
bos.write(buff, 0, bytesRead);
|
||||
}
|
||||
bos.flush();
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if(null!=bis){
|
||||
bis.close();
|
||||
}
|
||||
if(null!=bos){
|
||||
bos.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//bis = null;
|
||||
//bos = null;
|
||||
}
|
||||
//System.out.println(abspath+"路径================");
|
||||
//System.out.println(fileName+"文件================");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 获取ya
|
||||
* @param request
|
||||
* @param response
|
||||
* @return ActionForward
|
||||
*/
|
||||
@SneakyThrows
|
||||
@RequestMapping(value = "doVerifyCode.do")
|
||||
public void doVerifyCode(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model) throws Exception {
|
||||
int verCodeStrengthNum=0;
|
||||
int codenumber = 4;
|
||||
//生成图片
|
||||
int w = 110, h = 34;
|
||||
BasicComponentsService basicComponentsService = (BasicComponentsService) SpringContextUtil.getBean("basicComponentsService");
|
||||
List<BasicComponents> verCodeStrengthList = basicComponentsService.selectListByWhere("where active='1' and code like '%login-verCode-strength%' order by morder");
|
||||
if (verCodeStrengthList != null && verCodeStrengthList.size() > 0) {
|
||||
BasicComponents verCodeStrength = verCodeStrengthList.get(0);
|
||||
if(verCodeStrength!=null && verCodeStrength.getBasicConfigure()!=null && !verCodeStrength.getBasicConfigure().getType().isEmpty()){
|
||||
verCodeStrengthNum = Integer.parseInt(verCodeStrength.getBasicConfigure().getType());
|
||||
}
|
||||
}
|
||||
//生成随机字串
|
||||
String verifyCode = "";
|
||||
if(verCodeStrengthNum==0){
|
||||
codenumber=4;
|
||||
w = 100;
|
||||
h = 34;
|
||||
verifyCode = VerifyCodeUtils.generateVerifyCode(codenumber);
|
||||
}else{
|
||||
codenumber=6;
|
||||
w = 110;
|
||||
h = 34;
|
||||
verifyCode = VerifyCodeUtils.generateVerifyAllCode(codenumber);
|
||||
}
|
||||
String res = null;
|
||||
try {
|
||||
res = CommUtil.encryptAES(verifyCode,"base64");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//存入会话session
|
||||
HttpSession session = request.getSession(true);
|
||||
//删除以前的
|
||||
session.removeAttribute("verCode");
|
||||
session.setAttribute("verCode", verifyCode.toLowerCase());
|
||||
String result = "{\"res\":\"" + res + "\"}";
|
||||
model.addAttribute("result",result);
|
||||
Object sessionverCode = session.getAttribute("verCode");
|
||||
System.out.println("sessionNewVerCode:"+sessionverCode.toString());
|
||||
|
||||
response.setContentType("text/html");
|
||||
request.setCharacterEncoding("UTF-8");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
out.write(result);
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
176
src/main/java/com/sipai/controller/app/MsgAppController.java
Normal file
176
src/main/java/com/sipai/controller/app/MsgAppController.java
Normal file
@ -0,0 +1,176 @@
|
||||
package com.sipai.controller.app;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.msg.Msg;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.base.LoginService;
|
||||
import com.sipai.service.msg.MsgRecvService;
|
||||
import com.sipai.service.msg.MsgRecvServiceImpl;
|
||||
import com.sipai.service.msg.MsgServiceImpl;
|
||||
import com.sipai.service.msg.MsgTypeService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(value = "msgapp")
|
||||
public class MsgAppController {
|
||||
|
||||
@Resource
|
||||
private LoginService loginService;
|
||||
@Resource
|
||||
private MsgRecvServiceImpl msgrecvService;
|
||||
@Resource
|
||||
private MsgServiceImpl msgService;
|
||||
@Resource
|
||||
private MsgTypeService msgtypeService;
|
||||
@RequestMapping("/getlist.do")
|
||||
public ModelAndView getlist(HttpServletRequest request,Model model) {
|
||||
String j_username= request.getParameter("username");
|
||||
String j_password= request.getParameter("pwd");
|
||||
User cu = new User();
|
||||
if(j_username!=null && j_password!=null){
|
||||
cu= loginService.Login(j_username, j_password);
|
||||
}
|
||||
if(cu==null){
|
||||
model.addAttribute("result","");
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
int pages = 0;
|
||||
if(request.getParameter("page")!=null&&!request.getParameter("page").isEmpty()){
|
||||
pages = Integer.parseInt(request.getParameter("page"));
|
||||
}else {
|
||||
pages = 1;
|
||||
}
|
||||
int pagesize = 0;
|
||||
if(request.getParameter("rows")!=null&&!request.getParameter("rows").isEmpty()){
|
||||
pagesize = Integer.parseInt(request.getParameter("rows"));
|
||||
}else {
|
||||
pagesize = 20;
|
||||
}
|
||||
String sort="";
|
||||
if(request.getParameter("sort")!=null&&!request.getParameter("sort").isEmpty()
|
||||
&&!request.getParameter("sort").equals("mrecv")&&!request.getParameter("sort").equals("susername")
|
||||
&&!request.getParameter("sort").equals("typename")){
|
||||
sort = request.getParameter("sort");
|
||||
}else if(request.getParameter("sort")!=null&&request.getParameter("sort").equals("mrecv")){
|
||||
sort = " V.status ";
|
||||
}else if(request.getParameter("sort")!=null&&request.getParameter("sort").equals("susername")){
|
||||
sort = " U.caption ";
|
||||
}else if(request.getParameter("sort")!=null&&request.getParameter("sort").equals("typename")){
|
||||
sort = " T.name ";
|
||||
}else{
|
||||
sort = " M.insdt ";
|
||||
}
|
||||
String order="";
|
||||
if(request.getParameter("order")!=null&&!request.getParameter("order").isEmpty()){
|
||||
order = request.getParameter("order");
|
||||
}else {
|
||||
order = " desc ";
|
||||
}
|
||||
String orderstr=" order by "+sort+" "+order;
|
||||
|
||||
String wherestr=CommUtil.getwherestr("M.insuser", "msg/getMsgrecv.do", cu);
|
||||
wherestr+=" and M.issms!='sms' and M.delflag!='TRUE' and V.delflag!='TRUE' and V.unitid='"+cu.getId()+"' ";
|
||||
if(request.getParameter("search_susername")!=null && !request.getParameter("search_susername").isEmpty()){
|
||||
wherestr += "and U.caption like '%"+request.getParameter("search_susername")+"%' ";
|
||||
}
|
||||
if(request.getParameter("search_content")!=null && !request.getParameter("search_content").isEmpty()){
|
||||
wherestr += "and M.content like '%"+request.getParameter("search_content")+"%' ";
|
||||
}
|
||||
if(request.getParameter("sdt")!=null && !request.getParameter("sdt").isEmpty()){
|
||||
wherestr += "and M.sdt>= '"+request.getParameter("sdt")+"' ";
|
||||
}
|
||||
if(request.getParameter("edt")!=null && !request.getParameter("edt").isEmpty()){
|
||||
wherestr += "and M.sdt<= '"+request.getParameter("edt")+"' ";
|
||||
}
|
||||
|
||||
|
||||
PageHelper.startPage(pages, pagesize);
|
||||
List<Msg> list = this.msgService.getMsgrecv(wherestr+orderstr);
|
||||
PageInfo<Msg> page = new PageInfo<Msg>(list);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
String result1="{\"pi\":[{\"pageNum\":\""+page.getPageNum()+"\",\"pageCount\":\""+page.getPages()+"\"}],\"re1\":"+json+"}";
|
||||
String result="{\"total\":"+page.getTotal()+",\"re1\":"+json+"}";
|
||||
model.addAttribute("result",result1);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
@RequestMapping("/delete.do")
|
||||
public ModelAndView dodel(HttpServletRequest request,Model model){
|
||||
String id= request.getParameter("id");
|
||||
String setandwhere=" set delflag='TRUE' where masterid='"+id+"'";
|
||||
int result = this.msgrecvService.updateMsgRecvBySetAndWhere(setandwhere);
|
||||
if (result==1) { //由于触发器的存在 ,有时候更新成功返回也为0
|
||||
request.setAttribute("result", "{\"result\":\"yes\"}");
|
||||
} else {
|
||||
request.setAttribute("result", "{\"result\":\"no\"}");
|
||||
}
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
@RequestMapping("/viewMsg.do")
|
||||
public ModelAndView viewMsg(HttpServletRequest request,Model model){
|
||||
String j_userid= request.getParameter("userid");
|
||||
String msgId = request.getParameter("id");
|
||||
String orderstr=" order by M.insdt ";
|
||||
String wherestr="where 1=1";
|
||||
wherestr+=" and M.id='"+msgId+"' and V.delflag!='TRUE' and V.unitid='"+j_userid+"' ";
|
||||
List<Msg> list = this.msgService.getMsgrecv(wherestr+orderstr);
|
||||
int result=0;
|
||||
if(request.getParameter("send")==null){
|
||||
String readstatus=list.get(0).getMrecv().get(0).getStatus();
|
||||
if(readstatus.equals("U")){
|
||||
//第一次浏览
|
||||
String setandwhere=" set status='R' ,readtime= '"+CommUtil.nowDate()+"' where id='"+list.get(0).getMrecv().get(0).getId()+"' ";
|
||||
result=this.msgrecvService.updateMsgRecvBySetAndWhere(setandwhere);
|
||||
}
|
||||
}
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
/**为亿美短信方式保存消息和手机短信
|
||||
* @return result 发送成功,发送失败,无权限
|
||||
*/
|
||||
@RequestMapping("/saveMsgYM.do")
|
||||
public String saveMsgYM(HttpServletRequest request,Model model){
|
||||
String j_username= request.getParameter("username");
|
||||
String j_password= request.getParameter("pwd");
|
||||
User cu = new User();
|
||||
if(j_username!=null && j_password!=null){
|
||||
cu= loginService.Login(j_username, j_password);
|
||||
}
|
||||
if(cu==null){
|
||||
model.addAttribute("result","{\"res\":\"0\"}");
|
||||
return "result";
|
||||
}
|
||||
String mtypeid="";
|
||||
String result="";
|
||||
String mtypename=request.getParameter("mtypename");
|
||||
mtypeid=this.msgtypeService.getMsgType(" where name='"+mtypename+"'").get(0).getId();
|
||||
//String msgtype=request.getParameter("mtype");
|
||||
String content=request.getParameter("content");
|
||||
String recvid=request.getParameter("recvid");
|
||||
String cuid=cu.getId();
|
||||
result=this.msgService.insertMsgSend(mtypeid,content,recvid,cuid,"0");
|
||||
String resstr="{\"res\":\""+result+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
93
src/main/java/com/sipai/controller/app/ProAppController.java
Normal file
93
src/main/java/com/sipai/controller/app/ProAppController.java
Normal file
@ -0,0 +1,93 @@
|
||||
package com.sipai.controller.app;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.google.gson.Gson;
|
||||
import com.sipai.entity.document.Data;
|
||||
import com.sipai.entity.msg.Msg;
|
||||
import com.sipai.entity.timeefficiency.PatrolType;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.entity.work.Group;
|
||||
import com.sipai.entity.work.GroupMember;
|
||||
import com.sipai.service.base.LoginService;
|
||||
import com.sipai.service.maintenance.MaintainerService;
|
||||
import com.sipai.service.msg.MsgRecvService;
|
||||
import com.sipai.service.msg.MsgServiceImpl;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.service.work.GroupManageService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(value = "proapp")
|
||||
public class ProAppController {
|
||||
|
||||
@Resource
|
||||
private LoginService loginService;
|
||||
@Resource
|
||||
private MaintainerService maintainerService;
|
||||
|
||||
/**
|
||||
* 获取运维商运维厂区的负责人
|
||||
**/
|
||||
@RequestMapping("getMaintainerLeaders.do")
|
||||
public String getMaintainerLeaders(HttpServletRequest request, Model model) {
|
||||
String companyIds = request.getParameter("companyIds");
|
||||
String maintainerId = request.getParameter("maintainerId");
|
||||
List<User> users = this.maintainerService.getMaintainerLeaders(companyIds, maintainerId);
|
||||
model.addAttribute("result", JSONArray.fromObject(users));
|
||||
return "result";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取运维商运维厂区的联系人
|
||||
**/
|
||||
@RequestMapping("getCompanyContacters.do")
|
||||
public String getCompanyContacters(HttpServletRequest request, Model model) {
|
||||
String companyIds = request.getParameter("companyIds");
|
||||
String maintainerId = request.getParameter("maintainerId");
|
||||
List<User> users = this.maintainerService.getCompanyContacters(companyIds, maintainerId);
|
||||
model.addAttribute("result", JSONArray.fromObject(users));
|
||||
return "result";
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示水厂统计图
|
||||
*/
|
||||
/*@RequestMapping("/showBizStatisticalChart.do")
|
||||
public String showBizStatisticalChart(HttpServletRequest request,Model model){
|
||||
|
||||
return "maintenance/statisticalchart/bizStatisticalChart";
|
||||
}*/
|
||||
|
||||
@RequestMapping("saveWorkerPosition.do")
|
||||
public String saveWorkerPosition(HttpServletRequest request, Model model) {
|
||||
String userId = request.getParameter("userId");
|
||||
String latitude = request.getParameter("latitude");
|
||||
String longitude = request.getParameter("longitude");
|
||||
|
||||
|
||||
|
||||
model.addAttribute("result", JSONArray.fromObject(null));
|
||||
return "result";
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,101 @@
|
||||
package com.sipai.controller.base;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.xhtmlrenderer.extend.FSImage;
|
||||
import org.xhtmlrenderer.extend.ReplacedElement;
|
||||
import org.xhtmlrenderer.extend.ReplacedElementFactory;
|
||||
import org.xhtmlrenderer.extend.UserAgentCallback;
|
||||
import org.xhtmlrenderer.layout.LayoutContext;
|
||||
import org.xhtmlrenderer.pdf.ITextFSImage;
|
||||
import org.xhtmlrenderer.pdf.ITextImageElement;
|
||||
import org.xhtmlrenderer.render.BlockBox;
|
||||
import org.xhtmlrenderer.simple.extend.FormSubmissionListener;
|
||||
|
||||
|
||||
import com.lowagie.text.BadElementException;
|
||||
import com.lowagie.text.Image;
|
||||
import com.lowagie.text.pdf.codec.Base64;
|
||||
/**
|
||||
* 图片base64支持,把图片转换为itext自己的图片对象
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
public class Base64ImgReplacedElementFactory implements ReplacedElementFactory {
|
||||
|
||||
|
||||
/**
|
||||
* 实现createReplacedElement 替换html中的Img标签
|
||||
*
|
||||
* @param c 上下文
|
||||
* @param box 盒子
|
||||
* @param uac 回调
|
||||
* @param cssWidth css宽
|
||||
* @param cssHeight css高
|
||||
* @return ReplacedElement
|
||||
*/
|
||||
public ReplacedElement createReplacedElement(LayoutContext c, BlockBox box, UserAgentCallback uac,
|
||||
int cssWidth, int cssHeight) {
|
||||
Element e = box.getElement();
|
||||
if (e == null) {
|
||||
return null;
|
||||
}
|
||||
String nodeName = e.getNodeName();
|
||||
// 找到img标签
|
||||
if (nodeName.equals("img")) {
|
||||
String attribute = e.getAttribute("src");
|
||||
FSImage fsImage;
|
||||
try {
|
||||
// 生成itext图像
|
||||
fsImage = buildImage(attribute, uac);
|
||||
} catch (BadElementException e1) {
|
||||
fsImage = null;
|
||||
} catch (IOException e1) {
|
||||
fsImage = null;
|
||||
}
|
||||
if (fsImage != null) {
|
||||
// 对图像进行缩放
|
||||
if (cssWidth != -1 || cssHeight != -1) {
|
||||
fsImage.scale(cssWidth, cssHeight);
|
||||
}
|
||||
return new ITextImageElement(fsImage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 编解码base64并生成itext图像
|
||||
*/
|
||||
protected FSImage buildImage(String srcAttr, UserAgentCallback uac) throws IOException,
|
||||
BadElementException {
|
||||
FSImage fiImg=null;
|
||||
if (srcAttr.toLowerCase().startsWith("data:image/")) {
|
||||
String base64Code= srcAttr.substring(srcAttr.indexOf("base64,") + "base64,".length(),
|
||||
srcAttr.length());
|
||||
// 解码
|
||||
byte[] decodedBytes = Base64.decode(base64Code);
|
||||
|
||||
|
||||
fiImg= new ITextFSImage(Image.getInstance(decodedBytes));
|
||||
} else {
|
||||
fiImg= uac.getImageResource(srcAttr).getImage();
|
||||
}
|
||||
return fiImg;
|
||||
}
|
||||
|
||||
|
||||
public void reset() {}
|
||||
|
||||
@Override
|
||||
public void remove(Element arg0) {}
|
||||
|
||||
@Override
|
||||
public void setFormSubmissionListener(FormSubmissionListener arg0) {}
|
||||
|
||||
}
|
||||
@ -0,0 +1,154 @@
|
||||
package com.sipai.controller.base;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.base.BasicComponents;
|
||||
import com.sipai.entity.scada.MPoint4APP;
|
||||
import com.sipai.entity.user.Company;
|
||||
import com.sipai.entity.user.Unit;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.base.BasicComponentsService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.tools.CommString;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/base/basicComponents")
|
||||
public class BasicComponentsController {
|
||||
@Resource
|
||||
private BasicComponentsService basicComponentsService;
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
@RequestMapping("/showlist.do")
|
||||
public String showlist(HttpServletRequest request,Model model) {
|
||||
return "/base/basicComponentsManage";
|
||||
}
|
||||
@RequestMapping("/getlist.do")
|
||||
public ModelAndView getlist(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required=false) String sort,
|
||||
@RequestParam(value = "order", required=false) String order) {
|
||||
User cu=(User)request.getSession().getAttribute("cu");
|
||||
String orderstr=" order by morder asc";
|
||||
|
||||
String wherestr=" where 1=1 ";
|
||||
if (request.getParameter("type")!=null && !request.getParameter("type").toString().isEmpty()) {
|
||||
wherestr+= " and type ='"+request.getParameter("type").toString()+"' ";
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<BasicComponents> list = this.basicComponentsService.selectListByWhere(wherestr+orderstr);
|
||||
|
||||
PageInfo<BasicComponents> pi = new PageInfo<BasicComponents>(list);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
|
||||
String result="{\"total\":"+pi.getTotal()+",\"rows\":"+json+"}";
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
@RequestMapping("/add.do")
|
||||
public String doadd(HttpServletRequest request,Model model){
|
||||
String basicComponentsTypeId= request.getParameter("id");
|
||||
request.setAttribute("basicComponentsTypeId", basicComponentsTypeId);
|
||||
return "base/basicComponentsAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/edit.do")
|
||||
public String doedit(HttpServletRequest request,Model model){
|
||||
String groupId = request.getParameter("id");
|
||||
BasicComponents basicComponents = this.basicComponentsService.selectById(groupId);
|
||||
model.addAttribute("basicComponents", basicComponents);
|
||||
if(basicComponents.getPid()!=null && basicComponents.getPid().equals("")){
|
||||
BasicComponents parent = this.basicComponentsService.selectById(basicComponents.getPid());
|
||||
if(parent != null){
|
||||
model.addAttribute("pname",parent.getName());
|
||||
}else{
|
||||
model.addAttribute("pname","");
|
||||
}
|
||||
}else{
|
||||
model.addAttribute("pname","");
|
||||
}
|
||||
return "base/basicComponentsEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/save.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute BasicComponents basicComponents){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
String id = CommUtil.getUUID();
|
||||
basicComponents.setId(id);
|
||||
basicComponents.setInsuser(cu.getId());
|
||||
basicComponents.setInsdt(CommUtil.nowDate());
|
||||
|
||||
int result =this.basicComponentsService.save(basicComponents);
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+id+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
@RequestMapping("/update.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute BasicComponents basicComponents){
|
||||
int result = this.basicComponentsService.update(basicComponents);
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+basicComponents.getId()+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/delete.do")
|
||||
public String dodel(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id){
|
||||
int result = this.basicComponentsService.deleteById(id);
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/deletes.do")
|
||||
public String dodels(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="ids") String ids){
|
||||
ids=ids.replace(",","','");
|
||||
int result = this.basicComponentsService.deleteByWhere("where id in ('"+ids+"')");
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
/**
|
||||
* 获取树状结构
|
||||
*/
|
||||
@RequestMapping("/getBasicComponentsForTree.do")
|
||||
public String getBasicComponentsForTree(HttpServletRequest request,Model model){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
//获取非用户节点树(公司 水厂 部门)
|
||||
List<BasicComponents> list = this.basicComponentsService.selectListByWhere("order by morder");
|
||||
String json = basicComponentsService.getTreeList(null, list);
|
||||
model.addAttribute("result", json);
|
||||
return "result";
|
||||
}
|
||||
/**
|
||||
* 获取已配置内容
|
||||
*/
|
||||
@RequestMapping("/getBasicComponentsForCode.do")
|
||||
public String getBasicComponentsForCode(HttpServletRequest request,Model model){
|
||||
String code = request.getParameter("code");
|
||||
com.alibaba.fastjson.JSONArray jsonArray = this.basicComponentsService.selectListByWhereAll("where active='1' and code like '%"+code+"%' ");
|
||||
if(jsonArray!=null && jsonArray.size()>0){
|
||||
model.addAttribute("result", jsonArray);
|
||||
}else{
|
||||
model.addAttribute("result", null);
|
||||
}
|
||||
return "result";
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,127 @@
|
||||
package com.sipai.controller.base;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.base.BasicConfigure;
|
||||
import com.sipai.entity.scada.MPoint4APP;
|
||||
import com.sipai.entity.user.Company;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.base.BasicConfigureService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.tools.CommString;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/base/basicConfigure")
|
||||
public class BasicConfigureController {
|
||||
@Resource
|
||||
private BasicConfigureService basicConfigureService;
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
@RequestMapping("/showlist.do")
|
||||
public String showlist(HttpServletRequest request,Model model) {
|
||||
return "/base/basicConfigureManage";
|
||||
}
|
||||
@RequestMapping("/getlist.do")
|
||||
public ModelAndView getlist(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required=false) String sort,
|
||||
@RequestParam(value = "order", required=false) String order) {
|
||||
User cu=(User)request.getSession().getAttribute("cu");
|
||||
// if(cu==null){
|
||||
// cu=loginService.Login(request.getParameter("username"), request.getParameter("pwd"));
|
||||
// }
|
||||
String orderstr=" order by morder asc";
|
||||
|
||||
String wherestr=" where 1=1 ";
|
||||
if (request.getParameter("pid")!=null && !request.getParameter("pid").toString().isEmpty()) {
|
||||
wherestr+= " and pid ='"+request.getParameter("pid").toString()+"' ";
|
||||
}
|
||||
if (request.getParameter("type")!=null && !request.getParameter("type").toString().isEmpty()) {
|
||||
wherestr+= " and type ='"+request.getParameter("type").toString()+"' ";
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<BasicConfigure> list = this.basicConfigureService.selectListByWhere(wherestr+orderstr);
|
||||
|
||||
PageInfo<BasicConfigure> pi = new PageInfo<BasicConfigure>(list);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
|
||||
String result="{\"total\":"+pi.getTotal()+",\"rows\":"+json+"}";
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
@RequestMapping("/add.do")
|
||||
public String doadd(HttpServletRequest request,Model model){
|
||||
String companyId= request.getParameter("bizId");
|
||||
String basicConfigureTypeId= request.getParameter("id");
|
||||
Company company = this.unitService.getCompById(companyId);
|
||||
request.setAttribute("company", company);
|
||||
request.setAttribute("basicConfigureTypeId", basicConfigureTypeId);
|
||||
//request.setAttribute("list",list);
|
||||
return "base/basicConfigureAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/edit.do")
|
||||
public String doedit(HttpServletRequest request,Model model){
|
||||
String groupId = request.getParameter("id");
|
||||
BasicConfigure basicConfigure = this.basicConfigureService.selectById(groupId);
|
||||
model.addAttribute("basicConfigure", basicConfigure);
|
||||
return "base/basicConfigureEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/save.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute BasicConfigure basicConfigure){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
String id = CommUtil.getUUID();
|
||||
basicConfigure.setId(id);
|
||||
basicConfigure.setInsuser(cu.getId());
|
||||
basicConfigure.setInsdt(CommUtil.nowDate());
|
||||
|
||||
int result =this.basicConfigureService.save(basicConfigure);
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+id+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
@RequestMapping("/update.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute BasicConfigure basicConfigure){
|
||||
int result = this.basicConfigureService.update(basicConfigure);
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+basicConfigure.getId()+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/delete.do")
|
||||
public String dodel(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id){
|
||||
int result = this.basicConfigureService.deleteById(id);
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/deletes.do")
|
||||
public String dodels(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="ids") String ids){
|
||||
ids=ids.replace(",","','");
|
||||
int result = this.basicConfigureService.deleteByWhere("where id in ('"+ids+"')");
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,215 @@
|
||||
package com.sipai.controller.base;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.user.Unit;
|
||||
import com.sipai.service.company.CompanyService;
|
||||
import com.sipai.tools.CommString;
|
||||
import net.sf.json.JSONArray;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.base.BasicHomePage;
|
||||
import com.sipai.entity.user.Company;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.base.BasicHomePageService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/base/basicHomePage")
|
||||
public class BasicHomePageController {
|
||||
@Resource
|
||||
private BasicHomePageService basicHomePageService;
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
|
||||
@RequestMapping("/showlist.do")
|
||||
public String showlist(HttpServletRequest request, Model model) {
|
||||
return "/base/basicHomePageManage";
|
||||
}
|
||||
|
||||
@RequestMapping("/getlist.do")
|
||||
public ModelAndView getlist(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required = false) String sort,
|
||||
@RequestParam(value = "order", required = false) String order) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
// if(cu==null){
|
||||
// cu=loginService.Login(request.getParameter("username"), request.getParameter("pwd"));
|
||||
// }
|
||||
String orderstr = " order by morder asc";
|
||||
|
||||
String wherestr = " where 1=1 ";
|
||||
if (request.getParameter("pid") != null && !request.getParameter("pid").toString().isEmpty()) {
|
||||
wherestr += " and pid ='" + request.getParameter("pid").toString() + "' ";
|
||||
}
|
||||
if (request.getParameter("type") != null && !request.getParameter("type").toString().isEmpty()) {
|
||||
wherestr += " and type ='" + request.getParameter("type").toString() + "' ";
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<BasicHomePage> list = this.basicHomePageService.selectListByWhere(wherestr + orderstr);
|
||||
|
||||
PageInfo<BasicHomePage> pi = new PageInfo<BasicHomePage>(list);
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
|
||||
String result = "{\"total\":" + pi.getTotal() + ",\"rows\":" + json + "}";
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/getJsonByUserId.do")
|
||||
public ModelAndView getJsonByUserId(HttpServletRequest request, Model model) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
|
||||
String userId = cu.getId();
|
||||
String unitId = request.getParameter("unitId");
|
||||
// System.out.println("unitId==="+unitId);
|
||||
//分四步 1个人当前厂是否配置 2个人全局是否配置 3系统当前厂是否配置 4系统全局是否配置
|
||||
List<BasicHomePage> list = this.basicHomePageService.selectListByWhere(" where userid='" + userId + "' and unitId='" + unitId + "' and type='" + BasicHomePage.Type_Personal + "' and active='" + CommString.Active_True + "' ");
|
||||
if (list.size() == 0) {
|
||||
list = this.basicHomePageService.selectListByWhere(" where userid='" + userId + "' and unitId='all' and type='" + BasicHomePage.Type_Personal + "' and active='" + CommString.Active_True + "' ");
|
||||
if (list.size() == 0) {
|
||||
list = this.basicHomePageService.selectListByWhere(" where unitId='" + unitId + "' and type='" + BasicHomePage.Type_Sys + "' and active='" + CommString.Active_True + "' ");
|
||||
if (list.size() == 0) {
|
||||
list = this.basicHomePageService.selectListByWhere(" where unitId='all' and type='" + BasicHomePage.Type_Sys + "' and active='" + CommString.Active_True + "' ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jsonObject.put("data", list);
|
||||
jsonObject.put("userId", userId);
|
||||
|
||||
model.addAttribute("result", jsonObject);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/add.do")
|
||||
public String doadd(HttpServletRequest request, Model model) {
|
||||
|
||||
return "base/basicHomePageAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/roleManage.do")
|
||||
public String roleManage(HttpServletRequest request, Model model) {
|
||||
|
||||
return "base/basicHomePageRoleManage";
|
||||
}
|
||||
|
||||
@RequestMapping("/roleEdit.do")
|
||||
public String roleEdit(HttpServletRequest request, Model model) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String unitId = request.getParameter("unitId");
|
||||
List<BasicHomePage> list = this.basicHomePageService.selectListByWhere(" where unitId='" + unitId + "' and userid='emp01' ");
|
||||
|
||||
if (list != null && list.size() > 0) {
|
||||
model.addAttribute("basicHomePage", list.get(0));
|
||||
return "base/basicHomePageRoleEdit";
|
||||
} else {
|
||||
return "base/basicHomePageAdd";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping("/edit.do")
|
||||
public String doedit(HttpServletRequest request, Model model) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String unitId = request.getParameter("unitId");
|
||||
List<BasicHomePage> list = this.basicHomePageService.selectListByWhere(" where unitId='" + unitId + "' and userid='" + cu.getId() + "' ");
|
||||
|
||||
model.addAttribute("userId", cu.getId());
|
||||
if (list != null && list.size() > 0) {
|
||||
model.addAttribute("basicHomePage", list.get(0));
|
||||
return "base/basicHomePageEdit";
|
||||
} else {
|
||||
return "base/basicHomePageAdd";
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/save.do")
|
||||
public String dosave(HttpServletRequest request, Model model,
|
||||
@ModelAttribute BasicHomePage basicHomePage) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String id = CommUtil.getUUID();
|
||||
basicHomePage.setId(id);
|
||||
basicHomePage.setUserid(cu.getId());
|
||||
if (cu.getId().equals("emp01")) {
|
||||
basicHomePage.setType(BasicHomePage.Type_Sys);
|
||||
} else {
|
||||
basicHomePage.setType(BasicHomePage.Type_Personal);
|
||||
}
|
||||
|
||||
int result = this.basicHomePageService.save(basicHomePage);
|
||||
String resstr = "{\"res\":\"" + result + "\",\"id\":\"" + id + "\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/update.do")
|
||||
public String doupdate(HttpServletRequest request, Model model,
|
||||
@ModelAttribute BasicHomePage basicHomePage) {
|
||||
int result = this.basicHomePageService.update(basicHomePage);
|
||||
String resstr = "{\"res\":\"" + result + "\",\"id\":\"" + basicHomePage.getId() + "\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/delete.do")
|
||||
public String dodel(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
int res = this.basicHomePageService.deleteById(id);
|
||||
if (res == 1) {
|
||||
Result result = Result.success(res);
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
} else {
|
||||
Result result = Result.failed("保存失败");
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
}
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/deletes.do")
|
||||
public String dodels(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "ids") String ids) {
|
||||
ids = ids.replace(",", "','");
|
||||
int result = this.basicHomePageService.deleteByWhere("where id in ('" + ids + "')");
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取树状结构
|
||||
*/
|
||||
@RequestMapping("/getBasicHomePageForTree.do")
|
||||
public String getBasicHomePageForTree(HttpServletRequest request, Model model) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String unitId = request.getParameter("unitId");
|
||||
//获取非用户节点树(公司 水厂 部门)
|
||||
List<Unit> list = this.unitService.getParentCompanyChildrenBizByUnitid(unitId);
|
||||
String json = basicHomePageService.getTreeList(null, list);
|
||||
model.addAttribute("result", json);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/showNoRole.do")
|
||||
public String showNoRole(HttpServletRequest request, Model model) {
|
||||
|
||||
return "base/basicHomePageNoRole";
|
||||
}
|
||||
}
|
||||
220
src/main/java/com/sipai/controller/base/CSVFileUtil.java
Normal file
220
src/main/java/com/sipai/controller/base/CSVFileUtil.java
Normal file
@ -0,0 +1,220 @@
|
||||
package com.sipai.controller.base;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CSVFileUtil {
|
||||
// CSV文件编码
|
||||
public static final String ENCODE = "GBK";
|
||||
|
||||
private FileInputStream fis = null;
|
||||
private InputStreamReader isw = null;
|
||||
private BufferedReader br = null;
|
||||
|
||||
|
||||
public CSVFileUtil(String filename) throws Exception {
|
||||
fis = new FileInputStream(filename);
|
||||
isw = new InputStreamReader(fis, ENCODE);
|
||||
br = new BufferedReader(isw);
|
||||
}
|
||||
|
||||
// ==========以下是公开方法=============================
|
||||
/**
|
||||
* 从CSV文件流中读取一个CSV行。
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public String readLine() throws Exception {
|
||||
|
||||
StringBuffer readLine = new StringBuffer();
|
||||
boolean bReadNext = true;
|
||||
|
||||
while (bReadNext) {
|
||||
//
|
||||
if (readLine.length() > 0) {
|
||||
readLine.append("\r\n");
|
||||
}
|
||||
// 一行
|
||||
String strReadLine = br.readLine();
|
||||
|
||||
// readLine is Null
|
||||
if (strReadLine == null) {
|
||||
return null;
|
||||
}
|
||||
readLine.append(strReadLine);
|
||||
|
||||
// 如果双引号是奇数的时候继续读取。考虑有换行的是情况。
|
||||
if (countChar(readLine.toString(), '"', 0) % 2 == 1) {
|
||||
bReadNext = true;
|
||||
} else {
|
||||
bReadNext = false;
|
||||
}
|
||||
}
|
||||
return readLine.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*把CSV文件的一行转换成字符串数组。指定数组长度,不够长度的部分设置为null。
|
||||
*/
|
||||
public static String[] fromCSVLine(String source, int size) {
|
||||
ArrayList tmpArray = fromCSVLinetoArray(source);
|
||||
if (size < tmpArray.size()) {
|
||||
size = tmpArray.size();
|
||||
}
|
||||
String[] rtnArray = new String[size];
|
||||
tmpArray.toArray(rtnArray);
|
||||
return rtnArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把CSV文件的一行转换成字符串数组。不指定数组长度。
|
||||
*/
|
||||
public static ArrayList fromCSVLinetoArray(String source) {
|
||||
if (source == null || source.length() == 0) {
|
||||
return new ArrayList();
|
||||
}
|
||||
int currentPosition = 0;
|
||||
int maxPosition = source.length();
|
||||
int nextComma = 0;
|
||||
ArrayList rtnArray = new ArrayList();
|
||||
while (currentPosition < maxPosition) {
|
||||
nextComma = nextComma(source, currentPosition);
|
||||
rtnArray.add(nextToken(source, currentPosition, nextComma));
|
||||
currentPosition = nextComma + 1;
|
||||
if (currentPosition == maxPosition) {
|
||||
rtnArray.add("");
|
||||
}
|
||||
}
|
||||
return rtnArray;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 把字符串类型的数组转换成一个CSV行。(输出CSV文件的时候用)
|
||||
*/
|
||||
public static String toCSVLine(String[] strArray) {
|
||||
if (strArray == null) {
|
||||
return "";
|
||||
}
|
||||
StringBuffer cvsLine = new StringBuffer();
|
||||
for (int idx = 0; idx < strArray.length; idx++) {
|
||||
String item = addQuote(strArray[idx]);
|
||||
cvsLine.append(item);
|
||||
if (strArray.length - 1 != idx) {
|
||||
cvsLine.append(',');
|
||||
}
|
||||
}
|
||||
return cvsLine.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串类型的List转换成一个CSV行。(输出CSV文件的时候用)
|
||||
*/
|
||||
public static String toCSVLine(ArrayList strArrList) {
|
||||
if (strArrList == null) {
|
||||
return "";
|
||||
}
|
||||
String[] strArray = new String[strArrList.size()];
|
||||
for (int idx = 0; idx < strArrList.size(); idx++) {
|
||||
strArray[idx] = (String) strArrList.get(idx);
|
||||
}
|
||||
return toCSVLine(strArray);
|
||||
}
|
||||
|
||||
// ==========以下是内部使用的方法=============================
|
||||
/**
|
||||
*计算指定文字的个数。
|
||||
*
|
||||
* @param str 文字列
|
||||
* @param c 文字
|
||||
* @param start 开始位置
|
||||
* @return 个数
|
||||
*/
|
||||
private int countChar(String str, char c, int start) {
|
||||
int i = 0;
|
||||
int index = str.indexOf(c, start);
|
||||
return index == -1 ? i : countChar(str, c, index + 1) + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询下一个逗号的位置。
|
||||
*
|
||||
* @param source 文字列
|
||||
* @param st 检索开始位置
|
||||
* @return 下一个逗号的位置。
|
||||
*/
|
||||
private static int nextComma(String source, int st) {
|
||||
int maxPosition = source.length();
|
||||
boolean inquote = false;
|
||||
while (st < maxPosition) {
|
||||
char ch = source.charAt(st);
|
||||
if (!inquote && ch == ',') {
|
||||
break;
|
||||
} else if ('"' == ch) {
|
||||
inquote = !inquote;
|
||||
}
|
||||
st++;
|
||||
}
|
||||
return st;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得下一个字符串
|
||||
*/
|
||||
private static String nextToken(String source, int st, int nextComma) {
|
||||
StringBuffer strb = new StringBuffer();
|
||||
int next = st;
|
||||
while (next < nextComma) {
|
||||
char ch = source.charAt(next++);
|
||||
if (ch == '"') {
|
||||
if ((st + 1 < next && next < nextComma) && (source.charAt(next) == '"')) {
|
||||
strb.append(ch);
|
||||
next++;
|
||||
}
|
||||
} else {
|
||||
strb.append(ch);
|
||||
}
|
||||
}
|
||||
return strb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 在字符串的外侧加双引号。如果该字符串的内部有双引号的话,把"转换成""。
|
||||
*
|
||||
* @param item 字符串
|
||||
* @return 处理过的字符串
|
||||
*/
|
||||
private static String addQuote(String item) {
|
||||
if (item == null || item.length() == 0) {
|
||||
return "\"\"";
|
||||
}
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append('"');
|
||||
for (int idx = 0; idx < item.length(); idx++) {
|
||||
char ch = item.charAt(idx);
|
||||
if ('"' == ch) {
|
||||
sb.append("\"\"");
|
||||
} else {
|
||||
sb.append(ch);
|
||||
}
|
||||
}
|
||||
sb.append('"');
|
||||
return sb.toString();
|
||||
}
|
||||
/**
|
||||
* 关闭流
|
||||
*/
|
||||
public void close() {
|
||||
if (fis != null) {
|
||||
try {
|
||||
fis.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
984
src/main/java/com/sipai/controller/base/FileUploadHelper.java
Normal file
984
src/main/java/com/sipai/controller/base/FileUploadHelper.java
Normal file
@ -0,0 +1,984 @@
|
||||
package com.sipai.controller.base;
|
||||
|
||||
import java.io.*;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.sipai.entity.enums.FileNameSpaceEnum;
|
||||
import com.sipai.entity.report.RptCreate;
|
||||
import com.sipai.entity.report.RptInfoSet;
|
||||
import com.sipai.service.report.RptCreateService;
|
||||
import com.sipai.service.report.RptInfoSetService;
|
||||
import com.sipai.tools.MinioProp;
|
||||
import io.minio.MinioClient;
|
||||
import io.minio.errors.*;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.apache.axis.encoding.Base64;
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.achievement.AcceptanceModelMPoint;
|
||||
import com.sipai.entity.base.CommonFile;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.base.CommonFileService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
import com.sipai.tools.FileUtil;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(value = "/base")
|
||||
public class FileUploadHelper {
|
||||
|
||||
private String BaseFolderName = "UploadFile";
|
||||
@Resource
|
||||
CommonFileService commonFileService;
|
||||
@Autowired
|
||||
private MinioProp minioProp;
|
||||
@Resource
|
||||
private RptInfoSetService rptInfoSetService;
|
||||
@Resource
|
||||
private RptCreateService rptCreateService;
|
||||
|
||||
/**
|
||||
* 显示上传页面
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @param masterid
|
||||
* @param mappernamespace
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "fileupload.do", method = RequestMethod.GET)
|
||||
public String fileupload(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model, @RequestParam(value = "masterid") String masterid,
|
||||
@RequestParam(value = "mappernamespace") String mappernamespace) {
|
||||
model.addAttribute("mappernamespace", mappernamespace);
|
||||
model.addAttribute("masterid", masterid);
|
||||
return "base/fileupload";
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*
|
||||
* @param file
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @param masterid
|
||||
* @param mappernamespace
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@RequestMapping(value = "uploadfile.do")
|
||||
public ModelAndView uploadFile(@RequestParam MultipartFile[] file, HttpServletRequest request,
|
||||
HttpServletResponse response, Model model, @RequestParam(value = "masterid") String masterid,
|
||||
@RequestParam(value = "mappernamespace") String mappernamespace) throws IOException {
|
||||
String realPath = request.getSession().getServletContext().getRealPath("/");
|
||||
String pjName = request.getContextPath().substring(1, request.getContextPath().length());
|
||||
realPath = realPath.replace(pjName, BaseFolderName);
|
||||
|
||||
User user = (User) request.getSession().getAttribute("cu");
|
||||
String result = this.commonFileService.uploadFile(realPath, mappernamespace, masterid, user, file);
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @param id
|
||||
* @param mappernamespace
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@RequestMapping(value = "downloadFile.do")
|
||||
public ModelAndView downloadFile(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model, @RequestParam(value = "key") String id, @RequestParam(value = "tbName") String tbName) throws IOException {
|
||||
List<CommonFile> commfiles = this.commonFileService.selectListByTableAWhere(tbName, "where id='" + id + "'");
|
||||
if (commfiles != null && commfiles.size() > 0) {
|
||||
FileUtil.downloadFile(response, commfiles.get(0).getFilename(), commfiles.get(0).getAbspath());
|
||||
} else {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件 用于记录和文件唯一对应的情况
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @param id
|
||||
* @param mappernamespace
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@RequestMapping(value = "downloadFileFromMasterid.do")
|
||||
public ModelAndView downloadFileFromMasterid(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model, @RequestParam(value = "key") String id, @RequestParam(value = "tbName") String tbName) throws IOException {
|
||||
List<CommonFile> commfiles = this.commonFileService.selectListByTableAWhere(tbName, "where masterid='" + id + "'");
|
||||
if (commfiles != null && commfiles.size() > 0) {
|
||||
FileUtil.downloadFile(response, commfiles.get(0).getFilename(), commfiles.get(0).getAbspath());
|
||||
} else {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @param id
|
||||
* @param mappernamespace
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@RequestMapping(value = "deletefile.do")
|
||||
public ModelAndView deletefile(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model, @RequestParam(value = "id") String id,
|
||||
@RequestParam(value = "mappernamespace") String mappernamespace) throws IOException {
|
||||
CommonFile commfile = this.commonFileService.selectById(id, mappernamespace);
|
||||
int res = this.commonFileService.deleteById(id, mappernamespace);
|
||||
if (res > 0) {
|
||||
FileUtil.deleteFile(commfile.getAbspath());
|
||||
model.addAttribute("result", "删除成功");
|
||||
}
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主ID下的文件列表
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @param masterid
|
||||
* @param mappernamespace
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@RequestMapping(value = "getFileList.do")
|
||||
public ModelAndView getFileList(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model, @RequestParam(value = "masterid") String masterid,
|
||||
@RequestParam(value = "mappernamespace") String mappernamespace) throws IOException {
|
||||
List<CommonFile> list = this.commonFileService.selectByMasterId(masterid, mappernamespace);
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
model.addAttribute("result", json);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/doimportExcel.do")
|
||||
public String doimportExcel(HttpServletRequest request, Model model) {
|
||||
return "/base/importExcel";
|
||||
}
|
||||
|
||||
@RequestMapping("/doPrint.do")
|
||||
public String doPrint(HttpServletRequest request, Model model) {
|
||||
return "/base/print";
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示上传页面-bootstrap-fileinput
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "fileinput.do")
|
||||
public String fileinput(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model, @RequestParam(value = "masterId") String masterId,
|
||||
@RequestParam(value = "tbName") String tbName, @RequestParam(value = "nameSpace") String nameSpace) {
|
||||
model.addAttribute("tbName", tbName);
|
||||
model.addAttribute("masterId", masterId);
|
||||
model.addAttribute("nameSpace", nameSpace);
|
||||
return "base/fileinput";
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示上传页面-minio (文件)
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "fileinputMinio.do")
|
||||
public String fileinputMinio(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model, @RequestParam(value = "masterId") String masterId,
|
||||
@RequestParam(value = "tbName") String tbName, @RequestParam(value = "nameSpace") String nameSpace) {
|
||||
model.addAttribute("tbName", tbName);
|
||||
model.addAttribute("masterId", masterId);
|
||||
model.addAttribute("nameSpace", nameSpace);
|
||||
return "base/fileinputMinio";
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示上传页面-minio (图片)
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "fileinputMinioPic.do")
|
||||
public String fileinputMinioPic(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model, @RequestParam(value = "masterId") String masterId,
|
||||
@RequestParam(value = "tbName") String tbName, @RequestParam(value = "nameSpace") String nameSpace) {
|
||||
model.addAttribute("tbName", tbName);
|
||||
model.addAttribute("masterId", masterId);
|
||||
model.addAttribute("nameSpace", nameSpace);
|
||||
return "base/fileinputMinioPic";
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示上传页面-minio (模板上传页面)
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "fileinputMinio_Report.do")
|
||||
public String fileinputMinio_Report(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model, @RequestParam(value = "masterId") String masterId,
|
||||
@RequestParam(value = "tbName") String tbName, @RequestParam(value = "nameSpace") String nameSpace) {
|
||||
model.addAttribute("tbName", tbName);
|
||||
model.addAttribute("masterId", masterId);
|
||||
model.addAttribute("nameSpace", nameSpace);
|
||||
return "base/fileinputMinio_Report";
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示上传页面-minio (报表生成上传页面)
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "fileinputMinio_Report_Creat.do")
|
||||
public String fileinputMinio_Report_Creat(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model, @RequestParam(value = "masterId") String masterId,
|
||||
@RequestParam(value = "tbName") String tbName, @RequestParam(value = "nameSpace") String nameSpace) {
|
||||
model.addAttribute("tbName", tbName);
|
||||
model.addAttribute("masterId", masterId);
|
||||
model.addAttribute("nameSpace", nameSpace);
|
||||
return "base/fileinputMinio_Report_Creat";
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件通用接口
|
||||
*
|
||||
* @param request 请求体
|
||||
* @param dstFileName html上传组件中(input中name属性),上传文件体名称,通过此名称获取所有上传的文件map
|
||||
* @param reportGroupId (特殊)上传报告所述报告组id
|
||||
*/
|
||||
@RequestMapping(value = "inputFile.do")
|
||||
public ModelAndView inputFile(HttpServletRequest request, HttpServletResponse response, Model model) {
|
||||
Map<String, Object> ret = new HashMap<String, Object>();
|
||||
String masterId = request.getParameter("masterId");
|
||||
String tbName = request.getParameter("tbName");
|
||||
String nameSpace = request.getParameter("nameSpace");
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
//判断保存文件的路径是否存在
|
||||
String contextPath = request.getContextPath().replace("/", "");
|
||||
String filepathSever = request.getSession().getServletContext().getRealPath("");
|
||||
String filepath = filepathSever.replaceAll(contextPath, BaseFolderName + "/" + nameSpace + "/");
|
||||
File fileUploadPath = new File(filepath);
|
||||
if (!fileUploadPath.exists()) {
|
||||
//解决上传文件目录无法自动创建
|
||||
fileUploadPath.mkdirs();
|
||||
}
|
||||
|
||||
if (ServletFileUpload.isMultipartContent(request)) {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
List<MultipartFile> fileList = multipartRequest.getFiles("filelist"); //控件id
|
||||
//for循环只执行一次
|
||||
for (MultipartFile item : fileList) {
|
||||
String fileName = ""; //当前上传文件全名称
|
||||
String fileType = ""; //当前上传文件类型
|
||||
String saveFileName = ""; //保存到服务器目录的文件名称
|
||||
String reportAddr = ""; //保存到服务器目录的文件全路径
|
||||
try {
|
||||
fileName = item.getOriginalFilename();
|
||||
fileType = item.getContentType();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
|
||||
saveFileName = dateFormat.format(new Date()) + fileName;
|
||||
reportAddr = fileUploadPath + "/" + saveFileName;
|
||||
reportAddr = reportAddr.replace("/", File.separator).replace("\\", File.separator);
|
||||
|
||||
File savedFile = new File(fileUploadPath, saveFileName);
|
||||
item.transferTo(savedFile);
|
||||
|
||||
//上传文件成功,保存文件信息到表reportDetail
|
||||
CommonFile commonFile = new CommonFile();
|
||||
commonFile.setId(CommUtil.getUUID());
|
||||
commonFile.setMasterid(masterId);
|
||||
commonFile.setFilename(fileName);
|
||||
commonFile.setType(fileType);
|
||||
commonFile.setAbspath(reportAddr);
|
||||
commonFile.setInsdt(CommUtil.nowDate());
|
||||
commonFile.setInsuser(cu.getId());
|
||||
commonFile.setSize((int) item.getSize());
|
||||
int res = commonFileService.insertByTable(tbName, commonFile);
|
||||
|
||||
if (res == 1) {
|
||||
ret.put("suc", true);
|
||||
ret.put("msg", commonFile.getId());
|
||||
} else {
|
||||
ret.put("suc", false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
ret.put("suc", false);
|
||||
ret.put("msg", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
String result = JSONObject.fromObject(ret).toString();
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping(value = "inputFilemore.do")
|
||||
public ModelAndView inputFilemore(HttpServletRequest request, HttpServletResponse response, Model model) {
|
||||
Map<String, Object> ret = new HashMap<String, Object>();
|
||||
String masterId = request.getParameter("masterId");
|
||||
String tbName = request.getParameter("tbName");
|
||||
String nameSpace = request.getParameter("nameSpace");
|
||||
String typeId = request.getParameter("typeId");
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
//判断保存文件的路径是否存在
|
||||
String contextPath = request.getContextPath().replace("/", "");
|
||||
String filepathSever = request.getSession().getServletContext().getRealPath("");
|
||||
String filepath = filepathSever.replaceAll(contextPath, BaseFolderName + "/" + nameSpace + "/");
|
||||
File fileUploadPath = new File(filepath);
|
||||
if (!fileUploadPath.exists()) {
|
||||
//解决上传文件目录无法自动创建
|
||||
fileUploadPath.mkdirs();
|
||||
}
|
||||
|
||||
if (ServletFileUpload.isMultipartContent(request)) {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
List<MultipartFile> fileList = multipartRequest.getFiles("filelist"); //控件id
|
||||
//for循环只执行一次
|
||||
for (MultipartFile item : fileList) {
|
||||
String fileName = ""; //当前上传文件全名称
|
||||
String fileType = ""; //当前上传文件类型
|
||||
String saveFileName = ""; //保存到服务器目录的文件名称
|
||||
String reportAddr = ""; //保存到服务器目录的文件全路径
|
||||
try {
|
||||
fileName = item.getOriginalFilename();
|
||||
fileType = item.getContentType();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
|
||||
saveFileName = dateFormat.format(new Date()) + fileName;
|
||||
reportAddr = fileUploadPath + "/" + saveFileName;
|
||||
reportAddr = reportAddr.replace("/", File.separator).replace("\\", File.separator);
|
||||
|
||||
File savedFile = new File(fileUploadPath, saveFileName);
|
||||
item.transferTo(savedFile);
|
||||
|
||||
//上传文件成功,保存文件信息到表reportDetail
|
||||
CommonFile commonFile = new CommonFile();
|
||||
commonFile.setId(CommUtil.getUUID() + "-" + typeId);
|
||||
commonFile.setMasterid(masterId);
|
||||
commonFile.setFilename(fileName);
|
||||
commonFile.setType(fileType);
|
||||
commonFile.setAbspath(reportAddr);
|
||||
commonFile.setInsdt(CommUtil.nowDate());
|
||||
commonFile.setInsuser(cu.getId());
|
||||
commonFile.setSize((int) item.getSize());
|
||||
int res = commonFileService.insertByTable(tbName, commonFile);
|
||||
|
||||
if (res == 1) {
|
||||
ret.put("suc", true);
|
||||
ret.put("msg", commonFile.getId());
|
||||
} else {
|
||||
ret.put("suc", false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
ret.put("suc", false);
|
||||
ret.put("msg", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
String result = JSONObject.fromObject(ret).toString();
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件json
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@RequestMapping(value = "getInputFileList.do")
|
||||
public ModelAndView getInputFileList(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model) throws IOException {
|
||||
String masterId = request.getParameter("masterId");
|
||||
//masterId="56aa5f35dac644deb7b3938a79cf3fde";
|
||||
String tbName = request.getParameter("tbName");
|
||||
//String nameSpace = request.getParameter("nameSpace");
|
||||
List<CommonFile> list = this.commonFileService.selectListByTableAWhere(tbName, "where masterid='" + masterId + "'");
|
||||
/* String contextPath=request.getContextPath().replace("/", "");
|
||||
String filepathSever=request.getSession().getServletContext().getRealPath("");
|
||||
contextPath=request.getSession().getServletContext().getContextPath();*/
|
||||
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
model.addAttribute("result", json);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件json - minio中
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@RequestMapping(value = "getInputFileList_minio.do")
|
||||
public ModelAndView getInputFileList_minio(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model) throws IOException, InvalidPortException, InvalidEndpointException, InvalidBucketNameException, InsufficientDataException, XmlPullParserException, ErrorResponseException, NoSuchAlgorithmException, NoResponseException, InvalidExpiresRangeException, InvalidKeyException, InvalidResponseException, InternalException {
|
||||
String masterId = request.getParameter("masterId");
|
||||
String tbName = request.getParameter("tbName");
|
||||
String bucketName = request.getParameter("bucketName");
|
||||
String type = request.getParameter("type");//文件类型,传需要的类型,不传则查所有 (image是图片、video是视频)
|
||||
|
||||
String wherestr = "where masterid='" + masterId + "'";
|
||||
if (type != null && !type.trim().equals("")) {
|
||||
wherestr += " and type like '%" + type + "%'";
|
||||
}
|
||||
List<CommonFile> list = this.commonFileService.selectListByTableAWhere(tbName, wherestr);
|
||||
for (CommonFile commonFile : list) {
|
||||
String path = commonFile.getAbspath();
|
||||
MinioClient minioClient2 = new MinioClient(minioProp.getEndPoint(), minioProp.getAccessKey(), minioProp.getSecretKey());
|
||||
|
||||
//直接读取图片地址 存在外网无法使用 后面都换成下面的流文件
|
||||
String obj = minioClient2.presignedGetObject(bucketName, path, 3600 * 24 * 7);
|
||||
commonFile.setAbspath(obj);
|
||||
|
||||
//解析成流文件 后面都用这个
|
||||
byte[] buffer = commonFileService.getInputStreamBytes(bucketName, path);
|
||||
String base = Base64.encode(buffer);
|
||||
commonFile.setStreamFile(base);
|
||||
}
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
model.addAttribute("result", json);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件json - minio中 (List格式)
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@RequestMapping(value = "getInputFileList_minio2.do")
|
||||
public ModelAndView getInputFileList_minio2(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model) throws IOException, InvalidPortException, InvalidEndpointException, InvalidBucketNameException, InsufficientDataException, XmlPullParserException, ErrorResponseException, NoSuchAlgorithmException, NoResponseException, InvalidExpiresRangeException, InvalidKeyException, InvalidResponseException, InternalException {
|
||||
String masterId = request.getParameter("masterId");
|
||||
String tbName = request.getParameter("tbName");
|
||||
String bucketName = request.getParameter("bucketName");
|
||||
List<CommonFile> list = this.commonFileService.selectListByTableAWhere(tbName, "where masterid='" + masterId + "'");
|
||||
for (CommonFile commonFile : list) {
|
||||
MinioClient minioClient2 = new MinioClient(minioProp.getEndPoint(), minioProp.getAccessKey(), minioProp.getSecretKey());
|
||||
String obj = minioClient2.presignedGetObject(bucketName, commonFile.getAbspath(), 3600 * 24 * 7);
|
||||
commonFile.setAbspath(obj);
|
||||
}
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
String result = "{\"total\":" + 1 + ",\"rows\":" + json + "}";
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件json - minio中 (为前台分页)
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@RequestMapping(value = "getInputFileList_minio3.do")
|
||||
public ModelAndView getInputFileList_minio3(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model) throws IOException, InvalidPortException, InvalidEndpointException, InvalidBucketNameException, InsufficientDataException, XmlPullParserException, ErrorResponseException, NoSuchAlgorithmException, NoResponseException, InvalidExpiresRangeException, InvalidKeyException, InvalidResponseException, InternalException {
|
||||
String masterId = request.getParameter("masterId");
|
||||
String tbName = request.getParameter("tbName");
|
||||
String bucketName = request.getParameter("bucketName");
|
||||
|
||||
String sdt = request.getParameter("sdt");
|
||||
String edt = request.getParameter("edt");
|
||||
|
||||
String whereString = " where masterid='" + masterId + "' ";
|
||||
|
||||
if (sdt != null && sdt.length() > 0 && edt != null && edt.length() > 0) {
|
||||
whereString += " and insdt between '" + sdt + "' and '" + edt + "' ";
|
||||
}
|
||||
if (request.getParameter("pointId") != null && request.getParameter("pointId").length() > 0) {
|
||||
whereString += " and pointId='" + request.getParameter("pointId") + "' ";
|
||||
}
|
||||
|
||||
List<CommonFile> list = this.commonFileService.selectListByTableAWhere(tbName, whereString + " order by insdt desc");
|
||||
// for (CommonFile commonFile : list) {
|
||||
// MinioClient minioClient2 = new MinioClient(minioProp.getEndPoint(), minioProp.getAccessKey(), minioProp.getSecretKey());
|
||||
// String obj = minioClient2.presignedGetObject(bucketName, commonFile.getAbspath(), 3600 * 24 * 7);
|
||||
// commonFile.setAbspath(obj);
|
||||
// }
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
model.addAttribute("result", json);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping(value = "getInputFileList2.do")
|
||||
public String getInputFileList2(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model) throws IOException, InvalidBucketNameException, InsufficientDataException, XmlPullParserException, ErrorResponseException, NoSuchAlgorithmException, NoResponseException, InvalidKeyException, InvalidResponseException, InternalException, InvalidPortException, InvalidEndpointException, InvalidExpiresRangeException {
|
||||
String bucketName = "maintenance";
|
||||
String objectName = "2021-09-07-10-06-5811111111.png";
|
||||
MinioClient minioClient2 = new MinioClient("http://127.0.0.1:9000", "sipai", "ZAQwsx@2008");
|
||||
String obj = minioClient2.presignedGetObject(bucketName, objectName, 3600 * 24 * 7);
|
||||
// System.out.println(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "getInputFileTableList.do")
|
||||
public String getInputFileTableList(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required = false) String sort,
|
||||
@RequestParam(value = "order", required = false) String order) {
|
||||
PageHelper.startPage(page, rows);
|
||||
String masterId = request.getParameter("masterId");
|
||||
String tbName = request.getParameter("tbName");
|
||||
//String nameSpace = request.getParameter("nameSpace");
|
||||
List<CommonFile> list = this.commonFileService.selectListByTableAWhere(tbName, "where masterid='" + masterId + "' order by insdt desc");
|
||||
PageInfo<CommonFile> pi = new PageInfo<CommonFile>(list);
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
String result = "{\"total\":" + pi.getTotal() + ",\"rows\":" + json + "}";
|
||||
model.addAttribute("result", result);
|
||||
return ("result");
|
||||
}
|
||||
|
||||
@RequestMapping(value = "deleteInputFile.do")
|
||||
public String deleteInputFile(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model, @RequestParam(value = "key") String id, @RequestParam(value = "tbName") String tbName) throws IOException {
|
||||
int code = 0;
|
||||
Map<String, Object> ret = new HashMap<String, Object>();
|
||||
List<CommonFile> commfiles = this.commonFileService.selectListByTableAWhere(tbName, "where id='" + id + "'");
|
||||
|
||||
if (commfiles != null && commfiles.size() > 0) {
|
||||
File file = new File(commfiles.get(0).getAbspath());
|
||||
if (file.exists()) {
|
||||
file.delete();//删除文件
|
||||
}
|
||||
code = this.commonFileService.deleteByTableAWhere(tbName, "where id='" + id + "'");
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("删除失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
}
|
||||
return "result";
|
||||
}
|
||||
|
||||
//用于记录和文件唯一对应的情况
|
||||
@RequestMapping(value = "deleteInputFileFromMasterid.do")
|
||||
public String deleteInputFileFromMasterid(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model, @RequestParam(value = "key") String id, @RequestParam(value = "tbName") String tbName) throws IOException {
|
||||
int code = 0;
|
||||
Map<String, Object> ret = new HashMap<String, Object>();
|
||||
List<CommonFile> commfiles = this.commonFileService.selectListByTableAWhere(tbName, "where masterid='" + id + "'");
|
||||
|
||||
if (commfiles != null && commfiles.size() > 0) {
|
||||
File file = new File(commfiles.get(0).getAbspath());
|
||||
if (file.exists()) {
|
||||
file.delete();//删除文件
|
||||
}
|
||||
code = this.commonFileService.deleteByTableAWhere(tbName, "where masterid='" + id + "'");
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("删除失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
}
|
||||
return "result";
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存PDF临时文档,返回文档地址
|
||||
*/
|
||||
@RequestMapping("/getPDFUrl.do")
|
||||
public ModelAndView getPDFUrl(HttpServletRequest request, Model model) {
|
||||
|
||||
String htmlStr = request.getParameter("htmlStr");
|
||||
String realPath = request.getSession().getServletContext().getRealPath("/");
|
||||
String pjName = request.getContextPath().substring(1, request.getContextPath().length());
|
||||
realPath = realPath.replace(pjName, BaseFolderName);
|
||||
realPath += "TempFiles\\";
|
||||
File dir = new File(realPath);
|
||||
if (!dir.exists()) {
|
||||
try {
|
||||
dir.mkdir();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
dir = null;
|
||||
String fileName = CommUtil.getUUID() + ".pdf";
|
||||
realPath += fileName;
|
||||
PDFFileUtil.html2Pdf(realPath, htmlStr);
|
||||
String result = "{\"res\":\"" + realPath.substring(realPath.indexOf(BaseFolderName), realPath.length()).replace("\\", "/") + "\"}";
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程审核上传资料页面
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "fileInputForProcess.do")
|
||||
public String fileInputForProcess(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model, @RequestParam(value = "masterId") String masterId,
|
||||
@RequestParam(value = "tbName") String tbName, @RequestParam(value = "nameSpace") String nameSpace) {
|
||||
model.addAttribute("tbName", tbName);
|
||||
model.addAttribute("masterId", masterId);
|
||||
model.addAttribute("nameSpace", nameSpace);
|
||||
return "base/fileInputForProcess";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "fileInputForProcessmore.do")
|
||||
public String fileInputForProcessmore(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model, @RequestParam(value = "masterId") String masterId,
|
||||
@RequestParam(value = "tbName") String tbName, @RequestParam(value = "nameSpace") String nameSpace, @RequestParam(value = "typeId") String typeId) {
|
||||
model.addAttribute("tbName", tbName);
|
||||
model.addAttribute("masterId", masterId);
|
||||
model.addAttribute("nameSpace", nameSpace);
|
||||
model.addAttribute("typeId", typeId);
|
||||
return "base/fileInputForProcessMore";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "fileInputForProcessmore1.do")
|
||||
public String fileInputForProcessmore1(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model, @RequestParam(value = "masterId") String masterId,
|
||||
@RequestParam(value = "tbName") String tbName, @RequestParam(value = "nameSpace") String nameSpace, @RequestParam(value = "typeId") String typeId) {
|
||||
model.addAttribute("tbName", tbName);
|
||||
model.addAttribute("masterId", masterId);
|
||||
model.addAttribute("nameSpace", nameSpace);
|
||||
model.addAttribute("typeId", typeId);
|
||||
return "base/fileInputForProcessMore1";
|
||||
}
|
||||
|
||||
/*
|
||||
* 根据id获取单个文件
|
||||
*/
|
||||
@RequestMapping(value = "getInputFile4Id.do")
|
||||
public ModelAndView getInputFile4Id(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model) throws IOException {
|
||||
String id = request.getParameter("id");
|
||||
String tbName = request.getParameter("tbName");
|
||||
List<CommonFile> list = this.commonFileService.selectListByTableAWhere(tbName, "where id='" + id + "'");
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
model.addAttribute("result", json);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* minio 文件上传 (通用)
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "updateFile.do")
|
||||
public ModelAndView updateFile(HttpServletRequest request, HttpServletResponse response, Model model) {
|
||||
Map<String, Object> ret = new HashMap<String, Object>();
|
||||
String masterId = request.getParameter("masterId");
|
||||
String nameSpace = request.getParameter("nameSpace");
|
||||
String tbName = request.getParameter("tbName");
|
||||
if (nameSpace != null && !nameSpace.isEmpty()) {
|
||||
if (tbName == null || tbName.isEmpty()) {
|
||||
tbName = FileNameSpaceEnum.getTbName(nameSpace);
|
||||
}
|
||||
}
|
||||
if (ServletFileUpload.isMultipartContent(request)) {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
List<MultipartFile> fileList = multipartRequest.getFiles("filelist"); //控件id
|
||||
//for循环只执行一次
|
||||
for (MultipartFile item : fileList) {
|
||||
try {
|
||||
int res = commonFileService.updateFile(masterId, nameSpace, tbName, item);
|
||||
|
||||
if (res == 1) {
|
||||
ret.put("suc", true);
|
||||
} else {
|
||||
ret.put("suc", false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
ret.put("suc", false);
|
||||
ret.put("msg", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
String result = JSONObject.fromObject(ret).toString();
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
/**
|
||||
* 以下方法为 minio 文件相关方法 (报表上传定制功能,其他模板最好不要使用)
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "updateFile_creat.do")
|
||||
public ModelAndView updateFile_creat(HttpServletRequest request, HttpServletResponse response, Model model) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
Map<String, Object> ret = new HashMap<String, Object>();
|
||||
String masterId = request.getParameter("masterId");
|
||||
String nameSpace = request.getParameter("nameSpace");
|
||||
// YYJ 20201229
|
||||
String tbName = request.getParameter("tbName");
|
||||
if (nameSpace != null && !nameSpace.isEmpty()) {
|
||||
if (tbName == null || tbName.isEmpty()) {
|
||||
tbName = FileNameSpaceEnum.getTbName(nameSpace);
|
||||
}
|
||||
}
|
||||
|
||||
if (ServletFileUpload.isMultipartContent(request)) {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
List<MultipartFile> fileList = multipartRequest.getFiles("filelist"); //控件id
|
||||
//for循环只执行一次
|
||||
for (MultipartFile item : fileList) {
|
||||
try {
|
||||
String uuid = CommUtil.getUUID();
|
||||
int res = commonFileService.updateFile_creat(masterId, nameSpace, tbName, item, uuid);
|
||||
if (res == 1) {
|
||||
|
||||
RptInfoSet rptInfoSet = rptInfoSetService.selectById(masterId);
|
||||
if (rptInfoSet != null) {
|
||||
String rptname = item.getOriginalFilename();
|
||||
|
||||
RptCreate rptCreate = new RptCreate();
|
||||
rptCreate.setId(uuid);
|
||||
rptCreate.setInsdt(CommUtil.nowDate());
|
||||
rptCreate.setInsuser(cu.getId());
|
||||
rptCreate.setUpsdt(CommUtil.nowDate());
|
||||
rptCreate.setUpsuser(cu.getId());
|
||||
|
||||
rptname = rptname.replace(".xls", "");
|
||||
rptname = rptname.replace(".xlsx", "");
|
||||
|
||||
rptCreate.setRptname(rptname);
|
||||
rptCreate.setRptdt(CommUtil.nowDate());
|
||||
rptCreate.setUnitId(rptInfoSet.getUnitId());
|
||||
rptCreate.setRptsetId(masterId);
|
||||
rptCreateService.save2(rptCreate);
|
||||
}
|
||||
|
||||
ret.put("suc", true);
|
||||
} else {
|
||||
ret.put("suc", false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
ret.put("suc", false);
|
||||
ret.put("msg", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
String result = JSONObject.fromObject(ret).toString();
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping(value = "getInputFileListById.do")
|
||||
public ModelAndView getInputFileListById(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model) throws IOException {
|
||||
String id = request.getParameter("id");
|
||||
String masterId = request.getParameter("masterId");
|
||||
//masterId="56aa5f35dac644deb7b3938a79cf3fde";
|
||||
String tbName = request.getParameter("tbName");
|
||||
//String nameSpace = request.getParameter("nameSpace");
|
||||
List<CommonFile> list = this.commonFileService.selectListByTableAWhere(tbName, "where id='" + id + "'");
|
||||
/* String contextPath=request.getContextPath().replace("/", "");
|
||||
String filepathSever=request.getSession().getServletContext().getRealPath("");
|
||||
contextPath=request.getSession().getServletContext().getContextPath();*/
|
||||
if (list != null && list.size() > 0) {
|
||||
String typeString = list.get(0).getType();
|
||||
if (typeString.contains("word") || typeString.contains("sheet") ||
|
||||
typeString.contains("excel") || typeString.contains("presentation") ||
|
||||
typeString.contains("powerpoint")) {
|
||||
List<CommonFile> masterlist = this.commonFileService.selectListByTableAWhere(tbName, "where masterid='" + id + "'");
|
||||
if (masterlist != null && masterlist.size() > 0) {
|
||||
if (masterlist.get(0).getSize() > 0) {
|
||||
list = masterlist;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
list = this.commonFileService.selectListByTableAWhere(tbName, "where masterid='" + masterId + "'");
|
||||
if (list != null && list.size() > 0) {
|
||||
String typeString = list.get(0).getType();
|
||||
if (typeString.contains("word") || typeString.contains("sheet") ||
|
||||
typeString.contains("excel") || typeString.contains("presentation") ||
|
||||
typeString.contains("powerpoint")) {
|
||||
List<CommonFile> masterlist = this.commonFileService.selectListByTableAWhere(tbName, "where masterid='" + id + "'");
|
||||
if (masterlist != null && masterlist.size() > 0) {
|
||||
if (masterlist.get(0).getSize() > 0) {
|
||||
list = masterlist;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
model.addAttribute("result", json);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping(value = "showFileOnlinePic.do")
|
||||
public String showFileOnlinePic(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model, @RequestParam(value = "id") String id, @RequestParam(value = "masterId") String masterId,
|
||||
@RequestParam(value = "tbName") String tbName, @RequestParam(value = "nameSpace") String nameSpace) {
|
||||
model.addAttribute("id", id);
|
||||
model.addAttribute("tbName", tbName);
|
||||
model.addAttribute("masterId", masterId);
|
||||
model.addAttribute("nameSpace", nameSpace);
|
||||
model.addAttribute("sdt", request.getParameter("sdt"));
|
||||
model.addAttribute("edt", request.getParameter("edt"));
|
||||
return "base/fileOnlinePic";
|
||||
}
|
||||
|
||||
/**
|
||||
* 为获取图片相关,用于前台切换
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@RequestMapping(value = "getPicSwitchJson.do")
|
||||
public ModelAndView getPicSwitchJson(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model) {
|
||||
String masterId = request.getParameter("masterId");
|
||||
String tbName = request.getParameter("tbName");
|
||||
String id = request.getParameter("id");
|
||||
|
||||
String sdt = request.getParameter("sdt");
|
||||
String edt = request.getParameter("edt");
|
||||
|
||||
String whereString = " where masterid='" + masterId + "' ";
|
||||
|
||||
if (sdt != null && sdt.length() > 0 && edt != null && edt.length() > 0) {
|
||||
whereString += " and insdt between '" + sdt + "' and '" + edt + "' ";
|
||||
}
|
||||
|
||||
int nowFilePosition = -1;
|
||||
List<CommonFile> list = this.commonFileService.selectListByTableAWhere(tbName, whereString + " order by insdt desc ");
|
||||
if (list != null && list.size() > 0) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
CommonFile commonFile = list.get(i);
|
||||
if (commonFile.getId().equals(id)) {
|
||||
nowFilePosition = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("firstNum", nowFilePosition);
|
||||
jsonObject.put("list", json);
|
||||
model.addAttribute("result", jsonObject);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
/**
|
||||
* 为获取图片相关,用于前台切换
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@RequestMapping(value = "getNowPicFromSwitch.do")
|
||||
public ModelAndView getNowPicFromSwitch(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model) throws IOException, InvalidPortException, InvalidEndpointException, InvalidBucketNameException, InsufficientDataException, XmlPullParserException, ErrorResponseException, NoSuchAlgorithmException, NoResponseException, InvalidExpiresRangeException, InvalidKeyException, InvalidResponseException, InternalException {
|
||||
String tbName = request.getParameter("tbName");
|
||||
String bucketName = request.getParameter("bucketName");
|
||||
String id = request.getParameter("id");
|
||||
|
||||
List<CommonFile> list = this.commonFileService.selectListByTableAWhere(tbName, " where id='" + id + "' ");
|
||||
if (list != null && list.size() > 0) {
|
||||
CommonFile commonFile = list.get(0);
|
||||
String path = commonFile.getAbspath();
|
||||
MinioClient minioClient2 = new MinioClient(minioProp.getEndPoint(), minioProp.getAccessKey(), minioProp.getSecretKey());
|
||||
|
||||
//直接读取图片地址 存在外网无法使用 后面都换成下面的流文件
|
||||
String obj = minioClient2.presignedGetObject(bucketName, path, 3600 * 24 * 7);
|
||||
commonFile.setAbspath(obj);
|
||||
|
||||
//解析成流文件 后面都用这个
|
||||
byte[] buffer = commonFileService.getInputStreamBytes(bucketName, path);
|
||||
String base = Base64.encode(buffer);
|
||||
commonFile.setStreamFile(base);
|
||||
|
||||
JSONArray json = JSONArray.fromObject(commonFile);
|
||||
// System.out.println(json);
|
||||
model.addAttribute("result", json);
|
||||
}
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package com.sipai.controller.base;
|
||||
|
||||
import freemarker.template.Configuration;
|
||||
|
||||
public class FreemarkerConfiguration {
|
||||
private static Configuration config = null;
|
||||
|
||||
/**
|
||||
* Static initialization.
|
||||
*
|
||||
* Initialize the configuration of Freemarker.
|
||||
*/
|
||||
static{
|
||||
config = new Configuration();
|
||||
config.setClassForTemplateLoading(FreemarkerConfiguration.class, "template");
|
||||
}
|
||||
|
||||
public static Configuration getConfiguation(){
|
||||
return config;
|
||||
}
|
||||
|
||||
}
|
||||
41
src/main/java/com/sipai/controller/base/HtmlGenerator.java
Normal file
41
src/main/java/com/sipai/controller/base/HtmlGenerator.java
Normal file
@ -0,0 +1,41 @@
|
||||
package com.sipai.controller.base;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Map;
|
||||
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.Template;
|
||||
|
||||
public class HtmlGenerator {
|
||||
/**
|
||||
* Generate html string.
|
||||
*
|
||||
* @param template the name of freemarker teamlate.
|
||||
* @param variables the data of teamlate.
|
||||
* @return htmlStr
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String generate(String templateFile, Map<String,Object> variables) throws Exception{
|
||||
File file = new File(templateFile);
|
||||
if(!file.exists())
|
||||
throw new Exception("模板文件不存在:"+templateFile);
|
||||
|
||||
String templateDir = file.getParentFile().getPath();
|
||||
String templateName =file.getName();
|
||||
Configuration config = FreemarkerConfiguration.getConfiguation();
|
||||
//用于解决前端报空指针问题-->
|
||||
config.setClassicCompatible(true);
|
||||
config.setDirectoryForTemplateLoading(new File(templateDir));
|
||||
Template tp = config.getTemplate(templateName);
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
BufferedWriter writer = new BufferedWriter(stringWriter);
|
||||
tp.setEncoding("UTF-8");
|
||||
tp.process(variables, writer);
|
||||
String htmlStr = stringWriter.toString();
|
||||
writer.flush();
|
||||
writer.close();
|
||||
return htmlStr;
|
||||
}
|
||||
}
|
||||
680
src/main/java/com/sipai/controller/base/LoginServlet.java
Normal file
680
src/main/java/com/sipai/controller/base/LoginServlet.java
Normal file
@ -0,0 +1,680 @@
|
||||
package com.sipai.controller.base;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.sipai.entity.base.BasicComponents;
|
||||
import com.sipai.entity.base.BasicConfigure;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.user.*;
|
||||
import com.sipai.security.MyUserDetailServiceImpl;
|
||||
import com.sipai.service.base.BasicComponentsService;
|
||||
import com.sipai.service.base.LoginService;
|
||||
import com.sipai.service.user.*;
|
||||
import com.sipai.tools.CommString;
|
||||
import com.sipai.tools.CommUtil;
|
||||
import com.sipai.tools.JwtUtil;
|
||||
import com.sipai.tools.SessionManager;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.AuthenticationServiceException;
|
||||
import org.springframework.security.core.context.SecurityContextImpl;
|
||||
import org.springframework.security.web.WebAttributes;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(value = "Login")
|
||||
@Api(value = "Login", tags = "登录")
|
||||
public class LoginServlet {
|
||||
|
||||
@Resource
|
||||
private LoginService loginService;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Resource
|
||||
private MenuService menuService;
|
||||
|
||||
@Resource
|
||||
private UserDetailService userDetailService;
|
||||
|
||||
@Resource
|
||||
private MyUserDetailServiceImpl myUserDetailServiceImpl;
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
@Resource
|
||||
private ExtSystemService extSystemService;
|
||||
@Resource
|
||||
private BasicComponentsService basicComponentsService;
|
||||
|
||||
@RequestMapping(value = "login.do", method = RequestMethod.GET)
|
||||
public ModelAndView login(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model) {
|
||||
HttpSession session = request.getSession(false);
|
||||
String password = null;
|
||||
if(session.getAttribute("password")!=null){
|
||||
password = session.getAttribute("password").toString();
|
||||
}
|
||||
if (SessionManager.isOnline(session)) {
|
||||
/*User cu= (User)request.getSession().getAttribute("cu");
|
||||
List<Menu> list = this.menuService.getFullPower(cu.getId());
|
||||
if(list!=null &&list.size()>0){
|
||||
for(int i=list.size()-1;i>=0;i--){
|
||||
Menu menu=list.get(i);
|
||||
if((menu.getType() !=null && menu.getType().equals("func"))
|
||||
|| (menu.getActive() !=null && menu.getActive().equals("禁用"))){
|
||||
list.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
model.addAttribute("list",list);*/
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
if (cu != null) {
|
||||
JSONObject basicPW = basicPassword(password,cu.getId());
|
||||
String code =basicPW.get("code").toString();
|
||||
if("1".equals(code)){
|
||||
//需要跳转
|
||||
//修改密码配置信息
|
||||
JSONArray jsonArray = basicComponentsService.selectListByWhereAll("where active='1' and code like '%password%' order by morder ");
|
||||
if (jsonArray != null && jsonArray.size() > 0) {
|
||||
model.addAttribute("jsonArray", jsonArray);
|
||||
}
|
||||
if(basicPW.get("titleStr")!=null && !basicPW.get("titleStr").toString().isEmpty()){
|
||||
model.addAttribute("titleStr", basicPW.get("titleStr").toString());
|
||||
}
|
||||
return new ModelAndView("forcePasswordChange");
|
||||
}
|
||||
if (cu.getName().equals("admin")) {
|
||||
model.addAttribute("mqttId", cu.getName() + "_web_" + CommUtil.getUUID());
|
||||
} else {
|
||||
model.addAttribute("mqttId", cu.getName() + "_web");
|
||||
}
|
||||
|
||||
Unit unit = this.unitService.getUserBelongingCompany(cu.getId());
|
||||
if (unit != null) {
|
||||
model.addAttribute("top_user_companyId", unit.getId());
|
||||
model.addAttribute("top_user_companyType", unit.getType());
|
||||
}
|
||||
model.addAttribute("top_userId", cu.getId());
|
||||
|
||||
}
|
||||
return new ModelAndView("frameset");
|
||||
}
|
||||
try {
|
||||
//默认使用login-title、login-bottomlogo作为登录页所需代码
|
||||
JSONArray jsonArray = basicComponentsService.selectListByWhereAll("where active='1' and code like '%login%' order by morder ");
|
||||
if (jsonArray != null && jsonArray.size() > 0) {
|
||||
model.addAttribute("jsonArray", jsonArray);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new ModelAndView("login");
|
||||
}
|
||||
@ApiOperation(value = "判断密码情况", notes = "判断密码情况", httpMethod = "GET")
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "loginCheck.do", method = RequestMethod.GET)
|
||||
public ModelAndView loginCheck(HttpServletRequest request,HttpServletResponse response, Model model) {
|
||||
HttpSession session = request.getSession(false);
|
||||
String password = null;
|
||||
if(session.getAttribute("password")!=null){
|
||||
password = session.getAttribute("password").toString();
|
||||
}
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
JSONObject basicPW = basicPassword(password,cu.getId());
|
||||
String code =basicPW.get("code").toString();
|
||||
int passwordMaxNum =18;
|
||||
int passwordMinNum =10;
|
||||
List<BasicComponents> passwordMax_list = basicComponentsService.selectListByWhere("where active='1' and code like '%password-max%' order by morder");
|
||||
if (passwordMax_list != null && passwordMax_list.size() > 0) {
|
||||
BasicComponents passwordMax = passwordMax_list.get(0);
|
||||
passwordMaxNum = Integer.parseInt(passwordMax.getBasicConfigure().getType());
|
||||
}
|
||||
List<BasicComponents> passwordMin_list = basicComponentsService.selectListByWhere("where active='1' and code like '%password-min%' order by morder");
|
||||
if (passwordMin_list != null && passwordMin_list.size() > 0) {
|
||||
BasicComponents passwordMin = passwordMin_list.get(0);
|
||||
passwordMinNum = Integer.parseInt(passwordMin.getBasicConfigure().getType());
|
||||
}
|
||||
String result = "{\"code\":" + code + ",\"passwordMax\":\"" + passwordMaxNum + "\",\"passwordMin\":\"" + passwordMinNum + "\"}";
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
protected JSONObject basicPassword(String password,String userId) {
|
||||
JSONObject res = new JSONObject();
|
||||
String default_password = CommUtil.generatePassword(UserCommStr.default_password);
|
||||
//验证当前账号密码是否为默认密码,强制修改
|
||||
if (default_password.equals(password)) {
|
||||
res.put("code", 1);
|
||||
return res;
|
||||
//return new ModelAndView("forcePasswordChange");
|
||||
}
|
||||
//验证是否判断密码为强密码
|
||||
List<BasicComponents> passwordType_list = basicComponentsService.selectListByWhere("where active='1' and code like '%password-type%' order by morder");
|
||||
if (passwordType_list != null && passwordType_list.size() > 0) {
|
||||
BasicComponents passwordTypes = passwordType_list.get(0);
|
||||
String passwordType = passwordTypes.getBasicConfigure().getType();
|
||||
int passwordMaxNum =18;
|
||||
int passwordMinNum =10;
|
||||
List<BasicComponents> passwordMax_list = basicComponentsService.selectListByWhere("where active='1' and code like '%password-max%' order by morder");
|
||||
if (passwordMax_list != null && passwordMax_list.size() > 0) {
|
||||
BasicComponents passwordMax = passwordMax_list.get(0);
|
||||
passwordMaxNum = Integer.parseInt(passwordMax.getBasicConfigure().getType());
|
||||
}
|
||||
List<BasicComponents> passwordMin_list = basicComponentsService.selectListByWhere("where active='1' and code like '%password-min%' order by morder");
|
||||
if (passwordMin_list != null && passwordMin_list.size() > 0) {
|
||||
BasicComponents passwordMin = passwordMin_list.get(0);
|
||||
passwordMinNum = Integer.parseInt(passwordMin.getBasicConfigure().getType());
|
||||
}
|
||||
//首先判断是否配置了需要强密码
|
||||
if("strong".equals(passwordType)){
|
||||
//再判断是否为强密码
|
||||
if(!CommUtil.isStrongPwd(password,passwordMinNum,passwordMaxNum)){
|
||||
//不是则修改密码
|
||||
res.put("code", 1);
|
||||
return res;
|
||||
//return new ModelAndView("forcePasswordChange");
|
||||
}
|
||||
}
|
||||
}
|
||||
//验证是否判断密码超时
|
||||
List<BasicComponents> basicComponents_list = basicComponentsService.selectListByWhere("where active='1' and code like '%password-overtime%' order by morder");
|
||||
if (basicComponents_list != null && basicComponents_list.size() > 0) {
|
||||
BasicComponents basicComponents = basicComponents_list.get(0);
|
||||
if (basicComponents != null && basicComponents.getBasicConfigure() != null) {
|
||||
BasicConfigure basicConfigure = basicComponents.getBasicConfigure();
|
||||
if (basicConfigure != null) {
|
||||
String initial_time = "";
|
||||
int days = 30;
|
||||
//type设置强制修改密码天数
|
||||
if (basicConfigure.getType() != null && !basicConfigure.getType().isEmpty()) {
|
||||
//验证是否为数字
|
||||
if (CommUtil.isNumeric(basicConfigure.getType())) {
|
||||
days = Integer.parseInt(basicConfigure.getType());
|
||||
}
|
||||
}
|
||||
UserDetail userDetail = userDetailService.selectByUserId(userId);
|
||||
if (userDetail != null) {
|
||||
if (userDetail.getLastlogintime() != null
|
||||
&& !userDetail.getLastlogintime().isEmpty()) {
|
||||
//用户附属表中Lastlogintime为初始判断时间
|
||||
initial_time = userDetail.getLastlogintime();
|
||||
} else {
|
||||
if (userDetail.getInsdt() != null
|
||||
&& !userDetail.getInsdt().isEmpty()) {
|
||||
//用户附属表中Insdt为初始判断时间
|
||||
initial_time = userDetail.getInsdt();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//insdt设置初始时间
|
||||
if (basicConfigure.getInsdt() != null && !basicConfigure.getInsdt().isEmpty()) {
|
||||
initial_time = basicConfigure.getInsdt();
|
||||
}
|
||||
}
|
||||
if (initial_time != null && !initial_time.isEmpty()) {
|
||||
String nowDate = CommUtil.nowDate();
|
||||
int difference = CommUtil.getDays(nowDate, initial_time);
|
||||
//当前时间与设置时间的差值大于强制修改密码天数,则跳转强制修改
|
||||
if (difference > days) {
|
||||
res.put("titleStr", "当前账号已超过" + days + "天未修改密码,为了安全起见,请修改密码。");
|
||||
res.put("code", 1);
|
||||
return res;
|
||||
//return new ModelAndView("forcePasswordChange");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
res.put("code", 0);
|
||||
return res;
|
||||
}
|
||||
@RequestMapping(value = "main.do", method = RequestMethod.GET)
|
||||
public ModelAndView main(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model) {
|
||||
HttpSession session = request.getSession(false);
|
||||
|
||||
String rptdt = CommUtil.nowDate().substring(0, 7);
|
||||
request.setAttribute("datestr", rptdt.substring(0, 4) + "");
|
||||
|
||||
return new ModelAndView("main");
|
||||
}
|
||||
|
||||
//上实
|
||||
// @RequestMapping(value = "main.do", method = RequestMethod.GET)
|
||||
// public ModelAndView main(HttpServletRequest request,
|
||||
// HttpServletResponse response,Model model) {
|
||||
// HttpSession session = request.getSession(false);
|
||||
// return new ModelAndView("/work/overviewProduceGroup");
|
||||
// }
|
||||
@RequestMapping(value = "main3.do", method = RequestMethod.GET)
|
||||
public ModelAndView main3(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model) {
|
||||
HttpSession session = request.getSession(false);
|
||||
return new ModelAndView("main3");
|
||||
}
|
||||
|
||||
/**
|
||||
* 重庆白羊摊首页
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "mainCQBYT.do", method = RequestMethod.GET)
|
||||
public ModelAndView mainCQBYT(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model) {
|
||||
HttpSession session = request.getSession(false);
|
||||
return new ModelAndView("main_CQBYT");
|
||||
}
|
||||
|
||||
/**
|
||||
* 金山首页 金山排海层级
|
||||
* sj 2021-09-17
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "main_JS_Company.do", method = RequestMethod.GET)
|
||||
public ModelAndView main_JS_Company(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model) {
|
||||
HttpSession session = request.getSession(false);
|
||||
return new ModelAndView("main_JS_Company");
|
||||
}
|
||||
|
||||
/**
|
||||
* 金山首页 分厂层级
|
||||
* sj 2021-09-17
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "main_JS_Factory.do", method = RequestMethod.GET)
|
||||
public ModelAndView main_JS_Factory(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model) {
|
||||
HttpSession session = request.getSession(false);
|
||||
return new ModelAndView("main_JS_Factory");
|
||||
}
|
||||
|
||||
/**
|
||||
* 淄博首页
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "mainZB.do", method = RequestMethod.GET)
|
||||
public ModelAndView mainZB(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model) {
|
||||
HttpSession session = request.getSession(false);
|
||||
return new ModelAndView("main_zibo");
|
||||
}
|
||||
|
||||
/**
|
||||
* 虹桥安全首页
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "mainHQAQ.do", method = RequestMethod.GET)
|
||||
public ModelAndView mainHQAQ(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model) {
|
||||
HttpSession session = request.getSession(false);
|
||||
return new ModelAndView("main_HQAQ");
|
||||
}
|
||||
/**
|
||||
* 注册页面
|
||||
*/
|
||||
@RequestMapping(value = "register.do", method = RequestMethod.GET)
|
||||
public ModelAndView register(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model) {
|
||||
String unitId = request.getParameter("unitId");
|
||||
Unit unit = unitService.getUnitById(unitId);
|
||||
request.setAttribute("unit", unit);
|
||||
return new ModelAndView("register");
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示所有厂区汇总信息
|
||||
*/
|
||||
@RequestMapping(value = "showStatisticalInfo.do")
|
||||
public ModelAndView showStatisticalInfo(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model) {
|
||||
ExtSystem extSystem = this.extSystemService.getActiveDataManage(null);
|
||||
String url = "";
|
||||
if (extSystem != null) {
|
||||
url = extSystem.getUrl();
|
||||
}
|
||||
url += "/proapp.do?method=getStatisticalInfo";
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
String resp = com.sipai.tools.HttpUtil.sendPost(url, map);
|
||||
request.setAttribute("url", extSystem.getUrl());
|
||||
//JSONObject jsonObject = JSONObject.fromObject(resp);
|
||||
try {
|
||||
/*JSONObject re1=jsonObject.getJSONObject("re1");
|
||||
String result="{\"total\":"+re1.get("total")+",\"rows\":"+re1.getJSONArray("rows")+"}";*/
|
||||
// System.out.println(result);
|
||||
model.addAttribute("resp", resp);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new ModelAndView("statisticalInfo");
|
||||
}
|
||||
|
||||
@RequestMapping(value = "doPass.do", method = RequestMethod.GET, produces = "text/html;charset=UTF-8")
|
||||
public @ResponseBody
|
||||
JSONObject doPass(HttpServletRequest request, Model model) {
|
||||
SecurityContextImpl securityContextImpl = (SecurityContextImpl) request
|
||||
.getSession().getAttribute("SPRING_SECURITY_CONTEXT");
|
||||
String result = "";
|
||||
String unitId = "";
|
||||
if (securityContextImpl != null) {
|
||||
//设置cu其他信息
|
||||
String userName = securityContextImpl.getAuthentication().getName();
|
||||
User cu = userService.getUserById(userName);
|
||||
cu.setCurrentip(request.getRemoteAddr());
|
||||
cu.setLastlogintime(CommUtil.nowDate());
|
||||
UserDetail userDetail = this.userDetailService.selectByUserId(cu.getId());
|
||||
cu.setUserDetail(userDetail);
|
||||
if (cu.getThemeclass() == null || cu.getThemeclass().isEmpty()) {
|
||||
cu.setThemeclass(CommString.Default_Theme);
|
||||
}
|
||||
Company company = unitService.getCompanyByUserId(cu.getId());
|
||||
if (company != null) {
|
||||
cu.set_pname(company.getSname());
|
||||
unitId = company.getId();
|
||||
} else {
|
||||
//cu.set_pname("平台");
|
||||
List<Company> companies = unitService.getCompaniesByWhere("where pid='-1' and type='C'");
|
||||
if (companies != null) {
|
||||
cu.set_pname(companies.get(0).getSname());
|
||||
unitId = companies.get(0).getId();
|
||||
}
|
||||
}
|
||||
//设置session
|
||||
HttpSession newSession = request.getSession(true);
|
||||
newSession.setAttribute("cu", cu);
|
||||
newSession.setAttribute("unitId", unitId);
|
||||
String token = JwtUtil.sign(cu.getName(), cu.getId());
|
||||
result ="{\"status\":" + true +",\"res\":"+ JSONObject.toJSONString(cu) +
|
||||
",\"Access_Token\":\""+ token +"\"}";
|
||||
}
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "doFail.do")
|
||||
public @ResponseBody
|
||||
JSONObject doFail(HttpServletRequest request, Model model) {
|
||||
AuthenticationServiceException respp = (AuthenticationServiceException) request.getSession().getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
|
||||
String messange = respp.getMessage();
|
||||
String result = "{\"status\":" + false + ",\"res\":\"" + messange + "\"}";
|
||||
return JSONObject.parseObject(result);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "logout.do", method = RequestMethod.POST)
|
||||
public ModelAndView logout(HttpServletRequest request,
|
||||
HttpServletResponse response) throws UnsupportedEncodingException {
|
||||
HttpSession session = request.getSession(false);
|
||||
if (null != session) {
|
||||
session.invalidate();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "validate.do")
|
||||
public ModelAndView validate(HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
@RequestParam(value = "j_username", required = false) String j_username,
|
||||
@RequestParam(value = "j_password", required = false) String j_password) {
|
||||
User cu = new User();
|
||||
if (j_username != null && j_password != null) {
|
||||
cu = loginService.Login(j_username, j_password);
|
||||
} else {
|
||||
cu = null;
|
||||
}
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
if (null != cu) {
|
||||
|
||||
//设置cu其他信息
|
||||
cu.setCurrentip(request.getRemoteAddr());
|
||||
cu.setLastlogintime(CommUtil.nowDate());
|
||||
|
||||
HttpSession currentSession = request.getSession(false);
|
||||
if (null != currentSession) {
|
||||
currentSession.invalidate();
|
||||
}
|
||||
//设置session
|
||||
HttpSession newSession = request.getSession(true);
|
||||
newSession.setAttribute("cu", cu);
|
||||
if (CommUtil.checkFrontEnd(request)) {
|
||||
// JSONObject cuId = JSONObject.fromObject(cu.getId());
|
||||
map.put("result", "{\"res\":" + true + ",\"cuId\":\"" + cu.getId() + "\"}");
|
||||
return new ModelAndView("result", map);
|
||||
}
|
||||
map.put("result", true);
|
||||
|
||||
} else {
|
||||
map.put("result", false);
|
||||
}
|
||||
|
||||
return new ModelAndView("result", map);
|
||||
}
|
||||
|
||||
private boolean checkPassword(String psw) {
|
||||
boolean result = false;
|
||||
String regex = "^[a-zA-Z0-9]+$";
|
||||
if (null != psw) {
|
||||
result = psw.matches(regex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*@RequestMapping(value = "resetPwd.do", method = RequestMethod.POST)
|
||||
public ModelAndView resetPwd(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model,
|
||||
@RequestParam(value = "loadNewPassword") String loadNewPassword) {
|
||||
User cu = (User)request.getSession().getAttribute("cu");
|
||||
String loadOldPassword=cu.getPassword();
|
||||
|
||||
String result = "";
|
||||
if (checkPassword(loadOldPassword) && checkPassword(loadNewPassword)) {
|
||||
if (loadOldPassword.equals(loadNewPassword)) {
|
||||
result= "请不要与原密码相同";
|
||||
} else {
|
||||
if (userService.resetpassword(cu,loadNewPassword)==1) {
|
||||
result = "成功";
|
||||
} else {
|
||||
result = "用户不存在或原密码错误,请重新输入";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result= "请输入正确信息,密码只可以是字母或者数字";
|
||||
}
|
||||
// System.out.println(result);
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}*/
|
||||
|
||||
@RequestMapping("/mainPageImg.do")
|
||||
public String mainPageImg(HttpServletRequest request, Model model) {
|
||||
return "/fwk/mainPageImg";
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping("/doLogin4Name.do")
|
||||
public JSONObject doLogin4Name(HttpServletRequest request, Model model) {
|
||||
String userName = request.getParameter("userName");
|
||||
String result = "";
|
||||
String unitId = "";
|
||||
JSONObject jsonObject = null;
|
||||
//设置cu其他信息
|
||||
User cu = userService.getUserByLoginName(userName);
|
||||
if (cu != null) {
|
||||
cu.setCurrentip(request.getRemoteAddr());
|
||||
cu.setLastlogintime(CommUtil.nowDate());
|
||||
UserDetail userDetail = this.userDetailService.selectByUserId(cu.getId());
|
||||
cu.setUserDetail(userDetail);
|
||||
if (cu.getThemeclass() == null || cu.getThemeclass().isEmpty()) {
|
||||
cu.setThemeclass(CommString.Default_Theme);
|
||||
}
|
||||
Company company = unitService.getCompanyByUserId(cu.getId());
|
||||
if (company != null) {
|
||||
cu.set_pname(company.getSname());
|
||||
unitId = company.getId();
|
||||
} else {
|
||||
//cu.set_pname("平台");
|
||||
List<Company> companies = unitService.getCompaniesByWhere("where pid='-1' and type='C'");
|
||||
if (companies != null) {
|
||||
cu.set_pname(companies.get(0).getSname());
|
||||
unitId = companies.get(0).getId();
|
||||
}
|
||||
}
|
||||
//设置session
|
||||
HttpSession newSession = request.getSession(true);
|
||||
newSession.setAttribute("cu", cu);
|
||||
newSession.setAttribute("unitId", unitId);
|
||||
|
||||
// result ="{\"status\":" + true +",\"res\":"+ JSONObject.toJSONString(cu) +"}";
|
||||
result = "{\"status\":" + true + "}";
|
||||
jsonObject = JSONObject.parseObject(result);
|
||||
} else {
|
||||
result = "{\"status\":" + false + "}";
|
||||
jsonObject = JSONObject.parseObject(result);
|
||||
}
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping("/doLogin4NameIn.do")
|
||||
public ModelAndView doLogin4NameIn(HttpServletRequest request, Model model) {
|
||||
String userName = request.getParameter("userName");
|
||||
String result = "";
|
||||
String unitId = "";
|
||||
JSONObject jsonObject = null;
|
||||
//设置cu其他信息
|
||||
// User cu = userService.getUserByLoginName(userName);
|
||||
User cu = new User();
|
||||
cu = loginService.NameLogin(userName);
|
||||
if (cu != null) {
|
||||
cu.setCurrentip(request.getRemoteAddr());
|
||||
cu.setLastlogintime(CommUtil.nowDate());
|
||||
UserDetail userDetail = this.userDetailService.selectByUserId(cu.getId());
|
||||
cu.setUserDetail(userDetail);
|
||||
if (cu.getThemeclass() == null || cu.getThemeclass().isEmpty()) {
|
||||
cu.setThemeclass(CommString.Default_Theme);
|
||||
}
|
||||
Company company = unitService.getCompanyByUserId(cu.getId());
|
||||
if (company != null) {
|
||||
cu.set_pname(company.getSname());
|
||||
unitId = company.getId();
|
||||
} else {
|
||||
//cu.set_pname("平台");
|
||||
List<Company> companies = unitService.getCompaniesByWhere("where pid='-1' and type='C'");
|
||||
if (companies != null) {
|
||||
cu.set_pname(companies.get(0).getSname());
|
||||
unitId = companies.get(0).getId();
|
||||
}
|
||||
}
|
||||
|
||||
//设置session
|
||||
HttpSession newSession = request.getSession(true);
|
||||
newSession.setAttribute("cu", cu);
|
||||
newSession.setAttribute("unitId", unitId);
|
||||
|
||||
if (cu.getName().equals("admin")) {
|
||||
model.addAttribute("mqttId", cu.getName() + "_web_" + CommUtil.getUUID());
|
||||
} else {
|
||||
model.addAttribute("mqttId", cu.getName() + "_web");
|
||||
}
|
||||
|
||||
Unit unit = this.unitService.getUserBelongingCompany(cu.getId());
|
||||
if (unit != null) {
|
||||
model.addAttribute("top_user_companyId", unit.getId());
|
||||
model.addAttribute("top_user_companyType", unit.getType());
|
||||
}
|
||||
model.addAttribute("top_userId", cu.getId());
|
||||
|
||||
return new ModelAndView("frameset");
|
||||
} else {
|
||||
result = "{\"status\":" + false + "}";
|
||||
jsonObject = JSONObject.parseObject(result);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final String USERNAME = "j_username";
|
||||
public static final String PASSWORD = "j_password";
|
||||
@RequestMapping(value = "getToken.do", method = RequestMethod.POST)
|
||||
public void getToken(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model) throws IOException {
|
||||
|
||||
String username = obtainUsername(request);
|
||||
String password = obtainPassword(request);
|
||||
//验证用户账号与密码是否对应
|
||||
username = username.trim();
|
||||
User user =loginService.NameLogin(username);
|
||||
Result result = null;
|
||||
if(user == null || !user.getPassword().equals(password)) {
|
||||
result = Result.failed("用户名或者密码错误!");
|
||||
}else{
|
||||
String token = JwtUtil.sign(user.getName(), user.getId());
|
||||
String res ="{\"Access_Token\":\""+ token +"\"}";
|
||||
result = Result.success(res,"获取成功!");
|
||||
}
|
||||
|
||||
String jsonStr = JSON.toJSONString(result);
|
||||
response.setCharacterEncoding("UTF-8");// 设置将字符以"UTF-8"编码输出到
|
||||
response.getWriter().println(jsonStr);
|
||||
response.getWriter().flush();
|
||||
}
|
||||
protected String obtainUsername(HttpServletRequest request) {
|
||||
Object obj = request.getParameter(USERNAME);
|
||||
return null == obj ? "" : obj.toString();
|
||||
}
|
||||
protected String obtainPassword(HttpServletRequest request) {
|
||||
Object obj = request.getParameter(PASSWORD);
|
||||
return null == obj ? "" : obj.toString();
|
||||
}
|
||||
/**
|
||||
* 通用建设中界面
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "building.do", method = RequestMethod.GET)
|
||||
public ModelAndView building(HttpServletRequest request,
|
||||
HttpServletResponse response, Model model) {
|
||||
HttpSession session = request.getSession(false);
|
||||
return new ModelAndView("building");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
package com.sipai.controller.base;
|
||||
|
||||
import com.sipai.entity.base.MainConfig;
|
||||
import com.sipai.service.base.MainConfigService;
|
||||
import com.sipai.tools.CommString;
|
||||
import net.sf.json.JSONArray;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/base/mainConfig")
|
||||
public class MainConfigController {
|
||||
@Resource
|
||||
private MainConfigService mainConfigService;
|
||||
|
||||
/**
|
||||
* 获取首页配置的点位信息
|
||||
*
|
||||
* @param request
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getJson.do")
|
||||
public ModelAndView getJson(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "unitId") String unitId) {
|
||||
String result = "";
|
||||
try {
|
||||
String orderstr = " order by morder asc";
|
||||
String wherestr = " where 1=1";
|
||||
if (unitId != null && !unitId.equals("")) {
|
||||
wherestr += " and unit_id = '" + unitId + "' ";
|
||||
}
|
||||
List<MainConfig> list = mainConfigService.selectListByWhere(wherestr + orderstr);
|
||||
|
||||
JSONArray json1 = JSONArray.fromObject(list);
|
||||
result = "{\"status\":\"" + CommString.Status_Pass + "\",\"mpcode\":" + json1 + "}";
|
||||
} catch (Exception e) {
|
||||
result = "{\"status\":\"" + CommString.Status_Fail + "\"}";
|
||||
}
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
}
|
||||
206
src/main/java/com/sipai/controller/base/MainPageController.java
Normal file
206
src/main/java/com/sipai/controller/base/MainPageController.java
Normal file
@ -0,0 +1,206 @@
|
||||
package com.sipai.controller.base;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.base.MainPage;
|
||||
import com.sipai.entity.base.MainPageType;
|
||||
import com.sipai.entity.scada.MPoint4APP;
|
||||
import com.sipai.entity.user.Company;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.base.MainPageService;
|
||||
import com.sipai.service.base.MainPageTypeService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.tools.CommString;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/base/mainPage")
|
||||
public class MainPageController {
|
||||
@Resource
|
||||
private MainPageService mainPageService;
|
||||
@Resource
|
||||
private MainPageTypeService mainPageTypeService;
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
@RequestMapping("/showlist.do")
|
||||
public String showlist(HttpServletRequest request,Model model) {
|
||||
return "/base/mainPageManage";
|
||||
}
|
||||
@RequestMapping("/getlist.do")
|
||||
public ModelAndView getlist(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required=false) String sort,
|
||||
@RequestParam(value = "order", required=false) String order) {
|
||||
User cu=(User)request.getSession().getAttribute("cu");
|
||||
// if(cu==null){
|
||||
// cu=loginService.Login(request.getParameter("username"), request.getParameter("pwd"));
|
||||
// }
|
||||
String orderstr=" order by morder asc";
|
||||
|
||||
String wherestr=" where 1=1 ";
|
||||
if (request.getParameter("bizId")!=null && !request.getParameter("bizId").toString().isEmpty()) {
|
||||
wherestr+= " and biz_id ='"+request.getParameter("bizId").toString()+"' ";
|
||||
}
|
||||
if (request.getParameter("type")!=null && !request.getParameter("type").toString().isEmpty()) {
|
||||
wherestr+= " and type ='"+request.getParameter("type").toString()+"' ";
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<MainPage> list = this.mainPageService.selectListByWhere(wherestr+orderstr);
|
||||
|
||||
PageInfo<MainPage> pi = new PageInfo<MainPage>(list);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
|
||||
String result="{\"total\":"+pi.getTotal()+",\"rows\":"+json+"}";
|
||||
// System.out.println(result);
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
@RequestMapping("/getAllList.do")
|
||||
public ModelAndView getAllList(HttpServletRequest request,Model model) {
|
||||
String orderstr=" order by type , show_way ,morder asc";
|
||||
String wherestr=" where 1=1 ";
|
||||
if (request.getParameter("bizId")!=null && !request.getParameter("bizId").toString().isEmpty()) {
|
||||
wherestr+= " and biz_id ='"+request.getParameter("bizId").toString()+"' ";
|
||||
}
|
||||
if (request.getParameter("type")!=null && !request.getParameter("type").toString().isEmpty()) {
|
||||
wherestr+= " and type ='"+request.getParameter("type").toString()+"' ";
|
||||
}
|
||||
if (request.getParameter("showWay")!=null && !request.getParameter("showWay").toString().isEmpty()) {
|
||||
wherestr+= " and show_way in ('"+request.getParameter("showWay").toString().replace(",", "','")+"') ";
|
||||
}
|
||||
List<MainPage> list = this.mainPageService.selectListByWhere(wherestr+orderstr);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
// System.out.println(result);
|
||||
model.addAttribute("result",json);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
@RequestMapping("/add.do")
|
||||
public String doadd(HttpServletRequest request,Model model){
|
||||
/*
|
||||
String orderstr=" order by morder asc";
|
||||
String wherestr=" where 1=1 ";
|
||||
if (request.getParameter("bizId")!=null && !request.getParameter("bizId").toString().isEmpty()) {
|
||||
wherestr+= " and biz_id ='"+request.getParameter("bizId").toString()+"' ";
|
||||
}
|
||||
List<MainPageType> list = this.mainPageTypeService.selectListByWhere(wherestr+orderstr);
|
||||
*/
|
||||
String companyId= request.getParameter("bizId");
|
||||
String mainPageTypeId= request.getParameter("id");
|
||||
Company company = this.unitService.getCompById(companyId);
|
||||
request.setAttribute("company", company);
|
||||
request.setAttribute("mainPageTypeId", mainPageTypeId);
|
||||
//request.setAttribute("list",list);
|
||||
return "base/mainPageAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/edit.do")
|
||||
public String doedit(HttpServletRequest request,Model model){
|
||||
String groupId = request.getParameter("id");
|
||||
MainPage mainPage = this.mainPageService.selectById(groupId);
|
||||
Company company = this.unitService.getCompById(mainPage.getBizId());
|
||||
request.setAttribute("company", company);
|
||||
model.addAttribute("mainPage", mainPage);
|
||||
return "base/mainPageEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/save.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute MainPage mainPage){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
String id = CommUtil.getUUID();
|
||||
mainPage.setId(id);
|
||||
mainPage.setInsuser(cu.getId());
|
||||
mainPage.setInsdt(CommUtil.nowDate());
|
||||
|
||||
int result =this.mainPageService.save(mainPage);
|
||||
/*if(result>0){
|
||||
groupMemberService.saveMembers(group.getId(), request.getParameter("leaderid"), "leader");
|
||||
groupMemberService.saveMembers(group.getId(), request.getParameter("memberid"), "member");
|
||||
groupMemberService.saveMembers(group.getId(), request.getParameter("chiefid"), "chief");
|
||||
}*/
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+id+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
@RequestMapping("/update.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute MainPage mainPage){
|
||||
int result = this.mainPageService.update(mainPage);
|
||||
/*if(result>0){
|
||||
groupMemberService.deleteByGroupId(group.getId());
|
||||
groupMemberService.saveMembers(group.getId(), request.getParameter("leaderid"), "leader");
|
||||
groupMemberService.saveMembers(group.getId(), request.getParameter("memberid"), "member");
|
||||
groupMemberService.saveMembers(group.getId(), request.getParameter("chiefid"), "chief");
|
||||
}*/
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+mainPage.getId()+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/delete.do")
|
||||
public String dodel(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id){
|
||||
int result = this.mainPageService.deleteById(id);
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/deletes.do")
|
||||
public String dodels(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="ids") String ids){
|
||||
ids=ids.replace(",","','");
|
||||
int result = this.mainPageService.deleteByWhere("where id in ('"+ids+"')");
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
/***
|
||||
* APP接口。获取主页分类配置信息
|
||||
* @param request
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getList4APPBySort.do")
|
||||
public ModelAndView getList4APPBySort(HttpServletRequest request,Model model) {
|
||||
// if(cu==null){
|
||||
// cu=loginService.Login(request.getParameter("username"), request.getParameter("pwd"));
|
||||
// }
|
||||
String result = "";
|
||||
try{
|
||||
String orderstr=" order by type , show_way ,morder asc";
|
||||
|
||||
String wherestr=" where 1=1";
|
||||
if (request.getParameter("bizid")!=null && !request.getParameter("bizid").toString().isEmpty()) {
|
||||
wherestr+= " and biz_id ='"+request.getParameter("bizid").toString()+"' ";
|
||||
}
|
||||
List<MPoint4APP> list1 = this.mainPageService.selectListByWhere4App(wherestr+orderstr);
|
||||
|
||||
JSONArray json1=JSONArray.fromObject(list1);
|
||||
result="{\"status\":\""+CommString.Status_Pass+"\",\"content1\":"+json1+"}";
|
||||
}catch(Exception e){
|
||||
result="{\"status\":\""+CommString.Status_Fail+"\"}";
|
||||
//System.out.println(e);
|
||||
}
|
||||
|
||||
// System.out.println(result);
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,194 @@
|
||||
package com.sipai.controller.base;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.base.MainPage;
|
||||
import com.sipai.entity.base.MainPageType;
|
||||
import com.sipai.entity.user.Company;
|
||||
import com.sipai.entity.user.Unit;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.entity.work.Group;
|
||||
import com.sipai.entity.work.GroupMember;
|
||||
import com.sipai.entity.work.UserWorkStation;
|
||||
import com.sipai.service.base.LoginService;
|
||||
import com.sipai.service.base.MainPageService;
|
||||
import com.sipai.service.base.MainPageTypeService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.service.work.GroupMemberService;
|
||||
import com.sipai.service.work.GroupService;
|
||||
import com.sipai.tools.CommString;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/base/mainPageType")
|
||||
public class MainPageTypeController {
|
||||
@Resource
|
||||
private MainPageTypeService mainPageTypeService;
|
||||
@Resource
|
||||
private MainPageService mainPageService;
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
@RequestMapping("/showlist.do")
|
||||
public String showlist(HttpServletRequest request,Model model) {
|
||||
return "/base/mainPageTypeList";
|
||||
}
|
||||
@RequestMapping("/getlist.do")
|
||||
public ModelAndView getlist(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required=false) String sort,
|
||||
@RequestParam(value = "order", required=false) String order) {
|
||||
User cu=(User)request.getSession().getAttribute("cu");
|
||||
// if(cu==null){
|
||||
// cu=loginService.Login(request.getParameter("username"), request.getParameter("pwd"));
|
||||
// }
|
||||
String orderstr=" order by morder asc";
|
||||
|
||||
String wherestr=" where 1=1 ";
|
||||
/*
|
||||
if (request.getParameter("mainPageTypeId")!=null && !request.getParameter("mainPageTypeId").toString().isEmpty()) {
|
||||
wherestr+= " and id ='"+request.getParameter("mainPageTypeId").toString()+"' ";
|
||||
}
|
||||
*/
|
||||
if (request.getParameter("bizId")!=null && !request.getParameter("bizId").toString().isEmpty()) {
|
||||
wherestr+= " and biz_id ='"+request.getParameter("bizId").toString()+"' ";
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<MainPageType> list = this.mainPageTypeService.selectListByWhere(wherestr+orderstr);
|
||||
|
||||
PageInfo<MainPageType> pi = new PageInfo<MainPageType>(list);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
|
||||
String result="{\"total\":"+pi.getTotal()+",\"rows\":"+json+"}";
|
||||
// System.out.println(result);
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
@RequestMapping("/getAllList.do")
|
||||
public ModelAndView getAllList(HttpServletRequest request,Model model) {
|
||||
String orderstr=" order by morder asc";
|
||||
String wherestr=" where 1=1 ";
|
||||
if (request.getParameter("bizId")!=null && !request.getParameter("bizId").toString().isEmpty()) {
|
||||
wherestr+= " and biz_id ='"+request.getParameter("bizId").toString()+"' ";
|
||||
}
|
||||
if (request.getParameter("type")!=null && !request.getParameter("type").toString().isEmpty()) {
|
||||
wherestr+= " and type ='"+request.getParameter("type").toString()+"' ";
|
||||
}
|
||||
List<MainPageType> list = this.mainPageTypeService.selectListByWhere(wherestr+orderstr);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
// System.out.println(result);
|
||||
model.addAttribute("result",json);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
@RequestMapping("/add.do")
|
||||
public String doadd(HttpServletRequest request,Model model){
|
||||
String companyId= request.getParameter("bizId");
|
||||
Company company = this.unitService.getCompById(companyId);
|
||||
request.setAttribute("company", company);
|
||||
return "base/mainPageTypeAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/edit.do")
|
||||
public String doedit(HttpServletRequest request,Model model){
|
||||
String groupId = request.getParameter("id");
|
||||
MainPageType mainPageType = this.mainPageTypeService.selectById(groupId);
|
||||
Company company = this.unitService.getCompById(mainPageType.getBizId());
|
||||
request.setAttribute("company", company);
|
||||
model.addAttribute("mainPageType", mainPageType);
|
||||
return "base/mainPageTypeEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/save.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute MainPageType mainPageType){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
String id = CommUtil.getUUID();
|
||||
mainPageType.setId(id);
|
||||
mainPageType.setInsuser(cu.getId());
|
||||
mainPageType.setInsdt(CommUtil.nowDate());
|
||||
|
||||
int result =this.mainPageTypeService.save(mainPageType);
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+id+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/update.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute MainPageType mainPageType){
|
||||
int result = this.mainPageTypeService.update(mainPageType);
|
||||
/*if(result>0){
|
||||
groupMemberService.deleteByGroupId(group.getId());
|
||||
groupMemberService.saveMembers(group.getId(), request.getParameter("leaderid"), "leader");
|
||||
groupMemberService.saveMembers(group.getId(), request.getParameter("memberid"), "member");
|
||||
groupMemberService.saveMembers(group.getId(), request.getParameter("chiefid"), "chief");
|
||||
}*/
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+mainPageType.getId()+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/delete.do")
|
||||
public String dodel(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="mainPageTypeId") String mainPageTypeId){
|
||||
int result = this.mainPageTypeService.deleteById(mainPageTypeId);
|
||||
String whereStr="where type ="+"'"+mainPageTypeId+"'";
|
||||
int resultNum=mainPageService.deleteByWhere(whereStr);
|
||||
model.addAttribute("result", result);
|
||||
model.addAttribute("resultNum", resultNum);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/deletes.do")
|
||||
public String dodels(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="ids") String ids){
|
||||
ids=ids.replace(",","','");
|
||||
int result = this.mainPageTypeService.deleteByWhere("where id in ('"+ids+"')");
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/getType4Select.do")
|
||||
public String getPatrolArea4Select(HttpServletRequest request,Model model){
|
||||
String orderstr=" order by morder asc";
|
||||
|
||||
String wherestr=" where 1=1 ";
|
||||
if (request.getParameter("mainPageTypeId")!=null && !request.getParameter("mainPageTypeId").toString().isEmpty()) {
|
||||
wherestr+= " and id ='"+request.getParameter("mainPageTypeId").toString()+"' ";
|
||||
}
|
||||
if (request.getParameter("bizId")!=null && !request.getParameter("bizId").toString().isEmpty()) {
|
||||
wherestr+= " and biz_id ='"+request.getParameter("bizId").toString()+"' ";
|
||||
}
|
||||
|
||||
List<MainPageType> list = this.mainPageTypeService.selectListByWhere(wherestr+orderstr);
|
||||
JSONArray json = new JSONArray();
|
||||
if(list!=null && list.size()>0){
|
||||
for(int i=0;i<list.size();i++){
|
||||
JSONObject jsonObject =new JSONObject();
|
||||
jsonObject.put("id", list.get(i).getId());
|
||||
jsonObject.put("text", list.get(i).getTitle());
|
||||
json.add(jsonObject);
|
||||
}
|
||||
}
|
||||
model.addAttribute("result", json.toString());
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,170 @@
|
||||
package com.sipai.controller.base;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.base.MainPage;
|
||||
import com.sipai.entity.base.MainPageType;
|
||||
import com.sipai.entity.base.MainPageTypeUser;
|
||||
import com.sipai.entity.user.Company;
|
||||
import com.sipai.entity.user.Unit;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.entity.work.Group;
|
||||
import com.sipai.entity.work.GroupMember;
|
||||
import com.sipai.entity.work.UserWorkStation;
|
||||
import com.sipai.service.base.LoginService;
|
||||
import com.sipai.service.base.MainPageService;
|
||||
import com.sipai.service.base.MainPageTypeService;
|
||||
import com.sipai.service.base.MainPageTypeUserService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.service.work.GroupMemberService;
|
||||
import com.sipai.service.work.GroupService;
|
||||
import com.sipai.tools.CommString;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/base/mainPageTypeUser")
|
||||
public class MainPageTypeUserController {
|
||||
@Resource
|
||||
private MainPageTypeUserService mainPageTypeUserService;
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
@RequestMapping("/showlist.do")
|
||||
public String showlist(HttpServletRequest request,Model model) {
|
||||
return "/base/mainPageTypeUserList";
|
||||
}
|
||||
@RequestMapping("/getlist.do")
|
||||
public ModelAndView getlist(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required=false) String sort,
|
||||
@RequestParam(value = "order", required=false) String order) {
|
||||
User cu=(User)request.getSession().getAttribute("cu");
|
||||
// if(cu==null){
|
||||
// cu=loginService.Login(request.getParameter("username"), request.getParameter("pwd"));
|
||||
// }
|
||||
String orderstr=" order by morder asc";
|
||||
|
||||
String wherestr=" where 1=1 ";
|
||||
if (request.getParameter("bizId")!=null && !request.getParameter("bizId").toString().isEmpty()) {
|
||||
wherestr+= " and biz_id ='"+request.getParameter("bizId").toString()+"' ";
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<MainPageTypeUser> list = this.mainPageTypeUserService.selectListByWhere(wherestr+orderstr);
|
||||
|
||||
PageInfo<MainPageTypeUser> pi = new PageInfo<MainPageTypeUser>(list);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
|
||||
String result="{\"total\":"+pi.getTotal()+",\"rows\":"+json+"}";
|
||||
// System.out.println(result);
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
@RequestMapping("/getAllList.do")
|
||||
public ModelAndView getAllList(HttpServletRequest request,Model model) {
|
||||
String orderstr=" order by morder asc";
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
String wherestr=" where 1=1 and insuser ='"+cu.getId()+"'";
|
||||
List<MainPageTypeUser> list = this.mainPageTypeUserService.selectListByWhere(wherestr+orderstr);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
// System.out.println(result);
|
||||
model.addAttribute("result",json);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
@RequestMapping("/add.do")
|
||||
public String doadd(HttpServletRequest request,Model model){
|
||||
String companyId= request.getParameter("bizId");
|
||||
Company company = this.unitService.getCompById(companyId);
|
||||
request.setAttribute("company", company);
|
||||
return "base/mainPageTypeUserAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/edit.do")
|
||||
public String doedit(HttpServletRequest request,Model model){
|
||||
String groupId = request.getParameter("id");
|
||||
MainPageTypeUser mainPageTypeUser = this.mainPageTypeUserService.selectById(groupId);
|
||||
model.addAttribute("mainPageTypeUser", mainPageTypeUser);
|
||||
return "base/mainPageTypeUserEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/save.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute MainPageTypeUser mainPageTypeUser){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
String id = CommUtil.getUUID();
|
||||
mainPageTypeUser.setId(id);
|
||||
mainPageTypeUser.setInsuser(cu.getId());
|
||||
mainPageTypeUser.setInsdt(CommUtil.nowDate());
|
||||
|
||||
int result =this.mainPageTypeUserService.save(mainPageTypeUser);
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+id+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
@RequestMapping("/update.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute MainPageTypeUser mainPageTypeUser){
|
||||
int result = this.mainPageTypeUserService.update(mainPageTypeUser);
|
||||
/*if(result>0){
|
||||
groupMemberService.deleteByGroupId(group.getId());
|
||||
groupMemberService.saveMembers(group.getId(), request.getParameter("leaderid"), "leader");
|
||||
groupMemberService.saveMembers(group.getId(), request.getParameter("memberid"), "member");
|
||||
groupMemberService.saveMembers(group.getId(), request.getParameter("chiefid"), "chief");
|
||||
}*/
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+mainPageTypeUser.getId()+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
@RequestMapping("/saveAndUpdate.do")
|
||||
public String dosaveAndUpdate(HttpServletRequest request,Model model){
|
||||
String mainPageTypeIds=request.getParameter("mainPageTypeIds");
|
||||
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
|
||||
int result =this.mainPageTypeUserService.saveAndUpdate(cu.getId(),mainPageTypeIds);
|
||||
String resstr="{\"res\":\""+result+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
@RequestMapping("/delete.do")
|
||||
public String dodel(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id){
|
||||
int result = this.mainPageTypeUserService.deleteById(id);
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/deletes.do")
|
||||
public String dodels(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="ids") String ids){
|
||||
ids=ids.replace(",","','");
|
||||
int result = this.mainPageTypeUserService.deleteByWhere("where id in ('"+ids+"')");
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/clearRecord.do")
|
||||
public String clearRecord(HttpServletRequest request,Model model){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
int result = this.mainPageTypeUserService.deleteByWhere("where insuser = '"+cu.getId()+"'");
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
118
src/main/java/com/sipai/controller/base/MinioController.java
Normal file
118
src/main/java/com/sipai/controller/base/MinioController.java
Normal file
@ -0,0 +1,118 @@
|
||||
package com.sipai.controller.base;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.sipai.entity.enums.FileNameSpaceEnum;
|
||||
import com.sipai.service.base.CommonFileService;
|
||||
import com.sipai.tools.MinioUtils;
|
||||
import io.swagger.annotations.*;
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用于传文件到minio 通用
|
||||
* sj 2022-09-08
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/minio")
|
||||
@Api(value = "/minio", tags = "文件管理")
|
||||
public class MinioController {
|
||||
@Autowired
|
||||
private MinioUtils minioUtils;
|
||||
@Autowired
|
||||
CommonFileService commonFileService;
|
||||
|
||||
@GetMapping("init")
|
||||
public String init() {
|
||||
return "file";
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件上传 (单个视频)
|
||||
*/
|
||||
@ApiOperation(value = "文件上传 (单个视频)", notes = "文件上传 (单个视频)", httpMethod = "POST")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求参数没填好")})
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "file", value = "MultipartFile源文件", dataType = "MultipartFile", paramType = "query", required = true),
|
||||
@ApiImplicitParam(name = "masterId", value = "表单id", dataType = "String", paramType = "query", required = true),
|
||||
@ApiImplicitParam(name = "nameSpace", value = "桶名称", dataType = "String", paramType = "query", required = true),
|
||||
@ApiImplicitParam(name = "tbName", value = "数据库表", dataType = "String", paramType = "query", required = true)
|
||||
})
|
||||
@RequestMapping(value = "/uploadVideo.do", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public String upload(HttpServletRequest request,
|
||||
@RequestParam(name = "file", required = false) MultipartFile file,
|
||||
@RequestParam(value = "masterId") String masterId,
|
||||
@RequestParam(value = "nameSpace") String nameSpace,
|
||||
@RequestParam(value = "tbName") String tbName) {
|
||||
System.out.println("uploadVideo");
|
||||
JSONObject res = null;
|
||||
try {
|
||||
res = minioUtils.uploadFile(file, masterId, nameSpace, tbName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
res.put("code", 0);
|
||||
res.put("msg", "上传失败");
|
||||
}
|
||||
return res.toJSONString();
|
||||
}
|
||||
|
||||
/**
|
||||
* minio 文件上传 (通用)
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "updateFile.do")
|
||||
public ModelAndView updateFile(HttpServletRequest request, HttpServletResponse response, Model model) {
|
||||
System.out.println("updateFile");
|
||||
Map<String, Object> ret = new HashMap<String, Object>();
|
||||
String masterId = request.getParameter("masterId");
|
||||
String nameSpace = request.getParameter("nameSpace");
|
||||
String tbName = request.getParameter("tbName");
|
||||
if (nameSpace != null && !nameSpace.isEmpty()) {
|
||||
if (tbName == null || tbName.isEmpty()) {
|
||||
tbName = FileNameSpaceEnum.getTbName(nameSpace);
|
||||
}
|
||||
}
|
||||
|
||||
if (ServletFileUpload.isMultipartContent(request)) {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
List<MultipartFile> fileList = multipartRequest.getFiles("filelist"); //控件id
|
||||
//for循环只执行一次
|
||||
for (MultipartFile item : fileList) {
|
||||
try {
|
||||
int res = commonFileService.updateFile(masterId, nameSpace, tbName, item);
|
||||
|
||||
if (res == 1) {
|
||||
ret.put("suc", true);
|
||||
} else {
|
||||
ret.put("suc", false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
ret.put("suc", false);
|
||||
ret.put("msg", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
String result = net.sf.json.JSONObject.fromObject(ret).toString();
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
}
|
||||
396
src/main/java/com/sipai/controller/base/PDFFileUtil.java
Normal file
396
src/main/java/com/sipai/controller/base/PDFFileUtil.java
Normal file
@ -0,0 +1,396 @@
|
||||
package com.sipai.controller.base;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.itextpdf.text.BaseColor;
|
||||
import com.itextpdf.text.Document;
|
||||
import com.itextpdf.text.DocumentException;
|
||||
import com.itextpdf.text.Element;
|
||||
import com.itextpdf.text.Font;
|
||||
import com.itextpdf.text.FontProvider;
|
||||
import com.itextpdf.text.PageSize;
|
||||
import com.itextpdf.text.Paragraph;
|
||||
import com.itextpdf.text.Phrase;
|
||||
import com.itextpdf.text.Rectangle;
|
||||
import com.itextpdf.text.pdf.BaseFont;
|
||||
import com.itextpdf.text.pdf.PdfPCell;
|
||||
import com.itextpdf.text.pdf.PdfPTable;
|
||||
import com.itextpdf.text.pdf.PdfWriter;
|
||||
import com.itextpdf.tool.xml.XMLWorkerHelper;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.xhtmlrenderer.pdf.ITextFontResolver;
|
||||
import org.xhtmlrenderer.pdf.ITextRenderer;
|
||||
|
||||
|
||||
public class PDFFileUtil {
|
||||
Document document = null;// 建立一个Document对象
|
||||
/* private static Font headFont ;
|
||||
private static Font keyFont ;
|
||||
private static Font nbspFont;
|
||||
private static Font textfont_H ;
|
||||
private static Font textfont_B ;
|
||||
private static Font textfont_13;
|
||||
private static Font textfont_12;
|
||||
private static Font textfont_11;
|
||||
private static Font textfont_10;
|
||||
private static Font textfont_9;
|
||||
private static Font textfont_8;
|
||||
private static Font textfont_7;
|
||||
private static Font textfont_6;
|
||||
int maxWidth = 520;*/
|
||||
|
||||
|
||||
public void createPDF(String outputPath, String xmlStr) {
|
||||
try {
|
||||
Document document = new Document();
|
||||
document.setPageSize(PageSize.A4);// 设置页面大小
|
||||
PdfWriter mPdfWriter = PdfWriter. getInstance(document, new FileOutputStream(outputPath));
|
||||
document.open();
|
||||
ByteArrayInputStream bin = new ByteArrayInputStream(xmlStr.getBytes());
|
||||
XMLWorkerHelper.getInstance().parseXHtml(mPdfWriter, document, bin, Charset.forName("UTF-8"), new ChinaFontProvide());
|
||||
/*BaseFont baseFont = BaseFont.createFont("C:/Windows/Fonts/SIMYOU.TTF",BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);
|
||||
|
||||
Font font = new Font(baseFont);
|
||||
document.add(new Paragraph("解决中文问题了!",font)); */
|
||||
document.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (DocumentException e) {
|
||||
e.printStackTrace();
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
/*Document document = new Document();
|
||||
try {
|
||||
|
||||
// 建立一个Document对象
|
||||
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
|
||||
Font keyfont = new Font(bfChinese, 11, Font.BOLD);// 设置字体大小
|
||||
Font textfont = new Font(bfChinese, 9, Font.NORMAL);// 设置字体大小
|
||||
document.setPageSize(PageSize.A4);// 设置页面大小
|
||||
PdfWriter.getInstance(document, new FileOutputStream(outputPath));
|
||||
document.open();
|
||||
PdfPTable table = createTable(new float[]{1f, 4f, 2f, 2f, 2.5f, 2.5f, 2f});
|
||||
table.addCell(createCell("编号", keyfont, Element.ALIGN_CENTER));
|
||||
table.addCell(createCell("文件名", keyfont, Element.ALIGN_CENTER));
|
||||
table.addCell(createCell("广告类型", keyfont, Element.ALIGN_CENTER));
|
||||
table.addCell(createCell("频道包", keyfont, Element.ALIGN_CENTER));
|
||||
table.addCell(createCell("开始日期", keyfont, Element.ALIGN_CENTER));
|
||||
table.addCell(createCell("结束日期", keyfont, Element.ALIGN_CENTER));
|
||||
table.addCell(createCell("缩略图", keyfont, Element.ALIGN_CENTER));
|
||||
//设置单元格
|
||||
document.add(table);
|
||||
document.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
}*/
|
||||
}
|
||||
public synchronized static boolean html2Pdf(String outputPath, String xmlStr) {
|
||||
|
||||
OutputStream os = null;
|
||||
try {
|
||||
//xmlStr = HtmlGenerator.generate("D:/Workspaces/SSMBootstrap/resources/freemaker/template/maintenanceViewTemplate.ftl", new HashMap<String, Object>());
|
||||
os = new FileOutputStream(outputPath);
|
||||
|
||||
ITextRenderer renderer = new ITextRenderer();
|
||||
// DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
// org.w3c.dom.Document doc = builder.parse(new ByteArrayInputStream(xmlStr.getBytes("utf-8")));
|
||||
// renderer.setDocument(doc,null);
|
||||
renderer.setDocumentFromString(xmlStr);
|
||||
// 解决中文支持问题
|
||||
ITextFontResolver fontResolver = renderer.getFontResolver();
|
||||
try {
|
||||
fontResolver.addFont("C:/Windows/fonts/simsun.ttc", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 解决图片的相对路径问题
|
||||
/*String basePath="D:/Tomcat 7.0/webapps/UploadFile";
|
||||
renderer.getSharedContext().setBaseURL("file:/" + basePath + "/MaintenanceBill");
|
||||
renderer.getSharedContext().setReplacedElementFactory(new Base64ImgReplacedElementFactory());
|
||||
renderer.getSharedContext().getTextRenderer().setSmoothingThreshold(0);*/
|
||||
renderer.layout();
|
||||
try {
|
||||
renderer.createPDF(os);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
/*ByteArrayOutputStream baos=new ByteArrayOutputStream();
|
||||
baos=(ByteArrayOutputStream) os;
|
||||
Hibernate.createBlob();
|
||||
ByteArrayInputStream swapStream = new ByteArrayInputStream(baos.toByteArray());*/
|
||||
if (os!=null) {
|
||||
os.flush();
|
||||
os.close();
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 提供中文
|
||||
*
|
||||
*/
|
||||
public class ChinaFontProvide implements FontProvider{
|
||||
|
||||
|
||||
@Override
|
||||
public Font getFont(String arg0, String arg1, boolean arg2, float arg3,
|
||||
int arg4, BaseColor arg5) {
|
||||
BaseFont bfChinese =null;
|
||||
try {
|
||||
// bfChinese=BaseFont.createFont("STSong-Light", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
|
||||
bfChinese=BaseFont.createFont("C:/Windows/Fonts/SIMYOU.TTF,1",BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Font FontChinese = new Font(bfChinese);
|
||||
return FontChinese;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isRegistered(String arg0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/exportMaintenanceDetailPDF.do")
|
||||
public ModelAndView exportMaintenanceDetailPDF(HttpServletRequest request,Model model){
|
||||
|
||||
String htmlStr = request.getParameter("htmlStr");
|
||||
PDFFileUtil pdfFileUtil= new PDFFileUtil();
|
||||
String realPath = request.getSession().getServletContext().getRealPath("/");
|
||||
String pjName = request.getContextPath().substring(1, request.getContextPath().length());
|
||||
realPath = realPath.replace(pjName,"UploadFile");
|
||||
String fileName =CommUtil.getUUID()+".pdf";
|
||||
realPath+="MaintenanceBill\\"+fileName;
|
||||
pdfFileUtil.html2Pdf(realPath, htmlStr);
|
||||
|
||||
String result="{\"res\":\""+realPath.substring(realPath.indexOf("UploadFile"),realPath.length()).replace("\\", "/")+"\"}";
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
/* static{
|
||||
BaseFont bfChinese_H;
|
||||
try {
|
||||
*//**
|
||||
* 新建一个字体,iText的方法 STSongStd-Light 是字体,在iTextAsian.jar 中以property为后缀
|
||||
* UniGB-UCS2-H 是编码,在iTextAsian.jar 中以cmap为后缀 H 代表文字版式是 横版, 相应的 V 代表竖版
|
||||
*//*
|
||||
bfChinese_H = BaseFont.createFont("STSong-Light","UniGB-UCS2-H",BaseFont.NOT_EMBEDDED);
|
||||
|
||||
|
||||
headFont = new Font(bfChinese_H, 14, Font.NORMAL);
|
||||
keyFont = new Font(bfChinese_H, 26, Font.BOLD);
|
||||
nbspFont = new Font(bfChinese_H, 13, Font.NORMAL);
|
||||
textfont_H = new Font(bfChinese_H, 10, Font.NORMAL);
|
||||
textfont_B = new Font(bfChinese_H, 12, Font.NORMAL);
|
||||
textfont_13 = new Font(bfChinese_H, 13, Font.NORMAL);
|
||||
textfont_12 = new Font(bfChinese_H, 12, Font.NORMAL);
|
||||
textfont_11 = new Font(bfChinese_H, 11, Font.NORMAL);
|
||||
textfont_10 = new Font(bfChinese_H, 10, Font.NORMAL);
|
||||
textfont_9 = new Font(bfChinese_H, 9, Font.NORMAL);
|
||||
textfont_8 = new Font(bfChinese_H, 8, Font.NORMAL);
|
||||
textfont_7 = new Font(bfChinese_H, 7, Font.NORMAL);
|
||||
textfont_6 = new Font(bfChinese_H, 6, Font.NORMAL);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
/**
|
||||
* 设置页面属性
|
||||
* @param file
|
||||
*/
|
||||
public void setPageProperties(File file) {
|
||||
|
||||
|
||||
//自定义纸张
|
||||
Rectangle rectPageSize = new Rectangle(350, 620);
|
||||
|
||||
|
||||
// 定义A4页面大小
|
||||
//Rectangle rectPageSize = new Rectangle(PageSize.A4);
|
||||
rectPageSize = rectPageSize.rotate();// 加上这句可以实现页面的横置
|
||||
document = new Document(rectPageSize,10, 150, 10, 40);
|
||||
|
||||
|
||||
try {
|
||||
PdfWriter.getInstance(document,new FileOutputStream(file));
|
||||
document.open();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 建表格(以列的数量建)
|
||||
* @param colNumber
|
||||
* @return
|
||||
*/
|
||||
public PdfPTable createTable(int colNumber){
|
||||
PdfPTable table = new PdfPTable(colNumber);
|
||||
try{
|
||||
//table.setTotalWidth(maxWidth);
|
||||
//table.setLockedWidth(true);
|
||||
table.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
table.getDefaultCell().setBorder(1);
|
||||
table.setSpacingBefore(10);
|
||||
table.setWidthPercentage(100);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 建表格(以列的宽度比建)
|
||||
* @param widths
|
||||
* @return
|
||||
*/
|
||||
public PdfPTable createTable(float[] widths){
|
||||
PdfPTable table = new PdfPTable(widths);
|
||||
try{
|
||||
//table.setTotalWidth(maxWidth);
|
||||
//table.setLockedWidth(true);
|
||||
table.setHorizontalAlignment(Element.ALIGN_CENTER);
|
||||
table.getDefaultCell().setBorder(1);
|
||||
table.setSpacingBefore(10);
|
||||
table.setWidthPercentage(100);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 表格中单元格
|
||||
* @param value
|
||||
* @param font
|
||||
* @param align
|
||||
* @return
|
||||
*/
|
||||
public PdfPCell createCell(String value,Font font,int align){
|
||||
PdfPCell cell = new PdfPCell();
|
||||
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
||||
cell.setHorizontalAlignment(align);
|
||||
cell.setPhrase(new Phrase(value,font));
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 表格中单元格
|
||||
* @param value
|
||||
* @param font
|
||||
* @param align
|
||||
* @param colspan
|
||||
* @param rowspan
|
||||
* @return
|
||||
*/
|
||||
public PdfPCell createCell(String value,Font font,int align_v,int align_h,int colspan,int rowspan){
|
||||
PdfPCell cell = new PdfPCell();
|
||||
cell.setVerticalAlignment(align_v);
|
||||
cell.setHorizontalAlignment(align_h);
|
||||
cell.setColspan(colspan);
|
||||
cell.setRowspan(rowspan);
|
||||
cell.setPhrase(new Phrase(value,font));
|
||||
return cell;
|
||||
}
|
||||
/**
|
||||
* 创建无边框表格
|
||||
* @param value
|
||||
* @param font
|
||||
* @param align
|
||||
* @param colspan
|
||||
* @param rowspan
|
||||
* @return
|
||||
*/
|
||||
public PdfPCell createCellNotBorder(String value,Font font,int align_v,int align_h,int colspan,int rowspan){
|
||||
PdfPCell cell = new PdfPCell();
|
||||
cell.setVerticalAlignment(align_v);
|
||||
cell.setHorizontalAlignment(align_h);
|
||||
cell.setColspan(colspan);
|
||||
cell.setRowspan(rowspan);
|
||||
cell.setPhrase(new Phrase(value,font));
|
||||
cell.setBorderWidth(0f);
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 建短语
|
||||
* @param value
|
||||
* @param font
|
||||
* @return
|
||||
*/
|
||||
public Phrase createPhrase(String value,Font font){
|
||||
Phrase phrase = new Phrase();
|
||||
phrase.add(value);
|
||||
phrase.setFont(font);
|
||||
return phrase;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 建段落
|
||||
* @param value
|
||||
* @param font
|
||||
* @param align
|
||||
* @return
|
||||
*/
|
||||
public Paragraph createParagraph(String value,Font font,int align){
|
||||
Paragraph paragraph = new Paragraph();
|
||||
paragraph.add(new Phrase(value,font));
|
||||
paragraph.setAlignment(align);
|
||||
return paragraph;
|
||||
}
|
||||
}
|
||||
448
src/main/java/com/sipai/controller/base/PoiUtils.java
Normal file
448
src/main/java/com/sipai/controller/base/PoiUtils.java
Normal file
@ -0,0 +1,448 @@
|
||||
package com.sipai.controller.base;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import org.apache.poi.xwpf.usermodel.*;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.beans.BeanInfo;
|
||||
import java.beans.IntrospectionException;
|
||||
import java.beans.Introspector;
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.math.BigInteger;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PoiUtils {
|
||||
|
||||
private Map<String, Map<String, Object>> orderMap = new HashMap<String, Map<String, Object>>();
|
||||
|
||||
/*把*/
|
||||
public static void copy(Object obj, Object dest) {
|
||||
// 获取属性
|
||||
BeanInfo sourceBean = null;
|
||||
try {
|
||||
sourceBean = Introspector.getBeanInfo(obj.getClass(), Object.class);
|
||||
} catch (IntrospectionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
PropertyDescriptor[] sourceProperty = sourceBean.getPropertyDescriptors();
|
||||
|
||||
BeanInfo destBean = null;
|
||||
try {
|
||||
destBean = Introspector.getBeanInfo(dest.getClass(), Object.class);
|
||||
} catch (IntrospectionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
PropertyDescriptor[] destProperty = destBean.getPropertyDescriptors();
|
||||
try {
|
||||
for (int i = 0; i < sourceProperty.length; i++) {
|
||||
Object value = sourceProperty[i].getReadMethod().invoke(obj);
|
||||
if (value != null) {
|
||||
|
||||
for (int j = 0; j < destProperty.length; j++) {
|
||||
if (sourceProperty[i].getName().equals(destProperty[j].getName()) && sourceProperty[i].getPropertyType() == destProperty[j].getPropertyType()) {
|
||||
// 调用source的getter方法和dest的setter方法
|
||||
destProperty[j].getWriteMethod().invoke(dest, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
throw new Exception("属性复制失败:" + e.getMessage());
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置一级标题内容及样式
|
||||
*
|
||||
* @param paragraph
|
||||
* @param text
|
||||
*/
|
||||
public void setLevelTitle1(XWPFDocument document, XWPFParagraph paragraph, String text) {
|
||||
/**1.将段落原有文本(原有所有的Run)全部删除*/
|
||||
deleteRun(paragraph);
|
||||
/**3.插入新的Run即将新的文本插入段落*/
|
||||
XWPFRun createRun = paragraph.insertNewRun(0);
|
||||
createRun.setText(text);
|
||||
XWPFRun separtor = paragraph.insertNewRun(1);
|
||||
/**两段之间添加换行*/
|
||||
separtor.setText("\r");
|
||||
createRun.setFontSize(16);
|
||||
createRun.setFontFamily("黑体");
|
||||
paragraph.setIndentationFirstLine(600);
|
||||
paragraph.setSpacingAfter(20);
|
||||
paragraph.setSpacingBefore(20);
|
||||
addCustomHeadingStyle(document, "标题1", 1);
|
||||
paragraph.setStyle("标题1");
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置二级标题内容及样式
|
||||
*
|
||||
* @param paragraph
|
||||
* @param text
|
||||
*/
|
||||
public void setLevelTitle2(XWPFDocument document, XWPFParagraph paragraph, String text) {
|
||||
deleteRun(paragraph);
|
||||
/**3.插入新的Run即将新的文本插入段落*/
|
||||
XWPFRun createRun = paragraph.insertNewRun(0);
|
||||
createRun.setText(text);
|
||||
XWPFRun separtor = paragraph.insertNewRun(1);
|
||||
/**两段之间添加换行*/
|
||||
separtor.setText("\r");
|
||||
createRun.setFontSize(16);
|
||||
createRun.setBold(true);
|
||||
createRun.setFontFamily("楷体_GB2312");
|
||||
paragraph.setIndentationFirstLine(600);
|
||||
paragraph.setSpacingAfter(10);
|
||||
paragraph.setSpacingBefore(10);
|
||||
addCustomHeadingStyle(document, "标题2", 2);
|
||||
paragraph.setStyle("标题2");
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置正文文本内容及样式
|
||||
*
|
||||
* @param paragraph
|
||||
* @param text
|
||||
*/
|
||||
public void setTextPro(XWPFParagraph paragraph, String text) {
|
||||
deleteRun(paragraph);
|
||||
/**3.插入新的Run即将新的文本插入段落*/
|
||||
XWPFRun createRun = paragraph.insertNewRun(0);
|
||||
createRun.setText(text);
|
||||
XWPFRun separtor = paragraph.insertNewRun(1);
|
||||
/**两段之间添加换行*/
|
||||
separtor.addBreak();
|
||||
createRun.addTab();
|
||||
createRun.setFontFamily("仿宋_GB2312");
|
||||
createRun.setFontSize(16);
|
||||
|
||||
paragraph.setFirstLineIndent(20);
|
||||
paragraph.setAlignment(ParagraphAlignment.BOTH);
|
||||
paragraph.setIndentationFirstLine(600);
|
||||
paragraph.setSpacingAfter(10);
|
||||
paragraph.setSpacingBefore(10);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向段落添加文本
|
||||
*
|
||||
* @param paragraph
|
||||
* @param text
|
||||
*/
|
||||
public void addTextPro(XWPFParagraph paragraph, String text) {
|
||||
/**3.插入新的Run即将新的文本插入段落*/
|
||||
XWPFRun createRun = paragraph.createRun();
|
||||
createRun.setText(text);
|
||||
XWPFRun separtor = paragraph.createRun();
|
||||
/**两段之间添加换行*/
|
||||
separtor.addBreak();
|
||||
createRun.addTab();
|
||||
createRun.setFontFamily("仿宋_GB2312");
|
||||
createRun.setFontSize(16);
|
||||
paragraph.setFirstLineIndent(20);
|
||||
paragraph.setAlignment(ParagraphAlignment.BOTH);
|
||||
paragraph.setIndentationFirstLine(600);
|
||||
paragraph.setSpacingAfter(10);
|
||||
paragraph.setSpacingBefore(10);
|
||||
|
||||
paragraph.addRun(createRun);
|
||||
paragraph.addRun(separtor);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置表格标题内容及样式
|
||||
*
|
||||
* @param paragraph
|
||||
* @param text
|
||||
*/
|
||||
public void setTableOrChartTitle(XWPFParagraph paragraph, String text) {
|
||||
/**1.将段落原有文本(原有所有的Run)全部删除*/
|
||||
deleteRun(paragraph);
|
||||
XWPFRun createRun = paragraph.insertNewRun(0);
|
||||
createRun.setText(text);
|
||||
XWPFRun separtor = paragraph.insertNewRun(1);
|
||||
/**两段之间添加换行*/
|
||||
separtor.setText("\r");
|
||||
createRun.setFontFamily("楷体");
|
||||
createRun.setFontSize(16);
|
||||
createRun.setBold(true);
|
||||
paragraph.setSpacingAfter(10);
|
||||
paragraph.setSpacingBefore(10);
|
||||
paragraph.setAlignment(ParagraphAlignment.CENTER);
|
||||
}
|
||||
|
||||
public void deleteRun(XWPFParagraph paragraph) {
|
||||
/*1.将段落原有文本(原有所有的Run)全部删除*/
|
||||
List<XWPFRun> runs = paragraph.getRuns();
|
||||
int runSize = runs.size();
|
||||
/*Paragrap中每删除一个run,其所有的run对象就会动态变化,即不能同时遍历和删除*/
|
||||
int haveRemoved = 0;
|
||||
for (int runIndex = 0; runIndex < runSize; runIndex++) {
|
||||
paragraph.removeRun(runIndex - haveRemoved);
|
||||
haveRemoved++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并行
|
||||
*
|
||||
* @param table
|
||||
* @param col 需要合并的列
|
||||
* @param fromRow 开始行
|
||||
* @param toRow 结束行
|
||||
*/
|
||||
public static void mergeCellVertically(XWPFTable table, int col, int fromRow, int toRow) {
|
||||
for (int rowIndex = fromRow; rowIndex <= toRow; rowIndex++) {
|
||||
CTVMerge vmerge = CTVMerge.Factory.newInstance();
|
||||
if (rowIndex == fromRow) {
|
||||
vmerge.setVal(STMerge.RESTART);
|
||||
} else {
|
||||
vmerge.setVal(STMerge.CONTINUE);
|
||||
}
|
||||
XWPFTableCell cell = table.getRow(rowIndex).getCell(col);
|
||||
CTTcPr tcPr = cell.getCTTc().getTcPr();
|
||||
if (tcPr != null) {
|
||||
tcPr.setVMerge(vmerge);
|
||||
} else {
|
||||
tcPr = CTTcPr.Factory.newInstance();
|
||||
tcPr.setVMerge(vmerge);
|
||||
cell.getCTTc().setTcPr(tcPr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置表格内容居中
|
||||
*
|
||||
* @param table
|
||||
*/
|
||||
public void setTableCenter(XWPFTable table) {
|
||||
List<XWPFTableRow> rows = table.getRows();
|
||||
for (XWPFTableRow row : rows) {
|
||||
row.setHeight(400);
|
||||
List<XWPFTableCell> cells = row.getTableCells();
|
||||
for (XWPFTableCell cell : cells) {
|
||||
CTTc cttc = cell.getCTTc();
|
||||
CTTcPr ctPr = cttc.addNewTcPr();
|
||||
ctPr.addNewVAlign().setVal(STVerticalJc.CENTER);
|
||||
cttc.getPList().get(0).addNewPPr().addNewJc().setVal(STJc.CENTER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void init(XWPFDocument document) {
|
||||
//获取段落
|
||||
List<XWPFParagraph> paras = document.getParagraphs();
|
||||
|
||||
for (int i = 0; i < paras.size(); i++) {
|
||||
XWPFParagraph para = paras.get(i);
|
||||
// System.out.println(para.getCTP());//得到xml格式
|
||||
// System.out.println(para.getStyleID());//段落级别
|
||||
// System.out.println(para.getParagraphText());//段落内容
|
||||
|
||||
String titleLvl = getTitleLvl(document, para);//获取段落级别
|
||||
if ("a5".equals(titleLvl) || "HTML".equals(titleLvl) || "".equals(titleLvl) || null == titleLvl) {
|
||||
titleLvl = "8";
|
||||
}
|
||||
|
||||
if (null != titleLvl && !"".equals(titleLvl) && !"8".equals(titleLvl)) {
|
||||
String t = titleLvl;
|
||||
String orderCode = getOrderCode(titleLvl);//获取编号
|
||||
String text = para.getParagraphText();
|
||||
text = orderCode + " " + text;
|
||||
List<XWPFRun> runs = para.getRuns();
|
||||
int runSize = runs.size();
|
||||
/**Paragrap中每删除一个run,其所有的run对象就会动态变化,即不能同时遍历和删除*/
|
||||
int haveRemoved = 0;
|
||||
for (int runIndex = 0; runIndex < runSize; runIndex++) {
|
||||
para.removeRun(runIndex - haveRemoved);
|
||||
haveRemoved++;
|
||||
}
|
||||
if ("1".equals(titleLvl)) {
|
||||
setLevelTitle1(document, para, text);
|
||||
}
|
||||
if ("2".equals(titleLvl)) {
|
||||
setLevelTitle2(document, para, text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Word中的大纲级别,可以通过getPPr().getOutlineLvl()直接提取,但需要注意,Word中段落级别,通过如下三种方式定义:
|
||||
* 1、直接对段落进行定义;
|
||||
* 2、对段落的样式进行定义;
|
||||
* 3、对段落样式的基础样式进行定义。
|
||||
* 因此,在通过“getPPr().getOutlineLvl()”提取时,需要依次在如上三处读取。
|
||||
*
|
||||
* @param doc
|
||||
* @param para
|
||||
* @return
|
||||
*/
|
||||
public String getTitleLvl(XWPFDocument doc, XWPFParagraph para) {
|
||||
String titleLvl = "";
|
||||
|
||||
//判断该段落是否设置了大纲级别
|
||||
CTP ctp = para.getCTP();
|
||||
if (ctp != null) {
|
||||
CTPPr pPr = ctp.getPPr();
|
||||
if (pPr != null) {
|
||||
if (pPr.getOutlineLvl() != null) {
|
||||
return String.valueOf(pPr.getOutlineLvl().getVal());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//判断该段落的样式是否设置了大纲级别
|
||||
if (para.getStyle() != null) {
|
||||
if (doc.getStyles().getStyle(para.getStyle()).getCTStyle().getPPr().getOutlineLvl() != null) {
|
||||
return String.valueOf(doc.getStyles().getStyle(para.getStyle()).getCTStyle().getPPr().getOutlineLvl().getVal());
|
||||
}
|
||||
|
||||
|
||||
//判断该段落的样式的基础样式是否设置了大纲级别
|
||||
if (doc.getStyles().getStyle(doc.getStyles().getStyle(para.getStyle()).getCTStyle().getBasedOn().getVal())
|
||||
.getCTStyle().getPPr().getOutlineLvl() != null) {
|
||||
String styleName = doc.getStyles().getStyle(para.getStyle()).getCTStyle().getBasedOn().getVal();
|
||||
return String.valueOf(doc.getStyles().getStyle(styleName).getCTStyle().getPPr().getOutlineLvl().getVal());
|
||||
}
|
||||
}
|
||||
if (para.getStyleID() != null) {
|
||||
return para.getStyleID();
|
||||
}
|
||||
return titleLvl;
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加自定义标题样式。这里用的是stackoverflow的源码
|
||||
*
|
||||
* @param docxDocument 目标文档
|
||||
* @param strStyleId 样式名称
|
||||
* @param headingLevel 样式级别
|
||||
*/
|
||||
public static void addCustomHeadingStyle(XWPFDocument docxDocument, String strStyleId, int headingLevel) {
|
||||
|
||||
CTStyle ctStyle = CTStyle.Factory.newInstance();
|
||||
ctStyle.setStyleId(strStyleId);
|
||||
|
||||
CTString styleName = CTString.Factory.newInstance();
|
||||
styleName.setVal(strStyleId);
|
||||
ctStyle.setName(styleName);
|
||||
|
||||
CTDecimalNumber indentNumber = CTDecimalNumber.Factory.newInstance();
|
||||
indentNumber.setVal(BigInteger.valueOf(headingLevel));
|
||||
|
||||
// lower number > style is more prominent in the formats bar
|
||||
ctStyle.setUiPriority(indentNumber);
|
||||
|
||||
CTOnOff onoffnull = CTOnOff.Factory.newInstance();
|
||||
ctStyle.setUnhideWhenUsed(onoffnull);
|
||||
|
||||
// style shows up in the formats bar
|
||||
ctStyle.setQFormat(onoffnull);
|
||||
|
||||
// style defines a heading of the given level
|
||||
CTPPr ppr = CTPPr.Factory.newInstance();
|
||||
ppr.setOutlineLvl(indentNumber);
|
||||
ctStyle.setPPr(ppr);
|
||||
|
||||
XWPFStyle style = new XWPFStyle(ctStyle);
|
||||
|
||||
// is a null op if already defined
|
||||
XWPFStyles styles = docxDocument.createStyles();
|
||||
|
||||
style.setType(STStyleType.PARAGRAPH);
|
||||
styles.addStyle(style);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取标题编号
|
||||
*
|
||||
* @param titleLvl
|
||||
* @return
|
||||
*/
|
||||
public String getOrderCode(String titleLvl) {
|
||||
String order = "";
|
||||
|
||||
if ("0".equals(titleLvl) || Integer.parseInt(titleLvl) == 8) {//文档标题||正文
|
||||
return "";
|
||||
} else if (Integer.parseInt(titleLvl) > 0 && Integer.parseInt(titleLvl) < 8) {//段落标题
|
||||
|
||||
//设置最高级别标题
|
||||
Map<String, Object> maxTitleMap = orderMap.get("maxTitleLvlMap");
|
||||
if (null == maxTitleMap) {//没有,表示第一次进来
|
||||
//最高级别标题赋值
|
||||
maxTitleMap = new HashMap<String, Object>();
|
||||
maxTitleMap.put("lvl", titleLvl);
|
||||
orderMap.put("maxTitleLvlMap", maxTitleMap);
|
||||
} else {
|
||||
String maxTitleLvl = maxTitleMap.get("lvl") + "";//最上层标题级别(0,1,2,3)
|
||||
if (Integer.parseInt(titleLvl) < Integer.parseInt(maxTitleLvl)) {//当前标题级别更高
|
||||
maxTitleMap.put("lvl", titleLvl);//设置最高级别标题
|
||||
orderMap.put("maxTitleLvlMap", maxTitleMap);
|
||||
}
|
||||
}
|
||||
|
||||
//查父节点标题
|
||||
int parentTitleLvl = Integer.parseInt(titleLvl) - 1;//父节点标题级别
|
||||
Map<String, Object> cMap = orderMap.get(titleLvl);//当前节点信息
|
||||
Map<String, Object> pMap = orderMap.get(parentTitleLvl + "");//父节点信息
|
||||
|
||||
if (0 == parentTitleLvl) {//父节点为文档标题,表明当前节点为1级标题
|
||||
int count = 0;
|
||||
//最上层标题,没有父节点信息
|
||||
if (null == cMap) {//没有当前节点信息
|
||||
cMap = new HashMap<String, Object>();
|
||||
} else {
|
||||
count = Integer.parseInt(String.valueOf(cMap.get("cCount")));//当前序个数
|
||||
}
|
||||
count++;
|
||||
order = count + "";
|
||||
cMap.put("cOrder", order);//当前序
|
||||
cMap.put("cCount", count);//当前序个数
|
||||
orderMap.put(titleLvl, cMap);
|
||||
|
||||
} else {//父节点为非文档标题
|
||||
int count = 0;
|
||||
//如果没有相邻的父节点信息,当前标题级别自动升级
|
||||
if (null == pMap) {
|
||||
return getOrderCode(String.valueOf(parentTitleLvl));
|
||||
} else {
|
||||
String pOrder = String.valueOf(pMap.get("cOrder"));//父节点序
|
||||
if (null == cMap) {//没有当前节点信息
|
||||
cMap = new HashMap<String, Object>();
|
||||
} else {
|
||||
count = Integer.parseInt(String.valueOf(cMap.get("cCount")));//当前序个数
|
||||
}
|
||||
count++;
|
||||
order = pOrder + "." + count;//当前序编号
|
||||
cMap.put("cOrder", order);//当前序
|
||||
cMap.put("cCount", count);//当前序个数
|
||||
orderMap.put(titleLvl, cMap);
|
||||
}
|
||||
}
|
||||
|
||||
//字节点标题计数清零
|
||||
int childTitleLvl = Integer.parseInt(titleLvl) + 1;//子节点标题级别
|
||||
Map<String, Object> cdMap = orderMap.get(childTitleLvl + "");//
|
||||
if (null != cdMap) {
|
||||
cdMap.put("cCount", 0);//子节点序个数
|
||||
orderMap.get(childTitleLvl + "").put("cCount", 0);
|
||||
}
|
||||
}
|
||||
return order;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
package com.sipai.controller.bim;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.bim.BIMCamera;
|
||||
import com.sipai.entity.process.LibraryProcessAdjustment;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.bim.BIMCameraService;
|
||||
import net.sf.json.JSONArray;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/bim/BIMCamera")
|
||||
public class BIMCameraController {
|
||||
@Resource
|
||||
private BIMCameraService bimCameraService;
|
||||
|
||||
@RequestMapping("/cameraView.do")
|
||||
public String cameraView(HttpServletRequest request,Model model){
|
||||
String devicepass=request.getParameter("devicepass");
|
||||
|
||||
String wherestr = "where 1=1 and device_pass='"+devicepass+"' ";
|
||||
|
||||
List<BIMCamera> list = this.bimCameraService.selectListByWhere(wherestr);
|
||||
|
||||
if(list!=null&&list.size()>0){
|
||||
model.addAttribute("devicepass", list.get(0).getInterfaces());
|
||||
}
|
||||
|
||||
return "bim/openVLCCamera";
|
||||
}
|
||||
|
||||
@RequestMapping("/getList.do")
|
||||
public ModelAndView getList(HttpServletRequest request, Model model) {
|
||||
String wherestr = "where 1=1 and device_pass='"+request.getParameter("devicepass")+"' ";
|
||||
|
||||
List<BIMCamera> list = this.bimCameraService.selectListByWhere(wherestr);
|
||||
|
||||
JSONArray json = JSONArray.fromObject(list.get(0));
|
||||
|
||||
model.addAttribute("result", json);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/getListCamera.do")
|
||||
public ModelAndView getListCamera(HttpServletRequest request, Model model) {
|
||||
String wherestr = "where 1=1";
|
||||
|
||||
List<BIMCamera> list = this.bimCameraService.selectListByWhere(wherestr);
|
||||
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
|
||||
model.addAttribute("result", json);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
package com.sipai.controller.bim;
|
||||
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.forwardedUrl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import com.sipai.entity.app.AppDataConfigure;
|
||||
import com.sipai.entity.bim.BIMCurrency;
|
||||
import com.sipai.entity.scada.MPoint;
|
||||
import com.sipai.service.bim.BIMCurrencyService;
|
||||
import com.sipai.service.scada.MPointService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/bim/bIMCurrency")
|
||||
public class BIMCurrencyController {
|
||||
@Resource
|
||||
private MPointService mPointService;
|
||||
@Resource
|
||||
private BIMCurrencyService bIMCurrencyService;
|
||||
|
||||
@RequestMapping("getdata.do")
|
||||
public String getdata(HttpServletRequest request,Model model){
|
||||
String unitId=request.getParameter("bizid");
|
||||
|
||||
JSONArray jsonArray=new JSONArray();
|
||||
|
||||
List<BIMCurrency> bList=this.bIMCurrencyService.selectListByWhere(" where 1=1 ");
|
||||
if(bList!=null&&bList.size()>0){
|
||||
for (int i = 0; i < bList.size(); i++) {
|
||||
JSONObject jsonObject=new JSONObject();
|
||||
|
||||
String mpid=bList.get(i).getMpointCode();
|
||||
MPoint mPoint=this.mPointService.selectById(unitId, mpid);
|
||||
|
||||
if(mPoint!=null){
|
||||
BigDecimal vale=mPoint.getParmvalue();
|
||||
String unit=mPoint.getUnit();
|
||||
String numtail=mPoint.getNumtail();
|
||||
double endValue=0;
|
||||
if(vale!=null){
|
||||
endValue=CommUtil.round(vale.doubleValue(),Integer.valueOf(numtail));
|
||||
}
|
||||
|
||||
String locationId=bList.get(i).getLocationId();
|
||||
|
||||
jsonObject.put("name",bList.get(i).getTagName());
|
||||
jsonObject.put("value", endValue);
|
||||
jsonObject.put("unit", unit);
|
||||
jsonObject.put("locationId", locationId);
|
||||
jsonObject.put("tagId", bList.get(i).getTagId());
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
model.addAttribute("result", jsonArray);
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,73 @@
|
||||
package com.sipai.controller.bim;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.sipai.entity.equipment.EquipmentCard;
|
||||
import com.sipai.service.equipment.EquipmentCardService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import com.sipai.entity.scada.MPoint;
|
||||
import com.sipai.service.scada.MPointService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/bim/bimFrame")
|
||||
public class BimFrameController {
|
||||
@Resource
|
||||
private MPointService mPointService;
|
||||
@Resource
|
||||
private EquipmentCardService equipmentCardService;
|
||||
|
||||
/**
|
||||
* 水厂概览 提供给彭工
|
||||
*
|
||||
* @param request
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/overviewOfWaterPlants.do")
|
||||
public String overviewOfWaterPlants(HttpServletRequest request, Model model) {
|
||||
|
||||
return "bim/overviewOfWaterPlants";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 水厂概览 提供给彭工
|
||||
*
|
||||
* @param request
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/eqView.do")
|
||||
public String eqView(HttpServletRequest request, Model model) {
|
||||
String eqCode = request.getParameter("eqCode");
|
||||
List<EquipmentCard> equipmentCardList = this.equipmentCardService.selectListByWhere(" where equipmentCardID='"+eqCode+"' ");
|
||||
if (equipmentCardList != null && equipmentCardList.size() > 0) {
|
||||
model.addAttribute("equipmentCard", equipmentCardList.get(0));
|
||||
}
|
||||
return "bim/eqView";
|
||||
}
|
||||
|
||||
/**
|
||||
* 人员定位 提供给彭工
|
||||
*
|
||||
* @param request
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/personnelPositioning.do")
|
||||
public String personnelPositioning(HttpServletRequest request, Model model) {
|
||||
return "bim/personnelPositioning";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package com.sipai.controller.bim;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.sipai.entity.bim.BimRouteData;
|
||||
import com.sipai.entity.bim.BimRouteEqData;
|
||||
import com.sipai.entity.scada.ProAlarm;
|
||||
import com.sipai.service.bim.BimRouteDataService;
|
||||
import com.sipai.service.bim.BimRouteEqDataService;
|
||||
import com.sipai.service.scada.ProAlarmService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
import net.sf.json.JSONArray;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/bim/page")
|
||||
public class BimPageController {
|
||||
@Resource
|
||||
private BimRouteDataService bimRouteDataService;
|
||||
@Resource
|
||||
private ProAlarmService proAlarmService;
|
||||
@Resource
|
||||
private BimRouteEqDataService bimRouteEqDataService;
|
||||
|
||||
@RequestMapping("/inspectionPage.do")
|
||||
public String inspectionPage(HttpServletRequest request, Model model) {
|
||||
|
||||
return "bim/inspectionPage";
|
||||
}
|
||||
|
||||
@RequestMapping("/routeData.do")
|
||||
public String routeData(HttpServletRequest request, Model model) {
|
||||
|
||||
return "bim/routeData";
|
||||
}
|
||||
|
||||
@RequestMapping("/getRouteData.do")
|
||||
public ModelAndView getRouteData(HttpServletRequest request, Model model) {
|
||||
String code = request.getParameter("code");
|
||||
String unitId = request.getParameter("unitId");
|
||||
String type = request.getParameter("type");
|
||||
|
||||
List<BimRouteData> bimRouteDataList = this.bimRouteDataService.selectListByWhere("where code='" + code + "' and unitId='" + unitId + "' and type='"+type+"' ");
|
||||
|
||||
model.addAttribute("result", JSONArray.fromObject(bimRouteDataList));
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/getRouteEqData.do")
|
||||
public ModelAndView getRouteEqData(HttpServletRequest request, Model model) {
|
||||
String code = request.getParameter("code");
|
||||
String unitId = request.getParameter("unitId");
|
||||
|
||||
List<BimRouteEqData> bimRouteEqDataList = this.bimRouteEqDataService.selectListByWhere("where code='" + code + "' and unitId='" + unitId + "'");
|
||||
|
||||
model.addAttribute("result", JSONArray.fromObject(bimRouteEqDataList));
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
}
|
||||
70
src/main/java/com/sipai/controller/bim/CDBIMController.java
Normal file
70
src/main/java/com/sipai/controller/bim/CDBIMController.java
Normal file
@ -0,0 +1,70 @@
|
||||
package com.sipai.controller.bim;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import com.sipai.entity.bim.BIMCDHomePageTree;
|
||||
import com.sipai.entity.data.CurveMpoint;
|
||||
import com.sipai.entity.data.DataCurve;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.bim.BIMCDHomePageTreeService;
|
||||
import com.sipai.service.work.GroupManageService;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/bim/CDBIM")
|
||||
public class CDBIMController {
|
||||
@Resource
|
||||
private BIMCDHomePageTreeService bIMCDHomePageTreeService;
|
||||
|
||||
@RequestMapping("/homePage.do")
|
||||
public String homePage(HttpServletRequest request,Model model){
|
||||
|
||||
|
||||
|
||||
return "bim/CDBIMhomePage";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得个人方案树形结构
|
||||
* @param request
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getTree.do")
|
||||
public String getTree(HttpServletRequest request,Model model){
|
||||
String id=request.getParameter("id");
|
||||
String name=request.getParameter("name");
|
||||
|
||||
String searchIds="";
|
||||
|
||||
String whereString="";
|
||||
if(id.equals("-1")){
|
||||
|
||||
}else{
|
||||
searchIds=this.bIMCDHomePageTreeService.getTreeidsBySearch(name,request.getParameter("type"));
|
||||
searchIds = searchIds.replace(",","','");
|
||||
whereString+=" and id in ('"+searchIds+"') ";
|
||||
}
|
||||
|
||||
List<BIMCDHomePageTree> list = this.bIMCDHomePageTreeService.selectListByWhere("where 1=1 and type='"+request.getParameter("type")+"' "
|
||||
+ whereString
|
||||
+ "order by morder");
|
||||
|
||||
String json = this.bIMCDHomePageTreeService.getTreeList(null, list);
|
||||
|
||||
model.addAttribute("result", json);
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,82 @@
|
||||
package com.sipai.controller.bim;
|
||||
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.bim.YsAlarmRecord;
|
||||
import com.sipai.entity.user.Unit;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.entity.workorder.WorkorderDetail;
|
||||
import com.sipai.service.bim.YsAlarmRecordService;
|
||||
import com.sipai.tools.CommString;
|
||||
import com.sipai.tools.CommUtil;
|
||||
import net.sf.json.JSONArray;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/bim/ysAlarmRecord")
|
||||
public class YsAlarmRecordController {
|
||||
@Resource
|
||||
private YsAlarmRecordService ysAlarmRecordService;
|
||||
|
||||
//维修list
|
||||
@RequestMapping("/showList.do")
|
||||
public String showList(HttpServletRequest request, Model model) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
if (cu != null) {
|
||||
request.setAttribute("userId", cu.getId());
|
||||
}
|
||||
return "bim/ysAlarmRecordList";
|
||||
}
|
||||
|
||||
@RequestMapping("/getlist.do")
|
||||
public ModelAndView getlist(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required = false) String sort,
|
||||
@RequestParam(value = "order", required = false) String order) {
|
||||
String date = request.getParameter("date");//日期
|
||||
String selectType = request.getParameter("selectType");
|
||||
if (sort == null || sort.equals("id")) {
|
||||
sort = " insdt ";
|
||||
}
|
||||
if (order == null) {
|
||||
order = " desc ";
|
||||
}
|
||||
String orderstr = " order by " + sort + " " + order;
|
||||
String wherestr = "where 1=1 ";
|
||||
|
||||
if (date != null && !date.equals("")) {
|
||||
String[] str = date.split("~");
|
||||
wherestr += " and insdt between'" + str[0] + "'and'" + str[1] + "'";
|
||||
}
|
||||
if (selectType != null && !selectType.equals("")) {
|
||||
if (selectType.equals("0")) {//数据变化
|
||||
wherestr += " and record_type = 'job' ";
|
||||
}
|
||||
if (selectType.equals("1")) {//原水kafka反馈
|
||||
wherestr += " and record_type = 'kafka' ";
|
||||
}
|
||||
}
|
||||
|
||||
PageHelper.startPage(page, rows);
|
||||
List<YsAlarmRecord> list = this.ysAlarmRecordService.selectListByWhere(wherestr + orderstr);
|
||||
|
||||
PageInfo<YsAlarmRecord> pi = new PageInfo<>(list);
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
|
||||
String result = "{\"total\":" + pi.getTotal() + ",\"rows\":" + json + "}";
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
}
|
||||
337
src/main/java/com/sipai/controller/bot/BotController.java
Normal file
337
src/main/java/com/sipai/controller/bot/BotController.java
Normal file
@ -0,0 +1,337 @@
|
||||
package com.sipai.controller.bot;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.apache.batik.ext.awt.geom.Cubic;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.sipai.entity.base.CommonFile;
|
||||
import com.sipai.entity.bot.Bot;
|
||||
import com.sipai.entity.user.Company;
|
||||
import com.sipai.entity.user.Unit;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.base.CommonFileService;
|
||||
import com.sipai.service.bot.Botservice;
|
||||
import com.sipai.service.company.CompanyService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.service.user.UserService;
|
||||
import com.sipai.tools.CommString;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/bot/bot")
|
||||
public class BotController {
|
||||
@Resource
|
||||
private Botservice botservice;
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
@Resource
|
||||
private CommonFileService commonFileService;
|
||||
@Resource
|
||||
private CompanyService companyService;
|
||||
|
||||
|
||||
@RequestMapping("/botmanage.do")
|
||||
public String botmanage(HttpServletRequest request, Model model) {
|
||||
return "bot/botManage";
|
||||
}
|
||||
|
||||
@RequestMapping("/showBotEdit.do")
|
||||
public String showBotEdit(HttpServletRequest request, Model model,
|
||||
@RequestParam String bizid) {
|
||||
Bot bot = new Bot();
|
||||
List<Bot> botList = this.botservice.selectListByWhere("where bizid='" + bizid + "'");
|
||||
if (botList != null && botList.size() > 0) {
|
||||
bot.setId(botList.get(0).getId());
|
||||
bot.setBizid(bizid);
|
||||
bot.setDesignScale(botList.get(0).getDesignScale());
|
||||
bot.setEmission(botList.get(0).getEmission());
|
||||
bot.setInfluentIndex(botList.get(0).getInfluentIndex());
|
||||
bot.setEffluentIndex(botList.get(0).getEffluentIndex());
|
||||
bot.setProcess(botList.get(0).getProcess());
|
||||
bot.setPrice(botList.get(0).getPrice());
|
||||
bot.setCalculation(botList.get(0).getCalculation());
|
||||
bot.setSigndate(botList.get(0).getSigndate());
|
||||
bot.setFranchisePeriod(botList.get(0).getFranchisePeriod());
|
||||
} else {
|
||||
bot.setId(CommUtil.getUUID());
|
||||
bot.setBizid(bizid);
|
||||
}
|
||||
model.addAttribute("bot", bot);
|
||||
|
||||
return "bot/botEdit";
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/updateBot.do")
|
||||
public ModelAndView updateBot(HttpServletRequest request, Model model,
|
||||
@ModelAttribute Bot bot) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
|
||||
//判断是否有该记录
|
||||
List<Bot> botList = this.botservice.selectListByWhere("where id='" + bot.getId() + "'");
|
||||
int result = 0;
|
||||
if (botList != null && botList.size() > 0) {
|
||||
//更新
|
||||
bot.setUpsuser(cu.getId());
|
||||
bot.setUpsdt(CommUtil.nowDate());
|
||||
result = this.botservice.update(bot);
|
||||
} else {
|
||||
//新增
|
||||
bot.setInsuser(cu.getId());
|
||||
bot.setInsdt(CommUtil.nowDate());
|
||||
result = this.botservice.save(bot);
|
||||
}
|
||||
|
||||
String resstr = "{\"res\":\"" + result + "\",\"id\":\"" + bot.getId() + "\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/botList.do")
|
||||
public String botList(HttpServletRequest request, Model model) {
|
||||
|
||||
return "bot/showBotList";
|
||||
}
|
||||
|
||||
@RequestMapping("/botListForApp.do")
|
||||
public String botListForApp(HttpServletRequest request, Model model) {
|
||||
|
||||
return "bot/showBotListForApp";
|
||||
}
|
||||
|
||||
@RequestMapping("/getbotList.do")
|
||||
public String getbotList(HttpServletRequest request, Model model) {
|
||||
String bizidx = request.getParameter("bizid");
|
||||
String wherestr = "where 1=1 ";
|
||||
if (bizidx != null && !bizidx.isEmpty()) {
|
||||
//获取公司下所有子节点
|
||||
List<Unit> units = unitService.getUnitChildrenById(bizidx);
|
||||
String userids = "";
|
||||
for (Unit unit : units) {
|
||||
userids += "'" + unit.getId() + "',";
|
||||
}
|
||||
if (userids != "") {
|
||||
userids = userids.substring(0, userids.length() - 1);
|
||||
wherestr += "and bizid in (" + userids + ") ";
|
||||
}
|
||||
}
|
||||
|
||||
if (request.getParameter("search_name") != null && !request.getParameter("search_name").isEmpty()) {
|
||||
wherestr += " and process like '%" + request.getParameter("search_name") + "%'";
|
||||
|
||||
}
|
||||
|
||||
List<Bot> botList = this.botservice.selectListByWhere(wherestr);
|
||||
List<JSONObject> botJsonList = new ArrayList<JSONObject>();
|
||||
List<JSONObject> initialPointJsonListnew1 = new ArrayList<JSONObject>();
|
||||
if (botList != null && botList.size() > 0) {
|
||||
for (int i = 0; i < botList.size(); i++) {
|
||||
JSONObject botJsonObject = JSONObject.fromObject(botList.get(i));
|
||||
|
||||
Company company = unitService.getCompById(botList.get(i).getBizid());
|
||||
//查文件
|
||||
List<CommonFile> botfiles = this.commonFileService.selectListByTableAWhere("tb_bot_file", "where masterid='" + botList.get(i).getId() + "'");
|
||||
if (botfiles != null && botfiles.size() > 0) {
|
||||
botJsonObject.put("filetype", "yes");
|
||||
botJsonObject.put("fileid", botfiles.get(0).getId());
|
||||
|
||||
} else {
|
||||
botJsonObject.put("filetype", "no");
|
||||
botJsonObject.put("fileid", "");
|
||||
}
|
||||
if (company != null) {
|
||||
botJsonObject.put("bizidpid", company.getPid());
|
||||
botJsonObject.put("bizname", company.getName());
|
||||
}
|
||||
|
||||
botJsonList.add(botJsonObject);
|
||||
}
|
||||
|
||||
|
||||
//按类分
|
||||
HashSet<String> hashSet = new HashSet<>();
|
||||
for (JSONObject item : botJsonList) {
|
||||
hashSet.add((String) item.get("bizidpid"));
|
||||
}
|
||||
|
||||
Iterator<String> iterator = hashSet.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
JSONObject jsonObject2 = new JSONObject();
|
||||
jsonObject2.put("bizidpid", iterator.next());
|
||||
jsonObject2.put("color", getRandColorCode());
|
||||
initialPointJsonListnew1.add(jsonObject2);
|
||||
}
|
||||
|
||||
|
||||
for (JSONObject jsonObject2 : initialPointJsonListnew1) {
|
||||
List<JSONObject> codeslist = new ArrayList<JSONObject>();
|
||||
for (JSONObject item : botJsonList) {
|
||||
if (jsonObject2.get("bizidpid").equals(item.get("bizidpid"))) {
|
||||
codeslist.add(item);
|
||||
}
|
||||
}
|
||||
jsonObject2.put("codes", codeslist);
|
||||
}
|
||||
// System.out.println("---:"+initialPointJsonListnew1);
|
||||
request.setAttribute("botlist", initialPointJsonListnew1);
|
||||
}
|
||||
|
||||
request.setAttribute("result", initialPointJsonListnew1);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doBotEdit.do")
|
||||
public String doBotEdit(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
Bot bot = this.botservice.selectById(id);
|
||||
Company company = unitService.getCompById(bot.getBizid());
|
||||
request.setAttribute("bizname", company.getName());
|
||||
model.addAttribute("bot", bot);
|
||||
return "bot/doBotEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/doBotUpdate.do")
|
||||
public String doBotUpdate(HttpServletRequest request, Model model,
|
||||
@ModelAttribute("bot") Bot bot) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
bot.setUpsuser(cu.getId());
|
||||
bot.setUpsdt(CommUtil.nowDate());
|
||||
int res = this.botservice.update(bot);
|
||||
model.addAttribute("result", res);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/getBotdata.do")
|
||||
public String getBotdata(HttpServletRequest request, Model model,
|
||||
@RequestParam String unitId) {
|
||||
JSONObject botObject = new JSONObject();
|
||||
|
||||
if (unitId != null && !unitId.equals("")) {
|
||||
Company company = this.companyService.selectByPrimaryKey(unitId);
|
||||
if (company != null) {
|
||||
botObject.put("bizname", company.getName());
|
||||
}
|
||||
}
|
||||
|
||||
List<Bot> botList = this.botservice.selectListByWhere("where bizid='" + unitId + "'");
|
||||
if (botList != null && botList.size() > 0) {
|
||||
botObject.put("designScale", botList.get(0).getDesignScale());
|
||||
botObject.put("emission", botList.get(0).getEmission());
|
||||
botObject.put("influentIndex", botList.get(0).getInfluentIndex());
|
||||
botObject.put("effluentIndex", botList.get(0).getEffluentIndex());
|
||||
botObject.put("proess", botList.get(0).getProcess());
|
||||
botObject.put("price", botList.get(0).getPrice());
|
||||
botObject.put("calculation", botList.get(0).getCalculation());
|
||||
botObject.put("signdate", botList.get(0).getSigndate());
|
||||
botObject.put("franchisePeriod", botList.get(0).getFranchisePeriod());
|
||||
}
|
||||
request.setAttribute("result", botObject);
|
||||
|
||||
return "result";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* * 获取十bai六进制的颜du色zhi代码dao.例如 "#6E36B4" , For HTML ,
|
||||
* * @return String
|
||||
*
|
||||
*/
|
||||
public static String getRandColorCode() {
|
||||
String r, g, b;
|
||||
Random random = new Random();
|
||||
r = Integer.toHexString(random.nextInt(256)).toUpperCase();
|
||||
g = Integer.toHexString(random.nextInt(256)).toUpperCase();
|
||||
b = Integer.toHexString(random.nextInt(256)).toUpperCase();
|
||||
|
||||
r = r.length() == 1 ? "0" + r : r;
|
||||
g = g.length() == 1 ? "0" + g : g;
|
||||
b = b.length() == 1 ? "0" + b : b;
|
||||
return r + g + b;
|
||||
}
|
||||
|
||||
@RequestMapping("/getBotdataForApp.do")
|
||||
public String getBotdataForApp(HttpServletRequest request, Model model,
|
||||
@RequestParam String unitId) {
|
||||
List<Bot> botList = this.botservice.selectListByWhere("where bizid='" + unitId + "'");
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
if (botList != null && botList.size() > 0) {
|
||||
jsonObject.put("code", 1);
|
||||
jsonObject.put("msg", "");
|
||||
for (Bot bot : botList) {
|
||||
JSONObject jsonObjectD = new JSONObject();
|
||||
jsonObjectD.put("id", bot.getId());
|
||||
jsonObjectD.put("LGTD", bot.getLgtd());
|
||||
if (bot.getType() != null && !bot.getType().equals("")) {
|
||||
jsonObjectD.put("type", bot.getType());
|
||||
} else {
|
||||
jsonObjectD.put("type", "");
|
||||
}
|
||||
|
||||
Company company = companyService.selectByPrimaryKey(bot.getBizid());
|
||||
if (company != null) {
|
||||
jsonObjectD.put("SHORT_NAME", company.getName());
|
||||
jsonObjectD.put("ADDRESS", company.getAddress());
|
||||
jsonObjectD.put("sname", company.getSname());
|
||||
} else {
|
||||
jsonObjectD.put("SHORT_NAME", "");
|
||||
jsonObjectD.put("ADDRESS", bot.getAddress());
|
||||
jsonObjectD.put("sname", "");
|
||||
}
|
||||
|
||||
jsonObjectD.put("emission", bot.getEmission());
|
||||
jsonObjectD.put("LINE_MAP_URL", bot.getLineMapUrl());
|
||||
jsonObjectD.put("lgtd", bot.getLgtd());
|
||||
jsonObjectD.put("CAPFACT", "");
|
||||
jsonObjectD.put("defaultLoad", bot.getDefaultLoad());
|
||||
|
||||
if (bot.getClickState() != null && !bot.getClickState().equals("")) {
|
||||
jsonObjectD.put("CLICK_STATE", bot.getClickState());
|
||||
} else {
|
||||
jsonObjectD.put("CLICK_STATE", "false");
|
||||
}
|
||||
|
||||
jsonObjectD.put("OUTQ", "");
|
||||
jsonObjectD.put("lttd", bot.getLttd());
|
||||
jsonObjectD.put("INQ", "");
|
||||
jsonObjectD.put("LTTD", bot.getLttd());
|
||||
if (bot.getProcess() != null && !bot.getProcess().equals("")) {
|
||||
jsonObjectD.put("process", bot.getProcess());
|
||||
} else {
|
||||
jsonObjectD.put("process", "");
|
||||
}
|
||||
|
||||
jsonObjectD.put("POINT_MAP_URL", bot.getPointMapUrl());
|
||||
|
||||
jsonObjectD.put("bizid", bot.getBizid());
|
||||
jsonObjectD.put("TM", "");
|
||||
jsonArray.add(jsonObjectD);
|
||||
}
|
||||
|
||||
} else {
|
||||
jsonObject.put("code", 0);
|
||||
jsonObject.put("msg", "");
|
||||
}
|
||||
jsonObject.put("result", jsonArray);
|
||||
|
||||
request.setAttribute("result", jsonObject);
|
||||
return "result";
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,169 @@
|
||||
package com.sipai.controller.business;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.business.BusinessUnit;
|
||||
import com.sipai.entity.business.BusinessUnit;
|
||||
import com.sipai.entity.user.Unit;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.entity.work.Group;
|
||||
import com.sipai.entity.work.GroupMember;
|
||||
import com.sipai.entity.work.UserWorkStation;
|
||||
import com.sipai.service.base.LoginService;
|
||||
import com.sipai.service.business.BusinessUnitService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.service.work.GroupMemberService;
|
||||
import com.sipai.service.work.GroupService;
|
||||
import com.sipai.tools.CommString;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/business/businessunit")
|
||||
public class BusinessUnitController {
|
||||
@Resource
|
||||
private BusinessUnitService businessUnitService;
|
||||
|
||||
@RequestMapping("/selectById.do")
|
||||
public ModelAndView selectById(HttpServletRequest request,Model model) {
|
||||
String businessUnitId = request.getParameter("id");
|
||||
BusinessUnit businessUnit = this.businessUnitService.selectById(businessUnitId);
|
||||
model.addAttribute("result",com.alibaba.fastjson.JSONObject.toJSONString(businessUnit));
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
@RequestMapping("/showlist.do")
|
||||
public String showlist(HttpServletRequest request,Model model) {
|
||||
return "/business/businessUnitList";
|
||||
}
|
||||
@RequestMapping("/getlist.do")
|
||||
public ModelAndView getlist(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required=false) String sort,
|
||||
@RequestParam(value = "order", required=false) String order) {
|
||||
HttpSession currentSession = request.getSession(false);
|
||||
User cu=(User)request.getSession().getAttribute("cu");
|
||||
// if(cu==null){
|
||||
// cu=loginService.Login(request.getParameter("username"), request.getParameter("pwd"));
|
||||
// }
|
||||
if(sort==null){
|
||||
sort = " insdt ";
|
||||
}
|
||||
if(order==null){
|
||||
order = " asc ";
|
||||
}
|
||||
String orderstr=" order by "+sort+" "+order;
|
||||
|
||||
String wherestr=CommUtil.getwherestr("insuser", "business/businessUnit/showlist.do", cu);
|
||||
if(request.getParameter("querytype")!=null&&request.getParameter("querytype").equals("select")){
|
||||
wherestr = " where 1=1 ";
|
||||
}
|
||||
if(request.getParameter("search_name")!=null && !request.getParameter("search_name").isEmpty()){
|
||||
wherestr += " and name like '%"+request.getParameter("search_name")+"%' ";
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<BusinessUnit> list = this.businessUnitService.selectListByWhere(wherestr+orderstr);
|
||||
|
||||
PageInfo<BusinessUnit> pi = new PageInfo<BusinessUnit>(list);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
|
||||
String result="{\"total\":"+pi.getTotal()+",\"rows\":"+json+"}";
|
||||
// System.out.println(result);
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/add.do")
|
||||
public String doadd(HttpServletRequest request,Model model){
|
||||
return "business/businessUnitAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/edit.do")
|
||||
public String doedit(HttpServletRequest request,Model model){
|
||||
String businessUnitId = request.getParameter("id");
|
||||
BusinessUnit businessUnit = this.businessUnitService.selectById(businessUnitId);
|
||||
model.addAttribute("businessUnit", businessUnit);
|
||||
return "business/businessUnitEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/save.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute BusinessUnit businessUnit){
|
||||
User cu= (User)request.getSession().getAttribute("cu");
|
||||
String id = CommUtil.getUUID();
|
||||
businessUnit.setId(id);
|
||||
businessUnit.setInsuser(cu.getId());
|
||||
businessUnit.setInsdt(CommUtil.nowDate());
|
||||
|
||||
int result = this.businessUnitService.save(businessUnit);
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+id+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
@RequestMapping("/update.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute BusinessUnit businessUnit){
|
||||
int result = this.businessUnitService.update(businessUnit);
|
||||
String resstr="{\"res\":\""+result+"\",\"id\":\""+businessUnit.getId()+"\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/delete.do")
|
||||
public String dodel(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id){
|
||||
int result = this.businessUnitService.deleteById(id);
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/deletes.do")
|
||||
public String dodels(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="ids") String ids){
|
||||
ids=ids.replace(",","','");
|
||||
int result = this.businessUnitService.deleteByWhere("where id in ('"+ids+"')");
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/showlistForSelect.do")
|
||||
public String showlistForSelect(HttpServletRequest request,Model model) {
|
||||
return "/business/businessUnitListForSelect";
|
||||
}
|
||||
|
||||
@RequestMapping("/getList4Select.do")
|
||||
public String getList4Select(HttpServletRequest request,Model model) {
|
||||
JSONArray json=new JSONArray();
|
||||
String processTypeId = request.getParameter("processTypeId");
|
||||
String wherestr ="where active = '"+CommString.Active_True+"' and process_type_id ='"+processTypeId+"' order by insdt asc";
|
||||
List<BusinessUnit> list= businessUnitService.selectListByWhere(wherestr);
|
||||
if(list!=null && list.size()>0){
|
||||
for (BusinessUnit businessUnit : list) {
|
||||
JSONObject jsonObject =new JSONObject();
|
||||
jsonObject.put("id", businessUnit.getId());
|
||||
jsonObject.put("text", businessUnit.getName());
|
||||
json.add(jsonObject);
|
||||
}
|
||||
|
||||
}
|
||||
model.addAttribute("result", json.toString());
|
||||
return "result";
|
||||
}
|
||||
}
|
||||
448
src/main/java/com/sipai/controller/cmd/CmdController.java
Normal file
448
src/main/java/com/sipai/controller/cmd/CmdController.java
Normal file
@ -0,0 +1,448 @@
|
||||
package com.sipai.controller.cmd;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.sipai.entity.Listener.ListenerMessage;
|
||||
import com.sipai.entity.alarm.AlarmLevelsCodeEnum;
|
||||
import com.sipai.entity.alarm.AlarmMoldCodeEnum;
|
||||
import com.sipai.entity.base.BasicConfigure;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.equipment.EquipmentCard;
|
||||
import com.sipai.entity.equipment.EquipmentCardCamera;
|
||||
import com.sipai.entity.scada.MPoint;
|
||||
import com.sipai.entity.scada.ProAlarm;
|
||||
import com.sipai.entity.schedule.ScheduleJob;
|
||||
import com.sipai.entity.user.Company;
|
||||
import com.sipai.entity.user.ProcessSection;
|
||||
import com.sipai.entity.work.Camera;
|
||||
import com.sipai.quartz.job.*;
|
||||
import com.sipai.service.Listener.ListenerMessageService;
|
||||
import com.sipai.service.alarm.AlarmPointService;
|
||||
import com.sipai.service.base.BasicConfigureService;
|
||||
import com.sipai.service.cmd.CmdService;
|
||||
import com.sipai.service.company.CompanyService;
|
||||
import com.sipai.service.equipment.EquipmentCardCameraService;
|
||||
import com.sipai.service.equipment.EquipmentCardService;
|
||||
import com.sipai.service.scada.MPointService;
|
||||
import com.sipai.service.scada.ProAlarmService;
|
||||
import com.sipai.service.user.ProcessSectionService;
|
||||
import com.sipai.service.user.UserService;
|
||||
import com.sipai.service.work.CameraService;
|
||||
import com.sipai.tools.CommString;
|
||||
import com.sipai.tools.CommUtil;
|
||||
import com.sipai.tools.MessageEnum;
|
||||
import com.sipai.tools.WebSocketCmdUtil;
|
||||
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
|
||||
import io.swagger.annotations.*;
|
||||
import org.redisson.api.RBatch;
|
||||
import org.redisson.api.RMap;
|
||||
import org.redisson.api.RMapCache;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.security.access.method.P;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 一些控制的方法 包含智能供配电请求过来的
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/cmd/cmdController")
|
||||
@Api(value = "/cmd/cmdController", tags = "跟BIM交互接口")
|
||||
public class CmdController {
|
||||
@Resource
|
||||
private CmdService cmdService;
|
||||
@Resource
|
||||
private EquipmentCardService equipmentCardService;
|
||||
@Resource
|
||||
private ProAlarmService proAlarmService;
|
||||
@Resource
|
||||
private AlarmPointService alarmPointService;
|
||||
@Resource
|
||||
private ProcessSectionService processSectionService;
|
||||
@Resource
|
||||
private EquipmentCardCameraService equipmentCardCameraService;
|
||||
@Resource
|
||||
private ListenerMessageService listenerMessageSerice;
|
||||
@Resource
|
||||
private RedissonClient redissonClient;
|
||||
@Resource
|
||||
private BasicConfigureService basicConfigureService;
|
||||
@Resource
|
||||
private MPointService mPointService;
|
||||
|
||||
/**
|
||||
* 设备定位(从设备台账列表点击定位 给BIM发送指令)
|
||||
*/
|
||||
@RequestMapping("/locationEquipment.do")
|
||||
public String locationEquipment(HttpServletRequest request, Model model, @RequestParam(value = "id") String id) {
|
||||
String result = "1";
|
||||
cmdService.locationEquipment(id);
|
||||
|
||||
//发送弹出摄像头指令
|
||||
List<EquipmentCardCamera> cameras = equipmentCardCameraService.selectListByWhere("where eqId = '" + id + "'");
|
||||
if (cameras != null && cameras.size() > 0) {
|
||||
String cameraids = "";
|
||||
for (int i = 0; i < cameras.size(); i++) {
|
||||
cameraids += cameras.get(i).getCameraid() + ",";
|
||||
}
|
||||
//弹出摄像头指令
|
||||
cmdService.locationCameraOpenMore(cameraids);
|
||||
}
|
||||
|
||||
//删除设备附属信息
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
/**
|
||||
* 三维联动(从报警服务请求过来的测量点Id,然后去查对应的设备和设备下关联的摄像头,推送ws给三维)
|
||||
*/
|
||||
@RequestMapping("/linkBIM4Alarm.do")
|
||||
public String linkBIM4Alarm(HttpServletRequest request, Model model, @RequestParam(value = "id") String id) {
|
||||
String result = "1";
|
||||
|
||||
MPoint mPoint = mPointService.selectById(id);
|
||||
if (mPoint != null && mPoint.getEquipmentid() != null && !mPoint.getEquipmentid().equals("")) {
|
||||
//定位设备
|
||||
cmdService.locationEquipment(mPoint.getEquipmentid());
|
||||
|
||||
//关闭之前的摄像头
|
||||
cmdService.locationCameraClose("");
|
||||
|
||||
//发送弹出摄像头指令
|
||||
List<EquipmentCardCamera> cameras = equipmentCardCameraService.selectListByWhere("where eqId = '" + mPoint.getEquipmentid() + "'");
|
||||
if (cameras != null && cameras.size() > 0) {
|
||||
String cameraids = "";
|
||||
for (int i = 0; i < cameras.size(); i++) {
|
||||
cameraids += cameras.get(i).getCameraid() + ",";
|
||||
}
|
||||
cmdService.locationCameraOpenMore2(cameraids);
|
||||
} else {
|
||||
// cmdService.locationCameraClose("");
|
||||
}
|
||||
}
|
||||
|
||||
//删除设备附属信息
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备定位(从设备台账列表点击 给BIM发送指令)
|
||||
*/
|
||||
@RequestMapping("/locationUser.do")
|
||||
public String locationUser(HttpServletRequest request, Model model, @RequestParam(value = "id") String id) {
|
||||
String result = "1";
|
||||
cmdService.locationUser(id);
|
||||
//删除设备附属信息
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收第三方请求数据(万利达) 对BIM发送指令 ----------- 设备报警
|
||||
*/
|
||||
@RequestMapping("/locationWLD.do")
|
||||
public String locationWLD(HttpServletRequest request, Model model, @RequestParam(value = "equipmentCardId") String equipmentCardId, @RequestParam(value = "event") String event) {
|
||||
String itemName = request.getParameter("itemName");
|
||||
String startTime = request.getParameter("startTime");
|
||||
System.out.println("测试测试测试:" + equipmentCardId + "-------" + event + "-------" + itemName + "--------" + startTime);
|
||||
EquipmentCard equipmentCard = equipmentCardService.selectByEquipmentCardId(equipmentCardId);
|
||||
if (equipmentCard != null) {
|
||||
//查询摄像头关联信息
|
||||
String cameraids = "";
|
||||
List<EquipmentCardCamera> cameras = equipmentCardCameraService.selectListByWhere("where eqId = '" + equipmentCard.getId() + "'");
|
||||
if (cameras != null && cameras.size() > 0) {
|
||||
for (int i = 0; i < cameras.size(); i++) {
|
||||
cameraids += cameras.get(i).getCameraid() + ",";
|
||||
}
|
||||
}
|
||||
|
||||
//新报警
|
||||
String alarmType = AlarmMoldCodeEnum.Type_ZNPD.getKey();
|
||||
String pointCode = equipmentCard.getEquipmentcardid();
|
||||
String pointName = equipmentCard.getEquipmentname();
|
||||
String alarmTime = startTime;
|
||||
String bizId = equipmentCard.getBizid();
|
||||
String alarmLevel = AlarmLevelsCodeEnum.level1.getKey();
|
||||
String describe = "智能供配电设备报警:" + itemName;
|
||||
String nowValue = "1";
|
||||
String recoverValue = "0";
|
||||
String processSectionCode = "";
|
||||
String processSectionName = "";
|
||||
|
||||
String sql = "where point_code = '" + equipmentCardId + "' and alarm_type = '" + AlarmMoldCodeEnum.Type_ZNPD + "' and biz_id = '" + equipmentCard.getBizid() + "' and status ='" + ProAlarm.STATUS_ALARM + "' and alarm_level = '" + AlarmLevelsCodeEnum.level1 + "' order by insdt desc";
|
||||
List<ProAlarm> list = proAlarmService.selectListByWhere(equipmentCard.getBizid(), sql);
|
||||
if (list != null && list.size() > 0) {
|
||||
System.out.println("已存在:" + equipmentCardId);
|
||||
//已存在报警
|
||||
if (event != null && event.equals("RECOVERY")) {
|
||||
try {
|
||||
//1.关闭摄像头指令
|
||||
cmdService.locationCameraClose(cameraids);
|
||||
} catch (Exception e) {
|
||||
System.out.println("异常1------------");
|
||||
}
|
||||
|
||||
//2.报警恢复
|
||||
int result = this.alarmPointService.alarmRecover(bizId, pointCode, alarmTime, recoverValue);
|
||||
if (result == 1) {
|
||||
System.out.println("新增智能供配电报警恢复");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
System.out.println("新报警:" + equipmentCardId);
|
||||
if (equipmentCard.getProcesssectionid() != null && !equipmentCard.getProcesssectionid().equals("")) {
|
||||
ProcessSection processSection = processSectionService.selectById(equipmentCard.getProcesssectionid());
|
||||
if (processSection != null) {
|
||||
processSectionCode = processSection.getCode();
|
||||
processSectionName = processSection.getName();
|
||||
}
|
||||
}
|
||||
if (event != null && event.equals("NEW")) {
|
||||
try {
|
||||
//1.发送设备定位指令
|
||||
cmdService.locationEquipment(equipmentCard.getId());
|
||||
//2.弹出摄像头指令
|
||||
cmdService.locationCameraOpenMore(cameraids);
|
||||
} catch (Exception e) {
|
||||
System.out.println("异常2------------");
|
||||
}
|
||||
|
||||
//3.新增报警
|
||||
System.out.println("保存报警:" + equipmentCardId);
|
||||
int result = this.alarmPointService.insertAlarm(bizId, null, alarmType, pointCode, pointName, alarmTime, alarmLevel, describe, nowValue, processSectionCode, processSectionName);
|
||||
if (result == 1) {
|
||||
System.out.println("新增智能供配电报警成功");
|
||||
} else {
|
||||
System.out.println("新增智能供配电报警失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Result result = Result.success(null);
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 接收第三方请求数据(万利达) 对BIM发送指令 ----------- 开合闸
|
||||
*/
|
||||
@RequestMapping("/locationWLD2.do")
|
||||
public String locationWLD2(HttpServletRequest request, Model model, @RequestParam(value = "equipmentCardId") String equipmentCardId, @RequestParam(value = "st") String st, @RequestParam(value = "startTime") String startTime) {
|
||||
// System.out.println(equipmentCardId + "-------" + st + "-------" + CommUtil.nowDate());
|
||||
EquipmentCard equipmentCard = equipmentCardService.selectByEquipmentCardId(equipmentCardId);
|
||||
if (equipmentCard != null) {
|
||||
//发送设备定位指令
|
||||
cmdService.locationEquipment(equipmentCard.getId());
|
||||
|
||||
//发送弹出摄像头指令
|
||||
List<EquipmentCardCamera> cameras = equipmentCardCameraService.selectListByWhere("where eqid = '" + equipmentCard.getId() + "'");
|
||||
if (cameras != null && cameras.size() > 0) {
|
||||
/*JSONObject cameraJson = JSONObject.parseObject(MessageEnum.THE_OPENCAM.toString());
|
||||
Camera camera01 = cameraService.selectById(cameras.get(0).getCameraid());
|
||||
if ("dahua".equals(camera01.getType())) {
|
||||
String came = "rtsp://" + camera01.getUsername() + ":" + camera01.getPassword() + "@" + camera01.getUrl() + "/cam/realmonitor?channel=" + camera01.getChannel() + "&subtype=0";
|
||||
cameraJson.put("objId", came);
|
||||
cameraJson.put("action", "play[开合闸]");
|
||||
} else if ("hikvision".equals(camera01.getType())) {
|
||||
String came = "rtsp://" + camera01.getUsername() + ":" + camera01.getPassword() + "@" + camera01.getUrl() + "/h264/ch" + camera01.getChannel() + "/main/av_stream";
|
||||
cameraJson.put("objId", came);
|
||||
cameraJson.put("action", "play[开合闸]");
|
||||
}
|
||||
//调用指令给BIM发消息(摄像头)
|
||||
WebSocketCmdUtil.send(cameraJson);
|
||||
int camera2 = saveMessage(cameraJson.get("cmdType").toString(), "标识开合闸1_" + cameraJson.get("objId").toString(), cameraJson.get("action").toString());
|
||||
if (camera2 != 1) {
|
||||
System.out.println("存cmd失败");
|
||||
}*/
|
||||
String cameraids = "";
|
||||
for (int i = 0; i < cameras.size(); i++) {
|
||||
cameraids += cameras.get(i).getCameraid() + ",";
|
||||
}
|
||||
//弹出摄像头指令
|
||||
cmdService.locationCameraOpenMore(cameraids);
|
||||
}
|
||||
}
|
||||
|
||||
Result result = Result.success(null);
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
/**
|
||||
* 从mqtt客户端接收指令 通过wms发给BIM (其他系统也可以)
|
||||
*
|
||||
* @param request
|
||||
* @param model
|
||||
* @param measurepointId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/handleOtherSystem.do")
|
||||
public String handleOtherSystem(HttpServletRequest request, Model model, @RequestParam(value = "measurepointId") String measurepointId, @RequestParam(value = "dataType") String dataType, @RequestParam(value = "value") String value, @RequestParam(value = "listenerName") String listenerName) {
|
||||
cmdService.handleOtherSystem(measurepointId, dataType, value, listenerName);
|
||||
Result result = Result.success(null);
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
/**
|
||||
* 从沙口上位机接收语音 通过wms发给BIM
|
||||
*
|
||||
* @param request
|
||||
* @param model
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "上位机接收语音 通过wms发给BIM", notes = "上位机接收语音 通过wms发给BIM", httpMethod = "POST")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求参数没填好")})
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "value", value = "语音内容字符串", dataType = "String", paramType = "query", required = true)
|
||||
})
|
||||
@RequestMapping(value = "/handle4Speech.do", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public String handle4Speech(HttpServletRequest request, Model model, @RequestParam(value = "value") String value) {
|
||||
System.out.println("收到普通语音(" + CommUtil.nowDate() + "):" + value);
|
||||
//发送语音
|
||||
cmdService.handle4Speech(value);
|
||||
|
||||
//调用语音及后续处理
|
||||
cmdService.handle4Model(value);
|
||||
|
||||
Result result = Result.success(null);
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收报警推送来的内容+专家建议 通过wms 发给BIM 前端会请求好几次到接口,通过redis过滤只推送一条到BIM
|
||||
*
|
||||
* @param request
|
||||
* @param model
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "上位机接收语音 通过wms发给BIM", notes = "上位机接收语音 通过wms发给BIM", httpMethod = "POST")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求参数没填好")})
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "value", value = "语音内容字符串", dataType = "String", paramType = "query", required = true)
|
||||
})
|
||||
@RequestMapping(value = "/handle4SpeechAlarm.do", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public String handle4SpeechAlarm(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "value") String value,
|
||||
@RequestParam(value = "mpId") String mpId) {
|
||||
System.out.println("收到报警语音(" + CommUtil.nowDate() + "):" + mpId + value);
|
||||
|
||||
RBatch batch = redissonClient.createBatch();
|
||||
RMapCache<String, String> map_redis = redissonClient.getMapCache("alarm_handle_repeat");
|
||||
|
||||
if (map_redis.get(mpId) != null) {
|
||||
if (map_redis.get(mpId).equals("1")) {
|
||||
//重复
|
||||
} else {
|
||||
batch.getMapCache("alarm_handle_repeat").fastPutAsync(mpId, "1", 10, TimeUnit.SECONDS);
|
||||
batch.execute();
|
||||
//发送语音
|
||||
cmdService.handle4Speech(value);
|
||||
}
|
||||
|
||||
} else {
|
||||
batch.getMapCache("alarm_handle_repeat").fastPutAsync(mpId, "1", 10, TimeUnit.SECONDS);
|
||||
batch.execute();
|
||||
//发送语音
|
||||
cmdService.handle4Speech(value);
|
||||
}
|
||||
|
||||
Result result = Result.success(null);
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
/**
|
||||
* 存收发记录
|
||||
*
|
||||
* @param cmdtype
|
||||
* @param objid
|
||||
* @param action
|
||||
* @return
|
||||
*/
|
||||
private int saveMessage(String cmdtype, String objid, String action) {
|
||||
ListenerMessage listenerMessage = new ListenerMessage();
|
||||
listenerMessage.setId(CommUtil.getUUID());
|
||||
listenerMessage.setCmdtype(cmdtype);
|
||||
listenerMessage.setObjid(objid);
|
||||
listenerMessage.setAction(action);
|
||||
listenerMessage.setInsdt(CommUtil.nowDate());
|
||||
int save = listenerMessageSerice.save(listenerMessage);
|
||||
return save;
|
||||
}
|
||||
|
||||
@RequestMapping("/model_jy.do")
|
||||
public String model_jy(HttpServletRequest request, Model model) {
|
||||
ScheduleJob scheduleJob = null;
|
||||
ModelJob_FSSK_JY1 mojob = new ModelJob_FSSK_JY1();
|
||||
mojob.dataSave(scheduleJob);
|
||||
Result result = Result.success(null);
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/model_bz1.do")
|
||||
public String model_bz1(HttpServletRequest request, Model model) {
|
||||
ScheduleJob scheduleJob = null;
|
||||
ModelJob_FSSK_BZNH_1 mojob = new ModelJob_FSSK_BZNH_1();
|
||||
mojob.dataSave(scheduleJob);
|
||||
Result result = Result.success(null);
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/model_bz2.do")
|
||||
public String model_bz2(HttpServletRequest request, Model model) {
|
||||
ScheduleJob scheduleJob = null;
|
||||
ModelJob_FSSK_BZNH_2 mojob = new ModelJob_FSSK_BZNH_2();
|
||||
mojob.dataSave(scheduleJob);
|
||||
Result result = Result.success(null);
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取报警弹窗的任务头像路径
|
||||
*
|
||||
* @param request
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getAlarmImg.do")
|
||||
public String getAlarmImg(HttpServletRequest request, Model model) {
|
||||
BasicConfigure basicConfigure = basicConfigureService.selectById("alarm-layer-img");
|
||||
if (basicConfigure != null && basicConfigure.getAbspath() != null && !basicConfigure.getAbspath().equals("")) {
|
||||
model.addAttribute("result", basicConfigure.getAbspath());
|
||||
} else {
|
||||
model.addAttribute("result", "");
|
||||
}
|
||||
return "result";
|
||||
}
|
||||
|
||||
// String sdt = CommUtil.subplus(patrolPlan.getPlanIssuanceDate(), patrolPlan.getAdvanceDay() * (-1) + "", "day");
|
||||
@RequestMapping("/test.do")
|
||||
public String test(HttpServletRequest request, Model model) {
|
||||
String sdt = "2027-03-01";
|
||||
int edt = 45;
|
||||
String s = CommUtil.subplus(sdt, edt * (-1) + "", "day");
|
||||
System.out.println(s);
|
||||
return "result";
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,112 @@
|
||||
package com.sipai.controller.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import com.sipai.entity.command.EmergencyConfigureDetail;
|
||||
import com.sipai.entity.command.EmergencyConfigureInfo;
|
||||
import com.sipai.service.command.EmergencyConfigureDetailService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/command/emergencyConfigureDetail")
|
||||
public class EmergencyConfigureDetailController {
|
||||
|
||||
@Resource
|
||||
private EmergencyConfigureDetailService emergencyConfigureDetailService;
|
||||
|
||||
@RequestMapping("/getFuncJson.do")
|
||||
public String getFuncJson(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
List<EmergencyConfigureDetail> list = this.emergencyConfigureDetailService.selectListByWhere("where pid='"+id+"'");
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
String result="{\"total\":"+list.size()+",\"rows\":"+json+"}";
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
/**
|
||||
* 北控版本
|
||||
* @param request
|
||||
* @param model
|
||||
* @param pid
|
||||
* @param unitId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/showFuncAdd.do")
|
||||
public String doFuncAdd(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="pid") String pid,
|
||||
@RequestParam(value="unitId") String unitId){
|
||||
if(pid!=null && !pid.equals("")){
|
||||
//System.out.println("pid:::"+pid);
|
||||
model.addAttribute("pid",pid);
|
||||
/*model.addAttribute("_pname",emergencyConfigureInfo.getName());*/
|
||||
}
|
||||
model.addAttribute("bizid",unitId);
|
||||
return "command/menuFuncAdd_detail";
|
||||
}
|
||||
|
||||
@RequestMapping("/saveFunc.do")
|
||||
public String dosaveFunc(HttpServletRequest request,Model model,
|
||||
@ModelAttribute("emergencyConfigureDetail") EmergencyConfigureDetail emergencyConfigureDetail){
|
||||
emergencyConfigureDetail.setId(CommUtil.getUUID());
|
||||
|
||||
int result = this.emergencyConfigureDetailService.saveMenu(emergencyConfigureDetail);
|
||||
model.addAttribute("result", "{\"res\":\""+result+"\",\"id\":\""+emergencyConfigureDetail.getId()+"\"}");
|
||||
//System.out.println("new_result::"+"{\"res\":\""+result+"\",\"id\":\""+emergencyConfigureInfo.getId()+"\"}");
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/showFuncEdit.do")
|
||||
public String doFuncEdit(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="pid") String pid,
|
||||
@RequestParam(value="id") String id,
|
||||
@RequestParam(value="unitId") String unitId){
|
||||
EmergencyConfigureDetail emergencyConfigureDetail= emergencyConfigureDetailService.getMenuById(id);
|
||||
model.addAttribute("emergencyConfigureDetail",emergencyConfigureDetail );
|
||||
if(pid!=null && !pid.equals("")){
|
||||
model.addAttribute("pid",pid);
|
||||
}
|
||||
model.addAttribute("bizid",unitId);
|
||||
return "command/menuFuncEdit_detail";
|
||||
}
|
||||
|
||||
@RequestMapping("/updateFunc.do")
|
||||
public String doupdateFunc(HttpServletRequest request,Model model,
|
||||
@ModelAttribute EmergencyConfigureDetail emergencyConfigureDetail){
|
||||
int result = this.emergencyConfigureDetailService.updateMenu(emergencyConfigureDetail);
|
||||
model.addAttribute("result", "{\"res\":\""+result+"\",\"id\":\""+emergencyConfigureDetail.getId()+"\"}");
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/deleteMenu.do")
|
||||
public String dodel(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id){
|
||||
|
||||
String msg = "";
|
||||
int result = 0;
|
||||
//System.out.println("del_id:::"+id);
|
||||
List<EmergencyConfigureDetail> mlist = this.emergencyConfigureDetailService.selectListByWhere(" where id = '"+id+"'");
|
||||
if(mlist!=null && mlist.size()>0){
|
||||
result = this.emergencyConfigureDetailService.deleteMenuById(id);
|
||||
}else{
|
||||
msg="删除失败";
|
||||
}
|
||||
model.addAttribute("result","{\"res\":\""+result+"\",\"msg\":\""+msg+"\"}");
|
||||
|
||||
return "result";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,331 @@
|
||||
package com.sipai.controller.command;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.command.EmergencyConfigure;
|
||||
import com.sipai.entity.command.EmergencyConfigureInfo;
|
||||
import com.sipai.entity.command.EmergencyConfigureWorkOrder;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.command.EmergencyConfigureInfoService;
|
||||
import com.sipai.service.command.EmergencyConfigureService;
|
||||
import com.sipai.service.command.EmergencyConfigureWorkOrderService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/command/emergencyConfigure")
|
||||
public class EmergencyConfigureInfoController {
|
||||
@Resource
|
||||
private EmergencyConfigureInfoService emergencyConfigureInfoService;
|
||||
@Resource
|
||||
private EmergencyConfigureService emergencyConfigureService;
|
||||
@Resource
|
||||
private EmergencyConfigureWorkOrderService emergencyConfigureWorkOrderService;
|
||||
|
||||
@RequestMapping("/getFuncJson.do")
|
||||
public String getFuncJson(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required = false) String sort,
|
||||
@RequestParam(value = "order", required = false) String order){
|
||||
PageHelper.startPage(page, rows);
|
||||
List<EmergencyConfigureInfo> list = this.emergencyConfigureInfoService.selectcountByWhere("where m.pid='"+id+"' order by m.ord");
|
||||
PageInfo<EmergencyConfigureInfo> pInfo = new PageInfo<EmergencyConfigureInfo>(list);
|
||||
JSONArray jsonArray = JSONArray.fromObject(list);
|
||||
if(list.size()==0){
|
||||
List<EmergencyConfigureInfo> list1 = this.emergencyConfigureInfoService.selectListByWhere("where pid='"+id+"' order by ord");
|
||||
jsonArray = JSONArray.fromObject(list1);
|
||||
}
|
||||
List<EmergencyConfigureWorkOrder> list2 = this.emergencyConfigureWorkOrderService.selectListByWhere("where nodeid='"+id+"'");
|
||||
|
||||
String result = "{\"total\":"+pInfo.getTotal()+",\"rows\":"+jsonArray+",\"size\":"+list2.size()+"}";
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
// String result="{\"total\":"+list.size()+",\"rows\":"+json+",\"size\":"+list2.size()+"}";
|
||||
// model.addAttribute("result", result);
|
||||
//
|
||||
// return "result";
|
||||
}
|
||||
@RequestMapping("/getInfoJson.do")
|
||||
public ModelAndView getInfoJson(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
List<EmergencyConfigureInfo> list1 = this.emergencyConfigureInfoService.selectListByWhere("where pid='"+id+"' order by ord");
|
||||
JSONArray jsonArray = JSONArray.fromObject(list1);
|
||||
model.addAttribute("result", jsonArray);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
/**
|
||||
* 北控版本
|
||||
* @param request
|
||||
* @param model
|
||||
* @param pid
|
||||
* @param unitId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/showFuncAdd.do")
|
||||
public ModelAndView doFuncAdd(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="pid") String pid,
|
||||
@RequestParam(value="unitId") String unitId){
|
||||
if(pid!=null && !pid.equals("")){
|
||||
//检查是否有步骤
|
||||
List<EmergencyConfigure> list = emergencyConfigureService.selectListByWhere("where pid='"+pid+"' and type = '"+EmergencyConfigure.Type_Step+"' ");
|
||||
if(list!=null && list.size()>0){
|
||||
int result = 2;
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
//System.out.println("pid:::"+pid);
|
||||
/*model.addAttribute("_pname",emergencyConfigureInfo.getName());*/
|
||||
}
|
||||
model.addAttribute("id",request.getParameter("id"));
|
||||
model.addAttribute("pid",pid);
|
||||
model.addAttribute("bizid",unitId);
|
||||
return new ModelAndView("command/menuFuncAdd");
|
||||
}
|
||||
/**
|
||||
* 流程图版本
|
||||
* @param request
|
||||
* @param model
|
||||
* @param emergencyConfigureId
|
||||
* @param unitId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/showLogicFlowAdd.do")
|
||||
public ModelAndView showLogicFlowAdd(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="emergencyConfigureId") String emergencyConfigureId,
|
||||
@RequestParam(value="unitId") String unitId){
|
||||
model.addAttribute("emergencyConfigureId",emergencyConfigureId);
|
||||
model.addAttribute("bizid",unitId);
|
||||
return new ModelAndView("command/emergencyConfigureLogicFlowAdd");
|
||||
}
|
||||
/**
|
||||
* 南市版本
|
||||
* @param request
|
||||
* @param model
|
||||
* @param pid
|
||||
* @param unitId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/showFuncAdd4NS.do")
|
||||
public String showFuncAdd4NS(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="pid") String pid,
|
||||
@RequestParam(value="unitId") String unitId){
|
||||
if(pid!=null && !pid.equals("")){
|
||||
model.addAttribute("pid",pid);
|
||||
}
|
||||
model.addAttribute("bizid",unitId);
|
||||
return "command/menuFuncAdd4NS";
|
||||
}
|
||||
|
||||
@RequestMapping("/showFuncEdit.do")
|
||||
public String doFuncEdit(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="pid") String pid,
|
||||
@RequestParam(value="id") String id,
|
||||
@RequestParam(value="unitId") String unitId){
|
||||
EmergencyConfigureInfo emergencyConfigureInfo= emergencyConfigureInfoService.getMenuById(id);
|
||||
model.addAttribute("emergencyConfigureInfo",emergencyConfigureInfo );
|
||||
if(pid!=null && !pid.equals("")){
|
||||
model.addAttribute("pid",pid);
|
||||
}
|
||||
model.addAttribute("bizid",unitId);
|
||||
//return "command/menuFuncEdit";
|
||||
return "command/emergencyConfigureInfoEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/showFuncEdit4NS.do")
|
||||
public String doFuncEdit4NS(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="pid") String pid,
|
||||
@RequestParam(value="id") String id,
|
||||
@RequestParam(value="unitId") String unitId){
|
||||
EmergencyConfigureInfo emergencyConfigureInfo= emergencyConfigureInfoService.getMenuById(id);
|
||||
model.addAttribute("emergencyConfigureInfo",emergencyConfigureInfo );
|
||||
if(pid!=null && !pid.equals("")){
|
||||
model.addAttribute("pid",pid);
|
||||
}
|
||||
model.addAttribute("bizid",unitId);
|
||||
return "command/emergencyConfigureInfoEdit4NS";
|
||||
}
|
||||
|
||||
@RequestMapping("/editMemoFun.do")
|
||||
public String editMemoFun(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="pid") String pid,
|
||||
@RequestParam(value="id") String id,
|
||||
@RequestParam(value="unitId") String unitId){
|
||||
EmergencyConfigureInfo emergencyConfigureInfo= emergencyConfigureInfoService.getMenuById(id);
|
||||
model.addAttribute("emergencyConfigureInfo",emergencyConfigureInfo );
|
||||
if(pid!=null && !pid.equals("")){
|
||||
model.addAttribute("pid",pid);
|
||||
}
|
||||
model.addAttribute("bizid",unitId);
|
||||
//return "command/menuFuncEdit";
|
||||
return "command/emergencyConfigureInfoEdit4Memo";
|
||||
}
|
||||
|
||||
@RequestMapping("/saveFunc.do")
|
||||
public String dosaveFunc(HttpServletRequest request,Model model,
|
||||
@ModelAttribute("emergencyConfigureInfo") EmergencyConfigureInfo emergencyConfigureInfo){
|
||||
if(emergencyConfigureInfo.getId()==null || emergencyConfigureInfo.getId().isEmpty()){
|
||||
emergencyConfigureInfo.setId(CommUtil.getUUID());
|
||||
}
|
||||
int result = this.emergencyConfigureInfoService.saveMenu(emergencyConfigureInfo);
|
||||
model.addAttribute("result", "{\"res\":\""+result+"\",\"id\":\""+emergencyConfigureInfo.getId()+"\"}");
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/updateFunc.do")
|
||||
public String doupdateFunc(HttpServletRequest request,Model model,
|
||||
@ModelAttribute EmergencyConfigureInfo emergencyConfigureInfo){
|
||||
int result = this.emergencyConfigureInfoService.updateMenu(emergencyConfigureInfo);
|
||||
model.addAttribute("result", "{\"res\":\""+result+"\",\"id\":\""+emergencyConfigureInfo.getId()+"\"}");
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/deleteMenu.do")
|
||||
public String dodel(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id){
|
||||
|
||||
String msg = "";
|
||||
int result = 0;
|
||||
//System.out.println("del_id:::"+id);
|
||||
List<EmergencyConfigureInfo> mlist = this.emergencyConfigureInfoService.selectListByWhere(" where id = '"+id+"'");
|
||||
if(mlist!=null && mlist.size()>0){
|
||||
result = this.emergencyConfigureInfoService.deleteMenuById(id);
|
||||
}else{
|
||||
msg="删除失败";
|
||||
}
|
||||
model.addAttribute("result","{\"res\":\""+result+"\",\"msg\":\""+msg+"\"}");
|
||||
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doprocess3.do")
|
||||
public String doprocess3(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id,
|
||||
@RequestParam(value="category") String category){
|
||||
|
||||
|
||||
EmergencyConfigure emergencyConfigure = emergencyConfigureService.getMenuById(id);
|
||||
model.addAttribute("titleName",emergencyConfigure.getName());
|
||||
|
||||
/*
|
||||
* 三级菜单
|
||||
*/
|
||||
if(category!=null && category.equals("3")){
|
||||
List<EmergencyConfigureInfo> mlist = this.emergencyConfigureInfoService.selectListByWhere(" where pid = '"+emergencyConfigure.getId()+"'");
|
||||
JSONArray jsonArray=new JSONArray();//矩形框json
|
||||
int y=0;
|
||||
if (mlist!=null && mlist.size()>0) {
|
||||
for (int i = 0; i < mlist.size(); i++) {
|
||||
JSONObject jsonObject=new JSONObject();
|
||||
if(mlist.get(i).getRoles()!=null){
|
||||
jsonObject.put("roleName", mlist.get(i).getRoles().toString());
|
||||
}
|
||||
if(mlist.get(i).getPersonliablename() !=null){
|
||||
jsonObject.put("person", mlist.get(i).getPersonliablename().toString());
|
||||
}
|
||||
y=y+100;
|
||||
jsonObject.put("person_y", y);//责任人Y轴
|
||||
if(mlist.get(i).getContents() != null){//处理事项
|
||||
int clength = mlist.get(i).getContents().toString().length();
|
||||
if(clength>10){
|
||||
jsonObject.put("content", mlist.get(i).getContents().toString().substring(0, 10));
|
||||
}else{
|
||||
jsonObject.put("content", mlist.get(i).getContents().toString());
|
||||
}
|
||||
}
|
||||
if(mlist.get(i).getContentsdetail() != null){//操作内容
|
||||
int clength=mlist.get(i).getContentsdetail().toString().length();
|
||||
if(clength>10){
|
||||
jsonObject.put("contentDetailTitle", mlist.get(i).getContentsdetail().toString().substring(0, 10));
|
||||
}else {
|
||||
jsonObject.put("contentDetailTitle", mlist.get(i).getContentsdetail().toString());
|
||||
}
|
||||
jsonObject.put("contentDetail", mlist.get(i).getContentsdetail().toString());//详细内容
|
||||
}
|
||||
y=y+100;
|
||||
jsonObject.put("status_y", y);//是否完成Y轴
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
|
||||
}
|
||||
request.setAttribute("end_y", y+100);
|
||||
request.setAttribute("jsonArray", jsonArray);//矩形框json
|
||||
//System.out.println("jsonArray:::"+jsonArray);
|
||||
|
||||
return "command/processEmergencyConfigure";
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/dosortnew.do")
|
||||
public String dosortnew(HttpServletRequest request,Model model){
|
||||
//接收json数据
|
||||
BufferedReader streamReader = null;
|
||||
StringBuilder responseStrBuilder = new StringBuilder();
|
||||
String inputStr;
|
||||
try {
|
||||
streamReader = new BufferedReader( new
|
||||
InputStreamReader(request.getInputStream(), "UTF-8"));
|
||||
while ((inputStr = streamReader.readLine()) != null)
|
||||
responseStrBuilder.append(inputStr);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// TODO Auto-generated catch block
|
||||
System.out.println(e.toString());
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
System.out.println(e.toString());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
//转化成json对象
|
||||
com.alibaba.fastjson.JSONObject json=com.alibaba.fastjson.JSONObject.parseObject(responseStrBuilder.toString());
|
||||
String jsondata = json.getString("jsondata");
|
||||
// System.out.println("jsondata:::"+jsondata);
|
||||
String ds = jsondata;
|
||||
JSONArray jsonArray=JSONArray.fromObject(ds);
|
||||
JSONObject jsonOne;
|
||||
int result=0;
|
||||
for(int i=0;i<jsonArray.size();i++){
|
||||
jsonOne = jsonArray.getJSONObject(i);
|
||||
EmergencyConfigureInfo d= this.emergencyConfigureInfoService.getMenuById((String) jsonOne.get("id"));
|
||||
d.setOrd(i);
|
||||
result = this.emergencyConfigureInfoService.updateMenu(d);
|
||||
}
|
||||
model.addAttribute("result",result);
|
||||
return String.valueOf(result);
|
||||
}
|
||||
|
||||
@RequestMapping("/saveEditor.do")
|
||||
public String saveEditor(HttpServletRequest request,Model model){
|
||||
User cu=(User)request.getSession().getAttribute("cu");
|
||||
String descripe = request.getParameter("editorText");
|
||||
EmergencyConfigureInfo modeltype = new EmergencyConfigureInfo();
|
||||
modeltype.setId(request.getParameter("modelid"));
|
||||
modeltype.setMemo(descripe);
|
||||
int res = this.emergencyConfigureInfoService.updateMenu(modeltype);
|
||||
model.addAttribute("result", res);
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,158 @@
|
||||
package com.sipai.controller.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.sipai.entity.command.EmergencyConfigure;
|
||||
import com.sipai.entity.command.EmergencyConfigureInfo;
|
||||
import com.sipai.entity.command.EmergencyConfigureWorkOrder;
|
||||
import com.sipai.entity.command.EmergencyRecords;
|
||||
import com.sipai.entity.command.EmergencyRecordsWorkOrder;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.command.EmergencyConfigureWorkOrderService;
|
||||
import com.sipai.service.command.EmergencyRecordsWorkOrderService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/command/emergencyConfigureWorkOrder")
|
||||
public class EmergencyConfigureWorkOrderController {
|
||||
@Resource
|
||||
private EmergencyConfigureWorkOrderService emergencyConfigureWorkOrderService;
|
||||
|
||||
@RequestMapping("/showlist.do")
|
||||
public String showlist(HttpServletRequest request,Model model) {
|
||||
String id = request.getParameter("id");
|
||||
request.setAttribute("id", id);
|
||||
//System.out.println("id:::"+id);
|
||||
return "/command/emergencyConfigureWorkOrderList";
|
||||
}
|
||||
|
||||
/*
|
||||
* 工单数据查询
|
||||
*/
|
||||
@RequestMapping("/getListData.do")
|
||||
public ModelAndView getListData(HttpServletRequest request,Model model){
|
||||
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String id = request.getParameter("id");
|
||||
String scope = "";
|
||||
|
||||
// List<EmergencyRecordsWorkOrder> ia = this.emergencyRecordsWorkOrderService
|
||||
// .selectcompanynameByWhere(" where 1=1 and workreceiveuserid='"+cu.getId()+"' " + scope + " order by m.insdt desc");
|
||||
List<EmergencyConfigureWorkOrder> ia = this.emergencyConfigureWorkOrderService
|
||||
.selectworkorderrecordslistByWhere("where 1=1 and m.nodeid='"+id+"' order by insdt desc");
|
||||
//System.out.println("scpoe::"+scope);
|
||||
JSONArray json = JSONArray.fromObject(ia);
|
||||
String result="{\"total\":"+ia.size()+",\"rows\":"+json+"}";
|
||||
//System.out.println("result::"+result);
|
||||
|
||||
model.addAttribute("result", result);
|
||||
|
||||
return new ModelAndView("result");
|
||||
//return "result";
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping("/doadd.do")
|
||||
public String doadd(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id){
|
||||
request.setAttribute("id", id);
|
||||
if(id!=null && !id.equals("")){
|
||||
//System.out.println("pid:::"+pid);
|
||||
model.addAttribute("id",id);
|
||||
/*model.addAttribute("_pname",emergencyConfigureInfo.getName());*/
|
||||
}
|
||||
return "command/emergencyConfigureWorkOrderAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/dosave.do")
|
||||
public String dosave(HttpServletRequest request,Model model
|
||||
){
|
||||
EmergencyConfigureWorkOrder emergencyConfigureWorkOrder = new EmergencyConfigureWorkOrder();
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String id = request.getParameter("id");
|
||||
String workreceiveuser = request.getParameter("workreceiveuser");
|
||||
String workcontent = request.getParameter("workcontent");
|
||||
// String bizid = request.getParameter("bizid");
|
||||
String bizid = request.getParameter("bizid");
|
||||
|
||||
emergencyConfigureWorkOrder.setId(CommUtil.getUUID());
|
||||
emergencyConfigureWorkOrder.setBizid(bizid);
|
||||
emergencyConfigureWorkOrder.setInsdt(CommUtil.nowDate());
|
||||
emergencyConfigureWorkOrder.setInsuser(cu.getId());
|
||||
emergencyConfigureWorkOrder.setWorksenduser(cu.getId());
|
||||
emergencyConfigureWorkOrder.setWorksenddt(CommUtil.nowDate());
|
||||
emergencyConfigureWorkOrder.setStatus(0);
|
||||
emergencyConfigureWorkOrder.setNodeid(id);
|
||||
emergencyConfigureWorkOrder.setWorkreceiveuser(workreceiveuser);
|
||||
emergencyConfigureWorkOrder.setWorkcontent(workcontent);
|
||||
int result = this.emergencyConfigureWorkOrderService.save(emergencyConfigureWorkOrder);
|
||||
// model.addAttribute("result","{\"res\":\""+result+"\",\"id\":\"\"}");
|
||||
model.addAttribute("result",result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
// @RequestMapping("/doedit.do")
|
||||
// public String doedit(HttpServletRequest request,Model model){
|
||||
// String id = request.getParameter("id");
|
||||
// System.out.println(id);
|
||||
// List<EmergencyConfigureWorkOrder> emergencyConfigureWorkOrder= emergencyConfigureWorkOrderService
|
||||
// .selectworkorderrecordslistByWhere("where m.id='"+id+"'");
|
||||
// request.setAttribute("_workreceiveuser", emergencyConfigureWorkOrder.get(0).get_workreceiveuser());
|
||||
// request.setAttribute("workcontent", emergencyConfigureWorkOrder.get(0).getWorkcontent());
|
||||
//
|
||||
// return "command/emergencyConfigureWorkOrderEdit";
|
||||
// }
|
||||
|
||||
@RequestMapping("/doworkedit.do")
|
||||
public String doworkedit(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id){
|
||||
request.setAttribute("id", id);
|
||||
//System.out.println(id);
|
||||
List<EmergencyConfigureWorkOrder> emergencyConfigureWorkOrder= this.emergencyConfigureWorkOrderService
|
||||
.selectworkorderrecordslistByWhere("where m.id='"+id+"'");
|
||||
// request.setAttribute("_workreceiveuser", emergencyConfigureWorkOrder.get(0).get_workreceiveuser());
|
||||
// request.setAttribute("workcontent", emergencyConfigureWorkOrder.get(0).getWorkcontent());
|
||||
model.addAttribute("emergencyConfigureWorkOrder",emergencyConfigureWorkOrder.get(0));
|
||||
return "command/emergencyConfigureWorkOrderEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/doworkdelete.do")
|
||||
public String doworkdelete(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="id") String id){
|
||||
|
||||
String msg = "";
|
||||
int result = 0;
|
||||
//System.out.println("del_id:::"+id);
|
||||
List<EmergencyConfigureWorkOrder> mlist = this.emergencyConfigureWorkOrderService.selectListByWhere(" where id = '"+id+"'");
|
||||
if(mlist!=null && mlist.size()>0){
|
||||
result = this.emergencyConfigureWorkOrderService.delete(id);
|
||||
}else{
|
||||
msg="删除失败";
|
||||
}
|
||||
model.addAttribute("result","{\"res\":\""+result+"\",\"msg\":\""+msg+"\"}");
|
||||
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doworkupdate.do")
|
||||
public String doworkupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute EmergencyConfigureWorkOrder emergencyConfigureWorkOrder){
|
||||
int result = this.emergencyConfigureWorkOrderService.update(emergencyConfigureWorkOrder);
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,226 @@
|
||||
package com.sipai.controller.command;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.command.EmergencyConfigure;
|
||||
import com.sipai.entity.command.EmergencyPlan;
|
||||
import com.sipai.entity.command.EmergencyRecords;
|
||||
import com.sipai.entity.user.Unit;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.command.EmergencyConfigureService;
|
||||
import com.sipai.service.command.EmergencyPlanService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
import net.sf.json.JSONArray;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
* @Auther: 你的名字
|
||||
* @Date: 2021/10/23/10:31
|
||||
* @Description:
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/command/emergencyPlan")
|
||||
public class EmergencyPlanController {
|
||||
@Resource
|
||||
private EmergencyPlanService emergencyPlanService;
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
@Resource
|
||||
private EmergencyConfigureService emergencyConfigureService;
|
||||
|
||||
@RequestMapping("/showList.do")
|
||||
public String showList(HttpServletRequest request, Model model) {
|
||||
return "command/emergencyPlanList";
|
||||
}
|
||||
|
||||
@RequestMapping("/getList.do")
|
||||
public ModelAndView getList(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required = false) String sort,
|
||||
@RequestParam(value = "order", required = false) String order) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String companyId = request.getParameter("companyId");
|
||||
String pSectionId = request.getParameter("pSectionId");
|
||||
String ids = request.getParameter("ids");
|
||||
if (sort == null) {
|
||||
sort = " plan_date ";
|
||||
}
|
||||
if (order == null) {
|
||||
order = " desc ";
|
||||
}
|
||||
String orderstr = " order by " + sort + " " + order;
|
||||
|
||||
String wherestr = "where 1=1";
|
||||
if (companyId != null && !companyId.isEmpty()) {
|
||||
//获取公司下所有子节点
|
||||
List<Unit> units = unitService.getUnitChildrenById(companyId);
|
||||
String companyids = "";
|
||||
for (Unit unit : units) {
|
||||
companyids += "'" + unit.getId() + "',";
|
||||
}
|
||||
if (companyids != "") {
|
||||
companyids = companyids.substring(0, companyids.length() - 1);
|
||||
wherestr += " and biz_id in (" + companyids + ") ";
|
||||
}
|
||||
}
|
||||
if (pSectionId != null && !pSectionId.isEmpty()) {
|
||||
wherestr += " and process_section_id = '" + pSectionId + "' ";
|
||||
}
|
||||
if (ids != null && !ids.isEmpty()) {
|
||||
ids = ids.replace(",", "','");
|
||||
wherestr += " and id in ('" + ids + "')";
|
||||
}
|
||||
if (request.getParameter("search_name") != null && !request.getParameter("search_name").isEmpty()) {
|
||||
String wherestrConfigure = " where name like '%" + request.getParameter("search_name") + "%' order by id";
|
||||
List<EmergencyConfigure> emergencyConfigures = emergencyConfigureService.selectListByWhere(wherestrConfigure);
|
||||
String emergencyConfigureIDS = "";
|
||||
if(emergencyConfigures!=null && emergencyConfigures.size()>0){
|
||||
for(EmergencyConfigure emergencyConfigure : emergencyConfigures){
|
||||
emergencyConfigureIDS += emergencyConfigure.getId()+",";
|
||||
}
|
||||
emergencyConfigureIDS = emergencyConfigureIDS.replace(",", "','");
|
||||
}
|
||||
wherestr += " and emergency_configure_id in ('" + emergencyConfigureIDS + "') ";
|
||||
}
|
||||
if (request.getParameter("statusSelect") != null && !request.getParameter("statusSelect").isEmpty()) {
|
||||
wherestr += " and status = '" + request.getParameter("statusSelect") + "'";
|
||||
}
|
||||
if (request.getParameter("sdt") != null && !request.getParameter("sdt").isEmpty()) {
|
||||
wherestr += " and plan_date >= '" + request.getParameter("sdt") + "'";
|
||||
}
|
||||
if (request.getParameter("edt") != null && !request.getParameter("edt").isEmpty()) {
|
||||
wherestr += " and plan_date <= '" + request.getParameter("edt") + "'";
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<EmergencyPlan> list = this.emergencyPlanService.selectListByWhere(wherestr + orderstr);
|
||||
PageInfo<EmergencyPlan> pi = new PageInfo<EmergencyPlan>(list);
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
|
||||
String result = "{\"total\":" + pi.getTotal() + ",\"rows\":" + json + "}";
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增选择 应急配置页面
|
||||
*/
|
||||
@RequestMapping("/doadd.do")
|
||||
public String doadd(HttpServletRequest request, Model model) {
|
||||
return "command/emergencyPlanAdd";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param request
|
||||
* @param model
|
||||
* @param emergencyPlan
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/dosave.do")
|
||||
public String dosave(HttpServletRequest request, Model model,
|
||||
@ModelAttribute("emergencyPlan") EmergencyPlan emergencyPlan) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
|
||||
Result result = Result.success(null);
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除多条数据
|
||||
*/
|
||||
@RequestMapping("/dodeletes.do")
|
||||
public String dodels(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "ids") String ids) {
|
||||
ids = ids.replace(",", "','");
|
||||
int result = this.emergencyPlanService.deleteByWhere("where id in ('" + ids + "')");
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看信息
|
||||
*/
|
||||
@RequestMapping("/doview.do")
|
||||
public String doview(HttpServletRequest request, Model model) {
|
||||
String id = request.getParameter("id");
|
||||
EmergencyConfigure emergencyConfigure = this.emergencyConfigureService.getMenuById(id);
|
||||
model.addAttribute("emergencyConfigure", emergencyConfigure);
|
||||
return "command/emergencyConfigureView4Plan";
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增选择 应急配置页面
|
||||
*/
|
||||
@RequestMapping("/showConfigure.do")
|
||||
public String showConfigure(HttpServletRequest request, Model model) {
|
||||
return "command/emergencyConfigureList4Plan";
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存应急
|
||||
*
|
||||
* @param request
|
||||
* @param model
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/doChoice.do")
|
||||
public String doChoice(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "checkedIds") String checkedIds,
|
||||
@RequestParam(value = "unitId") String unitId) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
|
||||
int res = emergencyPlanService.doChoice(checkedIds, unitId, cu);
|
||||
|
||||
Result result = Result.success(null);
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 下发
|
||||
*
|
||||
* @param request
|
||||
* @param model
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/dodown.do")
|
||||
public String dodown(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "ids") String ids) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
//计划内
|
||||
int res = emergencyPlanService.dodown(ids, cu, EmergencyRecords.Inside);
|
||||
|
||||
Result result = Result.success(res);
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
/*@RequestMapping("/doedit.do")
|
||||
public String doedit(HttpServletRequest request, Model model) {
|
||||
String id = request.getParameter("id");
|
||||
EmergencyConfigure emergencyConfigure = this.emergencyConfigureService.getMenuById(id);
|
||||
model.addAttribute("emergencyConfigure", emergencyConfigure);
|
||||
return "command/emergencyPlanEdit";
|
||||
}*/
|
||||
|
||||
}
|
||||
@ -0,0 +1,865 @@
|
||||
package com.sipai.controller.command;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.command.EmergencyConfigure;
|
||||
import com.sipai.entity.command.EmergencyRecords;
|
||||
import com.sipai.entity.command.EmergencyRecordsDetail;
|
||||
import com.sipai.entity.maintenance.Maintenance;
|
||||
import com.sipai.entity.user.Company;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.command.*;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.service.user.UserService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/command/emergencyRecords")
|
||||
public class EmergencyRecordsController {
|
||||
|
||||
@Resource
|
||||
private EmergencyRecordsService emergencyRecordsService;
|
||||
@Resource
|
||||
private EmergencyConfigureService emergencyConfigureService;
|
||||
@Resource
|
||||
private EmergencyConfigurefileService emergencyConfigurefileService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
@Resource
|
||||
private EmergencyRecordsDetailService emergencyRecordsDetailService;
|
||||
@Resource
|
||||
private EmergencyPlanService emergencyPlanService;
|
||||
|
||||
/*
|
||||
* 应急预案演练(过程)
|
||||
*/
|
||||
@RequestMapping("/showlistDrill.do")
|
||||
public String showlistDrill(HttpServletRequest request, Model model) {
|
||||
return "command/emergencyRecordslistDrill";
|
||||
}
|
||||
|
||||
/*
|
||||
* 应急预案演练(浏览)
|
||||
*/
|
||||
@RequestMapping("/showlistView.do")
|
||||
public String showlistView(HttpServletRequest request, Model model) {
|
||||
return "command/emergencyRecordslistView";
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取应急预案演练(记录)
|
||||
*/
|
||||
@RequestMapping("/getList.do")
|
||||
public ModelAndView getList(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required = false) String sort,
|
||||
@RequestParam(value = "order", required = false) String order) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
if (sort == null || sort.equals("id")) {
|
||||
sort = " insdt ";
|
||||
}
|
||||
if (order == null) {
|
||||
order = " desc ";
|
||||
}
|
||||
String orderstr = " order by starttime desc";
|
||||
String wherestr = "where 1=1 ";
|
||||
String unitId = request.getParameter("unitId");
|
||||
String status = request.getParameter("status");
|
||||
|
||||
if (unitId != null && !unitId.equals("")) {
|
||||
wherestr += " and bizid = '" + unitId + "'";
|
||||
}
|
||||
if (status != null && !status.equals("")) {
|
||||
wherestr += " and status = '" + status + "'";
|
||||
}
|
||||
String statusPlan = request.getParameter("statusPlan");
|
||||
if (statusPlan != null && !statusPlan.equals("")) {
|
||||
wherestr += " and status_plan = '" + statusPlan + "'";
|
||||
}
|
||||
String search_name = request.getParameter("search_name");
|
||||
if (search_name != null && !search_name.equals("")) {
|
||||
wherestr += " and name like '%" + search_name + "%'";
|
||||
}
|
||||
if (request.getParameter("sdt") != null && !request.getParameter("sdt").isEmpty()) {
|
||||
wherestr += " and starttime >= '" + request.getParameter("sdt") + "'";
|
||||
}
|
||||
if (request.getParameter("edt") != null && !request.getParameter("edt").isEmpty()) {
|
||||
wherestr += " and starttime <= '" + request.getParameter("edt") + "'";
|
||||
}
|
||||
|
||||
PageHelper.startPage(page, rows);
|
||||
List<EmergencyRecords> list = this.emergencyRecordsService.selectListByWhere(wherestr + orderstr);
|
||||
|
||||
PageInfo<EmergencyRecords> pi = new PageInfo<EmergencyRecords>(list);
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
|
||||
String result = "{\"total\":" + pi.getTotal() + ",\"rows\":" + json + "}";
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增异常事件启动
|
||||
*
|
||||
* @param request
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/add.do")
|
||||
public String add(HttpServletRequest request, Model model) {
|
||||
request.setAttribute("id", CommUtil.getUUID());
|
||||
model.addAttribute("nowdate", CommUtil.nowDate());
|
||||
return "/command/emergencyRecordsadd";
|
||||
}
|
||||
|
||||
@RequestMapping("/dostartsave.do")
|
||||
public String dostartsave(HttpServletRequest request, Model model
|
||||
) {
|
||||
EmergencyRecords emergencyRecords = new EmergencyRecords();
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String id = request.getParameter("id");
|
||||
List<EmergencyConfigure> emergencyConfigure = this.emergencyConfigureService.selectListByWhere("where id='" + id + "'");
|
||||
if (emergencyConfigure.size() != 0) {
|
||||
String bizid = emergencyConfigure.get(0).getBizid();
|
||||
Company company = this.unitService.getCompById(bizid);
|
||||
String emergencyRecordsid = company.getEname()+"-YAYL-"+CommUtil.nowDate().replaceAll("[[\\s-:punct:]]","");
|
||||
emergencyRecords.setId(emergencyRecordsid);
|
||||
emergencyRecords.setInsdt(CommUtil.nowDate());
|
||||
emergencyRecords.setInsuser(cu.getId());
|
||||
emergencyRecords.setBizid(bizid);
|
||||
emergencyRecords.setStatus("0");
|
||||
emergencyRecords.setGrade(emergencyConfigure.get(0).getGrade());
|
||||
emergencyRecords.setStarter(cu.getId());//启动人
|
||||
|
||||
List<EmergencyConfigure> emergencyConfigure2 = this.emergencyConfigureService.selectListByWhere("where id='" + emergencyConfigure.get(0).getPid() + "'");
|
||||
if (emergencyConfigure2.size() != 0) {
|
||||
emergencyRecords.setFirstmenu(emergencyConfigure2.get(0).getPid());
|
||||
} else {
|
||||
emergencyRecords.setFirstmenu(null);
|
||||
}
|
||||
emergencyRecords.setSecondmenu(emergencyConfigure.get(0).getPid());
|
||||
emergencyRecords.setThirdmenu(emergencyConfigure.get(0).getId());
|
||||
emergencyRecords.setFirstperson(emergencyConfigure.get(0).getFirstpersonid());
|
||||
emergencyRecords.setType(0);
|
||||
emergencyRecords.setName(emergencyConfigure.get(0).getName());
|
||||
}
|
||||
|
||||
|
||||
int result = this.emergencyRecordsService.save(emergencyRecords);
|
||||
// model.addAttribute("result","{\"res\":\""+result+"\",\"id\":\"\"}");
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
/*
|
||||
* 应急预案演练记录列表数据查询
|
||||
*/
|
||||
@RequestMapping("/showlistedit.do")
|
||||
public ModelAndView showlistedit(HttpServletRequest request, Model model) {
|
||||
String scope = "";
|
||||
String bizid = request.getParameter("bizid");
|
||||
//获取查询时间
|
||||
if (request.getParameter("sdt") != null
|
||||
&& request.getParameter("sdt").trim().length() > 0) {
|
||||
scope += " and m.starttime>='"
|
||||
+ request.getParameter("sdt").substring(0, 10)
|
||||
+ " 00:00:00" + "' ";
|
||||
}
|
||||
if (request.getParameter("edt") != null
|
||||
&& request.getParameter("edt").trim().length() > 0) {
|
||||
scope += " and m.starttime<='"
|
||||
+ request.getParameter("edt").substring(0, 10)
|
||||
+ " 23:59:59" + "' ";
|
||||
}
|
||||
List<EmergencyRecords> ia = this.emergencyRecordsService
|
||||
.selectrecordslistByWhere(" where 1=1 and (m.status='0' or m.status='5' or m.status='10') and m.type='0' and m.bizid='" + bizid + "' " + scope + " order by m.insdt desc");
|
||||
System.out.println("scpoe::" + scope);
|
||||
JSONArray json = JSONArray.fromObject(ia);
|
||||
String result = "{\"total\":" + ia.size() + ",\"rows\":" + json + "}";
|
||||
System.out.println("result::" + result);
|
||||
|
||||
model.addAttribute("result", result);
|
||||
|
||||
return new ModelAndView("result");
|
||||
//return "result";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/getRecords.do")
|
||||
public ModelAndView getRecords(HttpServletRequest request, Model model) {
|
||||
|
||||
String result = "";
|
||||
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 厂区异常事件启动tab清单
|
||||
*/
|
||||
@RequestMapping("/showSubListByStatus.do")
|
||||
public String showSubListByStatus(HttpServletRequest request, Model model) {
|
||||
String st = request.getParameter("st");
|
||||
String bizid = request.getParameter("bizid");
|
||||
String result = "";
|
||||
switch (st) {
|
||||
case "0"://预案启动
|
||||
result = "/command/maintenanceSubList_Start";
|
||||
break;
|
||||
case "1"://预案执行
|
||||
result = "/command/maintenanceSubList_Execute";
|
||||
break;
|
||||
case "2"://预案结束
|
||||
result = "/command/maintenanceSubList_Finish";
|
||||
break;
|
||||
/*case "3"://维护中
|
||||
result="/maintenance/maintenanceSubList_Handle";
|
||||
break;
|
||||
case "4"://已完成
|
||||
result="/maintenance/maintenanceSubList_Finish";
|
||||
break;*/
|
||||
default:
|
||||
break;
|
||||
}
|
||||
System.out.println("bizid::" + bizid);
|
||||
System.out.println("st::" + st);
|
||||
request.setAttribute("bizid", bizid);
|
||||
request.setAttribute("staut", st);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加发起问题
|
||||
*/
|
||||
@RequestMapping("/addProblem.do")
|
||||
public String addProblem(HttpServletRequest request, Model model) {
|
||||
request.setAttribute("id", CommUtil.getUUID());
|
||||
return "command/unusualLaunchAdd";
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存发起任务
|
||||
*/
|
||||
@RequestMapping("/saveLaunch.do")
|
||||
public String saveLaunch(HttpServletRequest request, Model model,
|
||||
@ModelAttribute("emergencyRecords") EmergencyRecords emergencyRecords) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
emergencyRecords.setInsuser(cu.getId());
|
||||
emergencyRecords.setInsdt(CommUtil.nowDate());
|
||||
emergencyRecords.setStatus("未启动");
|
||||
System.out.println("bizid:::" + emergencyRecords.getBizid());
|
||||
//emergencyRecords.setType(emergencyRecords.TYPE_MAINTENANCE);
|
||||
int result = this.emergencyRecordsService.save(emergencyRecords);
|
||||
String resstr = "{\"res\":\"" + result + "\",\"id\":\"" + emergencyRecords.getId() + "\"}";
|
||||
model.addAttribute("result", resstr);
|
||||
return "result";
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新任务
|
||||
*/
|
||||
@RequestMapping("/showFuncEdit.do")
|
||||
public String doFuncEdit(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
EmergencyRecords emergencyRecords = emergencyRecordsService.getMenuById(id);
|
||||
model.addAttribute("emergencyRecords", emergencyRecords);
|
||||
|
||||
return "command/menuFuncEdit_records";
|
||||
}
|
||||
|
||||
@RequestMapping("/updateFunc.do")
|
||||
public String doupdateFunc(HttpServletRequest request, Model model,
|
||||
@ModelAttribute EmergencyRecords emergencyRecords,
|
||||
@RequestParam(value = "id") String id) {
|
||||
System.out.println("idid::" + emergencyRecords.getId());
|
||||
System.out.println("ididid::" + id);
|
||||
int result = this.emergencyRecordsService.updateMenu(emergencyRecords);
|
||||
|
||||
model.addAttribute("result", "{\"res\":\"" + result + "\",\"id\":\"" + emergencyRecords.getId() + "\"}");
|
||||
return "result";
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除任务
|
||||
*/
|
||||
@RequestMapping("/deleteMenu.do")
|
||||
public String dodel(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
String msg = "";
|
||||
int result = 0;
|
||||
System.out.println("del_id:::" + id);
|
||||
List<EmergencyRecords> mlist = this.emergencyRecordsService.selectListByWhere(" where id = '" + id + "'");
|
||||
if (mlist != null && mlist.size() > 0) {
|
||||
result = this.emergencyRecordsService.deleteMenuById(id);
|
||||
} else {
|
||||
msg = "删除失败";
|
||||
}
|
||||
model.addAttribute("result", "{\"res\":\"" + result + "\",\"msg\":\"" + msg + "\"}");
|
||||
|
||||
return "result";
|
||||
}
|
||||
|
||||
/**
|
||||
* start页面显示
|
||||
*/
|
||||
@RequestMapping("/getSubListByStatus.do")
|
||||
public ModelAndView getSubListByStatus(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required = false) String sort,
|
||||
@RequestParam(value = "order", required = false) String order) {
|
||||
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
if (sort == null || sort.equals("id")) {
|
||||
sort = " insdt ";
|
||||
}
|
||||
if (order == null) {
|
||||
order = " desc ";
|
||||
}
|
||||
String orderstr = " order by " + sort + " " + order;
|
||||
|
||||
String wherestr = "where 1=1 ";
|
||||
String companyid = request.getParameter("search_code");
|
||||
String status = request.getParameter("status");
|
||||
|
||||
switch (status) {
|
||||
case "0"://启动
|
||||
wherestr += "and status='未启动' and bizid='" + companyid + "'";
|
||||
break;
|
||||
case "1"://执行
|
||||
wherestr = CommUtil.getwherestr("companyid", "", cu);
|
||||
wherestr += " and status in ('" + Maintenance.Status_Submit_Problem + "' ,'" + Maintenance.Status_Confirm_Maintainer + "','" + Maintenance.Status_Submit_Maintainer +
|
||||
"','" + Maintenance.Status_CancelTOMaintainer + "')";
|
||||
break;
|
||||
case "2"://结束
|
||||
wherestr = CommUtil.getwherestr("maintainerId", null, cu);
|
||||
wherestr += " and status in ('" + Maintenance.Status_Submit_Problem + "' )";
|
||||
break;
|
||||
case "3"://维护商维护中
|
||||
wherestr = CommUtil.getwherestr("maintainerId", null, cu);
|
||||
wherestr += " and status in ('" + Maintenance.Status_Confirm_Maintainer + "','" + Maintenance.Status_Submit_Maintainer + "','" + Maintenance.Status_CancelTOMaintainer + "','" + Maintenance.Status_Supplementing + "' )";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
List<EmergencyRecords> list = this.emergencyRecordsService.selectListByWhere(wherestr);
|
||||
|
||||
PageInfo<EmergencyRecords> pi = new PageInfo<EmergencyRecords>(list);
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
System.out.println("total:::" + pi.getTotal());
|
||||
String result = "{\"total\":" + pi.getTotal() + ",\"rows\":" + json + "}";
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 应急预案演练记录列表数据查询
|
||||
*/
|
||||
@RequestMapping("/showlistDrilledit.do")
|
||||
public ModelAndView showlistDrilledit(HttpServletRequest request, Model model) {
|
||||
String scope = "";
|
||||
String bizid = request.getParameter("bizid");
|
||||
//获取查询时间
|
||||
if (request.getParameter("sdt") != null
|
||||
&& request.getParameter("sdt").trim().length() > 0) {
|
||||
scope += " and m.starttime>='"
|
||||
+ request.getParameter("sdt").substring(0, 10)
|
||||
+ " 00:00:00" + "' ";
|
||||
}
|
||||
if (request.getParameter("edt") != null
|
||||
&& request.getParameter("edt").trim().length() > 0) {
|
||||
scope += " and m.starttime<='"
|
||||
+ request.getParameter("edt").substring(0, 10)
|
||||
+ " 23:59:59" + "' ";
|
||||
}
|
||||
List<EmergencyRecords> ia = this.emergencyRecordsService
|
||||
.selectrecordslistByWhere(" where 1=1 and (m.status='0' or m.status='5') and m.type='1' and m.bizid='" + bizid + "' " + scope + " order by m.insdt desc");
|
||||
System.out.println("scpoe::" + scope);
|
||||
JSONArray json = JSONArray.fromObject(ia);
|
||||
String result = "{\"total\":" + ia.size() + ",\"rows\":" + json + "}";
|
||||
System.out.println("result::" + result);
|
||||
|
||||
model.addAttribute("result", result);
|
||||
|
||||
return new ModelAndView("result");
|
||||
//return "result";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除任务
|
||||
*/
|
||||
@RequestMapping("/dodeletes.do")
|
||||
public String dodeletes(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "ids") String ids) {
|
||||
String[] idslist = ids.split(",");
|
||||
int result = 0;
|
||||
for (int i = 0; i < idslist.length; i++) {
|
||||
|
||||
EmergencyRecords emergencyRecords = this.emergencyRecordsService.getMenuById(idslist[i]);
|
||||
if (emergencyRecords != null) {
|
||||
emergencyRecords.setType(2);
|
||||
result = this.emergencyRecordsService.updateMenu(emergencyRecords);
|
||||
}
|
||||
}
|
||||
model.addAttribute("result", result);
|
||||
return "result";
|
||||
}
|
||||
|
||||
/***
|
||||
* 获取应急预案演练详细数据(记录)
|
||||
* @param request
|
||||
* @param model
|
||||
* @param id 演练id或者报警点
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/dodrillview.do")
|
||||
public String dodrillview(HttpServletRequest request, Model model) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String id = request.getParameter("id");
|
||||
List<EmergencyRecords> emergencyRecords = emergencyRecordsService.selectrecordslistByWhere("where m.id='" + id + "' or m.mpointcodes='" + id + "' ");
|
||||
if (emergencyRecords != null) {
|
||||
id = emergencyRecords.get(0).getId();
|
||||
request.setAttribute("emergencyRecords", emergencyRecords.get(0));//演练
|
||||
request.setAttribute("titleName", emergencyRecords.get(0).getName());
|
||||
request.setAttribute("_starter", emergencyRecords.get(0).get_starter());
|
||||
if (emergencyRecords.get(0).getFirstperson() != null) {
|
||||
User user = userService.getUserById(emergencyRecords.get(0).getFirstperson());
|
||||
if (user != null) {
|
||||
request.setAttribute("_firstPerson", user.getCaption() + "(总负责人)");
|
||||
}
|
||||
}
|
||||
|
||||
//获得自身属性
|
||||
String emergencyConfigureSql = "select m.*,u.caption as _firstPerson "
|
||||
+ "from tb_Repair_EmergencyConfigure m "
|
||||
+ "left outer join tb_user u on u.id=m.firstPerson "
|
||||
+ "where m.id='" + emergencyRecords.get(0).getThirdmenu() + "' ";
|
||||
EmergencyConfigure emergencyConfigure = emergencyConfigureService.getMenuById(emergencyRecords.get(0).getThirdmenu());
|
||||
if (emergencyConfigure != null) {
|
||||
request.setAttribute("emergencyConfigure", emergencyConfigure);//配置
|
||||
request.setAttribute("emergencyConfigureID", emergencyConfigure.getId());//ID
|
||||
request.setAttribute("firstPerson", emergencyConfigure.getFirstperson());//总负责人
|
||||
/*//如果字数太多则截取部分文字,鼠标悬浮显示全部。
|
||||
if (emergencyConfigure.getMemo() != null && emergencyConfigure.getMemo().length() >= 82) {
|
||||
request.setAttribute("memo", emergencyConfigure.getMemo().substring(0, 80) + "...");//总体介绍_可能被截取
|
||||
request.setAttribute("memo_title", emergencyConfigure.getMemo());//总体介绍_全部内容
|
||||
}
|
||||
if (emergencyConfigure.getMemo() != null && emergencyConfigure.getMemo().length() < 80) {
|
||||
}*/
|
||||
request.setAttribute("memo", emergencyConfigure.getMemo());//总体介绍_可能被截取
|
||||
request.setAttribute("memo_title", emergencyConfigure.getMemo());//总体介绍_全部内容
|
||||
if (emergencyConfigure.getStartingcondition() != null && emergencyConfigure.getStartingcondition().length() >= 82) {
|
||||
request.setAttribute("startingCondition", emergencyConfigure.getStartingcondition().substring(0, 80) + "...");//启动条件_可能被截取
|
||||
request.setAttribute("startingCondition_title", emergencyConfigure.getStartingcondition());//启动条件_标题显示的全部内容
|
||||
}
|
||||
if (emergencyConfigure.getStartingcondition() != null && emergencyConfigure.getStartingcondition().length() < 82) {
|
||||
request.setAttribute("startingCondition", emergencyConfigure.getStartingcondition());//启动条件_可能被截取
|
||||
request.setAttribute("startingCondition_title", emergencyConfigure.getStartingcondition());//启动条件_标题显示的全部内容
|
||||
}
|
||||
|
||||
}
|
||||
//获取每个配置图片的路径
|
||||
// List<EmergencyConfigurefile> rs = this.emergencyConfigurefileService.selectListByWhere("where masterid='" + emergencyRecords.get(0).getThirdmenu() + "video' order by insdt desc");
|
||||
// if (rs != null && rs.size() > 0) {
|
||||
// request.setAttribute("abspath", rs.get(0).getAbspath());//图片路径
|
||||
// }
|
||||
//查询步骤
|
||||
List<EmergencyRecordsDetail> steplist = emergencyRecordsDetailService.selectListByWhere(
|
||||
"where pid='"+id+"' and id like '%"+"-"+EmergencyConfigure.Type_Step+"%' order by ord ");
|
||||
JSONArray stepArray = new JSONArray();
|
||||
if(steplist!=null && steplist.size()>0){
|
||||
stepArray = JSONArray.fromObject(steplist);
|
||||
}
|
||||
request.setAttribute("stepArray", stepArray);//步骤
|
||||
|
||||
JSONObject object = selectDetail(id);
|
||||
JSONArray jsonArray = (JSONArray) object.get("jsonArray");
|
||||
int end_y = (int) object.get("end_y");
|
||||
request.setAttribute("end_y", end_y);
|
||||
request.setAttribute("jsonArray", jsonArray);//矩形框json
|
||||
|
||||
String ids0 = object.getString("ids0");//未演练的ids
|
||||
String ids1 = object.getString("ids1");//执行中的ids
|
||||
String ids2 = object.getString("ids2");//已演练的ids
|
||||
String ids3 = object.getString("ids3");//已关闭的ids
|
||||
|
||||
request.setAttribute("ids0", ids0);//未演练的ids
|
||||
request.setAttribute("ids1", ids1);//正在演练的ids
|
||||
request.setAttribute("ids2", ids2);//已演练的ids
|
||||
request.setAttribute("ids3", ids3);//已关闭的ids
|
||||
}
|
||||
|
||||
return "command/processEmergencyConfigureDrill";
|
||||
}
|
||||
/***
|
||||
* 获取应急预案演练详细数据(记录) -LogicFlow流程图
|
||||
* @param request
|
||||
* @param model
|
||||
* @param id 演练id或者报警点
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/dodrillviewLF.do")
|
||||
public String dodrillviewLF(HttpServletRequest request, Model model) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String id = request.getParameter("id");
|
||||
List<EmergencyRecords> emergencyRecords = emergencyRecordsService.selectrecordslistByWhere("where m.id='" + id + "' or m.mpointcodes='" + id + "' ");
|
||||
if (emergencyRecords != null) {
|
||||
id = emergencyRecords.get(0).getId();
|
||||
request.setAttribute("emergencyRecords", emergencyRecords.get(0));//演练
|
||||
request.setAttribute("titleName", emergencyRecords.get(0).getName());
|
||||
request.setAttribute("_starter", emergencyRecords.get(0).get_starter());
|
||||
if (emergencyRecords.get(0).getFirstperson() != null) {
|
||||
User user = userService.getUserById(emergencyRecords.get(0).getFirstperson());
|
||||
if (user != null) {
|
||||
request.setAttribute("_firstPerson", user.getCaption() + "(总负责人)");
|
||||
}
|
||||
}
|
||||
|
||||
//获得自身属性
|
||||
String emergencyConfigureSql = "select m.*,u.caption as _firstPerson "
|
||||
+ "from tb_Repair_EmergencyConfigure m "
|
||||
+ "left outer join tb_user u on u.id=m.firstPerson "
|
||||
+ "where m.id='" + emergencyRecords.get(0).getThirdmenu() + "' ";
|
||||
EmergencyConfigure emergencyConfigure = emergencyConfigureService.getMenuById(emergencyRecords.get(0).getThirdmenu());
|
||||
if (emergencyConfigure != null) {
|
||||
request.setAttribute("emergencyConfigure", emergencyConfigure);//配置
|
||||
request.setAttribute("emergencyConfigureID", emergencyConfigure.getId());//ID
|
||||
request.setAttribute("firstPerson", emergencyConfigure.getFirstperson());//总负责人
|
||||
/*//如果字数太多则截取部分文字,鼠标悬浮显示全部。
|
||||
if (emergencyConfigure.getMemo() != null && emergencyConfigure.getMemo().length() >= 82) {
|
||||
request.setAttribute("memo", emergencyConfigure.getMemo().substring(0, 80) + "...");//总体介绍_可能被截取
|
||||
request.setAttribute("memo_title", emergencyConfigure.getMemo());//总体介绍_全部内容
|
||||
}
|
||||
if (emergencyConfigure.getMemo() != null && emergencyConfigure.getMemo().length() < 80) {
|
||||
}*/
|
||||
request.setAttribute("memo", emergencyConfigure.getMemo());//总体介绍_可能被截取
|
||||
request.setAttribute("memo_title", emergencyConfigure.getMemo());//总体介绍_全部内容
|
||||
if (emergencyConfigure.getStartingcondition() != null && emergencyConfigure.getStartingcondition().length() >= 82) {
|
||||
request.setAttribute("startingCondition", emergencyConfigure.getStartingcondition().substring(0, 80) + "...");//启动条件_可能被截取
|
||||
request.setAttribute("startingCondition_title", emergencyConfigure.getStartingcondition());//启动条件_标题显示的全部内容
|
||||
}
|
||||
if (emergencyConfigure.getStartingcondition() != null && emergencyConfigure.getStartingcondition().length() < 82) {
|
||||
request.setAttribute("startingCondition", emergencyConfigure.getStartingcondition());//启动条件_可能被截取
|
||||
request.setAttribute("startingCondition_title", emergencyConfigure.getStartingcondition());//启动条件_标题显示的全部内容
|
||||
}
|
||||
|
||||
}
|
||||
//获取每个配置图片的路径
|
||||
// List<EmergencyConfigurefile> rs = this.emergencyConfigurefileService.selectListByWhere("where masterid='" + emergencyRecords.get(0).getThirdmenu() + "video' order by insdt desc");
|
||||
// if (rs != null && rs.size() > 0) {
|
||||
// request.setAttribute("abspath", rs.get(0).getAbspath());//图片路径
|
||||
// }
|
||||
//查询步骤
|
||||
List<EmergencyRecordsDetail> steplist = emergencyRecordsDetailService.selectListByWhere(
|
||||
"where pid='"+id+"' and id like '%"+"-"+EmergencyConfigure.Type_Step+"%' order by ord ");
|
||||
JSONArray stepArray = new JSONArray();
|
||||
if(steplist!=null && steplist.size()>0){
|
||||
stepArray = JSONArray.fromObject(steplist);
|
||||
}
|
||||
request.setAttribute("stepArray", stepArray);//步骤
|
||||
|
||||
JSONObject object = selectDetail(id);
|
||||
JSONArray jsonArray = (JSONArray) object.get("jsonArray");
|
||||
int end_y = (int) object.get("end_y");
|
||||
request.setAttribute("end_y", end_y);
|
||||
request.setAttribute("jsonArray", jsonArray);//矩形框json
|
||||
|
||||
String ids0 = object.getString("ids0");//未演练的ids
|
||||
String ids1 = object.getString("ids1");//执行中的ids
|
||||
String ids2 = object.getString("ids2");//已演练的ids
|
||||
String ids3 = object.getString("ids3");//已关闭的ids
|
||||
|
||||
request.setAttribute("ids0", ids0);//未演练的ids
|
||||
request.setAttribute("ids1", ids1);//正在演练的ids
|
||||
request.setAttribute("ids2", ids2);//已演练的ids
|
||||
request.setAttribute("ids3", ids3);//已关闭的ids
|
||||
}
|
||||
|
||||
return "command/processEmergencyConfigureDrillLF";
|
||||
}
|
||||
|
||||
public JSONObject selectDetail(String id){
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
//查询有多少层级
|
||||
List<EmergencyRecordsDetail> rs = this.emergencyRecordsDetailService
|
||||
.selectrankListByWhere("where pid='" + id + "' group by rank order by rank ");
|
||||
int y = 0;
|
||||
if (rs != null && rs.size() > 0) {
|
||||
//循环层级
|
||||
for (int i = 0; i < rs.size(); i++) {
|
||||
y += 100;
|
||||
int x = 0;
|
||||
if(rs.get(i)!=null && rs.get(i).getRank()!=null){
|
||||
if (i == 0) {
|
||||
List<EmergencyRecordsDetail> rs2 = this.emergencyRecordsDetailService
|
||||
.selectListByWhere("where pid='" + id + "' and rank='" + rs.get(i).getRank() + "' order by ord");
|
||||
if (rs2 != null && rs2.size() > 0) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("id", rs2.get(0).getId());
|
||||
jsonObject.put("contents", rs2.get(0).getContents());
|
||||
jsonObject.put("status", rs2.get(0).getStatus());
|
||||
jsonObject.put("contents_x", x);
|
||||
jsonObject.put("contents_y", y);
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
} else {
|
||||
List<EmergencyRecordsDetail> rs2 = this.emergencyRecordsDetailService
|
||||
.selectcontentListByWhere("where m.pid='" + id + "' and d.pid='" + id + "' and m.rank='" + rs.get(i).getRank() + "' order by m.ord");
|
||||
if (rs2 != null && rs2.size() > 0) {
|
||||
//循环相同层级中的节点数
|
||||
for (int j = 0; j < rs2.size(); j++) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
//该层级只有一个节点
|
||||
if (rs2.size() == 1) {
|
||||
jsonObject.put("id", rs2.get(j).getId());
|
||||
jsonObject.put("contents", rs2.get(j).getContents());
|
||||
jsonObject.put("status", rs2.get(j).getStatus());
|
||||
jsonObject.put("contents_x", x);
|
||||
jsonObject.put("contents_y", y);
|
||||
if (rs2.get(j).getStartId() != null && !rs2.get(j).getStartId().equals("")) {
|
||||
jsonObject.put("startLine", rs2.get(j).getStartId().toString());
|
||||
jsonObject.put("endLine", rs2.get(j).getId().toString());
|
||||
}
|
||||
} else {
|
||||
//该节点为复数
|
||||
if (rs2.size() % 2 == 0) {
|
||||
if (j % 2 == 0) {
|
||||
x = x - (j + 1) * 50;
|
||||
jsonObject.put("id", rs2.get(j).getId());
|
||||
jsonObject.put("contents", rs2.get(j).getContents().toString());
|
||||
jsonObject.put("status", rs2.get(j).getStatus());
|
||||
jsonObject.put("contents_x", x);
|
||||
jsonObject.put("contents_y", y);
|
||||
if (rs2.get(j).getStartId() != null && !rs2.get(j).getStartId().equals("")) {
|
||||
jsonObject.put("startLine", rs2.get(j).getStartId().toString());
|
||||
jsonObject.put("endLine", rs2.get(j).getId().toString());
|
||||
}
|
||||
} else {
|
||||
x = x + (j + 1) * 50;
|
||||
jsonObject.put("id", rs2.get(j).getId());
|
||||
jsonObject.put("contents", rs2.get(j).getContents().toString());
|
||||
jsonObject.put("status", rs2.get(j).getStatus());
|
||||
jsonObject.put("contents_x", x);
|
||||
jsonObject.put("contents_y", y);
|
||||
if (rs2.get(j).getStartId() != null && !rs2.get(j).getStartId().equals("")) {
|
||||
jsonObject.put("startLine", rs2.get(j).getStartId().toString());
|
||||
jsonObject.put("endLine", rs2.get(j).getId().toString());
|
||||
}
|
||||
}
|
||||
//该节点为单数
|
||||
} else {
|
||||
//中间的节点
|
||||
if (j == 0) {
|
||||
jsonObject.put("id", rs2.get(j).getId());
|
||||
jsonObject.put("contents", rs2.get(j).getContents().toString());
|
||||
jsonObject.put("status", rs2.get(j).getStatus());
|
||||
jsonObject.put("contents_x", x);
|
||||
jsonObject.put("contents_y", y);
|
||||
if (rs2.get(j).getStartId() != null && !rs2.get(j).getStartId().equals("")) {
|
||||
jsonObject.put("startLine", rs2.get(j).getStartId().toString());
|
||||
jsonObject.put("endLine", rs2.get(j).getId().toString());
|
||||
}
|
||||
//两边节点
|
||||
} else {
|
||||
if (j % 2 == 0) {
|
||||
x = x - (j) * 160;
|
||||
jsonObject.put("id", rs2.get(j).getId());
|
||||
jsonObject.put("contents", rs2.get(j).getContents().toString());
|
||||
jsonObject.put("status", rs2.get(j).getStatus());
|
||||
jsonObject.put("contents_x", x);
|
||||
jsonObject.put("contents_y", y);
|
||||
if (rs2.get(j).getStartId() != null && !rs2.get(j).getStartId().equals("")) {
|
||||
jsonObject.put("startLine", rs2.get(j).getStartId().toString());
|
||||
jsonObject.put("endLine", rs2.get(j).getId().toString());
|
||||
}
|
||||
} else {
|
||||
x = x + (j) * 160;
|
||||
jsonObject.put("id", rs2.get(j).getId());
|
||||
jsonObject.put("contents", rs2.get(j).getContents().toString());
|
||||
jsonObject.put("status", rs2.get(j).getStatus());
|
||||
jsonObject.put("contents_x", x);
|
||||
jsonObject.put("contents_y", y);
|
||||
if (rs2.get(j).getStartId() != null && !rs2.get(j).getStartId().equals("")) {
|
||||
jsonObject.put("startLine", rs2.get(j).getStartId().toString());
|
||||
jsonObject.put("endLine", rs2.get(j).getId().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<EmergencyRecordsDetail> lists0 = this.emergencyRecordsDetailService
|
||||
.selectListByWhere("where pid='" + id + "' and status='0'");
|
||||
List<EmergencyRecordsDetail> lists1 = this.emergencyRecordsDetailService
|
||||
.selectListByWhere("where pid='" + id + "' and status='1'");
|
||||
List<EmergencyRecordsDetail> lists2 = this.emergencyRecordsDetailService
|
||||
.selectListByWhere("where pid='" + id + "' and status='2'");
|
||||
List<EmergencyRecordsDetail> lists3 = this.emergencyRecordsDetailService
|
||||
.selectListByWhere("where pid='" + id + "' and status='3'");
|
||||
|
||||
String ids0 = "";//未演练的ids
|
||||
String ids1 = "";//执行中的ids
|
||||
String ids2 = "";//已演练的ids
|
||||
String ids3 = "";//已关闭的ids
|
||||
|
||||
if (lists0 != null && lists0.size() > 0) {
|
||||
for (int i = 0; i < lists0.size(); i++) {
|
||||
ids0 += lists0.get(i).getId();
|
||||
}
|
||||
}
|
||||
if (lists1 != null && lists1.size() > 0) {
|
||||
for (int i = 0; i < lists1.size(); i++) {
|
||||
ids1 += lists1.get(i).getId();
|
||||
}
|
||||
}
|
||||
if (lists2 != null && lists2.size() > 0) {
|
||||
for (int i = 0; i < lists2.size(); i++) {
|
||||
ids2 += lists2.get(i).getId();
|
||||
}
|
||||
}
|
||||
if (lists3 != null && lists3.size() > 0) {
|
||||
for (int i = 0; i < lists3.size(); i++) {
|
||||
ids3 += lists3.get(i).getId();
|
||||
}
|
||||
}
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("jsonArray", jsonArray);
|
||||
object.put("end_y", y+100);
|
||||
object.put("ids0", ids0);
|
||||
object.put("ids1", ids1);
|
||||
object.put("ids2", ids2);
|
||||
object.put("ids3", ids3);
|
||||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询节点
|
||||
*
|
||||
* @param request
|
||||
* @param model
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/selectDetails.do")
|
||||
public ModelAndView selectDetails(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
JSONObject object = selectDetail(id);
|
||||
Result result = Result.success(object);
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
/**
|
||||
* 添加计划外演练
|
||||
*
|
||||
* @param request
|
||||
* @param model
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/doChoice.do")
|
||||
public ModelAndView doChoice(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "checkedIds") String checkedIds,
|
||||
@RequestParam(value = "unitId") String unitId) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
|
||||
//int res = this.emergencyRecordsService.doChoice(checkedIds, unitId, cu);
|
||||
//计划内和计划外目前只有状态的区别,合并到同一个方法里,增加参数变化
|
||||
//计划外
|
||||
int res = this.emergencyPlanService.dodown(checkedIds, cu, EmergencyRecords.Outside);
|
||||
|
||||
Result result = Result.success(res);
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
/**
|
||||
* 报警触发应急预案
|
||||
* @param mpid 报警点位
|
||||
* @return 返回触发数量,0为失败,大于0为成功触发数量
|
||||
*/
|
||||
@RequestMapping("/doAlarmDown.do")
|
||||
public ModelAndView doAlarmDown(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "mpid") String mpid) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
//计划外
|
||||
int res = this.emergencyPlanService.alarmDown(mpid, cu);
|
||||
model.addAttribute("result", res);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取预案演练数据
|
||||
*
|
||||
* @param request
|
||||
* @param model
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getEdit.do")
|
||||
public ModelAndView getEdit(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "id") String id) {
|
||||
EmergencyRecords emergencyRecords = emergencyRecordsService.getMenuById(id);
|
||||
JSONObject jsonObject = JSONObject.fromObject(emergencyRecords);
|
||||
model.addAttribute("result", jsonObject);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
/**
|
||||
* 获取预案演练-操作内容数据
|
||||
*
|
||||
* @param request
|
||||
* @param model
|
||||
* @param nodeId
|
||||
* @param recordsId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getDetailEdit.do")
|
||||
public ModelAndView getDetailEdit(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "nodeId") String nodeId,
|
||||
@RequestParam(value = "recordsId") String recordsId) {
|
||||
List<EmergencyRecordsDetail> list = this.emergencyRecordsDetailService.selectListByWhere("where ecDetailId='"+nodeId+"' and pid ='"+recordsId+"' order by insdt desc");
|
||||
if(list!=null && list.size()>0){
|
||||
JSONObject jsonObject = JSONObject.fromObject(list.get(0));
|
||||
model.addAttribute("result", jsonObject);
|
||||
}
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/updateMenuLf.do")
|
||||
public ModelAndView updateMenuLf(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "id") String id,
|
||||
@RequestParam(value = "graphData") String graphData) {
|
||||
EmergencyRecords emergencyRecords =this.emergencyRecordsService.getMenuById(id);
|
||||
emergencyRecords.setNodes(graphData);
|
||||
int result = this.emergencyRecordsService.updateMenu(emergencyRecords);
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,539 @@
|
||||
package com.sipai.controller.command;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.command.EmergencyRecordsDetail;
|
||||
import com.sipai.entity.command.EmergencyRecordsWorkOrder;
|
||||
import com.sipai.entity.msg.MsgType;
|
||||
import com.sipai.entity.timeefficiency.PatrolRecord;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.command.EmergencyRecordsWorkOrderService;
|
||||
import com.sipai.service.msg.MsgServiceImpl;
|
||||
import com.sipai.service.msg.MsgTypeService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
import com.sipai.tools.MqttUtil;
|
||||
import com.sipai.tools.SpringContextUtil;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/command/emergencyRecordsWorkOrder")
|
||||
public class EmergencyRecordsWorkOrderController {
|
||||
@Resource
|
||||
private EmergencyRecordsWorkOrderService emergencyRecordsWorkOrderService;
|
||||
@Resource
|
||||
private MsgTypeService msgtypeService;
|
||||
|
||||
@RequestMapping("/showlist.do")
|
||||
public String showlist(HttpServletRequest request, Model model) {
|
||||
return "/command/emergencyRecordsWorkOrderList";
|
||||
}
|
||||
|
||||
/*
|
||||
* 应急预案演练记录列表数据查询
|
||||
*/
|
||||
@RequestMapping("/getListData.do")
|
||||
public ModelAndView getListData(HttpServletRequest request, Model model) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String scope = "";
|
||||
//获取查询时间
|
||||
if (request.getParameter("sdt") != null
|
||||
&& request.getParameter("sdt").trim().length() > 0) {
|
||||
scope += " and m.worksenddt>='"
|
||||
+ request.getParameter("sdt").substring(0, 10)
|
||||
+ " 00:00:00" + "' ";
|
||||
}
|
||||
if (request.getParameter("edt") != null
|
||||
&& request.getParameter("edt").trim().length() > 0) {
|
||||
scope += " and m.worksenddt<='"
|
||||
+ request.getParameter("edt").substring(0, 10)
|
||||
+ " 23:59:59" + "' ";
|
||||
}
|
||||
if (request.getParameter("search_name") != null && !request.getParameter("search_name").isEmpty()) {
|
||||
scope += " and workcontent like '%" + request.getParameter("search_name") + "%' ";
|
||||
}
|
||||
String unitId = request.getParameter("unitId");
|
||||
String userId = request.getParameter("userId");
|
||||
String type = request.getParameter("type");//type不为空的话 则为app传过来的
|
||||
|
||||
if (unitId != null && !unitId.equals("")) {
|
||||
// scope += " and bizid = '" + unitId + "' ";
|
||||
}
|
||||
|
||||
if (userId != null && !userId.equals("") && !userId.equals("admin")) {
|
||||
scope += " and (worksenduser = '" + userId + "' or workreceiveuser = '" + userId + "') ";
|
||||
}else{
|
||||
scope += " and (worksenduser = '" + cu.getId() + "' or workreceiveuser = '" + cu.getId() + "') ";
|
||||
}
|
||||
|
||||
if (type != null && !type.equals("")) {
|
||||
scope += " and (status = '" + EmergencyRecordsWorkOrder.Status_NoReceive + "' or status = '" + EmergencyRecordsWorkOrder.Status_Receive + "') ";
|
||||
}
|
||||
|
||||
List<EmergencyRecordsWorkOrder> ia = this.emergencyRecordsWorkOrderService
|
||||
.selectcompanynameByWhere(" where 1=1 " + scope + " order by m.insdt desc");
|
||||
JSONArray json = JSONArray.fromObject(ia);
|
||||
String result = "{\"total\":" + ia.size() + ",\"rows\":" + json + "}";
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/getlist.do")
|
||||
public ModelAndView getlist(HttpServletRequest request, Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required = false) String sort,
|
||||
@RequestParam(value = "order", required = false) String order) {
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String nodeid = request.getParameter("nodeid");
|
||||
String recordid = request.getParameter("recordid");
|
||||
|
||||
String orderstr = " order by m.insdt desc ";
|
||||
|
||||
String wherestr = "where 1=1 ";
|
||||
if (nodeid != null && !nodeid.isEmpty()) {
|
||||
wherestr += " and nodeid like '%" + nodeid + "%' ";
|
||||
}
|
||||
if (recordid != null && !recordid.isEmpty()) {
|
||||
wherestr += " and recordid = '" + recordid + "' ";
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<EmergencyRecordsWorkOrder> list = this.emergencyRecordsWorkOrderService.selectlistlayerByWhere(wherestr + orderstr);
|
||||
PageInfo<EmergencyRecordsWorkOrder> pi = new PageInfo<EmergencyRecordsWorkOrder>(list);
|
||||
JSONArray json = JSONArray.fromObject(list);
|
||||
String result = "{\"total\":" + pi.getTotal() + ",\"rows\":" + json + "}";
|
||||
model.addAttribute("result", result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/donew.do")
|
||||
public String donew(HttpServletRequest request, Model model) {
|
||||
return "/command/emergencyRecordsWorkOrderNew";
|
||||
}
|
||||
|
||||
@RequestMapping("/donew2.do")
|
||||
public ModelAndView donew2(HttpServletRequest request, Model model) {
|
||||
String workOrderId = request.getParameter("workOrderId");
|
||||
List<EmergencyRecordsWorkOrder> list = this.emergencyRecordsWorkOrderService.selectlistlayerByWhere("where m.id='" + workOrderId + "' order by id");
|
||||
if (list != null && list.size() > 0) {
|
||||
model.addAttribute("emergencyRecordsWorkOrder", list.get(0));
|
||||
}
|
||||
return new ModelAndView("/command/emergencyRecordsWorkOrderNew2");
|
||||
}
|
||||
|
||||
/*下发任务*/
|
||||
@RequestMapping("/dosend.do")
|
||||
public ModelAndView dosend(HttpServletRequest request, Model model) {
|
||||
User user = (User) request.getSession().getAttribute("cu");
|
||||
String workOrderId = request.getParameter("workOrderId");
|
||||
List<EmergencyRecordsWorkOrder> list = this.emergencyRecordsWorkOrderService.selectlistlayerByWhere("where m.id='" + workOrderId + "' order by id");
|
||||
int res = 0;
|
||||
if (list != null && list.size() > 0) {
|
||||
EmergencyRecordsWorkOrder emergencyRecordsWorkOrder = list.get(0);
|
||||
emergencyRecordsWorkOrder.setStatus(Integer.parseInt(PatrolRecord.Status_Issue));
|
||||
res = this.emergencyRecordsWorkOrderService.update(emergencyRecordsWorkOrder);
|
||||
if (res == 1) {
|
||||
String msgContent = "";
|
||||
String sendUserId = user.getId();
|
||||
String receiveUserIds = emergencyRecordsWorkOrder.getWorkreceiveuserid();
|
||||
MsgType msgType = this.msgtypeService.getMsgTypeById(EmergencyRecordsDetail.Msg_Type);
|
||||
MsgServiceImpl msgService = (MsgServiceImpl) SpringContextUtil.getBean("msgService");
|
||||
if (msgType != null) {
|
||||
msgContent = "应急预案工单已下发至您,请及时处理。";
|
||||
msgService.insertMsgSend(msgType.getId(), msgContent, receiveUserIds, sendUserId, "U");
|
||||
msgService = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
model.addAttribute("result", res);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/dosave.do")
|
||||
public String dosave(HttpServletRequest request, Model model,
|
||||
@ModelAttribute("emergencyRecordsWorkOrder") EmergencyRecordsWorkOrder emergencyRecordsWorkOrder) {
|
||||
User user = (User) request.getSession().getAttribute("cu");
|
||||
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
emergencyRecordsWorkOrder.setId(CommUtil.getUUID());
|
||||
emergencyRecordsWorkOrder.setInsdt(CommUtil.nowDate());
|
||||
emergencyRecordsWorkOrder.setInsuser(user.getId());
|
||||
emergencyRecordsWorkOrder.setWorksenduser(user.getId());
|
||||
emergencyRecordsWorkOrder.setWorksenddt(CommUtil.nowDate());
|
||||
emergencyRecordsWorkOrder.setStatus(3);
|
||||
emergencyRecordsWorkOrder.setNodeid(request.getParameter("nodeid"));
|
||||
emergencyRecordsWorkOrder.setRecordid(request.getParameter("recordid"));
|
||||
emergencyRecordsWorkOrder.setWorkreceiveuserid(request.getParameter("workreceiveuserid"));
|
||||
int res = this.emergencyRecordsWorkOrderService.save(emergencyRecordsWorkOrder);
|
||||
System.out.println("res" + res);
|
||||
if (res == 1) {
|
||||
List<EmergencyRecordsWorkOrder> list = this.emergencyRecordsWorkOrderService
|
||||
.selectusernameByWhere("where m.nodeid='" + emergencyRecordsWorkOrder.getNodeid() + "' order by m.insdt asc");
|
||||
if (list != null && list.size() > 0) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if (list.get(i).getId() != null && !list.get(i).getId().equals("")) {
|
||||
jsonObject.put("id", list.get(i).getId());
|
||||
} else {
|
||||
jsonObject.put("id", "");
|
||||
}
|
||||
if (list.get(i).get_worksenduser() != null && !list.get(i).get_worksenduser().equals("")) {
|
||||
jsonObject.put("worksenduser", list.get(i).get_worksenduser());
|
||||
} else {
|
||||
jsonObject.put("worksenduser", "");
|
||||
}
|
||||
if (list.get(i).get_workreceiveuser() != null && !list.get(i).get_workreceiveuser().equals("")) {
|
||||
jsonObject.put("workreceiveuser", list.get(i).get_workreceiveuser());
|
||||
} else {
|
||||
jsonObject.put("workreceiveuser", "");
|
||||
}
|
||||
if (list.get(i).getWorkcontent() != null && !list.get(i).getWorkcontent().equals("")) {
|
||||
jsonObject.put("workcontent", list.get(i).getWorkcontent());
|
||||
} else {
|
||||
jsonObject.put("workcontent", "");
|
||||
}
|
||||
if (list.get(i).getWorksenddt() != null && !list.get(i).getWorksenddt().equals("")) {
|
||||
jsonObject.put("worksenddt", list.get(i).getWorksenddt());
|
||||
} else {
|
||||
jsonObject.put("worksenddt", "");
|
||||
}
|
||||
if (list.get(i).getWorkreceivedt() != null && !list.get(i).getWorkreceivedt().equals("")) {
|
||||
jsonObject.put("workreceivedt", list.get(i).getWorkreceivedt());
|
||||
} else {
|
||||
jsonObject.put("workreceivedt", "");
|
||||
}
|
||||
if (list.get(i).getStatus() == 0) {
|
||||
jsonObject.put("status", "未下发");
|
||||
}
|
||||
if (list.get(i).getStatus() == 3) {
|
||||
jsonObject.put("status", "待接单");
|
||||
}
|
||||
if (list.get(i).getStatus() == 5) {
|
||||
jsonObject.put("status", "已接单");
|
||||
}
|
||||
if (list.get(i).getStatus() == 10) {
|
||||
jsonObject.put("status", "已完成");
|
||||
}
|
||||
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
}
|
||||
// request.setAttribute("result", jsonArray);
|
||||
model.addAttribute("res", res);
|
||||
// request.setAttribute("res", res);
|
||||
model.addAttribute("result", "{\"res\":\"" + res + "\",\"results\":\"" + jsonArray + "\"}");
|
||||
System.out.println("{\"res\":\"" + res + "\",\"result\":\"" + jsonArray + "\"}");
|
||||
return "result";
|
||||
|
||||
} else {
|
||||
request.setAttribute("result", "0");
|
||||
return "result";
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/dosave2.do")
|
||||
public String dosave2(HttpServletRequest request, Model model,
|
||||
@ModelAttribute("emergencyRecordsWorkOrder") EmergencyRecordsWorkOrder emergencyRecordsWorkOrder) {
|
||||
User user = (User) request.getSession().getAttribute("cu");
|
||||
String status = request.getParameter("status");
|
||||
if (status == null || "".equals(status)) {
|
||||
status = "0";
|
||||
}
|
||||
int res = 0;
|
||||
String workreceiveuser = request.getParameter("workreceiveuserid");
|
||||
if (emergencyRecordsWorkOrder.getId() != null && !"".equals(emergencyRecordsWorkOrder.getId())) {
|
||||
emergencyRecordsWorkOrder.setInsdt(CommUtil.nowDate());
|
||||
emergencyRecordsWorkOrder.setInsuser(user.getId());
|
||||
emergencyRecordsWorkOrder.setWorksenduser(user.getId());
|
||||
emergencyRecordsWorkOrder.setWorksenddt(CommUtil.nowDate());
|
||||
res = this.emergencyRecordsWorkOrderService.update(emergencyRecordsWorkOrder);
|
||||
} else {
|
||||
emergencyRecordsWorkOrder.setId(CommUtil.getUUID());
|
||||
emergencyRecordsWorkOrder.setInsdt(CommUtil.nowDate());
|
||||
emergencyRecordsWorkOrder.setInsuser(user.getId());
|
||||
emergencyRecordsWorkOrder.setWorksenduser(user.getId());
|
||||
emergencyRecordsWorkOrder.setWorksenddt(CommUtil.nowDate());
|
||||
emergencyRecordsWorkOrder.setStatus(Integer.parseInt(status));
|
||||
emergencyRecordsWorkOrder.setNodeid(request.getParameter("nodeid"));
|
||||
emergencyRecordsWorkOrder.setRecordid(request.getParameter("recordid"));
|
||||
emergencyRecordsWorkOrder.setWorkreceiveuserid(request.getParameter("workreceiveuserid"));
|
||||
String patrolRecordId = CommUtil.getUUID();
|
||||
emergencyRecordsWorkOrder.setPatrolRecordId(patrolRecordId);
|
||||
res = this.emergencyRecordsWorkOrderService.save(emergencyRecordsWorkOrder);
|
||||
}
|
||||
if (res == 1 && PatrolRecord.Status_Issue.equals(status)) {
|
||||
String msgContent = "";
|
||||
String sendUserId = user.getId();
|
||||
String receiveUserIds = workreceiveuser;
|
||||
MsgType msgType = this.msgtypeService.getMsgTypeById(EmergencyRecordsDetail.Msg_Type);
|
||||
MsgServiceImpl msgService = (MsgServiceImpl) SpringContextUtil.getBean("msgService");
|
||||
if (msgType != null) {
|
||||
msgContent = "收到一条应急预案工单,请及时处理。";
|
||||
msgService.insertMsgSend(msgType.getId(), msgContent, receiveUserIds, sendUserId, "U");
|
||||
msgService = null;
|
||||
}
|
||||
com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
|
||||
jsonObject.put("title", "维修单");
|
||||
jsonObject.put("content", "收到一条应急预案工单,请及时处理。");
|
||||
/*Mqtt mqtt = new Mqtt();
|
||||
if (mqtt.getStatus() != null && mqtt.getStatus().equals("0")) {
|
||||
MqttUtil.publish(jsonObject, receiveUserIds);
|
||||
}*/
|
||||
MqttUtil.publish(jsonObject, receiveUserIds);
|
||||
}
|
||||
request.setAttribute("result", res);
|
||||
return "result";
|
||||
}
|
||||
|
||||
/*
|
||||
* 异步查询table记录
|
||||
*/
|
||||
@RequestMapping("/selectTable.do")
|
||||
public String selectTable(HttpServletRequest request, Model model) {
|
||||
User user = (User) request.getSession().getAttribute("cu");
|
||||
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
String nodeid = request.getParameter("nodeid");
|
||||
List<EmergencyRecordsWorkOrder> list = this.emergencyRecordsWorkOrderService
|
||||
.selectusernameByWhere("where m.nodeid='" + nodeid + "' order by m.insdt asc");
|
||||
if (list != null && list.size() > 0) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if (list.get(i).getId() != null && !list.get(i).getId().equals("")) {
|
||||
jsonObject.put("id", list.get(i).getId());
|
||||
} else {
|
||||
jsonObject.put("id", "");
|
||||
}
|
||||
if (list.get(i).get_worksenduser() != null && !list.get(i).get_worksenduser().equals("")) {
|
||||
jsonObject.put("worksenduser", list.get(i).get_worksenduser());
|
||||
} else {
|
||||
jsonObject.put("worksenduser", "");
|
||||
}
|
||||
if (list.get(i).get_workreceiveuser() != null && !list.get(i).get_workreceiveuser().equals("")) {
|
||||
jsonObject.put("workreceiveuser", list.get(i).get_workreceiveuser());
|
||||
} else {
|
||||
jsonObject.put("workreceiveuser", "");
|
||||
}
|
||||
if (list.get(i).getWorkcontent() != null && !list.get(i).getWorkcontent().equals("")) {
|
||||
jsonObject.put("workcontent", list.get(i).getWorkcontent());
|
||||
} else {
|
||||
jsonObject.put("workcontent", "");
|
||||
}
|
||||
if (list.get(i).getWorksenddt() != null && !list.get(i).getWorksenddt().equals("")) {
|
||||
jsonObject.put("worksenddt", list.get(i).getWorksenddt());
|
||||
} else {
|
||||
jsonObject.put("worksenddt", "");
|
||||
}
|
||||
if (list.get(i).getWorkreceivedt() != null && !list.get(i).getWorkreceivedt().equals("")) {
|
||||
jsonObject.put("workreceivedt", list.get(i).getWorkreceivedt());
|
||||
} else {
|
||||
jsonObject.put("workreceivedt", "");
|
||||
}
|
||||
if (list.get(i).getStatus() == 0) {
|
||||
jsonObject.put("status", "未下发");
|
||||
jsonObject.put("xfstatus", "下发");//xfstatus用来判断是否显示下发 只有为0的时候显示下发
|
||||
}
|
||||
if (list.get(i).getStatus() == 3) {
|
||||
jsonObject.put("status", "待接单");
|
||||
jsonObject.put("xfstatus", "");
|
||||
}
|
||||
if (list.get(i).getStatus() == 5) {
|
||||
jsonObject.put("status", "已接单");
|
||||
jsonObject.put("xfstatus", "");
|
||||
}
|
||||
if (list.get(i).getStatus() == 10) {
|
||||
jsonObject.put("status", "已完成");
|
||||
jsonObject.put("xfstatus", "");
|
||||
}
|
||||
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
}
|
||||
request.setAttribute("result", jsonArray);
|
||||
return "result";
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
@RequestMapping("/doedit.do")
|
||||
public String doedit(HttpServletRequest request, Model model) {
|
||||
User user = (User) request.getSession().getAttribute("cu");
|
||||
String id = request.getParameter("id");
|
||||
List<EmergencyRecordsWorkOrder> eRecordsWorkOrder = this.emergencyRecordsWorkOrderService
|
||||
.selectcompanynameByWhere("where m.id='" + id + "'");
|
||||
if (eRecordsWorkOrder != null) {
|
||||
request.setAttribute("eRecordsWorkOrder", eRecordsWorkOrder.get(0));
|
||||
return "/command/emergencyRecordsWorkOrderEdit";
|
||||
} else {
|
||||
request.setAttribute("msg", "数据已删除");
|
||||
return "redirect:showlist";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 弹窗显示摄像头页面
|
||||
*/
|
||||
@RequestMapping("/cameraListLayer.do")
|
||||
public String cameraListLayer(HttpServletRequest request, Model model) {
|
||||
String bizid = request.getParameter("bizid");
|
||||
// CameraDAO cd= new CameraDAO();
|
||||
// Result rs = null;
|
||||
// String serverIp = request.getServerName();
|
||||
// if(serverIp!=null && !serverIp.equals("")){
|
||||
// if(serverIp.substring(0, 2).equals("10")){
|
||||
// rs = cd.loadSql("select id,name,channel from TB_PRO_Camera where network='厂内' and bizid='"+ bizid +"' order by channel asc");
|
||||
// }else {
|
||||
// rs = cd.loadSql("select id,name,channel from TB_PRO_Camera where network='厂外' and bizid='"+ bizid +"' order by channel asc");
|
||||
// }
|
||||
// }
|
||||
// cd = null;
|
||||
// if(rs!=null && rs.getRowCount()>0){
|
||||
// request.setAttribute("list", rs.getRows());
|
||||
// rs = null;
|
||||
// return "/command/emergencyRecordsCameraListlayer";
|
||||
// }else {
|
||||
// request.setAttribute("msg", "数据已删除");
|
||||
// return showlist(mapping, form, request, response);
|
||||
// }
|
||||
return "/command/emergencyRecordsCameraListlayer";
|
||||
}
|
||||
|
||||
/*
|
||||
* 完成工单
|
||||
*/
|
||||
@RequestMapping("/dofinish.do")
|
||||
public String dofinish(HttpServletRequest request, Model model,
|
||||
@ModelAttribute("eRecordsWorkOrder") EmergencyRecordsWorkOrder ec) {
|
||||
User user = (User) request.getSession().getAttribute("cu");
|
||||
ec.setWorkfinishdt(CommUtil.nowDate());
|
||||
ec.setStatus(10);
|
||||
int result = this.emergencyRecordsWorkOrderService.update(ec);
|
||||
if (result == 1) {
|
||||
List<EmergencyRecordsWorkOrder> eRecordsWorkOrder = this.emergencyRecordsWorkOrderService
|
||||
.selectcompanynameByWhere("where m.id='" + ec.getId() + "'");
|
||||
if (eRecordsWorkOrder != null && eRecordsWorkOrder.size() > 0) {
|
||||
String msgContent = "";
|
||||
String sendUserId = user.getId();
|
||||
String receiveUserIds = eRecordsWorkOrder.get(0).getWorksenduser();
|
||||
MsgType msgType = this.msgtypeService.getMsgTypeById(EmergencyRecordsDetail.Msg_Type);
|
||||
MsgServiceImpl msgService = (MsgServiceImpl) SpringContextUtil.getBean("msgService");
|
||||
if (msgType != null) {
|
||||
msgContent = "应急预案工单已完成,请注意查看。";
|
||||
msgService.insertMsgSend(msgType.getId(), msgContent, receiveUserIds, sendUserId, "U");
|
||||
msgService = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if(res==0){
|
||||
// request.setAttribute("msg", "更新成功");
|
||||
// return "redirect:showlist";
|
||||
//
|
||||
// }else{
|
||||
// request.setAttribute("msg", "更新失败:"+res);
|
||||
// request.setAttribute("ec", ec);
|
||||
// return "redirect:doedit";
|
||||
// }
|
||||
request.setAttribute("result", result);
|
||||
return "result";
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* list界面
|
||||
*/
|
||||
@RequestMapping("/dolistlayer.do")
|
||||
public String dolistlayer(HttpServletRequest request, Model model) {
|
||||
User user = (User) request.getSession().getAttribute("cu");
|
||||
String recordid = request.getParameter("recordid");//应急预案主表的id
|
||||
List<EmergencyRecordsWorkOrder> rs = this.emergencyRecordsWorkOrderService
|
||||
.selectlistlayerByWhere("where m.recordid='" + recordid + "' order by rank asc");
|
||||
if (rs != null) {
|
||||
request.setAttribute("list", rs);
|
||||
return "/command/emergencyRecordsWorkOrderListlayer";
|
||||
} else {
|
||||
request.setAttribute("msg", "数据已删除");
|
||||
return "redirect:showlist";
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 签收
|
||||
*/
|
||||
@RequestMapping("/dosignfor.do")
|
||||
public String dosignfor(HttpServletRequest request, Model model,
|
||||
@ModelAttribute("eRecordsWorkOrder") EmergencyRecordsWorkOrder ec) {
|
||||
User user = (User) request.getSession().getAttribute("cu");
|
||||
ec.setWorkreceivedt(CommUtil.nowDate());//接单时间
|
||||
ec.setStatus(5);
|
||||
int result = this.emergencyRecordsWorkOrderService.update(ec);
|
||||
// if(res==0){
|
||||
// request.setAttribute("msg", "更新成功");
|
||||
// return "redirect:showlist";
|
||||
// }else{
|
||||
// request.setAttribute("msg", "更新失败:"+res);
|
||||
// request.setAttribute("ec", ec);
|
||||
// return "redirect:doedit";
|
||||
// }
|
||||
request.setAttribute("result", result);
|
||||
return "result";
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 查看界面
|
||||
*/
|
||||
@RequestMapping("/doviewlayer.do")
|
||||
public String doviewlayer(HttpServletRequest request, Model model) {
|
||||
User user = (User) request.getSession().getAttribute("cu");
|
||||
String id = request.getParameter("id");
|
||||
List<EmergencyRecordsWorkOrder> eRecordsWorkOrder = this.emergencyRecordsWorkOrderService
|
||||
.selectcompanynameByWhere("where m.id='" + id + "'");
|
||||
if (eRecordsWorkOrder != null) {
|
||||
request.setAttribute("eRecordsWorkOrder", eRecordsWorkOrder.get(0));
|
||||
// System.out.println(eRecordsWorkOrder.get(0));
|
||||
return "/command/emergencyRecordsWorkOrderViewlayer";
|
||||
} else {
|
||||
request.setAttribute("msg", "数据已删除");
|
||||
return "redirect:showlist";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 下发工单
|
||||
*/
|
||||
@RequestMapping("/downWork.do")
|
||||
public String downWork(HttpServletRequest request, Model model) {
|
||||
User user = (User) request.getSession().getAttribute("cu");
|
||||
EmergencyRecordsWorkOrder ec = new EmergencyRecordsWorkOrder();
|
||||
ec.setWorkfinishdt(CommUtil.nowDate());
|
||||
ec.setStatus(3);
|
||||
int res = this.emergencyRecordsWorkOrderService.save(ec);
|
||||
if (res == 0) {
|
||||
System.out.println("下发成功");
|
||||
request.setAttribute("result", "0");
|
||||
return "result";
|
||||
|
||||
} else {
|
||||
System.out.println("下发失败");
|
||||
request.setAttribute("result", "1");
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,227 @@
|
||||
package com.sipai.controller.cqbyt;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.cqbyt.CqbytSampleValue;
|
||||
import com.sipai.entity.user.Unit;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.cqbyt.CqbytSampleValueService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/cqbyt/cqbytSampleValue")
|
||||
public class CqbytSampleValueController {
|
||||
@Resource
|
||||
private CqbytSampleValueService cqbytSampleValueService;
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
|
||||
@RequestMapping("/showlist.do")
|
||||
public String showlist(HttpServletRequest request,Model model){
|
||||
ArrayList<String> itemUnit = new ArrayList<>();
|
||||
itemUnit.add("张玥");
|
||||
itemUnit.add("庞力");
|
||||
itemUnit.add("彭先乙");
|
||||
itemUnit.add("罗小红");
|
||||
itemUnit.add("陈文静");
|
||||
ArrayList<String> itemName = new ArrayList<>();
|
||||
itemName.add("江南水厂出厂水");
|
||||
itemName.add("江南水厂原水");
|
||||
ArrayList<String> checkStandardCode = new ArrayList<>();
|
||||
checkStandardCode.add("浅褐色、泥腥味、微浑、样品完好");
|
||||
checkStandardCode.add("无色、无味、透明、样品完好");
|
||||
checkStandardCode.add("无色、无味、微浑、样品完好");
|
||||
checkStandardCode.add("无色、无味、透明");
|
||||
Random random = new Random();
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add(Calendar.DAY_OF_YEAR, -1);
|
||||
Date date = cal.getTime();
|
||||
DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String nowDate = format.format(date).substring(0,10);
|
||||
List<CqbytSampleValue> list = this.cqbytSampleValueService.selectListByWhere(" where sampleCode = '"+nowDate+"' ");
|
||||
if (list.size()<4) {
|
||||
CqbytSampleValue cqbytSampleValue = new CqbytSampleValue();
|
||||
cqbytSampleValue.setSamplecode(nowDate);
|
||||
String user = itemUnit.get(random.nextInt(5));
|
||||
String user1 = itemUnit.get(random.nextInt(5));
|
||||
for (int i = 0; i < 4; i++) {
|
||||
int a = random.nextInt(999)+1;
|
||||
cqbytSampleValue.setId(CommUtil.getUUID());
|
||||
cqbytSampleValue.setItemcode("SR22401005"+a);
|
||||
if (i%2==0) {
|
||||
cqbytSampleValue.setItemname("江南水厂出厂水");
|
||||
cqbytSampleValue.setItemunit(user);
|
||||
}else {
|
||||
cqbytSampleValue.setItemname("江南水厂原水");
|
||||
cqbytSampleValue.setItemunit(user1);
|
||||
}
|
||||
cqbytSampleValue.setCheckstandardcode(checkStandardCode.get(i));
|
||||
|
||||
this.cqbytSampleValueService.save(cqbytSampleValue);
|
||||
}
|
||||
}
|
||||
|
||||
return "/cqbytSampleValue/cqbytSampleValueBrowse";
|
||||
}
|
||||
|
||||
@RequestMapping("/browseList.do")
|
||||
public String browseList(HttpServletRequest request,Model model){
|
||||
return "/cqbytSampleValue/cqbytSampleValueBrowse";
|
||||
}
|
||||
|
||||
@RequestMapping("/getList.do")
|
||||
public ModelAndView getList(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required=false) String sort,
|
||||
@RequestParam(value = "order", required=false) String order) {
|
||||
User cu=(User)request.getSession().getAttribute("cu");
|
||||
String companyId =request.getParameter("unitId");
|
||||
sort = " sampleCode ";
|
||||
if(order==null){
|
||||
order = " desc ";
|
||||
}
|
||||
String orderstr=" order by "+sort+" "+order;
|
||||
|
||||
String wherestr=" where 1=1";
|
||||
// if(companyId!=null && !companyId.isEmpty()){
|
||||
// //获取公司下所有子节点
|
||||
// List<Unit> units = unitService.getUnitChildrenById(companyId);
|
||||
// String companyids="";
|
||||
// for(Unit unit : units){
|
||||
// companyids += "'"+unit.getId()+"',";
|
||||
// }
|
||||
// if(companyids!=""){
|
||||
// companyids = companyids.substring(0, companyids.length()-1);
|
||||
// wherestr += " and unit_id in ("+companyids+") ";
|
||||
// }
|
||||
// }
|
||||
if(request.getParameter("search_name")!=null && !request.getParameter("search_name").isEmpty()){
|
||||
wherestr += " and itemName like '%"+request.getParameter("search_name")+"%' ";
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<CqbytSampleValue> list = this.cqbytSampleValueService.selectListByWhere(wherestr+orderstr);
|
||||
PageInfo<CqbytSampleValue> pi = new PageInfo<CqbytSampleValue>(list);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
|
||||
String result="{\"total\":"+pi.getTotal()+",\"rows\":"+json+"}";
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/doadd.do")
|
||||
public String doadd(HttpServletRequest request,Model model){
|
||||
return "/cqbytSampleValue/cqbytSampleValueAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/dosave.do")
|
||||
public String dosave(HttpServletRequest request,Model model,
|
||||
@ModelAttribute CqbytSampleValue cqbytSampleValue){
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String userId = cu.getId();
|
||||
cqbytSampleValue.setId(CommUtil.getUUID());
|
||||
int code = this.cqbytSampleValueService.save(cqbytSampleValue);
|
||||
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("新增失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/doedit.do")
|
||||
public String doedit(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
CqbytSampleValue cqbytSampleValue = this.cqbytSampleValueService.selectById(id);
|
||||
model.addAttribute("cqbytSampleValue", cqbytSampleValue);
|
||||
return "/cqbytSampleValue/cqbytSampleValueEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/doview.do")
|
||||
public String doview(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
CqbytSampleValue cqbytSampleValue = this.cqbytSampleValueService.selectById(id);
|
||||
model.addAttribute("cqbytSampleValue", cqbytSampleValue);
|
||||
return "/cqbytSampleValue/cqbytSampleValueView";
|
||||
}
|
||||
|
||||
@RequestMapping("/doupdate.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute CqbytSampleValue cqbytSampleValue){
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String userId = cu.getId();
|
||||
|
||||
int code = this.cqbytSampleValueService.update(cqbytSampleValue);
|
||||
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("更新失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodelete.do")
|
||||
public String dodelete(HttpServletRequest request,Model model,
|
||||
@ModelAttribute CqbytSampleValue cqbytSampleValue){
|
||||
Result result = new Result();
|
||||
int code = this.cqbytSampleValueService.deleteById(cqbytSampleValue.getId());
|
||||
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("删除失败");
|
||||
}
|
||||
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
@RequestMapping("/dodeletes.do")
|
||||
public String dodeletes(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="ids") String ids){
|
||||
String[] idArray = ids.split(",");
|
||||
try {
|
||||
for (int i = 0; i < idArray.length; i++) {
|
||||
this.cqbytSampleValueService.deleteById(idArray[i]);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Result result = Result.failed("删除失败");
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
Result result = Result.success(1);
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,174 @@
|
||||
package com.sipai.controller.cqbyt;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.entity.base.Result;
|
||||
import com.sipai.entity.cqbyt.CqbytVISITOUTINDATA;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.cqbyt.CqbytVISITOUTINDATAService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import com.sipai.tools.CommUtil;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/cqbyt/cqbytVISITOUTINDATA")
|
||||
public class CqbytVISITOUTINDATAController {
|
||||
@Resource
|
||||
private CqbytVISITOUTINDATAService cqbytVISITOUTINDATAService;
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
|
||||
@RequestMapping("/showlist.do")
|
||||
public String showlist(HttpServletRequest request,Model model){
|
||||
return "/cqbytSampleValue/cqbytVISITOUTINDATABrowse";
|
||||
}
|
||||
|
||||
@RequestMapping("/browseList.do")
|
||||
public String browseList(HttpServletRequest request,Model model){
|
||||
return "/cqbytSampleValue/cqbytVISITOUTINDATABrowse";
|
||||
}
|
||||
|
||||
@RequestMapping("/getList.do")
|
||||
public ModelAndView getList(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required=false) String sort,
|
||||
@RequestParam(value = "order", required=false) String order) {
|
||||
User cu=(User)request.getSession().getAttribute("cu");
|
||||
String companyId =request.getParameter("unitId");
|
||||
sort = " CREATETIME ";
|
||||
order = " desc ";
|
||||
String orderstr=" order by "+sort+" "+order;
|
||||
|
||||
String wherestr=" where 1=1";
|
||||
// if(companyId!=null && !companyId.isEmpty()){
|
||||
// //获取公司下所有子节点
|
||||
// List<Unit> units = unitService.getUnitChildrenById(companyId);
|
||||
// String companyids="";
|
||||
// for(Unit unit : units){
|
||||
// companyids += "'"+unit.getId()+"',";
|
||||
// }
|
||||
// if(companyids!=""){
|
||||
// companyids = companyids.substring(0, companyids.length()-1);
|
||||
// wherestr += " and unit_id in ("+companyids+") ";
|
||||
// }
|
||||
// }
|
||||
if(request.getParameter("search_name")!=null && !request.getParameter("search_name").isEmpty()){
|
||||
wherestr += " and name like '%"+request.getParameter("search_name")+"%' or cardid like '%"+request.getParameter("search_name")+"%'";
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<CqbytVISITOUTINDATA> list = this.cqbytVISITOUTINDATAService.selectListByWhere(wherestr+orderstr);
|
||||
PageInfo<CqbytVISITOUTINDATA> pi = new PageInfo<CqbytVISITOUTINDATA>(list);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
|
||||
String result="{\"total\":"+pi.getTotal()+",\"rows\":"+json+"}";
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
|
||||
@RequestMapping("/doadd.do")
|
||||
public String doadd(HttpServletRequest request,Model model){
|
||||
return "/cqbytVISITOUTINDATA/cqbytVISITOUTINDATAAdd";
|
||||
}
|
||||
|
||||
// @RequestMapping("/dosave.do")
|
||||
// public String dosave(HttpServletRequest request,Model model,
|
||||
// @ModelAttribute CqbytVISITOUTINDATA cqbytVISITOUTINDATA){
|
||||
// User cu = (User) request.getSession().getAttribute("cu");
|
||||
// String userId = cu.getId();
|
||||
// cqbytVISITOUTINDATA.setId(CommUtil.getUUID());
|
||||
// int code = this.cqbytVISITOUTINDATAService.save(cqbytVISITOUTINDATA);
|
||||
//
|
||||
// Result result = new Result();
|
||||
// if (code == Result.SUCCESS) {
|
||||
// result = Result.success(code);
|
||||
// } else {
|
||||
// result = Result.failed("新增失败");
|
||||
// }
|
||||
// model.addAttribute("result", CommUtil.toJson(result));
|
||||
// return "result";
|
||||
// }
|
||||
|
||||
@RequestMapping("/doedit.do")
|
||||
public String doedit(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
// CqbytVISITOUTINDATA cqbytVISITOUTINDATA = this.cqbytVISITOUTINDATAService.selectById(id);
|
||||
model.addAttribute("jpg", id);
|
||||
return "/cqbytSampleValue/cqbytVISITOUTINDATAEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/doview.do")
|
||||
public String doview(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
CqbytVISITOUTINDATA cqbytVISITOUTINDATA = this.cqbytVISITOUTINDATAService.selectById(id);
|
||||
model.addAttribute("cqbytVISITOUTINDATA", cqbytVISITOUTINDATA);
|
||||
return "/cqbytSampleValue/cqbytVISITOUTINDATAView";
|
||||
}
|
||||
|
||||
@RequestMapping("/doupdate.do")
|
||||
public String doupdate(HttpServletRequest request,Model model,
|
||||
@ModelAttribute CqbytVISITOUTINDATA cqbytVISITOUTINDATA){
|
||||
User cu = (User) request.getSession().getAttribute("cu");
|
||||
String userId = cu.getId();
|
||||
|
||||
int code = this.cqbytVISITOUTINDATAService.update(cqbytVISITOUTINDATA);
|
||||
|
||||
Result result = new Result();
|
||||
if (code == Result.SUCCESS) {
|
||||
result = Result.success(code);
|
||||
} else {
|
||||
result = Result.failed("更新失败");
|
||||
}
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
// @RequestMapping("/dodelete.do")
|
||||
// public String dodelete(HttpServletRequest request,Model model,
|
||||
// @ModelAttribute CqbytVISITOUTINDATA cqbytVISITOUTINDATA){
|
||||
// Result result = new Result();
|
||||
// int code = this.cqbytVISITOUTINDATAService.deleteById(cqbytVISITOUTINDATA.getId());
|
||||
//
|
||||
// if (code == Result.SUCCESS) {
|
||||
// result = Result.success(code);
|
||||
// } else {
|
||||
// result = Result.failed("删除失败");
|
||||
// }
|
||||
//
|
||||
// model.addAttribute("result", CommUtil.toJson(result));
|
||||
// return "result";
|
||||
// }
|
||||
|
||||
@RequestMapping("/dodeletes.do")
|
||||
public String dodeletes(HttpServletRequest request,Model model,
|
||||
@RequestParam(value="ids") String ids){
|
||||
String[] idArray = ids.split(",");
|
||||
try {
|
||||
for (int i = 0; i < idArray.length; i++) {
|
||||
this.cqbytVISITOUTINDATAService.deleteById(idArray[i]);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Result result = Result.failed("删除失败");
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
Result result = Result.success(1);
|
||||
model.addAttribute("result", CommUtil.toJson(result));
|
||||
return "result";
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
package com.sipai.controller.cqbyt;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sipai.dao.cqbyt.TestReportDao;
|
||||
import com.sipai.entity.cqbyt.TestReport;
|
||||
import com.sipai.entity.user.User;
|
||||
import com.sipai.service.cqbyt.TestReportService;
|
||||
import net.sf.json.JSONArray;
|
||||
import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
@Controller
|
||||
@RequestMapping({"/cqbyt/testReport"})
|
||||
public class TestReportController {
|
||||
@Resource
|
||||
private TestReportService testReportService;
|
||||
|
||||
@RequestMapping("/showlist.do")
|
||||
public String showlist(HttpServletRequest request,Model model){
|
||||
return "/cqbytSampleValue/testReportList";
|
||||
}
|
||||
@RequestMapping("/getList.do")
|
||||
public ModelAndView getList(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "page") Integer page,
|
||||
@RequestParam(value = "rows") Integer rows,
|
||||
@RequestParam(value = "sort", required=false) String sort,
|
||||
@RequestParam(value = "order", required=false) String order) {
|
||||
User cu=(User)request.getSession().getAttribute("cu");
|
||||
sort = " sampleDate ";
|
||||
if(order==null){
|
||||
order = " desc ";
|
||||
}
|
||||
String orderstr=" order by "+sort+" "+order;
|
||||
|
||||
String wherestr=" where 1=1 and name != 'SIPAIIS' ";
|
||||
if(request.getParameter("search_name")!=null && !request.getParameter("search_name").isEmpty()){
|
||||
wherestr += " and (name like '%"+request.getParameter("search_name")+"%' "
|
||||
+ "or code like '%"+request.getParameter("search_name")+"%' "
|
||||
+ "or classifyName like '%"+request.getParameter("search_name")+"%' "
|
||||
+ "or evaluateStandardName like '%"+request.getParameter("search_name")+"%' "
|
||||
+ "or sampleInstitutionName like '%"+request.getParameter("search_name")+"%' "
|
||||
+ "or beCheckedUnitName like '%"+request.getParameter("search_name")+"%' "
|
||||
+ "or waterPointName like '%"+request.getParameter("search_name")+"%' )";
|
||||
}
|
||||
//采样时间筛选
|
||||
if (request.getParameter("sdt")!= null && !request.getParameter("sdt").isEmpty()) {
|
||||
wherestr += " and sampleDate >= '"+request.getParameter("sdt")+"' ";
|
||||
}
|
||||
if (request.getParameter("edt")!= null && !request.getParameter("edt").isEmpty()) {
|
||||
wherestr += " and sampleDate <= '"+request.getParameter("edt")+"' ";
|
||||
}
|
||||
//采样点
|
||||
|
||||
if (request.getParameter("waterpointname")!= null && !request.getParameter("waterpointname").isEmpty()) {
|
||||
wherestr += " and [waterPointName] like '%"+request.getParameter("waterpointname")+"%' ";
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<TestReport> list = this.testReportService.selectListByWhere(wherestr+orderstr);
|
||||
PageInfo<TestReport> pi = new PageInfo<TestReport>(list);
|
||||
JSONArray json=JSONArray.fromObject(list);
|
||||
|
||||
String result="{\"total\":"+pi.getTotal()+",\"rows\":"+json+"}";
|
||||
model.addAttribute("result",result);
|
||||
return new ModelAndView("result");
|
||||
}
|
||||
@RequestMapping("/doview.do")
|
||||
public String doview(HttpServletRequest request,Model model,
|
||||
@RequestParam(value = "id") String id){
|
||||
TestReport testReport = this.testReportService.selectById(id);
|
||||
model.addAttribute("testReport", testReport);
|
||||
return "/cqbytSampleValue/testReportView";
|
||||
}
|
||||
}
|
||||
55
src/main/java/com/sipai/controller/cqbyt/YtsjController.java
Normal file
55
src/main/java/com/sipai/controller/cqbyt/YtsjController.java
Normal file
@ -0,0 +1,55 @@
|
||||
package com.sipai.controller.cqbyt;
|
||||
|
||||
import com.sipai.dao.cqbyt.YtsjDao;
|
||||
import com.sipai.entity.cqbyt.Ytsj;
|
||||
import com.sipai.service.cqbyt.YtsjService;
|
||||
import com.sipai.service.user.UnitService;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@Controller
|
||||
@RequestMapping({"/cqbyt/ytsj"})
|
||||
public class YtsjController {
|
||||
@Resource
|
||||
private YtsjService ytsjService;
|
||||
@Resource
|
||||
private YtsjDao ytsjDao;
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
|
||||
public YtsjController() {
|
||||
}
|
||||
|
||||
@RequestMapping({"/showpoint.do"})
|
||||
public String doedit(HttpServletRequest request, Model model, @RequestParam("name") String name) {
|
||||
Ytsj ytsj2 = new Ytsj();
|
||||
ytsj2.setWhere(" where name = '" + name + "' GROUP BY outputname");
|
||||
List<Ytsj> selectListByWhere1 = this.ytsjDao.selectListByWhere1(ytsj2);
|
||||
int a = 0;
|
||||
ArrayList<String> arrayList = new ArrayList();
|
||||
|
||||
for(int i = 0; i < selectListByWhere1.size(); ++i) {
|
||||
if (selectListByWhere1.get(i) != null) {
|
||||
String outputname = ((Ytsj)selectListByWhere1.get(i)).getOutputname();
|
||||
List<Ytsj> ytsj = this.ytsjService.selectListByWhere("where name = '" + name + "' and outputname = '" + outputname + "' ORDER BY tstamp DESC,factorname,valuetype ");
|
||||
model.addAttribute("outputname" + a, outputname);
|
||||
System.out.println(outputname);
|
||||
arrayList.add(outputname);
|
||||
model.addAttribute("list" + a, ytsj);
|
||||
System.out.println(ytsj.size());
|
||||
++a;
|
||||
}
|
||||
}
|
||||
|
||||
--a;
|
||||
model.addAttribute("stringlist", arrayList);
|
||||
model.addAttribute("a", a);
|
||||
return "/cqbytSampleValue/showYtsj";
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user