从源更新
This commit is contained in:
@@ -1,280 +0,0 @@
|
||||
package com.jsh.erp.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.constants.ExceptionConstants;
|
||||
import com.jsh.erp.datasource.entities.App;
|
||||
import com.jsh.erp.datasource.entities.User;
|
||||
import com.jsh.erp.datasource.entities.UserBusiness;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.service.app.AppService;
|
||||
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
||||
import com.jsh.erp.utils.BaseResponseInfo;
|
||||
import com.jsh.erp.utils.FileUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @author ji_sheng_hua 752*718*920
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/app")
|
||||
public class AppController {
|
||||
private Logger logger = LoggerFactory.getLogger(AppController.class);
|
||||
|
||||
@Value("${mybatis-plus.status}")
|
||||
private String mybatisPlusStatus;
|
||||
|
||||
@Resource
|
||||
private AppService appService;
|
||||
|
||||
@Resource
|
||||
private UserBusinessService userBusinessService;
|
||||
|
||||
/**
|
||||
* 根据用户查询有权限的app
|
||||
* @param userId
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/findAppByUserId")
|
||||
public JSONObject findAppByUserId(@RequestParam("userId") String userId, HttpServletRequest request)throws Exception {
|
||||
List<UserBusiness> roleList = userBusinessService.findRoleByUserId(userId);
|
||||
String roles = null;
|
||||
if(roleList!=null && roleList.size()>0 && roleList.get(0)!=null){
|
||||
roles = roleList.get(0).getValue();
|
||||
}
|
||||
if(roles!=null) {
|
||||
roles = roles.replaceAll("\\]\\[",",").replaceAll("\\]","").replaceAll("\\[",""); //转为逗号隔开的
|
||||
}
|
||||
List<UserBusiness> appList = userBusinessService.findAppByRoles(roles);
|
||||
String apps = null;
|
||||
if(appList!=null && appList.size()>0 && appList.get(0)!=null){
|
||||
apps = appList.get(0).getValue();
|
||||
}
|
||||
if(apps!=null) {
|
||||
apps = apps.replaceAll("\\]\\[",",").replaceAll("\\]","").replaceAll("\\[",""); //转为逗号隔开的
|
||||
}
|
||||
JSONObject obj = new JSONObject();
|
||||
List<App> dockList = appService.findAppInIds(apps,"dock");
|
||||
JSONArray dockArray = new JSONArray();
|
||||
if (null != dockList) {
|
||||
for (App app : dockList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("id", app.getId());
|
||||
item.put("title", app.getName());
|
||||
item.put("type", app.getType());
|
||||
item.put("icon", "../../upload/images/deskIcon/" + app.getIcon());
|
||||
item.put("url", app.getUrl());
|
||||
item.put("width", app.getWidth());
|
||||
item.put("height", app.getHeight());
|
||||
item.put("isresize", app.getResize());
|
||||
item.put("isopenmax", app.getOpenmax());
|
||||
item.put("isflash", app.getFlash());
|
||||
dockArray.add(item);
|
||||
}
|
||||
}
|
||||
obj.put("dock",dockArray);
|
||||
|
||||
List<App> deskList = appService.findAppInIds(apps,"desk");
|
||||
JSONArray deskArray = new JSONArray();
|
||||
if (null != deskList) {
|
||||
for (App app : deskList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("id", app.getId());
|
||||
item.put("title", app.getName());
|
||||
item.put("type", app.getType());
|
||||
item.put("icon", "../../upload/images/deskIcon/" + app.getIcon());
|
||||
item.put("url", "../../pages/common/menu.html?appID=" + app.getNumber() + "&id=" + app.getId());
|
||||
item.put("width", app.getWidth());
|
||||
item.put("height", app.getHeight());
|
||||
item.put("isresize", app.getResize());
|
||||
item.put("isopenmax", app.getOpenmax());
|
||||
item.put("isflash", app.getFlash());
|
||||
deskArray.add(item);
|
||||
}
|
||||
}
|
||||
obj.put("desk",deskArray);
|
||||
return obj;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/findDesk")
|
||||
public JSONObject findDesk(HttpServletRequest request)throws Exception {
|
||||
JSONObject obj = new JSONObject();
|
||||
List<App> dockList = appService.findDock();
|
||||
JSONArray dockArray = new JSONArray();
|
||||
if (null != dockList) {
|
||||
for (App app : dockList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("id", app.getId());
|
||||
item.put("title", app.getName());
|
||||
item.put("type", app.getType());
|
||||
item.put("icon", "../../upload/images/deskIcon/" + app.getIcon());
|
||||
item.put("url", app.getUrl());
|
||||
item.put("width", app.getWidth());
|
||||
item.put("height", app.getHeight());
|
||||
item.put("isresize", app.getResize());
|
||||
item.put("isopenmax", app.getOpenmax());
|
||||
item.put("isflash", app.getFlash());
|
||||
dockArray.add(item);
|
||||
}
|
||||
}
|
||||
obj.put("dock",dockArray);
|
||||
|
||||
List<App> deskList = appService.findDesk();
|
||||
JSONArray deskArray = new JSONArray();
|
||||
if (null != deskList) {
|
||||
for (App app : deskList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("id", app.getId());
|
||||
item.put("title", app.getName());
|
||||
item.put("type", app.getType());
|
||||
item.put("icon", "../../upload/images/deskIcon/" + app.getIcon());
|
||||
item.put("url", "../../pages/common/menu.html?appID=" + app.getNumber() + "&id=" + app.getId());
|
||||
item.put("width", app.getWidth());
|
||||
item.put("height", app.getHeight());
|
||||
item.put("isresize", app.getResize());
|
||||
item.put("isopenmax", app.getOpenmax());
|
||||
item.put("isflash", app.getFlash());
|
||||
deskArray.add(item);
|
||||
}
|
||||
}
|
||||
obj.put("desk",deskArray);
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色对应应用显示
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/findRoleAPP")
|
||||
public JSONArray findRoleAPP(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId,
|
||||
HttpServletRequest request)throws Exception {
|
||||
JSONArray arr = new JSONArray();
|
||||
try {
|
||||
List<App> dataListApp = appService.findRoleAPP();
|
||||
//开始拼接json数据
|
||||
JSONObject outer = new JSONObject();
|
||||
outer.put("id", 1);
|
||||
outer.put("text", "应用列表");
|
||||
outer.put("state", "open");
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if (null != dataListApp) {
|
||||
//根据条件从列表里面移除"系统管理"
|
||||
List<App> dataList = new ArrayList<App>();
|
||||
for (App appOne : dataListApp) {
|
||||
if(("open").equals(mybatisPlusStatus)){
|
||||
//从session中获取租户id
|
||||
String loginName = null;
|
||||
Object userInfo = request.getSession().getAttribute("user");
|
||||
if(userInfo != null) {
|
||||
User user = (User) userInfo;
|
||||
loginName = user.getLoginame();
|
||||
}
|
||||
if(("admin").equals(loginName)) {
|
||||
dataList.add(appOne);
|
||||
} else {
|
||||
if(!("系统管理").equals(appOne.getName())) {
|
||||
dataList.add(appOne);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dataList.add(appOne);
|
||||
}
|
||||
}
|
||||
|
||||
//筛选应用列表
|
||||
for (App app : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("id", app.getId());
|
||||
item.put("text", app.getName());
|
||||
//勾选判断1
|
||||
Boolean flag = false;
|
||||
try {
|
||||
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + app.getId().toString() + "]");
|
||||
} catch (Exception e) {
|
||||
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的应用:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
||||
}
|
||||
if (flag == true) {
|
||||
item.put("checked", true);
|
||||
}
|
||||
//结束
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
outer.put("children", dataArray);
|
||||
arr.add(outer);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传图片
|
||||
* @param fileInfo
|
||||
* @param request
|
||||
*/
|
||||
@PostMapping(value = "/uploadImg")
|
||||
public BaseResponseInfo uploadImg(MultipartFile fileInfo, @RequestParam("fileInfoName") String fileName,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
if (fileInfo != null) {
|
||||
String basePath = request.getSession().getServletContext().getRealPath("/"); //默认windows文件路径,linux环境下生成的目录与项目同级,而不是下级
|
||||
String path = basePath + "upload/images/deskIcon/"; //windows环境下的路径
|
||||
Properties pro = System.getProperties();
|
||||
String osName = pro.getProperty("os.name");//获得当前操作系统的名称
|
||||
if("Linux".equals(osName) || "linux".equals(osName) || "LINUX".equals(osName)){
|
||||
path = basePath + "/upload/images/deskIcon/"; //linux环境下的路径
|
||||
}
|
||||
FileUtils.SaveFileFromInputStream(fileInfo.getInputStream(), path, fileName);
|
||||
res.code = 200;
|
||||
res.data = "上传图片成功";
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取图片失败";
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "上传图片失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
/**
|
||||
* create by: qiankunpingtai
|
||||
* website:https://qiankunpingtai.cn
|
||||
* description:
|
||||
* 批量删除应用信息
|
||||
* create time: 2019/3/29 11:15
|
||||
* @Param: ids
|
||||
* @return java.lang.Object
|
||||
*/
|
||||
@RequestMapping(value = "/batchDeleteAppByIds")
|
||||
public Object batchDeleteAppByIds(@RequestParam("ids") String ids) throws Exception {
|
||||
|
||||
JSONObject result = ExceptionConstants.standardSuccess();
|
||||
int i= appService.batchDeleteAppByIds(ids);
|
||||
if(i<1){
|
||||
logger.error("异常码[{}],异常提示[{}],参数,ids[{}]",
|
||||
ExceptionConstants.APP_DELETE_FAILED_CODE,ExceptionConstants.APP_DELETE_FAILED_MSG,ids);
|
||||
throw new BusinessRunTimeException(ExceptionConstants.APP_DELETE_FAILED_CODE,
|
||||
ExceptionConstants.APP_DELETE_FAILED_MSG);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import com.jsh.erp.datasource.entities.Depot;
|
||||
import com.jsh.erp.datasource.entities.DepotEx;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.service.depot.DepotService;
|
||||
import com.jsh.erp.service.systemConfig.SystemConfigService;
|
||||
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
||||
import com.jsh.erp.utils.*;
|
||||
import org.slf4j.Logger;
|
||||
@@ -40,6 +41,9 @@ public class DepotController {
|
||||
@Resource
|
||||
private UserBusinessService userBusinessService;
|
||||
|
||||
@Resource
|
||||
private SystemConfigService systemConfigService;
|
||||
|
||||
@GetMapping(value = "/getAllList")
|
||||
public BaseResponseInfo getAllList(HttpServletRequest request) throws Exception{
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
@@ -102,6 +106,14 @@ public class DepotController {
|
||||
return arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户拥有权限的仓库列表
|
||||
* @param type
|
||||
* @param keyId
|
||||
* @param request
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "/findDepotByUserId")
|
||||
public JSONArray findDepotByUserId(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId,
|
||||
HttpServletRequest request) throws Exception{
|
||||
@@ -110,6 +122,7 @@ public class DepotController {
|
||||
List<Depot> dataList = depotService.findUserDepot();
|
||||
//开始拼接json数据
|
||||
if (null != dataList) {
|
||||
boolean depotFlag = systemConfigService.getDepotFlag();
|
||||
for (Depot depot : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
//勾选判断1
|
||||
@@ -119,7 +132,7 @@ public class DepotController {
|
||||
} catch (DataAccessException e) {
|
||||
logger.error(">>>>>>>>>>>>>>>>>查询用户对应的仓库:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
||||
}
|
||||
if (flag == true) {
|
||||
if (!depotFlag || flag) {
|
||||
item.put("id", depot.getId());
|
||||
item.put("depotName", depot.getName());
|
||||
arr.add(item);
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.jsh.erp.service.log.LogService;
|
||||
import com.jsh.erp.utils.BaseResponseInfo;
|
||||
import com.jsh.erp.utils.ErpInfo;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import com.jsh.erp.utils.Tools;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -30,6 +31,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
||||
import static com.jsh.erp.utils.Tools.getNow3;
|
||||
|
||||
/**
|
||||
* @author ji-sheng-hua 752*718*920
|
||||
@@ -39,9 +41,6 @@ import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
||||
public class DepotHeadController {
|
||||
private Logger logger = LoggerFactory.getLogger(DepotHeadController.class);
|
||||
|
||||
@Value("${mybatis-plus.status}")
|
||||
private String mybatisPlusStatus;
|
||||
|
||||
@Resource
|
||||
private DepotHeadService depotHeadService;
|
||||
|
||||
@@ -377,15 +376,12 @@ public class DepotHeadController {
|
||||
@RequestParam("deleted") String deleted,
|
||||
@RequestParam("updated") String updated, HttpServletRequest request) throws Exception{
|
||||
JSONObject result = ExceptionConstants.standardSuccess();
|
||||
if(("open").equals(mybatisPlusStatus)) {
|
||||
Long billsNumLimit = Long.parseLong(request.getSession().getAttribute("billsNumLimit").toString());
|
||||
Long count = depotHeadService.countDepotHead(null,null,null,null,null,null,null);
|
||||
if(count>= billsNumLimit) {
|
||||
throw new BusinessParamCheckingException(ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_CODE,
|
||||
ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_MSG);
|
||||
} else {
|
||||
depotHeadService.addDepotHeadAndDetail(beanJson,inserted,deleted,updated);
|
||||
}
|
||||
Long billsNumLimit = Long.parseLong(request.getSession().getAttribute("billsNumLimit").toString());
|
||||
Long tenantId = Long.parseLong(request.getSession().getAttribute("tenantId").toString());
|
||||
Long count = depotHeadService.countDepotHead(null,null,null,null,null,null,null);
|
||||
if(count>= billsNumLimit) {
|
||||
throw new BusinessParamCheckingException(ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_CODE,
|
||||
ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_MSG);
|
||||
} else {
|
||||
depotHeadService.addDepotHeadAndDetail(beanJson,inserted,deleted,updated);
|
||||
}
|
||||
@@ -405,12 +401,16 @@ public class DepotHeadController {
|
||||
* @return java.lang.Object
|
||||
*/
|
||||
@RequestMapping(value = "/updateDepotHeadAndDetail")
|
||||
public Object updateDepotHeadAndDetail(@RequestParam("id") Long id,@RequestParam("info") String beanJson,@RequestParam("inserted") String inserted,
|
||||
@RequestParam("deleted") String deleted,
|
||||
@RequestParam("updated") String updated,@RequestParam("preTotalPrice") BigDecimal preTotalPrice) throws Exception{
|
||||
|
||||
public Object updateDepotHeadAndDetail(@RequestParam("id") Long id,
|
||||
@RequestParam("info") String beanJson,
|
||||
@RequestParam("inserted") String inserted,
|
||||
@RequestParam("deleted") String deleted,
|
||||
@RequestParam("updated") String updated,
|
||||
@RequestParam("preTotalPrice") BigDecimal preTotalPrice,
|
||||
HttpServletRequest request) throws Exception{
|
||||
Long tenantId = Long.parseLong(request.getSession().getAttribute("tenantId").toString());
|
||||
JSONObject result = ExceptionConstants.standardSuccess();
|
||||
depotHeadService.updateDepotHeadAndDetail(id,beanJson,inserted,deleted,updated,preTotalPrice);
|
||||
depotHeadService.updateDepotHeadAndDetail(id,beanJson,inserted,deleted,updated,preTotalPrice,tenantId);
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
@@ -443,4 +443,39 @@ public class DepotHeadController {
|
||||
depotHeadService.batchDeleteDepotHeadAndDetail(ids);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计今日销售额、本月销售额、本月进货额
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getBuyAndSaleStatistics")
|
||||
public BaseResponseInfo getBuyAndSaleStatistics(HttpServletRequest request) {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
try {
|
||||
String today = Tools.getNow() + " 00:00:00";
|
||||
String firstDay = Tools.getCurrentMonth() + "-01 00:00:00";
|
||||
BigDecimal todaySale = depotHeadService.getBuyAndSaleStatistics("出库", "销售",
|
||||
1, today, getNow3()); //今日销售出库
|
||||
BigDecimal todayRetailSale = depotHeadService.getBuyAndSaleStatistics("出库", "销售",
|
||||
0, today, getNow3()); //今日零售出库
|
||||
BigDecimal monthSale = depotHeadService.getBuyAndSaleStatistics("出库", "销售",
|
||||
1,firstDay, getNow3()); //本月销售出库
|
||||
BigDecimal monthRetailSale = depotHeadService.getBuyAndSaleStatistics("出库", "销售",
|
||||
0,firstDay, getNow3()); //本月零售出库
|
||||
BigDecimal monthBuy = depotHeadService.getBuyAndSaleStatistics("入库", "采购",
|
||||
1, firstDay, getNow3()); //本月采购入库
|
||||
map.put("todaySale", todaySale.add(todayRetailSale));
|
||||
map.put("thisMonthSale", monthSale.add(monthRetailSale));
|
||||
map.put("thisMonthBuy", monthBuy);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,10 +24,8 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
||||
|
||||
@@ -98,30 +96,6 @@ public class DepotItemController {
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/findStockNumById")
|
||||
public String findStockNumById(
|
||||
@RequestParam("projectId") Integer pid,
|
||||
@RequestParam("materialId") String mId,
|
||||
HttpServletRequest request) throws Exception{
|
||||
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||
//存放数据json数组
|
||||
Long materialId = Long.valueOf(mId);
|
||||
Long depotId = Long.valueOf(pid);
|
||||
JSONArray dataArray = new JSONArray();
|
||||
JSONObject item = new JSONObject();
|
||||
/**查询指定仓库下指定材料的库存数量*/
|
||||
item.put("thisSum", depotItemService.getCurrentRepByMaterialIdAndDepotId(materialId,depotId));
|
||||
dataArray.add(item);
|
||||
objectMap.put("page", dataArray);
|
||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 只根据商品id查询库存数量
|
||||
* @param mId
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/findStockNumByMaterialId")
|
||||
public String findStockNumByMaterialId(
|
||||
@RequestParam("materialId") String mId,
|
||||
@@ -166,6 +140,7 @@ public class DepotItemController {
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Long tenantId = Long.parseLong(request.getSession().getAttribute("tenantId").toString());
|
||||
try {
|
||||
List<DepotItemVo4WithInfoEx> dataList = new ArrayList<DepotItemVo4WithInfoEx>();
|
||||
if(headerId != 0) {
|
||||
@@ -260,11 +235,11 @@ public class DepotItemController {
|
||||
return materialOther;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查找所有的明细
|
||||
* @param currentPage
|
||||
* @param pageSize
|
||||
* @param projectId
|
||||
* @param monthTime
|
||||
* @param headIds
|
||||
* @param materialIds
|
||||
@@ -272,10 +247,10 @@ public class DepotItemController {
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/findByAll")
|
||||
@RequestMapping(value = "/findByAll")
|
||||
public BaseResponseInfo findByAll(@RequestParam("currentPage") Integer currentPage,
|
||||
@RequestParam("pageSize") Integer pageSize,
|
||||
@RequestParam("projectId") Integer projectId,
|
||||
@RequestParam("depotId") Long depotId,
|
||||
@RequestParam("monthTime") String monthTime,
|
||||
@RequestParam("headIds") String headIds,
|
||||
@RequestParam("materialIds") String materialIds,
|
||||
@@ -283,45 +258,34 @@ public class DepotItemController {
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Long tenantId = Long.parseLong(request.getSession().getAttribute("tenantId").toString());
|
||||
try {
|
||||
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(headIds, materialIds, (currentPage-1)*pageSize, pageSize);
|
||||
String[] mpArr = mpList.split(",");
|
||||
int total = depotItemService.findByAllCount(headIds, materialIds);
|
||||
map.put("total", total);
|
||||
//存放数据json数组
|
||||
Integer pid = projectId;
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if (null != dataList) {
|
||||
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
BigDecimal prevSum = sumNumber("入库", pid, diEx.getMId(), monthTime, true).subtract(sumNumber("出库", pid, diEx.getMId(), monthTime, true));
|
||||
BigDecimal InSum = sumNumber("入库", pid, diEx.getMId(), monthTime, false);
|
||||
BigDecimal OutSum = sumNumber("出库", pid, diEx.getMId(), monthTime, false);
|
||||
BigDecimal prevPrice = sumPrice("入库", pid, diEx.getMId(), monthTime, true).subtract(sumPrice("出库", pid, diEx.getMId(), monthTime, true));
|
||||
BigDecimal InPrice = sumPrice("入库", pid, diEx.getMId(), monthTime, false);
|
||||
BigDecimal OutPrice = sumPrice("出库", pid, diEx.getMId(), monthTime, false);
|
||||
Long mId = diEx.getMId();
|
||||
String timeA = monthTime+"-01 00:00:00";
|
||||
String timeB = monthTime+"-31 23:59:59";
|
||||
item.put("MaterialName", diEx.getMName());
|
||||
item.put("MaterialModel", diEx.getMModel());
|
||||
//扩展信息
|
||||
String materialOther = getOtherInfo(mpArr, diEx);
|
||||
item.put("MaterialOther", materialOther);
|
||||
item.put("MaterialColor", diEx.getMColor());
|
||||
item.put("MaterialUnit", diEx.getMaterialUnit());
|
||||
BigDecimal unitPrice = BigDecimal.ZERO;
|
||||
if ((prevSum .add(InSum).subtract(OutSum)).compareTo(BigDecimal.ZERO)!= 0) {
|
||||
unitPrice = (prevPrice.add(InPrice).subtract(OutPrice)).divide(prevSum.add(InSum).subtract(OutSum),2, BigDecimal.ROUND_HALF_UP);
|
||||
/**
|
||||
* 2019-01-15通过除法算出金额后,保留两位小数
|
||||
* */
|
||||
DecimalFormat df = new DecimalFormat("#.00");
|
||||
unitPrice= new BigDecimal(df.format(unitPrice));
|
||||
}
|
||||
item.put("UnitPrice", unitPrice);
|
||||
item.put("prevSum", prevSum);
|
||||
item.put("InSum", InSum);
|
||||
item.put("OutSum", OutSum);
|
||||
item.put("thisSum", prevSum.add(InSum).subtract(OutSum));
|
||||
item.put("thisAllPrice", prevPrice.add(InPrice).subtract(OutPrice));
|
||||
item.put("unitName", getUName(diEx.getMaterialUnit(), diEx.getUName()));
|
||||
item.put("UnitPrice", getUnitPrice(diEx.getPresetPriceOne(), diEx.getPriceStrategy()));
|
||||
item.put("prevSum", depotItemService.getStockByParam(depotId,mId,null,timeA,tenantId));
|
||||
item.put("InSum", depotItemService.getInNumByParam(depotId,mId,timeA,timeB,tenantId));
|
||||
item.put("OutSum", depotItemService.getOutNumByParam(depotId,mId,timeA,timeB,tenantId));
|
||||
BigDecimal thisSum = depotItemService.getStockByParam(depotId,mId,null,null,tenantId);
|
||||
item.put("thisSum", thisSum);
|
||||
item.put("thisAllPrice", thisSum.multiply(getUnitPrice(diEx.getPresetPriceOne(), diEx.getPriceStrategy())));
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
@@ -336,32 +300,87 @@ public class DepotItemController {
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 导出excel表格
|
||||
* @param currentPage
|
||||
* @param pageSize
|
||||
* @param monthTime
|
||||
* @param headIds
|
||||
* @param materialIds
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/exportExcel")
|
||||
public void exportExcel(@RequestParam("currentPage") Integer currentPage,
|
||||
@RequestParam("pageSize") Integer pageSize,
|
||||
@RequestParam("depotId") Long depotId,
|
||||
@RequestParam("monthTime") String monthTime,
|
||||
@RequestParam("headIds") String headIds,
|
||||
@RequestParam("materialIds") String materialIds,
|
||||
HttpServletRequest request, HttpServletResponse response) {
|
||||
Long tenantId = Long.parseLong(request.getSession().getAttribute("tenantId").toString());
|
||||
try {
|
||||
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(headIds, materialIds, (currentPage-1)*pageSize, pageSize);
|
||||
//存放数据json数组
|
||||
String[] names = {"名称", "型号", "单位", "单价", "上月结存数量", "入库数量", "出库数量", "本月结存数量", "结存金额"};
|
||||
String title = "库存报表";
|
||||
List<String[]> objects = new ArrayList<String[]>();
|
||||
if (null != dataList) {
|
||||
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||
Long mId = diEx.getMId();
|
||||
String timeA = monthTime+"-01 00:00:00";
|
||||
String timeB = monthTime+"-31 23:59:59";
|
||||
String[] objs = new String[9];
|
||||
objs[0] = diEx.getMName().toString();
|
||||
objs[1] = diEx.getMModel().toString();
|
||||
objs[2] = diEx.getMaterialUnit().toString();
|
||||
objs[3] = getUnitPrice(diEx.getPresetPriceOne(), diEx.getPriceStrategy()).toString();
|
||||
objs[4] = depotItemService.getStockByParam(depotId,mId,null,timeA,tenantId).toString();
|
||||
objs[5] = depotItemService.getInNumByParam(depotId,mId,timeA,timeB,tenantId).toString();
|
||||
objs[6] = depotItemService.getOutNumByParam(depotId,mId,timeA,timeB,tenantId).toString();
|
||||
BigDecimal thisSum = depotItemService.getStockByParam(depotId,mId,null,null,tenantId);
|
||||
objs[7] = thisSum.toString();
|
||||
objs[8] = thisSum.multiply(getUnitPrice(diEx.getPresetPriceOne(), diEx.getPriceStrategy())).toString();
|
||||
objects.add(objs);
|
||||
}
|
||||
}
|
||||
File file = ExcelUtils.exportObjectsWithoutTitle(title, names, title, objects);
|
||||
ExportExecUtil.showExec(file, file.getName() + "-" + monthTime, response);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计总计金额
|
||||
* @param pid
|
||||
* @param monthTime
|
||||
* @param headIds
|
||||
* @param materialIds
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/totalCountMoney")
|
||||
public BaseResponseInfo totalCountMoney(@RequestParam("projectId") Integer pid,
|
||||
@RequestParam("monthTime") String monthTime,
|
||||
@RequestParam("headIds") String headIds,
|
||||
@RequestParam("materialIds") String materialIds,
|
||||
HttpServletRequest request) throws Exception{
|
||||
@RequestMapping(value = "/totalCountMoney")
|
||||
public BaseResponseInfo totalCountMoney(@RequestParam("depotId") Long depotId,
|
||||
@RequestParam("monthTime") String monthTime,
|
||||
@RequestParam("headIds") String headIds,
|
||||
@RequestParam("materialIds") String materialIds,
|
||||
HttpServletRequest request) throws Exception{
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Long tenantId = Long.parseLong(request.getSession().getAttribute("tenantId").toString());
|
||||
try {
|
||||
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(headIds, materialIds, null, null);
|
||||
BigDecimal thisAllPrice = BigDecimal.ZERO;
|
||||
if (null != dataList) {
|
||||
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||
BigDecimal prevPrice = sumPrice("入库", pid, diEx.getMId(), monthTime, true).subtract(sumPrice("出库", pid, diEx.getMId(), monthTime, true));
|
||||
BigDecimal InPrice = sumPrice("入库", pid, diEx.getMId(), monthTime, false);
|
||||
BigDecimal OutPrice = sumPrice("出库", pid, diEx.getMId(), monthTime, false);
|
||||
thisAllPrice = thisAllPrice .add(prevPrice.add(InPrice).subtract(OutPrice));
|
||||
Long mId = diEx.getMId();
|
||||
BigDecimal thisSum = depotItemService.getStockByParam(depotId,mId,null,null,tenantId);
|
||||
BigDecimal unitPrice = getUnitPrice(diEx.getPresetPriceOne(), diEx.getPriceStrategy());
|
||||
thisAllPrice = thisAllPrice.add(thisSum.multiply(unitPrice));
|
||||
}
|
||||
}
|
||||
map.put("totalCount", thisAllPrice);
|
||||
@@ -375,6 +394,8 @@ public class DepotItemController {
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 进货统计
|
||||
* @param currentPage
|
||||
@@ -499,134 +520,6 @@ public class DepotItemController {
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel表格
|
||||
* @param currentPage
|
||||
* @param pageSize
|
||||
* @param projectId
|
||||
* @param monthTime
|
||||
* @param headIds
|
||||
* @param materialIds
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/exportExcel")
|
||||
public void exportExcel(@RequestParam("currentPage") Integer currentPage,
|
||||
@RequestParam("pageSize") Integer pageSize,
|
||||
@RequestParam("projectId") Integer projectId,
|
||||
@RequestParam("monthTime") String monthTime,
|
||||
@RequestParam("headIds") String headIds,
|
||||
@RequestParam("materialIds") String materialIds,
|
||||
HttpServletRequest request, HttpServletResponse response)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String message = "成功";
|
||||
try {
|
||||
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(headIds, materialIds, (currentPage-1)*pageSize, pageSize);
|
||||
//存放数据json数组
|
||||
Integer pid = projectId;
|
||||
String[] names = {"名称", "型号", "单位", "单价", "上月结存数量", "入库数量", "出库数量", "本月结存数量", "结存金额"};
|
||||
String title = "库存报表";
|
||||
List<String[]> objects = new ArrayList<String[]>();
|
||||
if (null != dataList) {
|
||||
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||
String[] objs = new String[9];
|
||||
BigDecimal prevSum = sumNumber("入库", pid, diEx.getMId(), monthTime, true).subtract(sumNumber("出库", pid, diEx.getMId(), monthTime, true));
|
||||
BigDecimal InSum = sumNumber("入库", pid, diEx.getMId(), monthTime, false);
|
||||
BigDecimal OutSum = sumNumber("出库", pid, diEx.getMId(), monthTime, false);
|
||||
BigDecimal prevPrice = sumPrice("入库", pid, diEx.getMId(), monthTime, true).subtract(sumPrice("出库", pid, diEx.getMId(), monthTime, true));
|
||||
BigDecimal InPrice = sumPrice("入库", pid, diEx.getMId(), monthTime, false);
|
||||
BigDecimal OutPrice = sumPrice("出库", pid, diEx.getMId(), monthTime, false);
|
||||
BigDecimal unitPrice = BigDecimal.ZERO;
|
||||
if ((prevSum.add(InSum).subtract(OutSum)).compareTo(BigDecimal.ZERO) != 0) {
|
||||
unitPrice = (prevPrice.add(InPrice).subtract(OutPrice)).divide(prevSum.add(InSum).subtract(OutSum),2, BigDecimal.ROUND_HALF_UP);
|
||||
/**
|
||||
* 2019-01-15通过除法算出金额后,保留两位小数
|
||||
* */
|
||||
DecimalFormat df = new DecimalFormat("#.00");
|
||||
unitPrice= new BigDecimal(df.format(unitPrice));
|
||||
}
|
||||
BigDecimal thisSum = prevSum.add(InSum).subtract(OutSum);
|
||||
BigDecimal thisAllPrice = prevPrice.add(InPrice).subtract(OutPrice);
|
||||
objs[0] = diEx.getMName().toString();
|
||||
objs[1] = diEx.getMModel().toString();
|
||||
objs[2] = diEx.getMaterialUnit().toString();
|
||||
objs[3] = unitPrice.toString();
|
||||
objs[4] = prevSum.toString();
|
||||
objs[5] = InSum.toString();
|
||||
objs[6] = OutSum.toString();
|
||||
objs[7] = thisSum.toString();
|
||||
objs[8] = thisAllPrice.toString();
|
||||
objects.add(objs);
|
||||
}
|
||||
}
|
||||
File file = ExcelUtils.exportObjectsWithoutTitle(title, names, title, objects);
|
||||
ExportExecUtil.showExec(file, file.getName() + "-" + monthTime, response);
|
||||
res.code = 200;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
message = "导出失败";
|
||||
res.code = 500;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 数量合计
|
||||
*
|
||||
* @param type
|
||||
* @param MId
|
||||
* @param MonthTime
|
||||
* @param isPrev
|
||||
* @return
|
||||
*/
|
||||
public BigDecimal sumNumber(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev)throws Exception {
|
||||
BigDecimal sumNumber = BigDecimal.ZERO;
|
||||
try {
|
||||
BigDecimal sum = depotItemService.findByType(type, ProjectId, MId, MonthTime, isPrev);
|
||||
if(sum != null) {
|
||||
sumNumber = sum;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return sumNumber;
|
||||
}
|
||||
|
||||
public BigDecimal assembleNumber(String subType, String mType, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) throws Exception{
|
||||
BigDecimal assembleNumber = BigDecimal.ZERO;
|
||||
try {
|
||||
BigDecimal sum = depotItemService.findAssembleByType(subType, mType, ProjectId, MId, MonthTime, isPrev);
|
||||
if(sum != null) {
|
||||
assembleNumber = sum;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return assembleNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* 价格合计
|
||||
*
|
||||
* @param type
|
||||
* @param MId
|
||||
* @param MonthTime
|
||||
* @param isPrev
|
||||
* @return
|
||||
*/
|
||||
public BigDecimal sumPrice(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) throws Exception{
|
||||
BigDecimal sumPrice = BigDecimal.ZERO;
|
||||
try {
|
||||
BigDecimal sum = depotItemService.findPriceByType(type, ProjectId, MId, MonthTime, isPrev);
|
||||
if(sum != null) {
|
||||
sumPrice = sum;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return sumPrice;
|
||||
}
|
||||
|
||||
public BigDecimal sumNumberBuyOrSale(String type, String subType, Long MId, String MonthTime)throws Exception {
|
||||
BigDecimal sumNumber = BigDecimal.ZERO;
|
||||
@@ -655,6 +548,30 @@ public class DepotItemController {
|
||||
}
|
||||
return sumPrice;
|
||||
}
|
||||
/**
|
||||
* 获取单价
|
||||
* @param presetPriceOne
|
||||
* @param priceStrategy
|
||||
* @return
|
||||
*/
|
||||
public BigDecimal getUnitPrice(BigDecimal presetPriceOne, String priceStrategy) {
|
||||
BigDecimal unitPrice = BigDecimal.ZERO;
|
||||
if(presetPriceOne != null) {
|
||||
DecimalFormat df = new DecimalFormat("#.00");
|
||||
unitPrice = new BigDecimal(df.format(presetPriceOne));
|
||||
} else {
|
||||
JSONArray priceArr = JSONArray.parseArray(priceStrategy);
|
||||
if(priceArr!=null && priceArr.get(0)!=null) {
|
||||
JSONObject priceObj = JSONObject.parseObject(priceArr.get(0).toString());
|
||||
BigDecimal basicPresetPriceOne = priceObj.getJSONObject("basic").getBigDecimal("PresetPriceOne");
|
||||
if(basicPresetPriceOne!=null) {
|
||||
unitPrice = basicPresetPriceOne;
|
||||
}
|
||||
}
|
||||
}
|
||||
return unitPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* create by: qiankunpingtai
|
||||
* website:https://qiankunpingtai.cn
|
||||
@@ -707,7 +624,6 @@ public class DepotItemController {
|
||||
* @param currentPage
|
||||
* @param pageSize
|
||||
* @param projectId
|
||||
* @param monthTime
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
@@ -753,4 +669,62 @@ public class DepotItemController {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计采购或销售的总金额
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping(value = "/buyOrSalePrice")
|
||||
public BaseResponseInfo buyOrSalePrice(HttpServletRequest request, HttpServletResponse response)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String message = "成功";
|
||||
try {
|
||||
Date date = new Date();
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM");
|
||||
String dateString = formatter.format(date);
|
||||
List<String> list = Tools.getSixMonth(dateString);
|
||||
map.put("monthList", list);
|
||||
List<BigDecimal> buyPriceList = new ArrayList<BigDecimal>();
|
||||
for(String month: list) {
|
||||
BigDecimal outPrice = depotItemService.inOrOutPrice("入库", "采购", month);
|
||||
BigDecimal inPrice = depotItemService.inOrOutPrice("出库", "采购退货", month);
|
||||
buyPriceList.add(outPrice.subtract(inPrice));
|
||||
}
|
||||
map.put("buyPriceList", buyPriceList);
|
||||
List<BigDecimal> salePriceList = new ArrayList<BigDecimal>();
|
||||
for(String month: list) {
|
||||
BigDecimal outPrice = depotItemService.inOrOutPrice("出库", "销售", month);
|
||||
BigDecimal inPrice = depotItemService.inOrOutPrice("入库", "销售退货", month);
|
||||
salePriceList.add(outPrice.subtract(inPrice));
|
||||
}
|
||||
map.put("salePriceList", salePriceList);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
message = "统计失败";
|
||||
res.code = 500;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
/**
|
||||
* 获取单位
|
||||
* @param materialUnit
|
||||
* @param uName
|
||||
* @return
|
||||
*/
|
||||
public String getUName(String materialUnit, String uName) {
|
||||
String unitName = null;
|
||||
if(!StringUtil.isEmpty(materialUnit)) {
|
||||
unitName = materialUnit;
|
||||
} else if(!StringUtil.isEmpty(uName)) {
|
||||
unitName = uName.substring(0,uName.indexOf(","));
|
||||
}
|
||||
return unitName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,338 +1,330 @@
|
||||
package com.jsh.erp.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.constants.ExceptionConstants;
|
||||
import com.jsh.erp.datasource.entities.Functions;
|
||||
import com.jsh.erp.datasource.entities.User;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.service.functions.FunctionsService;
|
||||
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
||||
import com.jsh.erp.utils.BaseResponseInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author ji-sheng-hua 华夏ERP
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/functions")
|
||||
public class FunctionsController {
|
||||
private Logger logger = LoggerFactory.getLogger(FunctionsController.class);
|
||||
|
||||
@Value("${mybatis-plus.status}")
|
||||
private String mybatisPlusStatus;
|
||||
|
||||
@Resource
|
||||
private FunctionsService functionsService;
|
||||
|
||||
@Resource
|
||||
private UserBusinessService userBusinessService;
|
||||
|
||||
@PostMapping(value = "/findMenu")
|
||||
public JSONArray findMenu(@RequestParam(value="pNumber") String pNumber,
|
||||
@RequestParam(value="hasFunctions") String hasFunctions,
|
||||
HttpServletRequest request)throws Exception {
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
try {
|
||||
String fc = hasFunctions; //当前用户所拥有的功能列表,格式如:[1][2][5]
|
||||
List<Functions> dataList = functionsService.getRoleFunctions(pNumber);
|
||||
if (null != dataList) {
|
||||
for (Functions functions : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("id", functions.getId());
|
||||
List<Functions> dataList1 = functionsService.getRoleFunctions(functions.getNumber());
|
||||
JSONArray dataArray1 = new JSONArray();
|
||||
if (dataList1.size() != 0) {
|
||||
item.put("text", functions.getName()); //是目录就没链接
|
||||
for (Functions functions1 : dataList1) {
|
||||
item.put("state", "open"); //如果不为空,节点展开
|
||||
JSONObject item1 = new JSONObject();
|
||||
List<Functions> dataList2 = functionsService.getRoleFunctions(functions1.getNumber());
|
||||
if (fc.indexOf("[" + functions1.getId().toString() + "]") != -1 || dataList2.size() != 0) {
|
||||
item1.put("id", functions1.getId());
|
||||
JSONArray dataArray2 = new JSONArray();
|
||||
if (dataList2.size() != 0) {
|
||||
item1.put("text", functions1.getName());//是目录就没链接
|
||||
for (Functions functions2 : dataList2) {
|
||||
item1.put("state", "closed"); //如果不为空,节点不展开
|
||||
JSONObject item2 = new JSONObject();
|
||||
List<Functions> dataList3 = functionsService.getRoleFunctions(functions2.getNumber());
|
||||
if (fc.indexOf("[" + functions2.getId().toString() + "]") != -1 || dataList3.size() != 0) {
|
||||
item2.put("id", functions2.getId());
|
||||
JSONArray dataArray3 = new JSONArray();
|
||||
if (dataList3.size() != 0) {
|
||||
item2.put("text", functions2.getName());//是目录就没链接
|
||||
for (Functions functions3 : dataList3) {
|
||||
item2.put("state", "closed"); //如果不为空,节点不展开
|
||||
JSONObject item3 = new JSONObject();
|
||||
item3.put("id", functions3.getId());
|
||||
item3.put("text", functions3.getName());
|
||||
//
|
||||
dataArray3.add(item3);
|
||||
item2.put("children", dataArray3);
|
||||
}
|
||||
} else {
|
||||
//不是目录,有链接
|
||||
item2.put("text", "<a onclick=\"NewTab('" + functions2.getName() + "','" + functions2.getUrl() + "','" + functions2.getId() + "')\">" + functions2.getName() + "</a>");
|
||||
dataArray2.add(item2);
|
||||
item1.put("children", dataArray2);
|
||||
}
|
||||
} else {
|
||||
//不是目录,有链接
|
||||
//item2.put("text", "<a onclick=\"NewTab('" + functions2.getName() + "','" + functions2.getUrl() + "','" + functions2.getId() + "')\">" + functions2.getName() + "</a>");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//不是目录,有链接
|
||||
item1.put("text", "<a onclick=\"NewTab('" + functions1.getName() + "','" + functions1.getUrl() + "','" + functions1.getId() + "')\">" + functions1.getName() + "</a>");
|
||||
dataArray1.add(item1);
|
||||
item.put("children", dataArray1);
|
||||
}
|
||||
} else {
|
||||
//不是目录,有链接
|
||||
//item1.put("text", "<a onclick=\"NewTab('" + functions1.getName() + "','" + functions1.getUrl() + "','" + functions1.getId() + "')\">" + functions1.getName() + "</a>");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//不是目录,有链接
|
||||
item.put("text", "<a onclick=\"NewTab('" + functions.getName() + "','" + functions.getUrl() + "','" + functions.getId() + "')\">" + functions.getName() + "</a>");
|
||||
}
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
} catch (DataAccessException e) {
|
||||
logger.error(">>>>>>>>>>>>>>>>>>>查找应用异常", e);
|
||||
}
|
||||
return dataArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色对应功能显示
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/findRoleFunctions")
|
||||
public JSONArray findRoleFunctions(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId,
|
||||
HttpServletRequest request)throws Exception {
|
||||
JSONArray arr = new JSONArray();
|
||||
try {
|
||||
List<Functions> dataListFun = functionsService.findRoleFunctions("0");
|
||||
//开始拼接json数据
|
||||
JSONObject outer = new JSONObject();
|
||||
outer.put("id", 1);
|
||||
outer.put("text", "功能列表");
|
||||
outer.put("state", "open");
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if (null != dataListFun) {
|
||||
//根据条件从列表里面移除"系统管理"
|
||||
List<Functions> dataList = new ArrayList<Functions>();
|
||||
for (Functions fun : dataListFun) {
|
||||
if(("open").equals(mybatisPlusStatus)){
|
||||
//从session中获取租户id
|
||||
String loginName = null;
|
||||
Object userInfo = request.getSession().getAttribute("user");
|
||||
if(userInfo != null) {
|
||||
User user = (User) userInfo;
|
||||
loginName = user.getLoginame();
|
||||
}
|
||||
if(("admin").equals(loginName)) {
|
||||
dataList.add(fun);
|
||||
} else {
|
||||
/**
|
||||
* create by: qiankunpingtai
|
||||
* create time: 2019/4/28 11:24
|
||||
* website:https://qiankunpingtai.cn
|
||||
* description:
|
||||
* 为什么要移除系统管理?
|
||||
* 我觉得应该允许多级管理的存在
|
||||
*/
|
||||
// if(!("系统管理").equals(fun.getName())) {
|
||||
// dataList.add(fun);
|
||||
// }
|
||||
dataList.add(fun);
|
||||
}
|
||||
} else {
|
||||
dataList.add(fun);
|
||||
}
|
||||
}
|
||||
|
||||
//筛选功能列表
|
||||
for (Functions functions : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("id", functions.getId());
|
||||
item.put("text", functions.getName());
|
||||
|
||||
//勾选判断1
|
||||
Boolean flag = false;
|
||||
try {
|
||||
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + functions.getId().toString() + "]");
|
||||
} catch (Exception e) {
|
||||
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
||||
}
|
||||
if (flag == true) {
|
||||
item.put("checked", true);
|
||||
}
|
||||
//结束
|
||||
|
||||
List<Functions> dataList1 = functionsService.findRoleFunctions(functions.getNumber());
|
||||
JSONArray dataArray1 = new JSONArray();
|
||||
if (null != dataList1) {
|
||||
|
||||
for (Functions functions1 : dataList1) {
|
||||
item.put("state", "open"); //如果不为空,节点不展开
|
||||
JSONObject item1 = new JSONObject();
|
||||
item1.put("id", functions1.getId());
|
||||
item1.put("text", functions1.getName());
|
||||
|
||||
//勾选判断2
|
||||
//Boolean flag = false;
|
||||
try {
|
||||
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + functions1.getId().toString() + "]");
|
||||
} catch (Exception e) {
|
||||
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
||||
}
|
||||
if (flag == true) {
|
||||
item1.put("checked", true);
|
||||
}
|
||||
//结束
|
||||
|
||||
List<Functions> dataList2 = functionsService.findRoleFunctions(functions1.getNumber());
|
||||
JSONArray dataArray2 = new JSONArray();
|
||||
if (null != dataList2) {
|
||||
|
||||
for (Functions functions2 : dataList2) {
|
||||
item1.put("state", "closed"); //如果不为空,节点不展开
|
||||
JSONObject item2 = new JSONObject();
|
||||
item2.put("id", functions2.getId());
|
||||
item2.put("text", functions2.getName());
|
||||
|
||||
//勾选判断3
|
||||
//Boolean flag = false;
|
||||
try {
|
||||
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + functions2.getId().toString() + "]");
|
||||
} catch (Exception e) {
|
||||
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
||||
}
|
||||
if (flag == true) {
|
||||
item2.put("checked", true);
|
||||
}
|
||||
//结束
|
||||
|
||||
List<Functions> dataList3 = functionsService.findRoleFunctions(functions2.getNumber());
|
||||
JSONArray dataArray3 = new JSONArray();
|
||||
if (null != dataList3) {
|
||||
|
||||
for (Functions functions3 : dataList3) {
|
||||
item2.put("state", "closed"); //如果不为空,节点不展开
|
||||
JSONObject item3 = new JSONObject();
|
||||
item3.put("id", functions3.getId());
|
||||
item3.put("text", functions3.getName());
|
||||
|
||||
//勾选判断4
|
||||
//Boolean flag = false;
|
||||
try {
|
||||
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + functions3.getId().toString() + "]");
|
||||
} catch (Exception e) {
|
||||
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
||||
}
|
||||
if (flag == true) {
|
||||
item3.put("checked", true);
|
||||
}
|
||||
//结束
|
||||
|
||||
dataArray3.add(item3);
|
||||
item2.put("children", dataArray3);
|
||||
}
|
||||
}
|
||||
|
||||
dataArray2.add(item2);
|
||||
item1.put("children", dataArray2);
|
||||
}
|
||||
}
|
||||
|
||||
dataArray1.add(item1);
|
||||
item.put("children", dataArray1);
|
||||
}
|
||||
|
||||
}
|
||||
dataArray.add(item);
|
||||
}
|
||||
outer.put("children", dataArray);
|
||||
arr.add(outer);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id列表查找功能信息
|
||||
* @param functionsIds
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/findByIds")
|
||||
public BaseResponseInfo findByIds(@RequestParam("functionsIds") String functionsIds,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
List<Functions> dataList = functionsService.findByIds(functionsIds);
|
||||
JSONObject outer = new JSONObject();
|
||||
outer.put("total", dataList.size());
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if (null != dataList) {
|
||||
for (Functions functions : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("Id", functions.getId());
|
||||
item.put("Name", functions.getName());
|
||||
item.put("PushBtn", functions.getPushbtn());
|
||||
item.put("op", 1);
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
outer.put("rows", dataArray);
|
||||
res.code = 200;
|
||||
res.data = outer;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
/**
|
||||
* create by: qiankunpingtai
|
||||
* website:https://qiankunpingtai.cn
|
||||
* description:
|
||||
* 批量删除功能模块信息
|
||||
* create time: 2019/3/29 11:15
|
||||
* @Param: ids
|
||||
* @return java.lang.Object
|
||||
*/
|
||||
@RequestMapping(value = "/batchDeleteFunctionsByIds")
|
||||
public Object batchDeleteFunctionsByIds(@RequestParam("ids") String ids) throws Exception {
|
||||
JSONObject result = ExceptionConstants.standardSuccess();
|
||||
int i= functionsService.batchDeleteFunctionsByIds(ids);
|
||||
if(i<1){
|
||||
logger.error("异常码[{}],异常提示[{}],参数,ids[{}]",
|
||||
ExceptionConstants.FUNCTIONS_DELETE_FAILED_CODE,ExceptionConstants.FUNCTIONS_DELETE_FAILED_MSG,ids);
|
||||
throw new BusinessRunTimeException(ExceptionConstants.FUNCTIONS_DELETE_FAILED_CODE,
|
||||
ExceptionConstants.FUNCTIONS_DELETE_FAILED_MSG);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
package com.jsh.erp.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.constants.ExceptionConstants;
|
||||
import com.jsh.erp.datasource.entities.Functions;
|
||||
import com.jsh.erp.datasource.entities.User;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.service.functions.FunctionsService;
|
||||
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
||||
import com.jsh.erp.utils.BaseResponseInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author ji-sheng-hua 华夏ERP
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/functions")
|
||||
public class FunctionsController {
|
||||
private Logger logger = LoggerFactory.getLogger(FunctionsController.class);
|
||||
|
||||
@Resource
|
||||
private FunctionsService functionsService;
|
||||
|
||||
@Resource
|
||||
private UserBusinessService userBusinessService;
|
||||
|
||||
@PostMapping(value = "/findMenu")
|
||||
public JSONArray findMenu(@RequestParam(value="pNumber") String pNumber,
|
||||
@RequestParam(value="hasFunctions") String hasFunctions,
|
||||
HttpServletRequest request)throws Exception {
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
try {
|
||||
String fc = hasFunctions; //当前用户所拥有的功能列表,格式如:[1][2][5]
|
||||
List<Functions> dataList = functionsService.getRoleFunctions(pNumber);
|
||||
if (null != dataList) {
|
||||
for (Functions functions : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("id", functions.getId());
|
||||
List<Functions> dataList1 = functionsService.getRoleFunctions(functions.getNumber());
|
||||
JSONArray dataArray1 = new JSONArray();
|
||||
if (dataList1.size() != 0) {
|
||||
item.put("text", functions.getName()); //是目录就没链接
|
||||
item.put("icon", functions.getIcon());
|
||||
for (Functions functions1 : dataList1) {
|
||||
item.put("state", "open"); //如果不为空,节点展开
|
||||
JSONObject item1 = new JSONObject();
|
||||
List<Functions> dataList2 = functionsService.getRoleFunctions(functions1.getNumber());
|
||||
if (fc.indexOf("[" + functions1.getId().toString() + "]") != -1 || dataList2.size() != 0) {
|
||||
item1.put("id", functions1.getId());
|
||||
JSONArray dataArray2 = new JSONArray();
|
||||
if (dataList2.size() != 0) {
|
||||
item1.put("text", functions1.getName());//是目录就没链接
|
||||
item1.put("icon", functions1.getIcon());
|
||||
for (Functions functions2 : dataList2) {
|
||||
item1.put("state", "closed"); //如果不为空,节点不展开
|
||||
JSONObject item2 = new JSONObject();
|
||||
List<Functions> dataList3 = functionsService.getRoleFunctions(functions2.getNumber());
|
||||
if (fc.indexOf("[" + functions2.getId().toString() + "]") != -1 || dataList3.size() != 0) {
|
||||
item2.put("id", functions2.getId());
|
||||
JSONArray dataArray3 = new JSONArray();
|
||||
if (dataList3.size() != 0) {
|
||||
item2.put("text", functions2.getName());//是目录就没链接
|
||||
item2.put("icon", functions2.getIcon());
|
||||
for (Functions functions3 : dataList3) {
|
||||
item2.put("state", "closed"); //如果不为空,节点不展开
|
||||
JSONObject item3 = new JSONObject();
|
||||
item3.put("id", functions3.getId());
|
||||
item3.put("text", functions3.getName());
|
||||
item3.put("icon", functions3.getIcon());
|
||||
//
|
||||
dataArray3.add(item3);
|
||||
item2.put("children", dataArray3);
|
||||
}
|
||||
} else {
|
||||
//不是目录,有链接
|
||||
item2.put("text", functions2.getName());
|
||||
item2.put("icon", functions2.getIcon());
|
||||
item2.put("url", functions2.getUrl());
|
||||
dataArray2.add(item2);
|
||||
item1.put("children", dataArray2);
|
||||
}
|
||||
} else {
|
||||
//不是目录,有链接
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//不是目录,有链接
|
||||
item1.put("text", functions1.getName());
|
||||
item1.put("icon", functions1.getIcon());
|
||||
item1.put("url", functions1.getUrl());
|
||||
dataArray1.add(item1);
|
||||
item.put("children", dataArray1);
|
||||
}
|
||||
} else {
|
||||
//不是目录,有链接
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//不是目录,有链接
|
||||
item.put("text", functions.getName());
|
||||
item.put("icon", functions.getIcon());
|
||||
item.put("url", functions.getUrl());
|
||||
}
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
} catch (DataAccessException e) {
|
||||
logger.error(">>>>>>>>>>>>>>>>>>>查找应用异常", e);
|
||||
}
|
||||
return dataArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色对应功能显示
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/findRoleFunctions")
|
||||
public JSONArray findRoleFunctions(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId,
|
||||
HttpServletRequest request)throws Exception {
|
||||
JSONArray arr = new JSONArray();
|
||||
try {
|
||||
List<Functions> dataListFun = functionsService.findRoleFunctions("0");
|
||||
//开始拼接json数据
|
||||
JSONObject outer = new JSONObject();
|
||||
outer.put("id", 1);
|
||||
outer.put("text", "功能列表");
|
||||
outer.put("state", "open");
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if (null != dataListFun) {
|
||||
//根据条件从列表里面移除"系统管理"
|
||||
List<Functions> dataList = new ArrayList<Functions>();
|
||||
for (Functions fun : dataListFun) {
|
||||
//从session中获取租户id
|
||||
String loginName = null;
|
||||
Object userInfo = request.getSession().getAttribute("user");
|
||||
if(userInfo != null) {
|
||||
User user = (User) userInfo;
|
||||
loginName = user.getLoginame();
|
||||
}
|
||||
if(("admin").equals(loginName)) {
|
||||
dataList.add(fun);
|
||||
} else {
|
||||
if(!("系统管理").equals(fun.getName())) {
|
||||
dataList.add(fun);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//筛选功能列表
|
||||
for (Functions functions : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("id", functions.getId());
|
||||
item.put("text", functions.getName());
|
||||
|
||||
//勾选判断1
|
||||
Boolean flag = false;
|
||||
try {
|
||||
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + functions.getId().toString() + "]");
|
||||
} catch (Exception e) {
|
||||
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
||||
}
|
||||
if (flag == true) {
|
||||
item.put("checked", true);
|
||||
}
|
||||
//结束
|
||||
|
||||
List<Functions> dataList1 = functionsService.findRoleFunctions(functions.getNumber());
|
||||
JSONArray dataArray1 = new JSONArray();
|
||||
if (null != dataList1) {
|
||||
|
||||
for (Functions functions1 : dataList1) {
|
||||
item.put("state", "open"); //如果不为空,节点不展开
|
||||
JSONObject item1 = new JSONObject();
|
||||
item1.put("id", functions1.getId());
|
||||
item1.put("text", functions1.getName());
|
||||
|
||||
//勾选判断2
|
||||
//Boolean flag = false;
|
||||
try {
|
||||
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + functions1.getId().toString() + "]");
|
||||
} catch (Exception e) {
|
||||
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
||||
}
|
||||
if (flag == true) {
|
||||
item1.put("checked", true);
|
||||
}
|
||||
//结束
|
||||
|
||||
List<Functions> dataList2 = functionsService.findRoleFunctions(functions1.getNumber());
|
||||
JSONArray dataArray2 = new JSONArray();
|
||||
if (null != dataList2) {
|
||||
|
||||
for (Functions functions2 : dataList2) {
|
||||
item1.put("state", "closed"); //如果不为空,节点不展开
|
||||
JSONObject item2 = new JSONObject();
|
||||
item2.put("id", functions2.getId());
|
||||
item2.put("text", functions2.getName());
|
||||
|
||||
//勾选判断3
|
||||
//Boolean flag = false;
|
||||
try {
|
||||
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + functions2.getId().toString() + "]");
|
||||
} catch (Exception e) {
|
||||
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
||||
}
|
||||
if (flag == true) {
|
||||
item2.put("checked", true);
|
||||
}
|
||||
//结束
|
||||
|
||||
List<Functions> dataList3 = functionsService.findRoleFunctions(functions2.getNumber());
|
||||
JSONArray dataArray3 = new JSONArray();
|
||||
if (null != dataList3) {
|
||||
|
||||
for (Functions functions3 : dataList3) {
|
||||
item2.put("state", "closed"); //如果不为空,节点不展开
|
||||
JSONObject item3 = new JSONObject();
|
||||
item3.put("id", functions3.getId());
|
||||
item3.put("text", functions3.getName());
|
||||
|
||||
//勾选判断4
|
||||
//Boolean flag = false;
|
||||
try {
|
||||
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + functions3.getId().toString() + "]");
|
||||
} catch (Exception e) {
|
||||
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
||||
}
|
||||
if (flag == true) {
|
||||
item3.put("checked", true);
|
||||
}
|
||||
//结束
|
||||
|
||||
dataArray3.add(item3);
|
||||
item2.put("children", dataArray3);
|
||||
}
|
||||
}
|
||||
|
||||
dataArray2.add(item2);
|
||||
item1.put("children", dataArray2);
|
||||
}
|
||||
}
|
||||
|
||||
dataArray1.add(item1);
|
||||
item.put("children", dataArray1);
|
||||
}
|
||||
|
||||
}
|
||||
dataArray.add(item);
|
||||
}
|
||||
outer.put("children", dataArray);
|
||||
arr.add(outer);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id列表查找功能信息
|
||||
* @param functionsIds
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/findByIds")
|
||||
public BaseResponseInfo findByIds(@RequestParam("functionsIds") String functionsIds,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
List<Functions> dataList = functionsService.findByIds(functionsIds);
|
||||
JSONObject outer = new JSONObject();
|
||||
outer.put("total", dataList.size());
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if (null != dataList) {
|
||||
for (Functions functions : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("Id", functions.getId());
|
||||
item.put("Name", functions.getName());
|
||||
item.put("PushBtn", functions.getPushbtn());
|
||||
item.put("op", 1);
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
outer.put("rows", dataArray);
|
||||
res.code = 200;
|
||||
res.data = outer;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
/**
|
||||
* create by: qiankunpingtai
|
||||
* website:https://qiankunpingtai.cn
|
||||
* description:
|
||||
* 批量删除功能模块信息
|
||||
* create time: 2019/3/29 11:15
|
||||
* @Param: ids
|
||||
* @return java.lang.Object
|
||||
*/
|
||||
@RequestMapping(value = "/batchDeleteFunctionsByIds")
|
||||
public Object batchDeleteFunctionsByIds(@RequestParam("ids") String ids) throws Exception {
|
||||
JSONObject result = ExceptionConstants.standardSuccess();
|
||||
int i= functionsService.batchDeleteFunctionsByIds(ids);
|
||||
if(i<1){
|
||||
logger.error("异常码[{}],异常提示[{}],参数,ids[{}]",
|
||||
ExceptionConstants.FUNCTIONS_DELETE_FAILED_CODE,ExceptionConstants.FUNCTIONS_DELETE_FAILED_MSG,ids);
|
||||
throw new BusinessRunTimeException(ExceptionConstants.FUNCTIONS_DELETE_FAILED_CODE,
|
||||
ExceptionConstants.FUNCTIONS_DELETE_FAILED_MSG);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,12 +201,10 @@ public class MaterialController {
|
||||
public void exportExcel(@RequestParam("name") String name,
|
||||
@RequestParam("model") String model,
|
||||
@RequestParam("categoryIds") String categoryIds,
|
||||
HttpServletRequest request, HttpServletResponse response)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String message = "成功";
|
||||
HttpServletRequest request, HttpServletResponse response) {
|
||||
try {
|
||||
List<MaterialVo4Unit> dataList = materialService.findByAll(name, model, categoryIds);
|
||||
List<MaterialVo4Unit> dataList = materialService.findByAll(StringUtil.toNull(name), StringUtil.toNull(model),
|
||||
StringUtil.toNull(categoryIds));
|
||||
String[] names = {"品名", "类型", "型号", "安全存量", "单位", "零售价", "最低售价", "预计采购价", "批发价", "备注", "状态"};
|
||||
String title = "商品信息";
|
||||
List<String[]> objects = new ArrayList<String[]>();
|
||||
@@ -229,14 +227,8 @@ public class MaterialController {
|
||||
}
|
||||
File file = ExcelUtils.exportObjectsWithoutTitle(title, names, title, objects);
|
||||
ExportExecUtil.showExec(file, file.getName(), response);
|
||||
res.code = 200;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
message = "导出失败";
|
||||
res.code = 500;
|
||||
} finally {
|
||||
map.put("message", message);
|
||||
res.data = map;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,7 +257,6 @@ public class MaterialController {
|
||||
info.code = 400;
|
||||
info.data = data;
|
||||
}
|
||||
//读取所有的摄像机编码
|
||||
//每行中数据顺序 "品名","类型","型号","安全存量","单位","零售价","最低售价","预计采购价","批发价","备注","状态"
|
||||
List<Material> mList = new ArrayList<Material>();
|
||||
for (int i = 1; i < src.getRows(); i++) {
|
||||
|
||||
57
src/main/java/com/jsh/erp/controller/MsgController.java
Normal file
57
src/main/java/com/jsh/erp/controller/MsgController.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package com.jsh.erp.controller;
|
||||
|
||||
import com.jsh.erp.datasource.entities.Msg;
|
||||
import com.jsh.erp.service.msg.MsgService;
|
||||
import com.jsh.erp.utils.BaseResponseInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author ji sheng hua 华夏ERP
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/msg")
|
||||
public class MsgController {
|
||||
private Logger logger = LoggerFactory.getLogger(MsgController.class);
|
||||
|
||||
@Resource
|
||||
private MsgService msgService;
|
||||
|
||||
@GetMapping("/getMsgByStatus")
|
||||
public BaseResponseInfo getMsgByStatus(@RequestParam("status") String status,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
List<Msg> list = msgService.getMsgByStatus(status);
|
||||
res.code = 200;
|
||||
res.data = list;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@PostMapping("/batchUpdateStatus")
|
||||
public BaseResponseInfo batchUpdateStatus(@RequestParam("ids") String ids,
|
||||
@RequestParam("status") String status,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
msgService.batchUpdateStatus(ids, status);
|
||||
res.code = 200;
|
||||
res.data = "更新成功";
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -50,13 +50,6 @@ public class RoleController {
|
||||
JSONArray arr = new JSONArray();
|
||||
try {
|
||||
List<Role> dataList = roleService.findUserRole();
|
||||
//开始拼接json数据
|
||||
JSONObject outer = new JSONObject();
|
||||
outer.put("id", 1);
|
||||
outer.put("text", "角色列表");
|
||||
outer.put("state", "open");
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if (null != dataList) {
|
||||
for (Role role : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
@@ -72,12 +65,9 @@ public class RoleController {
|
||||
if (flag == true) {
|
||||
item.put("checked", true);
|
||||
}
|
||||
//结束
|
||||
dataArray.add(item);
|
||||
arr.add(item);
|
||||
}
|
||||
}
|
||||
outer.put("children", dataArray);
|
||||
arr.add(outer);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.jsh.erp.constants.ExceptionConstants;
|
||||
import com.jsh.erp.datasource.entities.Supplier;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.service.supplier.SupplierService;
|
||||
import com.jsh.erp.service.systemConfig.SystemConfigService;
|
||||
import com.jsh.erp.service.user.UserService;
|
||||
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
||||
import com.jsh.erp.utils.*;
|
||||
@@ -44,6 +45,10 @@ public class SupplierController {
|
||||
|
||||
@Resource
|
||||
private UserBusinessService userBusinessService;
|
||||
|
||||
@Resource
|
||||
private SystemConfigService systemConfigService;
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@@ -81,6 +86,7 @@ public class SupplierController {
|
||||
List<Supplier> supplierList = supplierService.findBySelectCus();
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if (null != supplierList) {
|
||||
boolean customerFlag = systemConfigService.getCustomerFlag();
|
||||
for (Supplier supplier : supplierList) {
|
||||
JSONObject item = new JSONObject();
|
||||
//勾选判断1
|
||||
@@ -90,7 +96,7 @@ public class SupplierController {
|
||||
} catch (DataAccessException e) {
|
||||
logger.error(">>>>>>>>>>>>>>>>>查询用户对应的客户:存在异常!");
|
||||
}
|
||||
if (flag == true) {
|
||||
if (!customerFlag || flag) {
|
||||
item.put("id", supplier.getId());
|
||||
item.put("supplier", supplier.getSupplier()); //客户名称
|
||||
dataArray.add(item);
|
||||
@@ -297,10 +303,7 @@ public class SupplierController {
|
||||
@RequestParam("phonenum") String phonenum,
|
||||
@RequestParam("telephone") String telephone,
|
||||
@RequestParam("description") String description,
|
||||
HttpServletRequest request, HttpServletResponse response)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String message = "成功";
|
||||
HttpServletRequest request, HttpServletResponse response) {
|
||||
try {
|
||||
List<Supplier> dataList = supplierService.findByAll(supplier, type, phonenum, telephone, description);
|
||||
String[] names = {"名称", "类型", "联系人", "电话", "电子邮箱", "预收款", "期初应收", "期初应付", "备注", "传真", "手机", "地址", "纳税人识别号", "开户行", "账号", "税率", "状态"};
|
||||
@@ -331,14 +334,8 @@ public class SupplierController {
|
||||
}
|
||||
File file = ExcelUtils.exportObjectsWithoutTitle(title, names, title, objects);
|
||||
ExportExecUtil.showExec(file, file.getName(), response);
|
||||
res.code = 200;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
message = "导出失败";
|
||||
res.code = 500;
|
||||
} finally {
|
||||
map.put("message", message);
|
||||
res.data = map;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -400,7 +397,6 @@ public class SupplierController {
|
||||
info.code = 400;
|
||||
info.data = data;
|
||||
}
|
||||
//读取所有的摄像机编码
|
||||
//每行中数据顺序 "名称","类型","联系人","电话","电子邮箱","预收款","期初应收","期初应付","备注","传真","手机","地址","纳税人识别号","开户行","账号","税率","状态"
|
||||
List<Supplier> sList = new ArrayList<Supplier>();
|
||||
for (int i = 1; i < src.getRows(); i++) {
|
||||
|
||||
@@ -7,16 +7,21 @@ import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.jsh.erp.constants.BusinessConstants;
|
||||
import com.jsh.erp.constants.ExceptionConstants;
|
||||
import com.jsh.erp.datasource.entities.Tenant;
|
||||
import com.jsh.erp.datasource.entities.User;
|
||||
import com.jsh.erp.datasource.entities.UserEx;
|
||||
import com.jsh.erp.datasource.vo.TreeNodeEx;
|
||||
import com.jsh.erp.exception.BusinessParamCheckingException;
|
||||
import com.jsh.erp.service.log.LogService;
|
||||
import com.jsh.erp.service.tenant.TenantService;
|
||||
import com.jsh.erp.service.user.UserService;
|
||||
import com.jsh.erp.utils.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -37,21 +42,18 @@ import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
||||
public class UserController {
|
||||
private Logger logger = LoggerFactory.getLogger(UserController.class);
|
||||
|
||||
@Value("${mybatis-plus.status}")
|
||||
private String mybatisPlusStatus;
|
||||
|
||||
@Value("${manage.ip}")
|
||||
private String manageIp;
|
||||
|
||||
@Value("${manage.port}")
|
||||
private Integer managePort;
|
||||
|
||||
@Value("${manage.roleId}")
|
||||
private Long manageRoleId;
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@Resource
|
||||
private TenantService tenantService;
|
||||
|
||||
@Resource
|
||||
private LogService logService;
|
||||
|
||||
private static String message = "成功";
|
||||
private static final String HTTP = "http://";
|
||||
private static final String CODE_OK = "200";
|
||||
@@ -82,6 +84,7 @@ public class UserController {
|
||||
try {
|
||||
userStatus = userService.validateUser(username, password);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error(">>>>>>>>>>>>>用户 " + username + " 登录 login 方法 访问服务层异常====", e);
|
||||
msgTip = "access service exception";
|
||||
}
|
||||
@@ -106,39 +109,24 @@ public class UserController {
|
||||
// new Timestamp(System.currentTimeMillis()), (short) 0, "管理用户:" + username + " 登录系统", username + " 登录系统"));
|
||||
msgTip = "user can login";
|
||||
request.getSession().setAttribute("user",user);
|
||||
if(("open").equals(mybatisPlusStatus)) {
|
||||
String tenantId = null;
|
||||
String userNumLimit = null;
|
||||
String billsNumLimit = null;
|
||||
if(user.getTenantId()==null){
|
||||
msgTip="用户数据错误,请联系管理员!";
|
||||
break;
|
||||
}
|
||||
JSONObject obj=null;
|
||||
if(user.getTenantId()!=-1){
|
||||
String url = HTTP + manageIp + ":" + managePort + "/tenant/getTenant?tenantId=" + user.getTenantId();
|
||||
obj = HttpClient.httpGet(url);
|
||||
if(obj!=null && obj.getString("code").equals(CODE_OK)) {
|
||||
JSONObject dataObj = obj.getJSONObject("data");
|
||||
if(dataObj!=null) {
|
||||
tenantId = dataObj.getString("tenantId");
|
||||
userNumLimit = dataObj.getString("userNumLimit");
|
||||
billsNumLimit = dataObj.getString("billsNumLimit");
|
||||
}
|
||||
if(user.getTenantId()!=null) {
|
||||
Tenant tenant = tenantService.getTenantByTenantId(user.getTenantId());
|
||||
if(tenant!=null) {
|
||||
Long tenantId = tenant.getTenantId();
|
||||
Integer userNumLimit = tenant.getUserNumLimit();
|
||||
Integer billsNumLimit = tenant.getBillsNumLimit();
|
||||
if(tenantId!=null) {
|
||||
request.getSession().setAttribute("tenantId",tenantId); //租户tenantId
|
||||
request.getSession().setAttribute("userNumLimit",userNumLimit); //用户限制数
|
||||
request.getSession().setAttribute("billsNumLimit",billsNumLimit); //单据限制数
|
||||
}
|
||||
}else{
|
||||
tenantId=user.getTenantId().toString();
|
||||
userNumLimit=BusinessConstants.TEST_USER_NUM_LIMIT;
|
||||
billsNumLimit=BusinessConstants.TEST_BILLS_NUM_LIMIT;
|
||||
}
|
||||
if(tenantId!=null) {
|
||||
request.getSession().setAttribute("tenantId",tenantId); //租户tenantId
|
||||
request.getSession().setAttribute("userNumLimit",userNumLimit); //用户限制数
|
||||
request.getSession().setAttribute("billsNumLimit",billsNumLimit); //单据限制数
|
||||
}
|
||||
}
|
||||
request.getSession().setAttribute("mybatisPlusStatus",mybatisPlusStatus); //开启状态
|
||||
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_USER,
|
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_LOGIN).append(user.getId()).toString(),
|
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error(">>>>>>>>>>>>>>>查询用户名为:" + username + " ,用户信息异常", e);
|
||||
}
|
||||
break;
|
||||
@@ -157,6 +145,7 @@ public class UserController {
|
||||
logger.info("===============用户登录 login 方法调用结束===============");
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
logger.error(e.getMessage());
|
||||
res.code = 500;
|
||||
res.data = "用户登录失败";
|
||||
}
|
||||
@@ -189,12 +178,9 @@ public class UserController {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
request.getSession().removeAttribute("user");
|
||||
request.getSession().removeAttribute("mybatisPlusStatus");
|
||||
if(("open").equals(mybatisPlusStatus)) {
|
||||
request.getSession().removeAttribute("tenantId");
|
||||
request.getSession().removeAttribute("userNumLimit");
|
||||
request.getSession().removeAttribute("billsNumLimit");
|
||||
}
|
||||
request.getSession().removeAttribute("tenantId");
|
||||
request.getSession().removeAttribute("userNumLimit");
|
||||
request.getSession().removeAttribute("billsNumLimit");
|
||||
response.sendRedirect("/login.html");
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
@@ -330,16 +316,11 @@ public class UserController {
|
||||
@ResponseBody
|
||||
public Object addUser(@RequestParam("info") String beanJson, HttpServletRequest request)throws Exception{
|
||||
JSONObject result = ExceptionConstants.standardSuccess();
|
||||
if(("open").equals(mybatisPlusStatus)) {
|
||||
Long userNumLimit = Long.parseLong(request.getSession().getAttribute("userNumLimit").toString());
|
||||
Long count = userService.countUser(null,null);
|
||||
if(count>= userNumLimit) {
|
||||
throw new BusinessParamCheckingException(ExceptionConstants.USER_OVER_LIMIT_FAILED_CODE,
|
||||
ExceptionConstants.USER_OVER_LIMIT_FAILED_MSG);
|
||||
} else {
|
||||
UserEx ue= JSON.parseObject(beanJson, UserEx.class);
|
||||
userService.addUserAndOrgUserRel(ue);
|
||||
}
|
||||
Long userNumLimit = Long.parseLong(request.getSession().getAttribute("userNumLimit").toString());
|
||||
Long count = userService.countUser(null,null);
|
||||
if(count>= userNumLimit) {
|
||||
throw new BusinessParamCheckingException(ExceptionConstants.USER_OVER_LIMIT_FAILED_CODE,
|
||||
ExceptionConstants.USER_OVER_LIMIT_FAILED_MSG);
|
||||
} else {
|
||||
UserEx ue= JSON.parseObject(beanJson, UserEx.class);
|
||||
userService.addUserAndOrgUserRel(ue);
|
||||
@@ -365,32 +346,6 @@ public class UserController {
|
||||
ue.setLoginame(loginame);
|
||||
ue.setPassword(password);
|
||||
ue = userService.registerUser(ue,manageRoleId);
|
||||
/**
|
||||
* create by: qiankunpingtai
|
||||
* create time: 2019/4/9 17:17
|
||||
* website:https://qiankunpingtai.cn
|
||||
* description:
|
||||
* 这里涉及到多个项目,需要用分布式事务去处理
|
||||
* 为了不使问题复杂化,暂时另外开启一个线程去处理其它项目的数据操作
|
||||
*/
|
||||
final UserEx ueFinal=ue;
|
||||
final ExecutorService executorService = Executors.newFixedThreadPool(1);
|
||||
executorService.execute(() -> {
|
||||
try{
|
||||
//调第三方接口创建租户管理信息
|
||||
String url = HTTP + manageIp + ":" + managePort + "/tenant/add";
|
||||
JSONObject tenantObj = new JSONObject();
|
||||
tenantObj.put("tenantId", ueFinal.getId());
|
||||
tenantObj.put("loginName",ueFinal.getLoginame());
|
||||
String param = URLEncoder.encode(tenantObj.toString());
|
||||
HttpClient.httpPost(url + "?info=" + param, param);
|
||||
logger.info("===============创建租户信息完成===============");
|
||||
}catch(Exception e){
|
||||
//记录一下第三方接口创建租户管理信息创建失败
|
||||
logger.debug("调用第三方接口创建租户管理信息失败:tenantId:[{}],loginName:[{}]",ueFinal.getId(),ueFinal.getLoginame());
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
@@ -437,20 +392,4 @@ public class UserController {
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
@GetMapping("/getTenantStatus")
|
||||
public BaseResponseInfo getTenantStatus(HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("status", mybatisPlusStatus);
|
||||
res.code = 200;
|
||||
res.data = data;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user