优化日志模块

This commit is contained in:
季圣华
2020-06-09 00:31:46 +08:00
parent b6f79820f5
commit 5168a11b1e
22 changed files with 80 additions and 64 deletions

View File

@@ -120,7 +120,8 @@ public class AccountService {
int result=0;
try{
result = accountMapper.insertSelective(account);
logService.insertLog("账户", BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
logService.insertLog("账户",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(account.getName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
@@ -135,7 +136,7 @@ public class AccountService {
try{
result = accountMapper.updateByPrimaryKeySelective(account);
logService.insertLog("账户",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request);
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(account.getName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}

View File

@@ -105,7 +105,8 @@ public class AccountHeadService {
int result=0;
try{
result = accountHeadMapper.insertSelective(accountHead);
logService.insertLog("财务", BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
logService.insertLog("财务",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(accountHead.getBillno()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
@@ -120,7 +121,7 @@ public class AccountHeadService {
try{
result = accountHeadMapper.updateByPrimaryKeySelective(accountHead);
logService.insertLog("财务",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request);
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(accountHead.getBillno()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
@@ -131,9 +132,10 @@ public class AccountHeadService {
public int deleteAccountHead(Long id, HttpServletRequest request)throws Exception {
int result=0;
try{
AccountHead accountHead = accountHeadMapper.selectByPrimaryKey(id);
result = accountHeadMapper.deleteByPrimaryKey(id);
logService.insertLog("财务",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(id).toString(), request);
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(accountHead.getBillno()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}

View File

@@ -103,7 +103,8 @@ public class DepotService {
int result=0;
try{
result=depotMapper.insertSelective(depot);
logService.insertLog("仓库", BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
logService.insertLog("仓库",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(depot.getName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
@@ -118,7 +119,7 @@ public class DepotService {
try{
result= depotMapper.updateByPrimaryKeySelective(depot);
logService.insertLog("仓库",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request);
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(depot.getName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
@@ -129,9 +130,10 @@ public class DepotService {
public int deleteDepot(Long id, HttpServletRequest request)throws Exception {
int result=0;
try{
Depot depot = depotMapper.selectByPrimaryKey(id);
result= depotMapper.deleteByPrimaryKey(id);
logService.insertLog("仓库",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(id).toString(), request);
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(depot.getName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}

View File

@@ -223,9 +223,6 @@ public class DepotHeadService {
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchSetStatus(String status, String depotHeadIDs)throws Exception {
logService.insertLog("单据",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(depotHeadIDs).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
List<Long> ids = StringUtil.strToLongList(depotHeadIDs);
DepotHead depotHead = new DepotHead();
depotHead.setStatus(status);
@@ -237,6 +234,9 @@ public class DepotHeadService {
}catch(Exception e){
JshException.writeFail(logger, e);
}
logService.insertLog("单据",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(depotHeadIDs).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
return result;
}
/**
@@ -456,9 +456,6 @@ public class DepotHeadService {
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void addDepotHeadAndDetail(String beanJson, String inserted, String deleted, String updated,Long tenantId,
HttpServletRequest request) throws Exception {
logService.insertLog("单据",
BusinessConstants.LOG_OPERATION_TYPE_ADD,
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
/**处理单据主表数据*/
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
//判断用户是否已经登录过,登录过不再处理
@@ -499,6 +496,9 @@ public class DepotHeadService {
JshException.writeFail(logger, e);
}
}
logService.insertLog("单据",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(depotHead.getNumber()).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
}
/**
@@ -516,9 +516,6 @@ public class DepotHeadService {
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void updateDepotHeadAndDetail(Long id, String beanJson, String inserted, String deleted, String updated,
BigDecimal preTotalPrice, Long tenantId,HttpServletRequest request)throws Exception {
logService.insertLog("单据",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
/**更新单据主表信息*/
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
//判断用户是否已经登录过,登录过不再处理
@@ -538,6 +535,9 @@ public class DepotHeadService {
}
/**入库和出库处理单据子表信息*/
depotItemService.saveDetials(inserted,deleted,updated,depotHead.getId(),tenantId,request);
logService.insertLog("单据",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(depotHead.getNumber()).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
}
/**
@@ -547,9 +547,6 @@ public class DepotHeadService {
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void deleteDepotHeadAndDetail(Long id) throws Exception {
logService.insertLog("单据",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(id).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
//查询单据主表信息
DepotHead depotHead =getDepotHead(id);
User userInfo=userService.getCurrentUser();
@@ -581,6 +578,9 @@ public class DepotHeadService {
/**删除单据主表信息*/
batchDeleteDepotHeadByIds(id.toString());
logService.insertLog("单据",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(depotHead.getNumber()).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
}
/**

View File

@@ -97,13 +97,13 @@ public class FunctionsService {
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateFunctions(String beanJson, Long id, HttpServletRequest request) throws Exception{
Functions depot = JSONObject.parseObject(beanJson, Functions.class);
depot.setId(id);
Functions functions = JSONObject.parseObject(beanJson, Functions.class);
functions.setId(id);
int result=0;
try{
result=functionsMapper.updateByPrimaryKeySelective(depot);
result=functionsMapper.updateByPrimaryKeySelective(functions);
logService.insertLog("功能",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request);
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(functions.getName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}

View File

@@ -85,11 +85,12 @@ public class InOutItemService {
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertInOutItem(String beanJson, HttpServletRequest request)throws Exception {
InOutItem depot = JSONObject.parseObject(beanJson, InOutItem.class);
InOutItem inOutItem = JSONObject.parseObject(beanJson, InOutItem.class);
int result=0;
try{
result=inOutItemMapper.insertSelective(depot);
logService.insertLog("收支项目", BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
result=inOutItemMapper.insertSelective(inOutItem);
logService.insertLog("收支项目",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(inOutItem.getName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
@@ -98,13 +99,13 @@ public class InOutItemService {
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateInOutItem(String beanJson, Long id, HttpServletRequest request)throws Exception {
InOutItem depot = JSONObject.parseObject(beanJson, InOutItem.class);
depot.setId(id);
InOutItem inOutItem = JSONObject.parseObject(beanJson, InOutItem.class);
inOutItem.setId(id);
int result=0;
try{
result=inOutItemMapper.updateByPrimaryKeySelective(depot);
result=inOutItemMapper.updateByPrimaryKeySelective(inOutItem);
logService.insertLog("收支项目",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request);
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(inOutItem.getName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}

View File

@@ -148,7 +148,7 @@ public class LogService {
}
}
public void insertLog(String moduleName, String type, HttpServletRequest request)throws Exception{
public void insertLog(String moduleName, String content, HttpServletRequest request)throws Exception{
try{
Long userId = getUserId(request);
if(userId!=null) {
@@ -159,7 +159,7 @@ public class LogService {
log.setCreatetime(new Date());
Byte status = 0;
log.setStatus(status);
log.setContentdetails(type + moduleName);
log.setContentdetails(content);
logMapper.insertSelective(log);
}
}catch(Exception e){

View File

@@ -162,7 +162,8 @@ public class MaterialService {
}
}
}
logService.insertLog("商品", BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
logService.insertLog("商品",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(m.getName()).toString(), request);
return 1;
}catch(Exception e){
JshException.writeFail(logger, e);
@@ -197,7 +198,7 @@ public class MaterialService {
}
}
logService.insertLog("商品",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request);
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(material.getName()).toString(), request);
return 1;
}catch(Exception e){
JshException.writeFail(logger, e);

View File

@@ -118,7 +118,8 @@ public class MaterialCategoryService {
int result=0;
try{
result=materialCategoryMapper.insertSelective(materialCategory);
logService.insertLog("商品类型", BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
logService.insertLog("商品类型",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(materialCategory.getName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
@@ -133,7 +134,7 @@ public class MaterialCategoryService {
try{
result=materialCategoryMapper.updateByPrimaryKeySelective(materialCategory);
logService.insertLog("商品类型",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request);
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(materialCategory.getName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}

View File

@@ -87,7 +87,8 @@ public class MaterialPropertyService {
int result=0;
try{
result=materialPropertyMapper.insertSelective(materialProperty);
logService.insertLog("商品属性", BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
logService.insertLog("商品属性",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(materialProperty.getNativename()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
@@ -102,7 +103,7 @@ public class MaterialPropertyService {
try{
result=materialPropertyMapper.updateByPrimaryKeySelective(materialProperty);
logService.insertLog("商品属性",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request);
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(materialProperty.getNativename()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}

View File

@@ -102,7 +102,8 @@ public class MsgService {
int result=0;
try{
result=msgMapper.insertSelective(msg);
logService.insertLog("消息", BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
logService.insertLog("消息",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(msg.getMsgTitle()).toString(), request);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE, ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
@@ -120,7 +121,7 @@ public class MsgService {
try{
result=msgMapper.updateByPrimaryKeySelective(msg);
logService.insertLog("消息",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request);
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(msg.getMsgTitle()).toString(), request);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE, ExceptionConstants.DATA_WRITE_FAIL_MSG,e);

View File

@@ -56,7 +56,8 @@ public class OrganizationService {
int result=0;
try{
result=organizationMapper.insertSelective(organization);
logService.insertLog("机构", BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
logService.insertLog("机构",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(organization.getOrgFullName()).toString(),request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
@@ -70,7 +71,7 @@ public class OrganizationService {
try{
result=organizationMapper.updateByPrimaryKeySelective(organization);
logService.insertLog("机构",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request);
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(organization.getOrgFullName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}

View File

@@ -92,7 +92,8 @@ public class PersonService {
int result=0;
try{
result=personMapper.insertSelective(person);
logService.insertLog("经手人", BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
logService.insertLog("经手人",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(person.getName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
@@ -107,7 +108,7 @@ public class PersonService {
try{
result=personMapper.updateByPrimaryKeySelective(person);
logService.insertLog("经手人",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request);
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(person.getName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}

View File

@@ -86,7 +86,8 @@ public class RoleService {
int result=0;
try{
result=roleMapper.insertSelective(role);
logService.insertLog("角色", BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
logService.insertLog("角色",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(role.getName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
@@ -101,7 +102,7 @@ public class RoleService {
try{
result=roleMapper.updateByPrimaryKeySelective(role);
logService.insertLog("角色",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request);
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(role.getName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}

View File

@@ -94,11 +94,11 @@ public class SerialNumberService {
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertSerialNumber(String beanJson, HttpServletRequest request)throws Exception {
SerialNumber serialNumber = JSONObject.parseObject(beanJson, SerialNumber.class);
logService.insertLog("序列号", BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
int result=0;
try{
result=serialNumberMapper.insertSelective(serialNumber);
logService.insertLog("序列号", BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
logService.insertLog("序列号",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(serialNumber.getSerialNumber()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
@@ -113,7 +113,7 @@ public class SerialNumberService {
try{
result=serialNumberMapper.updateByPrimaryKeySelective(serialNumber);
logService.insertLog("序列号",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request);
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(serialNumber.getSerialNumber()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}

View File

@@ -133,7 +133,8 @@ public class SupplierService {
int result=0;
try{
result=supplierMapper.insertSelective(supplier);
logService.insertLog("商家", BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
logService.insertLog("商家",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(supplier.getSupplier()).toString(),request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
@@ -154,7 +155,7 @@ public class SupplierService {
try{
result=supplierMapper.updateByPrimaryKeySelective(supplier);
logService.insertLog("商家",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request);
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(supplier.getSupplier()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}

View File

@@ -87,7 +87,8 @@ public class SystemConfigService {
int result=0;
try{
result=systemConfigMapper.insertSelective(systemConfig);
logService.insertLog("系统配置", BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
logService.insertLog("系统配置",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(systemConfig.getCompanyName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
@@ -102,7 +103,7 @@ public class SystemConfigService {
try{
result=systemConfigMapper.updateByPrimaryKeySelective(systemConfig);
logService.insertLog("系统配置",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request);
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(systemConfig.getCompanyName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}

View File

@@ -89,7 +89,8 @@ public class UnitService {
int result=0;
try{
result=unitMapper.insertSelective(unit);
logService.insertLog("计量单位", BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
logService.insertLog("计量单位",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(unit.getUname()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
@@ -104,7 +105,7 @@ public class UnitService {
try{
result=unitMapper.updateByPrimaryKeySelective(unit);
logService.insertLog("计量单位",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request);
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(unit.getUname()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}

View File

@@ -121,7 +121,8 @@ public class UserService {
int result=0;
try{
result=userMapper.insertSelective(user);
logService.insertLog("用户", BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
logService.insertLog("用户",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(user.getLoginName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
@@ -144,7 +145,7 @@ public class UserService {
try{
result=userMapper.updateByPrimaryKeySelective(user);
logService.insertLog("用户",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request);
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(user.getLoginName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}

View File

@@ -86,8 +86,7 @@ public class UserBusinessService {
int result=0;
try{
result=userBusinessMapper.updateByPrimaryKeySelective(userBusiness);
logService.insertLog("关联关系",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request);
logService.insertLog("关联关系", BusinessConstants.LOG_OPERATION_TYPE_EDIT, request);
}catch(Exception e){
JshException.writeFail(logger, e);
}