jiangshuang
2024-10-25 83c2b6cbf12ed3308eb875f517f2a1ed53d2dc9e
CRM>分单系统销售退货单同步
已添加12个文件
917 ■■■■■ 文件已修改
JavaSource/com/mandi/common/XmlUtils.java 159 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
JavaSource/com/mandi/fendan/controller/SaleBackOrderController.java 139 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
JavaSource/com/mandi/fendan/mapper/SaleBackOrderMapper.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
JavaSource/com/mandi/fendan/mapper/SaleReturnMapper.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
JavaSource/com/mandi/fendan/mapper/xmls/SaleBackOrderMapper.xml 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
JavaSource/com/mandi/fendan/mapper/xmls/SaleReturnMapper.xml 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
JavaSource/com/mandi/fendan/persist/SaleBackOrder.java 131 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
JavaSource/com/mandi/fendan/persist/SalesReturn.java 140 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
JavaSource/com/mandi/fendan/service/SaleBackOrderService.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
JavaSource/com/mandi/fendan/service/SaleReturnService.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
JavaSource/com/mandi/fendan/service/impl/SaleBackOrderServiceImpl.java 189 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
JavaSource/com/mandi/fendan/service/impl/SaleReturnServiceImpl.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
JavaSource/com/mandi/common/XmlUtils.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,159 @@
/**
 * Project Name:pay-protocol
 * File Name:Xml.java
 * Package Name:cn.swiftpass.pay.protocol
 * Date:2014-8-10下午10:48:21
 *
*/
package com.mandi.common;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.xml.sax.InputSource;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.util.*;
/**
 * ClassName:Xml
 * Function: XML的工具方法
 * Date:     2014-8-10 ä¸‹åˆ10:48:21
 * @author
 */
@SuppressWarnings({"rawtypes","unchecked"})
public class XmlUtils {
    /** <一句话功能简述>
     * <功能详细描述>request转字符串
     * @param request
     * @return
     * @see [类、类#方法、类#成员]
     */
    public static String parseRequst(HttpServletRequest request){
        String body = "";
        try {
            ServletInputStream inputStream = request.getInputStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(inputStream,"utf-8"));
            while(true){
                String info = br.readLine();
                if(info == null){
                    break;
                }
                if(body == null || "".equals(body)){
                    body = info;
                }else{
                    body += info;
                }
            }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return body;
    }
    public static String parseXML(SortedMap<String, String> parameters) {
        StringBuffer sb = new StringBuffer();
        sb.append("<xml>");
        Set es = parameters.entrySet();
        Iterator it = es.iterator();
        while (it.hasNext()) {
            Map.Entry entry = (Map.Entry)it.next();
            String k = (String)entry.getKey();
            String v = (String)entry.getValue();
            if (null != v && !"".equals(v) && !"appkey".equals(k)) {
                sb.append("<" + k + ">" + parameters.get(k) + "</" + k + ">\n");
            }
        }
        sb.append("</xml>");
        return sb.toString();
    }
    /**
     * ä»Žrequest中获得参数Map,并返回可读的Map
     *
     * @param request
     * @return
     */
    public static SortedMap getParameterMap(HttpServletRequest request) {
        // å‚æ•°Map
        Map properties = request.getParameterMap();
        // è¿”回值Map
        SortedMap returnMap = new TreeMap();
        Iterator entries = properties.entrySet().iterator();
        Map.Entry entry;
        String name = "";
        String value = "";
        while (entries.hasNext()) {
            entry = (Map.Entry) entries.next();
            name = (String) entry.getKey();
            Object valueObj = entry.getValue();
            if(null == valueObj){
                value = "";
            }else if(valueObj instanceof String[]){
                String[] values = (String[])valueObj;
                for(int i=0;i<values.length;i++){
                    value = values[i] + ",";
                }
                value = value.substring(0, value.length()-1);
            }else{
                value = valueObj.toString();
            }
            returnMap.put(name, value.trim());
        }
        returnMap.remove("method");
        return returnMap;
    }
    /**
     * è½¬XMLmap
     * @author
     * @param xmlBytes
     * @param charset
     * @return
     * @throws Exception
     */
    public static Map<String, String> toMap(byte[] xmlBytes,String charset) throws Exception{
        SAXReader reader = new SAXReader(false);
        InputSource source = new InputSource(new ByteArrayInputStream(xmlBytes));
        source.setEncoding(charset);
        Document doc = reader.read(source);
        Map<String, String> params = XmlUtils.toMap(doc.getRootElement());
        return params;
    }
    /**
     * è½¬MAP
     * @author
     * @param element
     * @return
     */
    public static Map<String, String> toMap(Element element){
        Map<String, String> rest = new HashMap<String, String>();
        List<Element> els = element.elements();
        for(Element el : els){
            rest.put(el.getName().toLowerCase(), el.getText());
        }
        return rest;
    }
    public static String toXml(Map<String, String> params){
        StringBuilder buf = new StringBuilder();
        List<String> keys = new ArrayList<String>(params.keySet());
        Collections.sort(keys);
        buf.append("<xml>");
        for(String key : keys){
            buf.append("<").append(key).append(">");
            buf.append("<![CDATA[").append(params.get(key)).append("]]>");
            buf.append("</").append(key).append(">\n");
        }
        buf.append("</xml>");
        return buf.toString();
    }
}
JavaSource/com/mandi/fendan/controller/SaleBackOrderController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,139 @@
package com.mandi.fendan.controller;
import com.mandi.common.XmlUtils;
import com.mandi.fendan.persist.SaleBackOrder;
import com.mandi.fendan.persist.SalesReturn;
import com.mandi.fendan.service.SaleBackOrderService;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping(value="/api/saleBackOrder",method={RequestMethod.GET,RequestMethod.POST})
public class SaleBackOrderController {
    private Logger log=Logger.getLogger(SaleBackOrderController.class);
    @Resource
    private SaleBackOrderService saleBackOrderService;
    @RequestMapping(value = "/receive.htm", method = {RequestMethod.POST,RequestMethod.GET })
//    public void insertSaleBackOrder(@RequestBody SaleBackOrder saleBackOrder){
    public void insertSaleBackOrder(HttpServletRequest req, HttpServletResponse resp){
        try {
            String strInfo = XmlUtils.parseRequst(req);
            if(StringUtils.isNotBlank(strInfo)){
                JSONObject jsonObject = new JSONObject(strInfo);
                SaleBackOrder convert = convert(jsonObject);
                saleBackOrderService.saveOrUpdateOrDelete(convert);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    private SaleBackOrder convert(JSONObject jsonObject) throws Exception {
        SaleBackOrder convert = new SaleBackOrder();
        if (StringUtils.isNotBlank(jsonObject.getString("newSalesId"))) {
            convert.setNewSalesId(jsonObject.getString("newSalesId"));
        }
        if (StringUtils.isNotBlank(jsonObject.getString("docNum"))) {
            convert.setDocNum(jsonObject.getString("docNum"));
        }
        if (StringUtils.isNotBlank(jsonObject.getString("docTime"))) {
            convert.setDocTime(jsonObject.getString("docTime"));
        }
        if (StringUtils.isNotBlank(jsonObject.getString("newAccountNo"))) {
            convert.setNewAccountNo(jsonObject.getString("newAccountNo"));
        }
        if (StringUtils.isNotBlank(jsonObject.getString("createdBy"))) {
            convert.setCreatedBy(jsonObject.getString("createdBy"));
        }
        if (StringUtils.isNotBlank(jsonObject.getString("ncDepCode"))) {
            convert.setNcDepCode(jsonObject.getString("ncDepCode"));
        }
        if (StringUtils.isNotBlank(jsonObject.getString("userCode"))) {
            convert.setUserCode(jsonObject.getString("userCode"));
        }
        if (StringUtils.isNotBlank(jsonObject.getString("invoiceNum"))) {
            convert.setInvoiceNum(jsonObject.getString("invoiceNum"));
        }
        if (StringUtils.isNotBlank(jsonObject.getString("docRemark"))) {
            convert.setDocRemark(jsonObject.getString("docRemark"));
        }
        if (StringUtils.isNotBlank(jsonObject.getString("rcDepCode"))) {
            convert.setRcDepCode(jsonObject.getString("rcDepCode"));
        }
        if (StringUtils.isNotBlank(jsonObject.getString("rcLocCompCode"))) {
            convert.setRcLocCompCode(jsonObject.getString("rcLocCompCode"));
        }
        if (StringUtils.isNotBlank(jsonObject.getString("operState"))) {
            convert.setOperState(jsonObject.getString("operState"));
        }
        JSONArray itemList = jsonObject.getJSONArray("itemList");
        List<SalesReturn> salesReturnList = new ArrayList<>();
        for(int i=0;i<itemList.length();i++){
            SalesReturn salesReturn = new SalesReturn();
            JSONObject itemObject = itemList.getJSONObject(i);
            // è®¾ç½®å„个字段
            if (StringUtils.isNotBlank(itemObject.getString("itemId"))) {
                salesReturn.setItemId(itemObject.getString("itemId"));
            }
            if (StringUtils.isNotBlank(itemObject.getString("batchNum"))) {
                salesReturn.setBatchNum(itemObject.getString("batchNum"));
            }
            if (StringUtils.isNotBlank(itemObject.getString("materialName"))) {
                salesReturn.setMaterialName(itemObject.getString("materialName"));
            }
            if (StringUtils.isNotBlank(itemObject.getString("specsName"))) {
                salesReturn.setSpecsName(itemObject.getString("specsName"));
            }
            if (StringUtils.isNotBlank(itemObject.getString("jzfmName"))) {
                salesReturn.setJzfmName(itemObject.getString("jzfmName"));
            }
            if (StringUtils.isNotBlank(itemObject.getString("materialSize"))) {
                salesReturn.setMaterialSize(itemObject.getString("materialSize"));
            }
            if (StringUtils.isNotBlank(itemObject.getString("outerPackingSize"))) {
                salesReturn.setOuterPackingSize(itemObject.getString("outerPackingSize"));
            }
            if (itemObject.has("grossWeight")) {
                salesReturn.setGrossWeight(itemObject.getDouble("grossWeight"));
            }
            if (itemObject.has("netWeight")) {
                salesReturn.setNetWeight(itemObject.getDouble("netWeight"));
            }
            if (StringUtils.isNotBlank(itemObject.getString("backTypeName"))) {
                salesReturn.setBackTypeName(itemObject.getString("backTypeName"));
            }
            if (StringUtils.isNotBlank(itemObject.getString("backReason"))) {
                salesReturn.setBackReason(itemObject.getString("backReason"));
            }
            if (StringUtils.isNotBlank(itemObject.getString("alloyStateName"))) {
                salesReturn.setAlloyStateName(itemObject.getString("alloyStateName"));
            }
            if (StringUtils.isNotBlank(itemObject.getString("itemRemark"))) {
                salesReturn.setItemRemark(itemObject.getString("itemRemark"));
            }
            if (StringUtils.isNotBlank(itemObject.getString("operState"))) {
                salesReturn.setOperState(itemObject.getString("operState"));
            }
            // æ·»åŠ åˆ°åˆ—表中
            salesReturnList.add(salesReturn);
        }
        convert.setItemList(salesReturnList);
        return convert;
    }
}
JavaSource/com/mandi/fendan/mapper/SaleBackOrderMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,22 @@
package com.mandi.fendan.mapper;
import com.mandi.fendan.persist.SaleBackOrder;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
public interface SaleBackOrderMapper {
    //新增
    void saveEntity(SaleBackOrder saleBackOrder);
    //根据Id查询
    @Select("select a.* from SaleBackOrder a where a.NewSalesId=#{newSalesId}")
    SaleBackOrder queryById(@Param("newSalesId") String newSalesId);
    //修改
    void updateEntity(SaleBackOrder saleBackOrder);
    @Delete("delete from SaleBackOrder where NewSalesId=#{newSalesId} ")
    void deleteByNewSalesId(@Param("newSalesId") String newSalesId);
}
JavaSource/com/mandi/fendan/mapper/SaleReturnMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,21 @@
package com.mandi.fendan.mapper;
import com.mandi.fendan.persist.SalesReturn;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
public interface SaleReturnMapper {
    void saveEntity(SalesReturn salesReturn);
    //根据Id查询
    @Select("select a.* from SalesReturn a where a.itemId=#{itemId}")
    SalesReturn queryById(@Param("itemId") String itemId);
    void updateEntity(SalesReturn convert);
    //根据Id删除
    @Delete("delete from SalesReturn where itemId=#{itemId} ")
    void deleteByItemId(@Param("itemId") String itemId);
}
JavaSource/com/mandi/fendan/mapper/xmls/SaleBackOrderMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,27 @@
<?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.mandi.fendan.mapper.SaleBackOrderMapper">
    <insert id="saveEntity">
        INSERT INTO SaleBackOrder (newSalesId, docNum, docTime, newAccountNo, createdBy,
            ncDepCode, userCode, invoiceNum, docRemark, rcDepCode, rcLocCompCode, operState)
        VALUES (#{newSalesId}, #{docNum}, #{docTime}, #{newAccountNo}, #{createdBy},
            #{ncDepCode}, #{userCode}, #{invoiceNum}, #{docRemark}, #{rcDepCode}, #{rcLocCompCode}, #{operState})
    </insert>
    <update id="updateEntity">
        UPDATE SaleBackOrder
            SET DocNum = #{docNum},
            DocTime = #{docTime},
            NewAccountNo = #{newAccountNo},
            CreatedBy = #{createdBy},
            NcDepCode = #{ncDepCode},
            UserCode = #{userCode},
            InvoiceNum = #{invoiceNum},
            DocRemark = #{docRemark},
            RcDepCode = #{rcDepCode},
            RcLocCompCode = #{rcLocCompCode},
            OperState = #{operState}
        WHERE NewSalesId = #{newSalesId}
    </update>
</mapper>
JavaSource/com/mandi/fendan/mapper/xmls/SaleReturnMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,32 @@
<?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.mandi.fendan.mapper.SaleReturnMapper">
    <insert id="saveEntity">
        INSERT INTO SalesReturn (itemId, batchNum, materialName, specsName, jzfmName,
            materialSize, outerPackingSize, grossWeight, netWeight, backTypeName,
            backReason, alloyStateName, itemRemark, operState)
        VALUES (#{itemId}, #{batchNum}, #{materialName}, #{specsName}, #{jzfmName},
            #{materialSize}, #{outerPackingSize}, #{grossWeight}, #{netWeight},
            #{backTypeName}, #{backReason}, #{alloyStateName}, #{itemRemark}, #{operState})
    </insert>
    <update id="updateEntity">
        UPDATE SalesReturn
            SET
                batchNum = #{batchNum},
                materialName = #{materialName},
                specsName = #{specsName},
                jzfmName = #{jzfmName},
                materialSize = #{materialSize},
                outerPackingSize = #{outerPackingSize},
                grossWeight = #{grossWeight},
                netWeight = #{netWeight},
                backTypeName = #{backTypeName},
                backReason = #{backReason},
                alloyStateName = #{alloyStateName},
                itemRemark = #{itemRemark},
                operState = #{operState}
            WHERE itemId = #{itemId}
    </update>
</mapper>
JavaSource/com/mandi/fendan/persist/SaleBackOrder.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,131 @@
package com.mandi.fendan.persist;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.List;
@Entity
@Table(name="fd_SeparateList")
public class SaleBackOrder implements Serializable {
    @Id
    private String newSalesId;//主键
    private String docNum;//单据号
    private String docTime;//单据日期
    private String newAccountNo;//客户
    private String createdBy;//创建人
    private String ncDepCode;//部门
    private String userCode;//业务员
    private String invoiceNum;//发票号
    private String docRemark;//备注
    private String rcDepCode;//收货单位
    private String rcLocCompCode;//客户退货行政区划
    private String operState;//处理操作
    private List<SalesReturn> itemList;
    public String getNewSalesId() {
        return newSalesId;
    }
    public void setNewSalesId(String newSalesId) {
        this.newSalesId = newSalesId;
    }
    public String getDocNum() {
        return docNum;
    }
    public void setDocNum(String docNum) {
        this.docNum = docNum;
    }
    public String getDocTime() {
        return docTime;
    }
    public void setDocTime(String docTime) {
        this.docTime = docTime;
    }
    public String getNewAccountNo() {
        return newAccountNo;
    }
    public void setNewAccountNo(String newAccountNo) {
        this.newAccountNo = newAccountNo;
    }
    public String getCreatedBy() {
        return createdBy;
    }
    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }
    public String getNcDepCode() {
        return ncDepCode;
    }
    public void setNcDepCode(String ncDepCode) {
        this.ncDepCode = ncDepCode;
    }
    public String getUserCode() {
        return userCode;
    }
    public void setUserCode(String userCode) {
        this.userCode = userCode;
    }
    public String getInvoiceNum() {
        return invoiceNum;
    }
    public void setInvoiceNum(String invoiceNum) {
        this.invoiceNum = invoiceNum;
    }
    public String getDocRemark() {
        return docRemark;
    }
    public void setDocRemark(String docRemark) {
        this.docRemark = docRemark;
    }
    public String getRcDepCode() {
        return rcDepCode;
    }
    public void setRcDepCode(String rcDepCode) {
        this.rcDepCode = rcDepCode;
    }
    public String getRcLocCompCode() {
        return rcLocCompCode;
    }
    public void setRcLocCompCode(String rcLocCompCode) {
        this.rcLocCompCode = rcLocCompCode;
    }
    public String getOperState() {
        return operState;
    }
    public void setOperState(String operState) {
        this.operState = operState;
    }
    public List<SalesReturn> getItemList() {
        return itemList;
    }
    public void setItemList(List<SalesReturn> itemList) {
        this.itemList = itemList;
    }
}
JavaSource/com/mandi/fendan/persist/SalesReturn.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,140 @@
package com.mandi.fendan.persist;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
@Entity
@Table(name="SalesReturn")
public class SalesReturn implements Serializable {
    @Id
    private String itemId; // ç‰©æ–™ç¼–号
    private String batchNum; // æ‰¹æ¬¡å·
    private String materialName; // ç‰©æ–™åç§°
    private String specsName; // è§„格名称
    private String jzfmName; // å¤¹çº¸è¦†è†œåç§°
    private String materialSize; // å°ºå¯¸
    private String outerPackingSize; // å¤–包装尺寸
    private Double grossWeight; // æ¯›é‡
    private Double netWeight; // å‡€é‡
    private String backTypeName; // é€€è´§ç±»åž‹
    private String backReason; // é€€è´§åŽŸå› 
    private String alloyStateName; // åˆé‡‘状态名称
    private String itemRemark; // å¤‡æ³¨
    private String operState; // å¤„理操作
    public String getItemId() {
        return itemId;
    }
    public void setItemId(String itemId) {
        this.itemId = itemId;
    }
    public String getBatchNum() {
        return batchNum;
    }
    public void setBatchNum(String batchNum) {
        this.batchNum = batchNum;
    }
    public String getMaterialName() {
        return materialName;
    }
    public void setMaterialName(String materialName) {
        this.materialName = materialName;
    }
    public String getSpecsName() {
        return specsName;
    }
    public void setSpecsName(String specsName) {
        this.specsName = specsName;
    }
    public String getJzfmName() {
        return jzfmName;
    }
    public void setJzfmName(String jzfmName) {
        this.jzfmName = jzfmName;
    }
    public String getMaterialSize() {
        return materialSize;
    }
    public void setMaterialSize(String materialSize) {
        this.materialSize = materialSize;
    }
    public String getOuterPackingSize() {
        return outerPackingSize;
    }
    public void setOuterPackingSize(String outerPackingSize) {
        this.outerPackingSize = outerPackingSize;
    }
    public Double getGrossWeight() {
        return grossWeight;
    }
    public void setGrossWeight(Double grossWeight) {
        this.grossWeight = grossWeight;
    }
    public Double getNetWeight() {
        return netWeight;
    }
    public void setNetWeight(Double netWeight) {
        this.netWeight = netWeight;
    }
    public String getBackTypeName() {
        return backTypeName;
    }
    public void setBackTypeName(String backTypeName) {
        this.backTypeName = backTypeName;
    }
    public String getBackReason() {
        return backReason;
    }
    public void setBackReason(String backReason) {
        this.backReason = backReason;
    }
    public String getAlloyStateName() {
        return alloyStateName;
    }
    public void setAlloyStateName(String alloyStateName) {
        this.alloyStateName = alloyStateName;
    }
    public String getItemRemark() {
        return itemRemark;
    }
    public void setItemRemark(String itemRemark) {
        this.itemRemark = itemRemark;
    }
    public String getOperState() {
        return operState;
    }
    public void setOperState(String operState) {
        this.operState = operState;
    }
}
JavaSource/com/mandi/fendan/service/SaleBackOrderService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
package com.mandi.fendan.service;
import com.mandi.fendan.persist.SaleBackOrder;
public interface SaleBackOrderService {
    void saveOrUpdateOrDelete(SaleBackOrder saleBackOrder);
}
JavaSource/com/mandi/fendan/service/SaleReturnService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,13 @@
package com.mandi.fendan.service;
import com.mandi.fendan.persist.SalesReturn;
public interface SaleReturnService{
    void saveEntity(SalesReturn salesReturn);
    SalesReturn queryById(String itemId);
    void updateEntity(SalesReturn convert);
    void deleteByItemId(String itemId);
}
JavaSource/com/mandi/fendan/service/impl/SaleBackOrderServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,189 @@
package com.mandi.fendan.service.impl;
import com.mandi.fendan.mapper.SaleBackOrderMapper;
import com.mandi.fendan.persist.SaleBackOrder;
import com.mandi.fendan.persist.SalesReturn;
import com.mandi.fendan.service.SaleBackOrderService;
import com.mandi.fendan.service.SaleReturnService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class SaleBackOrderServiceImpl implements SaleBackOrderService {
    @Resource
    private SaleBackOrderMapper saleBackOrderMapper;
    @Resource
    private SaleReturnService saleReturnService;
    public void saveOrUpdateOrDelete(SaleBackOrder saleBackOrder) {
        //更新或新增实体
        if(StringUtils.isNotBlank(saleBackOrder.getNewSalesId())){
            SaleBackOrder saleBackOrder1 = saleBackOrderMapper.queryById(saleBackOrder.getNewSalesId());
            //有主键数据 æ›´æ–°
            if(saleBackOrder1!=null){
                //有主键数据 å¹¶å¤„理状态为删除则删除
                if("1".equals(saleBackOrder.getOperState())) {
                    saleBackOrderMapper.deleteByNewSalesId(saleBackOrder.getNewSalesId());
                }else{
                    SaleBackOrder convert = convert(saleBackOrder, saleBackOrder1);
                    saleBackOrderMapper.updateEntity(convert);
                }
            }else {
                //无主键数据 æ–°å¢ž
                saleBackOrderMapper.saveEntity(saleBackOrder);
            }
        }
        //更新或新增子实体
        if(!saleBackOrder.getItemList().isEmpty() || saleBackOrder.getItemList().size()!=0){
            List<SalesReturn> salesReturnList = saleBackOrder.getItemList();
            for(SalesReturn salesReturn:salesReturnList){
                if(StringUtils.isNotBlank(salesReturn.getItemId())) {
                    SalesReturn salesReturn1=saleReturnService.queryById(salesReturn.getItemId());
                    //有主键数据 æ›´æ–°
                    if(salesReturn1!=null){
                        //有主键数据 å¹¶å¤„理状态为删除则删除
                        if("1".equals(salesReturn.getOperState())) {
                            saleReturnService.deleteByItemId(salesReturn.getItemId());
                        }else {
                            SalesReturn convert = convertSalesReturn(salesReturn, salesReturn1);
                            saleReturnService.updateEntity(convert);
                        }
                    }else{
                        //无主键数据 æ–°å¢ž
                        saleReturnService.saveEntity(salesReturn);
                    }
                }
            }
        }
    }
    private SalesReturn convertSalesReturn(SalesReturn salesReturn,SalesReturn salesReturn1){
        if (StringUtils.isNotBlank(salesReturn.getItemId()) &&
                !salesReturn.getItemId().equals(salesReturn1.getItemId())) {
            salesReturn1.setItemId(salesReturn.getItemId());
        }
        if (StringUtils.isNotBlank(salesReturn.getBatchNum()) &&
                !salesReturn.getBatchNum().equals(salesReturn1.getBatchNum())) {
            salesReturn1.setBatchNum(salesReturn.getBatchNum());
        }
        if (StringUtils.isNotBlank(salesReturn.getMaterialName()) &&
                !salesReturn.getMaterialName().equals(salesReturn1.getMaterialName())) {
            salesReturn1.setMaterialName(salesReturn.getMaterialName());
        }
        if (StringUtils.isNotBlank(salesReturn.getSpecsName()) &&
                !salesReturn.getSpecsName().equals(salesReturn1.getSpecsName())) {
            salesReturn1.setSpecsName(salesReturn.getSpecsName());
        }
        if (StringUtils.isNotBlank(salesReturn.getJzfmName()) &&
                !salesReturn.getJzfmName().equals(salesReturn1.getJzfmName())) {
            salesReturn1.setJzfmName(salesReturn.getJzfmName());
        }
        if (StringUtils.isNotBlank(salesReturn.getMaterialSize()) &&
                !salesReturn.getMaterialSize().equals(salesReturn1.getMaterialSize())) {
            salesReturn1.setMaterialSize(salesReturn.getMaterialSize());
        }
        if (StringUtils.isNotBlank(salesReturn.getOuterPackingSize()) &&
                !salesReturn.getOuterPackingSize().equals(salesReturn1.getOuterPackingSize())) {
            salesReturn1.setOuterPackingSize(salesReturn.getOuterPackingSize());
        }
        if (salesReturn.getGrossWeight() != null &&
                !salesReturn.getGrossWeight().equals(salesReturn1.getGrossWeight())) {
            salesReturn1.setGrossWeight(salesReturn.getGrossWeight());
        }
        if (salesReturn.getNetWeight() != null &&
                !salesReturn.getNetWeight().equals(salesReturn1.getNetWeight())) {
            salesReturn1.setNetWeight(salesReturn.getNetWeight());
        }
        if (StringUtils.isNotBlank(salesReturn.getBackTypeName()) &&
                !salesReturn.getBackTypeName().equals(salesReturn1.getBackTypeName())) {
            salesReturn1.setBackTypeName(salesReturn.getBackTypeName());
        }
        if (StringUtils.isNotBlank(salesReturn.getBackReason()) &&
                !salesReturn.getBackReason().equals(salesReturn1.getBackReason())) {
            salesReturn1.setBackReason(salesReturn.getBackReason());
        }
        if (StringUtils.isNotBlank(salesReturn.getAlloyStateName()) &&
                !salesReturn.getAlloyStateName().equals(salesReturn1.getAlloyStateName())) {
            salesReturn1.setAlloyStateName(salesReturn.getAlloyStateName());
        }
        if (StringUtils.isNotBlank(salesReturn.getItemRemark()) &&
                !salesReturn.getItemRemark().equals(salesReturn1.getItemRemark())) {
            salesReturn1.setItemRemark(salesReturn.getItemRemark());
        }
        if (StringUtils.isNotBlank(salesReturn.getOperState()) &&
                !salesReturn.getOperState().equals(salesReturn1.getOperState())) {
            salesReturn1.setOperState(salesReturn.getOperState());
        }
        return salesReturn1;
    }
    private SaleBackOrder convert(SaleBackOrder saleBackOrder,SaleBackOrder saleBackOrder1){
        if (StringUtils.isNotBlank(saleBackOrder.getNewSalesId()) &&
                !saleBackOrder.getNewSalesId().equals(saleBackOrder1.getNewSalesId())) {
            saleBackOrder1.setNewSalesId(saleBackOrder.getNewSalesId());
        }
        if (StringUtils.isNotBlank(saleBackOrder.getDocNum()) &&
                !saleBackOrder.getDocNum().equals(saleBackOrder1.getDocNum())) {
            saleBackOrder1.setDocNum(saleBackOrder.getDocNum());
        }
        if (StringUtils.isNotBlank(saleBackOrder.getDocTime()) &&
                !saleBackOrder.getDocTime().equals(saleBackOrder1.getDocTime())) {
            saleBackOrder1.setDocTime(saleBackOrder.getDocTime());
        }
        if (StringUtils.isNotBlank(saleBackOrder.getNewAccountNo()) &&
                !saleBackOrder.getNewAccountNo().equals(saleBackOrder1.getNewAccountNo())) {
            saleBackOrder1.setNewAccountNo(saleBackOrder.getNewAccountNo());
        }
        if (StringUtils.isNotBlank(saleBackOrder.getCreatedBy()) &&
                !saleBackOrder.getCreatedBy().equals(saleBackOrder1.getCreatedBy())) {
            saleBackOrder1.setCreatedBy(saleBackOrder.getCreatedBy());
        }
        if (StringUtils.isNotBlank(saleBackOrder.getNcDepCode()) &&
                !saleBackOrder.getNcDepCode().equals(saleBackOrder1.getNcDepCode())) {
            saleBackOrder1.setNcDepCode(saleBackOrder.getNcDepCode());
        }
        if (StringUtils.isNotBlank(saleBackOrder.getUserCode()) &&
                !saleBackOrder.getUserCode().equals(saleBackOrder1.getUserCode())) {
            saleBackOrder1.setUserCode(saleBackOrder.getUserCode());
        }
        if (StringUtils.isNotBlank(saleBackOrder.getInvoiceNum()) &&
                !saleBackOrder.getInvoiceNum().equals(saleBackOrder1.getInvoiceNum())) {
            saleBackOrder1.setInvoiceNum(saleBackOrder.getInvoiceNum());
        }
        if (StringUtils.isNotBlank(saleBackOrder.getDocRemark()) &&
                !saleBackOrder.getDocRemark().equals(saleBackOrder1.getDocRemark())) {
            saleBackOrder1.setDocRemark(saleBackOrder.getDocRemark());
        }
        if (StringUtils.isNotBlank(saleBackOrder.getRcDepCode()) &&
                !saleBackOrder.getRcDepCode().equals(saleBackOrder1.getRcDepCode())) {
            saleBackOrder1.setRcDepCode(saleBackOrder.getRcDepCode());
        }
        if (StringUtils.isNotBlank(saleBackOrder.getRcLocCompCode()) &&
                !saleBackOrder.getRcLocCompCode().equals(saleBackOrder1.getRcLocCompCode())) {
            saleBackOrder1.setRcLocCompCode(saleBackOrder.getRcLocCompCode());
        }
        if (StringUtils.isNotBlank(saleBackOrder.getOperState()) &&
                !saleBackOrder.getOperState().equals(saleBackOrder1.getOperState())) {
            saleBackOrder1.setOperState(saleBackOrder.getOperState());
        }
        return saleBackOrder1;
    }
}
JavaSource/com/mandi/fendan/service/impl/SaleReturnServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,36 @@
package com.mandi.fendan.service.impl;
import com.mandi.fendan.mapper.SaleBackOrderMapper;
import com.mandi.fendan.mapper.SaleReturnMapper;
import com.mandi.fendan.persist.SalesReturn;
import com.mandi.fendan.service.SaleReturnService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class SaleReturnServiceImpl implements SaleReturnService{
    @Resource
    private SaleReturnMapper saleReturnMapper;
    @Override
    public void saveEntity(SalesReturn salesReturn) {
        saleReturnMapper.saveEntity(salesReturn);
    }
    @Override
    public SalesReturn queryById(String itemId) {
        return saleReturnMapper.queryById(itemId);
    }
    @Override
    public void updateEntity(SalesReturn convert) {
        saleReturnMapper.updateEntity(convert);
    }
    @Override
    public void deleteByItemId(String itemId) {
        saleReturnMapper.deleteByItemId(itemId);
    }
}