提交部署

This commit is contained in:
磷叶 2024-12-21 15:14:54 +08:00
parent 911a2017f3
commit 709073c4b8
20 changed files with 177 additions and 16 deletions

View File

@ -61,8 +61,8 @@ public class SysDept extends BaseEntity
/** 父部门名称 */
private String parentName;
@ApiModelProperty("负责人ID")
private Long leaderId;
@ApiModelProperty("负责人ID列表")
private List<Long> leaderIds;
@Excel(name = "负责工序")
@ApiModelProperty("负责工序")

View File

@ -73,4 +73,6 @@ public enum BusinessType
SUBMIT,
// 入库
STOCK_IN,
// 完工
FINISH,
}

View File

@ -51,6 +51,10 @@ public class DataScopeUtil {
* 仅本人数据权限
*/
public static final String DATA_SCOPE_SELF = "5";
/**
* 负责部门数据权限
*/
public static final String DATA_SCOPE_LEADER_DEPT = "6";
public static String dataScope(String deptAlias, String userAlias, boolean needScope) {
if (needScope) {
@ -126,6 +130,11 @@ public class DataScopeUtil {
sqlString.append(" OR 1=0 ");
}
}
// 负责部门数据权限
else if (DATA_SCOPE_LEADER_DEPT.equals(dataScope)) {
String sql = getForeachSql(" OR {}.dept_id in ( SELECT dept_id FROM sys_dept WHERE find_in_set({}, leader_ids) )", deptList, user.getUserId());
sqlString.append(sql);
}
conditions.add(dataScope);
}

View File

@ -44,4 +44,9 @@ public enum OrderStatus {
public static List<String> asList(OrderStatus ...statuses) {
return CollectionUtils.map(OrderStatus::getStatus, statuses);
}
// 允许上报产量的状态
public static List<String> canAddStore() {
return asList(RELEASED);
}
}

View File

@ -77,4 +77,9 @@ public interface OrderService
* 逻辑删除
*/
int logicDel(Long id);
/**
* 完成订单
*/
int finish(Long id);
}

View File

@ -6,6 +6,7 @@ import com.ruoyi.bst.order.domain.OrderQuery;
import com.ruoyi.bst.order.domain.OrderVO;
import com.ruoyi.bst.order.domain.enums.OrderStatus;
import com.ruoyi.bst.order.mapper.OrderMapper;
import com.ruoyi.bst.order.service.OrderAssembler;
import com.ruoyi.bst.order.service.OrderService;
import com.ruoyi.bst.order.service.OrderValidator;
import com.ruoyi.bst.orderProd.domain.OrderProd;
@ -25,6 +26,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.support.TransactionTemplate;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@ -52,6 +55,9 @@ public class OrderServiceImpl implements OrderService
@Autowired
private IProdProcessService prodProcessService;
@Autowired
private OrderAssembler orderAssembler;
/**
* 查询生产订单
*
@ -214,6 +220,28 @@ public class OrderServiceImpl implements OrderService
return result == null ? 0 : result;
}
@Override
public int finish(Long id) {
if (id == null) {
return 0;
}
// 校验
OrderVO old = selectOrderById(id);
ServiceUtil.assertion(old == null, "待完工的订单不存在");
ServiceUtil.assertion(!OrderStatus.canFinished().contains(old.getStatus()), "当前订单状态不允许完工");
orderAssembler.assembleProgress(Collections.singletonList(old));
ServiceUtil.assertion(old.getProgress().compareTo(new BigDecimal("100")) < 0, "当前订单进度:%s%%暂不满足完工条件100%%", old.getProgress());
// 更新订单状态
Order data = new Order();
data.setStatus(OrderStatus.FINISHED.getStatus());
OrderQuery query = new OrderQuery();
query.setId(id);
query.setStatusList(OrderStatus.canFinished());
return updateByQuery(data, query);
}
private int updateByQuery(Order data, OrderQuery query) {
return orderMapper.updateByQuery(data, query);
}

View File

@ -20,4 +20,7 @@ public class ProdProcessQuery extends ProdProcessVO{
@ApiModelProperty("ID列表")
private List<Long> ids;
@ApiModelProperty("订单状态列表")
private List<String> orderStatusList;
}

View File

@ -19,6 +19,9 @@ public class ProdProcessVO extends ProdProcess{
@ApiModelProperty("订单编号")
private String orderNo;
@ApiModelProperty("订单状态")
private String orderStatus;
@ApiModelProperty("生产车间名称")
private String deptName;

View File

@ -25,6 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bop.name as order_prod_name,
bop.order_id as order_id,
bo.order_no as order_no,
bo.status as order_status,
sd.dept_name as dept_name
from bst_prod_process bpp
left join bst_order_prod bop on bop.id = bpp.order_prod_id
@ -49,6 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.orderProdName != null and query.orderProdName != ''"> and bop.name like concat('%', #{query.orderProdName}, '%')</if>
<if test="query.deptName != null and query.deptName != ''"> and sd.dept_name like concat('%', #{query.deptName}, '%')</if>
<if test="query.orderId != null">and bop.order_id = #{query.orderId}</if>
<if test="query.orderStatus != null">and bo.status = #{query.orderStatus}</if>
<if test="query.orderProdIds != null and query.orderProdIds.size() > 0">
and bpp.order_prod_id in
<foreach collection="query.orderProdIds" item="item" open="(" close=")" separator=",">
@ -67,6 +69,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item}
</foreach>
</if>
<if test="query.orderStatusList != null and query.orderStatusList.size() > 0">
and bo.status in
<foreach collection="query.orderStatusList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
${query.params.dataScope}
</sql>

View File

@ -25,6 +25,9 @@ public class StoreVO extends Store{
@ApiModelProperty("工序部门ID")
private Long processDeptId;
@ApiModelProperty("是否最终工序")
private Boolean processIsEnd;
@ApiModelProperty("负责工序")
private String deptProcess;

View File

@ -26,6 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bop.order_id as order_id,
bpp.dept_id as process_dept_id,
bpp.dept_process as dept_process,
bpp.is_end as process_is_end,
sd.dept_name as process_dept_name
from bst_store bs
left join bst_prod_process bpp on bpp.id = bs.process_id

View File

@ -0,0 +1,16 @@
package com.ruoyi.bst.store.service;
import com.ruoyi.bst.store.domain.Store;
/**
* @author wjh
* 2024/12/21
*/
public interface StoreValidator {
/**
* 新增前校验
*/
void checkBefore(Store data);
}

View File

@ -7,6 +7,7 @@ import com.ruoyi.bst.store.domain.enums.StoreGroupBy;
import com.ruoyi.bst.store.domain.enums.StoreStatus;
import com.ruoyi.bst.store.mapper.StoreMapper;
import com.ruoyi.bst.store.service.IStoreService;
import com.ruoyi.bst.store.service.StoreValidator;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServiceUtil;
@ -32,6 +33,9 @@ public class StoreServiceImpl implements IStoreService
@Autowired
private StoreMapper storeMapper;
@Autowired
private StoreValidator storeValidator;
@Autowired
private TransactionTemplate transactionTemplate;
@ -66,8 +70,10 @@ public class StoreServiceImpl implements IStoreService
* @return 结果
*/
@Override
public int insertStore(Store store)
{
public int insertStore(Store store) {
// 校验数据
storeValidator.checkBefore(store);
store.setCreateTime(DateUtils.getNowDate());
return storeMapper.insertStore(store);
}

View File

@ -0,0 +1,38 @@
package com.ruoyi.bst.store.service.impl;
import com.ruoyi.bst.order.domain.enums.OrderStatus;
import com.ruoyi.bst.prodProcess.domain.ProdProcessVO;
import com.ruoyi.bst.prodProcess.service.IProdProcessService;
import com.ruoyi.bst.store.domain.Store;
import com.ruoyi.bst.store.service.StoreValidator;
import com.ruoyi.common.utils.ServiceUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author wjh
* 2024/12/21
*/
@Service
public class StoreValidatorImpl implements StoreValidator {
@Autowired
private IProdProcessService prodProcessService;
/**
* 新增前校验
*
* @param data
*/
@Override
public void checkBefore(Store data) {
ServiceUtil.assertion(data == null, "参数错误");
// 校验工序
ServiceUtil.assertion(data.getProcessId() == null, "工序不允许为空");
ProdProcessVO process = prodProcessService.selectProdProcessById(data.getProcessId());
ServiceUtil.assertion(process == null, "待上报的工序不存在");
ServiceUtil.assertion(!OrderStatus.canAddStore().contains(process.getOrderStatus()), "当前工序的订单状态不允许上报");
}
}

View File

@ -24,4 +24,10 @@ public class SysDeptQuery extends SysDeptVO {
@ApiModelProperty("排除部门ID列表")
private List<Long> excludeDeptIds;
@ApiModelProperty("负责人名称")
private String leaderName;
@ApiModelProperty("负责人ID")
private Long leaderId;
}

View File

@ -1,9 +1,12 @@
package com.ruoyi.system.dept.domain;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.system.user.domain.SysUserVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author wjh
* 2024/12/19
@ -11,6 +14,7 @@ import lombok.Data;
@Data
public class SysDeptVO extends SysDept {
@ApiModelProperty("负责人名称")
private String leaderName;
@ApiModelProperty("负责人列表")
private List<SysUserVO> leaderList;
}

View File

@ -4,7 +4,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.dept.mapper.SysDeptMapper">
<resultMap type="SysDeptVO" id="SysDeptResult" autoMapping="true"/>
<resultMap type="SysDeptVO" id="SysDeptResult" autoMapping="true">
<id column="dept_id" property="deptId"/>
<result property="leaderIds" column="leader_ids" typeHandler="com.ruoyi.common.mybatis.typehandler.LongSplitListTypeHandler"/>
<collection property="leaderList" javaType="java.util.List" ofType="SysUserVO">
<id column="leader_id" property="userId"/>
<result column="leader_name" property="nickName"/>
</collection>
</resultMap>
<sql id="selectDeptVo">
select
@ -22,13 +29,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
d.create_time,
d.erp_id,
d.erp_number,
d.leader_id,
d.leader_ids,
d.process,
p.dept_name as parent_name,
l.user_id as leader_id,
l.nick_name as leader_name
from sys_dept d
left join sys_dept p on d.parent_id = p.dept_id
left join sys_user l on l.user_id = d.leader_id
left join sys_user l on find_in_set(l.user_id, d.leader_ids)
</sql>
<select id="selectDeptList" parameterType="SysDeptQuery" resultMap="SysDeptResult">
@ -50,14 +58,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND d.erp_id = #{erpId}
</if>
<if test="leaderId != null">
AND d.leader_id = #{leaderId}
</if>
<if test="process != null and process != ''">
AND d.process like concat('%', #{process}, '%')
AND l.user_id = #{leaderId}
</if>
<if test="leaderName != null and leaderName != ''">
AND l.nick_name like concat('%', #{leaderName}, '%')
</if>
<if test="process != null and process != ''">
AND d.process like concat('%', #{process}, '%')
</if>
<if test="deptNames != null and deptNames.size() > 0">
AND d.dept_name in
<foreach collection="deptNames" item="item" open="(" separator="," close=")">
@ -140,7 +148,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="erpId != null and erpId != ''">erp_id,</if>
<if test="erpNumber != null and erpNumber != ''">erp_number,</if>
<if test="leaderId != null">leader_id,</if>
<if test="leaderIds != null">leader_ids,</if>
<if test="process != null">process,</if>
create_time
)values(
@ -156,7 +164,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="erpId != null and erpId != ''">#{erpId},</if>
<if test="erpNumber != null and erpNumber != ''">#{erpNumber},</if>
<if test="leaderId != null">#{leaderId},</if>
<if test="leaderIds != null">#{leaderIds,typeHandler=com.ruoyi.common.mybatis.typehandler.LongSplitListTypeHandler},</if>
<if test="process != null">#{process},</if>
sysdate()
)
@ -176,7 +184,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="erpId != null and erpId != ''">erp_id = #{erpId},</if>
<if test="erpNumber != null and erpNumber != ''">erp_number = #{erpNumber},</if>
<if test="leaderId != null">leader_id = #{leaderId},</if>
<if test="leaderIds != null">leader_ids = #{leaderIds,typeHandler=com.ruoyi.common.mybatis.typehandler.LongSplitListTypeHandler},</if>
<if test="process != null">`process` = #{process},</if>
update_time = sysdate()
</set>

View File

@ -107,6 +107,17 @@ public class OrderController extends BaseController
return toAjax(orderService.editOrder(bo));
}
/**
* 完工
*/
@PreAuthorize("@ss.hasPermi('bst:order:finish')")
@Log(title = "生产订单", businessType = BusinessType.FINISH)
@PutMapping("/{id}/finish")
public AjaxResult finish(@PathVariable Long id)
{
return toAjax(orderService.finish(id));
}
/**
* 删除生产订单
*/
@ -117,4 +128,5 @@ public class OrderController extends BaseController
{
return toAjax(orderService.logicDel(id));
}
}

View File

@ -5,6 +5,7 @@ import com.ruoyi.bst.prodProcess.domain.ProdProcessQuery;
import com.ruoyi.bst.prodProcess.domain.ProdProcessVO;
import com.ruoyi.bst.prodProcess.service.IProdProcessService;
import com.ruoyi.bst.prodProcess.service.ProdProcessAssembler;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
@ -39,6 +40,7 @@ public class ProdProcessController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('bst:prodProcess:list')")
@GetMapping("/list")
@DataScope(deptAlias = "sd")
public TableDataInfo list(ProdProcessQuery query)
{
startPage();

View File

@ -6,6 +6,7 @@ import com.ruoyi.bst.store.domain.StoreVO;
import com.ruoyi.bst.store.domain.dto.StoreStockInDTO;
import com.ruoyi.bst.store.service.IStoreService;
import com.ruoyi.bst.store.service.StoreConverter;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
@ -42,6 +43,7 @@ public class StoreController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('bst:store:list')")
@GetMapping("/list")
@DataScope(deptAlias = "sd")
public TableDataInfo list(StoreQuery query)
{
startPage();