更新后端代码
This commit is contained in:
@@ -62,37 +62,62 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加仓管通
|
||||
* 增加单据
|
||||
* @return
|
||||
*/
|
||||
public void create()
|
||||
{
|
||||
Log.infoFileSync("==================开始调用增加仓管通信息信息方法create()===================");
|
||||
public void create(){
|
||||
Log.infoFileSync("==================开始调用增加单据信息信息方法create()===================");
|
||||
Boolean flag = false;
|
||||
try
|
||||
{
|
||||
DepotHead depotHead = new DepotHead();
|
||||
depotHead.setType(model.getType());
|
||||
depotHead.setSubType(model.getSubType());
|
||||
depotHead.setProjectId(new Depot(model.getProjectId()));
|
||||
depotHead.setNumber(model.getNumber());
|
||||
if(model.getProjectId()!=null){depotHead.setProjectId(new Depot(model.getProjectId()));}
|
||||
//构造新的编号
|
||||
String number = model.getNumber();
|
||||
String allNewNumber = "";
|
||||
if(number.equals(model.getDefaultNumber())){ //两个编号一致说明没有修改过
|
||||
number = number.substring(0,12); //截取前缀
|
||||
String beginTime = Tools.getNow() + " 00:00:00";
|
||||
String endTime = Tools.getNow() + " 23:59:59";
|
||||
String newNumber = buildNumberFun(model.getType(), model.getSubType(), beginTime, endTime); //从数据库查询最新的编号+1,这样能防止重复
|
||||
allNewNumber = number + newNumber;
|
||||
depotHead.setNumber(allNewNumber);
|
||||
}
|
||||
else { //修改过的编号
|
||||
depotHead.setNumber(model.getNumber());
|
||||
}
|
||||
depotHead.setDefaultNumber(allNewNumber); //初始编号,一直都从后台取值
|
||||
|
||||
depotHead.setOperPersonName(getUser().getUsername());
|
||||
depotHead.setCreateTime(new Timestamp(new Date().getTime()));
|
||||
try
|
||||
{
|
||||
depotHead.setOperTime(new Timestamp(Tools.parse(model.getOperTime(), "yyyy-MM-dd").getTime()));
|
||||
try{
|
||||
depotHead.setOperTime(new Timestamp(Tools.parse(model.getOperTime(), "yyyy-MM-dd HH:mm:ss").getTime()));
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
catch (ParseException e){
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>解析购买日期格式异常", e);
|
||||
}
|
||||
if(model.getOrganId()!=null){depotHead.setOrganId(new Supplier(model.getOrganId()));}
|
||||
if(model.getHandsPersonId()!=null){depotHead.setHandsPersonId(new Person(model.getHandsPersonId()));}
|
||||
if(model.getHandsPersonId()!=null){depotHead.setHandsPersonId(new Person(model.getHandsPersonId()));}
|
||||
if(model.getSalesman()!=null){
|
||||
depotHead.setSalesman(model.getSalesman().toString());
|
||||
}
|
||||
if(model.getAccountId()!=null){depotHead.setAccountId(new Account(model.getAccountId()));}
|
||||
depotHead.setChangeAmount(model.getChangeAmount());
|
||||
depotHead.setAccountIdList(model.getAccountIdList());
|
||||
depotHead.setAccountMoneyList(model.getAccountMoneyList());
|
||||
depotHead.setDiscount(model.getDiscount());
|
||||
depotHead.setDiscountMoney(model.getDiscountMoney());
|
||||
depotHead.setDiscountLastMoney(model.getDiscountLastMoney());
|
||||
depotHead.setOtherMoney(model.getOtherMoney());
|
||||
depotHead.setOtherMoneyList(model.getOtherMoneyList());
|
||||
depotHead.setOtherMoneyItem(model.getOtherMoneyItem());
|
||||
depotHead.setAccountDay(model.getAccountDay());
|
||||
if(model.getAllocationProjectId()!=null){depotHead.setAllocationProjectId(new Depot(model.getAllocationProjectId()));}
|
||||
depotHead.setTotalPrice(model.getTotalPrice());
|
||||
depotHead.setPayType(model.getPayType());
|
||||
depotHead.setStatus(false);
|
||||
depotHead.setRemark(model.getRemark());
|
||||
depotHeadService.create(depotHead);
|
||||
|
||||
@@ -102,88 +127,88 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
|
||||
tipMsg = "成功";
|
||||
tipType = 0;
|
||||
}
|
||||
catch (DataAccessException e)
|
||||
{
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加仓管通信息异常", e);
|
||||
catch (DataAccessException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加单据信息异常", e);
|
||||
flag = false;
|
||||
tipMsg = "失败";
|
||||
tipType = 1;
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
finally {
|
||||
try {
|
||||
toClient(flag.toString());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Log.errorFileSync(">>>>>>>>>>>>增加仓管通信息回写客户端结果异常", e);
|
||||
catch (IOException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>增加单据信息回写客户端结果异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
logService.create(new Logdetails(getUser(), "增加仓管通", model.getClientIp(),
|
||||
logService.create(new Logdetails(getUser(), "增加单据", model.getClientIp(),
|
||||
new Timestamp(System.currentTimeMillis())
|
||||
, tipType, "增加仓管通编号为 "+ model.getNumber() + " " + tipMsg + "!", "增加仓管通" + tipMsg));
|
||||
Log.infoFileSync("==================结束调用增加仓管通方法create()===================");
|
||||
, tipType, "增加单据编号为 "+ model.getNumber() + " " + tipMsg + "!", "增加单据" + tipMsg));
|
||||
Log.infoFileSync("==================结束调用增加单据方法create()===================");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除仓管通
|
||||
* 删除单据
|
||||
* @return
|
||||
*/
|
||||
public String delete()
|
||||
{
|
||||
Log.infoFileSync("====================开始调用删除仓管通信息方法delete()================");
|
||||
try
|
||||
{
|
||||
public String delete() {
|
||||
Log.infoFileSync("====================开始调用删除单据信息方法delete()================");
|
||||
try {
|
||||
depotHeadService.delete(model.getDepotHeadID());
|
||||
tipMsg = "成功";
|
||||
tipType = 0;
|
||||
}
|
||||
catch (DataAccessException e)
|
||||
{
|
||||
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getDepotHeadID() + " 的仓管通异常", e);
|
||||
catch (DataAccessException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getDepotHeadID() + " 的单据异常", e);
|
||||
tipMsg = "失败";
|
||||
tipType = 1;
|
||||
}
|
||||
model.getShowModel().setMsgTip(tipMsg);
|
||||
logService.create(new Logdetails(getUser(), "删除仓管通", model.getClientIp(),
|
||||
logService.create(new Logdetails(getUser(), "删除单据", model.getClientIp(),
|
||||
new Timestamp(System.currentTimeMillis())
|
||||
, tipType, "删除仓管通ID为 "+ model.getDepotHeadID() + " " + tipMsg + "!", "删除仓管通" + tipMsg));
|
||||
Log.infoFileSync("====================结束调用删除仓管通信息方法delete()================");
|
||||
, tipType, "删除单据ID为 "+ model.getDepotHeadID() + " " + tipMsg + "!", "删除单据" + tipMsg));
|
||||
Log.infoFileSync("====================结束调用删除单据信息方法delete()================");
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新仓管通
|
||||
* 更新单据
|
||||
* @return
|
||||
*/
|
||||
public void update()
|
||||
{
|
||||
public void update() {
|
||||
Boolean flag = false;
|
||||
try
|
||||
{
|
||||
try {
|
||||
DepotHead depotHead = depotHeadService.get(model.getDepotHeadID());
|
||||
depotHead.setType(model.getType());
|
||||
depotHead.setSubType(model.getSubType());
|
||||
depotHead.setProjectId(new Depot(model.getProjectId()));
|
||||
if(model.getProjectId()!=null){depotHead.setProjectId(new Depot(model.getProjectId()));}
|
||||
depotHead.setNumber(model.getNumber());
|
||||
depotHead.setOperPersonName(getUser().getUsername());
|
||||
try
|
||||
{
|
||||
depotHead.setOperTime(new Timestamp(Tools.parse(model.getOperTime(), "yyyy-MM-dd").getTime()));
|
||||
try{
|
||||
depotHead.setOperTime(new Timestamp(Tools.parse(model.getOperTime(), "yyyy-MM-dd HH:mm:ss").getTime()));
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
catch (ParseException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>解析入库时间格式异常", e);
|
||||
}
|
||||
if(model.getOrganId()!=null){depotHead.setOrganId(new Supplier(model.getOrganId()));}
|
||||
if(model.getHandsPersonId()!=null){depotHead.setHandsPersonId(new Person(model.getHandsPersonId()));}
|
||||
depotHead.setSalesman(model.getSalesman());
|
||||
if(model.getAccountId()!=null){depotHead.setAccountId(new Account(model.getAccountId()));}
|
||||
depotHead.setChangeAmount(model.getChangeAmount());
|
||||
depotHead.setAccountIdList(model.getAccountIdList());
|
||||
depotHead.setAccountMoneyList(model.getAccountMoneyList());
|
||||
depotHead.setDiscount(model.getDiscount());
|
||||
depotHead.setDiscountMoney(model.getDiscountMoney());
|
||||
depotHead.setDiscountLastMoney(model.getDiscountLastMoney());
|
||||
depotHead.setOtherMoney(model.getOtherMoney());
|
||||
depotHead.setOtherMoneyList(model.getOtherMoneyList());
|
||||
depotHead.setOtherMoneyItem(model.getOtherMoneyItem());
|
||||
depotHead.setAccountDay(model.getAccountDay());
|
||||
if(model.getAllocationProjectId()!=null){depotHead.setAllocationProjectId(new Depot(model.getAllocationProjectId()));}
|
||||
depotHead.setTotalPrice(model.getTotalPrice());
|
||||
depotHead.setPayType(model.getPayType());
|
||||
depotHead.setStatus(false);
|
||||
depotHead.setRemark(model.getRemark());
|
||||
depotHeadService.update(depotHead);
|
||||
|
||||
@@ -191,31 +216,27 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
|
||||
tipMsg = "成功";
|
||||
tipType = 0;
|
||||
}
|
||||
catch (DataAccessException e)
|
||||
{
|
||||
Log.errorFileSync(">>>>>>>>>>>>>修改仓管通ID为 : " + model.getDepotHeadID() + "信息失败", e);
|
||||
catch (DataAccessException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>>修改单据ID为 : " + model.getDepotHeadID() + "信息失败", e);
|
||||
flag = false;
|
||||
tipMsg = "失败";
|
||||
tipType = 1;
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
finally {
|
||||
try {
|
||||
toClient(flag.toString());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Log.errorFileSync(">>>>>>>>>>>>修改仓管通回写客户端结果异常", e);
|
||||
catch (IOException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>修改单据回写客户端结果异常", e);
|
||||
}
|
||||
}
|
||||
logService.create(new Logdetails(getUser(), "更新仓管通", model.getClientIp(),
|
||||
logService.create(new Logdetails(getUser(), "更新单据", model.getClientIp(),
|
||||
new Timestamp(System.currentTimeMillis())
|
||||
, tipType, "更新仓管通ID为 "+ model.getDepotHeadID() + " " + tipMsg + "!", "更新仓管通" + tipMsg));
|
||||
, tipType, "更新单据ID为 "+ model.getDepotHeadID() + " " + tipMsg + "!", "更新单据" + tipMsg));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除指定ID仓管通
|
||||
* 批量删除指定ID单据
|
||||
* @return
|
||||
*/
|
||||
public String batchDelete()
|
||||
@@ -230,19 +251,130 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
|
||||
}
|
||||
catch (DataAccessException e)
|
||||
{
|
||||
Log.errorFileSync(">>>>>>>>>>>批量删除仓管通ID为:" + model.getDepotHeadIDs() + "信息异常", e);
|
||||
Log.errorFileSync(">>>>>>>>>>>批量删除单据ID为:" + model.getDepotHeadIDs() + "信息异常", e);
|
||||
tipMsg = "失败";
|
||||
tipType = 1;
|
||||
}
|
||||
|
||||
logService.create(new Logdetails(getUser(), "批量删除仓管通", model.getClientIp(),
|
||||
logService.create(new Logdetails(getUser(), "批量删除单据", model.getClientIp(),
|
||||
new Timestamp(System.currentTimeMillis())
|
||||
, tipType, "批量删除仓管通ID为 "+ model.getDepotHeadIDs() + " " + tipMsg + "!", "批量删除仓管通" + tipMsg));
|
||||
, tipType, "批量删除单据ID为 "+ model.getDepotHeadIDs() + " " + tipMsg + "!", "批量删除单据" + tipMsg));
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查找仓管通信息
|
||||
* 批量设置状态-审核或者反审核
|
||||
* @return
|
||||
*/
|
||||
public String batchSetStatus() {
|
||||
try {
|
||||
depotHeadService.batchSetStatus(model.getStatus(), model.getDepotHeadIDs());
|
||||
model.getShowModel().setMsgTip("成功");
|
||||
//记录操作日志使用
|
||||
tipMsg = "成功";
|
||||
tipType = 0;
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>批量修改状态,单据ID为:" + model.getDepotHeadIDs() + "信息异常", e);
|
||||
tipMsg = "失败";
|
||||
tipType = 1;
|
||||
}
|
||||
|
||||
logService.create(new Logdetails(getUser(), "批量修改单据状态", model.getClientIp(),
|
||||
new Timestamp(System.currentTimeMillis())
|
||||
, tipType, "批量修改状态,单据ID为 "+ model.getDepotHeadIDs() + " " + tipMsg + "!", "批量修改单据状态" + tipMsg));
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查单据编号是否存在
|
||||
*/
|
||||
public void checkIsNumberExist() {
|
||||
Boolean flag = false;
|
||||
try {
|
||||
flag = depotHeadService.checkIsNameExist("Number", model.getNumber(), "Id", model.getDepotHeadID());
|
||||
}
|
||||
catch (DataAccessException e)
|
||||
{
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>检查单据编号为:" + model.getNumber() + " ID为: " + model.getDepotHeadID() + " 是否存在出现异常!");
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
toClient(flag.toString());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Log.errorFileSync(">>>>>>>>>>>>回写检查单据编号为:" + model.getNumber() + " ID为: " + model.getDepotHeadID() + " 是否存在出现异常!",e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 单据编号生成接口,规则:查找当前类型单据下的当天最大的单据号,并加1
|
||||
*/
|
||||
public void buildNumber(){
|
||||
try {
|
||||
String beginTime = model.getBeginTime();
|
||||
String endTime = model.getEndTime();
|
||||
String newNumber = buildNumberFun(model.getType(), model.getSubType(), beginTime, endTime);
|
||||
JSONObject outer = new JSONObject();
|
||||
outer.put("DefaultNumber", newNumber);
|
||||
//回写查询结果
|
||||
toClient(outer.toString());
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>单据编号生成异常", e);
|
||||
}
|
||||
catch (IOException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写单据编号生成接口异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找单据编号
|
||||
* @return
|
||||
*/
|
||||
public String buildNumberFun(String type,String subType,String beginTime,String endTime){
|
||||
String newNumber = "0001"; //新编号
|
||||
try {
|
||||
PageUtil<DepotHead> pageUtil = new PageUtil<DepotHead>();
|
||||
pageUtil.setPageSize(0);
|
||||
pageUtil.setCurPage(0);
|
||||
pageUtil.setAdvSearch(buildNumberCondition(type, subType, beginTime, endTime));
|
||||
depotHeadService.find(pageUtil);
|
||||
List<DepotHead> dataList = pageUtil.getPageList();
|
||||
//存放数据json数组
|
||||
if (null != dataList && dataList.size() > 0) {
|
||||
DepotHead depotHead = dataList.get(0);
|
||||
if (depotHead != null) {
|
||||
String number = depotHead.getDefaultNumber(); //最大的单据编号
|
||||
if (number != null) {
|
||||
Integer lastNumber = Integer.parseInt(number.substring(12, 16)); //末四尾
|
||||
lastNumber = lastNumber + 1;
|
||||
Integer nLen = lastNumber.toString().length();
|
||||
if (nLen == 1) {
|
||||
newNumber = "000" + lastNumber.toString();
|
||||
} else if (nLen == 2) {
|
||||
newNumber = "00" + lastNumber.toString();
|
||||
} else if (nLen == 3) {
|
||||
newNumber = "0" + lastNumber.toString();
|
||||
} else if (nLen == 4) {
|
||||
newNumber = lastNumber.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>单据编号生成异常", e);
|
||||
}
|
||||
return newNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找单据信息
|
||||
* @return
|
||||
*/
|
||||
public void findBy()
|
||||
@@ -270,19 +402,30 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
|
||||
item.put("ProjectName", depotHead.getProjectId()==null?"":depotHead.getProjectId().getName());
|
||||
item.put("Number", depotHead.getNumber());
|
||||
item.put("OperPersonName", depotHead.getOperPersonName());
|
||||
item.put("CreateTime", Tools.getCurrentMonth(depotHead.getCreateTime()));
|
||||
item.put("OperTime", Tools.getCurrentMonth(depotHead.getOperTime()));
|
||||
item.put("CreateTime", Tools.getCenternTime(depotHead.getCreateTime()));
|
||||
item.put("OperTime", Tools.getCenternTime(depotHead.getOperTime()));
|
||||
item.put("OrganId", depotHead.getOrganId()==null?"":depotHead.getOrganId().getId());
|
||||
item.put("OrganName", depotHead.getOrganId()==null?"":depotHead.getOrganId().getSupplier());
|
||||
item.put("HandsPersonId", depotHead.getHandsPersonId()==null?"":depotHead.getHandsPersonId().getId());
|
||||
item.put("Salesman", depotHead.getSalesman().toString());
|
||||
item.put("HandsPersonName", depotHead.getHandsPersonId()==null?"":depotHead.getHandsPersonId().getName());
|
||||
item.put("AccountId", depotHead.getAccountId()==null?"":depotHead.getAccountId().getId());
|
||||
item.put("AccountName", depotHead.getAccountId()==null?"":depotHead.getAccountId().getName());
|
||||
item.put("ChangeAmount", depotHead.getChangeAmount()==null?"":Math.abs(depotHead.getChangeAmount()));
|
||||
item.put("AccountIdList", depotHead.getAccountIdList());
|
||||
item.put("AccountMoneyList", depotHead.getAccountMoneyList());
|
||||
item.put("Discount", depotHead.getDiscount());
|
||||
item.put("DiscountMoney", depotHead.getDiscountMoney());
|
||||
item.put("DiscountLastMoney", depotHead.getDiscountLastMoney());
|
||||
item.put("OtherMoney", depotHead.getOtherMoney());
|
||||
item.put("OtherMoneyList", depotHead.getOtherMoneyList()); //id列表
|
||||
item.put("OtherMoneyItem", depotHead.getOtherMoneyItem()); //money列表
|
||||
item.put("AccountDay", depotHead.getAccountDay()); //结算天数
|
||||
item.put("AllocationProjectId", depotHead.getAllocationProjectId()==null?"":depotHead.getAllocationProjectId().getId());
|
||||
item.put("AllocationProjectName", depotHead.getAllocationProjectId()==null?"":depotHead.getAllocationProjectId().getName());
|
||||
item.put("TotalPrice", depotHead.getTotalPrice()==null?"":Math.abs(depotHead.getTotalPrice()));
|
||||
item.put("payType", depotHead.getPayType()==null?"":depotHead.getPayType());
|
||||
item.put("Status", depotHead.getStatus());
|
||||
item.put("Remark", depotHead.getRemark());
|
||||
item.put("op", 1);
|
||||
dataArray.add(item);
|
||||
@@ -294,16 +437,16 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
|
||||
}
|
||||
catch (DataAccessException e)
|
||||
{
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓管通信息异常", e);
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找单据信息异常", e);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓管通信息结果异常", e);
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询单据信息结果异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找进销存_根据月份(报表)
|
||||
* 查找单据_根据月份(报表)
|
||||
* @return
|
||||
*/
|
||||
public void findByMonth() {
|
||||
@@ -332,11 +475,11 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
|
||||
}
|
||||
catch (DataAccessException e)
|
||||
{
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓管通信息异常", e);
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找单据信息异常", e);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓管通信息结果异常", e);
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询单据信息结果异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,10 +520,10 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
|
||||
toClient(outer.toString());
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓管通信息异常", e);
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找单据信息异常", e);
|
||||
}
|
||||
catch (IOException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓管通信息结果异常", e);
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询单据信息结果异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -449,98 +592,6 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
|
||||
}
|
||||
return allMoney;
|
||||
}
|
||||
|
||||
/**
|
||||
*入库出库明细接口
|
||||
*/
|
||||
public void findInDetail(){
|
||||
PageUtil pageUtil = new PageUtil();
|
||||
pageUtil.setPageSize(model.getPageSize());
|
||||
pageUtil.setCurPage(model.getPageNo());
|
||||
Long pid =model.getProjectId();
|
||||
String dids =model.getDepotIds();
|
||||
String beginTime = model.getBeginTime();
|
||||
String endTime = model.getEndTime();
|
||||
String type = model.getType();
|
||||
try{
|
||||
depotHeadService.findInDetail(pageUtil,beginTime,endTime,type,pid,dids);
|
||||
List dataList = pageUtil.getPageList();
|
||||
JSONObject outer = new JSONObject();
|
||||
outer.put("total", pageUtil.getTotalCount());
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if(dataList!=null){
|
||||
for(Integer i=0; i<dataList.size(); i++){
|
||||
JSONObject item = new JSONObject();
|
||||
Object dl = dataList.get(i); //获取对象
|
||||
Object[] arr = (Object[]) dl; //转为数组
|
||||
item.put("number", arr[0]); //单据编号
|
||||
item.put("materialName", arr[1]); //商品名称
|
||||
item.put("materialModel", arr[2]); //商品型号
|
||||
item.put("unitPrice", arr[3]); //单价
|
||||
item.put("operNumber", arr[4]); //入库出库数量
|
||||
item.put("allPrice", arr[5]); //金额
|
||||
item.put("supplierName", arr[6]); //供应商
|
||||
item.put("depotName", arr[7]); //仓库
|
||||
item.put("operTime", arr[8]); //入库出库日期
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
outer.put("rows", dataArray);
|
||||
//回写查询结果
|
||||
toClient(outer.toString());
|
||||
}
|
||||
catch (JshException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找信息异常", e);
|
||||
}
|
||||
catch (IOException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*入库出库统计接口
|
||||
*/
|
||||
public void findInOutMaterialCount(){
|
||||
PageUtil pageUtil = new PageUtil();
|
||||
pageUtil.setPageSize(model.getPageSize());
|
||||
pageUtil.setCurPage(model.getPageNo());
|
||||
Long pid =model.getProjectId();
|
||||
String dids =model.getDepotIds();
|
||||
String beginTime = model.getBeginTime();
|
||||
String endTime = model.getEndTime();
|
||||
String type = model.getType();
|
||||
try{
|
||||
depotHeadService.findInOutMaterialCount(pageUtil, beginTime, endTime, type, pid, dids);
|
||||
List dataList = pageUtil.getPageList();
|
||||
JSONObject outer = new JSONObject();
|
||||
outer.put("total", pageUtil.getTotalCount());
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if(dataList!=null){
|
||||
for(Integer i=0; i<dataList.size(); i++){
|
||||
JSONObject item = new JSONObject();
|
||||
Object dl = dataList.get(i); //获取对象
|
||||
Object[] arr = (Object[]) dl; //转为数组
|
||||
item.put("MaterialId", arr[0]); //商品Id
|
||||
item.put("mName", arr[1]); //商品名称
|
||||
item.put("Model", arr[2]); //商品型号
|
||||
item.put("categoryName", arr[3]); //商品类型
|
||||
item.put("priceSum", arr[4]); //金额
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
outer.put("rows", dataArray);
|
||||
//回写查询结果
|
||||
toClient(outer.toString());
|
||||
}
|
||||
catch (JshException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找信息异常", e);
|
||||
}
|
||||
catch (IOException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼接搜索条件
|
||||
@@ -552,14 +603,6 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
|
||||
* 拼接搜索条件
|
||||
*/
|
||||
Map<String,Object> condition = new HashMap<String,Object>();
|
||||
if(model.getAllocationProjectId()!=null)
|
||||
{condition.put("AllocationProjectId_n_eq", model.getAllocationProjectId());}
|
||||
if(model.getProjectId()!=null) {
|
||||
condition.put("ProjectId_n_eq", model.getProjectId());
|
||||
}
|
||||
else {
|
||||
condition.put("ProjectId_s_in", model.getDepotIds());
|
||||
}
|
||||
condition.put("Type_s_eq",model.getType());
|
||||
condition.put("SubType_s_eq",model.getSubType());
|
||||
condition.put("Number_s_like",model.getNumber());
|
||||
@@ -568,13 +611,20 @@ public class DepotHeadAction extends BaseAction<DepotHeadModel>
|
||||
condition.put("Id_s_order","desc");
|
||||
return condition;
|
||||
}
|
||||
|
||||
private Map<String,Object> buildNumberCondition(String type,String subType,String beginTime,String endTime) {
|
||||
Map<String,Object> condition = new HashMap<String,Object>();
|
||||
condition.put("Type_s_eq", type);
|
||||
condition.put("SubType_s_eq", subType);
|
||||
condition.put("OperTime_s_gteq",beginTime);
|
||||
condition.put("OperTime_s_lteq",endTime);
|
||||
condition.put("Id_s_order","desc");
|
||||
return condition;
|
||||
}
|
||||
|
||||
private Map<String,Object> getConditionHead()
|
||||
{
|
||||
Map<String,Object> condition = new HashMap<String,Object>();
|
||||
if(model.getProjectId()!=null) {
|
||||
condition.put("ProjectId_n_eq", model.getProjectId());
|
||||
}
|
||||
condition.put("OperTime_s_lteq",model.getMonthTime() + "-31 00:00:00");
|
||||
return condition;
|
||||
}
|
||||
|
||||
@@ -1,29 +1,24 @@
|
||||
package com.jsh.action.materials;
|
||||
|
||||
import java.io.File;
|
||||
import com.jsh.base.BaseAction;
|
||||
import com.jsh.base.Log;
|
||||
import com.jsh.model.po.*;
|
||||
import com.jsh.model.vo.materials.DepotItemModel;
|
||||
import com.jsh.service.materials.DepotItemIService;
|
||||
import com.jsh.service.materials.MaterialIService;
|
||||
import com.jsh.util.JshException;
|
||||
import com.jsh.util.PageUtil;
|
||||
import com.jsh.util.Tools;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
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;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
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.util.AssetConstants;
|
||||
import com.jsh.util.JshException;
|
||||
import com.jsh.model.po.Asset;
|
||||
import com.jsh.model.po.DepotHead;
|
||||
import com.jsh.model.po.DepotItem;
|
||||
import com.jsh.model.po.Logdetails;
|
||||
import com.jsh.model.po.Material;
|
||||
import com.jsh.model.vo.materials.DepotItemModel;
|
||||
import com.jsh.service.materials.DepotHeadIService;
|
||||
import com.jsh.service.materials.DepotItemIService;
|
||||
import com.jsh.util.PageUtil;
|
||||
import com.jsh.util.Tools;
|
||||
/*
|
||||
* 单据明细管理
|
||||
* @author jishenghua qq:752718920
|
||||
@@ -31,6 +26,7 @@ import com.jsh.util.Tools;
|
||||
@SuppressWarnings("serial")
|
||||
public class DepotItemAction extends BaseAction<DepotItemModel>
|
||||
{
|
||||
private MaterialIService materialService;
|
||||
private DepotItemIService depotItemService;
|
||||
private DepotItemModel model = new DepotItemModel();
|
||||
/**
|
||||
@@ -42,12 +38,10 @@ public class DepotItemAction extends BaseAction<DepotItemModel>
|
||||
* 保存明细
|
||||
* @return
|
||||
*/
|
||||
public void saveDetials()
|
||||
{
|
||||
public void saveDetials() {
|
||||
Log.infoFileSync("==================开始调用保存仓管通明细信息方法saveDetials()===================");
|
||||
Boolean flag = false;
|
||||
try
|
||||
{
|
||||
try {
|
||||
Long headerId=model.getHeaderId();
|
||||
String inserted=model.getInserted();
|
||||
String deleted=model.getDeleted();
|
||||
@@ -56,40 +50,146 @@ public class DepotItemAction extends BaseAction<DepotItemModel>
|
||||
JSONArray insertedJson = JSONArray.fromObject(inserted);
|
||||
JSONArray deletedJson = JSONArray.fromObject(deleted);
|
||||
JSONArray updatedJson = JSONArray.fromObject(updated);
|
||||
if(null != insertedJson)
|
||||
{
|
||||
for(int i = 0;i < insertedJson.size(); i++)
|
||||
{
|
||||
if(null != insertedJson) {
|
||||
for(int i = 0;i < insertedJson.size(); i++) {
|
||||
DepotItem depotItem = new DepotItem();
|
||||
JSONObject tempInsertedJson = JSONObject.fromObject(insertedJson.get(i));
|
||||
depotItem.setHeaderId(new DepotHead(headerId));
|
||||
depotItem.setMaterialId(new Material(tempInsertedJson.getLong("MaterialId")));
|
||||
depotItem.setOperNumber(tempInsertedJson.getDouble("OperNumber"));
|
||||
if(tempInsertedJson.get("UnitPrice")!=null){depotItem.setUnitPrice(tempInsertedJson.getDouble("UnitPrice"));}
|
||||
if(tempInsertedJson.get("AllPrice")!=null){depotItem.setAllPrice(tempInsertedJson.getDouble("AllPrice"));}
|
||||
depotItem.setMUnit(tempInsertedJson.getString("Unit"));
|
||||
if(!StringUtils.isEmpty(tempInsertedJson.get("OperNumber").toString())){
|
||||
depotItem.setOperNumber(tempInsertedJson.getDouble("OperNumber"));
|
||||
try {
|
||||
String Unit = tempInsertedJson.get("Unit").toString();
|
||||
Double oNumber = tempInsertedJson.getDouble("OperNumber");
|
||||
Long mId = Long.parseLong(tempInsertedJson.get("MaterialId").toString());
|
||||
//以下进行单位换算
|
||||
String UnitName = findUnitName(mId); //查询计量单位名称
|
||||
if(!UnitName.equals("")) {
|
||||
String UnitList = UnitName.substring(0, UnitName.indexOf("("));
|
||||
String RatioList = UnitName.substring(UnitName.indexOf("("));
|
||||
String basicUnit = UnitList.substring(0, UnitList.indexOf(",")); //基本单位
|
||||
String otherUnit = UnitList.substring(UnitList.indexOf(",")+1); //副单位
|
||||
Integer ratio = Integer.parseInt(RatioList.substring(RatioList.indexOf(":") + 1).replace(")","")); //比例
|
||||
if(Unit.equals(basicUnit)){ //如果等于基础单位
|
||||
depotItem.setBasicNumber(oNumber); //数量一致
|
||||
}
|
||||
else if(Unit.equals(otherUnit)){ //如果等于副单位
|
||||
depotItem.setBasicNumber(oNumber*ratio); //数量乘以比例
|
||||
}
|
||||
}
|
||||
else {
|
||||
depotItem.setBasicNumber(oNumber); //其他情况
|
||||
}
|
||||
}
|
||||
catch(Exception e){
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>设置基础数量异常", e);
|
||||
}
|
||||
}
|
||||
if(!StringUtils.isEmpty(tempInsertedJson.get("UnitPrice").toString())){
|
||||
depotItem.setUnitPrice(tempInsertedJson.getDouble("UnitPrice"));
|
||||
}
|
||||
if(!StringUtils.isEmpty(tempInsertedJson.get("TaxUnitPrice").toString())){
|
||||
depotItem.setTaxUnitPrice(tempInsertedJson.getDouble("TaxUnitPrice"));
|
||||
}
|
||||
if(!StringUtils.isEmpty(tempInsertedJson.get("AllPrice").toString())){
|
||||
depotItem.setAllPrice(tempInsertedJson.getDouble("AllPrice"));
|
||||
}
|
||||
depotItem.setRemark(tempInsertedJson.getString("Remark"));
|
||||
if(tempInsertedJson.get("DepotId")!=null && !StringUtils.isEmpty(tempInsertedJson.get("DepotId").toString())){
|
||||
depotItem.setDepotId(new Depot(tempInsertedJson.getLong("DepotId")));
|
||||
}
|
||||
if(tempInsertedJson.get("AnotherDepotId")!=null && !StringUtils.isEmpty(tempInsertedJson.get("AnotherDepotId").toString())){
|
||||
depotItem.setAnotherDepotId(new Depot(tempInsertedJson.getLong("AnotherDepotId")));
|
||||
}
|
||||
if(!StringUtils.isEmpty(tempInsertedJson.get("TaxRate").toString())){
|
||||
depotItem.setTaxRate(tempInsertedJson.getDouble("TaxRate"));
|
||||
}
|
||||
if(!StringUtils.isEmpty(tempInsertedJson.get("TaxMoney").toString())){
|
||||
depotItem.setTaxMoney(tempInsertedJson.getDouble("TaxMoney"));
|
||||
}
|
||||
if(!StringUtils.isEmpty(tempInsertedJson.get("TaxLastMoney").toString())){
|
||||
depotItem.setTaxLastMoney(tempInsertedJson.getDouble("TaxLastMoney"));
|
||||
}
|
||||
if(tempInsertedJson.get("OtherField1")!=null){depotItem.setOtherField1(tempInsertedJson.getString("OtherField1"));}
|
||||
if(tempInsertedJson.get("OtherField2")!=null){depotItem.setOtherField2(tempInsertedJson.getString("OtherField2"));}
|
||||
if(tempInsertedJson.get("OtherField3")!=null){depotItem.setOtherField3(tempInsertedJson.getString("OtherField3"));}
|
||||
if(tempInsertedJson.get("OtherField4")!=null){depotItem.setOtherField4(tempInsertedJson.getString("OtherField4"));}
|
||||
if(tempInsertedJson.get("OtherField5")!=null){depotItem.setOtherField5(tempInsertedJson.getString("OtherField5"));}
|
||||
depotItemService.create(depotItem);
|
||||
}
|
||||
}
|
||||
if(null != deletedJson)
|
||||
{
|
||||
for(int i = 0;i < deletedJson.size(); i++)
|
||||
{
|
||||
if(null != deletedJson) {
|
||||
for(int i = 0;i < deletedJson.size(); i++) {
|
||||
JSONObject tempDeletedJson = JSONObject.fromObject(deletedJson.get(i));
|
||||
depotItemService.delete(tempDeletedJson.getLong("Id"));
|
||||
}
|
||||
}
|
||||
if(null != updatedJson)
|
||||
{
|
||||
for(int i = 0;i < updatedJson.size(); i++)
|
||||
{
|
||||
if(null != updatedJson) {
|
||||
for(int i = 0;i < updatedJson.size(); i++) {
|
||||
JSONObject tempUpdatedJson = JSONObject.fromObject(updatedJson.get(i));
|
||||
DepotItem depotItem = depotItemService.get(tempUpdatedJson.getLong("Id"));
|
||||
depotItem.setMaterialId(new Material(tempUpdatedJson.getLong("MaterialId")));
|
||||
depotItem.setOperNumber(tempUpdatedJson.getDouble("OperNumber"));
|
||||
if(tempUpdatedJson.get("UnitPrice")!=null){depotItem.setUnitPrice(tempUpdatedJson.getDouble("UnitPrice"));}
|
||||
if(tempUpdatedJson.get("AllPrice")!=null){depotItem.setAllPrice(tempUpdatedJson.getDouble("AllPrice"));}
|
||||
depotItem.setMUnit(tempUpdatedJson.getString("Unit"));
|
||||
if(!StringUtils.isEmpty(tempUpdatedJson.get("OperNumber").toString())){
|
||||
depotItem.setOperNumber(tempUpdatedJson.getDouble("OperNumber"));
|
||||
try {
|
||||
String Unit = tempUpdatedJson.get("Unit").toString();
|
||||
Double oNumber = tempUpdatedJson.getDouble("OperNumber");
|
||||
Long mId = Long.parseLong(tempUpdatedJson.get("MaterialId").toString());
|
||||
//以下进行单位换算
|
||||
String UnitName = findUnitName(mId); //查询计量单位名称
|
||||
if(!UnitName.equals("")) {
|
||||
String UnitList = UnitName.substring(0, UnitName.indexOf("("));
|
||||
String RatioList = UnitName.substring(UnitName.indexOf("("));
|
||||
String basicUnit = UnitList.substring(0, UnitList.indexOf(",")); //基本单位
|
||||
String otherUnit = UnitList.substring(UnitList.indexOf(",")+1); //副单位
|
||||
Integer ratio = Integer.parseInt(RatioList.substring(RatioList.indexOf(":") + 1).replace(")","")); //比例
|
||||
if(Unit.equals(basicUnit)){ //如果等于基础单位
|
||||
depotItem.setBasicNumber(oNumber); //数量一致
|
||||
}
|
||||
else if(Unit.equals(otherUnit)){ //如果等于副单位
|
||||
depotItem.setBasicNumber(oNumber*ratio); //数量乘以比例
|
||||
}
|
||||
}
|
||||
else {
|
||||
depotItem.setBasicNumber(oNumber); //其他情况
|
||||
}
|
||||
}
|
||||
catch(Exception e){
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>设置基础数量异常", e);
|
||||
}
|
||||
}
|
||||
if(!StringUtils.isEmpty(tempUpdatedJson.get("UnitPrice").toString())){
|
||||
depotItem.setUnitPrice(tempUpdatedJson.getDouble("UnitPrice"));
|
||||
}
|
||||
if(!StringUtils.isEmpty(tempUpdatedJson.get("TaxUnitPrice").toString())){
|
||||
depotItem.setTaxUnitPrice(tempUpdatedJson.getDouble("TaxUnitPrice"));
|
||||
}
|
||||
if(!StringUtils.isEmpty(tempUpdatedJson.get("AllPrice").toString())){
|
||||
depotItem.setAllPrice(tempUpdatedJson.getDouble("AllPrice"));
|
||||
}
|
||||
depotItem.setRemark(tempUpdatedJson.getString("Remark"));
|
||||
if(tempUpdatedJson.get("DepotId")!=null && !StringUtils.isEmpty(tempUpdatedJson.get("DepotId").toString())){
|
||||
depotItem.setDepotId(new Depot(tempUpdatedJson.getLong("DepotId")));
|
||||
}
|
||||
if(tempUpdatedJson.get("AnotherDepotId")!=null && !StringUtils.isEmpty(tempUpdatedJson.get("AnotherDepotId").toString())){
|
||||
depotItem.setAnotherDepotId(new Depot(tempUpdatedJson.getLong("AnotherDepotId")));
|
||||
}
|
||||
if(!StringUtils.isEmpty(tempUpdatedJson.get("TaxRate").toString())){
|
||||
depotItem.setTaxRate(tempUpdatedJson.getDouble("TaxRate"));
|
||||
}
|
||||
if(!StringUtils.isEmpty(tempUpdatedJson.get("TaxMoney").toString())){
|
||||
depotItem.setTaxMoney(tempUpdatedJson.getDouble("TaxMoney"));
|
||||
}
|
||||
if(!StringUtils.isEmpty(tempUpdatedJson.get("TaxLastMoney").toString())){
|
||||
depotItem.setTaxLastMoney(tempUpdatedJson.getDouble("TaxLastMoney"));
|
||||
}
|
||||
depotItem.setOtherField1(tempUpdatedJson.getString("OtherField1"));
|
||||
depotItem.setOtherField2(tempUpdatedJson.getString("OtherField2"));
|
||||
depotItem.setOtherField3(tempUpdatedJson.getString("OtherField3"));
|
||||
depotItem.setOtherField4(tempUpdatedJson.getString("OtherField4"));
|
||||
depotItem.setOtherField5(tempUpdatedJson.getString("OtherField5"));
|
||||
depotItemService.create(depotItem);
|
||||
}
|
||||
}
|
||||
@@ -100,21 +200,17 @@ public class DepotItemAction extends BaseAction<DepotItemModel>
|
||||
tipMsg = "成功";
|
||||
tipType = 0;
|
||||
}
|
||||
catch (DataAccessException e)
|
||||
{
|
||||
catch (DataAccessException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>保存仓管通明细信息异常", e);
|
||||
flag = false;
|
||||
tipMsg = "失败";
|
||||
tipType = 1;
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
finally {
|
||||
try {
|
||||
toClient(flag.toString());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
catch (IOException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>保存仓管通明细信息回写客户端结果异常", e);
|
||||
}
|
||||
}
|
||||
@@ -125,15 +221,39 @@ public class DepotItemAction extends BaseAction<DepotItemModel>
|
||||
Log.infoFileSync("==================结束调用保存仓管通明细方法saveDetials()===================");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询计量单位信息
|
||||
* @return
|
||||
*/
|
||||
public String findUnitName(Long mId){
|
||||
String unitName ="";
|
||||
PageUtil pageUtil = new PageUtil();
|
||||
pageUtil.setPageSize(0);
|
||||
pageUtil.setCurPage(0);
|
||||
try {
|
||||
materialService.findUnitName(pageUtil, mId);
|
||||
unitName = pageUtil.getPageList().toString();
|
||||
if(unitName!=null){
|
||||
unitName = unitName.substring(1,unitName.length()-1);
|
||||
if(unitName.equals("null")){
|
||||
unitName = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (JshException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return unitName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查找仓管通信息
|
||||
* 查找明细信息
|
||||
* @return
|
||||
*/
|
||||
public void findBy()
|
||||
{
|
||||
try
|
||||
{
|
||||
public void findBy() {
|
||||
try {
|
||||
PageUtil<DepotItem> pageUtil = new PageUtil<DepotItem>();
|
||||
pageUtil.setPageSize(model.getPageSize());
|
||||
pageUtil.setCurPage(model.getPageNo());
|
||||
@@ -145,23 +265,44 @@ public class DepotItemAction extends BaseAction<DepotItemModel>
|
||||
outer.put("total", pageUtil.getTotalCount());
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if(null != dataList)
|
||||
{
|
||||
for(DepotItem depotItem:dataList)
|
||||
{
|
||||
if(null != dataList) {
|
||||
for(DepotItem depotItem:dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("Id", depotItem.getId());
|
||||
item.put("MaterialId", depotItem.getMaterialId()==null?"":depotItem.getMaterialId().getId());
|
||||
String MaterialName = ((depotItem.getMaterialId().getModel() == null||depotItem.getMaterialId().getModel().equals(""))?"":depotItem.getMaterialId().getModel()+" ") + depotItem.getMaterialId().getName()
|
||||
+((depotItem.getMaterialId().getStandard() == null||depotItem.getMaterialId().getStandard().equals(""))?"":"("+depotItem.getMaterialId().getStandard() + ")")
|
||||
+((depotItem.getMaterialId().getColor() == null||depotItem.getMaterialId().getColor().equals(""))?"":"("+depotItem.getMaterialId().getColor() + ")")
|
||||
+((depotItem.getMaterialId().getUnit() == null||depotItem.getMaterialId().getUnit().equals(""))?"":"("+depotItem.getMaterialId().getUnit() + ")");
|
||||
String ratio; //比例
|
||||
if(depotItem.getMaterialId().getUnitId() == null || depotItem.getMaterialId().getUnitId().equals("")){
|
||||
ratio = "";
|
||||
}
|
||||
else {
|
||||
ratio = depotItem.getMaterialId().getUnitId().getUName();
|
||||
ratio = ratio.substring(ratio.indexOf("("));
|
||||
}
|
||||
//品名/型号/制造商/包装
|
||||
String MaterialName = depotItem.getMaterialId().getName() + ((depotItem.getMaterialId().getModel() == null||depotItem.getMaterialId().getModel().equals(""))?"":"("+depotItem.getMaterialId().getModel()+ ")")
|
||||
+((depotItem.getMaterialId().getMfrs() == null||depotItem.getMaterialId().getMfrs().equals(""))?"":"("+depotItem.getMaterialId().getMfrs() + ")")
|
||||
+ ratio;
|
||||
item.put("MaterialName", MaterialName);
|
||||
item.put("Unit", depotItem.getMUnit());
|
||||
item.put("OperNumber", depotItem.getOperNumber());
|
||||
item.put("BasicNumber", depotItem.getBasicNumber());
|
||||
item.put("UnitPrice", depotItem.getUnitPrice());
|
||||
item.put("TaxUnitPrice", depotItem.getTaxUnitPrice());
|
||||
item.put("AllPrice", depotItem.getAllPrice());
|
||||
item.put("Remark", depotItem.getRemark());
|
||||
item.put("Img", depotItem.getImg());
|
||||
item.put("DepotId", depotItem.getDepotId()==null?"":depotItem.getDepotId().getId());
|
||||
item.put("DepotName", depotItem.getDepotId()==null?"":depotItem.getDepotId().getName());
|
||||
item.put("AnotherDepotId", depotItem.getAnotherDepotId()==null?"":depotItem.getAnotherDepotId().getId());
|
||||
item.put("AnotherDepotName", depotItem.getAnotherDepotId()==null?"":depotItem.getAnotherDepotId().getName());
|
||||
item.put("TaxRate", depotItem.getTaxRate());
|
||||
item.put("TaxMoney", depotItem.getTaxMoney());
|
||||
item.put("TaxLastMoney", depotItem.getTaxLastMoney());
|
||||
item.put("OtherField1", depotItem.getOtherField1());
|
||||
item.put("OtherField2", depotItem.getOtherField2());
|
||||
item.put("OtherField3", depotItem.getOtherField3());
|
||||
item.put("OtherField4", depotItem.getOtherField4());
|
||||
item.put("OtherField5", depotItem.getOtherField5());
|
||||
item.put("op", 1);
|
||||
dataArray.add(item);
|
||||
}
|
||||
@@ -170,24 +311,20 @@ public class DepotItemAction extends BaseAction<DepotItemModel>
|
||||
//回写查询结果
|
||||
toClient(outer.toString());
|
||||
}
|
||||
catch (DataAccessException e)
|
||||
{
|
||||
catch (DataAccessException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓管通信息异常", e);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
catch (IOException e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓管通信息结果异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找进销存
|
||||
* 查找所有的明细
|
||||
* @return
|
||||
*/
|
||||
public void findByAll()
|
||||
{
|
||||
try
|
||||
{
|
||||
public void findByAll() {
|
||||
try {
|
||||
PageUtil<DepotItem> pageUtil = new PageUtil<DepotItem>();
|
||||
pageUtil.setPageSize(model.getPageSize());
|
||||
pageUtil.setCurPage(model.getPageNo());
|
||||
@@ -200,10 +337,8 @@ public class DepotItemAction extends BaseAction<DepotItemModel>
|
||||
//存放数据json数组
|
||||
Integer pid = model.getProjectId();
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if(null != dataList)
|
||||
{
|
||||
for(DepotItem depotItem:dataList)
|
||||
{
|
||||
if(null != dataList) {
|
||||
for(DepotItem depotItem:dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
Integer prevSum = sumNumber("入库",pid,depotItem.getMaterialId().getId(),model.getMonthTime(),true) - sumNumber("出库",pid,depotItem.getMaterialId().getId(),model.getMonthTime(),true);
|
||||
Integer InSum = sumNumber("入库",pid,depotItem.getMaterialId().getId(),model.getMonthTime(),false);
|
||||
@@ -218,7 +353,11 @@ public class DepotItemAction extends BaseAction<DepotItemModel>
|
||||
item.put("MaterialStandard", depotItem.getMaterialId().getStandard());
|
||||
item.put("MaterialColor", depotItem.getMaterialId().getColor());
|
||||
item.put("MaterialUnit", depotItem.getMaterialId().getUnit());
|
||||
item.put("UnitPrice", (prevPrice + InPrice - OutPrice)/(prevSum + InSum - OutSum));
|
||||
Double unitPrice = 0.0;
|
||||
if(prevSum + InSum - OutSum != 0.0){
|
||||
unitPrice = (prevPrice + InPrice - OutPrice)/(prevSum + InSum - OutSum);
|
||||
}
|
||||
item.put("UnitPrice", unitPrice);
|
||||
item.put("prevSum", prevSum);
|
||||
item.put("InSum", InSum);
|
||||
item.put("OutSum", OutSum);
|
||||
@@ -241,6 +380,50 @@ public class DepotItemAction extends BaseAction<DepotItemModel>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商品id和仓库id查询库存数量
|
||||
* @return
|
||||
*/
|
||||
public void findStockNumById() {
|
||||
try {
|
||||
PageUtil<DepotItem> pageUtil = new PageUtil<DepotItem>();
|
||||
pageUtil.setPageSize(model.getPageSize());
|
||||
pageUtil.setCurPage(model.getPageNo());
|
||||
pageUtil.setAdvSearch(getConditionById());
|
||||
depotItemService.find(pageUtil);
|
||||
List<DepotItem> dataList = pageUtil.getPageList();
|
||||
JSONObject outer = new JSONObject();
|
||||
outer.put("total", pageUtil.getTotalCount());
|
||||
//存放数据json数组
|
||||
Integer pid = model.getProjectId();
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if(null != dataList) {
|
||||
for(DepotItem depotItem:dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
Integer prevSum = sumNumber("入库",pid,depotItem.getMaterialId().getId(),model.getMonthTime(),true) - sumNumber("出库",pid,depotItem.getMaterialId().getId(),model.getMonthTime(),true);
|
||||
Integer InSum = sumNumber("入库",pid,depotItem.getMaterialId().getId(),model.getMonthTime(),false);
|
||||
Integer OutSum = sumNumber("出库",pid,depotItem.getMaterialId().getId(),model.getMonthTime(),false);
|
||||
item.put("MaterialId", depotItem.getMaterialId()==null?"":depotItem.getMaterialId().getId());
|
||||
item.put("MaterialName", depotItem.getMaterialId().getName());
|
||||
item.put("MaterialModel", depotItem.getMaterialId().getModel());
|
||||
item.put("thisSum", prevSum + InSum - OutSum);
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
outer.put("rows", dataArray);
|
||||
//回写查询结果
|
||||
toClient(outer.toString());
|
||||
}
|
||||
catch (DataAccessException e)
|
||||
{
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找信息异常", e);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找礼品卡信息
|
||||
* @return
|
||||
@@ -448,11 +631,9 @@ public class DepotItemAction extends BaseAction<DepotItemModel>
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public String exportExcel()
|
||||
{
|
||||
public String exportExcel() {
|
||||
Log.infoFileSync("===================调用导出信息action方法exportExcel开始=======================");
|
||||
try
|
||||
{
|
||||
try {
|
||||
PageUtil<DepotItem> pageUtil = new PageUtil<DepotItem>();
|
||||
pageUtil.setPageSize(model.getPageSize());
|
||||
pageUtil.setCurPage(model.getPageNo());
|
||||
@@ -463,10 +644,8 @@ public class DepotItemAction extends BaseAction<DepotItemModel>
|
||||
//存放数据json数组
|
||||
Integer pid = model.getProjectId();
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if(null != dataList)
|
||||
{
|
||||
for(DepotItem depotItem:dataList)
|
||||
{
|
||||
if(null != dataList) {
|
||||
for(DepotItem depotItem:dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
Integer prevSum = sumNumber("入库",pid,depotItem.getMaterialId().getId(),model.getMonthTime(),true) - sumNumber("出库",pid,depotItem.getMaterialId().getId(),model.getMonthTime(),true);
|
||||
Integer InSum = sumNumber("入库",pid,depotItem.getMaterialId().getId(),model.getMonthTime(),false);
|
||||
@@ -494,8 +673,7 @@ public class DepotItemAction extends BaseAction<DepotItemModel>
|
||||
model.setFileName(Tools.changeUnicode("report.xls",model.getBrowserType()));
|
||||
model.setExcelStream(depotItemService.exmportExcel(isCurrentPage,dataArray));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
catch (Exception e) {
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>调用导出信息action方法exportExcel异常",e);
|
||||
model.getShowModel().setMsgTip("export excel exception");
|
||||
}
|
||||
@@ -668,6 +846,15 @@ public class DepotItemAction extends BaseAction<DepotItemModel>
|
||||
condition.put("MaterialId_s_gb","aaa");
|
||||
return condition;
|
||||
}
|
||||
|
||||
private Map<String,Object> getConditionById() {
|
||||
/**
|
||||
* 拼接搜索条件
|
||||
*/
|
||||
Map<String,Object> condition = new HashMap<String,Object>();
|
||||
condition.put("MaterialId_n_eq", model.getMaterialId());
|
||||
return condition;
|
||||
}
|
||||
|
||||
//=============以下spring注入以及Model驱动公共方法,与Action处理无关==================
|
||||
@Override
|
||||
@@ -679,4 +866,8 @@ public class DepotItemAction extends BaseAction<DepotItemModel>
|
||||
{
|
||||
this.depotItemService = depotItemService;
|
||||
}
|
||||
|
||||
public void setMaterialService(MaterialIService materialService) {
|
||||
this.materialService = materialService;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加经手人
|
||||
|
||||
Reference in New Issue
Block a user