add:成品出库手动分配

This commit is contained in:
2023-05-29 15:46:27 +08:00
parent 3f05a84731
commit 3144e5f746
9 changed files with 117 additions and 10 deletions

View File

@@ -109,5 +109,13 @@ public class IStivtlostorivnCpOutController {
return new ResponseEntity<>(iStIvtIostorinvCpOutService.getStructIvt(whereJson),HttpStatus.OK);
}
@PostMapping("/manualDiv")
@Log("手工分配保存")
@ApiOperation("手工分配保存")
public ResponseEntity<Object> manualDiv(@RequestBody JSONObject whereJson){
iStIvtIostorinvCpOutService.manualDiv(whereJson);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@@ -131,4 +131,14 @@ public interface IStIvtIostorinvCpOutService extends IService<StIvtIostorinvCp>
* }
*/
List getStructIvt(JSONObject whereJson);
/**
* 手工分配保存
* @param whereJson
* {
* rows库存
* iostorinvdtl_id明细id
* }
*/
void manualDiv(JSONObject whereJson);
}

View File

@@ -59,6 +59,7 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import java.util.stream.Collectors;
/**
* <p>
@@ -478,11 +479,59 @@ public class StIvtIostorinvCpOutServiceImpl extends ServiceImpl<StIvtIostorinvCp
JSONObject param = new JSONObject();
param.put("materia_id", whereJson.getString("materia_id"));
param.put("stor_id", whereJson.getString("stor_id"));
if (ObjectUtil.isNotEmpty(whereJson.getString("sale_id"))) param.put("sale_id", whereJson.getString("sale_id"));
if (ObjectUtil.isNotEmpty(whereJson.getString("source_billdtl_id"))) param.put("sale_id", whereJson.getString("source_billdtl_id"));
if (ObjectUtil.isNotEmpty(whereJson.getString("search"))) param.put("remark", whereJson.getString("search"));
if (ObjectUtil.isNotEmpty(whereJson.getString("sect_id"))) param.put("sect_id", whereJson.getString("sect_id"));
return iStIvtStructivtCpService.getStructIvt(param);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void manualDiv(JSONObject whereJson) {
JSONArray rows = whereJson.getJSONArray("rows");
// 1.组织要更新库存的集合
ArrayList<StIvtStructivtCp> ivtDaoList = new ArrayList<>();
for (int i = 0; i < rows.size(); i++) {
JSONObject jsonObject = rows.getJSONObject(i);
StIvtStructivtCp ivtDao = iStIvtStructivtCpService.getById(jsonObject.getString("stockrecord_id"));
ivtDao.setCanuse_qty(jsonObject.getBigDecimal("plan_qty"));
ivtDaoList.add(ivtDao);
}
// 2.插入分配表
StIvtIostorinvdtlCp dtlDao = iostorinvdtlCpService.getById(whereJson.getString("iostorinvdtl_id"));
iostorinvdisCpService.onductDataOutDis(ivtDaoList,dtlDao);
// 3.更新明细状态
BigDecimal assign_qty = ivtDaoList.stream()
.map(StIvtStructivtCp::getCanuse_qty)
.reduce(BigDecimal.ZERO, BigDecimal::add); // 已分配数量
BigDecimal unassign_qty = NumberUtil.sub(dtlDao.getUnassign_qty(), assign_qty); // 未分配重量
if (unassign_qty.doubleValue() != 0) {
dtlDao.setBill_status(IOSEnum.BILL_STATUS.code("分配中"));
} else {
dtlDao.setBill_status(IOSEnum.BILL_STATUS.code("分配完"));
}
dtlDao.setUnassign_qty(unassign_qty);
dtlDao.setAssign_qty(assign_qty);
iostorinvdtlCpService.updateById(dtlDao);
// 4.更新库存冻结数 、 锁定仓位
StIvtIostorinvCp mstDao = this.getById(dtlDao.getIostorinv_id());
updateIvtDiv(ivtDaoList,mstDao);
// 5.更新主表
updateMst(mstDao.getIostorinv_id());
}
@NotNull
private StIvtIostorinvCp packageMstForm(StIvtIostorinvCp stIvtIostorinvCp,JSONObject whereJson,Boolean isUpdate) {
JSONArray rows = whereJson.getJSONArray("tableData");

View File

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import org.nl.wms.storage_manage.productmanage.service.structIvt.dao.StIvtStructivtCp;
import java.util.List;
import java.util.Map;
/**
* <p>
@@ -46,5 +47,5 @@ public interface IStIvtStructivtCpService extends IService<StIvtStructivtCp> {
* 明细row
* }
*/
List getStructIvt(JSONObject whereJson);
List<Map> getStructIvt(JSONObject whereJson);
}

View File

@@ -28,10 +28,18 @@
<select id="getStructIvt" resultType="java.util.Map">
SELECT
ivt.*
ivt.*,
attr.sect_name,
attr.struct_code,
attr.storagevehicle_code,
mater.material_code,
mater.material_name,
unit.unit_name AS qty_unit_name
FROM
ST_IVT_StructIvt_CP ivt
LEFT JOIN st_ivt_structattr attr ON ivt.struct_id = attr.struct_id
LEFT JOIN md_me_materialbase mater ON ivt.material_id = mater.material_id
LEFT JOIN md_pb_measureunit unit ON unit.measure_unit_id = mater.base_unit_id
WHERE attr.lock_type = '0'
<if test="stor_id != null and stor_id != ''">
and attr.stor_id = #{stor_id}
@@ -45,6 +53,11 @@
<if test="sale_id != null and sale_id != ''">
and ivt.sale_id = #{sale_id}
</if>
<if test="remark != null and remark != ''">
and attr.struct_code LIKE #{remark} OR
(attr.struct_name LIKE #{remark}) OR
(attr.storagevehicle_code LIKE #{remark})
</if>
order by ivt.canuse_qty ASC,ivt.struct_code ASC
</select>

View File

@@ -23,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* <p>
@@ -87,7 +88,7 @@ public class StIvtStructivtCpServiceImpl extends ServiceImpl<StIvtStructivtCpMap
}
@Override
public List getStructIvt(JSONObject whereJson) {
public List<Map> getStructIvt(JSONObject whereJson) {
return baseMapper.getStructIvt(whereJson);
}