修改了部分数据结构

master
mula.liu 2025-04-11 15:32:20 +08:00
commit 23afe6f58b
6 changed files with 159 additions and 47 deletions

View File

@ -1,6 +1,8 @@
package com.ruoyi.sip.controller;
import java.util.List;
import com.ruoyi.sip.domain.OrderList;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -113,7 +115,6 @@ public class OrderInfoController extends BaseController
{
return toAjax(orderInfoService.updateOrderInfo(orderInfo));
}
/**
*
*/

View File

@ -41,6 +41,8 @@ public class OrderList extends BaseEntity
@Excel(name = "总价")
private BigDecimal amount;
private String operateFlag;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
@ -138,6 +140,14 @@ public class OrderList extends BaseEntity
return deletedAt;
}
public String getOperateFlag() {
return operateFlag;
}
public void setOperateFlag(String operateFlag) {
this.operateFlag = operateFlag;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -84,4 +84,17 @@ public interface OrderInfoMapper
* @return
*/
public int deleteOrderListByOrderId(Long id);
/**
*
* @param id
* @return
*/
int logicRemoveListById(List<OrderList> orderListList);
/**
*
* @param orderListList
*/
void updateListBatch(List<OrderList> orderListList);
}

View File

@ -2,6 +2,7 @@ package com.ruoyi.sip.service;
import java.util.List;
import com.ruoyi.sip.domain.OrderInfo;
import com.ruoyi.sip.domain.OrderList;
/**
* Service

View File

@ -4,6 +4,9 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Map;
import java.util.stream.Collectors;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.sip.domain.OrderList;
@ -73,8 +76,26 @@ public class OrderInfoServiceImpl implements IOrderInfoService
@Override
public int updateOrderInfo(OrderInfo orderInfo)
{
orderInfoMapper.deleteOrderListByOrderId(orderInfo.getId());
insertOrderList(orderInfo);
List<OrderList> orderListList = orderInfo.getOrderListList();
Map<String, List<OrderList>> operateMap =
orderListList.stream().collect(Collectors.groupingBy(OrderList::getOperateFlag));
//新增
List<OrderList> addList = operateMap.get("0");
if (addList!=null && !addList.isEmpty()){
orderInfoMapper.batchOrderList(addList);
}
//更新
List<OrderList> updateList = operateMap.get("1");
if (updateList!=null && !updateList.isEmpty()){
orderInfoMapper.updateListBatch(updateList);
}
//删除
List<OrderList> deleteList = operateMap.get("2");
if (deleteList!=null && !deleteList.isEmpty()){
orderInfoMapper.logicRemoveListById(deleteList);
}
return orderInfoMapper.updateOrderInfo(orderInfo);
}

View File

@ -1,62 +1,101 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.sip.mapper.OrderInfoMapper">
<resultMap type="OrderInfo" id="OrderInfoResult">
<result property="id" column="id" />
<result property="projectCode" column="project_code" />
<result property="orderCode" column="order_code" />
<result property="versionCode" column="version_code" />
<result property="orderName" column="order_name" />
<result property="customerName" column="customer_name" />
<result property="customerContact" column="customer_contact" />
<result property="customerPhone" column="customer_phone" />
<result property="customerEmail" column="customer_email" />
<result property="orderType" column="order_type" />
<result property="orderDept" column="order_dept" />
<result property="partenerDept" column="partener_dept" />
<result property="orderDate" column="order_date" />
<result property="status" column="status" />
<result property="remark" column="remark" />
<result property="createdAt" column="created_at" />
<result property="updatedAt" column="updated_at" />
<result property="deletedAt" column="deleted_at" />
<result property="id" column="id"/>
<result property="projectCode" column="project_code"/>
<result property="orderCode" column="order_code"/>
<result property="versionCode" column="version_code"/>
<result property="orderName" column="order_name"/>
<result property="customerName" column="customer_name"/>
<result property="customerContact" column="customer_contact"/>
<result property="customerPhone" column="customer_phone"/>
<result property="customerEmail" column="customer_email"/>
<result property="orderType" column="order_type"/>
<result property="orderDept" column="order_dept"/>
<result property="partenerDept" column="partener_dept"/>
<result property="orderDate" column="order_date"/>
<result property="status" column="status"/>
<result property="remark" column="remark"/>
<result property="createdAt" column="created_at"/>
<result property="updatedAt" column="updated_at"/>
<result property="deletedAt" column="deleted_at"/>
</resultMap>
<resultMap id="OrderInfoOrderListResult" type="OrderInfo" extends="OrderInfoResult">
<collection property="orderListList" ofType="OrderList" column="id" select="selectOrderListList" />
<collection property="orderListList" ofType="OrderList" column="id" select="selectOrderListList"/>
</resultMap>
<resultMap type="OrderList" id="OrderListResult">
<result property="id" column="id" />
<result property="orderId" column="order_id" />
<result property="productCode" column="product_code" />
<result property="quantity" column="quantity" />
<result property="price" column="price" />
<result property="amount" column="amount" />
<result property="remark" column="remark" />
<result property="createdAt" column="created_at" />
<result property="id" column="id"/>
<result property="orderId" column="order_id"/>
<result property="productCode" column="product_code"/>
<result property="quantity" column="quantity"/>
<result property="price" column="price"/>
<result property="amount" column="amount"/>
<result property="remark" column="remark"/>
<result property="createdAt" column="created_at"/>
<result property="updatedAt" column="updated_at"/>
<result property="deletedAt" column="deleted_at"/>
</resultMap>
<sql id="selectOrderInfoVo">
select id, project_code, order_code, version_code, order_name, customer_name, customer_contact, customer_phone, customer_email, order_type, order_dept, partener_dept, order_date, status, remark, created_at, updated_at, deleted_at from order_info
select id,
project_code,
order_code,
version_code,
order_name,
customer_name,
customer_contact,
customer_phone,
customer_email,
order_type,
order_dept,
partener_dept,
order_date,
status,
remark,
created_at,
updated_at,
deleted_at
from order_info
</sql>
<select id="selectOrderInfoList" parameterType="OrderInfo" resultMap="OrderInfoResult">
<include refid="selectOrderInfoVo"/>
<where>
and status=0
<if test="orderCode != null and orderCode != ''"> and order_code like concat('%', #{orderCode}, '%')</if>
<if test="orderName != null and orderName != ''"> and order_name like concat('%', #{orderName}, '%')</if>
<if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
<if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
and status=0
<if test="orderCode != null and orderCode != ''">and order_code like concat('%', #{orderCode}, '%')</if>
<if test="orderName != null and orderName != ''">and order_name like concat('%', #{orderName}, '%')</if>
<if test="customerName != null and customerName != ''">and customer_name like concat('%', #{customerName},
'%')
</if>
<if test="orderType != null and orderType != ''">and order_type = #{orderType}</if>
</where>
</select>
<select id="selectOrderInfoById" parameterType="Long" resultMap="OrderInfoOrderListResult">
select id, project_code, order_code, version_code, order_name, customer_name, customer_contact, customer_phone, customer_email, order_type, order_dept, partener_dept, order_date, status, remark, created_at, updated_at, deleted_at
select id,
project_code,
order_code,
version_code,
order_name,
customer_name,
customer_contact,
customer_phone,
customer_email,
order_type,
order_dept,
partener_dept,
order_date,
status,
remark,
created_at,
updated_at,
deleted_at
from order_info
where id = #{id}
</select>
@ -85,7 +124,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">status,</if>
<if test="remark != null">remark,</if>
created_at,status,
</trim>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="projectCode != null">#{projectCode},</if>
<if test="orderCode != null and orderCode != ''">#{orderCode},</if>
@ -102,7 +141,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">#{status},</if>
<if test="remark != null">#{remark},</if>
NOW(),0
</trim>
</trim>
</insert>
<update id="updateOrderInfo" parameterType="OrderInfo">
@ -126,9 +165,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
where id = #{id}
</update>
<update id="logicRemoveListById">
update order_list set deleted_at=NOW(), status=1 where id in
<foreach item="item" index="index" collection="list" open="(" close=")" separator=",">
#{item.id}
</foreach>
</update>
<update id="updateListBatch">
<foreach item="item" index="index" collection="list" separator=";">
update order_list
<trim prefix="SET" suffixOverrides=",">
<if test="productId != null">product_id = #{productId},</if>
<if test="quantity != null ">quantity = #{quantity},</if>
<if test="price != null">price = #{price},</if>
<if test="amount != null">amount = #{amount},</if>
<if test="remark != null and remark!=''">remark = #{remark},</if>
updated_at = NOW(),
</trim>
where id = #{item.id}
</foreach>
</update>
<delete id="deleteOrderInfoById" parameterType="Long">
update order_info set deleted_at=NOW(), status=1 where id = #{id}
update order_info
set deleted_at=NOW(),
status=1
where id = #{id}
</delete>
<delete id="deleteOrderInfoByIds" parameterType="String">
@ -137,16 +201,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<delete id="deleteOrderListByOrderIds" parameterType="String">
delete from order_list where order_id in
delete from order_list where order_id in
<foreach item="orderId" collection="array" open="(" separator="," close=")">
#{orderId}
</foreach>
</delete>
<delete id="deleteOrderListByOrderId" parameterType="Long">
delete from order_list where order_id = #{orderId}
delete
from order_list
where order_id = #{orderId}
</delete>
<insert id="batchOrderList">