debug、性能优化

This commit is contained in:
磷叶 2024-12-12 18:06:02 +08:00
parent 69d06e22b3
commit 6041176f8e
44 changed files with 479 additions and 122 deletions

View File

@ -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<String> deptNames;
@ApiModelProperty("ERP部门ID列表")
private Collection<String> erpIds;
}

View File

@ -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<SysDept> selectDeptListByNames(List<String> names);
/**
* 根据ERP ID 列表查询
*/
List<SysDept> selectByErpIds(Collection<String> erpIds);
}

View File

@ -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<SysDept> selectByErpIds(Collection<String> erpIds) {
if (CollectionUtils.isEmptyElement(erpIds)) {
return Collections.emptyList();
}
SysDeptQuery query = new SysDeptQuery();
query.setErpIds(erpIds);
return deptMapper.selectDeptList(query);
}
/**
* 递归列表
*/

View File

@ -35,4 +35,7 @@ public class SysUserQuery extends SysUserVO {
@ApiModelProperty("排除用户ID")
private Long excludeUserId;
@ApiModelProperty("排除用户ID列表")
private List<Long> excludeUserIds;
}

View File

@ -128,6 +128,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item}
</foreach>
</if>
<if test="excludeUserIds != null and excludeUserIds.size() > 0">
AND u.user_id not in
<foreach collection="excludeUserIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<!-- 数据范围过滤 -->
${@com.ruoyi.framework.util.DataScopeUtil@dataScope("d", "u", needScope)}
${params.dataScope}

View File

@ -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<String> erpIds;
private Collection<String> erpIds;
}

View File

@ -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<MaterialVO> selectByErpIds(Collection<String> erpIds);
}

View File

@ -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<MaterialVO> selectByErpIds(Collection<String> erpIds) {
if (CollectionUtils.isEmptyElement(erpIds)) {
return Collections.emptyList();
}
MaterialQuery query = new MaterialQuery();
query.setErpIds(erpIds);
return this.selectMaterialList(query);
}
/**
* 通过物料编码新增或修改
*/

View File

@ -20,4 +20,6 @@ public class PriceQuery extends PriceVO {
@ApiModelProperty("单价ID列表")
private List<Long> priceIds;
@ApiModelProperty("排除的单价ID列表")
private List<Long> excludePriceIds;
}

View File

@ -72,6 +72,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item}
</foreach>
</if>
<if test="query.excludePriceIds != null and query.excludePriceIds.size() > 0">
and bp.price_id not in
<foreach item="item" collection="query.excludePriceIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
${@com.ruoyi.framework.util.DataScopeUtil@dataScope("sd", null, query.needScope)}
${query.params.dataScope}
</sql>

View File

@ -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;
}

View File

@ -27,16 +27,7 @@ public class ProdOrderQuery extends ProdOrderVO {
@ApiModelProperty("ERP业务状态列表")
private List<String> erpStatusList;
@ApiModelProperty("物料规格品类")
private String materialCategory;
@ApiModelProperty("物料大小")
private String materialSize;
@ApiModelProperty("物料表面处理")
private String materialSurface;
@ApiModelProperty("物料盖子")
private String materialCover;
@ApiModelProperty("排除的ID列表")
private List<Long> excludeIds;
}

View File

@ -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;
}

View File

@ -69,4 +69,9 @@ public interface ProdOrderMapper
* @param num 基础数量
*/
int addVerifiedBaseNum(@Param("orderId") Long orderId, @Param("num") BigDecimal num);
/**
* 查询简单列表
*/
List<ProdOrderVO> selectSimpleList(@Param("query") ProdOrderQuery query, @Param("fields") List<String> fields);
}

View File

@ -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
</sql>
<sql id="searchCondition">
@ -63,20 +64,20 @@
<if test="query.erpStatus != null and query.erpStatus != ''"> and bpo.erp_status = #{query.erpStatus}</if>
<if test="query.erpWorkShopId != null and query.erpWorkShopId != ''"> and bpo.erp_work_shop_id = #{query.erpWorkShopId}</if>
<if test="query.erpReqSrc != null and query.erpReqSrc != ''"> and bpo.erp_req_src = #{query.erpReqSrc}</if>
<if test="query.deptId != null "> and sd.dept_id = #{query.deptId}</if>
<if test="query.deptId != null "> and bpo.dept_id = #{query.deptId}</if>
<if test="query.erpMaterialId != null and query.erpMaterialId != ''"> and bpo.erp_material_id = #{query.erpMaterialId}</if>
<if test="query.erpBaseUnitId != null and query.erpBaseUnitId != ''"> and erp_base_unit_id = #{query.erpBaseUnitId}</if>
<if test="query.materialCategory != null and query.materialCategory != ''">
and bm.category = #{query.materialCategory}
and bpo.material_category = #{query.materialCategory}
</if>
<if test="query.materialSize != null and query.materialSize != ''">
and bm.size = #{query.materialSize}
and bpo.material_size = #{query.materialSize}
</if>
<if test="query.materialSurface != null and query.materialSurface != ''">
and bm.surface = #{query.materialSurface}
and bpo.material_surface = #{query.materialSurface}
</if>
<if test="query.materialCover != null and query.materialCover != ''">
and bm.cover = #{query.materialCover}
and bpo.material_cover = #{query.materialCover}
</if>
<if test="query.erpStatusList != null and query.erpStatusList.size() > 0">
and bpo.erp_status in
@ -90,6 +91,12 @@
#{item}
</foreach>
</if>
<if test="query.excludeIds != null and query.excludeIds.size() > 0">
and bpo.id not in
<foreach collection="query.excludeIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
${query.params.dataScope}
</sql>
@ -105,6 +112,18 @@
where bpo.id = #{id}
</select>
<select id="selectSimpleList" resultMap="ProdOrderResult">
select
<foreach collection="fields" separator="," item="item">
${item}
</foreach>
from bst_prod_order bpo
left join sys_dept sd on sd.erp_id = bpo.erp_work_shop_id
<where>
<include refid="searchCondition"/>
</where>
</select>
<insert id="insertProdOrder" parameterType="ProdOrder" useGeneratedKeys="true" keyProperty="id">
insert into bst_prod_order
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -133,6 +152,14 @@
<if test="verifiedBaseNum != null">verified_base_num,</if>
<if test="erpBaseUnitId != null">erp_base_unit_id,</if>
<if test="syncTime != null">sync_time,</if>
<if test="deptId != null">dept_id,</if>
<if test="materialNumber != null">material_number,</if>
<if test="materialCategory != null">material_category,</if>
<if test="materialSize != null">material_size,</if>
<if test="materialSurface != null">material_surface,</if>
<if test="materialCover != null">material_cover,</if>
<if test="unitName != null">unit_name,</if>
<if test="baseUnitName != null">base_unit_name,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="erpId != null and erpId != ''">#{erpId},</if>
@ -160,6 +187,14 @@
<if test="verifiedBaseNum != null">#{verifiedBaseNum},</if>
<if test="erpBaseUnitId != null">#{erpBaseUnitId},</if>
<if test="syncTime != null">#{syncTime},</if>
<if test="deptId != null">#{deptId},</if>
<if test="materialNumber != null">#{materialNumber},</if>
<if test="materialCategory != null">#{materialCategory},</if>
<if test="materialSize != null">#{materialSize},</if>
<if test="materialSurface != null">#{materialSurface},</if>
<if test="materialCover != null">#{materialCover},</if>
<if test="unitName != null">#{unitName},</if>
<if test="baseUnitName != null">#{baseUnitName},</if>
</trim>
</insert>
@ -203,6 +238,14 @@
<if test="data.verifiedBaseNum != null">verified_base_num = #{data.verifiedBaseNum},</if>
<if test="data.erpBaseUnitId != null">erp_base_unit_id = #{data.erpBaseUnitId},</if>
<if test="data.syncTime != null">sync_time = #{data.syncTime},</if>
<if test="data.deptId != null">dept_id = #{data.deptId},</if>
<if test="data.materialNumber != null">material_number = #{data.materialNumber},</if>
<if test="data.materialCategory != null">material_category = #{data.materialCategory},</if>
<if test="data.materialSize != null">material_size = #{data.materialSize},</if>
<if test="data.materialSurface != null">material_surface = #{data.materialSurface},</if>
<if test="data.materialCover != null">material_cover = #{data.materialCover},</if>
<if test="data.unitName != null">unit_name = #{data.unitName},</if>
<if test="data.baseUnitName != null">base_unit_name = #{data.baseUnitName},</if>
</sql>
<delete id="deleteProdOrderById" parameterType="Long">

View File

@ -86,4 +86,12 @@ public interface ProdOrderService
* @param num 增加数量
*/
int addVerifiedBaseNum(Long orderId, BigDecimal num);
/**
* 查询简单列表
*
* @param query 查询条件
* @param fields 字段列表
*/
List<ProdOrderVO> selectSimpleList(ProdOrderQuery query, String ...fields);
}

View File

@ -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<String> erpWorkShopIds = new HashSet<>(); // ERP生产车间ID
Set<String> erpMaterialIds = new HashSet<>(); // ERP物料ID
Set<String> 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<SysDept> 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<MaterialVO> 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<UnitVO> 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;
}
}

View File

@ -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<ProdOrderVO> selectSimpleList(ProdOrderQuery query, String ...fields) {
if (fields == null) {
return Collections.emptyList();
}
return prodOrderMapper.selectSimpleList(query, Arrays.asList(fields));
}
/**
* 新增或修改
*/

View File

@ -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

View File

@ -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<ReportProdBO> productList;
}

View File

@ -55,4 +55,11 @@ public enum ReportStatus {
public static List<String> canEdit() {
return asList(WAIT_SUBMIT, REJECT);
}
/**
* 允许重置审核员的状态
*/
public static List<String> canResetVerify() {
return asList(REJECT);
}
}

View File

@ -67,4 +67,8 @@ public interface ReportMapper
*/
int updateByQuery(@Param("data") Report data, @Param("query") ReportQuery query);
/**
* 重置审核信息
*/
int resetVerifyInfoByQuery(@Param("query") ReportQuery query);
}

View File

@ -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 @@
</where>
</update>
<update id="resetVerifyInfoByQuery">
update bst_report br
set br.verify_id = null,
br.verify_By = null,
br.verify_time = null,
br.verify_remark = null
<where>
<include refid="searchCondition"/>
</where>
</update>
<sql id="updateColumns">
<if test="data.deptId != null">dept_id = #{data.deptId},</if>
<if test="data.status != null and data.status != ''">`status` = #{data.status},</if>

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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<ReportProdBO> 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<ReportProdBO> 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;
}
}

View File

@ -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) {

View File

@ -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<ReportOrderProdVO> 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<ReportUserProdVO> 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<SysUserVO> 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<ReportProdBO> productList) {
@ -101,7 +141,8 @@ public class ReportValidatorImpl implements ReportValidator {
}
// 员工是否当前用户可选
// TODO 员工是否当前报表可选在当前报表的部门 or 排班在当前报表部门
List<ReportUserProdBO> 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<ReportOrderProdBO> 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<ProdOrderVO> 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, "部门不存在");
}
}

View File

@ -34,6 +34,9 @@ public class ReportOrderProdVO extends ReportOrderProd {
@ApiModelProperty("订单未入库数量")
private BigDecimal orderErpNoStockInQty;
@ApiModelProperty("订单生产部门ID")
private Long orderDeptId;
@ApiModelProperty("订单单位名称")
private String unitName;

View File

@ -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,

View File

@ -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<ReportUserProdVO> userProdList;
@ApiModelProperty("订单产量列表")
@Valid
private List<ReportOrderProdVO> orderProdList;
@ApiModelProperty("工序部门ID")
private Long priceDeptId;
}

View File

@ -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
</sql>
<sql id="searchCondition">

View File

@ -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<ReportUserProdBO> 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<ReportUserProdBO> userProdList = new ArrayList<>();

View File

@ -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
{
/**
* 查询调班

View File

@ -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 {
}

View File

@ -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<Long> shiftIds) {
return shiftMapper.logicDel(shiftIds);
}
}

View File

@ -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 {
}

View File

@ -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<String> erpIds;
}

View File

@ -22,6 +22,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.erpForbidStatus != null and query.erpForbidStatus != ''"> and bu.erp_forbid_status = #{query.erpForbidStatus}</if>
<if test="query.erpName != null and query.erpName != ''"> and bu.erp_name like concat('%', #{query.erpName}, '%')</if>
<if test="query.erpNumber != null and query.erpNumber != ''"> and bu.erp_number like concat('%', #{query.erpNumber}, '%')</if>
<if test="query.erpIds != null and query.erpIds.size() > 0">
and bu.erp_id in
<foreach item="item" collection="query.erpIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
${query.params.dataScope}
</sql>

View File

@ -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<UnitVO> selectByErpIds(Collection<String> erpIds);
}

View File

@ -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<UnitVO> selectByErpIds(Collection<String> 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 {

View File

@ -35,6 +35,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item}
</foreach>
</if>
<if test="erpIds != null and erpIds.size() > 0">
AND erp_id in
<foreach collection="erpIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
order by d.parent_id, d.order_num

View File

@ -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));
}

View File

@ -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;