opt:优化ERP同步锁,单据推送暂停问题

This commit is contained in:
2025-03-12 13:09:31 +08:00
parent fa85da9eb3
commit de817ef511
10 changed files with 100 additions and 100 deletions

View File

@@ -27,6 +27,7 @@ public class DictConstantPool {
,"qty","申请数量"
,"plan_qty","计划数量"
,"assign_qty","已领数量"
,"actual_qty","实际数量"
,"bar_code","条码"
,"unit_id","单位"
,"pcsn","批次"

View File

@@ -30,7 +30,7 @@ import java.util.stream.Collectors;
public class ErpServiceUtils {
@Resource
ErpSec erpSec;
private final ReentrantLock lock = new ReentrantLock();
/**
@@ -50,10 +50,8 @@ public class ErpServiceUtils {
if (StringUtils.isBlank(query.getFormId())) {
throw new BadRequestException("参数异常");
}
boolean islock = lock.tryLock();
List<Object> result = new ArrayList<>();
try {
if (islock) {
String jsonString = JSON.toJSONString(query);
K3CloudApi cloudApi = getCloudApi();
List<List<Object>> lists = cloudApi.executeBillQuery(jsonString);
@@ -81,18 +79,11 @@ public class ErpServiceUtils {
}
}
}
} else {
throw new BadRequestException("系统正在自动同步ERP单据正占用接口资源请稍后再试1");
}
return JSON.parseArray(JSON.toJSONString(result));
} catch (Exception ex) {
throw new BadRequestException(ex.getMessage());
} finally {
if (lock.isLocked() && lock.isHeldByCurrentThread()) {
lock.unlock();
}
}
return JSON.parseArray(JSON.toJSONString(result));
}
/**
* 查询单据指定结果
@@ -101,10 +92,8 @@ public class ErpServiceUtils {
if (StringUtils.isBlank(query.getFormId())) {
throw new BadRequestException("参数异常");
}
boolean islock = lock.tryLock();
List<JSONObject> result = new ArrayList<>();
try {
if (islock) {
String jsonString = JSON.toJSONString(query);
K3CloudApi cloudApi = getCloudApi();
List<List<Object>> lists = cloudApi.executeBillQuery(jsonString);
@@ -114,15 +103,8 @@ public class ErpServiceUtils {
jsonObject.put("erpCounts",list.get(1));
result.add(jsonObject);
}
} else {
throw new BadRequestException("系统正在自动同步ERP单据正占用接口资源请稍后再试2");
}
} catch (Exception ex) {
throw new BadRequestException(ex.getMessage());
} finally {
if (lock.isLocked() && lock.isHeldByCurrentThread()) {
lock.unlock();
}
}
return result;
}

View File

@@ -115,7 +115,7 @@ public class BmFormStrucController {
@GetMapping("/getParentFormTypes")
public ResponseEntity<Object> getParentFormTypes(){
//参数判读,参数解析,调用参数入库
QueryWrapper<BmFormStruc> queryWrapper = new QueryWrapper<BmFormStruc>().select("form_type", "form_name").isNull("parent_id").groupBy("form_type");
QueryWrapper<BmFormStruc> queryWrapper = new QueryWrapper<BmFormStruc>().select("form_type", "form_name").isNull("parent_id").isNotNull("sort").groupBy("form_type").orderByAsc("sort");;
List<Map<String, Object>> select = iBmFormStrucService.listMaps(queryWrapper);
List<Map> list = new ArrayList<>();
for (Map<String, Object> map : select) {
@@ -128,7 +128,7 @@ public class BmFormStrucController {
//参数判读,参数解析,调用参数入库
QueryWrapper<BmFormStruc> queryWrapper = new QueryWrapper<BmFormStruc>().select("form_type", "form_name").isNull("parent_id").groupBy("form_type").orderByAsc("sort");
if (StringUtils.isNotEmpty(desc)){
queryWrapper.like("form_desc",desc);
queryWrapper.like("form_desc",desc).isNotNull("sort");
}
List<Map<String, Object>> select = iBmFormStrucService.listMaps(queryWrapper);
List<Map> list = new ArrayList<>();

View File

@@ -106,6 +106,11 @@ public class BmFormStruc implements Serializable {
*/
private String plan_qty;
/**
* 实际数量
*/
private String actual_qty;
/**
* 已领取数量
*/

View File

@@ -153,11 +153,14 @@ public class SchBaseTaskServiceImpl extends ServiceImpl<SchBaseTaskMapper, SchBa
handleFinishTask(param, task);
return;
}
MdPbVehicleMater vehicleMater = iMdPbVehicleMaterService.getOne(new QueryWrapper<MdPbVehicleMater>()
List<MdPbVehicleMater> vehicleMaterList = iMdPbVehicleMaterService.list(new QueryWrapper<MdPbVehicleMater>()
.eq("vehicle_code", task.getVehicle_code())
.eq("is_delete", false));
if (vehicleMater != null && !StringUtils.isEmpty(vehicleMater.getProc_inst_id())) {
FlowContinueEvent continueEvent = new FlowContinueEvent(vehicleMater.getProc_inst_id(), null, null);
if (ObjectUtils.isEmpty(vehicleMaterList)) {
throw new BadRequestException("当前任务未找到组盘信息");
}
if (StringUtils.isEmpty(vehicleMaterList.get(0).getProc_inst_id())) {
FlowContinueEvent continueEvent = new FlowContinueEvent(vehicleMaterList.get(0).getProc_inst_id(), null, null);
BussEventMulticaster.Publish(continueEvent);
} else {
handleFinishTask(param, task);

View File

@@ -83,6 +83,11 @@ public class PmFormData implements Serializable {
*/
private BigDecimal assign_qty;
/**
* 实际数量
*/
private BigDecimal actual_qty;
/**
* 单位
*/

View File

@@ -125,6 +125,10 @@ public class PmFormDataDto implements Serializable {
* 已分配数量
*/
private BigDecimal assign_qty;
/**
* 实际数量
*/
private BigDecimal actual_qty;
/**
* 单位

View File

@@ -353,6 +353,8 @@ public class PmFormDataServiceImpl extends ServiceImpl<PmFormDataMapper, PmFormD
for (PmFormDataDto child : children) {
String childProductArea = child.getForm_data().getString("product_area");
child.setProduct_area(childProductArea);
BigDecimal total = child.getPlan_qty().subtract(child.getAssign_qty().add(child.getActual_qty() == null ? BigDecimal.ZERO : child.getActual_qty()));
child.setQty(total.compareTo(BigDecimal.ZERO) > 0 ? total : BigDecimal.ZERO);
}
}
dataDto.setChildren(children);
@@ -415,6 +417,8 @@ public class PmFormDataServiceImpl extends ServiceImpl<PmFormDataMapper, PmFormD
child.setSto_qty(BigDecimal.valueOf(maps.stream().mapToInt(a -> a.getSto_qty().intValue()).sum()));
child.setPcsn("");
}
BigDecimal total = child.getPlan_qty().subtract(child.getAssign_qty().add(child.getActual_qty() == null ? BigDecimal.ZERO : child.getActual_qty()));
child.setQty(total.compareTo(BigDecimal.ZERO) > 0 ? total : BigDecimal.ZERO);
}
pmFormDataDto.setChildren(childs);
return pmFormDataDto;

View File

@@ -180,10 +180,10 @@ public class SyncErpBillsScheduleService {
* 手动同步
*/
private String manualSyncData(String mappingJson, String formType, Boolean dtlSplit, String code, String start, String end) {
boolean islock = lock.tryLock();
Map errorMsg = new HashMap<>();
try {
if (islock) {
//单据同步总数
JSONArray result;
// 获取当前日期
@@ -211,15 +211,8 @@ public class SyncErpBillsScheduleService {
} else {
return "同步成功,共计" + result.size() + "";
}
}else {
throw new BadRequestException("3系统正在自动同步ERP单据正占用接口资源请稍后再试3");
}
} catch (Exception ex) {
throw new BadRequestException(ex.getMessage());
} finally {
if (lock.isLocked() && lock.isHeldByCurrentThread()) {
lock.unlock();
}
}
}
@@ -303,22 +296,19 @@ public class SyncErpBillsScheduleService {
//单据明细
if (StringUtils.isBlank(f.getCode())) {
PmFormData existDtlData = formDataService.getOne(new QueryWrapper<PmFormData>().eq("id", id).select("qty"));
//existDtlData.getQty().compareTo(BigDecimal.ZERO) > 0||f.getPlan_qty().compareTo(f.getAssign_qty()) > 0
if (existDtlData.getQty() != null) {
if (existDtlData.getQty().compareTo(BigDecimal.ZERO) > 0) {
formDataService.update(new LambdaUpdateWrapper<PmFormData>()
.set(PmFormData::getMaterial_id, f.getMaterial_id())
.set(PmFormData::getQty, f.getQty())
.set(PmFormData::getUnit_id, f.getUnit_id())
.set(PmFormData::getForm_data, JSON.toJSONString(f.getForm_data()))
.set(PmFormData::getPlan_qty, f.getPlan_qty())
.set(PmFormData::getTaxPrice, f.getActual_qty())
.set(PmFormData::getBar_code, f.getBar_code())
.set(PmFormData::getUpdate_name, DateUtil.now())
.set(PmFormData::getUpdate_name, SecurityUtils.getCurrentNickName())
.eq(PmFormData::getId, id));
}
}
}
} else {
//单据明细
if (StringUtils.isBlank(f.getCode())) {

View File

@@ -118,8 +118,8 @@
</el-form-item>
<el-form-item label="所属区域" prop="region_code">
<el-select
disabled
v-model="form.region_code"
disabled
placeholder="请选择"
style="width: 370px;"
>
@@ -185,7 +185,7 @@
</el-select>
</el-form-item>
<el-form-item label="是否启用" prop="is_used">
<el-switch v-model="form.is_used" :active-value=true :inactive-value=false />
<el-switch v-model="form.is_used" :active-value="true" :inactive-value="false" />
</el-form-item>
<el-form-item v-show="pointTypesDialogList.length > 0" label="点位类型" prop="device_point_type">
<el-select
@@ -210,7 +210,7 @@
<!-- <el-input v-model="form.priority" clearable style="width: 370px;"/>-->
<!-- </el-form-item>-->
<el-form-item label="表单数据" prop="form_data">
<el-input type="textarea" v-model="form.form_data" clearable style="width: 370px;"/>
<el-input v-model="form.form_data" type="textarea" clearable style="width: 370px;" />
</el-form-item>
<el-form-item label="备注">
<el-input v-model="form.remark" style="width: 370px;" rows="2" type="textarea" />
@@ -254,7 +254,13 @@
<!-- <el-table-column prop="point_location" label="位置" min-width="120" show-overflow-tooltip/>-->
<!-- <el-table-column prop="group_code" label="点位组编码" min-width="120" show-overflow-tooltip/>-->
<!-- <el-table-column prop="form_data" label="表单数据" min-width="120" show-overflow-tooltip/>-->
<el-table-column prop="remark" label="备注" :min-width="flexWidth('remark',crud.data,'备注')" show-overflow-tooltip/>
<el-table-column
prop="remark"
label="备注"
:min-width="flexWidth('remark' +
'',crud.data,'备注')"
show-overflow-tooltip
/>
<el-table-column prop="create_name" label="创建人" />
<el-table-column prop="create_time" label="创建时间" width="150" />
<el-table-column prop="update_name" label="修改人" width="100" />
@@ -415,7 +421,7 @@ export default {
this.crud.notify('操作成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
this.crud.toQuery()
})
},
}
}
}
</script>