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")
public R modifyLog(@RequestBody QueryModifyLogDTO dto) {
try {
QueryModifyLogResultDTO resp = 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);
return R.ok().put("data", commodityCodeModifyLogService.queryPage(dto));
} catch (NumberFormatException e) {
log.error("{},分页参数类型转换异常:{}", LOGGER_MSG, e.getMessage());
return R.error("商品信息列表查询异常");

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

@ -1,5 +1,6 @@
package com.dxhy.order.baseservice.module.commodity.model;
import com.dxhy.order.baseservice.annotation.FieldName;
import lombok.Getter;
import lombok.Setter;
@ -32,16 +33,25 @@ public class CommodityCodeEntity implements Serializable {
/**
* 纳税人识别号
*/
@FieldName(name = "xhfNsrsbh",fileName = "销方税号")
private String xhfNsrsbh;
/**
* 企业名称
* taxClassificationName
*/
@FieldName(name = "xhfMc",fileName = "销方名称")
private String xhfMc;
/**
* 商品名称
* merchandiseName
*/
@FieldName(name = "xmmc",fileName = "税收分类名称")
private String xmmc;
/**
* 编码
* encoding
*/
@FieldName(name = "zxbm",fileName = "物料编码")
private String zxbm;
/**
* 商品税目
@ -57,26 +67,31 @@ public class CommodityCodeEntity implements Serializable {
* 税率
* taxRate
*/
@FieldName(name = "sl",fileName = "税率")
private String sl;
/**
* 规格型号
* specificationModel
*/
@FieldName(name = "ggxh",fileName = "规格型号")
private String ggxh;
/**
* 计量单位
* meteringUnit
*/
@FieldName(name = "xmdw",fileName = "项目单位")
private String xmdw;
/**
* 单价
* unitPrice
*/
@FieldName(name = "xmdj",fileName = "项目单价")
private String xmdj;
/**
* 含税价标志01)
* taxLogo
*/
@FieldName(name = "hsbz",fileName = "含税标志")
private String hsbz;
/**
* '隐藏标志01;
@ -87,11 +102,13 @@ public class CommodityCodeEntity implements Serializable {
* '享受优惠政策01',
* enjoyPreferentialPolicies
*/
@FieldName(name = "yhzcbs",fileName = "优惠政策标识")
private String yhzcbs;
/**
* 税收分类编码
* taxClassCode
*/
@FieldName(name = "spbm",fileName = "税收分类编码")
private String spbm;
/**
* 税收分类名称
@ -107,6 +124,7 @@ public class CommodityCodeEntity implements Serializable {
/**
* 增值税特殊管理
*/
@FieldName(name = "zzstsgl",fileName = "优惠政策类型")
private String zzstsgl;
/**
* 当前登录人id
@ -149,15 +167,11 @@ public class CommodityCodeEntity implements Serializable {
* 匹配状态
*/
private String matchingState;
/**
* 企业名称
* taxClassificationName
*/
private String xhfMc;
/**
* 税收简称
* taxClassAbbreviation
*/
@FieldName(name = "spjc",fileName = "税收简称")
private String spjc;
/**
* 描述
@ -207,11 +221,12 @@ public class CommodityCodeEntity implements Serializable {
/**
* 特殊物料标识 0非特殊物料1特殊物料
*/
@FieldName(name = "tswl",fileName = "是否特殊物料")
private String tswl;
private String UUID;
private Boolean success;
@FieldName(name = "invoiceName",fileName = "开票名称")
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 lombok.Data;
import java.io.Serializable;
import java.util.Date;
@ -17,6 +18,7 @@ import java.util.Date;
* @author 巩权林
* @since 2023-03-20 15:31:30
*/
@Data
public class CommodityCodeModifyLog implements Serializable {
private static final long serialVersionUID = -85350041852113526L;
@ -49,76 +51,8 @@ public class CommodityCodeModifyLog implements Serializable {
private Date modifyTime;
private String modifyUserName;
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;
}
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;
}
/**
* 对比属性变化JSON报文存储
*/
private String compareData;
}

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

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

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

Loading…
Cancel
Save