Commit 2c86de2d by zhanglt

盘盈入库调整,

新增台账明细逻辑删除方法
parent 8ad7d0d8
......@@ -7,6 +7,7 @@ import com.jeeplus.core.persistence.BaseMapper;
import com.jeeplus.core.persistence.annotation.MyBatisMapper;
import com.jeeplus.modules.warehouse.ledger.dto.CountLedgerInfo;
import com.jeeplus.modules.warehouse.ledger.entity.LedgerInfo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -19,4 +20,5 @@ import java.util.List;
public interface LedgerInfoMapper extends BaseMapper<LedgerInfo> {
public List<CountLedgerInfo> findCliList(LedgerInfo ledgerInfo);
void deleteByLedgerInfo(@Param("id") String id);
}
\ No newline at end of file
......@@ -208,6 +208,12 @@
</otherwise>
</choose>
</update>
<!--逻辑删除-->
<update id="deleteByLedgerInfo">
UPDATE t_wh_ledger_info SET
del_flag = #{DEL_FLAG_DELETE}
WHERE id = #{id}
</update>
<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
......
......@@ -134,7 +134,7 @@ public class MaterialRequisitionService extends CrudService<MaterialRequisitionM
ledgerService.save(ledger);
}
}
ledgerInfoMapper.deleteByLogic(ledgerInfoId);
ledgerInfoMapper.deleteByLedgerInfo(ledgerInfoId);
outboundInfo.setId("");
outboundInfo.setOutbound(outbound);
outboundInfo.setLedgerInfo(one.getLedgerInfo());
......
......@@ -5,6 +5,7 @@
<sql id="profitWarehousingInfoColumns">
a.id AS "id",
a.profit_warehousing_id AS "profitWarehousing.id",
profitWarehousing.number AS "profitWarehousing.number",
a.name AS "name",
a.type AS "type.id",
a.marking AS "marking",
......@@ -24,6 +25,7 @@
<sql id="profitWarehousingInfoJoins">
LEFT JOIN t_wh_material_type type ON type.id = a.type
LEFT JOIN t_wh_warehouse warehouse ON warehouse.id = a.warehouse_id
LEFT JOIN t_profit_warehousing profitWarehousing ON profitWarehousing.id = a.profit_warehousing_id
</sql>
......
......@@ -15,7 +15,9 @@ import com.jeeplus.modules.warehouse.code.util.StaticNumSeq;
import com.jeeplus.modules.warehouse.goods.entity.GoodsInfo;
import com.jeeplus.modules.warehouse.ledger.entity.Ledger;
import com.jeeplus.modules.warehouse.ledger.entity.LedgerInfo;
import com.jeeplus.modules.warehouse.ledger.mapper.LedgerInfoMapper;
import com.jeeplus.modules.warehouse.ledger.mapper.LedgerMapper;
import com.jeeplus.modules.warehouse.ledger.service.LedgerService;
import com.jeeplus.modules.warehouse.qrcode.entity.QrCode;
import com.jeeplus.modules.warehouse.qrcode.mapper.QrCodeMapper;
import com.jeeplus.modules.warehouse.qrcode.util.BuildQcUtil;
......@@ -46,6 +48,10 @@ public class ProfitWarehousingService extends CrudService<ProfitWarehousingMappe
private LedgerMapper ledgerMapper;
@Autowired
private QrCodeMapper qrCodeMapper;
@Autowired
private LedgerInfoMapper ledgerInfoMapper;
@Autowired
private LedgerService ledgerService;
public ProfitWarehousing get(String id) {
ProfitWarehousing profitWarehousing = super.get(id);
......@@ -93,11 +99,9 @@ public class ProfitWarehousingService extends CrudService<ProfitWarehousingMappe
profitWarehousingInfo.setQrCode(qrCode);
profitWarehousingInfoMapper.insert(profitWarehousingInfo);
return profitWarehousingInfo;
}
@Transactional(readOnly = false)
public void save(ProfitWarehousing profitWarehousing) {
profitWarehousing.setNumber(createPYDH());
super.save(profitWarehousing);
for (ProfitWarehousingInfo profitWarehousingInfo : profitWarehousing.getProfitWarehousingInfoList()){
profitWarehousingInfo.setProfitWarehousing(profitWarehousing);
......@@ -125,38 +129,43 @@ public class ProfitWarehousingService extends CrudService<ProfitWarehousingMappe
}
//盘盈入库 保存 盘盈入库信息 ,并添加对应的台账信息
@Transactional(readOnly = false)
public void inLedgerInfo(ProfitWarehousing profitWarehousing) {
List<ProfitWarehousingInfo> profitWarehousingInfoList = profitWarehousing.getProfitWarehousingInfoList();
//当前盘盈入库单的明细信息
BigDecimal sum = BigDecimal.ONE;
if(profitWarehousingInfoList != null ){
if(profitWarehousingInfoList.size() > 0 ){
for (ProfitWarehousingInfo one:profitWarehousingInfoList) {
BigDecimal amount = one.getAmount();
if(amount != null){
//总价 是所有单价之和
sum = sum.add(amount);
}
//获取同名称类型型号的台账主表信息
Ledger ledger = new Ledger(one.getName(),one.getType(),one.getMarking());
Ledger oldLeger = ledgerMapper.findByTypeAndModel(ledger);
LedgerInfo ledgerInfo = new LedgerInfo();
//单价
ledgerInfo.setAmount(one.getAmount());
//名称
ledgerInfo.setName(one.getName());
//盘盈入库单号
ledgerInfo.setBatchNum(profitWarehousing.getNumber());
//物资编码
ledgerInfo.setCode("");
if(oldLeger!=null){
//台账主表
ledgerInfo.setLedger(oldLeger);
}else {
public void inLedgerInfo(ProfitWarehousingInfo profitWarehousingInfo) {
QrCode qrCode = profitWarehousingInfo.getQrCode();
qrCode.getId();
qrCode.getCode();
Ledger ledger = new Ledger(profitWarehousingInfo.getName(),profitWarehousingInfo.getType(),profitWarehousingInfo.getMarking());
Ledger oldLeger = ledgerMapper.findByTypeAndModel(ledger);
LedgerInfo ledgerInfo = new LedgerInfo();
//名称
ledgerInfo.setName(ledger.getName());
//类型
ledgerInfo.setType(ledger.getType());
//型号
ledgerInfo.setModel(ledger.getModel());
//物资编码
ledgerInfo.setCode(qrCode.getCode());
//二维码id
ledgerInfo.setQr(qrCode);
//货架id
ledgerInfo.setShelves(profitWarehousingInfo.getShelves());
//盘盈入库单编码
ledgerInfo.setBatchNum(profitWarehousingInfo.getProfitWarehousing().getNumber());
//单价
ledgerInfo.setAmount(profitWarehousingInfo.getAmount());
//查询 台账中是否有 该类型的物资
if(oldLeger != null){
//有台账 直接在该物资下加入一条明细,并更新台账
//台账主表id
ledgerInfo.setLedger(oldLeger);
BigDecimal sum = oldLeger.getSum();
sum = sum.add(profitWarehousingInfo.getAmount());
oldLeger.setSum(sum);
List<LedgerInfo> ledgerInfoList = oldLeger.getLedgerInfoList();
ledgerInfoList.add(ledgerInfo);
oldLeger.setLedgerInfoList(ledgerInfoList);
}else {
}
}
}
}
}
}
\ No newline at end of file
......@@ -5,11 +5,17 @@ package com.jeeplus.modules.warehouse.profitwarehousing.web;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolationException;
import com.jeeplus.modules.sys.utils.UserUtils;
import com.jeeplus.modules.warehouse.goods.entity.GoodsInfo;
import com.jeeplus.modules.warehouse.profitwarehousing.entity.ProfitWarehousingInfo;
import com.jeeplus.modules.warehouse.profitwarehousing.mapper.ProfitWarehousingInfoMapper;
import com.jeeplus.modules.warehouse.qrcode.entity.QrCode;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -46,6 +52,8 @@ public class ProfitWarehousingController extends BaseController {
@Autowired
private ProfitWarehousingService profitWarehousingService;
@Autowired
private ProfitWarehousingInfoMapper profitWarehousingInfoMapper;
@ModelAttribute
public ProfitWarehousing get(@RequestParam(required=false) String id) {
......@@ -86,6 +94,15 @@ public class ProfitWarehousingController extends BaseController {
@RequiresPermissions(value={"warehouse:profitwarehousing:profitWarehousing:view","warehouse:profitwarehousing:profitWarehousing:add","warehouse:profitwarehousing:profitWarehousing:edit"},logical=Logical.OR)
@RequestMapping(value = "form/{mode}")
public String form(@PathVariable String mode, ProfitWarehousing profitWarehousing, Model model) {
if(mode !=null ||Objects.equals(mode, "add")){
if(profitWarehousing.getNumber()==null|| Objects.equals(profitWarehousing.getNumber(), "")){
profitWarehousing.setNumber(profitWarehousingService.createPYDH());
}
if(profitWarehousing.getOperator() == null){
profitWarehousing.setOperator(UserUtils.getUser());
}
}
model.addAttribute("profitWarehousing", profitWarehousing);
model.addAttribute("mode", mode);
return "modules/warehouse/profitwarehousing/profitWarehousingForm";
......@@ -229,24 +246,53 @@ public class ProfitWarehousingController extends BaseController {
return j;
}
/**
* 保存新增盘盈入库信息后,入台账
* 打印二维码
*/
@ResponseBody
@RequestMapping(value = "printQr")
public AjaxJson printQr(String profitWarehousingInfoId) throws Exception{
AjaxJson j = new AjaxJson();
//查询该明细,是否已经生成二维码记录
ProfitWarehousingInfo profitWarehousingInfo1 = profitWarehousingInfoMapper.get(profitWarehousingInfoId);
if(profitWarehousingInfo1.getQrCode() != null){
j.setSuccess(false);
j.setMsg("二维码已存在");
return j;
}
ProfitWarehousingInfo profitWarehousingInfo = profitWarehousingService.printQr(profitWarehousingInfoId);//保存
j.put("profitWarehousingInfo", profitWarehousingInfo);
j.setSuccess(true);
j.setMsg("生成二维码成功");
return j;
}
/**
* 盘盈入库明细,入台账
*/
@ResponseBody
@RequiresPermissions(value={"warehouse:profitwarehousing:profitWarehousing:add","warehouse:profitwarehousing:profitWarehousing:edit"},logical=Logical.OR)
@RequestMapping(value = "inLedgerInfo")
public AjaxJson inLedgerInfo(ProfitWarehousing profitWarehousing, Model model) throws Exception{
public AjaxJson inLedgerInfo(String profitWarehousingInfoId, Model model) throws Exception{
AjaxJson j = new AjaxJson();
/**
* 后台hibernate-validation插件校验
*/
String errMsg = beanValidator(profitWarehousing);
String errMsg = beanValidator(profitWarehousingInfoId);
if (StringUtils.isNotBlank(errMsg)){
j.setSuccess(false);
j.setMsg(errMsg);
return j;
}
ProfitWarehousingInfo profitWarehousingInfo = profitWarehousingInfoMapper.get(profitWarehousingInfoId);
if(profitWarehousingInfo.getQrCode() == null){
j.setSuccess(false);
j.setMsg("请先生成二维码");
}
if(profitWarehousingInfo.getQrCode() != null){
QrCode qrCode = profitWarehousingInfo.getQrCode();
}
//新增或编辑表单保存
profitWarehousingService.inLedgerInfo(profitWarehousing);//保存
profitWarehousingService.inLedgerInfo(profitWarehousingInfo);//保存
j.setSuccess(true);
j.setMsg("物资入帐成功");
return j;
......
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