feature:物料编辑及修改记录开发

release
gaorl 2 years ago
parent a4ff5d2e0d
commit 33baa458ec
  1. 12
      order-management-base-service/src/main/java/com/dxhy/order/baseservice/annotation/FieldName.java
  2. 7
      order-management-base-service/src/main/java/com/dxhy/order/baseservice/module/commodity/controller/CommodityController.java
  3. 2
      order-management-base-service/src/main/java/com/dxhy/order/baseservice/module/commodity/dao/CommodityCodeModifyLogDao.java
  4. 27
      order-management-base-service/src/main/java/com/dxhy/order/baseservice/module/commodity/model/CommodityCodeEntity.java
  5. 78
      order-management-base-service/src/main/java/com/dxhy/order/baseservice/module/commodity/model/CommodityCodeModifyLog.java
  6. 3
      order-management-base-service/src/main/java/com/dxhy/order/baseservice/module/commodity/model/dto/QueryModifyLogResultDTO.java
  7. 72
      order-management-base-service/src/main/java/com/dxhy/order/baseservice/module/commodity/service/impl/CommodityCodeModifyLogServiceImpl.java
  8. 19
      order-management-base-service/src/main/resources/mybatis/mapper/CommodityCodeModifyLogDao.xml

@ -0,0 +1,12 @@
package com.dxhy.order.baseservice.annotation;
import java.lang.annotation.*;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface FieldName {
String name();
String fileName();
}

@ -677,12 +677,7 @@ public class CommodityController {
@PostMapping("/modifyLog") @PostMapping("/modifyLog")
public R modifyLog(@RequestBody QueryModifyLogDTO dto) { public R modifyLog(@RequestBody QueryModifyLogDTO dto) {
try { try {
QueryModifyLogResultDTO resp = commodityCodeModifyLogService.queryPage(dto); return R.ok().put("data", commodityCodeModifyLogService.queryPage(dto));
JSONObject respJson = new JSONObject();
respJson.put("data",resp.getList());
respJson.put("modifyUserName",resp.getModifyUserName());
respJson.put("modifyTime",resp.getModifyDate());
return R.ok().put("page", respJson);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
log.error("{},分页参数类型转换异常:{}", LOGGER_MSG, e.getMessage()); log.error("{},分页参数类型转换异常:{}", LOGGER_MSG, e.getMessage());
return R.error("商品信息列表查询异常"); return R.error("商品信息列表查询异常");

@ -55,7 +55,7 @@ public interface CommodityCodeModifyLogDao {
* @param commodityCodeModifyLog * @param commodityCodeModifyLog
* @return * @return
*/ */
int batchInsert(List<CommodityCodeModifyLog> commodityCodeModifyLog); int insertCommodityLog(CommodityCodeModifyLog commodityCodeModifyLog);
/** /**
* 修改数据 * 修改数据

@ -1,5 +1,6 @@
package com.dxhy.order.baseservice.module.commodity.model; package com.dxhy.order.baseservice.module.commodity.model;
import com.dxhy.order.baseservice.annotation.FieldName;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@ -32,16 +33,25 @@ public class CommodityCodeEntity implements Serializable {
/** /**
* 纳税人识别号 * 纳税人识别号
*/ */
@FieldName(name = "xhfNsrsbh",fileName = "销方税号")
private String xhfNsrsbh; private String xhfNsrsbh;
/**
* 企业名称
* taxClassificationName
*/
@FieldName(name = "xhfMc",fileName = "销方名称")
private String xhfMc;
/** /**
* 商品名称 * 商品名称
* merchandiseName * merchandiseName
*/ */
@FieldName(name = "xmmc",fileName = "税收分类名称")
private String xmmc; private String xmmc;
/** /**
* 编码 * 编码
* encoding * encoding
*/ */
@FieldName(name = "zxbm",fileName = "物料编码")
private String zxbm; private String zxbm;
/** /**
* 商品税目 * 商品税目
@ -57,26 +67,31 @@ public class CommodityCodeEntity implements Serializable {
* 税率 * 税率
* taxRate * taxRate
*/ */
@FieldName(name = "sl",fileName = "税率")
private String sl; private String sl;
/** /**
* 规格型号 * 规格型号
* specificationModel * specificationModel
*/ */
@FieldName(name = "ggxh",fileName = "规格型号")
private String ggxh; private String ggxh;
/** /**
* 计量单位 * 计量单位
* meteringUnit * meteringUnit
*/ */
@FieldName(name = "xmdw",fileName = "项目单位")
private String xmdw; private String xmdw;
/** /**
* 单价 * 单价
* unitPrice * unitPrice
*/ */
@FieldName(name = "xmdj",fileName = "项目单价")
private String xmdj; private String xmdj;
/** /**
* 含税价标志01) * 含税价标志01)
* taxLogo * taxLogo
*/ */
@FieldName(name = "hsbz",fileName = "含税标志")
private String hsbz; private String hsbz;
/** /**
* '隐藏标志01; * '隐藏标志01;
@ -87,11 +102,13 @@ public class CommodityCodeEntity implements Serializable {
* '享受优惠政策01', * '享受优惠政策01',
* enjoyPreferentialPolicies * enjoyPreferentialPolicies
*/ */
@FieldName(name = "yhzcbs",fileName = "优惠政策标识")
private String yhzcbs; private String yhzcbs;
/** /**
* 税收分类编码 * 税收分类编码
* taxClassCode * taxClassCode
*/ */
@FieldName(name = "spbm",fileName = "税收分类编码")
private String spbm; private String spbm;
/** /**
* 税收分类名称 * 税收分类名称
@ -107,6 +124,7 @@ public class CommodityCodeEntity implements Serializable {
/** /**
* 增值税特殊管理 * 增值税特殊管理
*/ */
@FieldName(name = "zzstsgl",fileName = "优惠政策类型")
private String zzstsgl; private String zzstsgl;
/** /**
* 当前登录人id * 当前登录人id
@ -149,15 +167,11 @@ public class CommodityCodeEntity implements Serializable {
* 匹配状态 * 匹配状态
*/ */
private String matchingState; private String matchingState;
/**
* 企业名称
* taxClassificationName
*/
private String xhfMc;
/** /**
* 税收简称 * 税收简称
* taxClassAbbreviation * taxClassAbbreviation
*/ */
@FieldName(name = "spjc",fileName = "税收简称")
private String spjc; private String spjc;
/** /**
* 描述 * 描述
@ -207,11 +221,12 @@ public class CommodityCodeEntity implements Serializable {
/** /**
* 特殊物料标识 0非特殊物料1特殊物料 * 特殊物料标识 0非特殊物料1特殊物料
*/ */
@FieldName(name = "tswl",fileName = "是否特殊物料")
private String tswl; private String tswl;
private String UUID; private String UUID;
private Boolean success; private Boolean success;
@FieldName(name = "invoiceName",fileName = "开票名称")
private String invoiceName; private String invoiceName;

@ -7,6 +7,7 @@ package com.dxhy.order.baseservice.module.commodity.model;
**/ **/
import com.dxhy.order.baseservice.module.commodity.model.dto.UserInfoDTO; import com.dxhy.order.baseservice.module.commodity.model.dto.UserInfoDTO;
import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
@ -17,6 +18,7 @@ import java.util.Date;
* @author 巩权林 * @author 巩权林
* @since 2023-03-20 15:31:30 * @since 2023-03-20 15:31:30
*/ */
@Data
public class CommodityCodeModifyLog implements Serializable { public class CommodityCodeModifyLog implements Serializable {
private static final long serialVersionUID = -85350041852113526L; private static final long serialVersionUID = -85350041852113526L;
@ -49,76 +51,8 @@ public class CommodityCodeModifyLog implements Serializable {
private Date modifyTime; private Date modifyTime;
private String modifyUserName; private String modifyUserName;
/**
public String getId() { * 对比属性变化JSON报文存储
return id; */
} private String compareData;
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;
}
public String getModifyUserName() {
return modifyUserName;
}
public void setModifyUserName(String modifyUserName) {
this.modifyUserName = modifyUserName;
}
public String getKeyName() {
return keyName;
}
public void setKeyName(String keyName) {
this.keyName = keyName;
}
} }

@ -13,8 +13,7 @@ import java.util.List;
**/ **/
@Data @Data
public class QueryModifyLogResultDTO { public class QueryModifyLogResultDTO {
private PageUtils pageUtils; private List compareData;
private List list;
private String modifyUserName; private String modifyUserName;
private Date modifyDate; private Date modifyDate;
} }

@ -3,24 +3,20 @@ package com.dxhy.order.baseservice.module.commodity.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.dxhy.order.baseservice.annotation.FieldName;
import com.dxhy.order.baseservice.config.UserCenterConfig; import com.dxhy.order.baseservice.config.UserCenterConfig;
import com.dxhy.order.baseservice.module.base.service.BaseService; import com.dxhy.order.baseservice.module.base.service.BaseService;
import com.dxhy.order.baseservice.module.commodity.constant.CommodityModifiyLogKeyNameEnum; import com.dxhy.order.baseservice.module.commodity.constant.CommodityModifiyLogKeyNameEnum;
import com.dxhy.order.baseservice.module.commodity.dao.CommodityCodeModifyLogDao; 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.CommodityCodeEntity;
import com.dxhy.order.baseservice.module.commodity.model.CommodityCodeModifyLog; 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.model.dto.QueryModifyLogDTO; import com.dxhy.order.baseservice.module.commodity.model.dto.QueryModifyLogDTO;
import com.dxhy.order.baseservice.module.commodity.model.dto.QueryModifyLogResultDTO; import com.dxhy.order.baseservice.module.commodity.model.dto.QueryModifyLogResultDTO;
import com.dxhy.order.baseservice.module.commodity.model.dto.UserInfoDTO; import com.dxhy.order.baseservice.module.commodity.model.dto.UserInfoDTO;
import com.dxhy.order.baseservice.module.commodity.service.CommodityCodeModifyLogService; import com.dxhy.order.baseservice.module.commodity.service.CommodityCodeModifyLogService;
import com.dxhy.order.constant.ConfigureConstant; import com.dxhy.order.constant.ConfigureConstant;
import com.dxhy.order.model.PageUtils;
import com.dxhy.order.model.R;
import com.dxhy.order.utils.HttpUtils; import com.dxhy.order.utils.HttpUtils;
import com.dxhy.order.utils.JsonUtils; import com.dxhy.order.utils.JsonUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -31,7 +27,9 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
@ -73,34 +71,48 @@ public class CommodityCodeModifyLogServiceImpl implements CommodityCodeModifyLog
return 0; return 0;
} }
Field[] fields = CommodityCodeEntity.class.getDeclaredFields(); CommodityCodeModifyLog modifyLog = new CommodityCodeModifyLog();
List<CommodityCodeModifyLog> modifyLogs = new ArrayList<>(); modifyLog.setId(baseService.getGenerateShotKey());
for (int i = 0; i < fields.length; i++) { modifyLog.setCommodityCodeId(originOne.getCommodityId());
Field tempField = fields[i]; modifyLog.setModifyTime(new Date());
tempField.setAccessible(true); modifyLog.setModifyUserId(Long.toString(modifyUserId));
List<JSONObject> compareResultList = new ArrayList<>();
// Class<? extends Class> aClass = CommodityCodeEntity.class.getClass();
Class<? extends CommodityCodeEntity> aClass = originOne.getClass();
Field[] declaredFields = aClass.getDeclaredFields();
for (Field declaredField : declaredFields) {
FieldName annotation = declaredField.getAnnotation(FieldName.class);
String fieldName = "";
if(annotation==null || StringUtils.isBlank(fieldName = annotation.name())){
continue;
}
String getMethodName = "get" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
Object originValue = null;
Object newValue = null;
try { try {
Object originValue = tempField.get(originOne) == null?"":tempField.get(originOne); Method getMethod = aClass.getDeclaredMethod(getMethodName);
Object newValue = tempField.get(newOne) == null?"":tempField.get(newOne); originValue = getMethod.invoke(originOne)==null?"":getMethod.invoke(originOne);
if (!originValue.equals(newValue)) { newValue = getMethod.invoke(newOne)==null?"":getMethod.invoke(newOne);
CommodityCodeModifyLog modifyLog = new CommodityCodeModifyLog(); } catch (Exception e) {
modifyLog.setId(baseService.getGenerateShotKey()); continue;
modifyLog.setCommodityCodeId(originOne.getCommodityId()); }
modifyLog.setKey(tempField.getName()); JSONObject jsonObject = new JSONObject();
modifyLog.setOriginValue(originValue.toString()); if (!originValue.equals(newValue)) {
modifyLog.setOriginValue(originValue.toString()); jsonObject.put("keyName",annotation.fileName());
modifyLog.setModifyTime(new Date()); jsonObject.put("originValue",originValue);
modifyLog.setModifyUserId(Long.toString(modifyUserId)); jsonObject.put("newValue",newValue);
modifyLogs.add(modifyLog); compareResultList.add(jsonObject);
}
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} }
} }
if(modifyLogs.isEmpty()){ modifyLog.setCompareData(JSONObject.toJSONString(compareResultList));
if(compareResultList.isEmpty()){
return -1; return -1;
} }
// 批量插入保存 // 批量插入保存
return commodityCodeModifyLogDao.batchInsert(modifyLogs); return commodityCodeModifyLogDao.insertCommodityLog(modifyLog);
} }
@Override @Override
@ -161,10 +173,10 @@ public class CommodityCodeModifyLogServiceImpl implements CommodityCodeModifyLog
Date modifyDate = commodityCodeModifyLogs.size() > 0 ? commodityCodeModifyLogs.get(commodityCodeModifyLogs.size() - 1).getModifyTime() : null; Date modifyDate = commodityCodeModifyLogs.size() > 0 ? commodityCodeModifyLogs.get(commodityCodeModifyLogs.size() - 1).getModifyTime() : null;
String modifyUserName = commodityCodeModifyLogs.size() > 0 ? commodityCodeModifyLogs.get(commodityCodeModifyLogs.size() - 1).getModifyUserName() : null; String modifyUserName = commodityCodeModifyLogs.size() > 0 ? commodityCodeModifyLogs.get(commodityCodeModifyLogs.size() - 1).getModifyUserName() : null;
// PageInfo<CommodityCodeModifyLog> pageInfo = new PageInfo<>(commodityCodeModifyLogs); JSONObject jsonObject = new JSONObject();
QueryModifyLogResultDTO resultDTO = new QueryModifyLogResultDTO(); QueryModifyLogResultDTO resultDTO = new QueryModifyLogResultDTO();
//resultDTO.setPageUtils(pageInfo.getList()); resultDTO.setCompareData(commodityCodeModifyLogs.size() > 0?JSONObject.parseArray(commodityCodeModifyLogs.get(0).getCompareData()):new ArrayList());
resultDTO.setList(commodityCodeModifyLogs);
resultDTO.setModifyDate(modifyDate); resultDTO.setModifyDate(modifyDate);
resultDTO.setModifyUserName(modifyUserName); resultDTO.setModifyUserName(modifyUserName);
return resultDTO; return resultDTO;

@ -10,12 +10,13 @@
<result property="newValue" column="new_value" jdbcType="VARCHAR"/> <result property="newValue" column="new_value" jdbcType="VARCHAR"/>
<result property="modifyUserId" column="modify_user_id" jdbcType="VARCHAR"/> <result property="modifyUserId" column="modify_user_id" jdbcType="VARCHAR"/>
<result property="modifyTime" column="modify_time" jdbcType="TIMESTAMP"/> <result property="modifyTime" column="modify_time" jdbcType="TIMESTAMP"/>
<result property="compareData" column="compare_data" jdbcType="VARCHAR"/>
</resultMap> </resultMap>
<!--查询单个--> <!--查询单个-->
<select id="queryById" resultMap="CommodityCodeModifyLogMap"> <select id="queryById" resultMap="CommodityCodeModifyLogMap">
select select
id, commodity_code_id, `key`, origin_value, new_value, modify_user_id, modify_time id, commodity_code_id, `key`, origin_value, new_value, modify_user_id, modify_time,compare_data
from commodity_code_modify_log from commodity_code_modify_log
where id = #{id} where id = #{id}
</select> </select>
@ -23,7 +24,7 @@
<!--查询指定行数据--> <!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="CommodityCodeModifyLogMap"> <select id="queryAllByLimit" resultMap="CommodityCodeModifyLogMap">
select select
id, commodity_code_id, `key`, origin_value, new_value, modify_user_id, modify_time id, commodity_code_id, `key`, origin_value, new_value, modify_user_id, modify_time,compare_data
from commodity_code_modify_log from commodity_code_modify_log
limit #{offset}, #{limit} limit #{offset}, #{limit}
</select> </select>
@ -31,7 +32,7 @@
<!--通过实体作为筛选条件查询--> <!--通过实体作为筛选条件查询-->
<select id="queryAll" resultMap="CommodityCodeModifyLogMap"> <select id="queryAll" resultMap="CommodityCodeModifyLogMap">
select select
id, commodity_code_id, `key`, origin_value, new_value, modify_user_id, modify_time id, commodity_code_id, `key`, origin_value, new_value, modify_user_id, modify_time,compare_data
from commodity_code_modify_log from commodity_code_modify_log
<where> <where>
<if test="id != null and id != ''"> <if test="id != null and id != ''">
@ -56,7 +57,7 @@
and modify_time = #{modifyTime} and modify_time = #{modifyTime}
</if> </if>
</where> </where>
order by modify_time asc limit 1 order by modify_time DESC limit 1
</select> </select>
<insert id="insert" keyProperty="id" useGeneratedKeys="true"> <insert id="insert" keyProperty="id" useGeneratedKeys="true">
@ -65,13 +66,9 @@
</insert> </insert>
<!--新增所有列--> <!--新增所有列-->
<insert id="batchInsert" keyProperty="id" useGeneratedKeys="true"> <insert id="insertCommodityLog" keyProperty="id" useGeneratedKeys="true">
insert into commodity_code_modify_log(id,commodity_code_id, `key`, origin_value, new_value, modify_user_id, modify_time) insert into commodity_code_modify_log(id,commodity_code_id, `key`, origin_value, new_value, modify_user_id, modify_time,compare_data)
values values(#{id}, #{commodityCodeId}, #{key}, #{originValue}, #{newValue}, #{modifyUserId}, #{modifyTime},#{compareData})
<foreach collection="list" item="item" index="index" separator=",">
(#{item.id}, #{item.commodityCodeId}, #{item.key}, #{item.originValue}, #{item.newValue}, #{item.modifyUserId}, #{item.modifyTime})
</foreach>
</insert> </insert>
<!--通过主键修改数据--> <!--通过主键修改数据-->

Loading…
Cancel
Save