public void addOrdersh(Ordersh ordersh) { String ordersh_no = DateUtil.dateToDateString(new Date(), "yyyyMMddHHmmssSSS"); ordersh.setOrdersh_no(ordersh_no); double ordersh_money = Math.round(ordersh.getHouse_price() * ordersh.getHouse_count() * 10)/10.0; ordersh.setOrdersh_money(ordersh_money); ordersh.setOrdersh_flag(1);; ordersh.setOrdersh_date(DateUtil.getCurDateTime()); ordershDao.addOrdersh(ordersh); }解释一下这段代码
时间: 2024-03-07 08:53:04 浏览: 19
这段代码是一个 Java 方法,名为 addOrdersh,它接受一个 Ordersh 类型的参数 ordersh。它的作用是向数据库中添加一个订单(订单编号、订单金额、订单状态等信息)。具体实现如下:
1. 生成订单号,格式为当前时间的年月日时分秒毫秒(如:20211105151234567)。
2. 将生成的订单号设置到订单对象 ordersh 中。
3. 根据订单中的房屋单价和数量计算订单金额,并将其设置到订单对象 ordersh 中。
4. 将订单状态设置为 1,表示订单已提交。
5. 将当前时间设置为订单日期,并将其设置到订单对象 ordersh 中。
6. 调用 ordershDao 的 addOrdersh 方法,将订单对象保存到数据库中。
整段代码的作用是将客户提交的订单信息保存到数据库中。
相关问题
package main.java.reader.bean; public class BForm { String jy_id,jy_name,b_isbn,b_name; String jy_date,gh_date,is_gh; int jy_count; public String getJy_id() { return jy_id; } public void setJy_id(String jy_id) { this.jy_id = jy_id; } public String getJy_name() { return jy_name; } public void setJy_name(String jy_name) { this.jy_name = jy_name; } public String getB_isbn() { return b_isbn; } public void setB_isbn(String b_isbn) { this.b_isbn = b_isbn; } public String getB_name() { return b_name; } public void setB_name(String b_name) { this.b_name = b_name; } public String getJy_date() { return jy_date; } public void setJy_date(String jy_date) { this.jy_date = jy_date; } public String getGh_date() { return gh_date; } public void setGh_date(String string) { this.gh_date = string; } public String getIs_gh() { return is_gh; } public void setIs_gh(String is_gh) { this.is_gh = is_gh; } public int getJy_count() { return jy_count; } public void setJy_count(int jy_count) { this.jy_count = jy_count; } @Override public String toString() { return "BForm [jy_id=" + jy_id + ", jy_name=" + jy_name + ", b_isbn=" + b_isbn + ", b_name=" + b_name + ", jy_date=" + jy_date + ", gh_date=" + gh_date + "]"; } public BForm() { super(); // TODO Auto-generated constructor stub } public BForm(String jy_id, String jy_name, String b_isbn, String b_name, String jy_date, String gh_date) { super(); this.jy_id = jy_id; this.jy_name = jy_name; this.b_isbn = b_isbn; this.b_name = b_name; this.jy_date = jy_date; this.gh_date = gh_date; } }
这是一个 Java 类,名为 BForm,它具有以下属性:jy_id、jy_name、b_isbn、b_name、jy_date、gh_date、is_gh、jy_count。它还有一些 getter 和 setter 方法,用于获取和设置属性。此外,它还有一个 toString() 方法,用于将对象转换成字符串表示形式。这个类还有两个构造方法,其中一个是默认构造方法,另一个是带参数的构造方法,用于初始化对象的属性。
public class DateTimeText : MonoBehaviour { public StringBuilder StrBuilder { get; set; } = new StringBuilder(); public Text m_dateText; public Text m_timeText; public Text m_weekText; DateTime m_lastDateTime; public DateTime CurrentDateTime { get; private set; } = DateTime.Now; void Start() { if (m_dateText != null) { m_dateText.text = GetDate(); } m_lastDateTime = DateTime.Now; } private string GetDate() { return CurrentDateTime.ToString(DateTimeFormat.DateFormat); } private string GetTime() { return CurrentDateTime.ToString(DateTimeFormat.TimeFormat); } private string GetWeek() { return CurrentDateTime.ToString("dddd"); } float m_interval = 0; void Update() { CurrentDateTime=DateTime.Now; m_interval += Time.deltaTime; if (m_interval >= 0.5f) { m_interval -= 0.5f; DateTime time = CurrentDateTime; if (m_dateText != null) { if (m_lastDateTime.Day != time.Day) { m_dateText.text = GetDate(); m_lastDateTime = time; } } if (m_timeText != null) { if (m_lastDateTime.Second != time.Second) { m_timeText.text = GetTime(); m_lastDateTime = time; } } if (m_weekText!=null) { if (m_lastDateTime.DayOfWeek!=time.DayOfWeek) { m_weekText.text = GetWeek(); m_lastDateTime = time; } } } } } public class DateTimeFormat { public const string Moday = "Moday"; public const string Tuesday = "Tuesday"; public const string Wednesday = "Wednesday"; public const string Thursday = "Thursday"; public const string Friday = "Friday"; public const string Saturday = "Saturday"; public const string Sunday = "Sunday"; public const string DateFormat = "yyyy/MM/dd"; public const string TimeFormat = "HH:mm:ss"; }这段代码显示不了星期数,是什么问题,请详细说下
这段代码中定义了一个获取当前日期和时间的类 `DateTimeText`,其中包括一个获取星期数的方法 `GetWeek()`。但是在 `Update()` 方法中,判断星期数是否变化的条件语句中使用了错误的变量名,应该是 `m_lastDateTime.DayOfWeek` 而不是 `m_lastDateTime.DayOfWeek`,导致每次更新时都无法更新星期数。
正确的条件语句应该是这样的:
```csharp
if (m_weekText != null)
{
if (m_lastDateTime.DayOfWeek != time.DayOfWeek)
{
m_weekText.text = GetWeek();
m_lastDateTime = time;
}
}
```
这样就能够正确更新星期数了。