Commit bf01d28c by zhanglt

盘盈入库,物资盘亏代码

parent aa2ec242
......@@ -14,6 +14,18 @@ public class StaticNumSeq {
* 购置备案
* */
public final static String GZBA = "GZBA";
/**
* 领用单号
* */
public final static String LYDH = "LYDH";
/**
* 出库单号
* */
public final static String CKDH = "CKDH";
/**
* 出库单号
* */
public final static String PKDH = "PKDH";
public static List<String> seqList(){
List<String> seqList = new ArrayList<>();
......
......@@ -9,7 +9,7 @@ import com.google.common.collect.Lists;
import com.jeeplus.core.persistence.DataEntity;
import com.jeeplus.common.utils.excel.annotation.ExcelField;
import javax.xml.crypto.Data;
import java.util.Date;
/**
* 物资盘亏记录Entity
......@@ -21,7 +21,7 @@ public class MaterialLoss extends DataEntity<MaterialLoss> {
private static final long serialVersionUID = 1L;
private String number; // 盘亏单号
private String operator; // 操作人
private Data time; // 盘亏时间
private Date time; // 盘亏时间
private String beginTime; // 开始 盘亏时间
private String endTime; // 结束 盘亏时间
private List<MaterialLossInfo> materialLossInfoList = Lists.newArrayList(); // 子表列表
......@@ -53,11 +53,11 @@ public class MaterialLoss extends DataEntity<MaterialLoss> {
}
@ExcelField(title="盘亏时间", align=2, sort=3)
public Data getTime() {
public Date getTime() {
return time;
}
public void setTime(Data time) {
public void setTime(Date time) {
this.time = time;
}
......
......@@ -3,8 +3,18 @@
*/
package com.jeeplus.modules.warehouse.materialloss.service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import com.jeeplus.modules.warehouse.code.util.CodeUtil;
import com.jeeplus.modules.warehouse.code.util.StaticNumSeq;
import com.jeeplus.modules.warehouse.materialrequisition.entity.MaterialRequisition;
import com.jeeplus.modules.warehouse.materialrequisition.entity.MaterialRequisitionInfo;
import com.jeeplus.modules.warehouse.outbound.entity.Outbound;
import com.jeeplus.modules.warehouse.outbound.entity.OutboundInfo;
import com.jeeplus.modules.warehouse.outbound.service.OutboundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -28,6 +38,8 @@ public class MaterialLossService extends CrudService<MaterialLossMapper, Materia
@Autowired
private MaterialLossInfoMapper materialLossInfoMapper;
@Autowired
private OutboundService outboundService;
public MaterialLoss get(String id) {
MaterialLoss materialLoss = super.get(id);
......@@ -71,5 +83,45 @@ public class MaterialLossService extends CrudService<MaterialLossMapper, Materia
super.delete(materialLoss);
materialLossInfoMapper.delete(new MaterialLossInfo(materialLoss));
}
@Transactional(readOnly = false)
public String createLYDH() {
String pkdh = CodeUtil.code("PKDH", StaticNumSeq.PKDH);
return pkdh;
}
//物资盘亏后生成 对应的 出库记录
@Transactional(readOnly = false)
public void delivery(MaterialLoss materialLoss) {
if(materialLoss.getNumber() == null || Objects.equals(materialLoss.getNumber(), "")){
materialLoss.setNumber(this.createLYDH());
}
this.save(materialLoss);
Outbound outbound = new Outbound();
//设置相关表单id为物资盘亏主表的ID
outbound.setRelationId(materialLoss.getId());
//查询当前记录是否已经出库
List<Outbound> list = outboundService.findList(outbound);
if(list != null && list.size()>0){
return;
}
//设置当 前的操作人 与 发放物资的操作人相同
outbound.setOperator(materialLoss.getOperator());
//当前出库时间
outbound.setOutboundTime(new Date());
//出库类型为 领用出库
outbound.setType("2");
List<OutboundInfo> outboundInfoList = new ArrayList<>();
List<MaterialLossInfo> materialLossInfoList = materialLoss.getMaterialLossInfoList();
for (MaterialLossInfo one:materialLossInfoList) {
OutboundInfo outboundInfo = new OutboundInfo();
String ledgerInfoId = one.getLedgerInfo().getId();
String sql = "UPDATE t_wh_ledger_info SET del_flag = 1 WHERE id = " + ledgerInfoId ;
outboundInfo.setId("");
outboundInfo.setOutbound(outbound);
outboundInfo.setLedgerInfo(one.getLedgerInfo());
outboundInfoList.add(outboundInfo);
this.executeUpdateSql(sql);
}
outbound.setOutboundInfoList(outboundInfoList);
outboundService.save(outbound);
}
}
\ No newline at end of file
......@@ -109,7 +109,8 @@ public class MaterialLossController extends BaseController {
return j;
}
//新增或编辑表单保存
materialLossService.save(materialLoss);//保存
// materialLossService.save(materialLoss);//保存
materialLossService.delivery(materialLoss);//保存
j.setSuccess(true);
j.setMsg("保存物资盘亏记录成功");
return j;
......@@ -229,5 +230,28 @@ public class MaterialLossController extends BaseController {
return j;
}
/**
* 保存物资盘亏记录
*/
@ResponseBody
@RequiresPermissions(value={"warehouse:materialloss:materialLoss:add","warehouse:materialloss:materialLoss:edit"},logical=Logical.OR)
@RequestMapping(value = "delivery")
public AjaxJson delivery(MaterialLoss materialLoss, Model model) throws Exception{
AjaxJson j = new AjaxJson();
/**
* 后台hibernate-validation插件校验
*/
String errMsg = beanValidator(materialLoss);
if (StringUtils.isNotBlank(errMsg)){
j.setSuccess(false);
j.setMsg(errMsg);
return j;
}
//新增或编辑表单保存
// materialLossService.save(materialLoss);//保存
materialLossService.delivery(materialLoss);//保存
j.setSuccess(true);
j.setMsg("保存物资盘亏记录成功");
return j;
}
}
\ No newline at end of file
......@@ -22,7 +22,7 @@ public class MaterialRequisition extends DataEntity<MaterialRequisition> {
private static final long serialVersionUID = 1L;
private String number; // 领用单号
private String operator; // 操作人
private String receiver; // 领用人
// private String receiver; // 领用人
private Office office; // 领用机构
private Date time; // 领用时间
private List<MaterialRequisitionInfo> materialRequisitionInfoList = Lists.newArrayList(); // 子表列表
......@@ -53,14 +53,6 @@ public class MaterialRequisition extends DataEntity<MaterialRequisition> {
this.operator = operator;
}
@ExcelField(title="领用人", align=2, sort=3)
public String getReceiver() {
return receiver;
}
public void setReceiver(String receiver) {
this.receiver = receiver;
}
@ExcelField(title="领用机构", fieldType=Office.class, value="", align=2, sort=4)
public Office getOffice() {
......
......@@ -17,6 +17,7 @@ public class MaterialRequisitionInfo extends DataEntity<MaterialRequisitionInfo>
private static final long serialVersionUID = 1L;
private MaterialRequisition materialRequisition; // 物资领用主表ID
private String receiver; // 领用人
private LedgerInfo ledgerInfo; // 物资台账明细ID
public MaterialRequisitionInfo() {
......@@ -44,6 +45,14 @@ public class MaterialRequisitionInfo extends DataEntity<MaterialRequisitionInfo>
public LedgerInfo getLedgerInfo() {
return ledgerInfo;
}
@ExcelField(title="领用人", align=2, sort=3)
public String getReceiver() {
return receiver;
}
public void setReceiver(String receiver) {
this.receiver = receiver;
}
public void setLedgerInfo(LedgerInfo ledgerInfo) {
this.ledgerInfo = ledgerInfo;
......
......@@ -6,6 +6,7 @@
a.id AS "id",
a.material_requisition_id AS "materialRequisition.id",
a.ledger_info_id AS "ledgerInfo.id",
a.receiver AS "receiver",
a.create_by AS "createBy.id",
a.create_date AS "createDate",
a.update_by AS "updateBy.id",
......@@ -76,6 +77,7 @@
INSERT INTO t_wh_material_requisition_info(
id,
material_requisition_id,
receiver,
ledger_info_id,
create_by,
create_date,
......@@ -86,6 +88,7 @@
) VALUES (
#{id},
#{materialRequisition.id},
#{receiver},
#{ledgerInfo.id},
#{createBy.id},
#{createDate},
......@@ -100,6 +103,7 @@
UPDATE t_wh_material_requisition_info SET
material_requisition_id = #{materialRequisition.id},
ledger_info_id = #{ledgerInfo.id},
receiver = #{receiver},
update_by = #{updateBy.id},
update_date = #{updateDate},
remarks = #{remarks}
......
......@@ -6,7 +6,6 @@
a.id AS "id",
a.number AS "number",
a.operator AS "operator",
a.receiver AS "receiver",
a.collecting_office_id AS "office.id",
a.time AS "time",
a.create_by AS "createBy.id",
......@@ -46,9 +45,6 @@
<if test="operator != null and operator != ''">
AND a.operator = #{operator}
</if>
<if test="receiver != null and receiver != ''">
AND a.receiver = #{receiver}
</if>
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
......@@ -84,7 +80,6 @@
id,
number,
operator,
receiver,
collecting_office_id,
time,
create_by,
......@@ -97,7 +92,6 @@
#{id},
#{number},
#{operator},
#{receiver},
#{office.id},
#{time},
#{createBy.id},
......@@ -113,7 +107,6 @@
UPDATE t_wh_material_requisition SET
number = #{number},
operator = #{operator},
receiver = #{receiver},
collecting_office_id = #{office.id},
time = #{time},
update_by = #{updateBy.id},
......
......@@ -3,8 +3,16 @@
*/
package com.jeeplus.modules.warehouse.materialrequisition.service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import com.jeeplus.modules.warehouse.code.util.CodeUtil;
import com.jeeplus.modules.warehouse.code.util.StaticNumSeq;
import com.jeeplus.modules.warehouse.outbound.entity.Outbound;
import com.jeeplus.modules.warehouse.outbound.entity.OutboundInfo;
import com.jeeplus.modules.warehouse.outbound.service.OutboundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -28,6 +36,9 @@ public class MaterialRequisitionService extends CrudService<MaterialRequisitionM
@Autowired
private MaterialRequisitionInfoMapper materialRequisitionInfoMapper;
@Autowired
private OutboundService outboundService;
public MaterialRequisition get(String id) {
MaterialRequisition materialRequisition = super.get(id);
......@@ -70,5 +81,49 @@ public class MaterialRequisitionService extends CrudService<MaterialRequisitionM
super.delete(materialRequisition);
materialRequisitionInfoMapper.delete(new MaterialRequisitionInfo(materialRequisition));
}
@Transactional(readOnly = false)
public String createLYDH() {
String lydh = CodeUtil.code("LYDH", StaticNumSeq.LYDH);
return lydh;
}
//物资领用后生成 对应的 出库记录
@Transactional(readOnly = false)
public void delivery(MaterialRequisition materialRequisition) {
if(materialRequisition.getNumber() == null &&Objects.equals(materialRequisition.getNumber(), "")){
materialRequisition.setNumber(this.createLYDH());
}
this.save(materialRequisition);
Outbound outbound = new Outbound();
//设置相关表单id为领用主表的ID
outbound.setRelationId(materialRequisition.getId());
//查询当前记录是否已经出库
List<Outbound> list = outboundService.findList(outbound);
if(list != null && list.size()>0){
return;
}
//设置当 前的操作人 与 发放物资的操作人相同
outbound.setOperator(materialRequisition.getOperator());
//当前出库时间
outbound.setOutboundTime(new Date());
//出库类型为 领用出库
outbound.setType("1");
List<OutboundInfo> outboundInfoList = new ArrayList<>();
List<MaterialRequisitionInfo> materialRequisitionInfoList = materialRequisition.getMaterialRequisitionInfoList();
if(materialRequisitionInfoList != null ){
for (MaterialRequisitionInfo one:materialRequisitionInfoList) {
OutboundInfo outboundInfo = new OutboundInfo();
String ledgerInfoId = one.getLedgerInfo().getId();
String sql = "UPDATE t_wh_ledger_info SET del_flag = 1 WHERE id = " + ledgerInfoId ;
outboundInfo.setId("");
outboundInfo.setOutbound(outbound);
outboundInfo.setLedgerInfo(one.getLedgerInfo());
outboundInfoList.add(outboundInfo);
this.executeUpdateSql(sql);
}
outbound.setOutboundInfoList(outboundInfoList);
outboundService.save(outbound);
}
}
}
\ No newline at end of file
......@@ -3,6 +3,7 @@
*/
package com.jeeplus.modules.warehouse.materialrequisition.web;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
......@@ -10,6 +11,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolationException;
import com.jeeplus.modules.sys.entity.User;
import com.jeeplus.modules.sys.service.SystemService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -46,6 +49,9 @@ public class MaterialRequisitionController extends BaseController {
@Autowired
private MaterialRequisitionService materialRequisitionService;
@Autowired
private SystemService systemService;
@ModelAttribute
public MaterialRequisition get(@RequestParam(required=false) String id) {
......@@ -109,7 +115,9 @@ public class MaterialRequisitionController extends BaseController {
return j;
}
//新增或编辑表单保存
materialRequisitionService.save(materialRequisition);//保存
// materialRequisitionService.save(materialRequisition);//保存
materialRequisitionService.delivery(materialRequisition);
j.setSuccess(true);
j.setMsg("保存物资领用成功");
return j;
......@@ -228,6 +236,46 @@ public class MaterialRequisitionController extends BaseController {
}
return j;
}
/**
* 生成对应的 出库记录 领用后出库
*/
@ResponseBody
@RequiresPermissions(value={"warehouse:materialrequisition:materialRequisition:add","warehouse:materialrequisition:materialRequisition:edit"},logical=Logical.OR)
@RequestMapping(value = "delivery")
public AjaxJson delivery(MaterialRequisition materialRequisition, Model model) throws Exception{
AjaxJson j = new AjaxJson();
/**
* 后台hibernate-validation插件校验
*/
String errMsg = beanValidator(materialRequisition);
if (StringUtils.isNotBlank(errMsg)){
j.setSuccess(false);
j.setMsg(errMsg);
return j;
}
//新增或编辑表单保存
// materialRequisitionService.save(materialRequisition);//保存
materialRequisitionService.delivery(materialRequisition);
j.setSuccess(true);
j.setMsg("保存物资领用成功");
return j;
}
/**
* 获取 领用机构下的 所有用户
*/
@ResponseBody
@RequestMapping(value = "getUserListByOfficeId")
public List<User> getUserListByOfficeId(String officeId) throws Exception{
/**
* 后台hibernate-validation插件校验
*/
List<User> list = new ArrayList<>();
if (StringUtils.isBlank(officeId)){
return list;
}
list = systemService.findUserByOfficeId(officeId);
return list;
}
}
\ No newline at end of file
......@@ -4,7 +4,10 @@
package com.jeeplus.modules.warehouse.outbound.service;
import java.util.List;
import java.util.Objects;
import com.jeeplus.modules.warehouse.code.util.CodeUtil;
import com.jeeplus.modules.warehouse.code.util.StaticNumSeq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -45,6 +48,9 @@ public class OutboundService extends CrudService<OutboundMapper, Outbound> {
@Transactional(readOnly = false)
public void save(Outbound outbound) {
if(outbound.getNumber() == null || Objects.equals(outbound.getNumber(), "")){
outbound.setNumber(this.createCKDH());
}
super.save(outbound);
for (OutboundInfo outboundInfo : outbound.getOutboundInfoList()){
if (outboundInfo.getId() == null){
......@@ -66,7 +72,11 @@ public class OutboundService extends CrudService<OutboundMapper, Outbound> {
}
}
}
@Transactional(readOnly = false)
public String createCKDH() {
String ckdh = CodeUtil.code("CKDH", StaticNumSeq.CKDH);
return ckdh;
}
@Transactional(readOnly = false)
public void delete(Outbound outbound) {
super.delete(outbound);
......
......@@ -10,6 +10,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolationException;
import com.jeeplus.modules.warehouse.warehouse.entity.Warehouse;
import com.jeeplus.modules.warehouse.warehouse.service.WarehouseService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -46,6 +48,8 @@ public class ShelvesController extends BaseController {
@Autowired
private ShelvesService shelvesService;
@Autowired
private WarehouseService warehouseService;
@ModelAttribute
public Shelves get(@RequestParam(required=false) String id) {
......@@ -66,6 +70,9 @@ public class ShelvesController extends BaseController {
@RequestMapping(value = {"list", ""})
public String list(Shelves shelves, Model model) {
model.addAttribute("shelves", shelves);
Warehouse warehouse = new Warehouse();
List<Warehouse> warehouseList = warehouseService.findList(warehouse);
model.addAttribute("warehouseList", warehouseList);
return "modules/warehouse/shelves/shelvesList";
}
......@@ -87,6 +94,9 @@ public class ShelvesController extends BaseController {
@RequestMapping(value = "form/{mode}")
public String form(@PathVariable String mode, Shelves shelves, Model model) {
model.addAttribute("shelves", shelves);
Warehouse warehouse = new Warehouse();
List<Warehouse> warehouseList = warehouseService.findList(warehouse);
model.addAttribute("warehouseList", warehouseList);
model.addAttribute("mode", mode);
return "modules/warehouse/shelves/shelvesForm";
}
......
......@@ -85,16 +85,11 @@
<form:input path="operator" htmlEscape="false" class="form-control "/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">领用人:</label>
<div class="col-sm-10">
<form:input path="receiver" htmlEscape="false" class="form-control "/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">领用机构:</label>
<div class="col-sm-10">
<sys:treeselect id="office" name="office.id" value="${materialRequisition.office.id}" labelName="" labelValue="${materialRequisition.office.id}"
<sys:treeselect id="office" name="office.id" value="${materialRequisition.office.id}" labelName="" labelValue="${materialRequisition.office.name}"
title="部门" url="/sys/office/treeData?type=2" cssClass="form-control " allowClear="true" notAllowSelectParent="true"/>
</div>
</div>
......@@ -129,6 +124,7 @@
<th class="hide"></th>
<th>物资领用主表ID</th>
<th>物资台账明细ID</th>
<th>领用人</th>
<th>备注信息</th>
<th width="10">&nbsp;</th>
</tr>
......@@ -152,6 +148,9 @@
<input id="materialRequisitionInfoList{{idx}}_ledgerInfo" name="materialRequisitionInfoList[{{idx}}].ledgerInfo.id" type="text" value="{{row.ledgerInfo.id}}" class="form-control "/>
</td>
<td>
<input id="materialRequisitionInfoList{{idx}}_receiver" name="materialRequisitionInfoList[{{idx}}].receiver" type="text" value="{{row.receiver}}" class="form-control "/>
</td>
<td>
<textarea id="materialRequisitionInfoList{{idx}}_remarks" name="materialRequisitionInfoList[{{idx}}].remarks" rows="4" class="form-control ">{{row.remarks}}</textarea>
......
......@@ -117,17 +117,10 @@ $(document).ready(function() {
}
,{
field: 'receiver',
title: '领用人',
sortable: true,
sortName: 'receiver'
}
,{
field: '',
field: 'office.name',
title: '领用机构',
sortable: true,
sortName: ''
sortName: 'o.name'
}
,{
......@@ -309,6 +302,7 @@ $(document).ready(function() {
<tr>
<th>物资领用主表ID</th>
<th>物资台账明细ID</th>
<th>领用人</th>
<th>备注信息</th>
</tr>
</thead>
......@@ -327,6 +321,9 @@ $(document).ready(function() {
{{row.ledgerInfo.id}}
</td>
<td>
{{row.receiver}}
</td>
<td>
{{row.remarks}}
</td>
</tr>//-->
......
......@@ -30,10 +30,6 @@
<form:input path="operator" htmlEscape="false" maxlength="64" class=" form-control"/>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<label class="label-item single-overflow pull-left" title="领用人:">领用人:</label>
<form:input path="receiver" htmlEscape="false" maxlength="64" class=" form-control"/>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<div style="margin-top:26px">
<a id="search" class="btn btn-primary btn-rounded btn-bordered btn-sm"><i class="fa fa-search"></i> 查询</a>
<a id="reset" class="btn btn-primary btn-rounded btn-bordered btn-sm" ><i class="fa fa-refresh"></i> 重置</a>
......
......@@ -101,7 +101,7 @@
<div class="col-sm-10">
<form:select path="type" class="form-control ">
<form:option value="" label=""/>
<form:options items="${fns:getDictList('')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
<form:options items="${fns:getDictList('wh_delivery_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
</form:select>
</div>
</div>
......
......@@ -129,7 +129,7 @@ $(document).ready(function() {
sortable: true,
sortName: 'type',
formatter:function(value, row , index){
return jp.getDictLabel(${fns:toJson(fns:getDictList(''))}, value, "-");
return jp.getDictLabel(${fns:toJson(fns:getDictList('wh_delivery_type'))}, value, "-");
}
}
......
......@@ -59,7 +59,7 @@
<label class="label-item single-overflow pull-left" title="出库分类:">出库分类:</label>
<form:select path="type" class="form-control m-b">
<form:option value="" label=""/>
<form:options items="${fns:getDictList('')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
<form:options items="${fns:getDictList('wh_delivery_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
</form:select>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
......
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