新增磅单管理功能,支持免密接口和数据同步,更新相关控制器、实体和服务,优化权限管理,确保系统的灵活性和可扩展性。

This commit is contained in:
geht
2026-05-06 15:30:31 +08:00
parent b03cbeff9b
commit 71b8d94da8
48 changed files with 4205 additions and 3 deletions

View File

@@ -16,9 +16,11 @@ import org.jeecg.modules.xslmes.constant.MesXslCustomerBizStatus;
import org.jeecg.modules.xslmes.entity.MesXslCustomer;
import org.jeecg.modules.xslmes.entity.MesXslSupplier;
import org.jeecg.modules.xslmes.entity.MesXslVehicle;
import org.jeecg.modules.xslmes.entity.MesXslWeightRecord;
import org.jeecg.modules.xslmes.service.IMesXslCustomerService;
import org.jeecg.modules.xslmes.service.IMesXslSupplierService;
import org.jeecg.modules.xslmes.service.IMesXslVehicleService;
import org.jeecg.modules.xslmes.service.IMesXslWeightRecordService;
import org.jeecg.modules.xslmes.service.MesXslStompNotifyService;
import org.springframework.web.bind.annotation.*;
@@ -42,6 +44,7 @@ public class MesXslDesktopAnonController {
private final IMesXslVehicleService vehicleService;
private final IMesXslCustomerService customerService;
private final IMesXslSupplierService supplierService;
private final IMesXslWeightRecordService weightRecordService;
private final MesXslStompNotifyService stompNotify;
// ═══════════════════════════ 车辆管理 ═══════════════════════════
@@ -342,8 +345,97 @@ public class MesXslDesktopAnonController {
return ok ? Result.OK("操作成功") : Result.error("操作失败");
}
// ═══════════════════════════ 磅单管理 ═══════════════════════════
@Operation(summary = "磅单-免密分页列表查询")
@GetMapping("/xslmes/mesXslWeightRecord/anon/list")
public Result<IPage<MesXslWeightRecord>> weightRecordAnonList(
MesXslWeightRecord mesXslWeightRecord,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<MesXslWeightRecord> qw = QueryGenerator.initQueryWrapper(mesXslWeightRecord, req.getParameterMap());
qw.orderByDesc("create_time");
IPage<MesXslWeightRecord> page = weightRecordService.page(new Page<>(pageNo, pageSize), qw);
return Result.OK(page);
}
@Operation(summary = "磅单-免密通过id查询")
@GetMapping("/xslmes/mesXslWeightRecord/anon/queryById")
public Result<MesXslWeightRecord> weightRecordAnonQueryById(@RequestParam(name = "id") String id) {
MesXslWeightRecord entity = weightRecordService.getById(id);
return entity != null ? Result.OK(entity) : Result.error("未找到对应数据");
}
@Operation(summary = "磅单-免密添加")
@PostMapping("/xslmes/mesXslWeightRecord/anon/add")
public Result<String> weightRecordAnonAdd(@RequestBody MesXslWeightRecord mesXslWeightRecord) {
if (oConvertUtils.isEmpty(mesXslWeightRecord.getPlateNumber())) {
return Result.error("车牌号不能为空");
}
// 净重自动计算
if (mesXslWeightRecord.getGrossWeight() != null && mesXslWeightRecord.getTareWeight() != null) {
mesXslWeightRecord.setNetWeight(
mesXslWeightRecord.getGrossWeight().subtract(mesXslWeightRecord.getTareWeight()));
}
applyWeightBillType(mesXslWeightRecord);
weightRecordService.save(mesXslWeightRecord);
stompNotify.publishWeightRecordChanged("add", mesXslWeightRecord.getId());
return Result.OK("添加成功!");
}
@Operation(summary = "磅单-免密编辑")
@RequestMapping(value = "/xslmes/mesXslWeightRecord/anon/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> weightRecordAnonEdit(@RequestBody MesXslWeightRecord mesXslWeightRecord) {
if (oConvertUtils.isEmpty(mesXslWeightRecord.getId())) {
return Result.error("主键不能为空");
}
// 净重自动计算
if (mesXslWeightRecord.getGrossWeight() != null && mesXslWeightRecord.getTareWeight() != null) {
mesXslWeightRecord.setNetWeight(
mesXslWeightRecord.getGrossWeight().subtract(mesXslWeightRecord.getTareWeight()));
}
applyWeightBillType(mesXslWeightRecord);
boolean ok = weightRecordService.updateById(mesXslWeightRecord);
if (!ok) {
return Result.error("数据已被他人修改,请刷新后重试");
}
stompNotify.publishWeightRecordChanged("edit", mesXslWeightRecord.getId());
return Result.OK("编辑成功!");
}
@Operation(summary = "磅单-免密删除")
@DeleteMapping("/xslmes/mesXslWeightRecord/anon/delete")
public Result<String> weightRecordAnonDelete(@RequestParam(name = "id") String id) {
weightRecordService.removeById(id);
stompNotify.publishWeightRecordChanged("delete", id);
return Result.OK("删除成功!");
}
@Operation(summary = "磅单-免密批量删除")
@DeleteMapping("/xslmes/mesXslWeightRecord/anon/deleteBatch")
public Result<String> weightRecordAnonDeleteBatch(@RequestParam(name = "ids") String ids) {
weightRecordService.removeByIds(Arrays.asList(ids.split(",")));
stompNotify.publishWeightRecordChanged("batchDelete", ids);
return Result.OK("批量删除成功!");
}
// ─────────────────────────── 车辆私有辅助 ────────────────────────────
private void applyWeightBillType(MesXslWeightRecord record) {
if (record.getGrossWeight() != null && record.getTareWeight() != null) {
record.setBillType("2");
return;
}
if (record.getGrossWeight() != null) {
record.setBillType("1");
return;
}
if (record.getTareWeight() != null) {
record.setBillType("3");
}
}
private void applyVehicleBelong(MesXslVehicle v) {
if (oConvertUtils.isEmpty(v.getVehicleBelong())) {
return;

View File

@@ -15,6 +15,7 @@ import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.xslmes.entity.MesXslWeightRecord;
import org.jeecg.modules.xslmes.service.IMesXslWeightRecordService;
import org.jeecg.modules.xslmes.service.MesXslStompNotifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
@@ -36,6 +37,8 @@ public class MesXslWeightRecordController extends JeecgController<MesXslWeightRe
@Autowired
private IMesXslWeightRecordService mesXslWeightRecordService;
@Autowired
private MesXslStompNotifyService stompNotifyService;
@Operation(summary = "地磅数据记录-分页列表查询")
@GetMapping(value = "/list")
@@ -61,8 +64,10 @@ public class MesXslWeightRecordController extends JeecgController<MesXslWeightRe
String seq = String.format("%03d", new Random().nextInt(1000));
mesXslWeightRecord.setBillNo("BDH-" + dateStr + seq);
}
computeBillType(mesXslWeightRecord);
computeNetWeight(mesXslWeightRecord);
mesXslWeightRecordService.save(mesXslWeightRecord);
stompNotifyService.publishWeightRecordChanged("add", mesXslWeightRecord.getId());
return Result.OK("添加成功!");
}
@@ -71,8 +76,10 @@ public class MesXslWeightRecordController extends JeecgController<MesXslWeightRe
@RequiresPermissions("xslmes:mes_xsl_weight_record:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> edit(@RequestBody MesXslWeightRecord mesXslWeightRecord) {
computeBillType(mesXslWeightRecord);
computeNetWeight(mesXslWeightRecord);
mesXslWeightRecordService.updateById(mesXslWeightRecord);
stompNotifyService.publishWeightRecordChanged("edit", mesXslWeightRecord.getId());
return Result.OK("编辑成功!");
}
@@ -82,6 +89,7 @@ public class MesXslWeightRecordController extends JeecgController<MesXslWeightRe
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
mesXslWeightRecordService.removeById(id);
stompNotifyService.publishWeightRecordChanged("delete", id);
return Result.OK("删除成功!");
}
@@ -91,6 +99,7 @@ public class MesXslWeightRecordController extends JeecgController<MesXslWeightRe
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
this.mesXslWeightRecordService.removeByIds(Arrays.asList(ids.split(",")));
stompNotifyService.publishWeightRecordChanged("deleteBatch", null);
return Result.OK("批量删除成功!");
}
@@ -124,4 +133,18 @@ public class MesXslWeightRecordController extends JeecgController<MesXslWeightRe
record.setNetWeight(net.compareTo(BigDecimal.ZERO) >= 0 ? net : BigDecimal.ZERO);
}
}
private void computeBillType(MesXslWeightRecord record) {
if (record.getGrossWeight() != null && record.getTareWeight() != null) {
record.setBillType("2");
return;
}
if (record.getGrossWeight() != null) {
record.setBillType("1");
return;
}
if (record.getTareWeight() != null) {
record.setBillType("3");
}
}
}

View File

@@ -81,6 +81,11 @@ public class MesXslWeightRecord extends JeecgEntity implements Serializable {
@Schema(description = "手机号")
private String driverPhone;
@Excel(name = "单据类型", width = 12, dicCode = "xslmes_weight_bill_type")
@Dict(dicCode = "xslmes_weight_bill_type")
@Schema(description = "单据类型1已称毛重 2称重完成")
private String billType;
@Schema(description = "租户ID")
private Integer tenantId;
}

View File

@@ -35,6 +35,11 @@ public class MesXslStompNotifyService {
publish("/topic/sync/mes-suppliers", "MES_SUPPLIER_CHANGED", "supplierId", supplierId, action);
}
/** 广播磅单数据变更事件到 /topic/sync/mes-weight-records */
public void publishWeightRecordChanged(String action, String weightRecordId) {
publish("/topic/sync/mes-weight-records", "MES_WEIGHT_RECORD_CHANGED", "weightRecordId", weightRecordId, action);
}
// ─────────────────────────── 私有辅助 ────────────────────────────
private void publish(String topic, String cmd, String idKey, String idValue, String action) {