opt:优化ERP同步锁,单据推送暂停问题
This commit is contained in:
@@ -27,6 +27,7 @@ public class DictConstantPool {
|
|||||||
,"qty","申请数量"
|
,"qty","申请数量"
|
||||||
,"plan_qty","计划数量"
|
,"plan_qty","计划数量"
|
||||||
,"assign_qty","已领数量"
|
,"assign_qty","已领数量"
|
||||||
|
,"actual_qty","实际数量"
|
||||||
,"bar_code","条码"
|
,"bar_code","条码"
|
||||||
,"unit_id","单位"
|
,"unit_id","单位"
|
||||||
,"pcsn","批次"
|
,"pcsn","批次"
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import java.util.stream.Collectors;
|
|||||||
public class ErpServiceUtils {
|
public class ErpServiceUtils {
|
||||||
@Resource
|
@Resource
|
||||||
ErpSec erpSec;
|
ErpSec erpSec;
|
||||||
private final ReentrantLock lock = new ReentrantLock();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -50,10 +50,8 @@ public class ErpServiceUtils {
|
|||||||
if (StringUtils.isBlank(query.getFormId())) {
|
if (StringUtils.isBlank(query.getFormId())) {
|
||||||
throw new BadRequestException("参数异常");
|
throw new BadRequestException("参数异常");
|
||||||
}
|
}
|
||||||
boolean islock = lock.tryLock();
|
|
||||||
List<Object> result = new ArrayList<>();
|
List<Object> result = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
if (islock) {
|
|
||||||
String jsonString = JSON.toJSONString(query);
|
String jsonString = JSON.toJSONString(query);
|
||||||
K3CloudApi cloudApi = getCloudApi();
|
K3CloudApi cloudApi = getCloudApi();
|
||||||
List<List<Object>> lists = cloudApi.executeBillQuery(jsonString);
|
List<List<Object>> lists = cloudApi.executeBillQuery(jsonString);
|
||||||
@@ -81,18 +79,11 @@ public class ErpServiceUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
return JSON.parseArray(JSON.toJSONString(result));
|
||||||
throw new BadRequestException("系统正在自动同步ERP单据,正占用接口资源,请稍后再试1");
|
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw new BadRequestException(ex.getMessage());
|
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())) {
|
if (StringUtils.isBlank(query.getFormId())) {
|
||||||
throw new BadRequestException("参数异常");
|
throw new BadRequestException("参数异常");
|
||||||
}
|
}
|
||||||
boolean islock = lock.tryLock();
|
|
||||||
List<JSONObject> result = new ArrayList<>();
|
List<JSONObject> result = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
if (islock) {
|
|
||||||
String jsonString = JSON.toJSONString(query);
|
String jsonString = JSON.toJSONString(query);
|
||||||
K3CloudApi cloudApi = getCloudApi();
|
K3CloudApi cloudApi = getCloudApi();
|
||||||
List<List<Object>> lists = cloudApi.executeBillQuery(jsonString);
|
List<List<Object>> lists = cloudApi.executeBillQuery(jsonString);
|
||||||
@@ -114,15 +103,8 @@ public class ErpServiceUtils {
|
|||||||
jsonObject.put("erpCounts",list.get(1));
|
jsonObject.put("erpCounts",list.get(1));
|
||||||
result.add(jsonObject);
|
result.add(jsonObject);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
throw new BadRequestException("系统正在自动同步ERP单据,正占用接口资源,请稍后再试2");
|
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw new BadRequestException(ex.getMessage());
|
throw new BadRequestException(ex.getMessage());
|
||||||
} finally {
|
|
||||||
if (lock.isLocked() && lock.isHeldByCurrentThread()) {
|
|
||||||
lock.unlock();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public class BmFormStrucController {
|
|||||||
@GetMapping("/getParentFormTypes")
|
@GetMapping("/getParentFormTypes")
|
||||||
public ResponseEntity<Object> 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<String, Object>> select = iBmFormStrucService.listMaps(queryWrapper);
|
||||||
List<Map> list = new ArrayList<>();
|
List<Map> list = new ArrayList<>();
|
||||||
for (Map<String, Object> map : select) {
|
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");
|
QueryWrapper<BmFormStruc> queryWrapper = new QueryWrapper<BmFormStruc>().select("form_type", "form_name").isNull("parent_id").groupBy("form_type").orderByAsc("sort");
|
||||||
if (StringUtils.isNotEmpty(desc)){
|
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<String, Object>> select = iBmFormStrucService.listMaps(queryWrapper);
|
||||||
List<Map> list = new ArrayList<>();
|
List<Map> list = new ArrayList<>();
|
||||||
|
|||||||
@@ -106,6 +106,11 @@ public class BmFormStruc implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String plan_qty;
|
private String plan_qty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实际数量
|
||||||
|
*/
|
||||||
|
private String actual_qty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 已领取数量
|
* 已领取数量
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -156,6 +156,11 @@ public class SchBaseTaskServiceImpl extends ServiceImpl<SchBaseTaskMapper, SchBa
|
|||||||
List<MdPbVehicleMater> vehicleMaterList = iMdPbVehicleMaterService.list(new QueryWrapper<MdPbVehicleMater>()
|
List<MdPbVehicleMater> vehicleMaterList = iMdPbVehicleMaterService.list(new QueryWrapper<MdPbVehicleMater>()
|
||||||
.eq("vehicle_code", task.getVehicle_code())
|
.eq("vehicle_code", task.getVehicle_code())
|
||||||
.eq("is_delete", false));
|
.eq("is_delete", false));
|
||||||
|
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);
|
||||||
if (ObjectUtil.isEmpty(vehicleMaterList)) {
|
if (ObjectUtil.isEmpty(vehicleMaterList)) {
|
||||||
throw new BadRequestException("任务完成失败,到载具物料信息: " + task.getVehicle_code());
|
throw new BadRequestException("任务完成失败,到载具物料信息: " + task.getVehicle_code());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,6 +83,11 @@ public class PmFormData implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private BigDecimal assign_qty;
|
private BigDecimal assign_qty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实际数量
|
||||||
|
*/
|
||||||
|
private BigDecimal actual_qty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 单位
|
* 单位
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -125,6 +125,10 @@ public class PmFormDataDto implements Serializable {
|
|||||||
* 已分配数量
|
* 已分配数量
|
||||||
*/
|
*/
|
||||||
private BigDecimal assign_qty;
|
private BigDecimal assign_qty;
|
||||||
|
/**
|
||||||
|
* 实际数量
|
||||||
|
*/
|
||||||
|
private BigDecimal actual_qty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 单位
|
* 单位
|
||||||
|
|||||||
@@ -353,6 +353,8 @@ public class PmFormDataServiceImpl extends ServiceImpl<PmFormDataMapper, PmFormD
|
|||||||
for (PmFormDataDto child : children) {
|
for (PmFormDataDto child : children) {
|
||||||
String childProductArea = child.getForm_data().getString("product_area");
|
String childProductArea = child.getForm_data().getString("product_area");
|
||||||
child.setProduct_area(childProductArea);
|
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);
|
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.setSto_qty(BigDecimal.valueOf(maps.stream().mapToInt(a -> a.getSto_qty().intValue()).sum()));
|
||||||
child.setPcsn("");
|
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);
|
pmFormDataDto.setChildren(childs);
|
||||||
return pmFormDataDto;
|
return pmFormDataDto;
|
||||||
|
|||||||
@@ -180,10 +180,10 @@ public class SyncErpBillsScheduleService {
|
|||||||
* 手动同步
|
* 手动同步
|
||||||
*/
|
*/
|
||||||
private String manualSyncData(String mappingJson, String formType, Boolean dtlSplit, String code, String start, String end) {
|
private String manualSyncData(String mappingJson, String formType, Boolean dtlSplit, String code, String start, String end) {
|
||||||
boolean islock = lock.tryLock();
|
|
||||||
Map errorMsg = new HashMap<>();
|
Map errorMsg = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
if (islock) {
|
|
||||||
//单据同步总数
|
//单据同步总数
|
||||||
JSONArray result;
|
JSONArray result;
|
||||||
// 获取当前日期
|
// 获取当前日期
|
||||||
@@ -211,15 +211,8 @@ public class SyncErpBillsScheduleService {
|
|||||||
} else {
|
} else {
|
||||||
return "同步成功,共计" + result.size() + "条";
|
return "同步成功,共计" + result.size() + "条";
|
||||||
}
|
}
|
||||||
}else {
|
|
||||||
throw new BadRequestException("3系统正在自动同步ERP单据,正占用接口资源,请稍后再试3");
|
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw new BadRequestException(ex.getMessage());
|
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())) {
|
if (StringUtils.isBlank(f.getCode())) {
|
||||||
PmFormData existDtlData = formDataService.getOne(new QueryWrapper<PmFormData>().eq("id", id).select("qty"));
|
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() != null) {
|
||||||
if (existDtlData.getQty().compareTo(BigDecimal.ZERO) > 0) {
|
|
||||||
formDataService.update(new LambdaUpdateWrapper<PmFormData>()
|
formDataService.update(new LambdaUpdateWrapper<PmFormData>()
|
||||||
.set(PmFormData::getMaterial_id, f.getMaterial_id())
|
.set(PmFormData::getMaterial_id, f.getMaterial_id())
|
||||||
.set(PmFormData::getQty, f.getQty())
|
|
||||||
.set(PmFormData::getUnit_id, f.getUnit_id())
|
.set(PmFormData::getUnit_id, f.getUnit_id())
|
||||||
.set(PmFormData::getForm_data, JSON.toJSONString(f.getForm_data()))
|
.set(PmFormData::getForm_data, JSON.toJSONString(f.getForm_data()))
|
||||||
.set(PmFormData::getPlan_qty, f.getPlan_qty())
|
.set(PmFormData::getPlan_qty, f.getPlan_qty())
|
||||||
|
.set(PmFormData::getTaxPrice, f.getActual_qty())
|
||||||
.set(PmFormData::getBar_code, f.getBar_code())
|
.set(PmFormData::getBar_code, f.getBar_code())
|
||||||
.set(PmFormData::getUpdate_name, DateUtil.now())
|
.set(PmFormData::getUpdate_name, DateUtil.now())
|
||||||
.set(PmFormData::getUpdate_name, SecurityUtils.getCurrentNickName())
|
.set(PmFormData::getUpdate_name, SecurityUtils.getCurrentNickName())
|
||||||
.eq(PmFormData::getId, id));
|
.eq(PmFormData::getId, id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
//单据明细
|
//单据明细
|
||||||
if (StringUtils.isBlank(f.getCode())) {
|
if (StringUtils.isBlank(f.getCode())) {
|
||||||
|
|||||||
@@ -118,8 +118,8 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="所属区域" prop="region_code">
|
<el-form-item label="所属区域" prop="region_code">
|
||||||
<el-select
|
<el-select
|
||||||
disabled
|
|
||||||
v-model="form.region_code"
|
v-model="form.region_code"
|
||||||
|
disabled
|
||||||
placeholder="请选择"
|
placeholder="请选择"
|
||||||
style="width: 370px;"
|
style="width: 370px;"
|
||||||
>
|
>
|
||||||
@@ -185,7 +185,7 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="是否启用" prop="is_used">
|
<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>
|
||||||
<el-form-item v-show="pointTypesDialogList.length > 0" label="点位类型" prop="device_point_type">
|
<el-form-item v-show="pointTypesDialogList.length > 0" label="点位类型" prop="device_point_type">
|
||||||
<el-select
|
<el-select
|
||||||
@@ -210,7 +210,7 @@
|
|||||||
<!-- <el-input v-model="form.priority" clearable style="width: 370px;"/>-->
|
<!-- <el-input v-model="form.priority" clearable style="width: 370px;"/>-->
|
||||||
<!-- </el-form-item>-->
|
<!-- </el-form-item>-->
|
||||||
<el-form-item label="表单数据" prop="form_data">
|
<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>
|
||||||
<el-form-item label="备注">
|
<el-form-item label="备注">
|
||||||
<el-input v-model="form.remark" style="width: 370px;" rows="2" type="textarea" />
|
<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="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="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="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_name" label="创建人" />
|
||||||
<el-table-column prop="create_time" label="创建时间" width="150" />
|
<el-table-column prop="create_time" label="创建时间" width="150" />
|
||||||
<el-table-column prop="update_name" label="修改人" width="100" />
|
<el-table-column prop="update_name" label="修改人" width="100" />
|
||||||
@@ -415,7 +421,7 @@ export default {
|
|||||||
this.crud.notify('操作成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
this.crud.notify('操作成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||||
this.crud.toQuery()
|
this.crud.toQuery()
|
||||||
})
|
})
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user