diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/SysDeptQuery.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/SysDeptQuery.java index 59cf2d9..30eca4f 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/SysDeptQuery.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/SysDeptQuery.java @@ -4,6 +4,7 @@ import com.ruoyi.common.core.domain.entity.SysDept; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.Collection; import java.util.List; /** @@ -16,4 +17,6 @@ public class SysDeptQuery extends SysDept { @ApiModelProperty("部门名称列表") private List deptNames; + @ApiModelProperty("ERP部门ID列表") + private Collection erpIds; } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java index b4f8f5f..7552ad1 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java @@ -1,6 +1,8 @@ package com.ruoyi.system.service; +import java.util.Collection; import java.util.List; + import com.ruoyi.common.core.domain.TreeSelect; import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.system.domain.dto.SysDeptQuery; @@ -138,4 +140,9 @@ public interface ISysDeptService * 根据名称列表,查询部门 */ List selectDeptListByNames(List names); + + /** + * 根据ERP ID 列表查询 + */ + List selectByErpIds(Collection erpIds); } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index 29f9f8f..96647fb 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -1,16 +1,11 @@ package com.ruoyi.system.service.impl; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; import com.alibaba.fastjson2.JSONObject; -import com.ruoyi.common.k3cloud.constants.K3Constants; import com.ruoyi.common.k3cloud.constants.K3FormIds; import com.ruoyi.common.k3cloud.service.K3Service; -import com.ruoyi.common.utils.ServiceUtil; import com.ruoyi.common.utils.collection.CollectionUtils; import com.ruoyi.system.domain.dto.SysDeptQuery; import org.springframework.beans.factory.annotation.Autowired; @@ -345,6 +340,16 @@ public class SysDeptServiceImpl implements ISysDeptService return this.selectDeptList(query); } + @Override + public List selectByErpIds(Collection erpIds) { + if (CollectionUtils.isEmptyElement(erpIds)) { + return Collections.emptyList(); + } + SysDeptQuery query = new SysDeptQuery(); + query.setErpIds(erpIds); + return deptMapper.selectDeptList(query); + } + /** * 递归列表 */ diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/user/domain/SysUserQuery.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/user/domain/SysUserQuery.java index a41f07b..8d7e433 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/user/domain/SysUserQuery.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/user/domain/SysUserQuery.java @@ -35,4 +35,7 @@ public class SysUserQuery extends SysUserVO { @ApiModelProperty("排除用户ID") private Long excludeUserId; + + @ApiModelProperty("排除用户ID列表") + private List excludeUserIds; } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/user/mapper/SysUserMapper.xml b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/user/mapper/SysUserMapper.xml index 3fdbfc5..bd3a022 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/user/mapper/SysUserMapper.xml +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/user/mapper/SysUserMapper.xml @@ -128,6 +128,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{item} + + AND u.user_id not in + + #{item} + + ${@com.ruoyi.framework.util.DataScopeUtil@dataScope("d", "u", needScope)} ${params.dataScope} diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/material/domain/MaterialQuery.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/material/domain/MaterialQuery.java index 5b870b6..00b2455 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/material/domain/MaterialQuery.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/material/domain/MaterialQuery.java @@ -3,6 +3,7 @@ package com.ruoyi.yh.material.domain; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.Collection; import java.util.List; /** @@ -16,5 +17,5 @@ public class MaterialQuery extends MaterialVO { private String eqErpNumber; @ApiModelProperty("erpId列表") - private List erpIds; + private Collection erpIds; } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/material/service/MaterialService.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/material/service/MaterialService.java index 10cef7a..33effd6 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/material/service/MaterialService.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/material/service/MaterialService.java @@ -1,6 +1,9 @@ package com.ruoyi.yh.material.service; +import java.util.Collection; import java.util.List; +import java.util.Set; + import com.ruoyi.yh.material.domain.Material; import com.ruoyi.yh.material.domain.MaterialVO; import com.ruoyi.yh.material.domain.MaterialQuery; @@ -63,4 +66,5 @@ public interface MaterialService void sync(); + List selectByErpIds(Collection erpIds); } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/material/service/impl/MaterialServiceImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/material/service/impl/MaterialServiceImpl.java index 508b072..09c6a65 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/material/service/impl/MaterialServiceImpl.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/material/service/impl/MaterialServiceImpl.java @@ -1,6 +1,8 @@ package com.ruoyi.yh.material.service.impl; import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -164,6 +166,16 @@ public class MaterialServiceImpl implements MaterialService } + @Override + public List selectByErpIds(Collection erpIds) { + if (CollectionUtils.isEmptyElement(erpIds)) { + return Collections.emptyList(); + } + MaterialQuery query = new MaterialQuery(); + query.setErpIds(erpIds); + return this.selectMaterialList(query); + } + /** * 通过物料编码新增或修改 */ diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/PriceQuery.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/PriceQuery.java index fc87bae..97239ac 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/PriceQuery.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/domain/PriceQuery.java @@ -20,4 +20,6 @@ public class PriceQuery extends PriceVO { @ApiModelProperty("单价ID列表") private List priceIds; + @ApiModelProperty("排除的单价ID列表") + private List excludePriceIds; } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/mapper/PriceMapper.xml b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/mapper/PriceMapper.xml index 74ee139..dfbc1f5 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/mapper/PriceMapper.xml +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/price/mapper/PriceMapper.xml @@ -72,6 +72,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{item} + + and bp.price_id not in + + #{item} + + ${@com.ruoyi.framework.util.DataScopeUtil@dataScope("sd", null, query.needScope)} ${query.params.dataScope} diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/domain/ProdOrder.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/domain/ProdOrder.java index 8b1d330..8e9f7f0 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/domain/ProdOrder.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/domain/ProdOrder.java @@ -127,4 +127,34 @@ public class ProdOrder extends BaseEntity @ApiModelProperty("最近同步时间") private LocalDateTime syncTime; + @ApiModelProperty("部门ID") + private Long deptId; + + @Excel(name = "物料编码") + @ApiModelProperty("物料编码") + private String materialNumber; + + @Excel(name = "物料规格品类(单价类别)") + @ApiModelProperty("物料规格品类(单价类别)") + private String materialCategory; + + @Excel(name = "物料大小") + @ApiModelProperty("物料大小") + private String materialSize; + + @Excel(name = "物料表面处理") + @ApiModelProperty("物料表面处理") + private String materialSurface; + + @Excel(name = "物料盖子方式") + @ApiModelProperty("物料盖子方式") + private String materialCover; + + @Excel(name = "单位名称") + @ApiModelProperty("单位名称") + private String unitName; + + @Excel(name = "基本单位名称") + @ApiModelProperty("基本单位名称") + private String baseUnitName; } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/domain/ProdOrderQuery.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/domain/ProdOrderQuery.java index 0f64834..d700a1c 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/domain/ProdOrderQuery.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/domain/ProdOrderQuery.java @@ -27,16 +27,7 @@ public class ProdOrderQuery extends ProdOrderVO { @ApiModelProperty("ERP业务状态列表") private List erpStatusList; - @ApiModelProperty("物料规格品类") - private String materialCategory; - - @ApiModelProperty("物料大小") - private String materialSize; - - @ApiModelProperty("物料表面处理") - private String materialSurface; - - @ApiModelProperty("物料盖子") - private String materialCover; + @ApiModelProperty("排除的ID列表") + private List excludeIds; } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/domain/ProdOrderVO.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/domain/ProdOrderVO.java index fb7783f..2a4c54d 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/domain/ProdOrderVO.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/domain/ProdOrderVO.java @@ -12,19 +12,7 @@ import java.util.List; @Data public class ProdOrderVO extends ProdOrder { - @ApiModelProperty("物料编码") - private String materialNumber; - @ApiModelProperty("生产车间名称") private String workShopName; - @ApiModelProperty("单位名称") - private String unitName; - - @ApiModelProperty("基本单位名称") - private String baseUnitName; - - @ApiModelProperty("部门ID") - private Long deptId; - } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/mapper/ProdOrderMapper.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/mapper/ProdOrderMapper.java index 3a1182b..08d54f1 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/mapper/ProdOrderMapper.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/mapper/ProdOrderMapper.java @@ -69,4 +69,9 @@ public interface ProdOrderMapper * @param num 基础数量 */ int addVerifiedBaseNum(@Param("orderId") Long orderId, @Param("num") BigDecimal num); + + /** + * 查询简单列表 + */ + List selectSimpleList(@Param("query") ProdOrderQuery query, @Param("fields") List fields); } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/mapper/ProdOrderMapper.xml b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/mapper/ProdOrderMapper.xml index 746492c..e90a139 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/mapper/ProdOrderMapper.xml +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/mapper/ProdOrderMapper.xml @@ -36,16 +36,17 @@ bpo.verified_base_num, bpo.erp_base_unit_id, bpo.sync_time, - bm.erp_number as material_number, - sd.dept_name as work_shop_name, - sd.dept_id as dept_id, - bu.erp_name as unit_name, - bu_b.erp_name as base_unit_name + bpo.dept_id as dept_id, + bpo.material_number, + bpo.material_category, + bpo.material_size, + bpo.material_surface, + bpo.material_cover, + bpo.unit_name, + bpo.base_unit_name, + sd.dept_name as work_shop_name from bst_prod_order bpo - left join sys_dept sd on sd.erp_id = bpo.erp_work_shop_id - left join bst_material bm on bm.erp_id = bpo.erp_material_id - left join bst_unit bu on bu.erp_id = bpo.erp_unit_id - left join bst_unit bu_b on bu_b.erp_id = bpo.erp_base_unit_id + left join sys_dept sd on sd.dept_id = bpo.dept_id @@ -63,20 +64,20 @@ and bpo.erp_status = #{query.erpStatus} and bpo.erp_work_shop_id = #{query.erpWorkShopId} and bpo.erp_req_src = #{query.erpReqSrc} - and sd.dept_id = #{query.deptId} + and bpo.dept_id = #{query.deptId} and bpo.erp_material_id = #{query.erpMaterialId} and erp_base_unit_id = #{query.erpBaseUnitId} - and bm.category = #{query.materialCategory} + and bpo.material_category = #{query.materialCategory} - and bm.size = #{query.materialSize} + and bpo.material_size = #{query.materialSize} - and bm.surface = #{query.materialSurface} + and bpo.material_surface = #{query.materialSurface} - and bm.cover = #{query.materialCover} + and bpo.material_cover = #{query.materialCover} and bpo.erp_status in @@ -90,6 +91,12 @@ #{item} + + and bpo.id not in + + #{item} + + ${query.params.dataScope} @@ -105,6 +112,18 @@ where bpo.id = #{id} + + insert into bst_prod_order @@ -133,6 +152,14 @@ verified_base_num, erp_base_unit_id, sync_time, + dept_id, + material_number, + material_category, + material_size, + material_surface, + material_cover, + unit_name, + base_unit_name, #{erpId}, @@ -160,6 +187,14 @@ #{verifiedBaseNum}, #{erpBaseUnitId}, #{syncTime}, + #{deptId}, + #{materialNumber}, + #{materialCategory}, + #{materialSize}, + #{materialSurface}, + #{materialCover}, + #{unitName}, + #{baseUnitName}, @@ -203,6 +238,14 @@ verified_base_num = #{data.verifiedBaseNum}, erp_base_unit_id = #{data.erpBaseUnitId}, sync_time = #{data.syncTime}, + dept_id = #{data.deptId}, + material_number = #{data.materialNumber}, + material_category = #{data.materialCategory}, + material_size = #{data.materialSize}, + material_surface = #{data.materialSurface}, + material_cover = #{data.materialCover}, + unit_name = #{data.unitName}, + base_unit_name = #{data.baseUnitName}, diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/service/ProdOrderService.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/service/ProdOrderService.java index adfed02..bb2c304 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/service/ProdOrderService.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/service/ProdOrderService.java @@ -86,4 +86,12 @@ public interface ProdOrderService * @param num 增加数量 */ int addVerifiedBaseNum(Long orderId, BigDecimal num); + + /** + * 查询简单列表 + * + * @param query 查询条件 + * @param fields 字段列表 + */ + List selectSimpleList(ProdOrderQuery query, String ...fields); } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/service/impl/ProdOrderConverterImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/service/impl/ProdOrderConverterImpl.java index 6045a1c..47d93ce 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/service/impl/ProdOrderConverterImpl.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/service/impl/ProdOrderConverterImpl.java @@ -1,19 +1,22 @@ package com.ruoyi.yh.prodOrder.service.impl; import com.alibaba.fastjson2.JSONArray; +import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.collection.CollectionUtils; import com.ruoyi.common.k3cloud.constants.fileds.K3ProdField; +import com.ruoyi.system.service.ISysDeptService; +import com.ruoyi.yh.material.domain.MaterialVO; import com.ruoyi.yh.material.service.MaterialService; import com.ruoyi.yh.prodOrder.domain.ProdOrder; import com.ruoyi.yh.prodOrder.service.ProdOrderConverter; +import com.ruoyi.yh.unit.domain.UnitVO; +import com.ruoyi.yh.unit.service.UnitService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import java.util.*; /** * @author wjh @@ -22,6 +25,16 @@ import java.util.List; @Service public class ProdOrderConverterImpl implements ProdOrderConverter { + @Autowired + private ISysDeptService deptService; + + @Autowired + private MaterialService materialService; + + @Autowired + private UnitService unitService; + + /** * 将ERP数据转为PO列表 * @@ -39,6 +52,10 @@ public class ProdOrderConverterImpl implements ProdOrderConverter { LocalDateTime syncTime = LocalDateTime.now(); + Set erpWorkShopIds = new HashSet<>(); // ERP生产车间ID + Set erpMaterialIds = new HashSet<>(); // ERP物料ID + Set erpUnitIds = new HashSet<>(); // ERP单位ID + for (JSONArray row : erpList) { ProdOrder po = new ProdOrder(); for (int i = 0; i < headers.size(); i++) { @@ -81,7 +98,9 @@ public class ProdOrderConverterImpl implements ProdOrderConverter { po.setErpStatus(row.getString(i)); break; case K3ProdField.F_WORK_SHOP_ID: - po.setErpWorkShopId(row.getString(i)); + String workShopId = row.getString(i); + po.setErpWorkShopId(workShopId); + erpWorkShopIds.add(workShopId); break; case K3ProdField.F_REQ_SRC: po.setErpReqSrc(row.getString(i)); @@ -93,13 +112,19 @@ public class ProdOrderConverterImpl implements ProdOrderConverter { po.setErpQty(row.getBigDecimal(i)); break; case K3ProdField.F_UNIT_ID: - po.setErpUnitId(row.getString(i)); + String unitId = row.getString(i); + po.setErpUnitId(unitId); + erpUnitIds.add(unitId); break; case K3ProdField.F_BASE_UNIT_ID: - po.setErpBaseUnitId(row.getString(i)); + String baseUnitId = row.getString(i); + po.setErpBaseUnitId(baseUnitId); + erpUnitIds.add(baseUnitId); break; case K3ProdField.F_MATERIAL_ID: - po.setErpMaterialId(row.getString(i)); + String materialId = row.getString(i); + po.setErpMaterialId(materialId); + erpMaterialIds.add(materialId); break; case K3ProdField.F_NO_STOCK_IN_QTY: po.setErpNoStockInQty(row.getBigDecimal(i)); @@ -117,6 +142,48 @@ public class ProdOrderConverterImpl implements ProdOrderConverter { result.add(po); } + // 生产部门ID + List deptList = deptService.selectByErpIds(erpWorkShopIds); + for (ProdOrder prodOrder : result) { + SysDept dept = deptList.stream().filter(item -> Objects.equals(item.getErpId(), prodOrder.getErpWorkShopId())).findFirst().orElse(null); + if (dept != null) { + prodOrder.setDeptId(dept.getDeptId()); + } + } + + // 物料信息 + List materialList = materialService.selectByErpIds(erpMaterialIds); + for (ProdOrder prodOrder : result) { + MaterialVO material = materialList.stream().filter(item -> Objects.equals(item.getErpId(), prodOrder.getErpMaterialId())).findFirst().orElse(null); + if (material != null) { + prodOrder.setMaterialCategory(material.getCategory()); + prodOrder.setMaterialCover(material.getCover()); + prodOrder.setMaterialSize(material.getSize()); + prodOrder.setMaterialNumber(material.getErpNumber()); + prodOrder.setMaterialSurface(material.getSurface()); + } else { + prodOrder.setMaterialCategory(""); + prodOrder.setMaterialCover(""); + prodOrder.setMaterialSize(""); + prodOrder.setMaterialNumber(""); + prodOrder.setMaterialSurface(""); + } + } + + // 单位信息 + List unitList = unitService.selectByErpIds(erpUnitIds); + for (ProdOrder prodOrder : result) { + UnitVO unit = unitList.stream().filter(item -> Objects.equals(item.getErpId(), prodOrder.getErpUnitId())).findFirst().orElse(null); + if (unit != null) { + prodOrder.setUnitName(unit.getErpName()); + } + + UnitVO baseUnit = unitList.stream().filter(item -> Objects.equals(item.getErpId(), prodOrder.getErpBaseUnitId())).findFirst().orElse(null); + if (baseUnit != null) { + prodOrder.setBaseUnitName(baseUnit.getErpName()); + } + } + return result; } } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/service/impl/ProdOrderServiceImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/service/impl/ProdOrderServiceImpl.java index f59cd1f..f510a7b 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/service/impl/ProdOrderServiceImpl.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/prodOrder/service/impl/ProdOrderServiceImpl.java @@ -2,6 +2,7 @@ package com.ruoyi.yh.prodOrder.service.impl; import java.math.BigDecimal; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -276,6 +277,14 @@ public class ProdOrderServiceImpl implements ProdOrderService return prodOrderMapper.addVerifiedBaseNum(orderId, num); } + @Override + public List selectSimpleList(ProdOrderQuery query, String ...fields) { + if (fields == null) { + return Collections.emptyList(); + } + return prodOrderMapper.selectSimpleList(query, Arrays.asList(fields)); + } + /** * 新增或修改 */ diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/domain/ReportVO.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/domain/ReportVO.java index 60a5ef5..94e6539 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/domain/ReportVO.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/domain/ReportVO.java @@ -21,6 +21,9 @@ public class ReportVO extends Report { @ApiModelProperty("部门名称") private String deptName; + @ApiModelProperty("部门ERP ID") + private String deptErpId; + @ApiModelProperty("产量明细") @Size(min = 1, message = "至少填写一个产量明细") @Valid diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/domain/bo/ReportBO.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/domain/bo/ReportBO.java index 27cab8c..dddc077 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/domain/bo/ReportBO.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/domain/bo/ReportBO.java @@ -3,6 +3,7 @@ package com.ruoyi.yh.report.domain.bo; import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.yh.report.domain.Report; +import com.ruoyi.yh.report.domain.ReportVO; import com.ruoyi.yh.reportProd.domain.ReportProd; import com.ruoyi.yh.reportProd.domain.bo.ReportProdBO; import lombok.Data; @@ -21,6 +22,9 @@ public class ReportBO extends Report { // 部门信息 private SysDept dept; + // 旧的报表数据 + private ReportVO old; + // 产量列表 private List productList; } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/domain/enums/ReportStatus.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/domain/enums/ReportStatus.java index 5b57f01..a4962f5 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/domain/enums/ReportStatus.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/domain/enums/ReportStatus.java @@ -55,4 +55,11 @@ public enum ReportStatus { public static List canEdit() { return asList(WAIT_SUBMIT, REJECT); } + + /** + * 允许重置审核员的状态 + */ + public static List canResetVerify() { + return asList(REJECT); + } } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/mapper/ReportMapper.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/mapper/ReportMapper.java index bd28a31..75aa059 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/mapper/ReportMapper.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/mapper/ReportMapper.java @@ -67,4 +67,8 @@ public interface ReportMapper */ int updateByQuery(@Param("data") Report data, @Param("query") ReportQuery query); + /** + * 重置审核信息 + */ + int resetVerifyInfoByQuery(@Param("query") ReportQuery query); } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/mapper/ReportMapper.xml b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/mapper/ReportMapper.xml index 2b51678..8494b6e 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/mapper/ReportMapper.xml +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/mapper/ReportMapper.xml @@ -24,7 +24,8 @@ br.update_id, br.update_by, br.remark, - sd.dept_name as dept_name + sd.dept_name as dept_name, + sd.erp_id as dept_erp_id from bst_report br left join sys_dept sd on sd.dept_id = br.dept_id left join sys_user su on su.user_id = br.create_id @@ -123,6 +124,17 @@ + + update bst_report br + set br.verify_id = null, + br.verify_By = null, + br.verify_time = null, + br.verify_remark = null + + + + + dept_id = #{data.deptId}, `status` = #{data.status}, diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/ReportConverter.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/ReportConverter.java index 04a93fd..a1ef7ca 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/ReportConverter.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/ReportConverter.java @@ -11,13 +11,15 @@ public interface ReportConverter { /** * 创建时,vo转为bo + * * @param vo + * @param submit * @return */ - ReportBO toBoByCreate(ReportVO vo); + ReportBO toBoByCreate(ReportVO vo, boolean submit); /** * 更新时,VO 转 BO */ - ReportBO toBoByUpdate(ReportVO vo); + ReportBO toBoByUpdate(ReportVO vo, boolean submit); } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/ReportValidator.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/ReportValidator.java index d96e6ba..bf2f74d 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/ReportValidator.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/ReportValidator.java @@ -10,7 +10,7 @@ import com.ruoyi.yh.report.domain.bo.ReportBO; public interface ReportValidator { /** - * 更新前校验 + * 编辑前校验 */ void checkPreEdit(ReportBO bo); @@ -19,5 +19,4 @@ public interface ReportValidator { */ void afterCheck(ReportVO vo); - } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/impl/ReportConverterImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/impl/ReportConverterImpl.java index fa21a15..138d438 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/impl/ReportConverterImpl.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/impl/ReportConverterImpl.java @@ -1,17 +1,15 @@ package com.ruoyi.yh.report.service.impl; -import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.system.service.ISysDeptService; import com.ruoyi.system.service.ISysUserService; -import com.ruoyi.yh.price.domain.PriceQuery; import com.ruoyi.yh.price.service.PriceService; -import com.ruoyi.yh.report.domain.Report; import com.ruoyi.yh.report.domain.ReportVO; import com.ruoyi.yh.report.domain.bo.ReportBO; import com.ruoyi.yh.report.domain.enums.ReportStatus; import com.ruoyi.yh.report.service.ReportConverter; -import com.ruoyi.yh.reportProd.domain.ReportProd; +import com.ruoyi.yh.report.service.ReportService; import com.ruoyi.yh.reportProd.domain.ReportProdVO; import com.ruoyi.yh.reportProd.domain.bo.ReportProdBO; import com.ruoyi.yh.reportProd.service.ReportProdConverter; @@ -30,10 +28,7 @@ import java.util.List; public class ReportConverterImpl implements ReportConverter { @Autowired - private ISysUserService userService; - - @Autowired - private PriceService priceService; + private ReportService reportService; @Autowired private ReportProdConverter reportProdConverter; @@ -42,21 +37,25 @@ public class ReportConverterImpl implements ReportConverter { private ISysDeptService deptService; @Override - public ReportBO toBoByCreate(ReportVO vo) { + public ReportBO toBoByCreate(ReportVO vo, boolean submit) { if (vo == null) { return null; } - LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser user = SecurityUtils.getLoginUser().getUser(); // 报表主表数据 ReportBO bo = new ReportBO(); bo.setDeptId(vo.getDeptId()); - bo.setStatus(ReportStatus.WAIT_VERIFY.getStatus()); - bo.setCreateId(loginUser.getUserId()); + if (submit) { + bo.setStatus(ReportStatus.WAIT_VERIFY.getStatus()); + } else { + bo.setStatus(ReportStatus.WAIT_SUBMIT.getStatus()); + } + bo.setCreateId(user.getUserId()); bo.setReportDate(vo.getReportDate()); bo.setTotalAmount(vo.getTotalAmount()); - bo.setCreateBy(loginUser.getUsername()); + bo.setCreateBy(user.getNickName()); // 报表产量数据 List productList = new ArrayList<>(); @@ -74,12 +73,12 @@ public class ReportConverterImpl implements ReportConverter { } @Override - public ReportBO toBoByUpdate(ReportVO vo) { + public ReportBO toBoByUpdate(ReportVO vo, boolean submit) { if (vo == null) { return null; } - LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser user = SecurityUtils.getLoginUser().getUser(); // 报表主表数据 ReportBO bo = new ReportBO(); @@ -87,9 +86,11 @@ public class ReportConverterImpl implements ReportConverter { bo.setDeptId(vo.getDeptId()); bo.setReportDate(vo.getReportDate()); bo.setTotalAmount(vo.getTotalAmount()); - bo.setStatus(ReportStatus.WAIT_VERIFY.getStatus()); - bo.setUpdateId(loginUser.getUserId()); - bo.setUpdateBy(loginUser.getUsername()); + if (submit) { + bo.setStatus(ReportStatus.WAIT_VERIFY.getStatus()); + } + bo.setUpdateId(user.getUserId()); + bo.setUpdateBy(user.getNickName()); // 报表产量数据 List productList = new ArrayList<>(); @@ -103,6 +104,7 @@ public class ReportConverterImpl implements ReportConverter { // 组装数据 bo.setProductList(productList); bo.setDept(deptService.selectDeptById(bo.getDeptId(), true)); + bo.setOld(reportService.selectReportByReportId(vo.getReportId())); return bo; } } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/impl/ReportServiceImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/impl/ReportServiceImpl.java index 83698ea..2c6bb2b 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/impl/ReportServiceImpl.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/impl/ReportServiceImpl.java @@ -158,8 +158,8 @@ public class ReportServiceImpl implements ReportService @Override public int addReport(ReportBO bo) { - ServiceUtil.assertion(bo == null, "参数错误"); - // TODO 校验 + // 校验 + reportValidator.checkPreEdit(bo); Integer result = transactionTemplate.execute(status -> { // 新增主表 @@ -175,6 +175,11 @@ public class ReportServiceImpl implements ReportService // 更新订单产量表 this.batchUpdateOrderProductList(bo); + // 后校验 + ReportVO vo = this.selectReportByReportId(bo.getReportId()); + reportAssembler.assembleProductList(Collections.singletonList(vo), true, true); + reportValidator.afterCheck(vo); + return insert; }); @@ -287,8 +292,15 @@ public class ReportServiceImpl implements ReportService public int editReport(ReportBO bo) { // 校验 reportValidator.checkPreEdit(bo); + ReportVO old = bo.getOld(); Integer result = transactionTemplate.execute(status -> { + // 若原来是审核未通过,则重置审核信息 + if (ReportStatus.REJECT.getStatus().equals(old.getStatus())) { + int reset = this.resetVerifyInfo(bo.getReportId()); + ServiceUtil.assertion(reset != 1, "重置审核信息失败"); + } + // 修改主表 int update = this.updateReport(bo); ServiceUtil.assertion(update != 1, "修改报表失败"); @@ -302,12 +314,27 @@ public class ReportServiceImpl implements ReportService // 修改订单产量表 this.batchUpdateOrderProductList(bo); + // 后校验 + ReportVO vo = this.selectReportByReportId(bo.getReportId()); + reportAssembler.assembleProductList(Collections.singletonList(vo), true, true); + reportValidator.afterCheck(vo); + return update; }); return result == null ? 0 : result; } + private int resetVerifyInfo(Long reportId) { + if (reportId == null) { + return 0; + } + ReportQuery query = new ReportQuery(); + query.setReportId(reportId); + query.setStatusList(ReportStatus.canResetVerify()); + return reportMapper.resetVerifyInfoByQuery(query); + } + @Override public int verify(ReportVerifyDTO dto, Long verifyId) { if (dto == null || dto.getReportId() == null) { diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/impl/ReportValidatorImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/impl/ReportValidatorImpl.java index 2dbc6ac..eb84c37 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/impl/ReportValidatorImpl.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/report/service/impl/ReportValidatorImpl.java @@ -4,6 +4,7 @@ import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.utils.ServiceUtil; import com.ruoyi.common.utils.collection.CollectionUtils; import com.ruoyi.system.user.domain.SysUserQuery; +import com.ruoyi.system.user.domain.SysUserShiftQuery; import com.ruoyi.system.user.domain.SysUserVO; import com.ruoyi.system.service.ISysDeptService; import com.ruoyi.system.service.ISysUserService; @@ -19,12 +20,17 @@ import com.ruoyi.yh.report.domain.bo.ReportBO; import com.ruoyi.yh.report.domain.enums.ReportStatus; import com.ruoyi.yh.report.service.ReportService; import com.ruoyi.yh.report.service.ReportValidator; +import com.ruoyi.yh.reportOrderProd.domain.ReportOrderProdVO; import com.ruoyi.yh.reportOrderProd.domain.bo.ReportOrderProdBO; +import com.ruoyi.yh.reportProd.domain.ReportProdVO; import com.ruoyi.yh.reportProd.domain.bo.ReportProdBO; +import com.ruoyi.yh.reportUserProd.domain.ReportUserProdVO; import com.ruoyi.yh.reportUserProd.domain.bo.ReportUserProdBO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.time.LocalDate; +import java.util.Arrays; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -36,45 +42,79 @@ import java.util.stream.Collectors; @Service public class ReportValidatorImpl implements ReportValidator { - @Autowired - private ReportService reportService; - - @Autowired - private ISysDeptService deptService; - @Autowired private PriceService priceService; @Autowired private ISysUserService userService; - @Autowired - private ProdOrderService prodOrderService; - @Override public void checkPreEdit(ReportBO bo) { - ServiceUtil.assertion(bo == null || bo.getReportId() == null, "参数错误"); + ServiceUtil.assertion(bo == null, "参数错误"); - ReportVO old = reportService.selectReportByReportId(bo.getReportId()); - ServiceUtil.assertion(old == null || old.getReportId() == null, "待更新的报表不存在"); - ServiceUtil.assertion(!ReportStatus.canEdit().contains(old.getStatus()), "报表当前状态不允许更新,请刷新后重试"); + // 校验日期 + this.checkReportDate(bo.getReportDate()); + + // 校验报表状态 + if (bo.getReportId() != null) { + ReportVO old = bo.getOld(); + ServiceUtil.assertion(old == null || old.getReportId() == null, "待更新的报表不存在"); + ServiceUtil.assertion(!ReportStatus.canEdit().contains(old.getStatus()), "报表当前状态不允许更新,请刷新后重试"); + } // 校验部门 - this.checkDept(bo.getDeptId()); + this.checkDept(bo.getDeptId(), bo.getDept()); // 校验产量列表 this.checkProduct(bo.getProductList()); } + private void checkReportDate(LocalDate reportDate) { + ServiceUtil.assertion(reportDate != null && reportDate.isAfter(LocalDate.now()), "报表日期不允许选择未来的日期"); + } + @Override public void afterCheck(ReportVO vo) { + Long deptId = vo.getDeptId(); - // TODO 工序是否当前部门的工序 + // 工序是否当前部门的工序 + for (ReportProdVO prod : vo.getProductList()) { + if (prod == null || prod.getPriceId() == null) { + continue; + } + ServiceUtil.assertion(!Objects.equals(prod.getPriceDeptId(), deptId), "工序%s不是部门%s的工序", prod.getPriceName(), vo.getDeptName()); + } - // TODO 员工是否当前部门的员工 + // 订单是否当前部门订单 + List orderProdList = vo.getProductList().stream() + .map(ReportProdVO::getOrderProdList) + .flatMap(List::stream).collect(Collectors.toList()); + for (ReportOrderProdVO orderProd : orderProdList) { + if (orderProd == null || orderProd.getOrderId() == null) { + continue; + } + ServiceUtil.assertion(!Objects.equals(orderProd.getOrderDeptId(), deptId), "订单%s不是部门%s的订单", orderProd.getOrderErpBillNo(), vo.getDeptName()); + } - // TODO 订单是否当前部门订单 + // 员工是否当天在该部门排班 + List userProdList = vo.getProductList().stream() + .map(ReportProdVO::getUserProdList) + .flatMap(List::stream).collect(Collectors.toList()); + SysUserShiftQuery userQuery = new SysUserShiftQuery(); + userQuery.setUserIds(CollectionUtils.map(userProdList, ReportUserProdVO::getUserId)); + userQuery.setShiftDate(vo.getReportDate()); + userQuery.setTargetDeptId(vo.getDeptId()); + List shiftUserList = userService.selectUserWithShiftList(userQuery); + for (ReportUserProdVO userProd : userProdList) { + if (userProd == null || userProd.getUserId() == null) { + continue; + } + SysUserVO shiftUser = shiftUserList.stream() + .filter(item -> Objects.equals(item.getUserId(), userProd.getUserId())) + .findFirst().orElse(null); + ServiceUtil.assertion(shiftUser == null, "员工%s在%s没有在部门%s排班", userProd.getUserName(), vo.getReportDate(), vo.getDeptName()); + } } private void checkProduct(List productList) { @@ -101,7 +141,8 @@ public class ReportValidatorImpl implements ReportValidator { } - // 员工是否当前用户可选 + + // TODO 员工是否当前报表可选(在当前报表的部门 or 排班在当前报表部门) List userProdList = productList.stream().map(ReportProdBO::getUserProdList).flatMap(List::stream).collect(Collectors.toList()); SysUserQuery userQuery = new SysUserQuery(); userQuery.setUserIds(CollectionUtils.map(userProdList, ReportUserProdBO::getUserId)); @@ -116,30 +157,14 @@ public class ReportValidatorImpl implements ReportValidator { ServiceUtil.assertion(user == null, "员工不存在"); } - // 订单是否当前用户可选 - List orderProdList = productList.stream().map(ReportProdBO::getOrderProdList).flatMap(List::stream).collect(Collectors.toList()); - ProdOrderQuery orderQuery = new ProdOrderQuery(); - orderQuery.setIds(CollectionUtils.map(orderProdList, ReportOrderProdBO::getOrderId)); - orderQuery.setNeedScope(true); - List orderList = prodOrderService.selectProdOrderList(orderQuery); - for (ReportOrderProdBO orderProd : orderProdList) { - if (orderProd == null || orderProd.getOrderId() == null) { - continue; - } - // 校验订单 - ProdOrderVO order = orderList.stream().filter(item -> Objects.equals(item.getId(), orderProd.getOrderId())).findFirst().orElse(null); - ServiceUtil.assertion(order == null, "生产订单%s不存在"); - } } - private void checkDept(Long deptId) { + private void checkDept(Long deptId, SysDept dept) { if (deptId == null) { return; } - // 部门是否当前用户可选 - SysDept dept = deptService.selectDeptById(deptId, true); ServiceUtil.assertion(dept == null, "部门不存在"); } } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportOrderProd/domain/ReportOrderProdVO.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportOrderProd/domain/ReportOrderProdVO.java index 8091bc7..286298a 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportOrderProd/domain/ReportOrderProdVO.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportOrderProd/domain/ReportOrderProdVO.java @@ -34,6 +34,9 @@ public class ReportOrderProdVO extends ReportOrderProd { @ApiModelProperty("订单未入库数量") private BigDecimal orderErpNoStockInQty; + @ApiModelProperty("订单生产部门ID") + private Long orderDeptId; + @ApiModelProperty("订单单位名称") private String unitName; diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportOrderProd/mapper/ReportOrderProdMapper.xml b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportOrderProd/mapper/ReportOrderProdMapper.xml index 6124844..c9bdb15 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportOrderProd/mapper/ReportOrderProdMapper.xml +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportOrderProd/mapper/ReportOrderProdMapper.xml @@ -25,6 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" bpo.erp_base_unit_qty as order_erp_base_unit_qty, bpo.erp_base_no_stock_in_qty as order_erp_base_no_stock_in_qty, bpo.verified_base_num as verified_base_num, + bpo.dept_id as order_dept_id, bu.erp_name as unit_name, bu_b.erp_name as base_unit_name, br.report_date as report_date, diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/ReportProdVO.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/ReportProdVO.java index 37340fa..33317c0 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/ReportProdVO.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/domain/ReportProdVO.java @@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.Valid; +import javax.validation.constraints.Size; import java.util.List; /** @@ -17,9 +18,13 @@ public class ReportProdVO extends ReportProd { @ApiModelProperty("员工产量列表") @Valid + @Size(min = 1, message = "至少需要填写一条员工产量") private List userProdList; @ApiModelProperty("订单产量列表") @Valid private List orderProdList; + + @ApiModelProperty("工序部门ID") + private Long priceDeptId; } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/mapper/ReportProdMapper.xml b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/mapper/ReportProdMapper.xml index cf52131..0aa5599 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/mapper/ReportProdMapper.xml +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/mapper/ReportProdMapper.xml @@ -26,8 +26,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" brp.price_quantity_denominator, brp.deleted, brp.price_type, - brp.remark + brp.remark, + bp.dept_id as price_dept_id from bst_report_prod brp + left join bst_price bp on bp.price_id = brp.price_id diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/service/impl/ReportProdConverterImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/service/impl/ReportProdConverterImpl.java index c106cf9..93f1e36 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/service/impl/ReportProdConverterImpl.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/reportProd/service/impl/ReportProdConverterImpl.java @@ -51,6 +51,7 @@ public class ReportProdConverterImpl implements ReportProdConverter { bo.setPriceQuantityNumerator(vo.getPriceQuantityNumerator()); bo.setPriceType(vo.getPriceType()); bo.setRemark(vo.getRemark()); + bo.setDefectNum(vo.getDefectNum()); // 用户产量明细 List userProdList = new ArrayList<>(); @@ -99,6 +100,7 @@ public class ReportProdConverterImpl implements ReportProdConverter { bo.setPriceQuantityNumerator(vo.getPriceQuantityNumerator()); bo.setPriceType(vo.getPriceType()); bo.setRemark(vo.getRemark()); + bo.setDefectNum(vo.getDefectNum()); // 用户产量明细 List userProdList = new ArrayList<>(); diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/shift/service/IShiftService.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/shift/service/ShiftService.java similarity index 95% rename from common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/shift/service/IShiftService.java rename to common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/shift/service/ShiftService.java index 14b6a98..d5af01a 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/shift/service/IShiftService.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/shift/service/ShiftService.java @@ -1,5 +1,6 @@ package com.ruoyi.yh.shift.service; +import java.time.LocalDate; import java.util.List; import com.ruoyi.yh.shift.domain.Shift; import com.ruoyi.yh.shift.domain.ShiftVO; @@ -11,7 +12,7 @@ import com.ruoyi.yh.shift.domain.ShiftQuery; * @author ruoyi * @date 2024-12-07 */ -public interface IShiftService +public interface ShiftService { /** * 查询调班 diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/shift/service/ShiftValidator.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/shift/service/ShiftValidator.java new file mode 100644 index 0000000..ad65b65 --- /dev/null +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/shift/service/ShiftValidator.java @@ -0,0 +1,13 @@ +package com.ruoyi.yh.shift.service; + +import java.time.LocalDateTime; +import java.util.List; + +/** + * @author wjh + * 2024/12/12 + */ +public interface ShiftValidator { + + +} diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/shift/service/impl/ShiftServiceImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/shift/service/impl/ShiftServiceImpl.java index 7c9ef24..7e2d6a3 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/shift/service/impl/ShiftServiceImpl.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/shift/service/impl/ShiftServiceImpl.java @@ -8,7 +8,7 @@ import com.ruoyi.yh.shift.mapper.ShiftMapper; import com.ruoyi.yh.shift.domain.Shift; import com.ruoyi.yh.shift.domain.ShiftVO; import com.ruoyi.yh.shift.domain.ShiftQuery; -import com.ruoyi.yh.shift.service.IShiftService; +import com.ruoyi.yh.shift.service.ShiftService; /** * 调班Service业务层处理 @@ -17,7 +17,7 @@ import com.ruoyi.yh.shift.service.IShiftService; * @date 2024-12-07 */ @Service -public class ShiftServiceImpl implements IShiftService +public class ShiftServiceImpl implements ShiftService { @Autowired private ShiftMapper shiftMapper; @@ -100,4 +100,5 @@ public class ShiftServiceImpl implements IShiftService public int logicDel(List shiftIds) { return shiftMapper.logicDel(shiftIds); } + } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/shift/service/impl/ShiftValidatorImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/shift/service/impl/ShiftValidatorImpl.java new file mode 100644 index 0000000..5f6e78b --- /dev/null +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/shift/service/impl/ShiftValidatorImpl.java @@ -0,0 +1,12 @@ +package com.ruoyi.yh.shift.service.impl; + +import com.ruoyi.yh.shift.service.ShiftValidator; +import org.springframework.stereotype.Service; + +/** + * @author wjh + * 2024/12/12 + */ +@Service +public class ShiftValidatorImpl implements ShiftValidator { +} diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/unit/domain/UnitQuery.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/unit/domain/UnitQuery.java index 207133e..2718379 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/unit/domain/UnitQuery.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/unit/domain/UnitQuery.java @@ -1,11 +1,19 @@ package com.ruoyi.yh.unit.domain; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.Collection; +import java.util.List; + /** * @author wjh * 2024/11/18 */ @Data public class UnitQuery extends UnitVO { + + @ApiModelProperty("ERP ID 列表") + private Collection erpIds; + } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/unit/mapper/UnitMapper.xml b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/unit/mapper/UnitMapper.xml index eb45f4f..e8a752a 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/unit/mapper/UnitMapper.xml +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/unit/mapper/UnitMapper.xml @@ -22,6 +22,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and bu.erp_forbid_status = #{query.erpForbidStatus} and bu.erp_name like concat('%', #{query.erpName}, '%') and bu.erp_number like concat('%', #{query.erpNumber}, '%') + + and bu.erp_id in + + #{item} + + ${query.params.dataScope} diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/unit/service/UnitService.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/unit/service/UnitService.java index 46d938d..ee1ee86 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/unit/service/UnitService.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/unit/service/UnitService.java @@ -1,6 +1,9 @@ package com.ruoyi.yh.unit.service; +import java.util.Collection; import java.util.List; +import java.util.Set; + import com.ruoyi.yh.unit.domain.Unit; import com.ruoyi.yh.unit.domain.UnitVO; import com.ruoyi.yh.unit.domain.UnitQuery; @@ -66,4 +69,5 @@ public interface UnitService */ void sync(); + List selectByErpIds(Collection erpIds); } diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/unit/service/impl/UnitServiceImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/unit/service/impl/UnitServiceImpl.java index 9b2aaf1..75b286b 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/unit/service/impl/UnitServiceImpl.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/yh/unit/service/impl/UnitServiceImpl.java @@ -1,6 +1,8 @@ package com.ruoyi.yh.unit.service.impl; import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -163,6 +165,17 @@ public class UnitServiceImpl implements UnitService }, 0, TimeUnit.SECONDS); } + @Override + public List selectByErpIds(Collection erpIds) { + if (CollectionUtils.isEmptyElement(erpIds)) { + return Collections.emptyList(); + } + + UnitQuery query = new UnitQuery(); + query.setErpIds(erpIds); + return this.selectUnitList(query); + } + private int saveByErpId(Unit unit) { String errorMsg = "成功"; try { diff --git a/common-ruoyi/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/common-ruoyi/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml index 6f1a071..f8804bf 100644 --- a/common-ruoyi/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/common-ruoyi/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -35,6 +35,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{item} + + AND erp_id in + + #{item} + + ${params.dataScope} order by d.parent_id, d.order_num diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/yh/ReportController.java b/ruoyi-web/src/main/java/com/ruoyi/web/yh/ReportController.java index ae970a9..2722762 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/yh/ReportController.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/yh/ReportController.java @@ -94,24 +94,30 @@ public class ReportController extends BaseController /** * 新增报表 + * @param data 数据 + * @param submit 是否提交 */ @PreAuthorize("@ss.hasPermi('yh:report:add')") @Log(title = LOG_TITLE, businessType = BusinessType.INSERT, bizType = LogBizType.REPORT, bizIdName = "arg0") @PostMapping - public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) ReportVO data) + public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) ReportVO data, + @RequestParam(required = false, defaultValue = "true") Boolean submit) { - ReportBO bo = reportConverter.toBoByCreate(data); + ReportBO bo = reportConverter.toBoByCreate(data, submit); return toAjax(reportService.addReport(bo)); } /** * 修改报表 + * @param data 数据 + * @param submit 是否提交 */ @PreAuthorize("@ss.hasPermi('yh:report:edit')") @Log(title = LOG_TITLE, businessType = BusinessType.UPDATE, bizType = LogBizType.REPORT, bizIdName = "arg0") @PutMapping - public AjaxResult edit(@RequestBody @Validated(ValidGroup.Update.class) ReportVO data) { - ReportBO bo = reportConverter.toBoByUpdate(data); + public AjaxResult edit(@RequestBody @Validated(ValidGroup.Update.class) ReportVO data, + @RequestParam(required = false, defaultValue = "true") Boolean submit) { + ReportBO bo = reportConverter.toBoByUpdate(data, submit); return toAjax(reportService.editReport(bo)); } diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/yh/ShiftController.java b/ruoyi-web/src/main/java/com/ruoyi/web/yh/ShiftController.java index 61b3463..a811bf4 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/yh/ShiftController.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/yh/ShiftController.java @@ -5,7 +5,6 @@ import javax.servlet.http.HttpServletResponse; import com.ruoyi.common.annotation.DataScope; import com.ruoyi.common.core.domain.entity.SysUser; -import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.enums.LogBizType; import com.ruoyi.yh.shift.service.ShiftConverter; import org.springframework.security.access.prepost.PreAuthorize; @@ -25,7 +24,7 @@ import com.ruoyi.common.enums.BusinessType; import com.ruoyi.yh.shift.domain.Shift; import com.ruoyi.yh.shift.domain.ShiftVO; import com.ruoyi.yh.shift.domain.ShiftQuery; -import com.ruoyi.yh.shift.service.IShiftService; +import com.ruoyi.yh.shift.service.ShiftService; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; @@ -40,7 +39,7 @@ import com.ruoyi.common.core.page.TableDataInfo; public class ShiftController extends BaseController { @Autowired - private IShiftService shiftService; + private ShiftService shiftService; @Autowired private ShiftConverter shiftConverter;