Commit e5d4116b authored by Junshan Wang's avatar Junshan Wang

Merge branch 'custom-for-wangli' of http://182.92.242.253/originstar/drp.git into custom-for-wangli

parents 3e0a2a5c 8689a575
...@@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import com.originspark.drp.models.User; import com.originspark.drp.models.User;
import com.originspark.drp.service.projects.inventories.InventoryService;
import com.originspark.drp.service.projects.invoices.StockInInvoiceService; import com.originspark.drp.service.projects.invoices.StockInInvoiceService;
import com.originspark.drp.service.projects.invoices.StockOutInvoiceService; import com.originspark.drp.service.projects.invoices.StockOutInvoiceService;
import com.originspark.drp.service.resources.VendorService; import com.originspark.drp.service.resources.VendorService;
...@@ -40,6 +41,9 @@ public class BaseController extends HandlerInterceptorAdapter { ...@@ -40,6 +41,9 @@ public class BaseController extends HandlerInterceptorAdapter {
@Autowired @Autowired
protected StockOutInvoiceService stockOutInvoiceService; protected StockOutInvoiceService stockOutInvoiceService;
@Autowired
protected InventoryService inventoryService;
private static final ThreadLocal<HttpServletRequest> REQUEST = new ThreadLocal<HttpServletRequest>(); private static final ThreadLocal<HttpServletRequest> REQUEST = new ThreadLocal<HttpServletRequest>();
private static final ThreadLocal<HttpServletResponse> RESPONSE = new ThreadLocal<HttpServletResponse>(); private static final ThreadLocal<HttpServletResponse> RESPONSE = new ThreadLocal<HttpServletResponse>();
......
...@@ -15,7 +15,9 @@ import org.springframework.web.bind.annotation.ResponseBody; ...@@ -15,7 +15,9 @@ import org.springframework.web.bind.annotation.ResponseBody;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.originspark.drp.models.User; import com.originspark.drp.models.User;
import com.originspark.drp.util.SessionUtil;
import com.originspark.drp.util.enums.Status; import com.originspark.drp.util.enums.Status;
import com.originspark.drp.util.enums.UserType;
import com.originspark.drp.util.json.FilterRequest; import com.originspark.drp.util.json.FilterRequest;
import com.originspark.drp.util.json.IdsJson; import com.originspark.drp.util.json.IdsJson;
import com.originspark.drp.util.json.JsonUtils; import com.originspark.drp.util.json.JsonUtils;
...@@ -24,26 +26,48 @@ import com.originspark.drp.util.json.JsonUtils; ...@@ -24,26 +26,48 @@ import com.originspark.drp.util.json.JsonUtils;
@RequestMapping("users") @RequestMapping("users")
public class UserController extends BaseController { public class UserController extends BaseController {
@RequestMapping(method = RequestMethod.POST) @RequestMapping(value="/{type}", method = RequestMethod.POST)
@ResponseBody @ResponseBody
public String create(@RequestBody User user) { public String create(@PathVariable String type, @RequestBody User user) {
if(type == null || "".equals(type)) {
return ok("参数错误");
}
User currentUser = getCurrentUser();
if(currentUser == null || !UserType.MANAGER.equals(currentUser.getType())) {
return ok("权限不足");
}
user.setType(UserType.valueOf(type.toUpperCase()));
user.setPassword("123456"); user.setPassword("123456");
userService.save(user); userService.save(user);
return ok("创建成功"); return ok("创建成功");
} }
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @RequestMapping(value = "/{type}/{id}", method = RequestMethod.DELETE)
@ResponseBody @ResponseBody
public String delete(@PathVariable Long id) { public String delete(@PathVariable String type, @PathVariable Long id) {
if(type == null || "".equals(type) || id == null || id < 1) {
return ok("参数错误");
}
User currentUser = getCurrentUser();
if(currentUser == null || !UserType.MANAGER.equals(currentUser.getType())) {
return ok("权限不足");
}
User leader = userService.findById(User.class, id); User leader = userService.findById(User.class, id);
leader.setStatus(Status.DESTORYED); leader.setStatus(Status.DESTORYED);
userService.update(leader); userService.update(leader);
return ok("注销成功"); return ok("注销成功");
} }
@RequestMapping(value= "/deleteBatch",method = RequestMethod.GET) @RequestMapping(value= "/{type}/deleteBatch",method = RequestMethod.GET)
@ResponseBody @ResponseBody
public String deleteBatch(HttpServletRequest request){ public String deleteBatch(@PathVariable String type, HttpServletRequest request){
if(type == null || "".equals(type)) {
return ok("参数错误");
}
User currentUser = getCurrentUser();
if(currentUser == null || !UserType.MANAGER.equals(currentUser.getType())) {
return ok("权限不足");
}
String data = request.getParameter("data"); String data = request.getParameter("data");
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
IdsJson json=null; IdsJson json=null;
...@@ -63,10 +87,16 @@ public class UserController extends BaseController { ...@@ -63,10 +87,16 @@ public class UserController extends BaseController {
return ok("注销成功"); return ok("注销成功");
} }
@RequestMapping(value = "/{id}", method = RequestMethod.PUT) @RequestMapping(value = "/{type}/{id}", method = RequestMethod.PUT)
@ResponseBody @ResponseBody
public String update(@PathVariable Long id, @RequestBody User user) { public String update(@PathVariable String type, @PathVariable Long id, @RequestBody User user) {
if(type == null || "".equals(type) || id == null || id < 1) {
return ok("参数错误");
}
User currentUser = getCurrentUser();
if(currentUser == null || !UserType.MANAGER.equals(currentUser.getType())) {
return ok("权限不足");
}
User existingLeader = userService.findById(User.class, id); User existingLeader = userService.findById(User.class, id);
if (existingLeader == null) { if (existingLeader == null) {
return failure("您要更新的领导不存在"); return failure("您要更新的领导不存在");
...@@ -84,13 +114,12 @@ public class UserController extends BaseController { ...@@ -84,13 +114,12 @@ public class UserController extends BaseController {
return ok("更新成功"); return ok("更新成功");
} }
@RequestMapping(method = RequestMethod.GET) @RequestMapping(value="/{type}", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public String list(@RequestParam int start, @RequestParam int limit,@RequestParam(required = false) Object filter) { public String list(@PathVariable String type, @RequestParam int start, @RequestParam int limit,@RequestParam(required = false) Object filter) {
List<FilterRequest> filters = new ArrayList<FilterRequest>(); List<FilterRequest> filters = new ArrayList<FilterRequest>();
filters.add(new FilterRequest("type", "Leader")); filters.add(new FilterRequest("type", type.toUpperCase()));
if (filter != null) { if (filter != null) {
filters.addAll(JsonUtils.getListFromJsonArray(filter)); filters.addAll(JsonUtils.getListFromJsonArray(filter));
......
package com.originspark.drp.controllers.projects.inventories; package com.originspark.drp.controllers.projects.inventories;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.originspark.drp.controllers.BaseController; import com.originspark.drp.controllers.BaseController;
import com.originspark.drp.util.FileUtil; import com.originspark.drp.models.User;
import com.originspark.drp.util.poi.exporter.MonthendInventoryGenerator;
import com.originspark.drp.web.models.projects.inventories.CurrentInventoryUI; import com.originspark.drp.web.models.projects.inventories.CurrentInventoryUI;
import com.originspark.drp.web.models.projects.inventories.Ware;
@Controller @Controller
@RequestMapping("project") @RequestMapping("inventories")
public class InventoryController extends BaseController { public class InventoryController extends BaseController {
/*@RequestMapping(value = "/{id}/inventories/current", method = RequestMethod.GET) @RequestMapping(value = "/current", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@AuthRoleGroup(type={RoleEnum.WAREKEEPER,RoleEnum.PROJECTMANAGER,RoleEnum.LEADER}) public String currentInventories(@RequestParam int start, @RequestParam int limit) {
public String currentInventories(@PathVariable Long id){ List<CurrentInventoryUI> data = inventoryService.pagedCurrentInventories(start, limit);
Long count = inventoryService.pagedCurrentInventoriesCount();
Project project = projectService.findById(id); return ok(data, count);
if(project == null){
return failure("你所查询的项目不存在");
}
List<CurrentInventoryUI> inventories = new ArrayList<CurrentInventoryUI>();
//如果是项目
if(project.getProject() == null){
for(Project system : project.getSystems()){
inventories.addAll(projectService.getCurrentInventories(system.getId()));
}
return ok(inventories);
}
inventories.addAll(projectService.getCurrentInventories(id));
return ok(inventories);
} }
/*
@ResponseBody @ResponseBody
@RequestMapping(value = "/{id}/inventories/monthend", method = RequestMethod.GET) @RequestMapping(value = "/{id}/inventories/monthend", method = RequestMethod.GET)
@AuthRoleGroup(type={RoleEnum.PROJECTMANAGER,RoleEnum.LEADER}) @AuthRoleGroup(type={RoleEnum.PROJECTMANAGER,RoleEnum.LEADER})
......
...@@ -34,12 +34,11 @@ public class VendorController extends BaseController { ...@@ -34,12 +34,11 @@ public class VendorController extends BaseController {
public String create(@RequestBody Vendor vendor) { public String create(@RequestBody Vendor vendor) {
String contactMan = vendor.getContactMan(); String contactMan = vendor.getContactMan();
if (contactMan == null || contactMan.trim().equals("")) { if (StringUtils.isEmpty(contactMan)) {
return failure("联系人不能为空"); return failure("联系人不能为空");
} }
String name = vendor.getName(); if (vendorService.have(vendor)) {
if (!StringUtils.isEmpty(name) && vendorService.findByName(name) != null) {
return failure("该供应商已经存在,不可重复添加"); return failure("该供应商已经存在,不可重复添加");
} }
...@@ -84,14 +83,12 @@ public class VendorController extends BaseController { ...@@ -84,14 +83,12 @@ public class VendorController extends BaseController {
return failure("您要更新的供应商不存在"); return failure("您要更新的供应商不存在");
} }
String name = vendor.getName(); String contactMan = vendor.getContactMan();
if (name == null || name.trim().equals("")) { if (StringUtils.isEmpty(contactMan)) {
logger.warn(">更新失败:商品名称不能为空"); return failure("联系人不能为空");
return failure("供应商名称不能为空");
} }
if (vendorService.findByName(name) != null) { if (vendorService.have(vendor)) {
logger.warn(">更新失败:该供应商已经存在,不可重复添加");
return failure("该供应商已经存在,不可重复添加"); return failure("该供应商已经存在,不可重复添加");
} }
...@@ -100,11 +97,9 @@ public class VendorController extends BaseController { ...@@ -100,11 +97,9 @@ public class VendorController extends BaseController {
existingVendor.setAddress(vendor.getAddress()); existingVendor.setAddress(vendor.getAddress());
existingVendor.setPhone(vendor.getPhone()); existingVendor.setPhone(vendor.getPhone());
existingVendor.setNote(vendor.getNote()); existingVendor.setNote(vendor.getNote());
existingVendor.setUpdatedBy(getCurrentUser().getName());
existingVendor.setUpdatedBy(SessionUtil.getCurrentUserName(request));
vendorService.update(existingVendor); vendorService.update(existingVendor);
logger.info(">更新成功:"+existingVendor.toString());
return ok("更新成功"); return ok("更新成功");
} }
......
...@@ -98,10 +98,10 @@ public class WareController extends BaseController { ...@@ -98,10 +98,10 @@ public class WareController extends BaseController {
@RequestMapping(value = "/{id}", method = RequestMethod.PUT) @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
@ResponseBody @ResponseBody
public String update(@PathVariable Long id, @RequestBody Ware ware,HttpServletRequest request) { public String update(@PathVariable Long id, @RequestBody Ware ware) {
Ware existingWare = wareService.findById(Ware.class, id); Ware existingWare = wareService.findById(Ware.class, id);
//validation //validation
if (existingWare == null) { if (existingWare == null) {
return failure("您要更新的商品不存在"); return failure("您要更新的商品不存在");
...@@ -130,8 +130,8 @@ public class WareController extends BaseController { ...@@ -130,8 +130,8 @@ public class WareController extends BaseController {
existingWare.setUnit(ware.getUnit()); existingWare.setUnit(ware.getUnit());
existingWare.setNote(ware.getNote()); existingWare.setNote(ware.getNote());
existingWare.setVendor(ware.getVendor()); existingWare.setVendor(ware.getVendor());
existingWare.setCategory(ware.getCategory());
existingWare.setUpdatedBy(SessionUtil.getCurrentUserName(request)); existingWare.setUpdatedBy(SessionUtil.getCurrentUserName(request()));
wareService.update(existingWare); wareService.update(existingWare);
logger.info(">更新成功:"+existingWare.toString()); logger.info(">更新成功:"+existingWare.toString());
...@@ -141,7 +141,6 @@ public class WareController extends BaseController { ...@@ -141,7 +141,6 @@ public class WareController extends BaseController {
@RequestMapping(method = RequestMethod.GET) @RequestMapping(method = RequestMethod.GET)
@ResponseBody @ResponseBody
public String list(@RequestParam int start, @RequestParam int limit, @RequestParam(required = false) Object filter, HttpServletRequest request) { public String list(@RequestParam int start, @RequestParam int limit, @RequestParam(required = false) Object filter, HttpServletRequest request) {
List<FilterRequest> filters = new ArrayList<FilterRequest>(); List<FilterRequest> filters = new ArrayList<FilterRequest>();
if (filter != null) { if (filter != null) {
......
package com.originspark.drp.models.projects.costs; package com.originspark.drp.models.projects.costs;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.MappedSuperclass; import javax.persistence.MappedSuperclass;
import javax.persistence.PrePersist; import javax.persistence.PrePersist;
import javax.persistence.PreUpdate; import javax.persistence.PreUpdate;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.originspark.drp.models.AbstractModel; import com.originspark.drp.models.AbstractModel;
@MappedSuperclass @MappedSuperclass
public abstract class AbstractCost extends AbstractModel{ public abstract class AbstractCost extends AbstractModel {
private static SimpleDateFormat forYearMonthFormatter = new SimpleDateFormat("yyyy-MM");
/**
* 该字段和对应invoice的时间字段保持一致,为冗余字段,
* 只为简化盘点计算,forYearMonth同理
* 日期:年-月-日
*/
@Temporal(TemporalType.DATE)
private Date forDate;
/**
* 日期:年-月
*/
@JsonIgnore
@Column(columnDefinition = "char(7)", nullable = false)
private String forYearMonth;
/** /**
* 单价 * 单价
...@@ -60,12 +81,31 @@ public abstract class AbstractCost extends AbstractModel{ ...@@ -60,12 +81,31 @@ public abstract class AbstractCost extends AbstractModel{
public void setTotal(BigDecimal total) { public void setTotal(BigDecimal total) {
this.total = total; this.total = total;
} }
public Date getForDate() {
return forDate;
}
public void setForDate(Date forDate) {
this.forDate = forDate;
if (forDate != null) {
setForYearMonth(forYearMonthFormatter.format(forDate));
}
}
public String getForYearMonth() {
return forYearMonth;
}
public void setForYearMonth(String forYearMonth) {
this.forYearMonth = forYearMonth;
}
@Override @Override
public String toString() { public String toString() {
return super.toString()+", unitPrice="+unitPrice+", quantity="+quantity; return super.toString()+", unitPrice="+unitPrice+", quantity="+quantity;
} }
@PrePersist @PrePersist
public void prePersist(){ public void prePersist(){
if(getUnitPrice() == null || getQuantity() == null){ if(getUnitPrice() == null || getQuantity() == null){
...@@ -73,7 +113,7 @@ public abstract class AbstractCost extends AbstractModel{ ...@@ -73,7 +113,7 @@ public abstract class AbstractCost extends AbstractModel{
} }
setTotal(getUnitPrice().multiply(getQuantity())); setTotal(getUnitPrice().multiply(getQuantity()));
} }
@PreUpdate @PreUpdate
public void PreUpdate(){ public void PreUpdate(){
if(getUnitPrice() == null || getQuantity() == null){ if(getUnitPrice() == null || getQuantity() == null){
......
...@@ -11,7 +11,6 @@ import javax.persistence.TemporalType; ...@@ -11,7 +11,6 @@ import javax.persistence.TemporalType;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.originspark.drp.models.AbstractModel; import com.originspark.drp.models.AbstractModel;
import com.sun.istack.internal.NotNull;
/** /**
* 单据 * 单据
...@@ -33,7 +32,6 @@ public abstract class AbstractInvoice extends AbstractModel{ ...@@ -33,7 +32,6 @@ public abstract class AbstractInvoice extends AbstractModel{
private Date forDate; private Date forDate;
@JsonIgnore @JsonIgnore
@NotNull
@Column(columnDefinition = "char(7)", nullable = false) @Column(columnDefinition = "char(7)", nullable = false)
private String forYearMonth; private String forYearMonth;
......
package com.originspark.drp.service.projects.inventories;
import java.util.List;
import com.originspark.drp.dao.BaseDAO;
import com.originspark.drp.web.models.projects.inventories.CurrentInventoryUI;
public interface InventoryService extends BaseDAO {
List<CurrentInventoryUI> pagedCurrentInventories(int start, int limit);
Long pagedCurrentInventoriesCount();
}
package com.originspark.drp.service.projects.inventories;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Query;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.originspark.drp.dao.BaseDAOSupport;
import com.originspark.drp.web.models.projects.inventories.CurrentInventoryUI;
@Transactional
@Service
public class InventoryServiceBean extends BaseDAOSupport implements InventoryService {
// 实时入库量统计
final String CURRENT_IN_SQL = "(SELECT DISTINCT(ware) as wid, sum(quantity) as incount, SUM(total) as outcome FROM cost_stock_in GROUP BY ware) as t1";
// 实时出库量统计
final String CURRENT_OUT_SQL = "(SELECT DISTINCT(ware) as wid, sum(quantity) as outcount, SUM(total) as income FROM cost_stock_out GROUP BY ware) as t2";
// 实时库存量统计
final String CURRENT_SUM_SQL = "SELECT t3.name, t3.model, t3.unit, t3.brand, t1.outcome, t1.incount, t2.income, t2.outcount FROM "
+ CURRENT_IN_SQL + " LEFT JOIN " + CURRENT_OUT_SQL + " ON t1.wid = t2.wid"
+ " JOIN wares as t3 WHERE t1.wid = t3.id";
// 实时库存量总数计算
final String CURRENT_COUNT = "SELECT COUNT(DISTINCT(ware)) FROM cost_stock_in";
@SuppressWarnings("unchecked")
@Override
public List<CurrentInventoryUI> pagedCurrentInventories(int start, int limit) {
Query query = em.createNativeQuery(CURRENT_SUM_SQL);
List<Object[]> res = query.setFirstResult(start).setMaxResults(limit).getResultList();
List<CurrentInventoryUI> currentInventories = new ArrayList<CurrentInventoryUI>();
Object[] objAry;
for (int i = 0, length = res.size(); i < length; i++) {
CurrentInventoryUI inventory = new CurrentInventoryUI();
objAry = res.get(i);
inventory.setName(objAry[0] + "");
inventory.setModel(objAry[1] + "");
inventory.setUnit(objAry[2] + "");
inventory.setBrand(objAry[3] + "");
inventory.setOutcome(objAry[4] == null ? BigDecimal.ZERO : (BigDecimal) objAry[4]);
inventory.setIncount(objAry[5] == null ? 0L : ((BigDecimal)objAry[5]).longValue());
inventory.setIncome(objAry[6] == null ? BigDecimal.ZERO : (BigDecimal) objAry[6]);
inventory.setOutcount(objAry[7] == null ? 0L : ((BigDecimal)objAry[7]).longValue());
currentInventories.add(inventory);
}
return currentInventories;
}
@Override
public Long pagedCurrentInventoriesCount() {
Query query = em.createNativeQuery(CURRENT_COUNT);
BigInteger count = (BigInteger)query.getSingleResult();
return count.longValue();
}
}
...@@ -3,20 +3,19 @@ package com.originspark.drp.service.resources; ...@@ -3,20 +3,19 @@ package com.originspark.drp.service.resources;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.springframework.stereotype.Service;
import com.originspark.drp.dao.BaseDAO; import com.originspark.drp.dao.BaseDAO;
import com.originspark.drp.models.resources.Vendor; import com.originspark.drp.models.resources.Vendor;
import com.originspark.drp.util.json.FilterRequest; import com.originspark.drp.util.json.FilterRequest;
public interface VendorService extends BaseDAO<Vendor>{ public interface VendorService extends BaseDAO<Vendor>{
List<Vendor> pagedDataSet(int start, int limit, List<FilterRequest> filters); List<Vendor> pagedDataSet(int start, int limit, List<FilterRequest> filters);
Long pagedDataCount(List<FilterRequest> filters); Long pagedDataCount(List<FilterRequest> filters);
Map<String,String> validate(); Map<String,String> validate();
Vendor findByName(String name); Vendor findByName(String name);
boolean have(Vendor vendor);
} }
...@@ -14,6 +14,7 @@ import org.springframework.stereotype.Service; ...@@ -14,6 +14,7 @@ import org.springframework.stereotype.Service;
import com.originspark.drp.dao.BaseDAOSupport; import com.originspark.drp.dao.BaseDAOSupport;
import com.originspark.drp.models.resources.Vendor; import com.originspark.drp.models.resources.Vendor;
import com.originspark.drp.models.resources.Ware;
import com.originspark.drp.models.resources.Vendor.COLUMNS; import com.originspark.drp.models.resources.Vendor.COLUMNS;
import com.originspark.drp.util.json.FilterRequest; import com.originspark.drp.util.json.FilterRequest;
...@@ -123,4 +124,18 @@ public class VendorServiceBean extends BaseDAOSupport<Vendor> implements VendorS ...@@ -123,4 +124,18 @@ public class VendorServiceBean extends BaseDAOSupport<Vendor> implements VendorS
return vendors.get(0); return vendors.get(0);
} }
@Override
public boolean have(Vendor vendor) {
String jpql = "from Vendor where name =:name and contactMan =:contactMan";
TypedQuery<Vendor> query = em.createQuery(jpql, Vendor.class)
.setParameter("name", vendor.getName())
.setParameter("contactMan", vendor.getContactMan());
List<Vendor> vendors = query.getResultList();
if(vendors.isEmpty()){
return false;
}
return true;
}
} }
...@@ -138,13 +138,14 @@ public class WareServiceBean extends BaseDAOSupport<Ware> implements WareService ...@@ -138,13 +138,14 @@ public class WareServiceBean extends BaseDAOSupport<Ware> implements WareService
@Override @Override
public boolean have(Ware ware) { public boolean have(Ware ware) {
String jpql = "from Ware where name =:name and model =:model and unit =:unit and brand =:brand"; String jpql = "from Ware where name =:name and model =:model and unit =:unit and brand =:brand and category =:category";
TypedQuery<Ware> query = em.createQuery(jpql,Ware.class) TypedQuery<Ware> query = em.createQuery(jpql, Ware.class)
.setParameter("name", ware.getName()) .setParameter("name", ware.getName())
.setParameter("model", ware.getModel()) .setParameter("model", ware.getModel())
.setParameter("unit", ware.getUnit()) .setParameter("unit", ware.getUnit())
.setParameter("brand", ware.getBrand()); .setParameter("brand", ware.getBrand())
.setParameter("category", ware.getCategory());
List<Ware> wares = query.getResultList(); List<Ware> wares = query.getResultList();
if(wares.isEmpty()){ if(wares.isEmpty()){
return false; return false;
......
...@@ -17,6 +17,7 @@ import com.originspark.drp.models.User; ...@@ -17,6 +17,7 @@ import com.originspark.drp.models.User;
import com.originspark.drp.models.User.COLUMNS; import com.originspark.drp.models.User.COLUMNS;
import com.originspark.drp.util.enums.Gender; import com.originspark.drp.util.enums.Gender;
import com.originspark.drp.util.enums.Status; import com.originspark.drp.util.enums.Status;
import com.originspark.drp.util.enums.UserType;
import com.originspark.drp.util.json.FilterRequest; import com.originspark.drp.util.json.FilterRequest;
@Transactional @Transactional
...@@ -80,7 +81,7 @@ public class UserServiceBean extends BaseDAOSupport<User> implements UserService ...@@ -80,7 +81,7 @@ public class UserServiceBean extends BaseDAOSupport<User> implements UserService
switch (column) { switch (column) {
case TYPE : case TYPE :
if (value != null && !value.equals("")) { if (value != null && !value.equals("")) {
criteria.add(cb.equal(user.get("type"), value)); criteria.add(cb.equal(user.get("type"), UserType.valueOf(value)));
} }
break; break;
case NAME: case NAME:
......
...@@ -2,56 +2,78 @@ package com.originspark.drp.web.models.projects.inventories; ...@@ -2,56 +2,78 @@ package com.originspark.drp.web.models.projects.inventories;
import java.math.BigDecimal; import java.math.BigDecimal;
/**
* 剩余量、盈利额会自动计算
* @author ReedMi
*/
public class CurrentInventoryUI { public class CurrentInventoryUI {
private String wareName; private String name;
private String wareBrand; private String brand;
private String wareModel; private String model;
private String wareUnit; private String unit;
private BigDecimal currentStockIn; private Long incount;// 入库量
private BigDecimal currentStockOut; private Long outcount;// 出库量
private BigDecimal income;// 收入
public String getWareName() { private BigDecimal outcome;// 支出
return wareName;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
} }
public void setWareName(String wareName) { public String getBrand() {
this.wareName = wareName; return brand;
} }
public String getWareBrand() { public void setBrand(String brand) {
return wareBrand; this.brand = brand;
} }
public void setWareBrand(String wareBrand) { public String getModel() {
this.wareBrand = wareBrand; return model;
} }
public String getWareModel() { public void setModel(String model) {
return wareModel; this.model = model;
} }
public void setWareModel(String wareModel) { public String getUnit() {
this.wareModel = wareModel; return unit;
} }
public String getWareUnit() { public void setUnit(String unit) {
return wareUnit; this.unit = unit;
} }
public void setWareUnit(String wareUnit) { public Long getIncount() {
this.wareUnit = wareUnit; return incount;
} }
public BigDecimal getCurrentStockIn() { public void setIncount(Long incount) {
return currentStockIn; this.incount = incount;
} }
public void setCurrentStockIn(BigDecimal currentStockIn) { public Long getOutcount() {
this.currentStockIn = currentStockIn; return outcount;
} }
public BigDecimal getCurrentStockOut() { public void setOutcount(Long outcount) {
return currentStockOut; this.outcount = outcount;
} }
public void setCurrentStockOut(BigDecimal currentStockOut) { public BigDecimal getIncome() {
this.currentStockOut = currentStockOut; return income;
}
public void setIncome(BigDecimal income) {
this.income = income;
}
public BigDecimal getOutcome() {
return outcome;
}
public void setOutcome(BigDecimal outcome) {
this.outcome = outcome;
}
// 剩余量
public Long getRestcount() {
return getIncount() - getOutcount();
} }
//json util // 盈利
public BigDecimal getCurrentStockRest(){ public BigDecimal getProfit() {
return getCurrentStockIn().subtract(getCurrentStockOut()); return getIncome().subtract(getOutcome());
} }
} }
Ext.define('drp.app.controller.projects.inventories.CurrentInventoryController', { Ext.define('drp.app.controller.projects.inventories.CurrentInventoryController', {
extend : 'Ext.app.Controller', extend : 'Ext.app.Controller',
currentInventoryGrid : null,
init : function() { init : function() {
me = this;
this.control({ this.control({
'currentinventoryview' : { 'currentinventoryview' : {
afterrender : function(panel) { afterrender : function(panel) {
currentInventoryGrid = panel.down('gridpanel'); var grid = panel.down('gridpanel');
} grid.getStore().load();
},
'currentinventoryview > treepanel' : {
select : function(treepanel, record){
var id = record.data.id;
var _url = "project/"+id+"/inventories/current";
currentInventoryGrid.getStore().getProxy().url = _url;
currentInventoryGrid.getStore().reload();
},
afterrender : function(treepanel){
var store = treepanel.getStore();
Ext.apply(store.proxy.extraParams, {
userType : user.type,
userId : user.id
});
store.load({
node : store.getRootNode()
});
} }
} }
}); });
}, },
views : ['drp.app.view.projects.inventories.CurrentInventoryView'], views : ['drp.app.view.projects.inventories.CurrentInventoryView'],
models :['drp.app.model.projects.ProjectModel','drp.app.model.projects.inventories.CurrentInventoryModel'], models :['drp.app.model.projects.inventories.CurrentInventoryModel'],
stores : ['drp.app.store.projects.inventories.CurrentInventoryStore'] stores : ['drp.app.store.projects.inventories.CurrentInventoryStore']
}); });
\ No newline at end of file
...@@ -5,7 +5,6 @@ Ext.define("drp.app.controller.resources.WareController", { ...@@ -5,7 +5,6 @@ Ext.define("drp.app.controller.resources.WareController", {
me : null, me : null,
init : function() { init : function() {
me = this; me = this;
this.control({ this.control({
......
...@@ -91,7 +91,7 @@ Ext.define("drp.app.controller.users.ManagerController", { ...@@ -91,7 +91,7 @@ Ext.define("drp.app.controller.users.ManagerController", {
deleteManager : function(btn) { deleteManager : function(btn) {
//me.deleteModel(btn, managerGrid, "负责人"); //me.deleteModel(btn, managerGrid, "负责人");
me.deleteBatchModel(btn,managerGrid,"负责人","/projectManager/deleteBatch"); me.deleteBatchModel(btn,managerGrid,"负责人","users/manager/deleteBatch");
}, },
submitManagerForm : function(btn) { submitManagerForm : function(btn) {
......
...@@ -90,7 +90,7 @@ Ext.define("drp.app.controller.users.RegulatorController", { ...@@ -90,7 +90,7 @@ Ext.define("drp.app.controller.users.RegulatorController", {
}, },
deleteRegulator : function(btn) { deleteRegulator : function(btn) {
me.deleteBatchModel(btn,regulatorGrid,"经手人","/materialKeeper/deleteBatch"); me.deleteBatchModel(btn,regulatorGrid,"经手人","users/regulator/deleteBatch");
}, },
submitRegulatorForm : function(btn) { submitRegulatorForm : function(btn) {
......
...@@ -91,7 +91,7 @@ Ext.define("drp.app.controller.users.WareKeeperController", { ...@@ -91,7 +91,7 @@ Ext.define("drp.app.controller.users.WareKeeperController", {
deleteWareKeeper : function(btn) { deleteWareKeeper : function(btn) {
//me.deleteModel(btn, wareKeeperGrid, "库管"); //me.deleteModel(btn, wareKeeperGrid, "库管");
me.deleteBatchModel(btn,wareKeeperGrid,"库管","/wareKeeper/deleteBatch"); me.deleteBatchModel(btn,wareKeeperGrid,"库管","users/wareKeeper/deleteBatch");
}, },
submitWareKeeperForm : function(btn) { submitWareKeeperForm : function(btn) {
......
Ext.define("drp.app.model.projects.inventories.CurrentInventoryModel", { Ext.define("drp.app.model.projects.inventories.CurrentInventoryModel", {
extend : "Ext.data.Model", extend : "Ext.data.Model",
fields : [{ fields : [{
name : "wareName" name : "name"
}, { }, {
name : "wareBrand" name : "brand"
}, { }, {
name : "wareModel" name : "model"
}, { }, {
name : "wareUnit" name : "unit"
}, { }, {
name : "currentStockIn", name : "incount",
type : 'int' type : 'int'
}, { }, {
name : "currentStockOut", name : "outcount",
type : 'int' type : 'int'
}, { }, {
name : "currentStockRest", name : "restcount",
type : 'int' type : 'int'
} ], }, {
name : "income"
}, {
name : "outcome"
}, {
name : "profit"
}],
proxy : { proxy : {
type : 'ajax', type : 'ajax',
url : 'inventories/current',
reader : { reader : {
type : "json", type : "json",
root : "data", root : "data",
......
...@@ -2,7 +2,7 @@ Ext.define("drp.app.model.users.ManagerModel", { ...@@ -2,7 +2,7 @@ Ext.define("drp.app.model.users.ManagerModel", {
extend : "drp.app.model.users.AbstractUserModel", extend : "drp.app.model.users.AbstractUserModel",
proxy : { proxy : {
type : 'rest', type : 'rest',
url : 'manager', url : 'users/manager',
reader : { reader : {
type : "json", type : "json",
root : "data", root : "data",
......
...@@ -2,7 +2,7 @@ Ext.define("drp.app.model.users.RegulatorModel", { ...@@ -2,7 +2,7 @@ Ext.define("drp.app.model.users.RegulatorModel", {
extend : "drp.app.model.users.AbstractUserModel", extend : "drp.app.model.users.AbstractUserModel",
proxy : { proxy : {
type : 'rest', type : 'rest',
url : 'regulator', url : 'users/regulator',
reader : { reader : {
type : "json", type : "json",
root : "data", root : "data",
......
...@@ -2,7 +2,7 @@ Ext.define("drp.app.model.users.WareKeeperModel", { ...@@ -2,7 +2,7 @@ Ext.define("drp.app.model.users.WareKeeperModel", {
extend : "drp.app.model.users.AbstractUserModel", extend : "drp.app.model.users.AbstractUserModel",
proxy : { proxy : {
type : 'rest', type : 'rest',
url : 'wareKeeper', url : 'users/wareKeeper',
reader : { reader : {
type : "json", type : "json",
root : "data", root : "data",
......
Ext.define("drp.app.store.projects.inventories.CurrentInventoryStore", { Ext.define("drp.app.store.projects.inventories.CurrentInventoryStore", {
extend : 'Ext.data.Store', extend : 'Ext.data.Store',
model : 'drp.app.model.projects.inventories.CurrentInventoryModel', model : 'drp.app.model.projects.inventories.CurrentInventoryModel',
pageSize : 50 pageSize : 50,
autoLoad : false
}); });
\ No newline at end of file
...@@ -12,67 +12,56 @@ Ext.define('drp.app.view.projects.inventories.CurrentInventoryView', { ...@@ -12,67 +12,56 @@ Ext.define('drp.app.view.projects.inventories.CurrentInventoryView', {
Ext.applyIf(me, { Ext.applyIf(me, {
items : [{ items : [{
xtype : 'treepanel',
region : 'west',
width : 200,
rootVisible : false,
title : '项目列表',
store : Ext.create("Ext.data.TreeStore",{
defaultRootId : '',
//防止store自动加载
//http://www.sencha.com/forum/showthread.php?150004-How-to-stop-TreeStore-autoload
root : {
data : []
},
model : 'drp.app.model.projects.ProjectModel'
}),
columns : [{
xtype : 'treecolumn',
dataIndex : 'name',
text : '名称',
flex : 1
}]
}, {
xtype : 'gridpanel', xtype : 'gridpanel',
region : 'center', region : 'center',
title : '库存量', title : '实时库存量',
columnLines : true, columnLines : true,
store : 'drp.app.store.projects.inventories.CurrentInventoryStore', store : 'drp.app.store.projects.inventories.CurrentInventoryStore',
columns : [{ columns : [{
xtype : 'gridcolumn', xtype : 'gridcolumn',
dataIndex : 'wareName', dataIndex : 'name',
flex : 1, flex : 1,
text : '品名' text : '品名'
}, { }, {
xtype : 'gridcolumn', xtype : 'gridcolumn',
dataIndex : 'wareBrand', dataIndex : 'model',
flex : 1,
text : '品牌'
}, {
xtype : 'gridcolumn',
dataIndex : 'wareModel',
flex : 1, flex : 1,
text : '规格' text : '规格'
}, { }, {
xtype : 'gridcolumn', xtype : 'gridcolumn',
dataIndex : 'wareUnit', dataIndex : 'unit',
flex : 1, flex : 1,
text : '单位' text : '单位'
}, { }, {
xtype : 'gridcolumn', xtype : 'gridcolumn',
dataIndex : 'currentStockIn', dataIndex : 'incount',
flex : 1, flex : 1,
text : '当前入库量' text : '当前入库量'
}, { }, {
xtype : 'gridcolumn', xtype : 'gridcolumn',
dataIndex : 'currentStockOut', dataIndex : 'outcount',
flex : 1, flex : 1,
text : '当前出库量' text : '当前出库量'
}, { }, {
xtype : 'gridcolumn', xtype : 'gridcolumn',
dataIndex : 'currentStockRest', dataIndex : 'restcount',
flex : 1, flex : 1,
text : '当前剩余量' text : '当前剩余量'
}, {
xtype : 'gridcolumn',
dataIndex : 'income',
flex : 1,
text : '收入'
}, {
xtype : 'gridcolumn',
dataIndex : 'outcome',
flex : 1,
text : '支出'
}, {
xtype : 'gridcolumn',
dataIndex : 'profit',
flex : 1,
text : '盈余'
}], }],
dockedItems : [{ dockedItems : [{
xtype : 'pagingtoolbar', xtype : 'pagingtoolbar',
......
...@@ -82,25 +82,25 @@ Ext.define('drp.app.view.resources.VendorView', { ...@@ -82,25 +82,25 @@ Ext.define('drp.app.view.resources.VendorView', {
stripeRows : true, stripeRows : true,
autoScroll : true, autoScroll : true,
columns : [{ columns : [{
xtype : 'gridcolumn',
width : 160,
dataIndex : 'name',
text : '名称'
}, {
xtype : 'gridcolumn', xtype : 'gridcolumn',
width : 90, width : 90,
dataIndex : 'contactMan', dataIndex : 'contactMan',
text : '联系人' text : '联系人'
}, {
xtype : 'gridcolumn',
width : 180,
dataIndex : 'address',
text : '地址'
}, { }, {
xtype : 'gridcolumn', xtype : 'gridcolumn',
width : 130, width : 130,
dataIndex : 'phone', dataIndex : 'phone',
text : '联系电话' text : '联系电话'
}, {
xtype : 'gridcolumn',
width : 160,
dataIndex : 'name',
text : '公司名称'
}, {
xtype : 'gridcolumn',
width : 180,
dataIndex : 'address',
text : '公司地址'
}, { }, {
xtype : 'gridcolumn', xtype : 'gridcolumn',
width : 100, width : 100,
......
...@@ -100,7 +100,7 @@ Ext.define('drp.app.view.users.ManagerView', { ...@@ -100,7 +100,7 @@ Ext.define('drp.app.view.users.ManagerView', {
}, { }, {
xtype : 'button', xtype : 'button',
margin : '5 0 0 20', margin : '5 0 0 20',
action : 'searchProjectManager', action : 'searchManager',
icon : 'resources/images/icons/search.png', icon : 'resources/images/icons/search.png',
text : '查询' text : '查询'
}, { }, {
......
...@@ -15,7 +15,7 @@ Ext.define("drp.app.view.users.ManagerViewForm", { ...@@ -15,7 +15,7 @@ Ext.define("drp.app.view.users.ManagerViewForm", {
margin : '5 0 0 5', margin : '5 0 0 5',
name : 'name', name : 'name',
allowBlank : false, allowBlank : false,
fieldLabel : '名称<font color="red">*</font>' fieldLabel : '姓名<font color="red">*</font>'
}, { }, {
xtype : 'textfield', xtype : 'textfield',
anchor : '60%', anchor : '60%',
......
...@@ -3,7 +3,7 @@ Ext.define('drp.app.view.users.RegulatorView', { ...@@ -3,7 +3,7 @@ Ext.define('drp.app.view.users.RegulatorView', {
alias : 'widget.regulatorview', alias : 'widget.regulatorview',
margins : '0 0 0 0', margins : '0 0 0 0',
border : 0, border : 0,
title : '<center height=40>材料员</center>', title : '<center height=40>经手人</center>',
autoScroll : true, autoScroll : true,
closable : true, closable : true,
layout : { layout : {
......
Ext.define("drp.app.view.users.MaterialKeeperViewForm", { Ext.define("drp.app.view.users.MaterialKeeperViewForm", {
extend : 'Ext.panel.Panel', extend : 'Ext.panel.Panel',
alias : 'widget.materialkeeperviewform', alias : 'widget.regulatorviewform',
author : '100%', author : '100%',
autoScroll : true, autoScroll : true,
items : [{ items : [{
...@@ -85,13 +85,13 @@ Ext.define("drp.app.view.users.MaterialKeeperViewForm", { ...@@ -85,13 +85,13 @@ Ext.define("drp.app.view.users.MaterialKeeperViewForm", {
items : [{ items : [{
xtype : 'button', xtype : 'button',
margin : '5 0 0 5', margin : '5 0 0 5',
action : 'submitMaterialKeeperForm', action : 'submitRegulatorForm',
width: 80, width: 80,
text : '确认' text : '确认'
}, { }, {
xtype : 'button', xtype : 'button',
margin : '5 0 0 5', margin : '5 0 0 5',
action : 'closeMaterialKeeperForm', action : 'closeRegulatorForm',
width: 80, width: 80,
text : '取消' text : '取消'
}] }]
......
...@@ -50,7 +50,7 @@ Ext.define("drp.base.controller.MainController", { ...@@ -50,7 +50,7 @@ Ext.define("drp.base.controller.MainController", {
else if(record.data["id"] == "menu_manager"){//库管员 else if(record.data["id"] == "menu_manager"){//库管员
itemViewXtype = "managerview"; itemViewXtype = "managerview";
itemViewController = "drp.app.controller.users.ManagerController"; itemViewController = "drp.app.controller.users.ManagerController";
itemViewName = "drp.app.view.users.MaterialKeeperView"; itemViewName = "drp.app.view.users.ManagerView";
}else if(record.data["id"] == "menu_warekeeper"){//负责人 }else if(record.data["id"] == "menu_warekeeper"){//负责人
itemViewXtype = "warekeeperview"; itemViewXtype = "warekeeperview";
itemViewController = "drp.app.controller.users.WareKeeperController"; itemViewController = "drp.app.controller.users.WareKeeperController";
......
...@@ -16,7 +16,7 @@ Ext.define("drp.base.view.WestView", { ...@@ -16,7 +16,7 @@ Ext.define("drp.base.view.WestView", {
activeOnTop : true activeOnTop : true
}, },
items : [{ items : [{
title : "库存查看", title : "库存管理",
titleAlign: 'center', titleAlign: 'center',
autoScroll : true, autoScroll : true,
items:[{ items:[{
...@@ -32,7 +32,7 @@ Ext.define("drp.base.view.WestView", { ...@@ -32,7 +32,7 @@ Ext.define("drp.base.view.WestView", {
id : 'menu_current_inventory', id : 'menu_current_inventory',
leaf : true leaf : true
}, { }, {
text : "<span style='font-weight:bold'>月末盘点</span>", text : "<span style='font-weight:bold'>每日总账</span>",
id : 'menu_monthend_inventory', id : 'menu_monthend_inventory',
leaf : true leaf : true
}] }]
......
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