更新后端代码

This commit is contained in:
季圣华
2017-08-30 00:14:38 +08:00
parent b9bc613c60
commit 5e05f53af2
49 changed files with 4413 additions and 793 deletions

View File

@@ -25,251 +25,260 @@ import com.jsh.util.PageUtil;
@SuppressWarnings("serial")
public class DepotAction extends BaseAction<DepotModel>
{
private DepotIService depotService;
private UserBusinessIService userBusinessService;
private DepotModel model = new DepotModel();
private DepotIService depotService;
private UserBusinessIService userBusinessService;
private DepotModel model = new DepotModel();
@SuppressWarnings({ "rawtypes", "unchecked" })
public String getBasicData()
{
Map<String,List> mapData = model.getShowModel().getMap();
PageUtil pageUtil = new PageUtil();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
try
{
Map<String,Object> condition = pageUtil.getAdvSearch();
condition.put("sort_s_order", "asc");
depotService.find(pageUtil);
mapData.put("depotList", pageUtil.getPageList());
}
catch (Exception e)
{
Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e);
model.getShowModel().setMsgTip("exceptoin");
}
return SUCCESS;
}
{
Map<String,List> mapData = model.getShowModel().getMap();
PageUtil pageUtil = new PageUtil();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
try
{
Map<String,Object> condition = pageUtil.getAdvSearch();
condition.put("sort_s_order", "asc");
depotService.find(pageUtil);
mapData.put("depotList", pageUtil.getPageList());
}
catch (Exception e)
{
Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e);
model.getShowModel().setMsgTip("exceptoin");
}
return SUCCESS;
}
/**
* 增加仓库
* @return
*/
public void create()
{
Log.infoFileSync("==================开始调用增加仓库信息方法create()===================");
Boolean flag = false;
Log.infoFileSync("==================开始调用增加仓库信息方法create()===================");
Boolean flag = false;
try
{
Depot depot = new Depot();
depot.setName(model.getName());
depot.setAddress(model.getAddress());
depot.setWarehousing(model.getWarehousing());
depot.setTruckage(model.getTruckage());
depot.setType(model.getType());
depot.setSort(model.getSort());
depot.setRemark(model.getRemark());
depotService.create(depot);
//========标识位===========
flag = true;
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加仓库信息异常", e);
flag = false;
tipMsg = "失败";
tipType = 1;
tipType = 1;
}
finally
{
try
{
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>增加仓库信息回写客户端结果异常", e);
}
try
{
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>增加仓库信息回写客户端结果异常", e);
}
}
logService.create(new Logdetails(getUser(), "增加仓库", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "增加仓库名称为 "+ model.getName() + " " + tipMsg + "", "增加仓库" + tipMsg));
new Timestamp(System.currentTimeMillis())
, tipType, "增加仓库名称为 "+ model.getName() + " " + tipMsg + "", "增加仓库" + tipMsg));
Log.infoFileSync("==================结束调用增加仓库方法create()===================");
}
/**
* 删除仓库
* @return
*/
public String delete()
{
Log.infoFileSync("====================开始调用删除仓库信息方法delete()================");
try
{
depotService.delete(model.getDepotID());
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getDepotID() + " 的仓库异常", e);
tipMsg = "失败";
tipType = 1;
}
model.getShowModel().setMsgTip(tipMsg);
logService.create(new Logdetails(getUser(), "删除仓库", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "删除仓库ID为 "+ model.getDepotID() + " " + tipMsg + "", "删除仓库" + tipMsg));
Log.infoFileSync("====================结束调用删除仓库信息方法delete()================");
return SUCCESS;
Log.infoFileSync("====================开始调用删除仓库信息方法delete()================");
try
{
depotService.delete(model.getDepotID());
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getDepotID() + " 的仓库异常", e);
tipMsg = "失败";
tipType = 1;
}
model.getShowModel().setMsgTip(tipMsg);
logService.create(new Logdetails(getUser(), "删除仓库", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "删除仓库ID为 "+ model.getDepotID() + " " + tipMsg + "", "删除仓库" + tipMsg));
Log.infoFileSync("====================结束调用删除仓库信息方法delete()================");
return SUCCESS;
}
/**
* 更新仓库
* @return
*/
public void update()
{
Boolean flag = false;
try
{
Depot depot = depotService.get(model.getDepotID());
depot.setName(model.getName());
Boolean flag = false;
try
{
Depot depot = depotService.get(model.getDepotID());
depot.setName(model.getName());
depot.setAddress(model.getAddress());
depot.setWarehousing(model.getWarehousing());
depot.setTruckage(model.getTruckage());
depot.setType(model.getType());
depot.setSort(model.getSort());
depot.setRemark(model.getRemark());
depotService.update(depot);
flag = true;
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>修改仓库ID为 " + model.getDepotID() + "信息失败", e);
flag = false;
tipMsg = "失败";
tipType = 1;
}
finally
{
try
{
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>修改仓库回写客户端结果异常", e);
}
}
logService.create(new Logdetails(getUser(), "更新仓库", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "更新仓库ID为 "+ model.getDepotID() + " " + tipMsg + "", "更新仓库" + tipMsg));
depot.setSort(model.getSort());
depot.setRemark(model.getRemark());
depotService.update(depot);
flag = true;
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>修改仓库ID为 " + model.getDepotID() + "信息失败", e);
flag = false;
tipMsg = "失败";
tipType = 1;
}
finally
{
try
{
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>修改仓库回写客户端结果异常", e);
}
}
logService.create(new Logdetails(getUser(), "更新仓库", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "更新仓库ID为 "+ model.getDepotID() + " " + tipMsg + "", "更新仓库" + tipMsg));
}
/**
* 批量删除指定ID仓库
* @return
*/
public String batchDelete()
{
try
{
depotService.batchDelete(model.getDepotIDs());
model.getShowModel().setMsgTip("成功");
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>批量删除仓库ID为" + model.getDepotIDs() + "信息异常", e);
tipMsg = "失败";
tipType = 1;
}
logService.create(new Logdetails(getUser(), "批量删除仓库", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "批量删除仓库ID为 "+ model.getDepotIDs() + " " + tipMsg + "", "批量删除仓库" + tipMsg));
return SUCCESS;
try
{
depotService.batchDelete(model.getDepotIDs());
model.getShowModel().setMsgTip("成功");
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>批量删除仓库ID为" + model.getDepotIDs() + "信息异常", e);
tipMsg = "失败";
tipType = 1;
}
logService.create(new Logdetails(getUser(), "批量删除仓库", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "批量删除仓库ID为 "+ model.getDepotIDs() + " " + tipMsg + "", "批量删除仓库" + tipMsg));
return SUCCESS;
}
/**
* 检查输入名称是否存在
*/
public void checkIsNameExist()
{
Boolean flag = false;
try
{
flag = depotService.checkIsNameExist("name",model.getName(),"id", model.getDepotID());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>检查仓库名称为:" + model.getName() + " ID为 " + model.getDepotID() + " 是否存在异常!");
}
finally
{
try
{
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>回写检查仓库名称为:" + model.getName() + " ID为 " + model.getDepotID() + " 是否存在异常!",e);
}
}
Boolean flag = false;
try
{
flag = depotService.checkIsNameExist("name",model.getName(),"id", model.getDepotID());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>检查仓库名称为:" + model.getName() + " ID为 " + model.getDepotID() + " 是否存在异常!");
}
finally
{
try
{
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>回写检查仓库名称为:" + model.getName() + " ID为 " + model.getDepotID() + " 是否存在异常!",e);
}
}
}
/**
* 查找仓库信息
* @return
*/
public void findBy()
public void findBy()
{
try
{
PageUtil<Depot> pageUtil = new PageUtil<Depot>();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition());
depotService.find(pageUtil);
List<Depot> dataList = pageUtil.getPageList();
JSONObject outer = new JSONObject();
outer.put("total", pageUtil.getTotalCount());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(Depot depot:dataList)
{
JSONObject item = new JSONObject();
item.put("id", depot.getId());
//供应商名称
item.put("name", depot.getName());
try
{
PageUtil<Depot> pageUtil = new PageUtil<Depot>();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition());
depotService.find(pageUtil);
List<Depot> dataList = pageUtil.getPageList();
JSONObject outer = new JSONObject();
outer.put("total", pageUtil.getTotalCount());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(Depot depot:dataList)
{
JSONObject item = new JSONObject();
item.put("id", depot.getId());
//供应商名称
item.put("name", depot.getName());
item.put("address", depot.getAddress());
item.put("warehousing", depot.getWarehousing());
item.put("truckage", depot.getTruckage());
item.put("type", depot.getType());
item.put("sort", depot.getSort());
item.put("remark", depot.getRemark());
item.put("op", 1);
dataArray.add(item);
}
}
outer.put("rows", dataArray);
//回写查询结果
toClient(outer.toString());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓库信息异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓库信息结果异常", e);
}
item.put("sort", depot.getSort());
item.put("remark", depot.getRemark());
item.put("op", 1);
dataArray.add(item);
}
}
outer.put("rows", dataArray);
//回写查询结果
toClient(outer.toString());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓库信息异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓库信息结果异常", e);
}
}
/**
@@ -311,82 +320,132 @@ public class DepotAction extends BaseAction<DepotModel>
Log.errorFileSync(">>>>>>>>>回写查询仓库信息结果异常", e);
}
}
/**
* 用户对应仓库显示
* @return
*/
public void findUserDepot()
public void findUserDepot()
{
try
{
PageUtil<Depot> pageUtil = new PageUtil<Depot>();
pageUtil.setPageSize(100);
//pageUtil.setCurPage(model.getPageNo());
try
{
PageUtil<Depot> pageUtil = new PageUtil<Depot>();
pageUtil.setPageSize(100);
//pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition_UserDepot());
depotService.find(pageUtil);
List<Depot> dataList = pageUtil.getPageList();
//开始拼接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(Depot depot:dataList)
{
JSONObject item = new JSONObject();
item.put("id", depot.getId());
item.put("text", depot.getName());
//勾选判断1
Boolean flag = false;
try
{
flag = userBusinessService.checkIsUserBusinessExist("Type",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+depot.getId().toString()+"]");
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>设置用户对应的仓库:类型" + model.getUBType() + " KeyId为 " + model.getUBKeyId() + " 存在异常!");
}
if (flag==true){item.put("checked", true);}
//结束
dataArray.add(item);
}
}
outer.put("children", dataArray);
//回写查询结果
toClient("["+outer.toString()+"]");
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓库异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓库结果异常", e);
}
pageUtil.setAdvSearch(getCondition_UserDepot());
depotService.find(pageUtil);
List<Depot> dataList = pageUtil.getPageList();
//开始拼接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(Depot depot:dataList)
{
JSONObject item = new JSONObject();
item.put("id", depot.getId());
item.put("text", depot.getName());
//勾选判断1
Boolean flag = false;
try
{
flag = userBusinessService.checkIsUserBusinessExist("Type",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+depot.getId().toString()+"]");
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>设置用户对应的仓库:类型" + model.getUBType() + " KeyId为 " + model.getUBKeyId() + " 存在异常!");
}
if (flag==true){item.put("checked", true);}
//结束
dataArray.add(item);
}
}
outer.put("children", dataArray);
//回写查询结果
toClient("["+outer.toString()+"]");
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓库异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓库结果异常", e);
}
}
/**
* 根据用户查找对应仓库列表-仅显示有权限的
* @return
*/
public void findDepotByUserId(){
try{
PageUtil<Depot> pageUtil = new PageUtil<Depot>();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
pageUtil.setAdvSearch(getCondition_UserDepot());
depotService.find(pageUtil);
List<Depot> dataList = pageUtil.getPageList();
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(Depot depot:dataList)
{
JSONObject item = new JSONObject();
//勾选判断1
Boolean flag = false;
try
{
flag = userBusinessService.checkIsUserBusinessExist("Type",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+depot.getId().toString()+"]");
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>查询用户对应的仓库:类型" + model.getUBType() + " KeyId为 " + model.getUBKeyId() + " 存在异常!");
}
if (flag==true){
item.put("id", depot.getId());
item.put("depotName", depot.getName());
dataArray.add(item);
}
}
}
//回写查询结果
toClient(dataArray.toString());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓库异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓库结果异常", e);
}
}
/**
* 拼接搜索条件
* @return
*/
private Map<String,Object> getCondition()
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("name_s_like", model.getName());
condition.put("remark_s_like", model.getRemark());
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("name_s_like", model.getName());
condition.put("remark_s_like", model.getRemark());
condition.put("type_n_eq", model.getType()); //0-仓库1-礼品卡
condition.put("sort_s_order", "asc");
return condition;
}
condition.put("sort_s_order", "asc");
return condition;
}
/**
* 拼接搜索条件
@@ -402,22 +461,22 @@ public class DepotAction extends BaseAction<DepotModel>
condition.put("sort_s_order", "asc");
return condition;
}
/**
* 拼接搜索条件-用户对应部门
* 拼接搜索条件-用户对应仓库
* @return
*/
private Map<String,Object> getCondition_UserDepot()
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
{
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("type_n_eq", 0);
condition.put("sort_s_order", "asc");
return condition;
}
condition.put("sort_s_order", "asc");
return condition;
}
//=============以下spring注入以及Model驱动公共方法与Action处理无关==================
@Override
public DepotModel getModel()
@@ -425,12 +484,12 @@ public class DepotAction extends BaseAction<DepotModel>
return model;
}
public void setDepotService(DepotIService depotService)
{
this.depotService = depotService;
}
{
this.depotService = depotService;
}
public void setUserBusinessService(UserBusinessIService userBusinessService) {
this.userBusinessService = userBusinessService;
}
}