Commit e24e3353 by yyq1988

Merge remote-tracking branch 'origin/master'

parents 7e5c153e 208a468c
......@@ -21,4 +21,5 @@ public interface LedgerInfoMapper extends BaseMapper<LedgerInfo> {
public List<CountLedgerInfo> findCliList(LedgerInfo ledgerInfo);
void deleteByLedgerInfo(@Param("id") String id);
void updateByLedgerInfo(@Param("id") String id);
}
\ No newline at end of file
......@@ -217,6 +217,11 @@
del_flag = '1'
WHERE id = #{id}
</update>
<update id="updateByLedgerInfo">
UPDATE t_wh_ledger_info SET
del_flag = '0'
WHERE id = #{id}
</update>
<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
......
......@@ -18,11 +18,22 @@ public class MaterialLossInfo extends DataEntity<MaterialLossInfo> {
private static final long serialVersionUID = 1L;
private MaterialLoss materialLoss; // 盘亏表主表ID
private LedgerInfo ledgerInfo; // 物资台账明细ID
private String remarks; // 物资台账明细ID
public MaterialLossInfo() {
super();
}
@Override
public String getRemarks() {
return remarks;
}
@Override
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public MaterialLossInfo(String id){
super(id);
}
......
......@@ -70,22 +70,91 @@ public class MaterialLossService extends CrudService<MaterialLossMapper, Materia
@Transactional(readOnly = false)
public void save(MaterialLoss materialLoss) {
super.save(materialLoss);
//保存出库主表信息
Outbound outbound = new Outbound();
//设置相关表单id为物资盘亏主表的ID
outbound.setRelationId(materialLoss.getId());
List<Outbound> list = outboundService.findList(outbound);
if(list != null && list.size()>0){
outbound.setId(list.get(0).getId());
outboundService.deleteInfo(outbound);
}
//设置当 前的操作人 与 发放物资的操作人相同
outbound.setOperator(materialLoss.getOperator());
//当前出库时间
outbound.setOutboundTime(materialLoss.getTime());
//出库类型为 领用出库
outbound.setType("2");
List<OutboundInfo> outboundInfoList = new ArrayList<>();
for (MaterialLossInfo materialLossInfo : materialLoss.getMaterialLossInfoList()){
if (materialLossInfo.getId() == null){
continue;
}
if (MaterialLossInfo.DEL_FLAG_NORMAL.equals(materialLossInfo.getDelFlag())){
OutboundInfo outboundInfo = new OutboundInfo();
outboundInfo.setId("");
outboundInfo.setOutbound(outbound);
outboundInfo.setLedgerInfo(materialLossInfo.getLedgerInfo());
outboundInfoList.add(outboundInfo);
outbound.setOutboundInfoList(outboundInfoList);
outboundService.saveOutbound(outbound);
if (StringUtils.isBlank(materialLossInfo.getId())){
materialLossInfo.setMaterialLoss(materialLoss);
materialLossInfo.preInsert();
materialLossInfoMapper.insert(materialLossInfo);
String ledgerInfoId = materialLossInfo.getLedgerInfo().getId();
LedgerInfo ledgerInfo = ledgerInfoMapper.get(ledgerInfoId);
ledgerInfoMapper.deleteByLedgerInfo(ledgerInfoId);
if(ledgerInfo.getQr() != null){
QrCode qrCode = qrCodeService.get(ledgerInfo.getQr().getId());
if(qrCode!=null){
qrCode.setState("3");
qrCodeService.save(qrCode);
}
}
if(ledgerInfo != null ){
Ledger ledger = ledgerService.get(ledgerInfo.getLedger().getId());
if(ledger != null){
ledger.setNum(ledger.getNum() - 1);
try {
ledger.setSum(ledger.getSum().subtract(ledgerInfo.getAmount()));
}catch (Exception e){
System.out.println(e.getMessage());
}
ledgerService.lowerLedger(ledger);
}
}
}else{
materialLossInfo.setMaterialLoss(materialLoss);
materialLossInfo.preUpdate();
materialLossInfoMapper.update(materialLossInfo);
}
}else{
materialLossInfoMapper.delete(materialLossInfo);
String ledgerInfoId = materialLossInfo.getLedgerInfo().getId();
LedgerInfo ledgerInfo = ledgerInfoMapper.get(ledgerInfoId);
ledgerInfoMapper.updateByLedgerInfo(ledgerInfoId);
if(ledgerInfo.getQr() != null){
QrCode qrCode = qrCodeService.get(ledgerInfo.getQr().getId());
if(qrCode!=null){
qrCode.setState("2");
qrCodeService.save(qrCode);
}
}
if(ledgerInfo != null ){
Ledger ledger = ledgerService.get(ledgerInfo.getLedger().getId());
if(ledger != null){
ledger.setNum(ledger.getNum() + 1);
try {
ledger.setSum(ledger.getSum().add(ledgerInfo.getAmount()));
}catch (Exception e){
System.out.println(e.getMessage());
}
ledgerService.lowerLedger(ledger);
}
}
}
}
}
......@@ -126,13 +195,14 @@ public class MaterialLossService extends CrudService<MaterialLossMapper, Materia
for (MaterialLossInfo one:materialLossInfoList) {
OutboundInfo outboundInfo = new OutboundInfo();
String ledgerInfoId = one.getLedgerInfo().getId();
LedgerInfo ledgerInfo = ledgerInfoMapper.get(ledgerInfoId);
ledgerInfoMapper.deleteByLedgerInfo(ledgerInfoId);
if(ledgerInfo.getQr() != null){
QrCode qrCode = qrCodeService.get(ledgerInfo.getQr().getId());
qrCode.setState("3");
qrCodeService.save(qrCode);
if(qrCode!=null){
qrCode.setState("3");
qrCodeService.save(qrCode);
}
}
if(ledgerInfo != null ){
Ledger ledger = ledgerService.get(ledgerInfo.getLedger().getId());
......
......@@ -119,8 +119,8 @@ public class MaterialLossController extends BaseController {
return j;
}
//新增或编辑表单保存
// materialLossService.save(materialLoss);//保存
materialLossService.delivery(materialLoss);//保存
materialLossService.save(materialLoss);//保存
// materialLossService.delivery(materialLoss);//保存
j.setSuccess(true);
j.setMsg("保存物资盘亏记录成功");
return j;
......
......@@ -6,6 +6,7 @@ package com.jeeplus.modules.warehouse.outbound.mapper;
import com.jeeplus.core.persistence.BaseMapper;
import com.jeeplus.core.persistence.annotation.MyBatisMapper;
import com.jeeplus.modules.warehouse.outbound.entity.OutboundInfo;
import org.apache.ibatis.annotations.Param;
/**
* 出库单明细表MAPPER接口
......@@ -14,5 +15,6 @@ import com.jeeplus.modules.warehouse.outbound.entity.OutboundInfo;
*/
@MyBatisMapper
public interface OutboundInfoMapper extends BaseMapper<OutboundInfo> {
void deleteByOutboundId(@Param("outboundInfo") OutboundInfo outboundInfo);
}
\ No newline at end of file
......@@ -24,8 +24,12 @@
left join t_wh_ledger_info ledgerInfo on a.ledger_info_id = ledgerInfo.id
LEFT JOIN t_wh_material_type tpye ON ledgerInfo.type_id = tpye.id
</sql>
<delete id="deleteByOutboundId" parameterType="com.jeeplus.modules.warehouse.outbound.entity.OutboundInfo">
DELETE FROM t_wh_outbound_info
WHERE outbound_id = #{outboundInfo.outbound.id}
</delete>
<select id="get" resultType="OutboundInfo" >
SELECT
<include refid="outboundInfoColumns"/>
......
......@@ -60,7 +60,8 @@ public class OutboundService extends CrudService<OutboundMapper, Outbound> {
public Page<Outbound> findPage(Page<Outbound> page, Outbound outbound) {
return super.findPage(page, outbound);
}
//出库并下账
@Transactional(readOnly = false)
public void save(Outbound outbound) {
if(outbound.getNumber() == null || Objects.equals(outbound.getNumber(), "")){
......@@ -78,7 +79,6 @@ public class OutboundService extends CrudService<OutboundMapper, Outbound> {
outboundInfoMapper.insert(outboundInfo);
}else{
outboundInfo.setOutbound(outbound);
outboundInfo.preUpdate();
outboundInfoMapper.update(outboundInfo);
}
......@@ -88,6 +88,32 @@ public class OutboundService extends CrudService<OutboundMapper, Outbound> {
}
this.delivery(outbound);
}
//更新盘亏出库
@Transactional(readOnly = false)
public void saveOutbound(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){
continue;
}
if (OutboundInfo.DEL_FLAG_NORMAL.equals(outboundInfo.getDelFlag())){
if (StringUtils.isBlank(outboundInfo.getId())){
outboundInfo.setOutbound(outbound);
outboundInfo.preInsert();
outboundInfoMapper.insert(outboundInfo);
}else{
outboundInfo.setOutbound(outbound);
outboundInfo.preUpdate();
outboundInfoMapper.update(outboundInfo);
}
}else{
outboundInfoMapper.delete(outboundInfo);
}
}
}
@Transactional(readOnly = false)
public void delivery(Outbound outbound) {
List<OutboundInfo> outboundInfoList = outbound.getOutboundInfoList();
......@@ -127,5 +153,9 @@ public class OutboundService extends CrudService<OutboundMapper, Outbound> {
super.delete(outbound);
outboundInfoMapper.delete(new OutboundInfo(outbound));
}
@Transactional(readOnly = false)
public void deleteInfo(Outbound outbound) {
outboundInfoMapper.deleteByOutboundId(new OutboundInfo(outbound));
}
}
\ No newline at end of file
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