Commit 5e05f53a authored by 季圣华's avatar 季圣华
Browse files

更新后端代码

parent b9bc613c
......@@ -47,7 +47,7 @@ public class FunctionsAction extends BaseAction<FunctionsModel>
functions.setSort(model.getSort());
functions.setEnabled(model.getEnabled());
functions.setType(model.getType());
functions.setPushBtn(model.getPushBtn());
functionsService.create(functions);
//========标识位===========
......@@ -126,6 +126,7 @@ public class FunctionsAction extends BaseAction<FunctionsModel>
functions.setSort(model.getSort());
functions.setEnabled(model.getEnabled());
functions.setType(model.getType());
functions.setPushBtn(model.getPushBtn());
functionsService.update(functions);
flag = true;
......@@ -246,6 +247,7 @@ public class FunctionsAction extends BaseAction<FunctionsModel>
item.put("Sort", functions.getSort());
item.put("Enabled", functions.getEnabled());
item.put("Type", functions.getType());
item.put("PushBtn", functions.getPushBtn());
item.put("op", 1);
dataArray.add(item);
}
......@@ -263,6 +265,49 @@ public class FunctionsAction extends BaseAction<FunctionsModel>
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询功能信息结果异常", e);
}
}
/**
* 根据id列表查找功能信息
* @return
*/
public void findByIds()
{
try {
PageUtil<Functions> pageUtil = new PageUtil<Functions>();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
pageUtil.setAdvSearch(getConditionByIds());
functionsService.find(pageUtil);
List<Functions> dataList = pageUtil.getPageList();
JSONObject outer = new JSONObject();
outer.put("total", pageUtil.getTotalCount());
//存放数据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);
//回写查询结果
toClient(outer.toString());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找功能信息异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询功能信息结果异常", e);
}
}
/**
......@@ -497,7 +542,7 @@ public class FunctionsAction extends BaseAction<FunctionsModel>
else
{
//不是目录,有链接
item2.put("text", "<a onclick=\"NewTab('"+functions2.getName()+"','"+functions2.getURL()+"')\">"+functions2.getName()+"</a>");
item2.put("text", "<a onclick=\"NewTab('"+functions2.getName()+"','"+functions2.getURL()+"','"+functions2.getId()+"')\">"+functions2.getName()+"</a>");
}
dataArray2.add(item2);
......@@ -508,7 +553,7 @@ public class FunctionsAction extends BaseAction<FunctionsModel>
else
{
//不是目录,有链接
item1.put("text", "<a onclick=\"NewTab('"+functions1.getName()+"','"+functions1.getURL()+"')\">"+functions1.getName()+"</a>");
item1.put("text", "<a onclick=\"NewTab('"+functions1.getName()+"','"+functions1.getURL()+"','"+functions1.getId()+"')\">"+functions1.getName()+"</a>");
}
dataArray1.add(item1);
......@@ -519,7 +564,7 @@ public class FunctionsAction extends BaseAction<FunctionsModel>
else
{
//不是目录,有链接
item.put("text", "<a onclick=\"NewTab('"+functions.getName()+"','"+functions.getURL()+"')\">"+functions.getName()+"</a>");
item.put("text", "<a onclick=\"NewTab('"+functions.getName()+"','"+functions.getURL()+"','"+functions.getId()+"')\">"+functions.getName()+"</a>");
}
dataArray.add(item);
......@@ -569,6 +614,18 @@ public class FunctionsAction extends BaseAction<FunctionsModel>
condition.put("Sort_s_order", "asc");
return condition;
}
/**
* 拼接搜索条件-角色对应功能
* @return
*/
private Map<String,Object> getConditionByIds() {
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("Enabled_n_eq", 1);
condition.put("Id_s_in", model.getFunctionsIDs());
condition.put("Sort_s_order", "asc");
return condition;
}
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
@Override
......
package com.jsh.action.basic;
import com.jsh.base.BaseAction;
import com.jsh.base.Log;
import com.jsh.model.po.Unit;
import com.jsh.model.po.Logdetails;
import com.jsh.model.vo.basic.UnitModel;
import com.jsh.service.basic.UnitIService;
import com.jsh.util.PageUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.dao.DataAccessException;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 计量单位
* @author ji shenghua qq:752 718 920
*/
@SuppressWarnings("serial")
public class UnitAction extends BaseAction<UnitModel>
{
private UnitIService unitService;
private UnitModel model = new UnitModel();
/**
* 增加计量单位
* @return
*/
public void create()
{
Log.infoFileSync("==================开始调用增加计量单位方法create()===================");
Boolean flag = false;
try
{
Unit unit = new Unit();
unit.setUName(model.getUName());
unitService.create(unit);
//========标识位===========
flag = true;
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加计量单位异常", 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, "增加计量单位名称为 "+ model.getUName() + " " + tipMsg + "!", "增加计量单位" + tipMsg));
Log.infoFileSync("==================结束调用增加计量单位方法create()===================");
}
/**
* 删除计量单位
* @return
*/
public String delete() {
Log.infoFileSync("====================开始调用删除计量单位方法delete()================");
try {
unitService.delete(model.getUnitID());
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getUnitID() + " 的计量单位异常", e);
tipMsg = "失败";
tipType = 1;
}
model.getShowModel().setMsgTip(tipMsg);
logService.create(new Logdetails(getUser(), "删除计量单位", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "删除计量单位ID为 "+ model.getUnitID() + " " + tipMsg + "!", "删除计量单位" + tipMsg));
Log.infoFileSync("====================结束调用删除计量单位方法delete()================");
return SUCCESS;
}
/**
* 更新计量单位
* @return
*/
public void update() {
Boolean flag = false;
try {
Unit unit = unitService.get(model.getUnitID());
unit.setUName(model.getUName());
unitService.update(unit);
flag = true;
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>>>修改计量单位ID为 : " + model.getUnitID() + "信息失败", 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.getUnitID() + " " + tipMsg + "!", "更新计量单位" + tipMsg));
}
/**
* 批量删除指定ID计量单位
* @return
*/
public String batchDelete()
{
try
{
unitService.batchDelete(model.getUnitIDs());
model.getShowModel().setMsgTip("成功");
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>批量删除计量单位ID为:" + model.getUnitIDs() + "信息异常", e);
tipMsg = "失败";
tipType = 1;
}
logService.create(new Logdetails(getUser(), "批量删除计量单位", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "批量删除计量单位ID为 "+ model.getUnitIDs() + " " + tipMsg + "!", "批量删除计量单位" + tipMsg));
return SUCCESS;
}
/**
* 检查输入名称是否存在
*/
public void checkIsNameExist()
{
Boolean flag = false;
try
{
flag = unitService.checkIsNameExist("UName",model.getUName(),"id", model.getUnitID());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>检查计量单位名称为:" + model.getUName() + " ID为: " + model.getUnitID() + " 是否存在异常!");
}
finally
{
try
{
toClient(flag.toString());
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>回写检查计量单位名称为:" + model.getUName() + " ID为: " + model.getUnitID() + " 是否存在异常!",e);
}
}
}
/**
* 查找计量单位信息
* @return
*/
public void findBy()
{
try
{
PageUtil<Unit> pageUtil = new PageUtil<Unit>();
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
pageUtil.setAdvSearch(getCondition());
unitService.find(pageUtil);
List<Unit> dataList = pageUtil.getPageList();
JSONObject outer = new JSONObject();
outer.put("total", pageUtil.getTotalCount());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(Unit unit:dataList)
{
JSONObject item = new JSONObject();
item.put("id", unit.getId());
//名称
item.put("UName", unit.getUName());
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);
}
}
/**
* 查找计量单位信息-下拉框
* @return
*/
public void findUnitDownList() {
try {
PageUtil<Unit> pageUtil = new PageUtil<Unit>();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
pageUtil.setAdvSearch(getCondition());
unitService.find(pageUtil);
List<Unit> dataList = pageUtil.getPageList();
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList) {
for(Unit unit:dataList) {
JSONObject item = new JSONObject();
item.put("id", unit.getId());
//名称
item.put("UName", unit.getUName());
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("UName_s_like", model.getUName());
condition.put("id_s_order", "asc");
return condition;
}
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
@Override
public UnitModel getModel()
{
return model;
}
public void setUnitService(UnitIService unitService) {
this.unitService = unitService;
}
}
......@@ -325,7 +325,40 @@ public class UserAction extends BaseAction<UserModel>
new Timestamp(System.currentTimeMillis())
, tipType, "更新用户ID为 "+ model.getUserID() + "密码信息 " + tipMsg + "!", "更新用户" + tipMsg));
}
/**
* 重置用户的密码
*/
public void resetPwd() {
Integer flag = 0;
try {
Basicuser user = userService.get(model.getUserID());
String password = "123456";
String md5Pwd = Tools.md5Encryp(password);
user.setPassword(md5Pwd);
userService.update(user);
flag = 1;
tipMsg = "成功";
tipType = 0;
}
catch (Exception e) {
Log.errorFileSync(">>>>>>>>>>>>>修改用户ID为 : " + model.getUserID() + "密码信息失败", e);
flag = 0;
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.getUserID() + "密码信息 " + tipMsg + "!", "重置用户密码" + tipMsg));
}
/**
* 批量删除指定ID用户
* @return
......
......@@ -5,6 +5,8 @@ import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.jsh.model.po.Functions;
import org.springframework.dao.DataAccessException;
import com.jsh.base.BaseAction;
import com.jsh.base.Log;
......@@ -173,6 +175,42 @@ public class UserBusinessAction extends BaseAction<UserBusinessModel>
new Timestamp(System.currentTimeMillis())
, tipType, "更新UserBusiness的ID为 "+ id + " " + tipMsg + "!", "更新UserBusiness" + tipMsg));
}
/**
* 更新角色的按钮权限
* @return
*/
public void updateBtnStr() {
Boolean flag = false;
try {
UserBusiness userBusiness = userBusinessService.get(model.getUserBusinessID());
userBusiness.setType(userBusiness.getType());
userBusiness.setKeyId(userBusiness.getKeyId());
userBusiness.setValue(userBusiness.getValue());
userBusiness.setBtnStr(model.getBtnStr());
userBusinessService.update(userBusiness);
flag = true;
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>>>修改角色按钮权限的ID为 : " + model.getUserBusinessID() + "信息失败", 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.getUserBusinessID() + " " + tipMsg + "!", "更新角色按钮权限" + tipMsg));
}
/**
* 拼接搜索条件-RoleAPP
......
package com.jsh.action.materials;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.jsh.model.po.*;
import com.jsh.util.JshException;
import com.jsh.util.MaterialConstants;
import com.jsh.util.Tools;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.dao.DataAccessException;
import com.jsh.base.BaseAction;
import com.jsh.base.Log;
import com.jsh.model.po.DepotHead;
import com.jsh.model.po.Material;
import com.jsh.model.po.Logdetails;
import com.jsh.model.po.MaterialCategory;
import com.jsh.model.po.Supplier;
import com.jsh.model.vo.materials.MaterialModel;
import com.jsh.service.materials.MaterialIService;
import com.jsh.util.PageUtil;
......@@ -27,6 +29,7 @@ public class MaterialAction extends BaseAction<MaterialModel>
{
private MaterialIService materialService;
private MaterialModel model = new MaterialModel();
public static final String EXCEL = "excel"; //action返回excel结果
/**
* 增加商品
......@@ -42,6 +45,9 @@ public class MaterialAction extends BaseAction<MaterialModel>
material.setMaterialCategory(new MaterialCategory(model.getCategoryId()));
material.setName(model.getName());
material.setMfrs(model.getMfrs());
material.setPacking(model.getPacking());
material.setSafetyStock(model.getSafetyStock());
material.setModel(model.getModel());
material.setStandard(model.getStandard());
material.setColor(model.getColor());
......@@ -50,7 +56,17 @@ public class MaterialAction extends BaseAction<MaterialModel>
material.setLowPrice(model.getLowPrice());
material.setPresetPriceOne(model.getPresetPriceOne());
material.setPresetPriceTwo(model.getPresetPriceTwo());
if(model.getUnitId()!=null){
material.setUnitId(new Unit(model.getUnitId()));
}
else {
material.setUnitId(null);
}
material.setFirstOutUnit(model.getFirstOutUnit());
material.setFirstInUnit(model.getFirstInUnit());
material.setPriceStrategy(model.getPriceStrategy());
material.setRemark(model.getRemark());
material.setEnabled(model.getEnabled());
materialService.create(material);
//========标识位===========
......@@ -124,6 +140,9 @@ public class MaterialAction extends BaseAction<MaterialModel>
material.setMaterialCategory(new MaterialCategory(model.getCategoryId()));
material.setName(model.getName());
material.setMfrs(model.getMfrs());
material.setPacking(model.getPacking());
material.setSafetyStock(model.getSafetyStock());
material.setModel(model.getModel());
material.setStandard(model.getStandard());
material.setColor(model.getColor());
......@@ -132,8 +151,16 @@ public class MaterialAction extends BaseAction<MaterialModel>
material.setLowPrice(model.getLowPrice());
material.setPresetPriceOne(model.getPresetPriceOne());
material.setPresetPriceTwo(model.getPresetPriceTwo());
if(model.getUnitId()!=null){
material.setUnitId(new Unit(model.getUnitId()));
}
else {
material.setUnitId(null);
}
material.setFirstOutUnit(model.getFirstOutUnit());
material.setFirstInUnit(model.getFirstInUnit());
material.setPriceStrategy(model.getPriceStrategy());
material.setRemark(model.getRemark());
material.setName(model.getName());
materialService.update(material);
flag = true;
......@@ -189,6 +216,63 @@ public class MaterialAction extends BaseAction<MaterialModel>
, tipType, "批量删除商品ID为 "+ model.getMaterialIDs() + " " + tipMsg + "!", "批量删除商品" + tipMsg));
return SUCCESS;
}
/**
* 批量设置状态-启用或者禁用
* @return
*/
public String batchSetEnable()
{
try
{
materialService.batchSetEnable(model.getEnabled(),model.getMaterialIDs());
model.getShowModel().setMsgTip("成功");
//记录操作日志使用
tipMsg = "成功";
tipType = 0;
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>批量修改状态,商品ID为:" + model.getMaterialIDs() + "信息异常", e);
tipMsg = "失败";
tipType = 1;
}
logService.create(new Logdetails(getUser(), "批量修改商品状态", model.getClientIp(),
new Timestamp(System.currentTimeMillis())
, tipType, "批量修改状态,商品ID为 "+ model.getMaterialIDs() + " " + tipMsg + "!", "批量修改商品状态" + tipMsg));
return SUCCESS;
}
/**
* 查找该商品是否存在
* @return
*/
public void checkIsExist() {
try {
Boolean flag = false;
PageUtil<Material> pageUtil = new PageUtil<Material>();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
pageUtil.setAdvSearch(getConditionCheckIsExist());
materialService.find(pageUtil);
List<Material> dataList = pageUtil.getPageList();
if(null != dataList && dataList.size() > 0){
flag = true;
}
else{
flag = false;
}
//回写查询结果
toClient(flag.toString());
}
catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找商品信息异常", e);
}
catch (IOException e) {
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询商品信息结果异常", e);
}
}
/**
* 查找商品信息
......@@ -211,6 +295,7 @@ public class MaterialAction extends BaseAction<MaterialModel>
pageUtil.setAdvSearch(getCondition());
}
materialService.find(pageUtil);
getSession().put("pageUtilMaterial", pageUtil);
List<Material> dataList = pageUtil.getPageList();
JSONObject outer = new JSONObject();
......@@ -224,6 +309,11 @@ public class MaterialAction extends BaseAction<MaterialModel>
JSONObject item = new JSONObject();
item.put("Id", material.getId());
item.put("Name", material.getName());
item.put("CategoryId", material.getMaterialCategory().getId()); //类型Id
item.put("CategoryName", material.getMaterialCategory().getName()); //类型名称
item.put("Mfrs", material.getMfrs()==null?"" : material.getMfrs());
item.put("Packing", material.getPacking()==null?"" : material.getPacking());
item.put("SafetyStock", material.getSafetyStock()==null?"" : material.getSafetyStock());
item.put("Model", material.getModel()==null?"" : material.getModel());
item.put("Standard", material.getStandard()==null?"": material.getStandard());
item.put("Color", material.getColor()==null?"": material.getColor());
......@@ -232,6 +322,12 @@ public class MaterialAction extends BaseAction<MaterialModel>
item.put("LowPrice", material.getLowPrice());
item.put("PresetPriceOne", material.getPresetPriceOne()==null? "":material.getPresetPriceOne());
item.put("PresetPriceTwo", material.getPresetPriceTwo()==null? "":material.getPresetPriceTwo());
item.put("UnitId",material.getUnitId()==null? "": material.getUnitId().getId()); //计量单位Id
item.put("UnitName", material.getUnitId()==null? "": material.getUnitId().getUName()); //计量单位名称
item.put("FirstOutUnit", material.getFirstOutUnit());
item.put("FirstInUnit", material.getFirstInUnit());
item.put("PriceStrategy", material.getPriceStrategy());
item.put("Enabled", material.getEnabled());
item.put("Remark", material.getRemark());
item.put("op", 1);
dataArray.add(item);
......@@ -273,6 +369,9 @@ public class MaterialAction extends BaseAction<MaterialModel>
JSONObject item = new JSONObject();
item.put("Id", material.getId());
item.put("Name", material.getName());
item.put("Mfrs", material.getMfrs()==null?"" : material.getMfrs());
item.put("Packing", material.getPacking()==null?"" : material.getPacking());
item.put("SafetyStock", material.getSafetyStock()==null?"" : material.getSafetyStock());
item.put("Model", material.getModel());
item.put("Standard", material.getStandard());
item.put("Color", material.getColor());
......@@ -281,6 +380,11 @@ public class MaterialAction extends BaseAction<MaterialModel>
item.put("LowPrice", material.getLowPrice());
item.put("PresetPriceOne", material.getPresetPriceOne());
item.put("PresetPriceTwo", material.getPresetPriceTwo());
item.put("UnitId",material.getUnitId()==null? "": material.getUnitId().getId()); //计量单位Id
item.put("UnitName", material.getUnitId()==null? "": material.getUnitId().getUName()); //计量单位名称
item.put("FirstOutUnit", material.getFirstOutUnit());
item.put("FirstInUnit", material.getFirstInUnit());
item.put("PriceStrategy", material.getPriceStrategy());
item.put("Remark", material.getRemark());
item.put("op", 1);
dataArray.add(item);
......@@ -304,10 +408,8 @@ public class MaterialAction extends BaseAction<MaterialModel>
* 查找商品信息-下拉框
* @return
*/
public void findBySelect()
{
try
{
public void findBySelect() {
try {
PageUtil<Material> pageUtil = new PageUtil<Material>();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
......@@ -316,17 +418,22 @@ public class MaterialAction extends BaseAction<MaterialModel>
List<Material> dataList = pageUtil.getPageList();
//存放数据json数组
JSONArray dataArray = new JSONArray();
if(null != dataList)
{
for(Material material:dataList)
{
if(null != dataList) {
for(Material material:dataList) {
JSONObject item = new JSONObject();
item.put("Id", material.getId());
//名称
String MaterialName = ((material.getModel() == null || material.getModel().equals(""))?"":material.getModel() +" ") + material.getName()
+ ((material.getStandard() == null || material.getStandard().equals(""))?"":"("+material.getStandard() + ")")
+ ((material.getColor() == null || material.getColor().equals(""))?"":"("+material.getColor() + ")")
+ ((material.getUnit() == null || material.getUnit().equals(""))?"":"("+material.getUnit() + ")");
String ratio; //比例
if(material.getUnitId() == null || material.getUnitId().equals("")){
ratio = "";
}
else {
ratio = material.getUnitId().getUName();
ratio = ratio.substring(ratio.indexOf("("));
}
//品名/型号/制造商/包装
String MaterialName = material.getName() + ((material.getModel() == null || material.getModel().equals(""))?"":"("+material.getModel() + ")")
+ ((material.getMfrs() == null || material.getMfrs().equals(""))?"":"("+material.getMfrs() + ")")
+ ratio;
item.put("MaterialName", MaterialName);
dataArray.add(item);
}
......@@ -334,12 +441,10 @@ public class MaterialAction extends BaseAction<MaterialModel>
//回写查询结果
toClient(dataArray.toString());
}
catch (DataAccessException e)
{
catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>查找供应商信息异常", e);
}
catch (IOException e)
{
catch (IOException e) {
Log.errorFileSync(">>>>>>>>>回写查询供应商信息结果异常", e);
}
}
......@@ -384,6 +489,67 @@ public class MaterialAction extends BaseAction<MaterialModel>
Log.errorFileSync(">>>>>>>>>回写查询供应商信息结果异常", e);
}
}
/**
* 导入excel表格-供应商
* @return
*/
@SuppressWarnings("unchecked")
public String importExcel() {
//excel表格file
Boolean result = false;
String returnStr = "";
try {
InputStream in = materialService.importExcel(model.getMaterialFile());
if(null != in)
{
model.setFileName(Tools.getRandomChar() + Tools.getNow2(Calendar.getInstance().getTime()) + "_wrong.xls");
model.setExcelStream(in);
returnStr = MaterialConstants.BusinessForExcel.EXCEL;
}
else {
result = true;
try {
toClient(result.toString());
} catch (IOException e) {
Log.errorFileSync(">>>>>>>>>回写导入信息结果异常", e);
}
//导入数据成功
returnStr = SUCCESS;
}
}
catch (JshException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>导入excel表格信息异常", e);
}
return returnStr;
}
/**
* 导出excel表格
* @return
*/
@SuppressWarnings("unchecked")
public String exportExcel() {
Log.infoFileSync("===================调用导出信息action方法exportExcel开始=======================");
try {
String sName = "pageUtilMaterial";
PageUtil<Material> pageUtil = (PageUtil<Material>)getSession().get(sName);
pageUtil.setPageSize(model.getPageSize());
pageUtil.setCurPage(model.getPageNo());
String isCurrentPage = "allPage";
model.setFileName(Tools.changeUnicode("goods" + System.currentTimeMillis() + ".xls", model.getBrowserType()));
model.setExcelStream(materialService.exmportExcel(isCurrentPage,pageUtil));
}
catch (Exception e) {
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>调用导出信息action方法exportExcel异常",e);
model.getShowModel().setMsgTip("export excel exception");
}
Log.infoFileSync("===================调用导出信息action方法exportExcel结束==================");
return EXCEL;
}
/**
* 拼接搜索条件(查全部)
......@@ -395,6 +561,9 @@ public class MaterialAction extends BaseAction<MaterialModel>
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("Name_s_like", model.getName());
condition.put("Model_s_like", model.getModel());
condition.put("Mfrs_s_like", model.getMfrs());
condition.put("Id_s_order", "asc");
return condition;
}
......@@ -403,17 +572,36 @@ public class MaterialAction extends BaseAction<MaterialModel>
* 拼接搜索条件
* @return
*/
private Map<String,Object> getCondition()
{
private Map<String,Object> getCondition() {
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("Name_s_like", model.getName());
condition.put("Model_s_like", model.getModel());
condition.put("Mfrs_s_like", model.getMfrs());
condition.put("CategoryId_s_in", model.getCategoryIds());
condition.put("Id_s_order", "asc");
return condition;
}
private Map<String,Object> getConditionCheckIsExist() {
Map<String,Object> condition = new HashMap<String,Object>();
if(model.getMaterialID()>0){
condition.put("ID_n_neq", model.getMaterialID());
}
condition.put("Name_s_eq", model.getName());
condition.put("Model_s_eq", model.getModel());
condition.put("Mfrs_s_eq", model.getMfrs());
if(model.getUnit()!=null){
condition.put("Unit_s_eq", model.getUnit());
}
if(model.getUnitId()!=null){
condition.put("UnitId_n_eq", model.getUnitId());
}
return condition;
}
/**
* 拼接搜索条件
* @return
......@@ -438,6 +626,7 @@ public class MaterialAction extends BaseAction<MaterialModel>
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("enabled_s_eq",1);
condition.put("Id_s_order", "asc");
return condition;
}
......
......@@ -245,6 +245,36 @@ public class MaterialCategoryAction extends BaseAction<MaterialCategoryModel>
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询商品类别信息结果异常", e);
}
}
/**
* 根据id来查询商品名称
* @return
*/
public void findById() {
try {
PageUtil<MaterialCategory> pageUtil = new PageUtil<MaterialCategory>();
pageUtil.setAdvSearch(getConditionById());
materialCategoryService.find(pageUtil);
List<MaterialCategory> dataList = pageUtil.getPageList();
JSONObject outer = new JSONObject();
if(null != dataList) {
for(MaterialCategory materialCategory : dataList) {
outer.put("name", materialCategory.getName());
outer.put("parentId", materialCategory.getMaterialCategory().getId());
}
}
//回写查询结果
toClient(outer.toString());
}
catch (DataAccessException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找商品类别信息异常", e);
}
catch (IOException e)
{
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询商品类别信息结果异常", e);
}
}
/**
* 拼接搜索条件
......@@ -256,11 +286,25 @@ public class MaterialCategoryAction extends BaseAction<MaterialCategoryModel>
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("Name_s_like", model.getName());
condition.put("ParentId_n_eq", model.getParentId());
condition.put("Id_n_neq", 1);
condition.put("Id_s_order", "asc");
return condition;
}
/**
* 拼接搜索条件
* @return
*/
private Map<String,Object> getConditionById(){
/**
* 拼接搜索条件
*/
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("Id_n_eq", model.getMaterialCategoryID());
return condition;
}
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
@Override
......
......@@ -70,6 +70,81 @@ public class PersonAction extends BaseAction<PersonModel>
}
return SUCCESS;
}
/**
* 根据类型获取经手人信息 1-业务员,2-仓管员,3-财务员
* @return
*/
public void getPersonByNumType() {
try {
PageUtil<Person> pageUtil = new PageUtil<Person>();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
Map<String,Object> condition = pageUtil.getAdvSearch();
String type = "";
if(model.getType().equals("1")){
type = "业务员";
}
else if(model.getType().equals("2")){
type = "仓管员";
}
else if(model.getType().equals("3")){
type = "财务员";
}
condition.put("Type_s_eq",type);
condition.put("Id_s_order", "asc");
personService.find(pageUtil);
List<Person> dataList = pageUtil.getPageList();
JSONArray dataArray = new JSONArray();
if(null != dataList) {
for(Person person:dataList){
JSONObject item = new JSONObject();
item.put("id", person.getId());
item.put("name", person.getName());
dataArray.add(item);
}
}
//回写查询结果
toClient(dataArray.toString());
}
catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>查找信息异常", e);
}
catch (IOException e) {
Log.errorFileSync(">>>>>>>>>回写查询信息结果异常", e);
}
}
/**
* 根据Id获取经手人信息
* @return
*/
public void getPersonByIds() {
try {
PageUtil<Person> pageUtil = new PageUtil<Person>();
pageUtil.setPageSize(0);
pageUtil.setCurPage(0);
Map<String,Object> condition = pageUtil.getAdvSearch();
condition.put("Id_s_in", model.getPersonIDs());
condition.put("Id_s_order", "asc");
personService.find(pageUtil);
List<Person> dataList = pageUtil.getPageList();
StringBuffer sb = new StringBuffer();
if(null != dataList) {
for(Person person:dataList){
sb.append(person.getName() + " ");
}
}
//回写查询结果
toClient(sb.toString());
}
catch (DataAccessException e) {
Log.errorFileSync(">>>>>>>>>查找信息异常", e);
}
catch (IOException e) {
Log.errorFileSync(">>>>>>>>>回写查询信息结果异常", e);
}
}
/**
* 增加经手人
......
......@@ -2,7 +2,7 @@ package com.jsh.dao.basic;
import com.jsh.base.BaseDAO;
import com.jsh.model.po.Supplier;
import com.jsh.util.PageUtil;
import com.jsh.util.JshException;
import com.jsh.util.SearchConditionUtil;
import org.hibernate.Query;
......@@ -18,4 +18,11 @@ public class SupplierDAO extends BaseDAO<Supplier> implements SupplierIDAO
return Supplier.class;
}
@SuppressWarnings("unchecked")
@Override
public void batchSetEnable(Boolean enable,String supplierIDs) {
String sql="update jsh_supplier s set s.enabled=" + enable + " where s.id in (" + supplierIDs + ")";
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(sql);
query.executeUpdate();
}
}
......@@ -5,4 +5,5 @@ import com.jsh.model.po.Supplier;
public interface SupplierIDAO extends BaseIDAO<Supplier>
{
public void batchSetEnable(Boolean enable,String supplierIDs);
}
package com.jsh.dao.basic;
import com.jsh.base.BaseDAO;
import com.jsh.model.po.Unit;
public class UnitDAO extends BaseDAO<Unit> implements UnitIDAO
{
/**
* 设置dao映射基类
* @return
*/
@Override
public Class<Unit> getEntityClass()
{
return Unit.class;
}
}
package com.jsh.dao.basic;
import com.jsh.base.BaseIDAO;
import com.jsh.model.po.Unit;
public interface UnitIDAO extends BaseIDAO<Unit>
{
}
......@@ -5,12 +5,10 @@ import org.hibernate.Query;
import com.jsh.base.BaseDAO;
import com.jsh.util.JshException;
import com.jsh.model.po.DepotHead;
import com.jsh.model.po.UserBusiness;
import com.jsh.util.PageUtil;
import com.jsh.util.SearchConditionUtil;
public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO
{
public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO {
/**
* 设置dao映射基类
* @return
......@@ -46,67 +44,10 @@ public class DepotHeadDAO extends BaseDAO<DepotHead> implements DepotHeadIDAO
}
@SuppressWarnings("unchecked")
public void findInDetail(PageUtil pageUtil,String beginTime,String endTime,String type,Long pid,String dids) throws JshException {
StringBuffer queryString = new StringBuffer();
queryString.append("select dh.Number,m.`name`,m.Model,di.UnitPrice,di.OperNumber,di.AllPrice,s.supplier,d.dName,date_format(dh.OperTime, '%Y-%m-%d') " +
"from jsh_depothead dh inner join jsh_depotitem di on di.HeaderId=dh.id " +
"inner join jsh_material m on m.id=di.MaterialId " +
"inner join jsh_supplier s on s.id=dh.OrganId " +
"inner join (select id,name as dName from jsh_depot) d on d.id=dh.ProjectId " +
"where dh.Type='"+ type +"' and dh.OperTime >='"+ beginTime +"' and dh.OperTime <='"+ endTime +"' ");
if(pid!=null){
queryString.append(" and dh.ProjectId=" + pid );
}
else {
queryString.append(" and dh.ProjectId in (" + dids + ")" );
}
queryString.append(" ORDER BY OperTime DESC,Number desc");
Query query;
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
pageUtil.setTotalCount(query.list().size());
// 分页查询
int pageNo = pageUtil.getCurPage();
int pageSize = pageUtil.getPageSize();
if (0 != pageNo && 0 != pageSize) {
query.setFirstResult((pageNo - 1) * pageSize);
query.setMaxResults(pageSize);
}
pageUtil.setPageList(query.list());
}
@SuppressWarnings("unchecked")
public void findInOutMaterialCount(PageUtil pageUtil,String beginTime,String endTime,String type,Long pid,String dids) throws JshException {
StringBuffer queryString = new StringBuffer();
queryString.append("select di.MaterialId, m.mName,m.Model,m.categoryName, "+
" (select sum(jsh_depotitem.AllPrice) priceSum from jsh_depothead INNER JOIN jsh_depotitem " +
"on jsh_depothead.id=jsh_depotitem.HeaderId where jsh_depotitem.MaterialId=di.MaterialId " +
" and jsh_depothead.type='"+ type +"' and dh.OperTime >='"+ beginTime +"' and dh.OperTime <='"+ endTime +"'");
if(pid!=null){
queryString.append(" and dh.ProjectId=" + pid );
}
else {
queryString.append(" and dh.ProjectId in (" + dids + ")" );
}
queryString.append(" ) priceSum from jsh_depothead dh INNER JOIN jsh_depotitem di on dh.id=di.HeaderId " +
" INNER JOIN (SELECT jsh_material.id,jsh_material.name mName, Model,jsh_materialcategory.`Name` categoryName from jsh_material INNER JOIN jsh_materialcategory on jsh_material.CategoryId=jsh_materialcategory.Id) m " +
" on m.Id=di.MaterialId where dh.type='"+ type +"' and dh.OperTime >='"+ beginTime +"' and dh.OperTime <='"+ endTime +"' ");
if(pid!=null){
queryString.append(" and dh.ProjectId=" + pid );
}
else {
queryString.append(" and dh.ProjectId in (" + dids + ")" );
}
queryString.append(" GROUP BY di.MaterialId,m.mName,m.Model,m.categoryName ");
Query query;
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
pageUtil.setTotalCount(query.list().size());
// 分页查询
int pageNo = pageUtil.getCurPage();
int pageSize = pageUtil.getPageSize();
if (0 != pageNo && 0 != pageSize) {
query.setFirstResult((pageNo - 1) * pageSize);
query.setMaxResults(pageSize);
}
pageUtil.setPageList(query.list());
@Override
public void batchSetStatus(Boolean status,String depotHeadIDs) {
String sql="update jsh_depothead d set d.Status=" + status + " where d.id in (" + depotHeadIDs + ")";
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(sql);
query.executeUpdate();
}
}
......@@ -15,8 +15,6 @@ public interface DepotHeadIDAO extends BaseIDAO<DepotHead>
void findAllMoney(PageUtil<DepotHead> pageUtil, Integer supplierId, String type, String subType, String mode) throws JshException;
public void findInDetail(PageUtil pageUtil,String beginTime,String endTime,String type,Long pid,String dids) throws JshException;
public void findInOutMaterialCount(PageUtil pageUtil,String beginTime,String endTime,String type,Long pid,String dids) throws JshException;
public void batchSetStatus(Boolean status,String depotHeadIDs);
}
......@@ -20,7 +20,7 @@ public class DepotItemDAO extends BaseDAO<DepotItem> implements DepotItemIDAO
{
return DepotItem.class;
}
@SuppressWarnings("unchecked")
@Override
public void findByType(PageUtil<DepotItem> pageUtil,String type,Integer ProjectId,Long MId,String MonthTime,Boolean isPrev) throws JshException
......@@ -29,19 +29,19 @@ public class DepotItemDAO extends BaseDAO<DepotItem> implements DepotItemIDAO
Query query;
StringBuffer queryString = new StringBuffer();
if(isPrev) {
queryString.append("select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"'");
queryString.append("select sum(BasicNumber) as BasicNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"'");
if(ProjectId!=null) {
queryString.append(" and ProjectId='" + ProjectId +"'");
queryString.append(" and DepotId='" + ProjectId +"'");
}
queryString.append(" and MaterialId ="+ MId + " and jsh_depothead.OperTime <'"+ MonthTime +"-01 00:00:00' ");
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
}
else {
queryString.append("select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"'");
queryString.append("select sum(BasicNumber) as BasicNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"'");
if(ProjectId!=null) {
queryString.append(" and ProjectId='" + ProjectId +"'");
queryString.append(" and DepotId='" + ProjectId +"'");
}
queryString.append(" and MaterialId ="+ MId + " and jsh_depothead.OperTime >='"+ MonthTime +"-01 00:00:00' and jsh_depothead.OperTime <='"+ MonthTime +"-31 00:00:00' ");
queryString.append(" and MaterialId ="+ MId + " and jsh_depothead.OperTime >='"+ MonthTime +"-01 00:00:00' and jsh_depothead.OperTime <='"+ MonthTime +"-31 59:59:59' ");
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
}
pageUtil.setTotalCount(query.list().size());
......@@ -58,16 +58,16 @@ public class DepotItemDAO extends BaseDAO<DepotItem> implements DepotItemIDAO
if (isPrev) {
queryString.append("select sum(AllPrice) as AllPrice from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type + "'");
if (ProjectId != null) {
queryString.append(" and ProjectId='" + ProjectId + "'");
queryString.append(" and DepotId='" + ProjectId + "'");
}
queryString.append(" and MaterialId =" + MId + " and jsh_depothead.OperTime <'" + MonthTime + "-01 00:00:00' ");
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
} else {
queryString.append("select sum(AllPrice) as AllPrice from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type + "'");
if (ProjectId != null) {
queryString.append(" and ProjectId='" + ProjectId + "'");
queryString.append(" and DepotId='" + ProjectId + "'");
}
queryString.append(" and MaterialId =" + MId + " and jsh_depothead.OperTime >='" + MonthTime + "-01 00:00:00' and jsh_depothead.OperTime <='" + MonthTime + "-31 00:00:00' ");
queryString.append(" and MaterialId =" + MId + " and jsh_depothead.OperTime >='" + MonthTime + "-01 00:00:00' and jsh_depothead.OperTime <='" + MonthTime + "-31 59:59:59' ");
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
}
pageUtil.setTotalCount(query.list().size());
......@@ -81,10 +81,10 @@ public class DepotItemDAO extends BaseDAO<DepotItem> implements DepotItemIDAO
//多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便
Query query;
if(sumType.equals("Number")) {
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"' and subType='" + subType +"' and MaterialId ="+ MId + " and jsh_depothead.OperTime >='"+ MonthTime +"-01 00:00:00' and jsh_depothead.OperTime <='"+ MonthTime +"-31 00:00:00' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"' and subType='" + subType +"' and MaterialId ="+ MId + " and jsh_depothead.OperTime >='"+ MonthTime +"-01 00:00:00' and jsh_depothead.OperTime <='"+ MonthTime +"-31 59:59:59' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
}
else {
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(AllPrice) as AllPrice from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"' and subType='" + subType +"' and MaterialId ="+ MId + " and jsh_depothead.OperTime >='"+ MonthTime +"-01 00:00:00' and jsh_depothead.OperTime <='"+ MonthTime +"-31 00:00:00' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(AllPrice) as AllPrice from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"' and subType='" + subType +"' and MaterialId ="+ MId + " and jsh_depothead.OperTime >='"+ MonthTime +"-01 00:00:00' and jsh_depothead.OperTime <='"+ MonthTime +"-31 59:59:59' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
}
pageUtil.setTotalCount(query.list().size());
pageUtil.setPageList(query.list());
......@@ -103,7 +103,7 @@ public class DepotItemDAO extends BaseDAO<DepotItem> implements DepotItemIDAO
queryString.append(" and AllocationProjectId='" + ProjectId +"'"); //礼品充值时
}
else if(type.equals("out")){
queryString.append(" and ProjectId='" + ProjectId +"'");
queryString.append(" and DepotId='" + ProjectId +"'");
}
}
queryString.append(" and MaterialId ="+ MId);
......
......@@ -2,6 +2,10 @@ package com.jsh.dao.materials;
import com.jsh.base.BaseDAO;
import com.jsh.model.po.Material;
import com.jsh.util.JshException;
import com.jsh.util.PageUtil;
import com.jsh.util.SearchConditionUtil;
import org.hibernate.Query;
public class MaterialDAO extends BaseDAO<Material> implements MaterialIDAO
{
......@@ -14,4 +18,25 @@ public class MaterialDAO extends BaseDAO<Material> implements MaterialIDAO
{
return Material.class;
}
@SuppressWarnings("unchecked")
@Override
public void batchSetEnable(Boolean enable,String supplierIDs) {
String sql="update jsh_material m set m.enabled=" + enable + " where m.id in (" + supplierIDs + ")";
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(sql);
query.executeUpdate();
}
@SuppressWarnings("unchecked")
@Override
public void findUnitName(PageUtil<Material> pageUtil,Long mId) throws JshException {
//多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便,
StringBuffer queryString = new StringBuffer();
queryString.append("select jsh_unit.UName from jsh_unit inner join jsh_material on UnitId=jsh_unit.id where jsh_material.id="+mId);
Query query;
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
pageUtil.setTotalCount(query.list().size());
pageUtil.setPageList(query.list());
}
}
......@@ -2,8 +2,12 @@ package com.jsh.dao.materials;
import com.jsh.base.BaseIDAO;
import com.jsh.model.po.Material;
import com.jsh.util.JshException;
import com.jsh.util.PageUtil;
public interface MaterialIDAO extends BaseIDAO<Material>
{
public void batchSetEnable(Boolean enable,String supplierIDs);
public void findUnitName(PageUtil<Material> pageUtil,Long mId) throws JshException;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment