chenlu
2025-11-19 117ffa570f78a7c6d62a2089feede76cd3969bb0
north-glass-erp/src/main/java/com/example/erp/service/sd/CustomerService.java
@@ -7,9 +7,11 @@
import com.example.erp.dto.sd.DeliveryDetailDTO;
import com.example.erp.dto.sd.DeliveryDetailProductDTO;
import com.example.erp.entity.sd.*;
import com.example.erp.entity.userInfo.Log;
import com.example.erp.entity.userInfo.SysError;
import com.example.erp.mapper.mm.FinishedGoodsInventoryMapper;
import com.example.erp.mapper.sd.*;
import com.example.erp.service.userInfo.LogService;
import com.example.erp.service.userInfo.SysErrorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -28,6 +30,8 @@
    CustomerMapper customerMapper;
    @Autowired
    SysErrorService sysErrorService;
    @Autowired
    LogService logService;
    public Map<String, Object> getSelectCustomer(Integer pageNum, Integer pageSize, Customer customer) {
@@ -42,25 +46,30 @@
    public Boolean insertCustomer(Map<String,Object> object) {
        boolean saveState = true;
        Log log = new Log();
        log.setOperatorId(object.get("userId").toString());
        log.setOperator(object.get("userName").toString());
        log.setContent(object.toString());
        //设置回滚点
        Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint();
        try {
            Customer customer = JSONObject.parseObject(JSONObject.toJSONString(object.get("customer")), Customer.class);
            customer=null;
           if(customer!=null){
               if (customer.getId()!=null && customer.getId()!=0){
                   customerMapper.updateCustomer(customer);
                   log.setFunction("insertCustomer修改");
               }else{
                   customerMapper.insertCustomer(customer);
                   log.setFunction("insertCustomer新增");
               }
               logService.saveLog(log);
           }
        } catch (Exception e) {
            TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint);
            //将异常传入数据库
            SysError sysError = new SysError();
            sysError.setError(e+Arrays.toString(e.getStackTrace()));
            sysError.setFunc("insertCustomer");
            sysError.setError(Arrays.toString(e.getStackTrace()));
            sysError.setFunc("saveOrder");
            sysErrorService.insert(sysError);
            saveState = false;
@@ -79,20 +88,21 @@
                if (customer.getId()!=null){
                    customerMapper.deleteCustomer(customer);
                }
                Log log = new Log();
                log.setOperatorId(object.get("userId").toString());
                log.setOperator(object.get("userName").toString());
                log.setContent(object.toString());
                log.setFunction("deleteCustomer删除");
                logService.saveLog(log);
            }
        } catch (Exception e) {
            TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint);
            //将异常传入数据库
            SysError sysError = new SysError();
            sysError.setError(e+Arrays.toString(e.getStackTrace()));
            sysError.setFunc("deleteCustomer");
            sysError.setError(e.toString());
            sysError.setFunc("saveOrder");
            sysErrorService.insert(sysError);
            saveState = false;
        }
        return saveState;
@@ -118,7 +128,6 @@
            map.put("data", customerMapper.getSelectCustomerDeliveryDate(offset, pageSize,startDate,endDate, orderDetail));
            map.put("total", customerMapper.getSelectCustomerDeliveryDatePageTotal(offset, pageSize,startDate,endDate, orderDetail));
        }
        List<String> list = new ArrayList<>();
        list.add(startDate);
        list.add(endDate);