parent
877fd28460
commit
8899392143
@ -0,0 +1,76 @@ |
|||||||
|
package com.dxhy.order.baseservice.module.commodity.dao; |
||||||
|
|
||||||
|
import com.dxhy.order.baseservice.module.commodity.model.CommodityCodeModifyLog; |
||||||
|
import com.dxhy.order.baseservice.module.commodity.model.GroupCommodity; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* (CommodityCodeModifyLog)表数据库访问层 |
||||||
|
* |
||||||
|
* @author 巩权林 |
||||||
|
* @since 2023-03-20 15:31:37 |
||||||
|
*/ |
||||||
|
public interface CommodityCodeModifyLogDao { |
||||||
|
|
||||||
|
/** |
||||||
|
* 通过ID查询单条数据 |
||||||
|
* |
||||||
|
* @param id 主键 |
||||||
|
* @return 实例对象 |
||||||
|
*/ |
||||||
|
CommodityCodeModifyLog queryById(String id); |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询指定行数据 |
||||||
|
* |
||||||
|
* @param offset 查询起始位置 |
||||||
|
* @param limit 查询条数 |
||||||
|
* @return 对象列表 |
||||||
|
*/ |
||||||
|
List<CommodityCodeModifyLog> queryAllByLimit(@Param("offset") int offset, @Param("limit") int limit); |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 通过实体作为筛选条件查询 |
||||||
|
* |
||||||
|
* @param commodityCodeModifyLog 实例对象 |
||||||
|
* @return 对象列表 |
||||||
|
*/ |
||||||
|
List<CommodityCodeModifyLog> queryAll(CommodityCodeModifyLog commodityCodeModifyLog); |
||||||
|
|
||||||
|
/** |
||||||
|
* 新增数据 |
||||||
|
* |
||||||
|
* @param commodityCodeModifyLog 实例对象 |
||||||
|
* @return 影响行数 |
||||||
|
*/ |
||||||
|
int insert(CommodityCodeModifyLog commodityCodeModifyLog); |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 批量插入 |
||||||
|
* |
||||||
|
* @param commodityCodeModifyLog |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
int batchInsert(List<CommodityCodeModifyLog> commodityCodeModifyLog); |
||||||
|
|
||||||
|
/** |
||||||
|
* 修改数据 |
||||||
|
* |
||||||
|
* @param commodityCodeModifyLog 实例对象 |
||||||
|
* @return 影响行数 |
||||||
|
*/ |
||||||
|
int update(CommodityCodeModifyLog commodityCodeModifyLog); |
||||||
|
|
||||||
|
/** |
||||||
|
* 通过主键删除数据 |
||||||
|
* |
||||||
|
* @param id 主键 |
||||||
|
* @return 影响行数 |
||||||
|
*/ |
||||||
|
int deleteById(String id); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,104 @@ |
|||||||
|
package com.dxhy.order.baseservice.module.commodity.model; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Description |
||||||
|
* @Author 巩权林 |
||||||
|
* @Date 2023/3/20 15:33 |
||||||
|
**/ |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
/** |
||||||
|
* (CommodityCodeModifyLog)实体类 |
||||||
|
* |
||||||
|
* @author 巩权林 |
||||||
|
* @since 2023-03-20 15:31:30 |
||||||
|
*/ |
||||||
|
public class CommodityCodeModifyLog implements Serializable { |
||||||
|
private static final long serialVersionUID = -85350041852113526L; |
||||||
|
|
||||||
|
private String id; |
||||||
|
/** |
||||||
|
* 修改的物料编码id |
||||||
|
*/ |
||||||
|
private String commodityCodeId; |
||||||
|
/** |
||||||
|
* 修改的字段属性,key |
||||||
|
*/ |
||||||
|
private String key; |
||||||
|
/** |
||||||
|
* 原值 |
||||||
|
*/ |
||||||
|
private String originValue; |
||||||
|
/** |
||||||
|
* 新值 |
||||||
|
*/ |
||||||
|
private String newValue; |
||||||
|
/** |
||||||
|
* 修改人 |
||||||
|
*/ |
||||||
|
private String modifyUserId; |
||||||
|
/** |
||||||
|
* 修改时间 |
||||||
|
*/ |
||||||
|
private Date modifyTime; |
||||||
|
|
||||||
|
|
||||||
|
public String getId() { |
||||||
|
return id; |
||||||
|
} |
||||||
|
|
||||||
|
public void setId(String id) { |
||||||
|
this.id = id; |
||||||
|
} |
||||||
|
|
||||||
|
public String getCommodityCodeId() { |
||||||
|
return commodityCodeId; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCommodityCodeId(String commodityCodeId) { |
||||||
|
this.commodityCodeId = commodityCodeId; |
||||||
|
} |
||||||
|
|
||||||
|
public String getKey() { |
||||||
|
return key; |
||||||
|
} |
||||||
|
|
||||||
|
public void setKey(String key) { |
||||||
|
this.key = key; |
||||||
|
} |
||||||
|
|
||||||
|
public String getOriginValue() { |
||||||
|
return originValue; |
||||||
|
} |
||||||
|
|
||||||
|
public void setOriginValue(String originValue) { |
||||||
|
this.originValue = originValue; |
||||||
|
} |
||||||
|
|
||||||
|
public String getNewValue() { |
||||||
|
return newValue; |
||||||
|
} |
||||||
|
|
||||||
|
public void setNewValue(String newValue) { |
||||||
|
this.newValue = newValue; |
||||||
|
} |
||||||
|
|
||||||
|
public String getModifyUserId() { |
||||||
|
return modifyUserId; |
||||||
|
} |
||||||
|
|
||||||
|
public void setModifyUserId(String modifyUserId) { |
||||||
|
this.modifyUserId = modifyUserId; |
||||||
|
} |
||||||
|
|
||||||
|
public Date getModifyTime() { |
||||||
|
return modifyTime; |
||||||
|
} |
||||||
|
|
||||||
|
public void setModifyTime(Date modifyTime) { |
||||||
|
this.modifyTime = modifyTime; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,63 @@ |
|||||||
|
package com.dxhy.order.baseservice.module.commodity.service; |
||||||
|
|
||||||
|
import com.dxhy.order.baseservice.module.commodity.model.CommodityCodeEntity; |
||||||
|
import com.dxhy.order.baseservice.module.commodity.model.CommodityCodeModifyLog; |
||||||
|
import com.dxhy.order.baseservice.module.commodity.model.GroupCommodity; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* (CommodityCodeModifyLog)表服务接口 |
||||||
|
* |
||||||
|
* @author 巩权林 |
||||||
|
* @since 2023-03-20 15:31:37 |
||||||
|
*/ |
||||||
|
public interface CommodityCodeModifyLogService { |
||||||
|
|
||||||
|
public int saveCommodityCodeDifferenceBetween2(CommodityCodeEntity originOne, CommodityCodeEntity newOne, String modifyUserId); |
||||||
|
|
||||||
|
|
||||||
|
public |
||||||
|
|
||||||
|
/** |
||||||
|
* 通过ID查询单条数据 |
||||||
|
* |
||||||
|
* @param id 主键 |
||||||
|
* @return 实例对象 |
||||||
|
*/ |
||||||
|
CommodityCodeModifyLog queryById(String id); |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询多条数据 |
||||||
|
* |
||||||
|
* @param offset 查询起始位置 |
||||||
|
* @param limit 查询条数 |
||||||
|
* @return 对象列表 |
||||||
|
*/ |
||||||
|
List<CommodityCodeModifyLog> queryAllByLimit(int offset, int limit); |
||||||
|
|
||||||
|
/** |
||||||
|
* 新增数据 |
||||||
|
* |
||||||
|
* @param commodityCodeModifyLog 实例对象 |
||||||
|
* @return 实例对象 |
||||||
|
*/ |
||||||
|
CommodityCodeModifyLog insert(CommodityCodeModifyLog commodityCodeModifyLog); |
||||||
|
|
||||||
|
/** |
||||||
|
* 修改数据 |
||||||
|
* |
||||||
|
* @param commodityCodeModifyLog 实例对象 |
||||||
|
* @return 实例对象 |
||||||
|
*/ |
||||||
|
CommodityCodeModifyLog update(CommodityCodeModifyLog commodityCodeModifyLog); |
||||||
|
|
||||||
|
/** |
||||||
|
* 通过主键删除数据 |
||||||
|
* |
||||||
|
* @param id 主键 |
||||||
|
* @return 是否成功 |
||||||
|
*/ |
||||||
|
boolean deleteById(String id); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,132 @@ |
|||||||
|
package com.dxhy.order.baseservice.module.commodity.service.impl; |
||||||
|
|
||||||
|
import com.dxhy.order.baseservice.module.base.service.BaseService; |
||||||
|
import com.dxhy.order.baseservice.module.commodity.dao.CommodityCodeModifyLogDao; |
||||||
|
import com.dxhy.order.baseservice.module.commodity.model.CommodityCodeEntity; |
||||||
|
import com.dxhy.order.baseservice.module.commodity.model.CommodityCodeModifyLog; |
||||||
|
import com.dxhy.order.baseservice.module.commodity.model.GroupCommodity; |
||||||
|
import com.dxhy.order.baseservice.module.commodity.service.CommodityCodeModifyLogService; |
||||||
|
import org.apache.commons.lang3.StringUtils; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import java.lang.reflect.Field; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* (CommodityCodeModifyLog)表服务实现类 |
||||||
|
* |
||||||
|
* @author 巩权林 |
||||||
|
* @since 2023-03-20 15:31:37 |
||||||
|
*/ |
||||||
|
@Service("commodityCodeModifyLogService") |
||||||
|
public class CommodityCodeModifyLogServiceImpl implements CommodityCodeModifyLogService { |
||||||
|
@Resource |
||||||
|
private CommodityCodeModifyLogDao commodityCodeModifyLogDao; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private BaseService baseService; |
||||||
|
|
||||||
|
/** |
||||||
|
* 比较两个集团物料编码的区别并且保存历史记录 |
||||||
|
* |
||||||
|
* @param originOne |
||||||
|
* @param newOne |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public int saveCommodityCodeDifferenceBetween2(CommodityCodeEntity originOne, CommodityCodeEntity newOne, String modifyUserId) { |
||||||
|
if (StringUtils.isBlank(originOne.getId())) { |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
Field[] fields = CommodityCodeEntity.class.getFields(); |
||||||
|
List<CommodityCodeModifyLog> modifyLogs = new ArrayList<>(); |
||||||
|
for (int i = 0; i < fields.length; i++) { |
||||||
|
Field tempField = fields[i]; |
||||||
|
tempField.setAccessible(true); |
||||||
|
try { |
||||||
|
Object originValue = tempField.get(originOne); |
||||||
|
Object newValue = tempField.get(newOne); |
||||||
|
if (!originValue.equals(newValue)) { |
||||||
|
CommodityCodeModifyLog modifyLog = new CommodityCodeModifyLog(); |
||||||
|
modifyLog.setId(baseService.getGenerateShotKey()); |
||||||
|
modifyLog.setCommodityCodeId(originOne.getCommodityId()); |
||||||
|
modifyLog.setKey(tempField.getName()); |
||||||
|
modifyLog.setOriginValue(originValue.toString()); |
||||||
|
modifyLog.setOriginValue(originValue.toString()); |
||||||
|
modifyLog.setModifyTime(new Date()); |
||||||
|
modifyLog.setModifyUserId(modifyUserId); |
||||||
|
modifyLogs.add(modifyLog); |
||||||
|
} |
||||||
|
} catch (IllegalAccessException e) { |
||||||
|
throw new RuntimeException(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// 批量插入保存
|
||||||
|
|
||||||
|
|
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 通过ID查询单条数据 |
||||||
|
* |
||||||
|
* @param id 主键 |
||||||
|
* @return 实例对象 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public CommodityCodeModifyLog queryById(String id) { |
||||||
|
return this.commodityCodeModifyLogDao.queryById(id); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询多条数据 |
||||||
|
* |
||||||
|
* @param offset 查询起始位置 |
||||||
|
* @param limit 查询条数 |
||||||
|
* @return 对象列表 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public List<CommodityCodeModifyLog> queryAllByLimit(int offset, int limit) { |
||||||
|
return this.commodityCodeModifyLogDao.queryAllByLimit(offset, limit); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 新增数据 |
||||||
|
* |
||||||
|
* @param commodityCodeModifyLog 实例对象 |
||||||
|
* @return 实例对象 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public CommodityCodeModifyLog insert(CommodityCodeModifyLog commodityCodeModifyLog) { |
||||||
|
this.commodityCodeModifyLogDao.insert(commodityCodeModifyLog); |
||||||
|
return commodityCodeModifyLog; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 修改数据 |
||||||
|
* |
||||||
|
* @param commodityCodeModifyLog 实例对象 |
||||||
|
* @return 实例对象 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public CommodityCodeModifyLog update(CommodityCodeModifyLog commodityCodeModifyLog) { |
||||||
|
this.commodityCodeModifyLogDao.update(commodityCodeModifyLog); |
||||||
|
return this.queryById(commodityCodeModifyLog.getId()); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 通过主键删除数据 |
||||||
|
* |
||||||
|
* @param id 主键 |
||||||
|
* @return 是否成功 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public boolean deleteById(String id) { |
||||||
|
return this.commodityCodeModifyLogDao.deleteById(id) > 0; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,103 @@ |
|||||||
|
<?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"> |
||||||
|
<mapper namespace="com.dxhy.order.baseservice.module.commodity.dao.CommodityCodeModifyLogDao"> |
||||||
|
|
||||||
|
<resultMap type="com.dxhy.order.baseservice.module.commodity.entity.CommodityCodeModifyLog" id="CommodityCodeModifyLogMap"> |
||||||
|
<result property="id" column="id" jdbcType="VARCHAR"/> |
||||||
|
<result property="commodityCodeId" column="commodity_code_id" jdbcType="VARCHAR"/> |
||||||
|
<result property="key" column="key" jdbcType="VARCHAR"/> |
||||||
|
<result property="originValue" column="origin_value" jdbcType="VARCHAR"/> |
||||||
|
<result property="newValue" column="new_value" jdbcType="VARCHAR"/> |
||||||
|
<result property="modifyUserId" column="modify_user_id" jdbcType="VARCHAR"/> |
||||||
|
<result property="modifyTime" column="modify_time" jdbcType="TIMESTAMP"/> |
||||||
|
</resultMap> |
||||||
|
|
||||||
|
<!--查询单个--> |
||||||
|
<select id="queryById" resultMap="CommodityCodeModifyLogMap"> |
||||||
|
select |
||||||
|
id, commodity_code_id, key, origin_value, new_value, modify_user_id, modify_time |
||||||
|
from sales_order_sdenergy.commodity_code_modify_log |
||||||
|
where id = #{id} |
||||||
|
</select> |
||||||
|
|
||||||
|
<!--查询指定行数据--> |
||||||
|
<select id="queryAllByLimit" resultMap="CommodityCodeModifyLogMap"> |
||||||
|
select |
||||||
|
id, commodity_code_id, key, origin_value, new_value, modify_user_id, modify_time |
||||||
|
from sales_order_sdenergy.commodity_code_modify_log |
||||||
|
limit #{offset}, #{limit} |
||||||
|
</select> |
||||||
|
|
||||||
|
<!--通过实体作为筛选条件查询--> |
||||||
|
<select id="queryAll" resultMap="CommodityCodeModifyLogMap"> |
||||||
|
select |
||||||
|
id, commodity_code_id, key, origin_value, new_value, modify_user_id, modify_time |
||||||
|
from sales_order_sdenergy.commodity_code_modify_log |
||||||
|
<where> |
||||||
|
<if test="id != null and id != ''"> |
||||||
|
and id = #{id} |
||||||
|
</if> |
||||||
|
<if test="commodityCodeId != null and commodityCodeId != ''"> |
||||||
|
and commodity_code_id = #{commodityCodeId} |
||||||
|
</if> |
||||||
|
<if test="key != null and key != ''"> |
||||||
|
and key = #{key} |
||||||
|
</if> |
||||||
|
<if test="originValue != null and originValue != ''"> |
||||||
|
and origin_value = #{originValue} |
||||||
|
</if> |
||||||
|
<if test="newValue != null and newValue != ''"> |
||||||
|
and new_value = #{newValue} |
||||||
|
</if> |
||||||
|
<if test="modifyUserId != null and modifyUserId != ''"> |
||||||
|
and modify_user_id = #{modifyUserId} |
||||||
|
</if> |
||||||
|
<if test="modifyTime != null"> |
||||||
|
and modify_time = #{modifyTime} |
||||||
|
</if> |
||||||
|
</where> |
||||||
|
</select> |
||||||
|
|
||||||
|
<insert id="insert" keyProperty="id" useGeneratedKeys="true"> |
||||||
|
insert into sales_order_sdenergy.commodity_code_modify_log(commodity_code_id, key, origin_value, new_value, modify_user_id, modify_time) |
||||||
|
values (#{commodityCodeId}, #{key}, #{originValue}, #{newValue}, #{modifyUserId}, #{modifyTime}) |
||||||
|
</insert> |
||||||
|
|
||||||
|
<!--新增所有列--> |
||||||
|
<insert id="batchInsert" keyProperty="id" useGeneratedKeys="true"> |
||||||
|
insert into sales_order_sdenergy.commodity_code_modify_log(commodity_code_id, key, origin_value, new_value, modify_user_id, modify_time) |
||||||
|
values (#{commodityCodeId}, #{key}, #{originValue}, #{newValue}, #{modifyUserId}, #{modifyTime}) |
||||||
|
</insert> |
||||||
|
|
||||||
|
<!--通过主键修改数据--> |
||||||
|
<update id="update"> |
||||||
|
update sales_order_sdenergy.commodity_code_modify_log |
||||||
|
<set> |
||||||
|
<if test="commodityCodeId != null and commodityCodeId != ''"> |
||||||
|
commodity_code_id = #{commodityCodeId}, |
||||||
|
</if> |
||||||
|
<if test="key != null and key != ''"> |
||||||
|
key = #{key}, |
||||||
|
</if> |
||||||
|
<if test="originValue != null and originValue != ''"> |
||||||
|
origin_value = #{originValue}, |
||||||
|
</if> |
||||||
|
<if test="newValue != null and newValue != ''"> |
||||||
|
new_value = #{newValue}, |
||||||
|
</if> |
||||||
|
<if test="modifyUserId != null and modifyUserId != ''"> |
||||||
|
modify_user_id = #{modifyUserId}, |
||||||
|
</if> |
||||||
|
<if test="modifyTime != null"> |
||||||
|
modify_time = #{modifyTime}, |
||||||
|
</if> |
||||||
|
</set> |
||||||
|
where id = #{id} |
||||||
|
</update> |
||||||
|
|
||||||
|
<!--通过主键删除--> |
||||||
|
<delete id="deleteById"> |
||||||
|
delete from sales_order_sdenergy.commodity_code_modify_log where id = #{id} |
||||||
|
</delete> |
||||||
|
|
||||||
|
</mapper> |
Loading…
Reference in new issue