Commit 293ad776 authored by reedmi's avatar reedmi

初步完成入库单

parent bf805bbe
......@@ -3,8 +3,6 @@ package com.originspark.drp.controllers.projects.costs;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
......@@ -18,7 +16,6 @@ import com.originspark.drp.controllers.BaseController;
import com.originspark.drp.models.projects.costs.StockInCost;
import com.originspark.drp.models.projects.invoices.StockInInvoice;
import com.originspark.drp.service.projects.costs.StockInCostService;
import com.originspark.drp.util.SessionUtil;
import com.originspark.drp.util.json.FilterRequest;
import com.originspark.drp.util.json.JsonUtils;
......@@ -31,18 +28,18 @@ public class StockInCostController extends BaseController{
@RequestMapping(method = RequestMethod.POST)
@ResponseBody
public String create(@RequestBody StockInCost stockInCost,HttpServletRequest request) {
public String create(@RequestBody StockInCost stockInCost) {
StockInInvoice invoiceUI = stockInCost.getInvoice();
if(invoiceUI == null){
return failure("所选入库单不能为空");
}
StockInInvoice invoice = stockInInvoiceService.findById(invoiceUI.getId());
if(invoice == null){
return failure("你所选择的入库单不存在,请重新选择");
}
//检查该商品是否已经存在
boolean have = false;
for(StockInCost cost : invoice.getCosts()){
......@@ -51,14 +48,14 @@ public class StockInCostController extends BaseController{
break;
}
}
if(have){
if(have) {
return failure("抱歉,不能重复添加商品");
}
stockInCost.setCreatedBy(SessionUtil.getCurrentUserName(request));
stockInCost.setCreatedBy(getCurrentUser().getName());
stockInCost.setForDate(invoice.getForDate());
service.save(stockInCost);
return ok("创建成功");
}
......@@ -72,19 +69,18 @@ public class StockInCostController extends BaseController{
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
@ResponseBody
public String update(@PathVariable Long id, @RequestBody StockInCost stockInCost,HttpServletRequest request) {
public String update(@PathVariable Long id, @RequestBody StockInCost stockInCost) {
StockInCost existingStockInCost = service.findById(StockInCost.class, id);
if (existingStockInCost == null) {
return failure("您要更新的商品不存在");
return failure("您要更新的记录不存在");
}
existingStockInCost.setUnitPrice(stockInCost.getUnitPrice());
existingStockInCost.setQuantity(stockInCost.getQuantity());
existingStockInCost.setUpdatedBy(SessionUtil.getCurrentUserName(request));
existingStockInCost.setUpdatedBy(getCurrentUser().getName());
service.update(existingStockInCost);
return ok("更新成功");
}
......@@ -103,5 +99,5 @@ public class StockInCostController extends BaseController{
return ok(data, count);
}
}
......@@ -16,71 +16,43 @@ import org.springframework.web.bind.annotation.ResponseBody;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.originspark.drp.models.projects.invoices.StockInInvoice;
import com.originspark.drp.util.SessionUtil;
import com.originspark.drp.util.enums.AuditState;
import com.originspark.drp.util.json.AuditStateUpdateJson;
import com.originspark.drp.util.json.IdsJson;
import com.originspark.drp.util.json.FilterRequest;
import com.originspark.drp.util.json.IdsJson;
import com.originspark.drp.util.json.JsonUtils;
@Controller
@RequestMapping("stockInInvoice")
@RequestMapping("invoices/in")
public class StockInInvoiceController extends AbstractInvoiceController {
private Logger logger = Logger.getLogger(StockInInvoiceController.class);
/*@RequestMapping(method = RequestMethod.POST)
@RequestMapping(method = RequestMethod.POST)
@ResponseBody
public String create(@RequestBody StockInInvoice invoice,HttpServletRequest request) {
Project systemUI = invoice.getSystem();
if(systemUI == null){
return failure("所选系统不能为空");
}
Project system = projectService.findById(systemUI.getId());
if(system==null){
return failure("你所选择的系统不存在,请重新选择");
}
invoice.setMaterialKeeperName(system.getMaterialKeeperName());
invoice.setWareKeeperName(system.getWareKeeperName());
invoice.setProjectManagerName(system.getProjectManagerName());
String currentUserName = SessionUtil.getCurrentUserName(request);
invoice.setCreatedByUserName(currentUserName);
public String create(@RequestBody StockInInvoice invoice) {
invoice.setCreatedBy(getCurrentUser().getName());
StockInInvoice savedInvoice = stockInInvoiceService.save(invoice);
logger.info(">添加成功:"+savedInvoice.toString());
return ok("系统确认成功",savedInvoice.getId());
return ok("信息确认成功", savedInvoice.getId());
}
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
@ResponseBody
public String update(@PathVariable Long id, @RequestBody StockInInvoice invoice,HttpServletRequest request) {
public String update(@PathVariable Long id, @RequestBody StockInInvoice invoice) {
StockInInvoice existingInvoice = stockInInvoiceService.findById(StockInInvoice.class, id);
if (existingInvoice == null) {
return failure("您要更新的入库单不存在");
}
Project systemUI = invoice.getSystem();
if(systemUI != null){
if(systemUI.getId() != null){
Project system = projectService.findById(systemUI.getId());
existingInvoice.setSystem(system);
}
}
existingInvoice.setForDate(invoice.getForDate());
existingInvoice.setCode(invoice.getCode());
existingInvoice.setTotalPrice(invoice.getTotalPrice());
existingInvoice.setUpdatedByUserName(SessionUtil.getCurrentUserName(request));
existingInvoice.setUpdatedBy(getCurrentUser().getName());
stockInInvoiceService.update(existingInvoice);
return ok("更新成功",existingInvoice.getId());
}*/
return ok("更新成功", existingInvoice.getId());
}
@RequestMapping(method = RequestMethod.GET)
@ResponseBody
......@@ -100,8 +72,8 @@ public class StockInInvoiceController extends AbstractInvoiceController {
@RequestMapping(value = "/deleteBatch", method = RequestMethod.GET)
@ResponseBody
public String deleteBatch(HttpServletRequest request) {
String data = request.getParameter("data");
public String deleteBatch() {
String data = request().getParameter("data");
ObjectMapper mapper = new ObjectMapper();
IdsJson json = null;
......@@ -120,7 +92,7 @@ public class StockInInvoiceController extends AbstractInvoiceController {
continue;
}
StockInInvoice invoice = stockInInvoiceService.findById(StockInInvoice.class, id);
if(invoice != null && invoice.getCosts().isEmpty()){
stockInInvoiceService.delete(invoice);
logger.info(">删除成功:"+invoice.toString());
......@@ -130,46 +102,4 @@ public class StockInInvoiceController extends AbstractInvoiceController {
return ok("删除成功(注释:部分合价不为0的入库单已忽略)");
}
/*@RequestMapping(value = "/updateAuditState", method = RequestMethod.GET)
@ResponseBody
public String updateAuditStateByUser(HttpServletRequest request) {
String data = request.getParameter("data");
ObjectMapper mapper = new ObjectMapper();
AuditStateUpdateJson json = null;
try {
json = mapper.readValue(data, AuditStateUpdateJson.class);
} catch (Exception e) {
return failure("提交数据有误");
}
if (json == null) {
return failure("没有需要审核的数据");
}
// 对当前登录用户的验证
AbstractUser user = SessionUtil.getCurrentUser(request);
Long userId = json.getUserId();
String userType = json.getUserType();
if (user.getId() != userId || !user.getType().equals(userType)) {
return failure("操作失败,无审核权限");
}
AuditState state = json.getState();
for (Long id : json.getInvoiceIds()) {
if(id == null){
continue;
}
StockInInvoice inInvoice = stockInInvoiceService.findById(StockInInvoice.class, id);
updateState(inInvoice, userType, state);
stockInInvoiceService.update(inInvoice);
}
return ok("提交成功");
}*/
}
......@@ -56,6 +56,11 @@ public abstract class AbstractInvoice extends AbstractModel{
*/
private String regulator;
/**
* 领用人
*/
private String receiveMan;
public static enum COLUMNS {
STARTDATE,ENDDATE,CODE,
MINTOTAL,MAXTOTAL,PROJECT,SYSTEM,
......@@ -122,6 +127,14 @@ public abstract class AbstractInvoice extends AbstractModel{
this.totalPrice = totalPrice;
}
public String getReceiveMan() {
return receiveMan;
}
public void setReceiveMan(String receiveMan) {
this.receiveMan = receiveMan;
}
@Override
public String toString() {
return super.toString()+", code="+code+", forDate="+forDate+", totalPrice="+totalPrice;
......
......@@ -25,9 +25,9 @@ public class StockOutInvoice extends AbstractInvoice{
private List<StockOutCost> costs;
/**
* 领用人
* 联系地址
*/
private String receiveMan;
private String address;
public List<StockOutCost> getCosts() {
return costs;
......@@ -37,20 +37,15 @@ public class StockOutInvoice extends AbstractInvoice{
this.costs = costs;
}
public String getReceiveMan() {
return receiveMan;
public String getAddress() {
return address;
}
public void setReceiveMan(String receiveMan) {
this.receiveMan = receiveMan;
public void setAddress(String address) {
this.address = address;
}
public int getCostCount(){
return getCosts().size();
}
@Override
public String toString() {
return "StockInInvoice(出库单) => ["+super.toString()+", receiveMan="+receiveMan+"]";
}
}
......@@ -24,20 +24,11 @@ Ext.define("drp.app.controller.projects.invoices.StockOutInvoiceController", {
currentInvoice = null;
wareWindow= false;
invoiceGrid = panel.down('gridpanel');
//只有材料员可以新建删除出库单
/*if(user.type != "MaterialKeeper"){
invoiceGrid.down('#addOutInvoice_btn').setVisible(false);
invoiceGrid.down('#deleteOutInvoice_btn').setVisible(false);
}
if(user.type == "Leader"){
invoiceGrid.down('#operationOutInvoice_tb').setVisible(false);
}*/
}
},
//stock_in_invoice filter
'stockoutinvoiceview > gridpanel' : {
afterrender : this.buildFiltersByLoginUser,
itemdblclick : this.showUpdateOutInvoiceForm
},
......@@ -156,12 +147,6 @@ Ext.define("drp.app.controller.projects.invoices.StockOutInvoiceController", {
}, {
property : "endDate",
value : Ext.Date.format(form.down("#endDate_filter").getValue(),'Y-m-d')
}, {
property : "project",
value : form.down("#projectName_filter").getValue()
}, {
property : "system",
value : form.down("#systemName_filter").getValue()
}, {
property : "minTotal",
value : form.down("#minTotal_filter").getValue()
......@@ -175,49 +160,16 @@ Ext.define("drp.app.controller.projects.invoices.StockOutInvoiceController", {
property : "receiveManName",
value : form.down("#receiveManName_filter").getValue()
}, {
property : "materialKeeperName",
value : form.down("#materialKeeperName_filter").getValue()
property : "regulatorName",
value : form.down("#regulatorName_filter").getValue()
}, {
property : "wareKeeperName",
value : form.down("#wareKeeperName_filter").getValue()
}, {
property : "projectManagerName",
value : form.down("#projetManagerName_filter").getValue()
property : "managerName",
value : form.down("#managerName_filter").getValue()
} ]);
},
//根据当前登录用户过滤出库单
buildFiltersByLoginUser : function(grid){
var filters = [];
var index = 0;
if(user.type == "MaterialKeeper"){
filters[index++] = new Object({
property : "materialKeeperId",
value : user.id
});
}else if(user.type == "WareKeeper"){
filters[index++] = {
property : "materialKeeperAuditState",
value : "APPROVED"
};
filters[index++] = {
property : "wareKeeperId",
value : user.id
};
}else if(user.type == "ProjectManager"){
filters[index++] = new Object({
property : "wareKeeperAuditState",
value : "APPROVED"
});
filters[index++] = new Object({
property : "projectManagerId",
value : user.id
});
}
var store = grid.getStore();
store.filters.clear();
store.filter(filters);
},
//入库商品-删除
deleteStockOutCost : function(btn) {
......
......@@ -5,40 +5,16 @@ Ext.define("drp.app.model.projects.invoices.AbstractInvoiceModel", {
}, {
name : "forDate"
}, {
name : "system"
name : 'manager'
}, {
name : "system.id",
persist : false
name : 'wareKeeper'
}, {
name : "system.projectName",
persist : false
name : 'regulator'
}, {
name : "system.name",
persist : false
name : "receiveMan"
}, {
name : "totalPrice",
type : "number"
}, {
name : "materialKeeperName",
persist : false
}, {
name : "wareKeeperName",
persist : false
}, {
name : "projectManagerName",
persist : false
}, {
name : "wareKeeperAuditState",
persist : false
}, {
name : "materialKeeperAuditState",
persist : false
}, {
name : "projectManagerAuditState",
persist : false
}, {
name : "pass",
type : "boolean"
}, {
name : "costCount",
type : "int",
......
......@@ -2,7 +2,7 @@ Ext.define("drp.app.model.projects.invoices.StockInInvoiceModel", {
extend : "drp.app.model.projects.invoices.AbstractInvoiceModel",
proxy : {
type : 'rest',
url : 'stockInInvoice',
url : 'invoices/in',
reader : {
type : "json",
root : "data",
......
Ext.define("drp.app.model.projects.invoices.StockOutInvoiceModel", {
extend : "drp.app.model.projects.invoices.AbstractInvoiceModel",
fields : [{
name : "receiveMan"
name : "address"
} ],
proxy : {
type : 'rest',
url : 'stockOutInvoice',
url : 'invoices/out',
reader : {
type : "json",
root : "data",
......
......@@ -2,7 +2,7 @@ Ext.define("drp.app.store.AbstractStore", {
extend : 'Ext.data.Store',
model : 'drp.app.model.AbstractModel',
pageSize : 50,
autoLoad : false,
// autoLoad : false,
remoteFilter : true,
remoteSort : true
});
\ No newline at end of file
......@@ -22,7 +22,7 @@ Ext.define('drp.app.view.projects.resources.StockInCostShowView', {
height: 40,
items : [{
xtype : 'form',
itemId : 'systemInfo_stockInCost_form',
itemId : 'stockInCost_form',
items : [{
xtype : 'fieldcontainer',
layout : 'column',
......@@ -30,16 +30,9 @@ Ext.define('drp.app.view.projects.resources.StockInCostShowView', {
xtype : 'displayfield',
margin : '5 0 0 15',
labelWidth: 30,
name : 'system.projectName',
name : 'receiveMan',
width : 200,
fieldLabel : '项目'
}, {
xtype : 'displayfield',
margin : '5 0 0 15',
labelWidth: 30,
name : 'system.name',
width : 200,
fieldLabel : '系统'
fieldLabel : '收到'
}, {
xtype: 'displayfield',
fieldLabel: '日期',
......@@ -108,25 +101,23 @@ Ext.define('drp.app.view.projects.resources.StockInCostShowView', {
flex : 1,
margin : '0 0 0 30',
labelWidth: 50,
itemId : 'wareKeeperName_df',
fieldLabel : '库管员'
itemId : 'managerName_df',
fieldLabel : '负责人'
}, {
xtype : 'displayfield',
flex : 1,
labelWidth: 50,
itemId : 'materialKeeperName_df',
fieldLabel : '材料'
itemId : 'wareKeeperName_df',
fieldLabel : '库管'
}, {
xtype : 'displayfield',
flex : 1,
labelWidth: 60,
itemId : 'projectManagerName_df',
fieldLabel : '项目经理'
itemId : 'regulatorName_df',
fieldLabel : '经手人'
}]
}]
});
me.callParent(arguments);
}
});
\ No newline at end of file
......@@ -13,32 +13,15 @@ Ext.define('drp.app.view.projects.invoices.StockInInvoiceView', {
initComponent : function() {
var me = this;
var selModel = Ext.create('Ext.selection.CheckboxModel', {
listeners : {
selectionchange : function(sm, selections) {
me.down('#deleteInInvoice_btn').setDisabled(selections.length == 0);
me.down('#submitInInvoice_btn').setDisabled(selections.length == 0);
}
}
});
var menuItems = [{
xtype : 'button',
action : 'approveInInvoice',
icon : 'resources/images/icons/approved.gif',
text : '提交通过'
}];
if(user.type != "MaterialKeeper"){
menuItems[1]={
xtype : 'button',
action : 'unapproveInInvoice',
icon : 'resources/images/icons/unapproved.gif',
text : '失败退回'
};
}
Ext.applyIf(me, {
items : [{
......@@ -67,18 +50,6 @@ Ext.define('drp.app.view.projects.invoices.StockInInvoiceView', {
fieldLabel : '结束日期',
editable : false,
format : 'Y-m-d'
}, {
xtype : 'textfield',
margin : '5 0 0 20',
labelWidth: 60,
itemId : 'projectName_filter',
fieldLabel : '项目名称'
}, {
xtype : 'textfield',
margin : '5 0 0 20',
labelWidth: 60,
itemId : 'systemName_filter',
fieldLabel : '系统名称'
}]
}, {
xtype : 'fieldcontainer',
......@@ -109,8 +80,8 @@ Ext.define('drp.app.view.projects.invoices.StockInInvoiceView', {
xtype : 'textfield',
margin : '5 0 0 10',
labelWidth: 60,
itemId : 'materialKeeperName_filter',
fieldLabel : '材料员'
itemId : 'regulatorName_filter',
fieldLabel : '经手人'
}, {
xtype : 'textfield',
margin : '5 0 0 20',
......@@ -121,8 +92,8 @@ Ext.define('drp.app.view.projects.invoices.StockInInvoiceView', {
xtype : 'textfield',
margin : '5 0 0 20',
labelWidth: 60,
itemId : 'projetManagerName_filter',
fieldLabel : '项目经理'
itemId : 'managerName_filter',
fieldLabel : '负责人'
}, {
xtype : 'button',
margin : '5 0 0 25',
......@@ -161,14 +132,9 @@ Ext.define('drp.app.view.projects.invoices.StockInInvoiceView', {
dataIndex : 'code'
}, {
xtype : 'gridcolumn',
dataIndex : 'system.projectName',
flex : 2,
text : '项目名称'
}, {
xtype : 'gridcolumn',
dataIndex : 'system.name',
dataIndex : 'receiveMan',
flex : 2,
text : '系统名称'
text : '收到'
}, {
xtype : 'gridcolumn',
dataIndex : 'totalPrice',
......@@ -176,31 +142,19 @@ Ext.define('drp.app.view.projects.invoices.StockInInvoiceView', {
text : '合价'
}, {
xtype : 'gridcolumn',
dataIndex : 'materialKeeperName',
dataIndex : 'manager',
flex : 2,
text : '材料员',
renderer : function(value, metadata, record) {
var materialKeeperAuditState = record.data.materialKeeperAuditState;
return me.displyAuditState(value, materialKeeperAuditState);
}
text : '负责人'
}, {
xtype : 'gridcolumn',
dataIndex : 'wareKeeperName',
dataIndex : 'wareKeeper',
flex : 2,
text : '库管员',
renderer : function(value, metadata, record) {
var wareKeeperAuditState = record.data.wareKeeperAuditState;
return me.displyAuditState(value, wareKeeperAuditState);
}
text : '库管员'
}, {
xtype : 'gridcolumn',
dataIndex : 'projectManagerName',
dataIndex : 'regulatorName',
flex : 2,
text : '项目经理',
renderer : function(value, metadata, record) {
var projectManagerAuditState = record.data.projectManagerAuditState;
return me.displyAuditState(value, projectManagerAuditState);
}
text : '经手人'
}],
dockedItems : [{
xtype : 'pagingtoolbar',
......@@ -224,15 +178,7 @@ Ext.define('drp.app.view.projects.invoices.StockInInvoiceView', {
itemId : 'deleteInInvoice_btn',
disabled : true,
text : '删除'
}/*, {
itemId : 'submitInInvoice_btn',
disabled : true,
text : '提交审核',
icon : 'resources/images/icons/database_save.png',
menu : {
items : menuItems
}
}*/]
}]
}]
}]
......
......@@ -13,7 +13,7 @@ Ext.define('drp.app.view.projects.invoices.StockOutInvoiceView', {
initComponent : function() {
var me = this;
var selModel = Ext.create('Ext.selection.CheckboxModel', {
listeners : {
selectionchange : function(sm, selections) {
......@@ -22,23 +22,7 @@ Ext.define('drp.app.view.projects.invoices.StockOutInvoiceView', {
}
}
});
var menuItems = [{
xtype : 'button',
action : 'approveOutInvoice',
icon : 'resources/images/icons/approved.gif',
text : '提交通过'
}];
if(user.type != "MaterialKeeper"){
menuItems[1]={
xtype : 'button',
action : 'unapproveOutInvoice',
icon : 'resources/images/icons/unapproved.gif',
text : '失败退回'
};
}
Ext.applyIf(me, {
items : [{
......@@ -67,18 +51,6 @@ Ext.define('drp.app.view.projects.invoices.StockOutInvoiceView', {
fieldLabel : '结束日期',
editable : false,
format : 'Y-m-d'
}, {
xtype : 'textfield',
margin : '5 0 0 20',
labelWidth: 60,
itemId : 'projectName_filter',
fieldLabel : '项目名称'
}, {
xtype : 'textfield',
margin : '5 0 0 20',
labelWidth: 60,
itemId : 'systemName_filter',
fieldLabel : '系统名称'
}]
}, {
xtype : 'fieldcontainer',
......@@ -115,7 +87,7 @@ Ext.define('drp.app.view.projects.invoices.StockOutInvoiceView', {
xtype : 'textfield',
margin : '5 0 0 10',
labelWidth: 60,
itemId : 'materialKeeperName_filter',
itemId : 'regulatorName_filter',
fieldLabel : '材料员'
}, {
xtype : 'textfield',
......@@ -127,7 +99,7 @@ Ext.define('drp.app.view.projects.invoices.StockOutInvoiceView', {
xtype : 'textfield',
margin : '5 0 0 20',
labelWidth: 60,
itemId : 'projetManagerName_filter',
itemId : 'managerName_filter',
fieldLabel : '项目经理'
}, {
xtype : 'button',
......
Markdown is supported
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