Commit e24e3353 by yyq1988

Merge remote-tracking branch 'origin/master'

parents 7e5c153e 208a468c
...@@ -21,4 +21,5 @@ public interface LedgerInfoMapper extends BaseMapper<LedgerInfo> { ...@@ -21,4 +21,5 @@ public interface LedgerInfoMapper extends BaseMapper<LedgerInfo> {
public List<CountLedgerInfo> findCliList(LedgerInfo ledgerInfo); public List<CountLedgerInfo> findCliList(LedgerInfo ledgerInfo);
void deleteByLedgerInfo(@Param("id") String id); void deleteByLedgerInfo(@Param("id") String id);
void updateByLedgerInfo(@Param("id") String id);
} }
\ No newline at end of file
...@@ -217,6 +217,11 @@ ...@@ -217,6 +217,11 @@
del_flag = '1' del_flag = '1'
WHERE id = #{id} WHERE id = #{id}
</update> </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> { ...@@ -18,11 +18,22 @@ public class MaterialLossInfo extends DataEntity<MaterialLossInfo> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private MaterialLoss materialLoss; // 盘亏表主表ID private MaterialLoss materialLoss; // 盘亏表主表ID
private LedgerInfo ledgerInfo; // 物资台账明细ID private LedgerInfo ledgerInfo; // 物资台账明细ID
private String remarks; // 物资台账明细ID
public MaterialLossInfo() { public MaterialLossInfo() {
super(); super();
} }
@Override
public String getRemarks() {
return remarks;
}
@Override
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public MaterialLossInfo(String id){ public MaterialLossInfo(String id){
super(id); super(id);
} }
......
...@@ -70,22 +70,91 @@ public class MaterialLossService extends CrudService<MaterialLossMapper, Materia ...@@ -70,22 +70,91 @@ public class MaterialLossService extends CrudService<MaterialLossMapper, Materia
@Transactional(readOnly = false) @Transactional(readOnly = false)
public void save(MaterialLoss materialLoss) { public void save(MaterialLoss materialLoss) {
super.save(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()){ for (MaterialLossInfo materialLossInfo : materialLoss.getMaterialLossInfoList()){
if (materialLossInfo.getId() == null){ if (materialLossInfo.getId() == null){
continue; continue;
} }
if (MaterialLossInfo.DEL_FLAG_NORMAL.equals(materialLossInfo.getDelFlag())){ 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())){ if (StringUtils.isBlank(materialLossInfo.getId())){
materialLossInfo.setMaterialLoss(materialLoss); materialLossInfo.setMaterialLoss(materialLoss);
materialLossInfo.preInsert(); materialLossInfo.preInsert();
materialLossInfoMapper.insert(materialLossInfo); 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{ }else{
materialLossInfo.setMaterialLoss(materialLoss); materialLossInfo.setMaterialLoss(materialLoss);
materialLossInfo.preUpdate(); materialLossInfo.preUpdate();
materialLossInfoMapper.update(materialLossInfo); materialLossInfoMapper.update(materialLossInfo);
} }
}else{ }else{
materialLossInfoMapper.delete(materialLossInfo); 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,14 +195,15 @@ public class MaterialLossService extends CrudService<MaterialLossMapper, Materia ...@@ -126,14 +195,15 @@ public class MaterialLossService extends CrudService<MaterialLossMapper, Materia
for (MaterialLossInfo one:materialLossInfoList) { for (MaterialLossInfo one:materialLossInfoList) {
OutboundInfo outboundInfo = new OutboundInfo(); OutboundInfo outboundInfo = new OutboundInfo();
String ledgerInfoId = one.getLedgerInfo().getId(); String ledgerInfoId = one.getLedgerInfo().getId();
LedgerInfo ledgerInfo = ledgerInfoMapper.get(ledgerInfoId); LedgerInfo ledgerInfo = ledgerInfoMapper.get(ledgerInfoId);
ledgerInfoMapper.deleteByLedgerInfo(ledgerInfoId); ledgerInfoMapper.deleteByLedgerInfo(ledgerInfoId);
if(ledgerInfo.getQr() != null){ if(ledgerInfo.getQr() != null){
QrCode qrCode = qrCodeService.get(ledgerInfo.getQr().getId()); QrCode qrCode = qrCodeService.get(ledgerInfo.getQr().getId());
if(qrCode!=null){
qrCode.setState("3"); qrCode.setState("3");
qrCodeService.save(qrCode); qrCodeService.save(qrCode);
} }
}
if(ledgerInfo != null ){ if(ledgerInfo != null ){
Ledger ledger = ledgerService.get(ledgerInfo.getLedger().getId()); Ledger ledger = ledgerService.get(ledgerInfo.getLedger().getId());
if(ledger != null){ if(ledger != null){
......
...@@ -119,8 +119,8 @@ public class MaterialLossController extends BaseController { ...@@ -119,8 +119,8 @@ public class MaterialLossController extends BaseController {
return j; return j;
} }
//新增或编辑表单保存 //新增或编辑表单保存
// materialLossService.save(materialLoss);//保存 materialLossService.save(materialLoss);//保存
materialLossService.delivery(materialLoss);//保存 // materialLossService.delivery(materialLoss);//保存
j.setSuccess(true); j.setSuccess(true);
j.setMsg("保存物资盘亏记录成功"); j.setMsg("保存物资盘亏记录成功");
return j; return j;
......
...@@ -6,6 +6,7 @@ package com.jeeplus.modules.warehouse.outbound.mapper; ...@@ -6,6 +6,7 @@ package com.jeeplus.modules.warehouse.outbound.mapper;
import com.jeeplus.core.persistence.BaseMapper; import com.jeeplus.core.persistence.BaseMapper;
import com.jeeplus.core.persistence.annotation.MyBatisMapper; import com.jeeplus.core.persistence.annotation.MyBatisMapper;
import com.jeeplus.modules.warehouse.outbound.entity.OutboundInfo; import com.jeeplus.modules.warehouse.outbound.entity.OutboundInfo;
import org.apache.ibatis.annotations.Param;
/** /**
* 出库单明细表MAPPER接口 * 出库单明细表MAPPER接口
...@@ -15,4 +16,5 @@ import com.jeeplus.modules.warehouse.outbound.entity.OutboundInfo; ...@@ -15,4 +16,5 @@ import com.jeeplus.modules.warehouse.outbound.entity.OutboundInfo;
@MyBatisMapper @MyBatisMapper
public interface OutboundInfoMapper extends BaseMapper<OutboundInfo> { public interface OutboundInfoMapper extends BaseMapper<OutboundInfo> {
void deleteByOutboundId(@Param("outboundInfo") OutboundInfo outboundInfo);
} }
\ No newline at end of file
...@@ -24,6 +24,10 @@ ...@@ -24,6 +24,10 @@
left join t_wh_ledger_info ledgerInfo on a.ledger_info_id = ledgerInfo.id 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 LEFT JOIN t_wh_material_type tpye ON ledgerInfo.type_id = tpye.id
</sql> </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 id="get" resultType="OutboundInfo" >
......
...@@ -61,6 +61,7 @@ public class OutboundService extends CrudService<OutboundMapper, Outbound> { ...@@ -61,6 +61,7 @@ public class OutboundService extends CrudService<OutboundMapper, Outbound> {
return super.findPage(page, outbound); return super.findPage(page, outbound);
} }
//出库并下账
@Transactional(readOnly = false) @Transactional(readOnly = false)
public void save(Outbound outbound) { public void save(Outbound outbound) {
if(outbound.getNumber() == null || Objects.equals(outbound.getNumber(), "")){ if(outbound.getNumber() == null || Objects.equals(outbound.getNumber(), "")){
...@@ -78,7 +79,6 @@ public class OutboundService extends CrudService<OutboundMapper, Outbound> { ...@@ -78,7 +79,6 @@ public class OutboundService extends CrudService<OutboundMapper, Outbound> {
outboundInfoMapper.insert(outboundInfo); outboundInfoMapper.insert(outboundInfo);
}else{ }else{
outboundInfo.setOutbound(outbound); outboundInfo.setOutbound(outbound);
outboundInfo.preUpdate(); outboundInfo.preUpdate();
outboundInfoMapper.update(outboundInfo); outboundInfoMapper.update(outboundInfo);
} }
...@@ -88,6 +88,32 @@ public class OutboundService extends CrudService<OutboundMapper, Outbound> { ...@@ -88,6 +88,32 @@ public class OutboundService extends CrudService<OutboundMapper, Outbound> {
} }
this.delivery(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) @Transactional(readOnly = false)
public void delivery(Outbound outbound) { public void delivery(Outbound outbound) {
List<OutboundInfo> outboundInfoList = outbound.getOutboundInfoList(); List<OutboundInfo> outboundInfoList = outbound.getOutboundInfoList();
...@@ -127,5 +153,9 @@ public class OutboundService extends CrudService<OutboundMapper, Outbound> { ...@@ -127,5 +153,9 @@ public class OutboundService extends CrudService<OutboundMapper, Outbound> {
super.delete(outbound); super.delete(outbound);
outboundInfoMapper.delete(new OutboundInfo(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