From 52adc4d46bf83cf8c968a8cd870fb021519e145f Mon Sep 17 00:00:00 2001 From: cuilei <ray_tsu1@163.com> Date: 星期五, 15 八月 2025 16:11:30 +0800 Subject: [PATCH] 报工、齐套性检查部分接口 --- src/main/java/org/jeecg/modules/mes/service/impl/MesWorkReportingServiceImpl.java | 106 +++++++++++ db/双林新火炬MES数据库设计.pdma.json | 62 ++++++ src/main/java/org/jeecg/modules/mes/service/impl/MesProductionWorkOrderServiceImpl.java | 90 +++++++++ src/main/java/org/jeecg/modules/mes/utils/CommonUtils.java | 15 + src/main/java/org/jeecg/modules/mes/service/IMesKittingCompletenessCheckService.java | 2 src/main/java/org/jeecg/modules/mes/enums/ProductionOrderStatus.java | 13 + src/main/java/org/jeecg/modules/lsw/service/ILswMaterialInventoryService.java | 3 src/main/java/org/jeecg/modules/lsw/vo/LswMaterialInventoryVo.java | 21 ++ src/main/java/org/jeecg/modules/mes/dto/MesProductionWorkOrderRepublishRequest.java | 4 src/main/java/org/jeecg/modules/lsw/mapper/xml/LswMaterialInventoryMapper.xml | 18 ++ src/main/java/org/jeecg/modules/mes/controller/MesWorkReportingController.java | 6 src/main/java/org/jeecg/modules/mes/entity/MesProductionWorkOrder.java | 20 ++ src/main/java/org/jeecg/modules/mes/service/IMesWorkReportingService.java | 2 src/main/java/org/jeecg/modules/mes/controller/MesProductionWorkOrderController.java | 37 ++- src/main/java/org/jeecg/modules/lsw/entity/LswMaterialInventory.java | 3 src/main/java/org/jeecg/modules/lsw/service/impl/LswMaterialInventoryServiceImpl.java | 7 src/main/java/org/jeecg/modules/mes/service/impl/MesKittingCompletenessCheckServiceImpl.java | 25 ++ src/main/java/org/jeecg/modules/lsw/enums/MaterialCategory.java | 34 +++ src/main/java/org/jeecg/modules/mes/controller/MesKittingCompletenessCheckController.java | 11 + src/main/java/org/jeecg/modules/mes/service/IMesProductionWorkOrderService.java | 3 src/main/java/org/jeecg/modules/lsw/mapper/LswMaterialInventoryMapper.java | 4 src/main/java/org/jeecg/modules/mes/controller/MesProductionOrderController.java | 29 +++ src/main/java/org/jeecg/modules/mes/entity/MesKittingCompletenessCheck.java | 8 23 files changed, 495 insertions(+), 28 deletions(-) diff --git "a/db/\345\217\214\346\236\227\346\226\260\347\201\253\347\202\254MES\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241.pdma.json" "b/db/\345\217\214\346\236\227\346\226\260\347\201\253\347\202\254MES\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241.pdma.json" index 848a138..b9447c3 100644 --- "a/db/\345\217\214\346\236\227\346\226\260\347\201\253\347\202\254MES\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241.pdma.json" +++ "b/db/\345\217\214\346\236\227\346\226\260\347\201\253\347\202\254MES\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241.pdma.json" @@ -2,9 +2,9 @@ "name": "鍙屾灄鏂扮伀鐐琈ES鏁版嵁搴撹璁�", "describe": "鎻忚堪鍙岃柂鏂扮伀鐐琈ES鏁版嵁搴撹璁¤鎯�", "avatar": "", - "version": "4.9.2", + "version": "4.9.4", "createdTime": "2025-3-10 16:38:19", - "updatedTime": "2025-8-14 13:31:57", + "updatedTime": "2025-8-15 14:58:22", "dbConns": [], "profile": { "default": { @@ -632,7 +632,7 @@ "#DDE5FF" ], "DDLToggleCase": "L", - "menuWidth": "364px" + "menuWidth": "309px" }, "entities": [ { @@ -11467,7 +11467,7 @@ { "defKey": "work_order_status", "defName": "宸ュ崟鐘舵��", - "comment": "鏂板缓銆佸凡鍙戝竷銆侀噸鍙戝竷", + "comment": "鏂板缓銆佸凡鍙戝竷銆佹墽琛屼腑銆佸凡鍏抽棴", "type": "", "len": "", "scale": "", @@ -11483,6 +11483,60 @@ "id": "2150E931-22A6-452C-BD42-54A37E0A5968" }, { + "defKey": "completeness_check_flag", + "defName": "鏄惁閫氳繃榻愬鎬ф鏌�", + "comment": "0鍚�1鏄�", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64", + "extProps": {}, + "domain": "6F7C1C5C-D159-41E6-BF9D-54DEEFA79AFF", + "id": "D9F104A5-0DF1-40FB-8F0D-850E0E0C7EC6" + }, + { + "defKey": "equipment_inspection_flag", + "defName": "鏄惁閫氳繃璁惧鐐规", + "comment": "0鍚�1鏄�", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64", + "extProps": {}, + "domain": "6F7C1C5C-D159-41E6-BF9D-54DEEFA79AFF", + "id": "CAF6B87F-AC08-41D7-867B-31B6906A35FC" + }, + { + "defKey": "process_inspection_flag", + "defName": "鏄惁閫氳繃宸ヨ壓鐐规", + "comment": "0鍚�1鏄�", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64", + "extProps": {}, + "domain": "6F7C1C5C-D159-41E6-BF9D-54DEEFA79AFF", + "id": "17F725F0-ADC2-4265-9136-125AE1FDA8CA" + }, + { "defKey": "actual_quantity", "defName": "瀹為檯鎶ュ伐鏁伴噺", "comment": "", diff --git a/src/main/java/org/jeecg/modules/lsw/entity/LswMaterialInventory.java b/src/main/java/org/jeecg/modules/lsw/entity/LswMaterialInventory.java index 59d0235..2c8c6b7 100644 --- a/src/main/java/org/jeecg/modules/lsw/entity/LswMaterialInventory.java +++ b/src/main/java/org/jeecg/modules/lsw/entity/LswMaterialInventory.java @@ -14,6 +14,7 @@ import javax.persistence.Table; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Date; /** @@ -62,7 +63,7 @@ /**鏁伴噺*/ @Excel(name = "鏁伴噺", width = 15) @ApiModelProperty(value = "鏁伴噺") - private Double quantity; + private BigDecimal quantity; /**搴撳瓨鍦癐D*/ @Excel(name = "搴撳瓨鍦癐D", width = 15) @Dict(dictTable = "base_line_side_warehouse", dicCode = "id", dicText = "warehouse_name") diff --git a/src/main/java/org/jeecg/modules/lsw/enums/MaterialCategory.java b/src/main/java/org/jeecg/modules/lsw/enums/MaterialCategory.java new file mode 100644 index 0000000..9e1a112 --- /dev/null +++ b/src/main/java/org/jeecg/modules/lsw/enums/MaterialCategory.java @@ -0,0 +1,34 @@ +package org.jeecg.modules.lsw.enums; + + +public enum MaterialCategory { + /** + * 鎴愬搧 + */ + FINISHED, + /** + * 鍗婃垚鍝� + */ + HALF, + /** + * 姣涘澂 + */ + RAW, + /** + * 閰嶄欢 + */ + PARTS; + + /** + * @param name 鏋氫妇鐨勫悕绉� + * @return 瀵瑰簲鐨� MaterialCategory 鏋氫妇绫诲瀷锛屽鏋滄湭鎵惧埌鍒欒繑鍥� null + */ + public static MaterialCategory fromName(String name) { + for (MaterialCategory category : MaterialCategory.values()) { + if (category.name().equals(name)) { + return category; + } + } + return null; + } +} diff --git a/src/main/java/org/jeecg/modules/lsw/mapper/LswMaterialInventoryMapper.java b/src/main/java/org/jeecg/modules/lsw/mapper/LswMaterialInventoryMapper.java index c715596..b755fe5 100644 --- a/src/main/java/org/jeecg/modules/lsw/mapper/LswMaterialInventoryMapper.java +++ b/src/main/java/org/jeecg/modules/lsw/mapper/LswMaterialInventoryMapper.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Param; import org.jeecg.modules.lsw.entity.LswMaterialInventory; +import org.jeecg.modules.lsw.vo.LswMaterialInventoryVo; import java.util.List; @@ -29,4 +30,7 @@ * @return List<LswMaterialInventory> */ public List<LswMaterialInventory> selectByMainId(@Param("mainId") String mainId); + + List<LswMaterialInventoryVo> selectLineSideMaterialInventoryByMaterialNumber(@Param("materialNumberList") List<String> bomMaterialNumberList, + @Param("factoryId") String factoryId); } diff --git a/src/main/java/org/jeecg/modules/lsw/mapper/xml/LswMaterialInventoryMapper.xml b/src/main/java/org/jeecg/modules/lsw/mapper/xml/LswMaterialInventoryMapper.xml index 6620c48..ef93fbc 100644 --- a/src/main/java/org/jeecg/modules/lsw/mapper/xml/LswMaterialInventoryMapper.xml +++ b/src/main/java/org/jeecg/modules/lsw/mapper/xml/LswMaterialInventoryMapper.xml @@ -13,4 +13,22 @@ FROM lsw_material_inventory WHERE material_id = #{mainId} </select> + <select id="selectLineSideMaterialInventoryByMaterialNumber" + resultType="org.jeecg.modules.lsw.vo.LswMaterialInventoryVo"> + SELECT + t1.material_number materialNumber, + t1.material_name materialName, + SUM(t2.quantity) AS stockQuantity + FROM lsw_material t1 + INNER JOIN lsw_material_inventory t2 ON t1.id = t2.material_id + WHERE t1.material_number IN + <foreach collection="materialNumberList" item="item" separator="," open="(" close=")"> + #{item} + </foreach> + AND t2.warehouse_id = #{factoryId} + AND t1.del_flag = 0 + GROUP BY + t1.material_number, + t1.material_name + </select> </mapper> diff --git a/src/main/java/org/jeecg/modules/lsw/service/ILswMaterialInventoryService.java b/src/main/java/org/jeecg/modules/lsw/service/ILswMaterialInventoryService.java index 3b49085..b7601f8 100644 --- a/src/main/java/org/jeecg/modules/lsw/service/ILswMaterialInventoryService.java +++ b/src/main/java/org/jeecg/modules/lsw/service/ILswMaterialInventoryService.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import org.jeecg.modules.lsw.entity.LswMaterialInventory; +import org.jeecg.modules.lsw.vo.LswMaterialInventoryVo; import java.util.List; @@ -20,4 +21,6 @@ * @return List<LswMaterialInventory> */ public List<LswMaterialInventory> selectByMainId(String mainId); + /** 閫氳繃鐗╂枡缂栫爜鍜岀嚎杈瑰簱id鏌ヨ鐗╂枡搴撳瓨 */ + List<LswMaterialInventoryVo> selectLineSideMaterialInventoryByMaterialNumber(List<String> bomMaterialNumberList, String factoryId); } diff --git a/src/main/java/org/jeecg/modules/lsw/service/impl/LswMaterialInventoryServiceImpl.java b/src/main/java/org/jeecg/modules/lsw/service/impl/LswMaterialInventoryServiceImpl.java index dc8f786..fc0a4da 100644 --- a/src/main/java/org/jeecg/modules/lsw/service/impl/LswMaterialInventoryServiceImpl.java +++ b/src/main/java/org/jeecg/modules/lsw/service/impl/LswMaterialInventoryServiceImpl.java @@ -4,9 +4,11 @@ import org.jeecg.modules.lsw.entity.LswMaterialInventory; import org.jeecg.modules.lsw.mapper.LswMaterialInventoryMapper; import org.jeecg.modules.lsw.service.ILswMaterialInventoryService; +import org.jeecg.modules.lsw.vo.LswMaterialInventoryVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Collections; import java.util.List; /** @@ -25,4 +27,9 @@ public List<LswMaterialInventory> selectByMainId(String mainId) { return lswMaterialInventoryMapper.selectByMainId(mainId); } + + @Override + public List<LswMaterialInventoryVo> selectLineSideMaterialInventoryByMaterialNumber(List<String> bomMaterialNumberList, String factoryId) { + return lswMaterialInventoryMapper.selectLineSideMaterialInventoryByMaterialNumber(bomMaterialNumberList, factoryId); + } } diff --git a/src/main/java/org/jeecg/modules/lsw/vo/LswMaterialInventoryVo.java b/src/main/java/org/jeecg/modules/lsw/vo/LswMaterialInventoryVo.java new file mode 100644 index 0000000..6bf66f8 --- /dev/null +++ b/src/main/java/org/jeecg/modules/lsw/vo/LswMaterialInventoryVo.java @@ -0,0 +1,21 @@ +package org.jeecg.modules.lsw.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +public class LswMaterialInventoryVo implements Serializable { + private static final long serialVersionUID = 1L; + + /**鐗╂枡缂栫爜*/ + @ApiModelProperty(value = "鐗╂枡缂栫爜") + private String materialNumber; + /**鐗╂枡鍚嶇О*/ + @ApiModelProperty(value = "鐗╂枡鍚嶇О") + private String materialName; + /**鏁伴噺*/ + @ApiModelProperty(value = "搴撳瓨鏁伴噺") + private BigDecimal stockQuantity; +} diff --git a/src/main/java/org/jeecg/modules/mes/controller/MesKittingCompletenessCheckController.java b/src/main/java/org/jeecg/modules/mes/controller/MesKittingCompletenessCheckController.java index 3ae72b7..930c5f4 100644 --- a/src/main/java/org/jeecg/modules/mes/controller/MesKittingCompletenessCheckController.java +++ b/src/main/java/org/jeecg/modules/mes/controller/MesKittingCompletenessCheckController.java @@ -6,6 +6,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; +import org.apache.shiro.authz.annotation.RequiresPermissions; import org.jeecg.common.api.vo.Result; import org.jeecg.common.aspect.annotation.AutoLog; import org.jeecg.common.system.base.controller.JeecgController; @@ -19,6 +20,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.Arrays; +import java.util.List; /** * @Description: 榻愬鎬ф鏌ヨ褰� @@ -71,6 +73,15 @@ return Result.OK("娣诲姞鎴愬姛锛�"); } + @AutoLog(value = "榻愬鎬ф鏌ヨ褰�-鎵归噺娣诲姞") + @ApiOperation(value="榻愬鎬ф鏌ヨ褰�-鎵归噺娣诲姞", notes="榻愬鎬ф鏌ヨ褰�-鎵归噺娣诲姞") + //@RequiresPermissions("org.jeecg.modules:mes_kitting_completeness_check:addBatch") + @PostMapping(value = "/addBatch") + public Result<String> addBatch(@RequestBody List<MesKittingCompletenessCheck> mesKittingCompletenessCheckList) { + mesKittingCompletenessCheckService.batchSave(mesKittingCompletenessCheckList); + return Result.OK("鎵归噺娣诲姞鎴愬姛锛�"); + } + /** * 缂栬緫 * diff --git a/src/main/java/org/jeecg/modules/mes/controller/MesProductionOrderController.java b/src/main/java/org/jeecg/modules/mes/controller/MesProductionOrderController.java index 7003c7f..87e8b9d 100644 --- a/src/main/java/org/jeecg/modules/mes/controller/MesProductionOrderController.java +++ b/src/main/java/org/jeecg/modules/mes/controller/MesProductionOrderController.java @@ -1,21 +1,29 @@ package org.jeecg.modules.mes.controller; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; import org.jeecg.common.api.vo.Result; import org.jeecg.common.aspect.annotation.AutoLog; +import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.modules.mes.entity.MesProductionOrder; +import org.jeecg.modules.mes.enums.ProductionOrderStatus; import org.jeecg.modules.mes.service.IMesProductionOrderService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; /** * @Description: SAP鐢熶骇璁㈠崟 @@ -81,4 +89,25 @@ } return Result.OK(mesProductionOrder); } + + @ApiOperation(value = "SAP鐢熶骇璁㈠崟-鏌ヨ鍙姤宸ョ殑鐢熶骇璁㈠崟", notes = "SAP鐢熶骇璁㈠崟-鏌ヨ鍙姤宸ョ殑鐢熶骇璁㈠崟") + @GetMapping(value = "/selectReportWorkOrderList") + public Result<?> selectReportWorkOrderList(MesProductionOrder mesProductionOrder) { + if (StringUtils.isBlank(mesProductionOrder.getMaterialNumber())) { + return Result.error("璇蜂紶鍏ュ繀瑕佺殑鏌ヨ鍙傛暟锛�"); + } + List<MesProductionOrder> orderList = mesProductionOrderService.list(new LambdaQueryWrapper<MesProductionOrder>() + .eq(MesProductionOrder::getMaterialNumber, mesProductionOrder.getMaterialNumber()) + .eq(MesProductionOrder::getOrderStatus, ProductionOrderStatus.REL.name()) + .eq(MesProductionOrder::getDelFlag, CommonConstant.DEL_FLAG_0) + .orderByAsc(MesProductionOrder::getPlanStart)); + List<Map<String, Object>> res = orderList.stream().map(order -> { + Map<String, Object> map = new HashMap<>(); + map.put("title", order.getOrderCode()); + map.put("label", order.getOrderCode()); + map.put("value", order.getId()); + return map; + }).collect(Collectors.toList()); + return Result.OK(res); + } } diff --git a/src/main/java/org/jeecg/modules/mes/controller/MesProductionWorkOrderController.java b/src/main/java/org/jeecg/modules/mes/controller/MesProductionWorkOrderController.java index b0321ff..c021299 100644 --- a/src/main/java/org/jeecg/modules/mes/controller/MesProductionWorkOrderController.java +++ b/src/main/java/org/jeecg/modules/mes/controller/MesProductionWorkOrderController.java @@ -9,18 +9,19 @@ import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; -import org.apache.shiro.SecurityUtils; +import org.apache.shiro.authz.annotation.RequiresPermissions; import org.jeecg.common.api.vo.Result; import org.jeecg.common.aspect.annotation.AutoLog; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.common.system.query.QueryGenerator; -import org.jeecg.common.system.vo.LoginUser; import org.jeecg.modules.mes.dto.MesProductionWorkOrderRepublishRequest; import org.jeecg.modules.mes.dto.MesProductionWorkScheduleRequest; +import org.jeecg.modules.mes.entity.MesKittingCompletenessCheck; import org.jeecg.modules.mes.entity.MesProductionWorkOrder; import org.jeecg.modules.mes.enums.ProductionWorkOrderStatus; import org.jeecg.modules.mes.service.IMesProductionWorkOrderService; +import org.jeecg.modules.mes.utils.CommonUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; @@ -136,7 +137,7 @@ @AutoLog(value = "鎺掍骇宸ュ崟-鍙戝竷鎺掍骇璁″垝") @ApiOperation(value = "鎺掍骇宸ュ崟-鍙戝竷鎺掍骇璁″垝", notes = "鎺掍骇宸ュ崟-鍙戝竷鎺掍骇璁″垝") - //@RequiresPermissions("mes:production:work:order:publish") + //@RequiresPermissions("org.jeecg.modules:mes_production_work_order:publish") @RequestMapping(value = "/publish", method = {RequestMethod.POST, RequestMethod.PUT}) public Result<String> publish(@RequestParam("ids") String ids) { List<String> idList = Arrays.asList(ids.split(",")); @@ -153,7 +154,7 @@ MesProductionWorkOrder publish = new MesProductionWorkOrder() .setId(id) .setPublishTime(new Date()) - .setPublisher(Objects.requireNonNull(getCurrentUser()).getUsername()) + .setPublisher(Objects.requireNonNull(CommonUtils.getCurrentUser()).getUsername()) .setWorkOrderStatus(ProductionWorkOrderStatus.PUBLISHED.name()); publishList.add(publish); }); @@ -163,7 +164,7 @@ @AutoLog(value = "鎺掍骇宸ュ崟-閲嶅彂甯冩帓浜ц鍒�") @ApiOperation(value="鎺掍骇宸ュ崟-閲嶅彂甯冩帓浜ц鍒�", notes="閲嶅彂甯冩帓浜ц鍒�") - //@RequiresPermissions("mes:production:work:order:republish") + //@RequiresPermissions("org.jeecg.modules:mes_production_work_order:republish") @PostMapping(value = "/republish") public Result<String> republish(@RequestBody MesProductionWorkOrderRepublishRequest request) { MesProductionWorkOrder workOrder = mesProductionWorkOrderService.getById(request.getId()); @@ -174,15 +175,32 @@ MesProductionWorkOrder republish = new MesProductionWorkOrder() .setId(request.getId()) .setPlanQuantity(request.getPlanQuantity()) - .setRepublisher(Objects.requireNonNull(getCurrentUser()).getUsername()) + .setRepublisher(Objects.requireNonNull(Objects.requireNonNull(CommonUtils.getCurrentUser()).getUsername())) .setRepublishTime(new Date()) .setRepublishReason(request.getRepublishReason()); mesProductionWorkOrderService.updateById(republish); return Result.ok("閲嶅彂甯冩垚鍔燂紒"); } + @AutoLog(value = "鎺掍骇宸ュ崟-榻愬鎬ф鏌�") + @ApiOperation(value="鎺掍骇宸ュ崟-榻愬鎬ф鏌�", notes="榻愬鎬ф鏌�") + //@RequiresPermissions("org.jeecg.modules:mes_production_work_order:workOrderCompletenessCheck") + @GetMapping(value = "/workOrderCompletenessCheck") + public Result<List<MesKittingCompletenessCheck>> workOrderCompletenessCheck(@RequestParam("id") String id) { + MesProductionWorkOrder workOrder = mesProductionWorkOrderService.getById(id); + if (workOrder == null) { + return Result.error("宸ュ崟涓嶅瓨鍦紒"); + } + if (!ProductionWorkOrderStatus.PUBLISHED.name().equals(workOrder.getWorkOrderStatus())) { + return Result.error("褰撳墠宸ュ崟鐘舵�佷笉鑳借繘琛岄綈濂楁�ф鏌ワ紒"); + } + List<MesKittingCompletenessCheck> list = mesProductionWorkOrderService.workOrderCompletenessCheck(workOrder); + return Result.ok(list); + } + @AutoLog(value = "鎺掍骇宸ュ崟-鎵ц鎺掍骇宸ュ崟璁″垝") @ApiOperation(value = "鎺掍骇宸ュ崟-鎵ц鎺掍骇宸ュ崟璁″垝", notes = "鎺掍骇宸ュ崟-鎵ц鎺掍骇宸ュ崟璁″垝") + //@RequiresPermissions("org.jeecg.modules:mes_production_work_order:execute") @GetMapping(value = "/execute") public Result<?> execute(@RequestParam("id") String id) { MesProductionWorkOrder workOrder = mesProductionWorkOrderService.getById(id); @@ -284,11 +302,4 @@ return super.importExcel(request, response, MesProductionWorkOrder.class); } - private LoginUser getCurrentUser() { - try { - return (LoginUser) SecurityUtils.getSubject().getPrincipal(); - } catch (Exception e) { - return null; - } - } } diff --git a/src/main/java/org/jeecg/modules/mes/controller/MesWorkReportingController.java b/src/main/java/org/jeecg/modules/mes/controller/MesWorkReportingController.java index a3634d0..cc373c6 100644 --- a/src/main/java/org/jeecg/modules/mes/controller/MesWorkReportingController.java +++ b/src/main/java/org/jeecg/modules/mes/controller/MesWorkReportingController.java @@ -63,12 +63,12 @@ * @param mesWorkReporting * @return */ - @AutoLog(value = "宸ュ崟鎶ュ伐-娣诲姞") - @ApiOperation(value="宸ュ崟鎶ュ伐-娣诲姞", notes="宸ュ崟鎶ュ伐-娣诲姞") + @AutoLog(value = "宸ュ崟鎶ュ伐-鏂板鎶ュ伐") + @ApiOperation(value="宸ュ崟鎶ュ伐-鏂板鎶ュ伐", notes="宸ュ崟鎶ュ伐-鏂板鎶ュ伐") //@RequiresPermissions("org.jeecg.modules:mes_work_reporting:add") @PostMapping(value = "/add") public Result<String> add(@RequestBody MesWorkReporting mesWorkReporting) { - mesWorkReportingService.save(mesWorkReporting); + mesWorkReportingService.addReporting(mesWorkReporting); return Result.OK("娣诲姞鎴愬姛锛�"); } diff --git a/src/main/java/org/jeecg/modules/mes/dto/MesProductionWorkOrderRepublishRequest.java b/src/main/java/org/jeecg/modules/mes/dto/MesProductionWorkOrderRepublishRequest.java index 2c02022..7cec998 100644 --- a/src/main/java/org/jeecg/modules/mes/dto/MesProductionWorkOrderRepublishRequest.java +++ b/src/main/java/org/jeecg/modules/mes/dto/MesProductionWorkOrderRepublishRequest.java @@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.math.BigDecimal; + @Data public class MesProductionWorkOrderRepublishRequest { @@ -13,7 +15,7 @@ /**璁″垝鐢熶骇鏁伴噺*/ @ApiModelProperty(value = "璁″垝鐢熶骇鏁伴噺") - private Double planQuantity; + private BigDecimal planQuantity; /**閲嶅彂甯冨師鍥�*/ @ApiModelProperty(value = "閲嶅彂甯冨師鍥�") diff --git a/src/main/java/org/jeecg/modules/mes/entity/MesKittingCompletenessCheck.java b/src/main/java/org/jeecg/modules/mes/entity/MesKittingCompletenessCheck.java index 1e9224f..0152089 100644 --- a/src/main/java/org/jeecg/modules/mes/entity/MesKittingCompletenessCheck.java +++ b/src/main/java/org/jeecg/modules/mes/entity/MesKittingCompletenessCheck.java @@ -15,6 +15,7 @@ import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Date; /** @@ -59,11 +60,11 @@ /**闇�姹傛暟閲�*/ @Excel(name = "闇�姹傛暟閲�", width = 15) @ApiModelProperty(value = "闇�姹傛暟閲�") - private Double requiredQuantity; + private BigDecimal requiredQuantity; /**瀹為檯鏁伴噺*/ @Excel(name = "瀹為檯鏁伴噺", width = 15) @ApiModelProperty(value = "瀹為檯鏁伴噺") - private Double actualQuantity; + private BigDecimal actualQuantity; /**鏄惁榻愬*/ @Excel(name = "鏄惁榻愬", width = 15) @ApiModelProperty(value = "鏄惁榻愬") @@ -71,4 +72,7 @@ @TableField(exist = false) @ApiModelProperty(value = "宸ュ崟鍙�") private String workOrderCode; + @TableField(exist = false) + @ApiModelProperty(value = "鍩烘湰鍗曚綅") + private String productionUnit; } diff --git a/src/main/java/org/jeecg/modules/mes/entity/MesProductionWorkOrder.java b/src/main/java/org/jeecg/modules/mes/entity/MesProductionWorkOrder.java index db5c5ca..252384d 100644 --- a/src/main/java/org/jeecg/modules/mes/entity/MesProductionWorkOrder.java +++ b/src/main/java/org/jeecg/modules/mes/entity/MesProductionWorkOrder.java @@ -13,6 +13,7 @@ import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Date; /** @@ -69,7 +70,7 @@ /**璁″垝鐢熶骇鏁伴噺*/ @Excel(name = "璁″垝鐢熶骇鏁伴噺", width = 15) @ApiModelProperty(value = "璁″垝鐢熶骇鏁伴噺") - private Double planQuantity; + private BigDecimal planQuantity; /**浜х嚎ID(鍐椾綑)*/ @Excel(name = "浜х嚎ID(鍐椾綑)", width = 15) @Dict(dictTable = "base_factory", dicCode = "id", dicText = "factory_name") @@ -96,10 +97,25 @@ @Dict(dicCode = "work_order_status") @ApiModelProperty(value = "宸ュ崟鐘舵��") private String workOrderStatus; + /**鏄惁閫氳繃榻愬鎬ф鏌�*/ + @Excel(name = "鏄惁閫氳繃榻愬鎬ф鏌�", width = 15, dicCode = "yn") + @Dict(dicCode = "yn") + @ApiModelProperty(value = "鏄惁閫氳繃榻愬鎬ф鏌�") + private String completenessCheckFlag = CommonConstant.DEFAULT_0; + /**鏄惁閫氳繃璁惧鐐规*/ + @Excel(name = "鏄惁閫氳繃璁惧鐐规", width = 15, dicCode = "yn") + @Dict(dicCode = "yn") + @ApiModelProperty(value = "鏄惁閫氳繃璁惧鐐规") + private String equipmentInspectionFlag = CommonConstant.DEFAULT_0; + /**鏄惁閫氳繃宸ヨ壓鐐规*/ + @Excel(name = "鏄惁閫氳繃宸ヨ壓鐐规", width = 15, dicCode = "yn") + @Dict(dicCode = "yn") + @ApiModelProperty(value = "鏄惁閫氳繃宸ヨ壓鐐规") + private String processInspectionFlag = CommonConstant.DEFAULT_0; /**瀹為檯鎶ュ伐鏁伴噺*/ @Excel(name = "瀹為檯鎶ュ伐鏁伴噺", width = 15) @ApiModelProperty(value = "瀹為檯鎶ュ伐鏁伴噺") - private Double actualQuantity; + private BigDecimal actualQuantity; /**鍙戝竷浜�*/ @Excel(name = "鍙戝竷浜�", width = 15) @ApiModelProperty(value = "鍙戝竷浜�") diff --git a/src/main/java/org/jeecg/modules/mes/enums/ProductionOrderStatus.java b/src/main/java/org/jeecg/modules/mes/enums/ProductionOrderStatus.java new file mode 100644 index 0000000..7ab12d4 --- /dev/null +++ b/src/main/java/org/jeecg/modules/mes/enums/ProductionOrderStatus.java @@ -0,0 +1,13 @@ +package org.jeecg.modules.mes.enums; + + +public enum ProductionOrderStatus { + /** + * 涓嬭揪 + */ + REL, + /** + * 鍏抽棴 + */ + TECO +} diff --git a/src/main/java/org/jeecg/modules/mes/service/IMesKittingCompletenessCheckService.java b/src/main/java/org/jeecg/modules/mes/service/IMesKittingCompletenessCheckService.java index 3df31ef..fd6a672 100644 --- a/src/main/java/org/jeecg/modules/mes/service/IMesKittingCompletenessCheckService.java +++ b/src/main/java/org/jeecg/modules/mes/service/IMesKittingCompletenessCheckService.java @@ -13,4 +13,6 @@ */ public interface IMesKittingCompletenessCheckService extends IService<MesKittingCompletenessCheck> { List<MesKittingCompletenessCheck> queryCompletenessCheckByWorkOrderId(String workOrderId); + + void batchSave(List<MesKittingCompletenessCheck> mesKittingCompletenessCheckList); } diff --git a/src/main/java/org/jeecg/modules/mes/service/IMesProductionWorkOrderService.java b/src/main/java/org/jeecg/modules/mes/service/IMesProductionWorkOrderService.java index 9ba50b0..d643686 100644 --- a/src/main/java/org/jeecg/modules/mes/service/IMesProductionWorkOrderService.java +++ b/src/main/java/org/jeecg/modules/mes/service/IMesProductionWorkOrderService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import org.jeecg.modules.mes.dto.MesProductionWorkScheduleRequest; +import org.jeecg.modules.mes.entity.MesKittingCompletenessCheck; import org.jeecg.modules.mes.entity.MesProductionWorkOrder; import java.util.List; @@ -20,4 +21,6 @@ List<MesProductionWorkOrder> schedule(MesProductionWorkScheduleRequest request); IPage<MesProductionWorkOrder> queryPageList(Page<MesProductionWorkOrder> page, Map<String, String[]> parameterMap); + + List<MesKittingCompletenessCheck> workOrderCompletenessCheck(MesProductionWorkOrder workOrder); } diff --git a/src/main/java/org/jeecg/modules/mes/service/IMesWorkReportingService.java b/src/main/java/org/jeecg/modules/mes/service/IMesWorkReportingService.java index adc9c0d..08505bf 100644 --- a/src/main/java/org/jeecg/modules/mes/service/IMesWorkReportingService.java +++ b/src/main/java/org/jeecg/modules/mes/service/IMesWorkReportingService.java @@ -14,4 +14,6 @@ public interface IMesWorkReportingService extends IService<MesWorkReporting> { List<MesWorkReporting> queryWorkReportingByWorkOrderId(String workOrderId); List<MesWorkReporting> queryWorkReportingByOrderId(String orderId); + + void addReporting(MesWorkReporting mesWorkReporting); } diff --git a/src/main/java/org/jeecg/modules/mes/service/impl/MesKittingCompletenessCheckServiceImpl.java b/src/main/java/org/jeecg/modules/mes/service/impl/MesKittingCompletenessCheckServiceImpl.java index 0fa7e96..1835695 100644 --- a/src/main/java/org/jeecg/modules/mes/service/impl/MesKittingCompletenessCheckServiceImpl.java +++ b/src/main/java/org/jeecg/modules/mes/service/impl/MesKittingCompletenessCheckServiceImpl.java @@ -1,11 +1,15 @@ package org.jeecg.modules.mes.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.common.constant.CommonConstant; import org.jeecg.modules.mes.entity.MesKittingCompletenessCheck; +import org.jeecg.modules.mes.entity.MesProductionWorkOrder; import org.jeecg.modules.mes.mapper.MesKittingCompletenessCheckMapper; import org.jeecg.modules.mes.service.IMesKittingCompletenessCheckService; +import org.jeecg.modules.mes.service.IMesProductionWorkOrderService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; - +import org.springframework.transaction.annotation.Transactional; import java.util.List; /** @@ -17,8 +21,27 @@ @Service public class MesKittingCompletenessCheckServiceImpl extends ServiceImpl<MesKittingCompletenessCheckMapper, MesKittingCompletenessCheck> implements IMesKittingCompletenessCheckService { + @Autowired + private IMesProductionWorkOrderService mesProductionWorkOrderService; + @Override public List<MesKittingCompletenessCheck> queryCompletenessCheckByWorkOrderId(String workOrderId) { return baseMapper.queryCompletenessCheckByWorkOrderId(workOrderId); } + + @Override + @Transactional(rollbackFor = Exception.class) + public void batchSave(List<MesKittingCompletenessCheck> mesKittingCompletenessCheckList) { + boolean allMatch = mesKittingCompletenessCheckList.stream() + .allMatch(item -> CommonConstant.DEFAULT_1.equals(item.getCheckFlag())); + //鐗╂枡閮介綈澶囷紝鏇存柊鎺掍骇宸ュ崟榻愬妫�鏌ョ姸鎬� + if (allMatch) { + MesProductionWorkOrder order = new MesProductionWorkOrder() + .setId(mesKittingCompletenessCheckList.get(0).getWorkOrderId()) + .setCompletenessCheckFlag(CommonConstant.DEFAULT_1); + mesProductionWorkOrderService.updateById(order); + } + //淇濆瓨榻愬妫�鏌ヨ褰� + saveBatch(mesKittingCompletenessCheckList); + } } diff --git a/src/main/java/org/jeecg/modules/mes/service/impl/MesProductionWorkOrderServiceImpl.java b/src/main/java/org/jeecg/modules/mes/service/impl/MesProductionWorkOrderServiceImpl.java index 407a954..2b407ff 100644 --- a/src/main/java/org/jeecg/modules/mes/service/impl/MesProductionWorkOrderServiceImpl.java +++ b/src/main/java/org/jeecg/modules/mes/service/impl/MesProductionWorkOrderServiceImpl.java @@ -8,20 +8,35 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.jeecg.common.constant.CommonConstant; +import org.jeecg.common.exception.JeecgBootException; import org.jeecg.modules.base.entity.Factory; +import org.jeecg.modules.base.entity.LineSideWarehouse; import org.jeecg.modules.base.entity.Shift; import org.jeecg.modules.base.entity.ShiftGroup; import org.jeecg.modules.base.service.IFactoryService; +import org.jeecg.modules.base.service.ILineSideWarehouseService; import org.jeecg.modules.base.service.IShiftGroupService; import org.jeecg.modules.base.service.IShiftService; +import org.jeecg.modules.lsw.entity.LswMaterialInventory; +import org.jeecg.modules.lsw.service.ILswMaterialInventoryService; +import org.jeecg.modules.lsw.vo.LswMaterialInventoryVo; import org.jeecg.modules.mes.dto.MesProductionWorkScheduleRequest; +import org.jeecg.modules.mes.entity.MesKittingCompletenessCheck; +import org.jeecg.modules.mes.entity.MesProductionOrder; +import org.jeecg.modules.mes.enums.ProductionOrderStatus; +import org.jeecg.modules.mes.service.IMesProductionOrderService; import org.jeecg.modules.mes.service.IMesProductionWorkOrderService; import org.jeecg.modules.mes.entity.MesProductionWorkOrder; import org.jeecg.modules.mes.mapper.MesProductionWorkOrderMapper; -import org.jeecg.modules.system.service.ISysDictService; +import org.jeecg.modules.pms.entity.PmsProcessBillMaterials; +import org.jeecg.modules.pms.entity.PmsProcessBillMaterialsDetail; +import org.jeecg.modules.pms.service.IPmsProcessBillMaterialsDetailService; +import org.jeecg.modules.pms.service.IPmsProcessBillMaterialsService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.time.LocalDate; import java.time.ZoneId; import java.time.temporal.ChronoUnit; @@ -43,6 +58,16 @@ private IShiftGroupService shiftGroupService; @Autowired private IFactoryService factoryService; + @Autowired + private IMesProductionOrderService mesProductionOrderService; + @Autowired + private IPmsProcessBillMaterialsService pmsProcessBillMaterialsService; + @Autowired + private IPmsProcessBillMaterialsDetailService pmsProcessBillMaterialsDetailService; + @Autowired + private ILswMaterialInventoryService lswMaterialInventoryService; + @Autowired + private ILineSideWarehouseService lineSideWarehouseService; @Override public List<MesProductionWorkOrder> schedule(MesProductionWorkScheduleRequest request) { @@ -127,4 +152,67 @@ queryWrapper.orderByAsc("t1.work_order_date"); return this.baseMapper.queryPageList(page, queryWrapper); } + + @Override + public List<MesKittingCompletenessCheck> workOrderCompletenessCheck(MesProductionWorkOrder workOrder) { + //鏍规嵁褰撳墠鎺掍骇宸ュ崟纭畾鐢熶骇璁㈠崟 + List<MesProductionOrder> orderList = mesProductionOrderService.list(new LambdaQueryWrapper<MesProductionOrder>() + .eq(MesProductionOrder::getMaterialNumber, workOrder.getMaterialNumber()) + .eq(MesProductionOrder::getOrderStatus, ProductionOrderStatus.REL.name()) + .eq(MesProductionOrder::getDelFlag, CommonConstant.DEL_FLAG_0) + .orderByAsc(MesProductionOrder::getPlanStart)); + if (orderList.isEmpty()) { + throw new JeecgBootException("鏈壘鍒拌鐗╂枡鐨勫叧鑱旂敓浜ц鍗曪紒"); + } + //榛樿鍙栨椂闂存渶鏃╂湭瀹屾垚鐨勮鍗曪紝涔熷氨鏄涓�椤� + MesProductionOrder order = orderList.get(0); + //鏍规嵁鐢熶骇璁㈠崟id鍜岀墿鏂欑紪鐮佹煡璇㈣鍗旴OM + PmsProcessBillMaterials processBillMaterials = pmsProcessBillMaterialsService.list(new LambdaQueryWrapper<PmsProcessBillMaterials>() + .eq(PmsProcessBillMaterials::getOrderId, order.getId()) + .eq(PmsProcessBillMaterials::getMaterialNumber, workOrder.getMaterialNumber())) + .stream().findFirst().orElse(null); + if (processBillMaterials == null) { + throw new JeecgBootException("鏈壘鍒颁笌璇ョ墿鏂欏叧鑱旂殑璁㈠崟BOM锛�"); + } + //鏌ヨ宸ュ崟鎵�灞炰骇绾垮搴旂殑绾胯竟浠� + LineSideWarehouse lineSideWarehouse = lineSideWarehouseService.list(new LambdaQueryWrapper<LineSideWarehouse>() + .eq(LineSideWarehouse::getFactoryId, workOrder.getFactoryId()) + .eq(LineSideWarehouse::getDelFlag, CommonConstant.DEL_FLAG_0) + .eq(LineSideWarehouse::getWarehouseStatus, CommonConstant.DEFAULT_1)) + .stream().findFirst().orElse(null); + if (lineSideWarehouse == null) { + throw new JeecgBootException("璇ヤ骇绾挎湭閰嶇疆绾胯竟浠擄紒"); + } + //璁㈠崟BOM鏄庣粏 + List<PmsProcessBillMaterialsDetail> processBillMaterialsDetails = pmsProcessBillMaterialsDetailService.queryByMaterialId(processBillMaterials.getId()); + //鏌ヨ璁㈠崟BOM鏄庣粏涓殑鐗╂枡鍦ㄨ浜х嚎绾胯竟浠撲腑鐨勫簱瀛� + List<String> bomMaterialNumberList = processBillMaterialsDetails.stream() + .map(PmsProcessBillMaterialsDetail::getMaterialNumber).collect(Collectors.toList()); + Map<String, LswMaterialInventoryVo> lswMaterialInventoryMap = lswMaterialInventoryService + .selectLineSideMaterialInventoryByMaterialNumber(bomMaterialNumberList, lineSideWarehouse.getId()).stream() + .collect(Collectors.toMap(LswMaterialInventoryVo::getMaterialNumber, v1 -> v1, (v1, v2) -> v1)); + List<MesKittingCompletenessCheck> completenessCheckResultList = CollectionUtil.newArrayList(); + //鏍规嵁璁㈠崟BOM鏄庣粏鍒楀嚭榻愬妫�鏌ョ粨鏋� + for (PmsProcessBillMaterialsDetail processBillMaterialsDetail : processBillMaterialsDetails) { + LswMaterialInventoryVo materialInventoryVo = lswMaterialInventoryMap.get(processBillMaterialsDetail.getMaterialNumber()); + MesKittingCompletenessCheck completenessCheckItem = new MesKittingCompletenessCheck() + .setMaterialNumber(processBillMaterialsDetail.getMaterialNumber()) + .setMaterialName(processBillMaterialsDetail.getMaterialName()) + //闇�姹傛暟閲� = (bom鏄庣粏鐨勯渶姹傛暟閲� / bom璁㈠崟鐨勬暟閲�) * 鎺掍骇宸ュ崟璁″垝鐢熶骇鏁伴噺 + .setRequiredQuantity(processBillMaterialsDetail.getUsageQuantity() + .divide(processBillMaterials.getProductionQuantity(), 2, RoundingMode.HALF_UP) + .multiply(workOrder.getPlanQuantity())) + .setActualQuantity(materialInventoryVo == null ? BigDecimal.ZERO : materialInventoryVo.getStockQuantity()) + .setProductionUnit(processBillMaterialsDetail.getProductionUnit()); + completenessCheckResultList.add(completenessCheckItem); + } + completenessCheckResultList.forEach(item -> { + if (item.getRequiredQuantity().compareTo(item.getActualQuantity()) > 0) { + item.setCheckFlag(CommonConstant.DEFAULT_0); + } else { + item.setCheckFlag(CommonConstant.DEFAULT_1); + } + }); + return completenessCheckResultList; + } } diff --git a/src/main/java/org/jeecg/modules/mes/service/impl/MesWorkReportingServiceImpl.java b/src/main/java/org/jeecg/modules/mes/service/impl/MesWorkReportingServiceImpl.java index 9021437..3dde504 100644 --- a/src/main/java/org/jeecg/modules/mes/service/impl/MesWorkReportingServiceImpl.java +++ b/src/main/java/org/jeecg/modules/mes/service/impl/MesWorkReportingServiceImpl.java @@ -1,12 +1,35 @@ package org.jeecg.modules.mes.service.impl; +import cn.hutool.core.date.DateUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.common.constant.CommonConstant; +import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.modules.base.entity.Factory; +import org.jeecg.modules.base.entity.LineSideWarehouse; +import org.jeecg.modules.base.entity.Shift; +import org.jeecg.modules.base.service.IFactoryService; +import org.jeecg.modules.base.service.ILineSideWarehouseService; +import org.jeecg.modules.base.service.IShiftService; +import org.jeecg.modules.lsw.entity.LswMaterial; +import org.jeecg.modules.lsw.entity.LswMaterialInbound; +import org.jeecg.modules.lsw.enums.MaterialCategory; +import org.jeecg.modules.lsw.service.ILswMaterialInboundService; +import org.jeecg.modules.lsw.service.ILswMaterialService; +import org.jeecg.modules.mes.entity.MesProductionWorkOrder; import org.jeecg.modules.mes.entity.MesWorkReporting; import org.jeecg.modules.mes.mapper.MesWorkReportingMapper; +import org.jeecg.modules.mes.service.IMesProductionWorkOrderService; import org.jeecg.modules.mes.service.IMesWorkReportingService; +import org.jeecg.modules.mes.utils.CommonUtils; +import org.jeecg.modules.system.service.ISysBusinessCodeRuleService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Date; import java.util.List; +import java.util.Objects; +import java.util.Optional; /** * @Description: 宸ュ崟鎶ュ伐 @@ -17,6 +40,21 @@ @Service public class MesWorkReportingServiceImpl extends ServiceImpl<MesWorkReportingMapper, MesWorkReporting> implements IMesWorkReportingService { + @Autowired + private IMesProductionWorkOrderService mesProductionWorkOrderService; + @Autowired + private ILswMaterialService lswMaterialService; + @Autowired + private IFactoryService factoryService; + @Autowired + private IShiftService shiftService; + @Autowired + private ILineSideWarehouseService lineSideWarehouseService; + @Autowired + private ILswMaterialInboundService lswMaterialInboundService; + @Autowired + private ISysBusinessCodeRuleService sysBusinessCodeRuleService; + @Override public List<MesWorkReporting> queryWorkReportingByWorkOrderId(String workOrderId) { return baseMapper.queryWorkReportingByWorkOrderId(workOrderId); @@ -26,4 +64,72 @@ public List<MesWorkReporting> queryWorkReportingByOrderId(String orderId) { return baseMapper.queryWorkReportingByOrderId(orderId); } + + @Override + public void addReporting(MesWorkReporting mesWorkReporting) { + MesProductionWorkOrder workOrder = mesProductionWorkOrderService.getById(mesWorkReporting.getWorkOrderId()); + if (workOrder == null) { + throw new JeecgBootException("宸ュ崟涓嶅瓨鍦紒"); + } + LswMaterial material = lswMaterialService.list(new LambdaQueryWrapper<LswMaterial>() + .eq(LswMaterial::getMaterialNumber, workOrder.getMaterialNumber()) + .eq(LswMaterial::getDelFlag, CommonConstant.DEL_FLAG_0)).stream() + .findAny().orElse(null); + if (material == null) { + throw new JeecgBootException("鐗╂枡涓嶅瓨鍦紒"); + } + MaterialCategory materialCategory = MaterialCategory.fromName(material.getMaterialCategory()); + if (materialCategory == null) { + throw new JeecgBootException("鏈煡鐨勭墿鏂欑被鍨嬶紒"); + } + //鐢熶骇鎵规鍙� + String batchNumber = sysBusinessCodeRuleService.generateBusinessCodeSeq("WorkReportingBatchNumber"); + mesWorkReporting.setBatchNumber(batchNumber); + LineSideWarehouse lineSideWarehouse = lineSideWarehouseService.list(new LambdaQueryWrapper<LineSideWarehouse>() + .eq(LineSideWarehouse::getFactoryId, mesWorkReporting.getFactoryId()) + .eq(LineSideWarehouse::getDelFlag, CommonConstant.DEL_FLAG_0)) + .stream().findAny().orElse(null); + if (lineSideWarehouse == null) { + throw new JeecgBootException("绾胯竟浠撳簱涓嶅瓨鍦紒"); + } + mesWorkReporting.setWarehouseId(lineSideWarehouse.getId()); + mesWorkReporting.setReporter(Objects.requireNonNull(CommonUtils.getCurrentUser()).getUsername()); + mesWorkReporting.setReportTime(new Date()); + String date = DateUtil.format(new Date(), "yyMMdd"); + switch (materialCategory) { + case FINISHED: + //鎴愬搧鎶ュ伐閫昏緫 + String palletNumber4 = sysBusinessCodeRuleService.generateBusinessCodeSeq("WorkReportingPalletNumber4"); + String finishedPalletNumber = material.getMaterialNumber() + date + palletNumber4; + mesWorkReporting.setPalletNumber(finishedPalletNumber); + //todo 鎵e噺鍐呮硶鍏帮紙瀵瑰簲鏈哄姞鍐呮硶鍏扮嚎杈瑰簱锛夈�佸娉曞叞锛堝搴旀満鍔犲娉曞叞绾胯竟搴擄級銆佸皬鍐呭湀锛堝搴旇閰嶇嚎杈瑰簱锛夊簱瀛橈紝璋冪敤SAP鎶曟枡鎺ュ彛 + //todo 璋冪敤SAP宸ュ簭鎶ュ伐 + //todo 鎵撳嵃鎴愬搧鎵樻爣绛俱�佹楠屾爣璇嗗崱銆佺Щ搴撳崟銆佸畬宸ユ楠屽伐鍗曪紱鍒ゆ柇鐢熶骇璁㈠崟鏄惁闇�瑕佸叧闂紙鍚堟牸鏁伴噺 = 璁㈠崟鏁伴噺锛� + break; + case HALF: + case RAW: + //鍗婃垚鍝佹姤宸ラ�昏緫 + Factory factory = factoryService.getById(mesWorkReporting.getFactoryId()); + Shift shift = shiftService.getById(workOrder.getShiftId()); + String palletNumber6 = sysBusinessCodeRuleService.generateBusinessCodeSeq("WorkReportingPalletNumber6"); + //鎷兼帴鍗婃垚鍝佹姤宸ユ墭鍙� + String halfPalletNumber = factory.getFactoryCode() + material.getMaterialNumber() + date + shift.getShiftCode() + palletNumber6; + mesWorkReporting.setPalletNumber(halfPalletNumber); + //todo 鎵e噺瀵瑰簲绾胯竟搴擄紙澶栨硶鍏版瘺鍧�佸唴娉曞叞姣涘澂锛夊簱瀛樺悗锛岃皟鐢⊿AP鎶曟枡鎺ュ彛 + //todo 璋冪敤SAP宸ュ簭鎶ュ伐 + break; + case PARTS: + break; + } + save(mesWorkReporting); + //绾胯竟搴撳叆搴撻�昏緫 + LswMaterialInbound lswMaterialInbound = new LswMaterialInbound() + .setFactoryId(mesWorkReporting.getFactoryId()) + .setMaterialNumber(material.getMaterialNumber()) + .setMaterialName(material.getMaterialName()) + .setBatchNumber(batchNumber) + .setQuantity(mesWorkReporting.getQuantity()) + .setWarehouseId(lineSideWarehouse.getId()); + lswMaterialInboundService.save(lswMaterialInbound); + } } diff --git a/src/main/java/org/jeecg/modules/mes/utils/CommonUtils.java b/src/main/java/org/jeecg/modules/mes/utils/CommonUtils.java new file mode 100644 index 0000000..a0d521b --- /dev/null +++ b/src/main/java/org/jeecg/modules/mes/utils/CommonUtils.java @@ -0,0 +1,15 @@ +package org.jeecg.modules.mes.utils; + +import org.apache.shiro.SecurityUtils; +import org.jeecg.common.system.vo.LoginUser; + +public class CommonUtils { + + public static LoginUser getCurrentUser() { + try { + return (LoginUser) SecurityUtils.getSubject().getPrincipal(); + } catch (Exception e) { + return null; + } + } +} -- Gitblit v1.9.3